当前位置: 首页>>代码示例>>PHP>>正文


PHP CommonDBTM::getType方法代码示例

本文整理汇总了PHP中CommonDBTM::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonDBTM::getType方法的具体用法?PHP CommonDBTM::getType怎么用?PHP CommonDBTM::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommonDBTM的用法示例。


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

示例1: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'delete_for_user':
             $input = $ma->getInput();
             if (isset($input['users_id'])) {
                 $user = new User();
                 $user->getFromDB($input['users_id']);
                 foreach ($ids as $id) {
                     if ($input['users_id'] == Session::getLoginUserID()) {
                         if ($item->deleteByCriteria(array('users_id' => $input['users_id'], 'itemtype' => $id))) {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                             $ma->addMessage($user->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($user->getErrorMessage(ERROR_RIGHT));
                     }
                 }
             } else {
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:stweil,项目名称:glpi,代码行数:33,代码来源:displaypreference.class.php

示例2: pdfForItem

 static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
 {
     global $DB, $CFG_GLPIG;
     if (!Session::haveRight("contract", "r")) {
         return false;
     }
     $type = $item->getType();
     $ID = $item->getField('id');
     $con = new Contract();
     $query = "SELECT *\n                FROM `glpi_contracts_items`\n                WHERE `glpi_contracts_items`.`items_id` = '" . $ID . "'\n                      AND `glpi_contracts_items`.`itemtype` = '" . $type . "'";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = $j = 0;
     $pdf->setColumnsSize(100);
     if ($number > 0) {
         $pdf->displayTitle('<b>' . _N('Associated contract', 'Associated contracts', 2) . '</b>');
         $pdf->setColumnsSize(19, 19, 19, 16, 11, 16);
         $pdf->displayTitle(__('Name'), _x('phone', 'Number'), __('Contract type'), __('Supplier'), __('Start date'), __('Initial contract period'));
         $i++;
         while ($j < $number) {
             $cID = $DB->result($result, $j, "contracts_id");
             $assocID = $DB->result($result, $j, "id");
             if ($con->getFromDB($cID)) {
                 $pdf->displayLine(empty($con->fields["name"]) ? "(" . $con->fields["id"] . ")" : $con->fields["name"], $con->fields["num"], Html::clean(Dropdown::getDropdownName("glpi_contracttypes", $con->fields["contracttypes_id"])), str_replace("<br>", " ", $con->getSuppliersNames()), Html::convDate($con->fields["begin_date"]), sprintf(_n('%d month', '%d months', $con->fields["duration"]), $con->fields["duration"]));
             }
             $j++;
         }
     } else {
         $pdf->displayTitle("<b>" . __('No item found') . "</b>");
     }
     $pdf->displaySpace();
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:32,代码来源:contract_item.class.php

示例3: countForItem

 /**
  * @param CommonDBTM $item
  **/
 static function countForItem(CommonDBTM $item)
 {
     global $DB;
     $query = "SELECT COUNT(*) AS cpt FROM `glpi_plugin_monitoring_componentscatalogs_hosts`\n         LEFT JOIN `glpi_plugin_monitoring_services`\n            ON `glpi_plugin_monitoring_services`.`plugin_monitoring_componentscatalogs_hosts_id` =\n               `glpi_plugin_monitoring_componentscatalogs_hosts`.`id`\n         WHERE `itemtype` = '" . $item->getType() . "'\n            AND `items_id` ='" . $item->getField('id') . "'\n            AND `glpi_plugin_monitoring_services`.`id` IS NOT NULL";
     $result = $DB->query($query);
     $ligne = $DB->fetch_assoc($result);
     return $ligne['cpt'];
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:11,代码来源:host.class.php

示例4: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case "use_filter_assign_group":
             $escalade_user = new self();
             $input = $ma->getInput();
             foreach ($ids as $id) {
                 if ($escalade_user->getFromDBByQuery("WHERE users_id = {$id}")) {
                     $escalade_user->fields['use_filter_assign_group'] = $input['use_filter_assign_group'];
                     if ($escalade_user->update($escalade_user->fields)) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
     }
 }
开发者ID:korial29,项目名称:escalade,代码行数:23,代码来源:user.class.php

示例5: pdfForItem

 static function pdfForItem(PluginPdfSimplePDF $pdf, CommonDBTM $item)
 {
     global $DB;
     $ID = $item->getField('id');
     $type = $item->getType();
     $crit = $type == 'Software' ? 'softwares_id' : 'id';
     if ($type == 'Software') {
         $crit = 'softwares_id';
         // Software ID
         $innerjoin = "INNER JOIN `glpi_softwareversions`\n                           ON (`glpi_computers_softwareversions`.`softwareversions_id`\n                               = `glpi_softwareversions`.`id`)";
         $where = "WHERE `glpi_softwareversions`.`softwares_id` = '" . $ID . "'";
     } else {
         $crit = 'id';
         //SoftwareVersion ID
         $innerjoin = '';
         $where = "WHERE `glpi_computers_softwareversions`.`softwareversions_id` = '" . $ID . "'";
     }
     $query_number = "SELECT COUNT(*) AS cpt\n                       FROM `glpi_computers_softwareversions`\n                       {$innerjoin}\n                       INNER JOIN `glpi_computers`\n                           ON (`glpi_computers_softwareversions`.`computers_id` = `glpi_computers`.`id`)\n                       {$where}" . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n                            AND `glpi_computers`.`is_deleted` = '0'\n                            AND `glpi_computers`.`is_template` = '0'";
     $total = 0;
     if ($result = $DB->query($query_number)) {
         $total = $DB->result($result, 0, 0);
     }
     $query = "SELECT DISTINCT `glpi_computers_softwareversions`.*,\n                          `glpi_computers`.`name` AS compname,\n                          `glpi_computers`.`id` AS cID,\n                          `glpi_computers`.`serial`,\n                          `glpi_computers`.`otherserial`,\n                          `glpi_users`.`name` AS username,\n                          `glpi_users`.`id` AS userid,\n                          `glpi_users`.`realname` AS userrealname,\n                          `glpi_users`.`firstname` AS userfirstname,\n                          `glpi_softwareversions`.`name` AS version,\n                          `glpi_softwareversions`.`id` AS vID,\n                          `glpi_softwareversions`.`softwares_id` AS sID,\n                          `glpi_softwareversions`.`name` AS vername,\n                          `glpi_entities`.`completename` AS entity,\n                          `glpi_locations`.`completename` AS location,\n                          `glpi_states`.`name` AS state,\n                          `glpi_groups`.`name` AS groupe\n                FROM `glpi_computers_softwareversions`\n                INNER JOIN `glpi_softwareversions`\n                     ON (`glpi_computers_softwareversions`.`softwareversions_id`\n                              = `glpi_softwareversions`.`id`)\n                INNER JOIN `glpi_computers`\n                     ON (`glpi_computers_softwareversions`.`computers_id` = `glpi_computers`.`id`)\n                LEFT JOIN `glpi_entities` ON (`glpi_computers`.`entities_id` = `glpi_entities`.`id`)\n                LEFT JOIN `glpi_locations`\n                     ON (`glpi_computers`.`locations_id` = `glpi_locations`.`id`)\n                LEFT JOIN `glpi_states` ON (`glpi_computers`.`states_id` = `glpi_states`.`id`)\n                LEFT JOIN `glpi_groups` ON (`glpi_computers`.`groups_id` = `glpi_groups`.`id`)\n                LEFT JOIN `glpi_users` ON (`glpi_computers`.`users_id` = `glpi_users`.`id`)\n                WHERE (`glpi_softwareversions`.`{$crit}` = '{$ID}') " . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n                      AND `glpi_computers`.`is_deleted` = '0'\n                      AND `glpi_computers`.`is_template` = '0'\n                ORDER BY version, compname\n                LIMIT 0," . intval($_SESSION['glpilist_limit']);
     $pdf->setColumnsSize(100);
     if (($result = $DB->query($query)) && ($number = $DB->numrows($result)) > 0) {
         if ($number == $total) {
             $pdf->displayTitle('<b>' . sprintf(__('%1$s: %2$s'), _n('Installation', 'Installations', 2), $number) . "</b>");
         } else {
             $pdf->displayTitle('<b>' . sprintf(__('%1$s: %2$s'), _n('Installation', 'Installations', 2), $number / $total) . "</b>");
         }
         $pdf->setColumnsSize(12, 16, 15, 15, 22, 20);
         $pdf->displayTitle('<b><i>' . _n('Version', 'Versions', 2), __('Name'), __('Serial number'), __('Inventory number'), __('Location'), _n('License', 'Licenses', 2) . '</i></b>');
         while ($data = $DB->fetch_assoc($result)) {
             $compname = $data['compname'];
             if (empty($compname) || $_SESSION['glpiis_ids_visible']) {
                 $compname = sprintf(__('%1$s (%2$s)'), $compname, $data['cID']);
             }
             $lics = Computer_SoftwareLicense::GetLicenseForInstallation($data['cID'], $data['vID']);
             $tmp = array();
             if (count($lics)) {
                 foreach ($lics as $lic) {
                     $licname = $lic['name'];
                     if (!empty($lic['type'])) {
                         $licname = sprintf(__('%1$s (%2$s)'), $licname, $lic['type']);
                     }
                     $tmp[] = $licname;
                 }
             }
             $pdf->displayLine($data['version'], $compname, $data['serial'], $data['otherserial'], $data['location'], implode(', ', $tmp));
         }
     } else {
         $pdf->displayTitle('<b>' . _n('Installation', 'Installations', 2) . '</b>');
         $pdf->displayLine(__('No item found'));
     }
     $pdf->displaySpace();
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:56,代码来源:computer_softwareversion.class.php

示例6: processMassiveActionsForOneItemtype

 /**
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'sendmail':
             foreach ($ids as $id) {
                 if ($item->canEdit($id)) {
                     if ($item->sendMailById($id)) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:22,代码来源:queuedmail.class.php

示例7: processMassiveActionsForOneItemtype

 /**
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  * @param MassiveAction $ma
  * @param CommonDBTM $item
  * @param array $ids
  * @return void
  */
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'deleteSelected':
             if (isset($_POST['items']['PluginFpsoftwareCommon']) && is_array($_POST['items']['PluginFpsoftwareCommon'])) {
                 foreach ($_POST['items']['PluginFpsoftwareCommon'] as $id => $val) {
                     self::deleteItem($id);
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                 }
             }
             break;
     }
 }
开发者ID:dawidplocki,项目名称:glpi-fpsoftware,代码行数:20,代码来源:common.class.php

示例8: countForItem

 static function countForItem(CommonDBTM $item)
 {
     $restrict = "`glpi_documents_items`.`documents_id` = `glpi_documents`.`id`\n                   AND `glpi_documents_items`.`items_id` = '" . $item->getField('id') . "'\n                   AND `glpi_documents_items`.`itemtype` = '" . $item->getType() . "'";
     if (getLoginUserID()) {
         $restrict .= getEntitiesRestrictRequest(" AND ", "glpi_documents", '', '', true);
     } else {
         // Anonymous access from FAQ
         $restrict .= " AND `glpi_documents`.`entities_id` = '0' ";
     }
     $nb = countElementsInTable(array('glpi_documents_items', 'glpi_documents'), $restrict);
     // Document case : search in both
     if ($item->getType() == 'Document') {
         $restrict = "`glpi_documents_items`.`items_id` = `glpi_documents`.`id`\n                      AND `glpi_documents_items`.`documents_id` = '" . $item->getField('id') . "'\n                      AND `glpi_documents_items`.`itemtype` = '" . $item->getType() . "'";
         if (getLoginUserID()) {
             $restrict .= getEntitiesRestrictRequest(" AND ", "glpi_documents", '', '', true);
         } else {
             // Anonymous access from FAQ
             $restrict .= " AND `glpi_documents`.`entities_id` = '0' ";
         }
         $nb += countElementsInTable(array('glpi_documents_items', 'glpi_documents'), $restrict);
     }
     return $nb;
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:23,代码来源:document_item.class.php

示例9: showForItem

 /**
  * Show OcsLink of an item
  *
  * @param $item CommonDBTM object
  *
  * @return nothing
  **/
 static function showForItem(CommonDBTM $item)
 {
     global $DB, $LANG;
     if (in_array($item->getType(), array('Computer'))) {
         $items_id = $item->getField('id');
         $query = "SELECT `glpi_ocslinks`.`tag` AS tag\n                   FROM `glpi_ocslinks`\n                   WHERE `glpi_ocslinks`.`computers_id` = '{$items_id}' " . getEntitiesRestrictRequest("AND", "glpi_ocslinks");
         $result = $DB->query($query);
         if ($DB->numrows($result) > 0) {
             $data = $DB->fetch_assoc($result);
             $data = clean_cross_side_scripting_deep(addslashes_deep($data));
             echo "<div class='center'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr><th>" . $LANG['ocsng'][0] . "</th>";
             echo "<tr class='tab_bg_2'>";
             echo "<td class='center'>" . $LANG['ocsconfig'][39] . "&nbsp;: " . $data['tag'] . "</td></tr>";
         }
     }
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:25,代码来源:ocslink.class.php

示例10: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $CFG_GLPI;
     switch ($ma->getAction()) {
         case "uninstall":
             $itemtype = $ma->getItemtype(false);
             foreach ($ids as $id) {
                 if ($item->getFromDB($id)) {
                     //Session::addMessageAfterRedirect(sprintf(__('Form duplicated: %s', 'formcreator'), $item->getName()));
                     $_SESSION['glpi_uninstalllist'][$itemtype][$id] = $id;
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                 }
             }
             Html::redirect($CFG_GLPI["root_doc"] . '/plugins/uninstall/front/action.php?device_type=' . $itemtype . "&model_id=" . $_POST["model_id"]);
             return;
             break;
     }
     return;
 }
开发者ID:pluginsGLPI,项目名称:uninstall,代码行数:24,代码来源:uninstall.class.php

示例11: countForItem

 /**
  * @param CommonDBTM $item
  **/
 static function countForItem(CommonDBTM $item)
 {
     return countElementsInTable('glpi_networkports', "`itemtype` = '" . $item->getType() . "'\n                                      AND `items_id` ='" . $item->getField('id') . "'\n                                      AND `is_deleted` = '0'");
 }
开发者ID:gaforeror,项目名称:glpi,代码行数:7,代码来源:networkport.class.php

示例12: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'add_followup':
             $input = $ma->getInput();
             $fup = new self();
             foreach ($ids as $id) {
                 if ($item->getFromDB($id)) {
                     $input2 = array('tickets_id' => $id, 'is_private' => $input['is_private'], 'requesttypes_id' => $input['requesttypes_id'], 'content' => $input['content']);
                     if ($fup->can(-1, CREATE, $input2)) {
                         if ($fup->add($input2)) {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                     $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                 }
             }
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:33,代码来源:ticketfollowup.class.php

示例13: autocompletionTextField

 /**
  * Show div with auto completion
  *
  * @param $item            item object used for create dropdown
  * @param $field           field to search for autocompletion
  * @param $options   array of possible options:
  *    - name    : string / name of the select (default is field parameter)
  *    - value   : integer / preselected value (default value of the item object)
  *    - size    : integer / size of the text field
  *    - entity  : integer / restrict to a defined entity (default entity of the object if define)
  *                set to -1 not to take into account
  *    - user    : integer / restrict to a defined user (default -1 : no restriction)
  *    - option  : string / options to add to text field
  *    - display : boolean / if false get string
  *
  * @return nothing (print out an HTML div)
  **/
 static function autocompletionTextField(CommonDBTM $item, $field, $options = array())
 {
     global $CFG_GLPI;
     $params['name'] = $field;
     $params['value'] = '';
     if (array_key_exists($field, $item->fields)) {
         $params['value'] = $item->fields[$field];
     }
     $params['size'] = 40;
     $params['entity'] = -1;
     if (array_key_exists('entities_id', $item->fields)) {
         $params['entity'] = $item->fields['entities_id'];
     }
     $params['user'] = -1;
     $params['option'] = '';
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $params[$key] = $val;
         }
     }
     $output = '';
     if ($CFG_GLPI["use_ajax_autocompletion"]) {
         $rand = mt_rand();
         $name = "field_" . $params['name'] . $rand;
         $output .= "<input " . $params['option'] . " id='text{$name}' type='text' name='" . $params['name'] . "' value=\"" . self::cleanInputText($params['value']) . "\" size='" . $params['size'] . "'>\n";
         $parameters['itemtype'] = $item->getType();
         $parameters['field'] = $field;
         if ($params['entity'] >= 0) {
             $parameters['entity_restrict'] = $params['entity'];
         }
         if ($params['user'] >= 0) {
             $parameters['user_restrict'] = $params['user'];
         }
         $js = "  \$( '#text{$name}' ).autocomplete({\n                        source: '" . $CFG_GLPI["root_doc"] . "/ajax/autocompletion.php?" . Toolbox::append_params($parameters, '&') . "',\n                        minLength: 3,\n                        });";
         $output .= Html::scriptBlock($js);
     } else {
         $output .= "<input " . $params['option'] . " type='text' name='" . $params['name'] . "'\n                value=\"" . self::cleanInputText($params['value']) . "\" size='" . $params['size'] . "'>\n";
     }
     if (!isset($options['display']) || $options['display']) {
         echo $output;
     } else {
         return $output;
     }
 }
开发者ID:OlivierLM,项目名称:glpi,代码行数:61,代码来源:html.class.php

示例14: countForItem

 /**
  * @param $item      CommonDBTM object
  **/
 static function countForItem(CommonDBTM $item)
 {
     global $DB;
     switch ($item->getType()) {
         case 'FQDN':
             return countElementsInTable('glpi_networknames', "`fqdns_id` = '" . $item->fields["id"] . "'\n                                             AND `is_deleted` = '0'");
         case 'NetworkPort':
             return countElementsInTable('glpi_networknames', "itemtype = '" . $item->getType() . "'\n                                             AND items_id = '" . $item->getID() . "'\n                                             AND `is_deleted` = '0'");
         case 'NetworkEquipment':
             $query = "SELECT DISTINCT COUNT(*) AS cpt\n                      FROM `glpi_networknames`, `glpi_networkports`\n                      WHERE `glpi_networkports`.`itemtype` = '" . $item->getType() . "'\n                            AND `glpi_networkports`.`items_id` ='" . $item->getID() . "'\n                            AND `glpi_networkports`.`is_deleted` ='0'\n                            AND `glpi_networknames`.`itemtype` = 'NetworkPort'\n                            AND `glpi_networknames`.`items_id` = `glpi_networkports`.`id`\n                            AND `glpi_networknames`.`is_deleted` = '0'";
             $result = $DB->query($query);
             $ligne = $DB->fetch_assoc($result);
             return $ligne['cpt'];
     }
 }
开发者ID:kipman,项目名称:glpi,代码行数:18,代码来源:networkname.class.php

示例15: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $DB;
     switch ($ma->getAction()) {
         case 'add_actor':
             $input = $ma->getInput();
             foreach ($ids as $id) {
                 $input2 = array('id' => $id);
                 if (isset($input['_itil_requester'])) {
                     $input2['_itil_requester'] = $input['_itil_requester'];
                 }
                 if (isset($input['_itil_observer'])) {
                     $input2['_itil_observer'] = $input['_itil_observer'];
                 }
                 if (isset($input['_itil_assign'])) {
                     $input2['_itil_assign'] = $input['_itil_assign'];
                 }
                 if ($item->can($id, UPDATE)) {
                     if ($item->update($input2)) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             return;
         case 'update_notif':
             $input = $ma->getInput();
             foreach ($ids as $id) {
                 if ($item->can($id, UPDATE)) {
                     $linkclass = new $item->userlinkclass();
                     foreach ($linkclass->getActors($id) as $type => $users) {
                         foreach ($users as $data) {
                             $data['use_notification'] = $input['use_notification'];
                             $linkclass->update($data);
                         }
                     }
                     $linkclass = new $this->supplierlinkclass();
                     foreach ($linkclass->getActors($id) as $type => $users) {
                         foreach ($users as $data) {
                             $data['use_notification'] = $input['use_notification'];
                             $linkclass->update($data);
                         }
                     }
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             return;
         case 'add_task':
             if (!($task = getItemForItemtype($item->getType() . 'Task'))) {
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
                 break;
             }
             $field = $item->getForeignKeyField();
             $input = $ma->getInput();
             foreach ($ids as $id) {
                 if ($item->getFromDB($id)) {
                     $input2 = array($field => $id, 'taskcategories_id' => $input['taskcategories_id'], 'content' => $input['content']);
                     if ($task->can(-1, CREATE, $input2)) {
                         if ($task->add($input2)) {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                     $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:90,代码来源:commonitilobject.class.php


注:本文中的CommonDBTM::getType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。