• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP exportArrayToDB函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中exportArrayToDB函数的典型用法代码示例。如果您正苦于以下问题:PHP exportArrayToDB函数的具体用法?PHP exportArrayToDB怎么用?PHP exportArrayToDB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了exportArrayToDB函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: addInfocomsForComputer

 /**
  * @param $computers_id
  * @param $date
  * @param $computer_updates
  * @return array
  */
 static function addInfocomsForComputer($computers_id, $date, $computer_updates)
 {
     global $DB;
     $infocom = new Infocom();
     $use_date = substr($date, 0, 10);
     if ($infocom->getFromDBByQuery("WHERE `items_id` = {$computers_id} AND `itemtype` = 'Computer'")) {
         if (empty($infocom->fields['use_date']) || $infocom->fields['use_date'] == 'NULL') {
             //add use_date
             $infocom->update(array('id' => $infocom->fields['id'], 'use_date' => $use_date));
         }
     } else {
         //add infocom
         $infocom->add(array('items_id' => $computers_id, 'itemtype' => 'Computer', 'use_date' => $use_date));
     }
     //Add lock
     $ocslink = new PluginOcsinventoryngOcslink();
     if ($ocslink->getFromDBforComputer($computers_id)) {
         $cfg_ocs = PluginOcsinventoryngOcsServer::getConfig($ocslink->fields["plugin_ocsinventoryng_ocsservers_id"]);
         if ($cfg_ocs["use_locks"]) {
             $computer_updates[] = "use_date";
             $query = "UPDATE `glpi_plugin_ocsinventoryng_ocslinks`\n                         SET `computer_update` = '" . addslashes(exportArrayToDB($computer_updates)) . "'\n                         WHERE `computers_id` = '{$computers_id}'";
             $DB->query($query);
         }
     }
     return $computer_updates;
 }
开发者ID:pluginsGLPI,项目名称:ocsinventoryng,代码行数:32,代码来源:ocsadmininfoslink.class.php


示例2: prepareInputForUpdate

 function prepareInputForUpdate($input)
 {
     if (isset($input['networkports_id_list']) && is_array($input['networkports_id_list'])) {
         $input['networkports_id_list'] = exportArrayToDB($input['networkports_id_list']);
     } else {
         $input['networkports_id_list'] = exportArrayToDB(array());
     }
     return parent::prepareInputForAdd($input);
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:9,代码来源:networkportaggregate.class.php


示例3: updateDurationCache

 /**
  * Update the calendar cache
  *
  * @param $calendars_id integer calendar ID
  **/
 function updateDurationCache($calendars_id)
 {
     if ($this->getFromDB($calendars_id)) {
         $input['id'] = $calendars_id;
         $input['cache_duration'] = exportArrayToDB($this->getDaysDurations());
         return $this->update($input);
     }
     return false;
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:14,代码来源:calendar.class.php


示例4: addLocks

 /**
  * Add lock fields for a record.
  *
  * @param $p_itemtype Table id.
  * @param $p_items_id Line id.
  * @param $p_fieldsToLock Array of fields to lock.
  *TODO:  check rights and entity
  *
  * @return nothing
  **/
 static function addLocks($p_itemtype, $p_items_id, $p_fieldsToLock)
 {
     global $DB;
     $tableName = getTableForItemType($p_itemtype);
     $pfl = new PluginFusioninventoryLock();
     $a_exclude = $pfl->excludeFields();
     $p_fieldsToLock = array_diff($p_fieldsToLock, $a_exclude);
     $result = PluginFusioninventoryLock::getLock($tableName, $p_items_id);
     if ($DB->numrows($result)) {
         $row = $DB->fetch_assoc($result);
         $lockedFields = importArrayFromDB($row['tablefields']);
         if (count(array_diff($p_fieldsToLock, $lockedFields))) {
             // old locks --> new locks
             $p_fieldsToLock = array_merge($p_fieldsToLock, $lockedFields);
             $a_lines = $pfl->find("`tablename`='" . $tableName . "' AND `items_id`='" . $p_items_id . "'");
             $a_line = current($a_lines);
             $pfl->getFromDB($a_line['id']);
             $pfl->fields['tablefields'] = exportArrayToDB($p_fieldsToLock);
             $pfl->update($pfl->fields);
         }
     } elseif (count($p_fieldsToLock)) {
         // no locks --> new locks
         $input = array();
         $input['tablename'] = $tableName;
         $input['items_id'] = $p_items_id;
         $input['tablefields'] = exportArrayToDB($p_fieldsToLock);
         $pfl->add($input);
     }
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:39,代码来源:lock.class.php


示例5: prepareRun


//.........这里部分代码省略.........
                 $a_devicesubnet[$ip_subnet]['Printer'][$items_id] = 1;
             }
         }
         $a_agentsubnet = array();
         foreach ($a_subnet as $subnet => $num) {
             $a_agentList = $this->getAgentsSubnet($num, $communication, $subnet);
             if (!isset($a_agentList)) {
                 $a_agentsubnet[$subnet] = '';
             } else {
                 $a_agentsubnet[$subnet] = $a_agentList;
             }
         }
         $a_input = array();
         $a_input['plugin_fusioninventory_taskjobs_id'] = $taskjobs_id;
         $a_input['state'] = 1;
         $a_input['plugin_fusioninventory_agents_id'] = 0;
         $a_input['itemtype'] = '';
         $a_input['items_id'] = 0;
         $a_input['uniqid'] = $uniqid;
         $a_input['execution_id'] = $task->fields['execution_id'];
         $taskvalid = 0;
         foreach ($a_agentsubnet as $subnet => $a_agentList) {
             if (!isset($a_agentList) or isset($a_agentList) && is_array($a_agentList) && count($a_agentList) == '0' or isset($a_agentList) && !is_array($a_agentList) && $a_agentList == '') {
                 // No agent available for this subnet
                 for ($i = 0; $i < 2; $i++) {
                     $itemtype = 'Printer';
                     if ($i == '0') {
                         $itemtype = 'NetworkEquipment';
                     }
                     if (isset($a_devicesubnet[$subnet][$itemtype])) {
                         foreach ($a_devicesubnet[$subnet][$itemtype] as $items_id => $num) {
                             $a_input['itemtype'] = $itemtype;
                             $a_input['items_id'] = $items_id;
                             $a_input['specificity'] = exportArrayToDB($a_specificity['DEVICE'][$itemtype . $items_id]);
                             $Taskjobstates_id = $pfTaskjobstate->add($a_input);
                             //Add log of taskjob
                             $a_input['plugin_fusioninventory_taskjobstates_id'] = $Taskjobstates_id;
                             $a_input['state'] = 7;
                             $a_input['date'] = date("Y-m-d H:i:s");
                             $pfTaskjoblog->add($a_input);
                             $pfTaskjobstate->changeStatusFinish($Taskjobstates_id, 0, '', 1, "Unable to find agent to inventory " . "this " . $itemtype, 0, 0);
                             $a_input['state'] = 1;
                         }
                     }
                 }
             } else {
                 // add taskjobstate
                 $count_device_subnet = 0;
                 if (isset($a_devicesubnet[$subnet]['NetworkEquipment'])) {
                     $count_device_subnet += count($a_devicesubnet[$subnet]['NetworkEquipment']);
                 }
                 if (isset($a_devicesubnet[$subnet]['Printer'])) {
                     $count_device_subnet += count($a_devicesubnet[$subnet]['Printer']);
                 }
                 $nb_devicebyagent = ceil($count_device_subnet / count($a_agentList));
                 $nbagent = 0;
                 $agent_id = array_pop($a_agentList);
                 $a_input['state'] = 0;
                 for ($i = 0; $i < 2; $i++) {
                     $itemtype = 'Printer';
                     if ($i == '0') {
                         $itemtype = 'NetworkEquipment';
                     }
                     if (isset($a_devicesubnet[$subnet][$itemtype])) {
                         foreach ($a_devicesubnet[$subnet][$itemtype] as $items_id => $num) {
                             $a_input['itemtype'] = $itemtype;
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:67,代码来源:networkinventory.class.php


示例6: prepareInputForAdd

 function prepareInputForAdd($input)
 {
     if (isset($input["helpdesk_item_type"])) {
         $input["helpdesk_item_type"] = exportArrayToDB($input["helpdesk_item_type"]);
     }
     $this->profileRight = array();
     foreach (ProfileRight::getAllPossibleRights() as $right => $default) {
         if (isset($input[$right])) {
             $this->profileRight[$right] = $input[$right];
             unset($input[$right]);
         }
     }
     return $input;
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:14,代码来源:profile.class.php


示例7: FusionUnknownKnownDevice

 function FusionUnknownKnownDevice()
 {
     global $DB;
     $query = "SELECT *\n                FROM `glpi_networking_ports`\n                WHERE `ifmac` != ''\n                      AND `ifmac` != '00:00:00:00:00:00'\n                      AND `device_type`=" . PLUGIN_FUSIONINVENTORY_MAC_UNKNOWN . "\n                GROUP BY `ifmac`\n                HAVING COUNT(*)>0;";
     if ($result = $DB->query($query)) {
         while ($data = $DB->fetch_array($result)) {
             // $data = ID of unknown device
             $query_known = "SELECT *\n                            FROM `glpi_networking_ports`\n                            WHERE `ifmac` IN ('" . $data["ifmac"] . "','" . strtoupper($data["ifmac"]) . "',\n                                              '" . strtolower($data["ifmac"]) . "')\n                                  AND `device_type`!=" . PLUGIN_FUSIONINVENTORY_MAC_UNKNOWN . "\n                            LIMIT 0,1;";
             $result_known = $DB->query($query_known);
             if ($DB->numrows($result_known) > 0) {
                 $data_known = $DB->fetch_array($result_known);
                 $query_update = "UPDATE `glpi_networking_ports`\n                                SET `on_device`='" . $data_known["on_device"] . "',\n                                    `device_type='" . $data_known["device_type"] . "',\n                                    `logical_number`='" . $data_known["logical_number"] . "',\n                                    `name`='" . $data_known["name"] . "',\n                                    `ifaddr`='" . $data_known["ifaddr"] . "',\n                                    `iface`='" . $data_known["iface"] . "',\n                                    `netpoint`='" . $data_known["netpoint"] . "',\n                                    `netmask`='" . $data_known["netmask"] . "',\n                                    `gateway`='" . $data_known["gateway"] . "',\n                                    `subnet`='" . $data_known["subnet"] . "'\n                                  WHERE `ID`='" . $data["ID"] . "';";
                 $DB->query($query_update);
                 // Delete old networking port
                 $this->deleteFromDB($data_known["ID"], 1);
                 // Delete unknown device
                 $this->deleteFromDB($data["on_device"], 1);
                 // Modify OCS link of this networking port
                 $query = "SELECT *\n                         FROM `glpi_ocs_link`\n                         WHERE `glpi_id`='" . $data_known["on_device"] . "';";
                 $result = $DB->query($query);
                 if ($DB->numrows($result) == 1) {
                     $line = $DB->fetch_assoc($result);
                     $import_ip = importArrayFromDB($line["import_ip"]);
                     $ip_port = $import_ip[$data_known["ID"]];
                     unset($import_ip[$data_known["ID"]]);
                     $import_ip[$data["ID"]] = $ip_port;
                     $query_update = "UPDATE `glpi_ocs_link`\n                                   SET `import_ip`='" . exportArrayToDB($import_ip) . "'\n                                   WHERE `glpi_id`='" . $line["ID"] . "';";
                     $DB->query($query_update);
                 }
             }
         }
     }
 }
开发者ID:Hawke,项目名称:fusioninventory-for-glpi,代码行数:33,代码来源:unknowndevice.class.php


示例8: updateDisplayOptions

 /**
  * Update $_SESSION to set the display options.
  *
  * @since version 0.84
  *
  * @param $input         array   of data to update
  * @param $sub_itemtype  string  sub itemtype if needed (default '')
  *
  * @return nothing
  **/
 static function updateDisplayOptions($input = array(), $sub_itemtype = '')
 {
     $options = static::getAvailableDisplayOptions();
     if (count($options)) {
         if (empty($sub_itemtype)) {
             $display_options =& $_SESSION['glpi_display_options'][self::getType()];
         } else {
             $display_options =& $_SESSION['glpi_display_options'][self::getType()][$sub_itemtype];
         }
         // reset
         if (isset($input['reset'])) {
             foreach ($options as $option_group_name => $option_group) {
                 foreach ($option_group as $option_name => $attributs) {
                     $display_options[$option_name] = $attributs['default'];
                 }
             }
         } else {
             foreach ($options as $option_group_name => $option_group) {
                 foreach ($option_group as $option_name => $attributs) {
                     if (isset($input[$option_name]) && $_GET[$option_name] == 'on') {
                         $display_options[$option_name] = true;
                     } else {
                         $display_options[$option_name] = false;
                     }
                 }
             }
         }
         // Store new display options for user
         if ($uid = Session::getLoginUserID()) {
             $user = new User();
             if ($user->getFromDB($uid)) {
                 $user->update(array('id' => $uid, 'display_options' => exportArrayToDB($_SESSION['glpi_display_options'])));
             }
         }
     }
 }
开发者ID:korial29,项目名称:glpi,代码行数:46,代码来源:commonglpi.class.php


示例9: prepareInputForAdd

 /**
  * Gère la transformation des inputs multiples en quelque chose d'inserable dans la base (en l'occurence une chaine json).
  * .
  *
  * @see CommonDBTM::prepareInputForAdd()
  */
 final function prepareInputForAdd($input)
 {
     foreach (self::getConfigParams() as $param => $desc) {
         if (isset($input[$param]) && isset($desc['multiple']) && $desc['multiple']) {
             $input[$param] = exportArrayToDB($input[$param]);
         }
     }
     return $input;
 }
开发者ID:Etiennef,项目名称:configmanager,代码行数:15,代码来源:rule.class.php


示例10: saveDatas

 function saveDatas($params)
 {
     global $DB;
     $tasks_id = $params['tasks_id'];
     $tasks = json_decode($params['tasks']);
     //remove old jobs from task
     $query = "DELETE FROM " . $this->getTable() . "\n      WHERE plugin_fusioninventory_deploytasks_id = '" . $tasks_id . "'";
     $res = $DB->query($query);
     //get plugin id
     $plug = new Plugin();
     $plug->getFromDBbyDir('fusinvdeploy');
     $plugins_id = $plug->getField('id');
     //insert new rows
     $sql_tasks = array();
     $i = 0;
     foreach ($tasks as $task) {
         $task = get_object_vars($task);
         //encode action and definition
         //$action = exportArrayToDB(array(array(
         //    $task['action_type'] => $task['action_selection'])));
         $action = exportArrayToDB($task['action']);
         $definition = exportArrayToDB(array(array('PluginFusioninventoryDeployPackage' => $task['package_id'])));
         $sql_tasks[] = "INSERT INTO " . $this->getTable() . "\n         (\n            plugin_fusioninventory_deploytasks_id, name, date_creation, entities_id,\n            plugins_id, method, definition, action,\n            retry_nb, retry_time, periodicity_type, periodicity_count\n         ) VALUES (\n            '{$tasks_id}', 'job_" . $tasks_id . "_{$i}', NOW(), '0',\n            '{$plugins_id}', '" . $task['method'] . "', '{$definition}', '{$action}',\n            '" . $task['retry_nb'] . "', '" . $task['retry_time'] . "', 'minutes', '0'\n         )";
         $i++;
     }
     foreach ($sql_tasks as $query) {
         $res = $DB->query($query);
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:29,代码来源:deploytaskjob.class.php


示例11: addToOcsArray

 static function addToOcsArray($computers_id, $toadd, $field)
 {
     global $DB;
     $query = "SELECT `{$field}`\n                FROM `glpi_plugin_ocsinventoryng_ocslinks`\n                WHERE `computers_id` = '{$computers_id}'";
     if ($result = $DB->query($query)) {
         if ($DB->numrows($result)) {
             $tab = importArrayFromDB($DB->result($result, 0, 0));
             // Stripslashes because importArray get clean array
             foreach ($toadd as $key => $val) {
                 $tab[$key] = stripslashes($val);
             }
             $query = "UPDATE `glpi_plugin_ocsinventoryng_ocslinks`\n                      SET `{$field}` = '" . addslashes(exportArrayToDB($tab)) . "'\n                      WHERE `computers_id` = '{$computers_id}'";
             $DB->query($query);
         }
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:16,代码来源:ocsserver.class.php


示例12: deleteGaugeItems

 function deleteGaugeItems($array)
 {
     $this->getFromDB($array['id']);
     $aggregate_items = importArrayFromDB($this->fields['aggregate_items']);
     $split = explode('|', $array['delete_item']);
     if (count($split) == 5) {
         unset($aggregate_items[$split[0]][$split[1]][$split[2]][$split[3]][$split[4]]);
         if (count($aggregate_items[$split[0]][$split[1]][$split[2]][$split[3]]) == 0) {
             unset($aggregate_items[$split[0]][$split[1]][$split[2]][$split[3]]);
             if (count($aggregate_items[$split[0]][$split[1]][$split[2]]) == 0) {
                 unset($aggregate_items[$split[0]][$split[1]][$split[2]]);
                 if (count($aggregate_items[$split[0]][$split[1]]) == 0) {
                     unset($aggregate_items[$split[0]][$split[1]]);
                     if (count($aggregate_items[$split[0]]) == 0) {
                         unset($aggregate_items[$split[0]]);
                     }
                 }
             }
         }
     }
     $input = array('id' => $array['id'], 'aggregate_items' => exportArrayToDB($aggregate_items));
     $this->update($input);
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:23,代码来源:customitem_gauge.class.php


示例13: array

      $input = array();
      $pmComponentscatalog->getFromDB($_POST['plugin_monitoring_componentscalalog_id']);
      $input['id'] = $_POST['id'];
      $input['entities_id'] = $pmComponentscatalog->fields['entities_id'];
      $input['is_recursive'] = $pmComponentscatalog->fields['is_recursive'];
      $input['name'] = $_POST['name'];
      $input['itemtype'] = $_POST['itemtype'];
      $input['plugin_monitoring_componentscalalog_id'] = $_POST['plugin_monitoring_componentscalalog_id'];
      unset($_POST['entities_id']);
      unset($_POST['is_recursive']);
      unset($_POST['name']);
      unset($_POST['updaterule']);
      unset($_POST['itemtypen']);
      unset($_POST['plugin_monitoring_componentscalalog_id']);
      unset($_POST['id']);
      $input['condition'] = exportArrayToDB($_POST);
      $pmComponentscatalog_rule->update($input);
      unset($_SESSION['plugin_monitoring_rules']);
      unset($_SESSION["glpisearch"][$input['itemtype']]);
      Html::redirect($CFG_GLPI['root_doc']."/plugins/monitoring/front/componentscatalog.form.php?id=".$input['plugin_monitoring_componentscalalog_id']);

   }
} else if (isset($_GET['deleterule'])) {
   $_POST = $_GET;
   $pmComponentscatalog_rule->delete($_POST);
   Html::redirect($CFG_GLPI['root_doc']."/plugins/monitoring/front/componentscatalog.form.php?id=".$_POST['plugin_monitoring_componentscalalog_id']);
} else if (isset($_GET['contains'])
        OR isset($_GET['reset'])) {
//   if (isset($_SESSION['plugin_monitoring_rules'])) {
//      unset($_SESSION['plugin_monitoring_rules']);
//   }
开发者ID:euqip,项目名称:glpi-smartcities,代码行数:31,代码来源:componentscatalog_rule.form.php


示例14: moveBookmark

 /**
  * Move a bookmark in an ordered collection
  *
  * @since version 0.85
  *
  * @param $items    array      of the rules ID to move
  * @param $ref_ID   integer    of the rule position  (0 means all, so before all or after all)
  * @param $action   string     of move : after or before ( default 'after')
  *
  * @return true if all ok
  **/
 function moveBookmark($items = array(), $ref_ID, $action = 'after')
 {
     global $DB;
     if (count($items)) {
         // Clean IDS : drop ref_ID
         if (isset($items[$ref_ID])) {
             unset($items[$ref_ID]);
         }
         $user = new User();
         $personalorderfield = 'privatebookmarkorder';
         if ($user->getFromDB(Session::getLoginUserID())) {
             $personalorder = importArrayFromDB($user->fields[$personalorderfield]);
         }
         if (!is_array($personalorder)) {
             return false;
         }
         $newpersonalorder = array();
         foreach ($personalorder as $val) {
             // Found item
             if ($val == $ref_ID) {
                 // Add after so add ref ID
                 if ($action == 'after') {
                     $newpersonalorder[] = $ref_ID;
                 }
                 foreach ($items as $val2) {
                     $newpersonalorder[] = $val2;
                 }
                 if ($action == 'before') {
                     $newpersonalorder[] = $ref_ID;
                 }
             } else {
                 if (!isset($items[$val])) {
                     $newpersonalorder[] = $val;
                 }
             }
         }
         $user->update(array('id' => Session::getLoginUserID(), $personalorderfield => exportArrayToDB($newpersonalorder)));
         return true;
     }
     return false;
 }
开发者ID:pvasener,项目名称:glpi,代码行数:52,代码来源:bookmark.class.php


示例15: savePlanningsInDB

 static function savePlanningsInDB()
 {
     $user = new User();
     $user->update(array('id' => $_SESSION['glpiID'], 'plannings' => exportArrayToDB($_SESSION['glpi_plannings'])));
 }
开发者ID:korial29,项目名称:glpi,代码行数:5,代码来源:planning.class.php


示例16: update0782to080

/**
 * Update from 0.78.2 to 0.80
 *
 * @return bool for success (will die for most error)
**/
function update0782to080()
{
    global $DB, $migration;
    $updateresult = true;
    $ADDTODISPLAYPREF = array();
    //TRANS: %s is the number of new version
    $migration->displayTitle(sprintf(__('Update to %s'), '0.80'));
    $migration->setVersion('0.80');
    $backup_tables = false;
    $newtables = array('glpi_calendars', 'glpi_calendars_holidays', 'glpi_calendarsegments', 'glpi_computervirtualmachines', 'glpi_computers_softwarelicenses', 'glpi_fieldblacklists', 'glpi_fieldunicities', 'glpi_groups_tickets', 'glpi_holidays', 'glpi_rulecacheprinters', 'glpi_slas', 'glpi_slalevels', 'glpi_slalevels_tickets', 'glpi_slalevelactions', 'glpi_tickets_tickets', 'glpi_tickets_users', 'glpi_ticketsatisfactions', 'glpi_ticketsolutiontemplates', 'glpi_virtualmachinestates', 'glpi_virtualmachinesystems', 'glpi_virtualmachinetypes');
    foreach ($newtables as $new_table) {
        // rename new tables if exists ?
        if (TableExists($new_table)) {
            if (TableExists("backup_{$new_table}")) {
                $query = "DROP TABLE `backup_" . $new_table . "`";
                $DB->queryOrDie($query, "0.80 drop backup table backup_{$new_table}");
            }
            $migration->displayWarning("{$new_table} table already exists. " . "A backup have been done to backup_{$new_table}.");
            $backup_tables = true;
            $query = $migration->renameTable("{$new_table}", "backup_{$new_table}");
        }
    }
    if ($backup_tables) {
        $migration->displayWarning("You can delete backup tables if you have no need of them.", true);
    }
    $migration->displayMessage(sprintf(__('Change of the database layout - %s'), 'Calendar'));
    // Updating schema
    $default_calendar_id = 0;
    if (!TableExists('glpi_calendars')) {
        $query = "CREATE TABLE `glpi_calendars` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `name` varchar(255) default NULL,\n                  `entities_id` int(11) NOT NULL default '0',\n                  `is_recursive` tinyint(1) NOT NULL default '0',\n                  `comment` TEXT DEFAULT NULL ,\n                  `date_mod` DATETIME DEFAULT NULL ,\n                  `cache_duration` TEXT DEFAULT NULL ,\n                  PRIMARY KEY  (`id`),\n                  KEY `name` (`name`),\n                  KEY `entities_id` (`entities_id`),\n                  KEY `is_recursive` (`is_recursive`),\n                  KEY `date_mod` (`date_mod`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDie($query, "0.80 create glpi_calendars");
        $ADDTODISPLAYPREF['Calendar'] = array(19);
        // Create default calendar : use existing config planning_begin _end
        $query = "INSERT INTO `glpi_calendars`\n                       (`name`, `entities_id`, `is_recursive`, `comment`)\n                VALUES ('Default', 0, 1, 'Default calendar');";
        $DB->queryOrDie($query, "0.80 add default glpi_calendars");
        $default_calendar_id = $DB->insert_id();
    }
    if (!TableExists('glpi_calendarsegments')) {
        $query = "CREATE TABLE `glpi_calendarsegments` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `calendars_id` int(11) NOT NULL default '0',\n                  `entities_id` int(11) NOT NULL default '0',\n                  `is_recursive` tinyint(1) NOT NULL default '0',\n                  `day` tinyint(1) NOT NULL default '1' COMMENT 'numer of the day based on date(w)',\n                  `begin` time DEFAULT NULL,\n                  `end` time DEFAULT NULL,\n                  PRIMARY KEY  (`id`),\n                  KEY `calendars_id` (`calendars_id`),\n                  KEY `day` (`day`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDie($query, "0.80 create glpi_calendarsegments");
        // add defautl days : from monday to friday
        if ($default_calendar_id > 0) {
            $query = "SELECT `planning_begin`, `planning_end`\n                   FROM `glpi_configs`\n                   WHERE `id` = '1'";
            if ($result = $DB->query($query)) {
                $begin = $DB->result($result, 0, 'planning_begin');
                $end = $DB->result($result, 0, 'planning_end');
                if ($begin < $end) {
                    for ($i = 1; $i < 6; $i++) {
                        $query = "INSERT INTO `glpi_calendarsegments`\n                                   (`calendars_id`, `day`, `begin`, `end`)\n                            VALUES ({$default_calendar_id}, {$i}, '{$begin}', '{$end}')";
                        $DB->queryOrDie($query, "0.80 add default glpi_calendarsegments");
                    }
                }
            }
            // Update calendar
            $calendar = new Calendar();
            if ($calendar->getFromDB($default_calendar_id)) {
                $query = "UPDATE `glpi_calendars`\n                      SET `cache_duration` = '" . exportArrayToDB($calendar->getDaysDurations()) . "'\n                      WHERE `id` = '{$default_calendar_id}'";
                $DB->queryOrDie($query, "0.80 update default calendar cache");
            }
        }
    }
    // Holidays : wrong management : may be a group of several days : will be easy to managed holidays
    if (!TableExists('glpi_holidays')) {
        $query = "CREATE TABLE `glpi_holidays` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `name` varchar(255) default NULL,\n                  `entities_id` int(11) NOT NULL default '0',\n                  `is_recursive` tinyint(1) NOT NULL default '0',\n                  `comment` TEXT DEFAULT NULL ,\n                  `begin_date` date default NULL,\n                  `end_date` date default NULL,\n                  `is_perpetual` tinyint(1) NOT NULL default '0',\n                  PRIMARY KEY  (`id`),\n                  KEY `name` (`name`),\n                  KEY `begin_date` (`begin_date`),\n                  KEY `end_date` (`end_date`),\n                  KEY `is_perpetual` (`is_perpetual`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDie($query, "0.80 create glpi_holidays");
        $ADDTODISPLAYPREF['Holiday'] = array(11, 12, 13);
    }
    if (!TableExists('glpi_calendars_holidays')) {
        $query = "CREATE TABLE `glpi_calendars_holidays` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `calendars_id` int(11) NOT NULL default '0',\n                  `holidays_id` int(11) NOT NULL default '0',\n                  PRIMARY KEY  (`id`),\n                  UNIQUE KEY `unicity` (`calendars_id`,`holidays_id`),\n                  KEY `holidays_id` (`holidays_id`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDie($query, "0.80 create glpi_calendars_holidays");
    }
    $migration->displayMessage(sprintf(__('Change of the database layout - %s'), 'SLA'));
    // Updating schema
    if (!TableExists('glpi_slas')) {
        $query = "CREATE TABLE `glpi_slas` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `name` varchar(255) default NULL,\n                  `entities_id` int(11) NOT NULL default '0',\n                  `is_recursive` tinyint(1) NOT NULL default '0',\n                  `comment` TEXT DEFAULT NULL ,\n                  `resolution_time` int(11) NOT NULL,\n                  `calendars_id` int(11) NOT NULL default '0',\n                  `date_mod` datetime default NULL,\n                  PRIMARY KEY  (`id`),\n                  KEY `name` (`name`),\n                  KEY `calendars_id` (`calendars_id`),\n                  KEY `entities_id` (`entities_id`),\n                  KEY `is_recursive` (`is_recursive`),\n                  KEY `date_mod` (`date_mod`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDie($query, "0.80 create glpi_slas");
        $ADDTODISPLAYPREF['SLA'] = array(4);
        // Get first Ticket template
        $query = "SELECT `id`\n                FROM `glpi_notificationtemplates`\n                WHERE `itemtype` LIKE 'Ticket%'\n                ORDER BY `id` ASC";
        if ($result = $DB->query($query)) {
            if ($DB->numrows($result) > 0) {
                $query = "INSERT INTO `glpi_notifications`\n                             (`name`, `entities_id`, `itemtype`, `event`, `mode`,\n                              `notificationtemplates_id`, `comment`, `is_recursive`, `is_active`,\n                              `date_mod`)\n                      VALUES ('Ticket Recall', 0, 'Ticket', 'recall', 'mail',\n                              " . $DB->result($result, 0, 0) . ", '', 1, 1,\n                              NOW());";
                $DB->queryOrDie($query, "0.80 insert notification");
            }
        }
    }
    if (!TableExists('glpi_slalevels')) {
        $query = "CREATE TABLE `glpi_slalevels` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `name` varchar(255) collate utf8_unicode_ci default NULL,\n                  `slas_id` int(11) NOT NULL default '0',\n                  `execution_time` int(11) NOT NULL,\n                  `is_active` tinyint(1) NOT NULL default '1',\n                  PRIMARY KEY  (`id`),\n                  KEY `name` (`name`),\n                  KEY `is_active` (`is_active`),\n                  KEY `slas_id` (`slas_id`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDie($query, "0.80 create glpi_slalevels");
    }
    if (!TableExists('glpi_slalevelactions')) {
        $query = "CREATE TABLE `glpi_slalevelactions` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `slalevels_id` int(11) NOT NULL default '0',\n                  `action_type` varchar(255) collate utf8_unicode_ci default NULL,\n                  `field` varchar(255) collate utf8_unicode_ci default NULL,\n                  `value` varchar(255) collate utf8_unicode_ci default NULL,\n                  PRIMARY KEY  (`id`),\n                  KEY `slalevels_id` (`slalevels_id`)\n                ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;";
        $DB->queryOrDie($query, "0.80 create glpi_slalevelactions");
    }
    $migration->addField("glpi_profiles", "calendar", "CHAR( 1 ) NULL", array('update' => "`entity_dropdown`"));
//.........这里部分代码省略.........
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:101,代码来源:update_0782_080.php


示例17: updateNetworkFramework


//.........这里部分代码省略.........
    }
    $migration->displayMessage(sprintf(__('Change of the database layout - %s'), "glpi_networkportdialups"));
    // Adding NetworkPortDialup table
    if (!TableExists('glpi_networkportdialups')) {
        $query = "CREATE TABLE `glpi_networkportdialups` (\n                  `id` int(11) NOT NULL AUTO_INCREMENT,\n                  `networkports_id` int(11) NOT NULL DEFAULT '0',\n                  PRIMARY KEY (`id`),\n                  UNIQUE KEY `networkports_id` (`networkports_id`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDie($query, "0.84 create glpi_networkportdialups");
        $port = new NetworkPortDialup();
        updateNetworkPortInstantiation($port, array(), true);
    }
    $migration->displayMessage(sprintf(__('Change of the database layout - %s'), "glpi_networkportaggregates"));
    // Adding NetworkPortAggregate table
    if (!TableExists('glpi_networkportaggregates')) {
        $query = "CREATE TABLE `glpi_networkportaggregates` (\n                  `id` int(11) NOT NULL AUTO_INCREMENT,\n                  `networkports_id` int(11) NOT NULL DEFAULT '0',\n                  `networkports_id_list` TEXT DEFAULT NULL\n                             COMMENT 'array of associated networkports_id',\n                  PRIMARY KEY (`id`),\n                  UNIQUE KEY `networkports_id` (`networkports_id`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDie($query, "0.84 create glpi_networkportaggregates");
        // Transform NetworkEquipment local MAC address as a networkport that aggregates all ports
        $query = "SELECT *\n                FROM `origin_glpi_networkequipments`\n                WHERE `mac` != ''\n                      OR `ip` != ''";
        $port_input = array('itemtype' => 'NetworkEquipment', 'logical_number' => '0', 'name' => 'management', 'instantiation_type' => 'NetworkPortAggregate');
        foreach ($DB->request($query) as $equipment) {
            $networkequipments_id = $equipment['id'];
            $query = "SELECT `id`, `ip`, `mac`\n                   FROM `origin_glpi_networkports`\n                   WHERE `itemtype` = 'NetworkEquipment'\n                         AND `items_id` = '{$networkequipments_id}'\n                         AND (`ip` = '" . $equipment['ip'] . "'\n                              OR `mac` = '" . $equipment['mac'] . "')";
            $both = array();
            $mac = array();
            $ip = array();
            foreach ($DB->request($query) as $ports) {
                if ($ports['ip'] == $equipment['ip']) {
                    if ($ports['mac'] == $equipment['mac']) {
                        $both[] = $ports['id'];
                    } else {
                        $ip[] = $ports['id'];
                    }
                } else {
                    $mac[] = $ports['id'];
                }
            }
            if (count($both) != 1) {
                // Only add a NetworkPort if there is 0 or more than one element !
                $port_input['items_id'] = $networkequipments_id;
                $port_input['entities_id'] = $equipment['entities_id'];
                $port_input['is_recursive'] = $equipment['is_recursive'];
                $port_input['mac'] = strtolower($equipment['mac']);
                $networkports_id = $migration->insertInTable('glpi_networkports', $port_input);
                $aggregate_input = array();
                $aggregate_input['networkports_id'] = $networkports_id;
                $aggregate_input['networkports_id_list'] = exportArrayToDB($both);
                $migration->insertInTable('glpi_networkportaggregates', $aggregate_input);
                createNetworkNameFromItem('NetworkPort', $networkports_id, $equipment['id'], 'NetworkEquipment', $equipment['entities_id'], $equipment['ip']);
                foreach ($both as $aggregated_networkports_id) {
                    $query = "DELETE\n                         FROM `glpi_networknames`\n                         WHERE `itemtype` = 'NetworkPort'\n                               AND `items_id` = '{$aggregated_networkports_id}'";
                    $DB->query($query);
                    $query = "UPDATE `glpi_networkports`\n                         SET `mac` = ''\n                         WHERE `id` = '{$aggregated_networkports_id}'";
                    $DB->query($query);
                }
            }
        }
    }
    $migration->displayMessage(sprintf(__('Change of the database layout - %s'), "glpi_networkportaliases"));
    // Adding NetworkPortAlias table
    if (!TableExists('glpi_networkportaliases')) {
        $query = "CREATE TABLE `glpi_networkportaliases` (\n                  `id` int(11) NOT NULL AUTO_INCREMENT,\n                  `networkports_id` int(11) NOT NULL DEFAULT '0',\n                  `networkports_id_alias` int(11) NOT NULL DEFAULT '0',\n                  PRIMARY KEY (`id`),\n                  UNIQUE KEY `networkports_id` (`networkports_id`),\n                  KEY `networkports_id_alias` (`networkports_id_alias`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDie($query, "0.84 create glpi_networkportaliases");
        // New element, so, we don't need to create items
    }
    $migration->addField('glpi_networkports_vlans', 'tagged', 'bool', array('value' => '0'));
    $migration->addField('glpi_vlans', 'entities_id', 'integer', array('value' => '0', 'after' => 'id'));
    $migration->addKey('glpi_vlans', 'entities_id');
    $migration->addField('glpi_vlans', 'is_recursive', 'bool', array('value' => '0', 'after' => 'entities_id', 'update' => '1'));
    $migration->addKey('glpi_vlans', 'tag');
    $migration->displayMessage(sprintf(__('Data migration - %s'), 'Update connections between IPAddress and IPNetwork'));
    // Here, we are sure that there is only IPv4 addresses. So, the SQL requests are simplified
    $query = "SELECT `id`, `address_3`, `netmask_3`\n             FROM `glpi_ipnetworks`";
    if ($network_result = $DB->query($query)) {
        unset($query);
        while ($ipnetwork_row = $DB->fetch_assoc($network_result)) {
            $ipnetworks_id = $ipnetwork_row['id'];
            $netmask = floatval($ipnetwork_row['netmask_3']);
            $address = floatval($ipnetwork_row['address_3']) & $netmask;
            $query = "SELECT `id`\n                   FROM `glpi_ipaddresses`\n                   WHERE (`glpi_ipaddresses`.`binary_3` & '{$netmask}') = {$address}\n                         AND `glpi_ipaddresses`.`version` = '4'\n                   GROUP BY `items_id`";
            if ($ipaddress_result = $DB->query($query)) {
                unset($query);
                while ($link = $DB->fetch_assoc($ipaddress_result)) {
                    $query = "INSERT INTO `glpi_ipaddresses_ipnetworks`\n                                (`ipaddresses_id`, `ipnetworks_id`)\n                         VALUES ('" . $link['id'] . "', '{$ipnetworks_id}')";
                    $DB->query($query);
                    unset($query);
                }
            }
        }
    }
    $migration->displayMessage(sprintf(__('Change of the database layout - %s'), 'Drop table glpi_networkportmigrations if empty'));
    if (countElementsInTable("glpi_networkportmigrations") == 0) {
        $migration->dropTable("glpi_networkportmigrations");
        $migration->dropTable("glpi_networkportinterfaces");
        unset($ADDTODISPLAYPREF['Ne 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP exportDataToXML函数代码示例发布时间:2022-05-15
下一篇:
PHP export函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap