當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Item_Devices類代碼示例

本文整理匯總了PHP中Item_Devices的典型用法代碼示例。如果您正苦於以下問題:PHP Item_Devices類的具體用法?PHP Item_Devices怎麽用?PHP Item_Devices使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Item_Devices類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: pdfDevice

 static function pdfDevice(PluginPdfSimplePDF $pdf, Computer $computer)
 {
     global $DB;
     $devtypes = Item_Devices::getDeviceTypes();
     $ID = $computer->getField('id');
     if (!$computer->can($ID, 'r')) {
         return false;
     }
     $pdf->setColumnsSize(100);
     $pdf->displayTitle('<b>' . Toolbox::ucfirst(_n('Component', 'Components', 2)) . '</b>');
     $pdf->setColumnsSize(3, 14, 42, 41);
     foreach ($devtypes as $itemtype) {
         $devicetypes = new $itemtype();
         $specificities = $devicetypes->getSpecificities();
         $specif_fields = array_keys($specificities);
         $specif_text = implode(',', $specif_fields);
         if (!empty($specif_text)) {
             $specif_text = " ," . $specif_text . " ";
         }
         $associated_type = str_replace('Item_', '', $itemtype);
         $linktable = getTableForItemType($itemtype);
         $fk = getForeignKeyFieldForTable(getTableForItemType($associated_type));
         $query = "SELECT count(*) AS NB, `id`, `" . $fk . "`" . $specif_text . "\n                   FROM `" . $linktable . "`\n                   WHERE `items_id` = '" . $ID . "'\n                   AND `itemtype` = 'Computer'\n                   GROUP BY `" . $fk . "`" . $specif_text;
         $device = new $associated_type();
         foreach ($DB->request($query) as $data) {
             if ($device->getFromDB($data[$fk])) {
                 $spec = $device->getAdditionalFields();
                 $col4 = '';
                 if (count($spec)) {
                     $colspan = 60 / count($spec);
                     foreach ($spec as $i => $label) {
                         if (isset($device->fields[$label["name"]]) && !empty($device->fields[$label["name"]])) {
                             if ($label["type"] == "dropdownValue" && $device->fields[$label["name"]] != 0) {
                                 $table = getTableNameForForeignKeyField($label["name"]);
                                 $value = Dropdown::getDropdownName($table, $device->fields[$label["name"]]);
                                 $col4 .= '<b><i>' . sprintf(__('%1$s: %2$s'), $label["label"] . '</i></b>', Html::clean($value) . " ");
                             } else {
                                 $value = $device->fields[$label["name"]];
                                 $col4 .= '<b><i>' . sprintf(__('%1$s: %2$s'), $label["label"] . '</i></b>', $value . " ");
                             }
                         } else {
                             if (isset($device->fields[$label["name"] . "_default"]) && !empty($device->fields[$label["name"] . "_default"])) {
                                 $col4 .= '<b><i>' . sprintf(__('%1$s: %2$s'), $label["label"] . '</i></b>', $device->fields[$label["name"] . "_default"] . " ");
                             }
                         }
                     }
                 }
                 $pdf->displayLine($data['NB'], $device->getTypeName(), $device->getName(), $col4);
             }
         }
     }
     $pdf->displaySpace();
 }
開發者ID:geldarr,項目名稱:hack-space,代碼行數:53,代碼來源:computer.class.php

示例2: cleanDBonPurge

 function cleanDBonPurge()
 {
     $csv = new Computer_SoftwareVersion();
     $csv->cleanDBonItemDelete('Computer', $this->fields['id']);
     $csl = new Computer_SoftwareLicense();
     $csl->cleanDBonItemDelete('Computer', $this->fields['id']);
     $ip = new Item_Problem();
     $ip->cleanDBonItemDelete('Computer', $this->fields['id']);
     $ci = new Change_Item();
     $ci->cleanDBonItemDelete('Computer', $this->fields['id']);
     $ip = new Item_Project();
     $ip->cleanDBonItemDelete(__CLASS__, $this->fields['id']);
     $ci = new Computer_Item();
     $ci->cleanDBonItemDelete('Computer', $this->fields['id']);
     Item_Devices::cleanItemDeviceDBOnItemDelete($this->getType(), $this->fields['id'], !empty($this->input['keep_devices']));
     $disk = new ComputerDisk();
     $disk->cleanDBonItemDelete('Computer', $this->fields['id']);
     $vm = new ComputerVirtualMachine();
     $vm->cleanDBonItemDelete('Computer', $this->fields['id']);
 }
開發者ID:pvasener,項目名稱:glpi,代碼行數:20,代碼來源:computer.class.php

示例3: cleanDBonPurge

 function cleanDBonPurge()
 {
     global $DB;
     $ci = new Computer_Item();
     $ci->cleanDBonItemDelete(__CLASS__, $this->fields['id']);
     $query = "UPDATE `glpi_cartridges`\n                SET `printers_id` = NULL\n                WHERE `printers_id` = '" . $this->fields['id'] . "'";
     $result = $DB->query($query);
     $ip = new Item_Problem();
     $ip->cleanDBonItemDelete(__CLASS__, $this->fields['id']);
     $ci = new Change_Item();
     $ci->cleanDBonItemDelete(__CLASS__, $this->fields['id']);
     $ip = new Item_Project();
     $ip->cleanDBonItemDelete(__CLASS__, $this->fields['id']);
     Item_Devices::cleanItemDeviceDBOnItemDelete($this->getType(), $this->fields['id'], !empty($this->input['keep_devices']));
 }
開發者ID:pvasener,項目名稱:glpi,代碼行數:15,代碼來源:printer.class.php

示例4:

GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
* @since version 0.84
*/
include '../inc/includes.php';
Session::checkCentralAccess();
if (isset($_POST["add"])) {
    Item_Devices::addDevicesFromPOST($_POST);
    Html::back();
} else {
    if (isset($_POST["updateall"])) {
        Item_Devices::updateAll($_POST);
        Html::back();
    }
}
Html::displayErrorAndDie('Lost');
開發者ID:glpi-project,項目名稱:glpi,代碼行數:30,代碼來源:item_devices.form.php

示例5: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $baseitem, array $ids)
 {
     global $DB;
     switch ($ma->getAction()) {
         case 'unlock':
             $input = $ma->getInput();
             if (isset($input['attached_item'])) {
                 $attached_items = $input['attached_item'];
                 if (($device_key = array_search('Device', $attached_items)) !== false) {
                     unset($attached_items[$device_key]);
                     $attached_items = array_merge($attached_items, Item_Devices::getDeviceTypes());
                 }
                 $links = array();
                 foreach ($attached_items as $attached_item) {
                     $infos = self::getLocksQueryInfosByItemType($attached_item, $baseitem->getType());
                     if ($item = getItemForItemtype($infos['type'])) {
                         $infos['item'] = $item;
                         $links[$attached_item] = $infos;
                     }
                 }
                 foreach ($ids as $id) {
                     $action_valid = false;
                     foreach ($links as $infos) {
                         $infos['condition'][$infos['field']] = $id;
                         foreach ($DB->request($infos['table'], $infos['condition']) as $data) {
                             // Restore without history
                             $action_valid = $infos['item']->restore(array('id' => $data['id']));
                         }
                     }
                     if ($action_valid) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         $ma->addMessage($infos['item']->getErrorMessage(ERROR_ON_ACTION));
                     }
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $baseitem, $ids);
 }
開發者ID:pvasener,項目名稱:glpi,代碼行數:46,代碼來源:lock.class.php

示例6:

GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
* @since version 0.84
*/
include '../inc/includes.php';
Session::checkCentralAccess();
if (isset($_POST["add"])) {
    if (isset($_POST['devicetype'])) {
        if ($link = getItemForItemtype('Item_' . $_POST['devicetype'])) {
            $link->addDevices(1, $_POST['itemtype'], $_POST['items_id'], $_POST['devices_id']);
        }
    }
    Html::back();
} else {
    if (isset($_POST["updateall"])) {
        Item_Devices::updateAll($_POST, false);
        Html::back();
    } else {
        if (isset($_POST["delete"])) {
            Item_Devices::updateAll($_POST, true);
            Html::back();
        }
    }
}
Html::displayErrorAndDie('Lost');
開發者ID:geldarr,項目名稱:hack-space,代碼行數:31,代碼來源:item_devices.form.php

示例7: showFormButtons

 /**
  * Display a 2 columns Footer for Form buttons
  * Close the form is user can edit
  *
  * @param $options   array of possible options:
  *     - withtemplate : 1 for newtemplate, 2 for newobject from template
  *     - colspan for each column (default 2)
  *     - candel : set to false to hide "delete" button
  *     - canedit : set to false to hide all buttons
  *     - addbuttons : array of buttons to add
  **/
 function showFormButtons($options = array())
 {
     global $CFG_GLPI;
     // for single object like config
     if (isset($this->fields['id'])) {
         $ID = $this->fields['id'];
     } else {
         $ID = 1;
     }
     $params['colspan'] = 2;
     $params['withtemplate'] = '';
     $params['candel'] = true;
     $params['canedit'] = true;
     $params['addbuttons'] = array();
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $params[$key] = $val;
         }
     }
     if (!$params['canedit'] || !$this->canEdit($ID)) {
         echo "</table></div>";
         // Form Header always open form
         if (!$params['canedit']) {
             Html::closeForm();
         }
         return false;
     }
     echo "<tr class='tab_bg_2'>";
     if ($params['withtemplate'] || $this->isNewID($ID)) {
         echo "<td class='center' colspan='" . $params['colspan'] * 2 . "'>";
         if ($ID <= 0 || $params['withtemplate'] == 2) {
             echo Html::submit(_x('button', 'Add'), array('name' => 'add'));
         } else {
             //TRANS : means update / actualize
             echo Html::submit(_x('button', 'Save'), array('name' => 'update'));
         }
     } else {
         if ($params['candel'] && !$this->can($ID, DELETE) && !$this->can($ID, PURGE)) {
             $params['candel'] = false;
         }
         if ($params['canedit'] && $this->can($ID, UPDATE)) {
             echo "<td class='center' colspan='" . $params['colspan'] * 2 . "'>\n";
             echo Html::submit(_x('button', 'Save'), array('name' => 'update'));
         }
         if ($params['candel']) {
             if ($params['canedit'] && $this->can($ID, UPDATE)) {
                 echo "</td></tr><tr class='tab_bg_2'>\n";
             }
             if ($this->isDeleted()) {
                 if ($this->can($ID, DELETE)) {
                     echo "<td class='right' colspan='" . $params['colspan'] * 2 . "' >\n";
                     echo Html::submit(_x('button', 'Restore'), array('name' => 'restore'));
                 }
                 if ($this->can($ID, PURGE)) {
                     echo "<span class='very_small_space'>";
                     if (in_array($this->getType(), Item_Devices::getConcernedItems())) {
                         Html::showToolTip(__('Check to keep the devices while deleting this item'));
                         echo "&nbsp;";
                         echo "<input type='checkbox' name='keep_devices' value='1'";
                         if (!empty($_SESSION['glpikeep_devices_when_purging_item'])) {
                             echo " checked";
                         }
                         echo ">&nbsp;";
                     }
                     echo Html::submit(_x('button', 'Delete permanently'), array('name' => 'purge'));
                     echo "</span>";
                 }
             } else {
                 echo "<td class='right' colspan='" . $params['colspan'] * 2 . "' >\n";
                 // If maybe dynamic : do not take into account  is_deleted  field
                 if (!$this->maybeDeleted() || $this->useDeletedToLockIfDynamic()) {
                     if ($this->can($ID, PURGE)) {
                         echo Html::submit(_x('button', 'Delete permanently'), array('name' => 'purge', 'confirm' => __('Confirm the final deletion?')));
                     }
                 } else {
                     if (!$this->isDeleted() && $this->can($ID, DELETE)) {
                         echo Html::submit(_x('button', 'Put in dustbin'), array('name' => 'delete'));
                     }
                 }
             }
         }
         if ($this->isField('date_mod')) {
             echo "<input type='hidden' name='_read_date_mod' value='" . $this->getField('date_mod') . "'>";
         }
     }
     if (!$this->isNewID($ID)) {
         echo "<input type='hidden' name='id' value='{$ID}'>";
     }
     echo "</td>";
//.........這裏部分代碼省略.........
開發者ID:JULIO8,項目名稱:respaldo_glpi,代碼行數:101,代碼來源:commondbtm.class.php

示例8: doMassiveActions


//.........這裏部分代碼省略.........
             foreach ($input["item"] as $key => $val) {
                 if (isset($input['items_id'])) {
                     // Add items to contracts
                     $input = array('itemtype' => $input["item_itemtype"], 'items_id' => $input["items_id"], 'contracts_id' => $key);
                 }
                 if (isset($input['contracts_id'])) {
                     // Add contract to item
                     $input = array('itemtype' => $input["itemtype"], 'items_id' => $key, 'contracts_id' => $input['contracts_id']);
                 } else {
                     return false;
                 }
                 if ($contractitem->can(-1, 'w', $input)) {
                     if ($contractitem->add($input)) {
                         $res['ok']++;
                     } else {
                         $res['ko']++;
                     }
                 } else {
                     $res['noright']++;
                 }
             }
             break;
         case "remove_contract_item":
             foreach ($input["item"] as $key => $val) {
                 if (isset($input['items_id'])) {
                     // Remove item to contracts
                     $input = array('itemtype' => $input["item_itemtype"], 'items_id' => $input["items_id"], 'contracts_id' => $key);
                 } else {
                     // Remove contract to items
                     $input = array('itemtype' => $input["itemtype"], 'items_id' => $key, 'contracts_id' => $input['contracts_id']);
                 }
                 $contractitem = new Contract_Item();
                 if ($contractitem->can(-1, 'w', $input)) {
                     if ($item = getItemForItemtype($input["itemtype"])) {
                         if ($item->getFromDB($input['items_id'])) {
                             $contract = new Contract();
                             if ($contract->getFromDB($input['contracts_id'])) {
                                 if ($contractitem->getFromDBForItems($contract, $item)) {
                                     if ($contractitem->delete(array('id' => $contractitem->getID()))) {
                                         $res['ok']++;
                                     } else {
                                         $res['ko']++;
                                     }
                                 } else {
                                     $res['ko']++;
                                 }
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['ko']++;
                     }
                 } else {
                     $res['noright']++;
                 }
             }
             break;
             //Lock management
         //Lock management
         case 'unlock_Printer':
         case 'unlock_Monitor':
         case 'unlock_NetworkPort':
         case 'unlock_NetworkName':
         case 'unlock_IPAddress':
         case 'unlock_ComputerDisk':
         case 'unlock_ComputerVirtualMachine':
         case 'unlock_Peripheral':
         case 'unlock_SoftwareVersion':
             $itemtype = Lock::getItemTypeForMassiveAction($input["action"]);
             if ($itemtype) {
                 $res = Lock::unlockItems($itemtype, $this->getType(), $input["item"]);
             }
             break;
         case 'unlock_Device':
             foreach (Item_Devices::getDeviceTypes() as $itemtype) {
                 $res = Lock::unlockItems($itemtype, $this->getType(), $input["item"]);
             }
             break;
         default:
             // Plugin specific actions
             $split = explode('_', $input["action"]);
             $res = '';
             if ($split[0] == 'plugin' && isset($split[1])) {
                 // Normalized name plugin_name_action
                 // Allow hook from any plugin on any (core or plugin) type
                 $res = Plugin::doOneHook($split[1], 'MassiveActionsProcess', $input);
                 //            } else if ($plug=isPluginItemType($input["itemtype"])) {
                 // non-normalized name
                 // hook from the plugin defining the type
                 //               $res = Plugin::doOneHook($plug['plugin'], 'MassiveActionsProcess', $input);
             } else {
                 $res = $this->doSpecificMassiveActions($input);
             }
             break;
     }
     return $res;
 }
開發者ID:gaforeror,項目名稱:glpi,代碼行數:101,代碼來源:commondbtm.class.php

示例9: cleanDBonPurge

 function cleanDBonPurge()
 {
     $csv = new Computer_SoftwareVersion();
     $csv->cleanDBonItemDelete('Computer', $this->fields['id']);
     $csl = new Computer_SoftwareLicense();
     $csl->cleanDBonItemDelete('Computer', $this->fields['id']);
     $ip = new Item_Problem();
     $ip->cleanDBonItemDelete('Computer', $this->fields['id']);
     $ci = new Computer_Item();
     $ci->cleanDBonItemDelete('Computer', $this->fields['id']);
     Item_Devices::cleanItemDeviceDBOnItemDelete('Computer', $this->fields['id']);
     $disk = new ComputerDisk();
     $disk->cleanDBonItemDelete('Computer', $this->fields['id']);
     $vm = new ComputerVirtualMachine();
     $vm->cleanDBonItemDelete('Computer', $this->fields['id']);
 }
開發者ID:geldarr,項目名稱:hack-space,代碼行數:16,代碼來源:computer.class.php

示例10: resetOCSLocks

 static function resetOCSLocks($objectId, $entities)
 {
     global $DB;
     $res = array('ok' => 0, 'ko' => 0);
     $object = new $objectId();
     $objecttable = getTableForItemType($objectId);
     $restrict = "";
     if ($object->maybeTemplate()) {
         $restrict = "`is_template` = '0'";
     }
     if ($object->isEntityAssign() && $entities != -1) {
         $restrict .= getEntitiesRestrictRequest(" AND ", $objecttable, '', $entities, $object->maybeRecursive());
     }
     $count = countElementsInTable($objecttable, $restrict);
     $items = getAllDatasFromTable($objecttable, $restrict);
     $computers = array();
     if (!empty($items)) {
         echo "<div class='center'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><td>";
         Html::createProgressBar(__('Work in progress...'));
         echo "</td></tr></table></div></br>\n";
         $i = 0;
         foreach ($items as $item) {
             //Fields
             if (PluginOcsinventoryngOcsServer::deleteInOcsArray($item['id'], 'all', "computer_update", true)) {
                 $res['ok']++;
             }
             $i++;
             $computers[$item['id']] = 1;
             Html::changeProgressBarPosition($i, $count);
         }
         foreach (Item_Devices::getDeviceTypes() as $itemtype) {
             $res[] = Lock::unlockItems($itemtype, 'Computer', $computers);
         }
         $res[] = Lock::unlockItems('Monitor', 'Monitor', $computers);
         $res[] = Lock::unlockItems('Printer', 'Printer', $computers);
         $res[] = Lock::unlockItems('Peripheral', 'Peripheral', $computers);
         $res[] = Lock::unlockItems('SoftwareVersion', 'SoftwareVersion', $computers);
         $res[] = Lock::unlockItems('NetworkPort', 'Computer', $computers);
         $res[] = Lock::unlockItems('NetworkName', 'NetworkPort', $computers);
         $res[] = Lock::unlockItems('IPAddress', 'NetworkName', $computers);
         $res[] = Lock::unlockItems('ComputerDisk', 'ComputerDisk', $computers);
         $res[] = Lock::unlockItems('ComputerVirtualMachine', 'ComputerVirtualMachine', $computers);
         Html::changeProgressBarPosition($i, $count, __('Task completed.'));
     }
     return $res;
 }
開發者ID:geldarr,項目名稱:hack-space,代碼行數:48,代碼來源:utilitaire.class.php

示例11: updateComputer

 /** Update a ocs computer
  *
  * @param $ID integer : ID of ocslinks row
  * @param $plugin_ocsinventoryng_ocsservers_id integer : ocs server ID
  * @param $dohistory bool : do history ?
  * @param $force bool : force update ?
  *
  * @return action done
  **/
 static function updateComputer($ID, $plugin_ocsinventoryng_ocsservers_id, $dohistory, $force = 0)
 {
     global $DB, $PluginOcsinventoryngDBocs, $CFG_GLPI;
     self::checkOCSconnection($plugin_ocsinventoryng_ocsservers_id);
     $cfg_ocs = self::getConfig($plugin_ocsinventoryng_ocsservers_id);
     $query = "SELECT *\n                FROM `glpi_plugin_ocsinventoryng_ocslinks`\n                WHERE `id` = '{$ID}'\n                      AND `plugin_ocsinventoryng_ocsservers_id`\n                              = '{$plugin_ocsinventoryng_ocsservers_id}'";
     $result = $DB->query($query);
     if ($DB->numrows($result) == 1) {
         $line = $DB->fetch_assoc($result);
         $comp = new Computer();
         $comp->getFromDB($line["computers_id"]);
         // Get OCS ID
         $query_ocs = "SELECT *\n                       FROM `hardware`\n                       WHERE `ID` = '" . $line['ocsid'] . "'";
         $result_ocs = $PluginOcsinventoryngDBocs->query($query_ocs);
         // Need do history to be 2 not to lock fields
         if ($dohistory) {
             $dohistory = 2;
         }
         if ($PluginOcsinventoryngDBocs->numrows($result_ocs) == 1) {
             $data_ocs = Toolbox::addslashes_deep($PluginOcsinventoryngDBocs->fetch_array($result_ocs));
             // automatic transfer computer
             if ($CFG_GLPI['transfers_id_auto'] > 0 && Session::isMultiEntitiesMode()) {
                 self::transferComputer($line, $data_ocs);
                 $comp->getFromDB($line["computers_id"]);
             }
             // update last_update and and last_ocs_update
             $query = "UPDATE `glpi_plugin_ocsinventoryng_ocslinks`\n                      SET `last_update` = '" . $_SESSION["glpi_currenttime"] . "',\n                          `last_ocs_update` = '" . $data_ocs["LASTDATE"] . "',\n                          `ocs_agent_version` = '" . $data_ocs["USERAGENT"] . " '\n                      WHERE `id` = '{$ID}'";
             $DB->query($query);
             if ($force) {
                 $ocs_checksum = self::MAX_CHECKSUM;
                 self::setChecksumForComputer($line['ocsid'], $ocs_checksum);
             } else {
                 $ocs_checksum = $data_ocs["CHECKSUM"];
             }
             $mixed_checksum = intval($ocs_checksum) & intval($cfg_ocs["checksum"]);
             //By default log history
             $loghistory["history"] = 1;
             // Is an update to do ?
             if ($mixed_checksum) {
                 // Get updates on computers :
                 $computer_updates = importArrayFromDB($line["computer_update"]);
                 if (!in_array(self::IMPORT_TAG_078, $computer_updates)) {
                     $computer_updates = self::migrateComputerUpdates($line["computers_id"], $computer_updates);
                 }
                 // Update Administrative informations
                 self::updateAdministrativeInfo($line['computers_id'], $line['ocsid'], $plugin_ocsinventoryng_ocsservers_id, $cfg_ocs, $computer_updates, $comp->fields['entities_id'], $dohistory);
                 if ($mixed_checksum & pow(2, self::HARDWARE_FL)) {
                     $p = array('computers_id' => $line['computers_id'], 'ocs_id' => $line['ocsid'], 'plugin_ocsinventoryng_ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id, 'cfg_ocs' => $cfg_ocs, 'computers_updates' => $computer_updates, 'dohistory' => $dohistory, 'check_history' => true, 'entities_id' => $comp->fields['entities_id']);
                     $loghistory = self::updateHardware($p);
                 }
                 if ($mixed_checksum & pow(2, self::BIOS_FL)) {
                     self::updateBios($line['computers_id'], $line['ocsid'], $plugin_ocsinventoryng_ocsservers_id, $cfg_ocs, $computer_updates, $dohistory, $comp->fields['entities_id']);
                 }
                 // Get import devices
                 $import_device = array();
                 $types = Item_Devices::getDeviceTypes();
                 foreach ($types as $old => $type) {
                     $associated_type = str_replace('Item_', '', $type);
                     $associated_table = getTableForItemType($associated_type);
                     $fk = getForeignKeyFieldForTable($associated_table);
                     $query = "SELECT `i`.`id`, `t`.`designation` as `name`\n                            FROM `" . getTableForItemType($type) . "` as i\n                            LEFT JOIN `{$associated_table}` as t ON (`t`.`id`=`i`.`{$fk}`)\n                            WHERE `itemtype`='Computer'\n                               AND `items_id`='" . $line['computers_id'] . "'\n                               AND `is_dynamic`";
                     $prevalue = $type . self::FIELD_SEPARATOR;
                     foreach ($DB->request($query) as $data) {
                         $import_device[$prevalue . $data['id']] = $prevalue . $data["name"];
                         // TODO voir si il ne serait pas plus simple propre
                         // en adaptant updateDevices
                         // $import_device[$type][$data['id']] = $data["name"];
                     }
                 }
                 if ($mixed_checksum & pow(2, self::MEMORIES_FL)) {
                     self::updateDevices("Item_DeviceMemory", $line['computers_id'], $line['ocsid'], $plugin_ocsinventoryng_ocsservers_id, $cfg_ocs, $import_device, '', $dohistory);
                 }
                 if ($mixed_checksum & pow(2, self::STORAGES_FL)) {
                     self::updateDevices("Item_DeviceHardDrive", $line['computers_id'], $line['ocsid'], $plugin_ocsinventoryng_ocsservers_id, $cfg_ocs, $import_device, '', $dohistory);
                     self::updateDevices("Item_DeviceDrive", $line['computers_id'], $line['ocsid'], $plugin_ocsinventoryng_ocsservers_id, $cfg_ocs, $import_device, '', $dohistory);
                 }
                 if ($mixed_checksum & pow(2, self::HARDWARE_FL)) {
                     self::updateDevices("Item_DeviceProcessor", $line['computers_id'], $line['ocsid'], $plugin_ocsinventoryng_ocsservers_id, $cfg_ocs, $import_device, '', $dohistory);
                 }
                 if ($mixed_checksum & pow(2, self::VIDEOS_FL)) {
                     self::updateDevices("Item_DeviceGraphicCard", $line['computers_id'], $line['ocsid'], $plugin_ocsinventoryng_ocsservers_id, $cfg_ocs, $import_device, '', $dohistory);
                 }
                 if ($mixed_checksum & pow(2, self::SOUNDS_FL)) {
                     self::updateDevices("Item_DeviceSoundCard", $line['computers_id'], $line['ocsid'], $plugin_ocsinventoryng_ocsservers_id, $cfg_ocs, $import_device, '', $dohistory);
                 }
                 if ($mixed_checksum & pow(2, self::NETWORKS_FL)) {
                     //TODO import_ip ?
                     //$import_ip = importArrayFromDB($line["import_ip"]);
                     self::updateDevices("Item_DeviceNetworkCard", $line['computers_id'], $line['ocsid'], $plugin_ocsinventoryng_ocsservers_id, $cfg_ocs, $import_device, array(), $dohistory);
                 }
                 if ($mixed_checksum & pow(2, self::MODEMS_FL) || $mixed_checksum & pow(2, self::PORTS_FL)) {
//.........這裏部分代碼省略.........
開發者ID:geldarr,項目名稱:hack-space,代碼行數:101,代碼來源:ocsserver.class.php

示例12: plugin_ocsinventoryng_migrateComputerLocks

/**
 * Move locks from ocslink.import_* to is_dynamic in related tables
 *
 * @param $migration
**/
function plugin_ocsinventoryng_migrateComputerLocks(Migration $migration)
{
    global $DB;
    $import = array('import_printer' => 'Printer', 'import_monitor' => 'Monitor', 'import_peripheral' => 'Peripheral');
    foreach ($import as $field => $itemtype) {
        foreach ($DB->request('ocs_glpi_ocslinks', '', array('computers_id', $field)) as $data) {
            if (FieldExists('ocs_glpi_ocslinks', $field)) {
                $import_field = importArrayFromDB($data[$field]);
                //If array is not empty
                if (!empty($import_field)) {
                    $query_update = "UPDATE `glpi_computers_items`\n                                SET `is_dynamic`='1'\n                                WHERE `id` IN (" . implode(',', array_keys($import_field)) . ")\n                                      AND `itemtype`='{$itemtype}'";
                    $DB->query($query_update);
                }
            }
        }
        $migration->dropField('ocs_glpi_ocslinks', $field);
    }
    //Migration disks and vms
    $import = array('import_disk' => 'glpi_computerdisks', 'import_vm' => 'glpi_computervirtualmachines', 'import_software' => 'glpi_computers_softwareversions', 'import_ip' => 'glpi_networkports');
    foreach ($import as $field => $table) {
        if (FieldExists('ocs_glpi_ocslinks', $field)) {
            foreach ($DB->request('ocs_glpi_ocslinks', '', array('computers_id', $field)) as $data) {
                $import_field = importArrayFromDB($data[$field]);
                //If array is not empty
                if (!empty($import_field)) {
                    $in_where = "(" . implode(',', array_keys($import_field)) . ")";
                    $query_update = "UPDATE `{$table}`\n                                SET `is_dynamic`='1'\n                                WHERE `id` IN {$in_where}";
                    $DB->query($query_update);
                    if ($table == 'glpi_networkports') {
                        $query_update = "UPDATE `glpi_networkports` AS PORT,\n                                          `glpi_networknames` AS NAME\n                                   SET NAME.`is_dynamic` = 1\n                                   WHERE PORT.`id` IN {$in_where}\n                                     AND NAME.`itemtype` = 'NetworkPort'\n                                     AND NAME.`items_id` = PORT.`id`";
                        $DB->query($query_update);
                        $query_update = "UPDATE `glpi_networkports` AS PORT,\n                                          `glpi_networknames` AS NAME,\n                                          `glpi_ipaddresses` AS ADDR\n                                   SET ADDR.`is_dynamic` = 1\n                                   WHERE PORT.`id` IN {$in_where}\n                                     AND NAME.`itemtype` = 'NetworkPort'\n                                     AND NAME.`items_id` = PORT.`id`\n                                     AND ADDR.`itemtype` = 'NetworkName'\n                                     AND ADDR.`items_id` = NAME.`id`";
                        $DB->query($query_update);
                    }
                }
            }
            $migration->dropField('ocs_glpi_ocslinks', $field);
        }
    }
    if (FieldExists('ocs_glpi_ocslinks', 'import_device')) {
        foreach ($DB->request('ocs_glpi_ocslinks', '', array('computers_id', 'import_device')) as $data) {
            $import_device = importArrayFromDB($data['import_device']);
            if (!in_array('_version_078_', $import_device)) {
                $import_device = plugin_ocsinventoryng_migrateImportDevice($import_device);
            }
            $devices = array();
            $types = Item_Devices::getDeviceTypes();
            foreach ($import_device as $key => $val) {
                if (!$key) {
                    // OcsServer::IMPORT_TAG_078
                    continue;
                }
                list($type, $nomdev) = explode('$$$$$', $val);
                list($type, $iddev) = explode('$$$$$', $key);
                if (!isset($types[$type])) {
                    // should never happen
                    continue;
                }
                $devices[$types[$type]][] = $iddev;
            }
            foreach ($devices as $type => $data) {
                //If array is not empty
                $query_update = "UPDATE `" . getTableForItemType($type) . "`\n                             SET `is_dynamic`='1'\n                             WHERE `id` IN (" . implode(',', $data) . ")";
                $DB->query($query_update);
            }
        }
        $migration->dropField('ocs_glpi_ocslinks', 'import_device');
    }
    $migration->migrationOneTable('ocs_glpi_ocslinks');
}
開發者ID:geldarr,項目名稱:hack-space,代碼行數:75,代碼來源:hook.php

示例13: getItemtypesThatCanHave

 /**
  * Get all the types that can have a document
  *
  * @since version 0.85
  *
  * @return array of the itemtypes
  **/
 static function getItemtypesThatCanHave()
 {
     global $CFG_GLPI;
     return array_merge($CFG_GLPI['document_types'], CommonDevice::getDeviceTypes(), Item_Devices::getDeviceTypes());
 }
開發者ID:paisdelconocimiento,項目名稱:glpi-smartcities,代碼行數:12,代碼來源:document.class.php

示例14: getAllMassiveActions

 /**
  * Get the standard massive actions
  *
  * @param $item                   the item for which we want the massive actions
  * @param $is_deleted             massive action for deleted items ?   (default 0)
  * @param $checkitem              link item to check right              (default NULL)
  *
  * @return an array of massive actions or false if $item is not valid
  **/
 static function getAllMassiveActions($item, $is_deleted = 0, CommonDBTM $checkitem = NULL)
 {
     global $CFG_GLPI, $PLUGIN_HOOKS;
     // TODO: when maybe* will be static, when can completely switch to $itemtype !
     if (is_string($item)) {
         $itemtype = $item;
         if (!($item = getItemForItemtype($itemtype))) {
             return false;
         }
     } else {
         if ($item instanceof CommonDBTM) {
             $itemtype = $item->getType();
         } else {
             return false;
         }
     }
     if (!is_null($checkitem)) {
         $canupdate = $checkitem->canUpdate();
         $candelete = $checkitem->canDelete();
         $canpurge = $checkitem->canPurge();
     } else {
         $canupdate = $itemtype::canUpdate();
         $candelete = $itemtype::canDelete();
         $canpurge = $itemtype::canPurge();
     }
     $actions = array();
     $self_pref = __CLASS__ . self::CLASS_ACTION_SEPARATOR;
     if ($is_deleted) {
         if ($canpurge) {
             if (in_array($itemtype, Item_Devices::getConcernedItems())) {
                 $actions[$self_pref . 'purge_item_but_devices'] = _x('button', 'Delete permanently but keep devices');
                 $actions[$self_pref . 'purge'] = _x('button', 'Delete permanently and remove devices');
             } else {
                 $actions[$self_pref . 'purge'] = _x('button', 'Delete permanently');
             }
             $actions[$self_pref . 'restore'] = _x('button', 'Restore');
         }
     } else {
         if ($_SESSION['glpiactiveprofile']['interface'] == 'central' && ($canupdate || InfoCom::canApplyOn($itemtype) && Infocom::canUpdate())) {
             //TRANS: select action 'update' (before doing it)
             $actions[$self_pref . 'update'] = _x('button', 'Update');
         }
         Infocom::getMassiveActionsForItemtype($actions, $itemtype, $is_deleted, $checkitem);
         CommonDBConnexity::getMassiveActionsForItemtype($actions, $itemtype, $is_deleted, $checkitem);
         // do not take into account is_deleted if items may be dynamic
         if ($item->maybeDeleted() && !$item->useDeletedToLockIfDynamic()) {
             if ($candelete) {
                 $actions[$self_pref . 'delete'] = _x('button', 'Put in dustbin');
             }
         } else {
             if ($canpurge) {
                 $actions[$self_pref . 'purge'] = _x('button', 'Delete permanently');
                 if ($item instanceof CommonDropdown) {
                     $actions[$self_pref . 'purge_but_item_linked'] = _x('button', 'Delete permanently even if linked items');
                 }
             }
         }
         Document::getMassiveActionsForItemtype($actions, $itemtype, $is_deleted, $checkitem);
         Contract::getMassiveActionsForItemtype($actions, $itemtype, $is_deleted, $checkitem);
         // Specific actions
         $actions += $item->getSpecificMassiveActions($checkitem);
         // Plugin Specific actions
         if (isset($PLUGIN_HOOKS['use_massive_action'])) {
             foreach ($PLUGIN_HOOKS['use_massive_action'] as $plugin => $val) {
                 $plug_actions = Plugin::doOneHook($plugin, 'MassiveActions', $itemtype);
                 if (count($plug_actions)) {
                     $actions += $plug_actions;
                 }
             }
         }
     }
     Lock::getMassiveActionsForItemtype($actions, $itemtype, $is_deleted, $checkitem);
     // Manage forbidden actions : try complete action name or MassiveAction:action_name
     $forbidden_actions = $item->getForbiddenStandardMassiveAction();
     if (is_array($forbidden_actions) && count($forbidden_actions)) {
         foreach ($forbidden_actions as $actiontodel) {
             if (isset($actions[$actiontodel])) {
                 unset($actions[$actiontodel]);
             } else {
                 // Not found search adding MassiveAction prefix
                 $actiontodel = $self_pref . $actiontodel;
                 if (isset($actions[$actiontodel])) {
                     unset($actions[$actiontodel]);
                 }
             }
         }
     }
     return $actions;
 }
開發者ID:kipman,項目名稱:glpi,代碼行數:98,代碼來源:massiveaction.class.php

示例15: showForItem


//.........這裏部分代碼省略.........
             echo "</tr>\n";
         }
         //Software licenses
         $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
         $first = true;
         $query = "SELECT `csv`.`id` AS `id`,\n                           `sv`.`name` AS `version`,\n                           `s`.`name` AS `software`\n                    FROM `glpi_computers_softwarelicenses` AS csv\n                    LEFT JOIN `glpi_softwarelicenses` AS sv\n                       ON (`csv`.`softwarelicenses_id` = `sv`.`id`)\n                    LEFT JOIN `glpi_softwares` AS s\n                       ON (`sv`.`softwares_id` = `s`.`id`)\n                    WHERE `csv`.`is_deleted` = '1'\n                          AND `csv`.`is_dynamic` = '1'\n                          AND `csv`.`computers_id` = '{$ID}'";
         foreach ($DB->request($query) as $line) {
             $header = true;
             if ($first) {
                 echo "<tr><th colspan='2'>" . SoftwareLicense::getTypeName(2) . "</th>" . "</tr>\n";
                 $first = false;
             }
             echo "<tr class='tab_bg_1'><td class='center' width='10'>";
             echo "<input type='checkbox' name='Computer_SoftwareLicense[" . $line['id'] . "]'></td>";
             echo "<td class='left' width='95%'>" . $line['software'] . " " . $line['version'] . "</td>";
             echo "</tr>\n";
         }
     }
     $first = true;
     $item = new NetworkPort();
     $params = array('is_dynamic' => 1, 'is_deleted' => 1, 'items_id' => $ID, 'itemtype' => $itemtype);
     $params['FIELDS'] = array('id');
     foreach ($DB->request('glpi_networkports', $params) as $line) {
         $item->getFromDB($line['id']);
         $header = true;
         if ($first) {
             echo "<tr><th colspan='2'>" . NetworkPort::getTypeName(2) . "</th></tr>\n";
             $first = false;
         }
         echo "<tr class='tab_bg_1'><td class='center' width='10'>";
         echo "<input type='checkbox' name='NetworkPort[" . $line['id'] . "]'></td>";
         echo "<td class='left' width='95%'>" . $item->getName() . "</td>";
         echo "</tr>\n";
     }
     $first = true;
     $item = new NetworkName();
     $params = array('`glpi_networknames`.`is_dynamic`' => 1, '`glpi_networknames`.`is_deleted`' => 1, '`glpi_networknames`.`itemtype`' => 'NetworkPort', '`glpi_networknames`.`items_id`' => '`glpi_networkports`.`id`', '`glpi_networkports`.`items_id`' => $ID, '`glpi_networkports`.`itemtype`' => $itemtype);
     $params['FIELDS'] = array('glpi_networknames' => 'id');
     foreach ($DB->request(array('glpi_networknames', 'glpi_networkports'), $params) as $line) {
         $item->getFromDB($line['id']);
         $header = true;
         if ($first) {
             echo "<tr><th colspan='2'>" . NetworkName::getTypeName(2) . "</th></tr>\n";
             $first = false;
         }
         echo "<tr class='tab_bg_1'><td class='center' width='10'>";
         echo "<input type='checkbox' name='NetworkName[" . $line['id'] . "]'></td>";
         echo "<td class='left' width='95%'>" . $item->getName() . "</td>";
         echo "</tr>\n";
     }
     $first = true;
     $item = new IPAddress();
     $params = array('`glpi_ipaddresses`.`is_dynamic`' => 1, '`glpi_ipaddresses`.`is_deleted`' => 1, '`glpi_ipaddresses`.`itemtype`' => 'Networkname', '`glpi_ipaddresses`.`items_id`' => '`glpi_networknames`.`id`', '`glpi_networknames`.`itemtype`' => 'NetworkPort', '`glpi_networknames`.`items_id`' => '`glpi_networkports`.`id`', '`glpi_networkports`.`items_id`' => $ID, '`glpi_networkports`.`itemtype`' => $itemtype);
     $params['FIELDS'] = array('glpi_ipaddresses' => 'id');
     foreach ($DB->request(array('glpi_ipaddresses', 'glpi_networknames', 'glpi_networkports'), $params) as $line) {
         $item->getFromDB($line['id']);
         $header = true;
         if ($first) {
             echo "<tr><th colspan='2'>" . IPAddress::getTypeName(2) . "</th></tr>\n";
             $first = false;
         }
         echo "<tr class='tab_bg_1'><td class='center' width='10'>";
         echo "<input type='checkbox' name='IPAddress[" . $line['id'] . "]'></td>";
         echo "<td class='left' width='95%'>" . $item->getName() . "</td>";
         echo "</tr>\n";
     }
     $types = Item_Devices::getDeviceTypes();
     $nb = 0;
     foreach ($types as $old => $type) {
         $nb += countElementsInTable(getTableForItemType($type), "`items_id`='{$ID}'\n                                         AND `itemtype`='{$itemtype}'\n                                         AND `is_dynamic`='1'\n                                         AND `is_deleted`='1'");
     }
     if ($nb) {
         $header = true;
         echo "<tr><th colspan='2'>" . _n('Component', 'Components', 2) . "</th></tr>\n";
         foreach ($types as $old => $type) {
             $associated_type = str_replace('Item_', '', $type);
             $associated_table = getTableForItemType($associated_type);
             $fk = getForeignKeyFieldForTable($associated_table);
             $query = "SELECT `i`.`id`,\n                             `t`.`designation` AS `name`\n                      FROM `" . getTableForItemType($type) . "` AS i\n                      LEFT JOIN `{$associated_table}` AS t\n                         ON (`t`.`id` = `i`.`{$fk}`)\n                      WHERE `itemtype` = '{$itemtype}'\n                            AND `items_id` = '{$ID}'\n                            AND `is_dynamic` = '1'\n                            AND `is_deleted` = '1'";
             foreach ($DB->request($query) as $data) {
                 echo "<tr class='tab_bg_1'><td class='center' width='10'>";
                 echo "<input type='checkbox' name='" . $type . "[" . $data['id'] . "]'></td>";
                 echo "<td class='left' width='95%'>";
                 printf(__('%1$s: %2$s'), $associated_type::getTypeName(), $data['name']);
                 echo "</td></tr>\n";
             }
         }
     }
     if ($header) {
         echo "</table>";
         Html::openArrowMassives('lock_form', true);
         Html::closeArrowMassives(array('unlock' => _sx('button', 'Unlock')));
     } else {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' colspan='2'>" . __('No locked item') . "</td></tr>";
         echo "</table>";
     }
     Html::closeForm();
     echo "</div>\n";
 }
開發者ID:geldarr,項目名稱:hack-space,代碼行數:101,代碼來源:lock.class.php


注:本文中的Item_Devices類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。