/** * Display datas extracted from DB * * @param $data array of search datas prepared to get datas * * @return nothing **/ static function displayDatas(array &$data) { global $CFG_GLPI; $item = null; if (class_exists($data['itemtype'])) { $item = new $data['itemtype'](); } $rand = mt_rand(); if (!isset($data['data']) || !isset($data['data']['totalcount'])) { return false; } // Contruct Pager parameters $globallinkto = Toolbox::append_params(array('criteria' => Toolbox::stripslashes_deep($data['search']['criteria']), 'metacriteria' => Toolbox::stripslashes_deep($data['search']['metacriteria'])), '&'); $parameters = "sort=" . $data['search']['sort'] . "&order=" . $data['search']['order'] . '&' . $globallinkto; if (isset($_GET['_in_modal'])) { $parameters .= "&_in_modal=1"; } // Global search header if ($data['display_type'] == self::GLOBAL_SEARCH) { if ($data['item']) { echo "<div class='center'><h2>" . $data['item']->getTypeName(); // More items if ($data['data']['totalcount'] > $data['search']['start'] + self::GLOBAL_DISPLAY_COUNT) { echo " <a href='" . $data['search']['target'] . "?{$parameters}'>" . __('All') . "</a>"; } echo "</h2></div>\n"; } else { return false; } } // If the begin of the view is before the number of items if ($data['data']['count'] > 0) { // Display pager only for HTML if ($data['display_type'] == self::HTML_OUTPUT) { // For plugin add new parameter if available if ($plug = isPluginItemType($data['itemtype'])) { $function = 'plugin_' . $plug['plugin'] . '_addParamFordynamicReport'; if (function_exists($function)) { $out = $function($data['itemtype']); if (is_array($out) && count($out)) { $parameters .= Toolbox::append_params($out, '&'); } } } $search_config_top = ""; $search_config_bottom = ""; if (!isset($_GET['_in_modal']) && Session::haveRightsOr('search_config', array(DisplayPreference::PERSONAL, DisplayPreference::GENERAL))) { $search_config_top = $search_config_bottom = "<div class='pager_controls'><img alt=\"" . __s('Select default items to show') . "\" title=\"" . __s('Select default items to show') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/options_search.png' "; $search_config_top .= " class='pointer' onClick=\""; $search_config_top .= Html::jsGetElementbyID('search_config_top') . ".dialog('open');\">"; $search_config_bottom .= " class='pointer' onClick=\""; $search_config_bottom .= Html::jsGetElementbyID('search_config_bottom') . ".dialog('open');\">"; $search_config_top .= Ajax::createIframeModalWindow('search_config_top', $CFG_GLPI["root_doc"] . "/front/displaypreference.form.php?itemtype=" . $data['itemtype'], array('title' => __('Select default items to show'), 'reloadonclose' => true, 'display' => false)); $search_config_bottom .= Ajax::createIframeModalWindow('search_config_bottom', $CFG_GLPI["root_doc"] . "/front/displaypreference.form.php?itemtype=" . $data['itemtype'], array('title' => __('Select default items to show'), 'reloadonclose' => true, 'display' => false)); } if ($item !== null && $item->maybeDeleted()) { $delete_ctrl = self::isDeletedSwitch($data['search']['is_deleted']); $search_config_top .= $delete_ctrl; } Html::printPager($data['search']['start'], $data['data']['totalcount'], $data['search']['target'], $parameters, $data['itemtype'], 0, $search_config_top); $search_config_top .= "</div>"; $search_config_bottom .= "</div>"; } // Define begin and end var for loop // Search case $begin_display = $data['data']['begin']; $end_display = $data['data']['end']; // Form to massive actions $isadmin = $data['item'] && $data['item']->canUpdate(); if (!$isadmin && InfoCom::canApplyOn($data['itemtype'])) { $isadmin = Infocom::canUpdate() || Infocom::canCreate(); } if ($data['itemtype'] != 'AllAssets') { $showmassiveactions = count(MassiveAction::getAllMassiveActions($data['item'], $data['search']['is_deleted'])); } else { $showmassiveactions = true; } $massformid = 'massform' . $data['itemtype']; if ($showmassiveactions && $data['display_type'] == self::HTML_OUTPUT) { Html::openMassiveActionsForm($massformid); $massiveactionparams = $data['search']['massiveactionparams']; $massiveactionparams['num_displayed'] = $end_display - $begin_display; $massiveactionparams['fixed'] = false; $massiveactionparams['is_deleted'] = $data['search']['is_deleted']; $massiveactionparams['container'] = $massformid; Html::showMassiveActions($massiveactionparams); } // Compute number of columns to display // Add toview elements $nbcols = count($data['data']['cols']); if ($data['display_type'] == self::HTML_OUTPUT && $showmassiveactions) { // HTML display - massive modif $nbcols++; } // Display List Header echo self::showHeader($data['display_type'], $end_display - $begin_display + 1, $nbcols); // New Line for Header Items Line $headers_line = ''; $headers_line_top = ''; $headers_line_bottom = ''; $headers_line_top .= self::showBeginHeader($data['display_type']); $headers_line_top .= self::showNewLine($data['display_type']); if ($data['display_type'] == self::HTML_OUTPUT) { // $headers_line_bottom .= self::showBeginHeader($data['display_type']); $headers_line_bottom .= self::showNewLine($data['display_type']); } $header_num = 1; if ($data['display_type'] == self::HTML_OUTPUT && $showmassiveactions) { // HTML display - massive modif $headers_line_top .= self::showHeaderItem($data['display_type'], Html::getCheckAllAsCheckbox($massformid), $header_num, "", 0, $data['search']['order']); if ($data['display_type'] == self::HTML_OUTPUT) { $headers_line_bottom .= self::showHeaderItem($data['display_type'], Html::getCheckAllAsCheckbox($massformid), $header_num, "", 0, $data['search']['order']); } } // Display column Headers for toview items $metanames = array(); foreach ($data['data']['cols'] as $key => $val) { $linkto = ''; if (!$val['meta'] && (!isset($val['searchopt']['nosort']) || !$val['searchopt']['nosort'])) { $linkto = $data['search']['target'] . (strpos($data['search']['target'], '?') ? '&' : '?') . "itemtype=" . $data['itemtype'] . "&sort=" . $val['id'] . "&order=" . ($data['search']['order'] == "ASC" ? "DESC" : "ASC") . "&start=" . $data['search']['start'] . "&" . $globallinkto; } $name = $val["name"]; // prefix by group name (corresponding to optgroup in dropdown) if exists if (isset($val['groupname'])) { $name = $val['groupname'] . " - " . $name; } // Not main itemtype add itemtype to display if ($data['itemtype'] != $val['itemtype']) { if (!isset($metanames[$val['itemtype']])) { if ($metaitem = getItemForItemtype($val['itemtype'])) { $metanames[$val['itemtype']] = $metaitem->getTypeName(); } } $name = sprintf(__('%1$s - %2$s'), $metanames[$val['itemtype']], $val["name"]); } $headers_line .= self::showHeaderItem($data['display_type'], $name, $header_num, $linkto, !$val['meta'] && $data['search']['sort'] == $val['id'], $data['search']['order']); } // Add specific column Header if (isset($CFG_GLPI["union_search_type"][$data['itemtype']])) { $headers_line .= self::showHeaderItem($data['display_type'], __('Item type'), $header_num); } // End Line for column headers $headers_line .= self::showEndLine($data['display_type']); $headers_line_top .= $headers_line; if ($data['display_type'] == self::HTML_OUTPUT) { $headers_line_bottom .= $headers_line; } $headers_line_top .= self::showEndHeader($data['display_type']); // $headers_line_bottom .= self::showEndHeader($data['display_type']); echo $headers_line_top; // Init list of items displayed if ($data['display_type'] == self::HTML_OUTPUT) { Session::initNavigateListItems($data['itemtype']); } // Num of the row (1=header_line) $row_num = 1; $massiveaction_field = 'id'; if ($data['itemtype'] != 'AllAssets' && isset($CFG_GLPI["union_search_type"][$data['itemtype']])) { $massiveaction_field = 'refID'; } $typenames = array(); // Display Loop foreach ($data['data']['rows'] as $rowkey => $row) { // Column num $item_num = 1; $row_num++; // New line echo self::showNewLine($data['display_type'], $row_num % 2, $data['search']['is_deleted']); $current_type = isset($row['TYPE']) ? $row['TYPE'] : $data['itemtype']; $massiveaction_type = $current_type; if ($data['itemtype'] != 'AllAssets' && isset($CFG_GLPI["union_search_type"][$data['itemtype']])) { $massiveaction_type = $data['itemtype']; } // Add item in item list Session::addToNavigateListItems($current_type, $row["id"]); if ($data['display_type'] == self::HTML_OUTPUT && $showmassiveactions) { // HTML display - massive modif $tmpcheck = ""; if ($data['itemtype'] == 'Entity' && !in_array($row["id"], $_SESSION["glpiactiveentities"])) { $tmpcheck = " "; } else { if ($data['item'] instanceof CommonDBTM && $data['item']->maybeRecursive() && !in_array($row["entities_id"], $_SESSION["glpiactiveentities"])) { $tmpcheck = " "; } else { $tmpcheck = Html::getMassiveActionCheckBox($massiveaction_type, $row[$massiveaction_field]); } } echo self::showItem($data['display_type'], $tmpcheck, $item_num, $row_num, "width='10'"); } // Print other toview items foreach ($data['data']['cols'] as $colkey => $col) { if (!$col['meta']) { echo self::showItem($data['display_type'], $row[$colkey]['displayname'], $item_num, $row_num, self::displayConfigItem($data['itemtype'], $col['id'], $row, $colkey)); } else { // META case echo self::showItem($data['display_type'], $row[$colkey]['displayname'], $item_num, $row_num); } } if (isset($CFG_GLPI["union_search_type"][$data['itemtype']])) { if (!isset($typenames[$row["TYPE"]])) { if ($itemtmp = getItemForItemtype($row["TYPE"])) { $typenames[$row["TYPE"]] = $itemtmp->getTypeName(); } } echo self::showItem($data['display_type'], $typenames[$row["TYPE"]], $item_num, $row_num); } // End Line echo self::showEndLine($data['display_type']); } // Create title $title = ''; if ($data['display_type'] == self::PDF_OUTPUT_LANDSCAPE || $data['display_type'] == self::PDF_OUTPUT_PORTRAIT) { $title = self::computeTitle($data); } if ($data['display_type'] == self::HTML_OUTPUT) { echo $headers_line_bottom; } // Display footer echo self::showFooter($data['display_type'], $title); // Delete selected item if ($data['display_type'] == self::HTML_OUTPUT) { if ($showmassiveactions) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); // End form for delete item Html::closeForm(); } else { echo "<br>"; } } if ($data['display_type'] == self::HTML_OUTPUT) { // In case of HTML display Html::printPager($data['search']['start'], $data['data']['totalcount'], $data['search']['target'], $parameters, '', 0, $search_config_bottom); } } else { if ($item !== null && $item->maybeDeleted()) { echo "<div class='center'>" . self::isDeletedSwitch($data['search']['is_deleted']) . "</div><br/>"; } echo self::showError($data['display_type']); } }
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { switch ($ma->getAction()) { case 'add': $input = $ma->getInput(); $ticket = new Ticket(); if (isset($input['link']) && isset($input['tickets_id_1'])) { if ($item->getFromDB($input['tickets_id_1'])) { foreach ($ids as $id) { $input2 = array(); $input2['id'] = $input['tickets_id_1']; $input2['_link']['tickets_id_1'] = $input['tickets_id_1']; $input2['_link']['link'] = $input['link']; $input2['_link']['tickets_id_2'] = $id; if ($item->can($input['tickets_id_1'], UPDATE)) { if ($ticket->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; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }
/** * @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); }
/** * @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; } }
/** * @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); } } } } }
/** * @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); }
/** * @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; }
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { global $DB; switch ($ma->getAction()) { case 'force_user_ldap_update': foreach ($ids as $id) { if ($item->can($id, UPDATE)) { if ($item->fields["authtype"] == Auth::LDAP || $item->fields["authtype"] == Auth::EXTERNAL) { if (AuthLdap::ldapImportUserByServerId(array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $item->fields["name"]), 1, $item->fields["auths_id"])) { $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_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 'change_authtype': $input = $ma->getInput(); if (!isset($input["authtype"]) || !isset($input["auths_id"])) { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION)); return; } if (Session::haveRight(self::$rightname, self::UPDATEAUTHENT)) { if (User::changeAuthMethod($ids, $input["authtype"], $input["auths_id"])) { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); } } else { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_NORIGHT); $ma->addMessage($item->getErrorMessage(ERROR_RIGHT)); } return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { global $CFG_GLPI; $input = $ma->getInput(); switch ($ma->getAction()) { case 'import_group': $group = new Group(); if (!Session::haveRight("user", User::UPDATEAUTHENT) || !$group->canGlobal(UPDATE)) { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_NORIGHT); $ma->addMessage($item->getErrorMessage(ERROR_RIGHT)); return; } foreach ($ids as $id) { if (isset($input["dn"][$id])) { $group_dn = $input["dn"][$id]; if (isset($input["ldap_import_entities"][$id])) { $entity = $input["ldap_import_entities"][$id]; } else { $entity = $_SESSION["glpiactive_entity"]; } // Is recursive is in the main form and thus, don't pass through // zero_on_empty mechanism inside massive action form ... $is_recursive = empty($input['ldap_import_recursive'][$id]) ? 0 : 1; $options = array('authldaps_id' => $_SESSION['ldap_server'], 'entities_id' => $entity, 'is_recursive' => $is_recursive, 'type' => $input['ldap_import_type'][$id]); if (AuthLdap::ldapImportGroup($group_dn, $options)) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION, $group_dn)); } } // Clean history as id does not correspond to group $_SESSION['glpimassiveactionselected'] = array(); } return; case 'import': case 'sync': if (!Session::haveRight("user", User::IMPORTEXTAUTHUSERS)) { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_NORIGHT); $ma->addMessage($item->getErrorMessage(ERROR_RIGHT)); return; } foreach ($ids as $id) { if (AuthLdap::ldapImportUserByServerId(array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $id), $_SESSION['ldap_import']['mode'], $_SESSION['ldap_import']['authldaps_id'], true)) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION, $id)); } } return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }
/** * @see CommonDBTM::getSpecificMassiveActions() **/ function getSpecificMassiveActions($checkitem = NULL) { $actions = parent::getSpecificMassiveActions($checkitem); $isadmin = static::canUpdate(); if ($this->canAdminActors()) { $actions[__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'add_actor'] = __('Add an actor'); $actions[__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'update_notif'] = __('Set notifications for all actors'); } if ($isadmin) { MassiveAction::getAddTransferList($actions); } return $actions; }
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() * @param MassiveAction $ma * @param CommonDBTM $item * @param array $ids * @return nothing|void */ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { $notimport = new PluginOcsinventoryngNotimportedcomputer(); switch ($ma->getAction()) { case "plugin_ocsinventoryng_import": $input = $ma->getInput(); foreach ($ids as $id) { if (PluginOcsinventoryngNotimportedcomputer::computerImport(array('id' => $id, 'force' => true, 'entity' => $input['entity']))) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); } } return; case "plugin_ocsinventoryng_replayrules": foreach ($ids as $id) { if (PluginOcsinventoryngNotimportedcomputer::computerImport(array('id' => $id))) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); } } return; case "plugin_ocsinventoryng_delete": foreach ($ids as $id) { if ($notimport->deleteNotImportedComputer($id)) { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); } } return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }
/** * @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); }
/** * @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); }
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { switch ($ma->getAction()) { case 'export': foreach ($ids as $key) { if ($item->can($key, UPDATE)) { $item->exportPackage($key); $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } } break; case 'transfert': $pfDeployPackage = new PluginFusioninventoryDeployPackage(); foreach ($ids as $key) { if ($pfDeployPackage->getFromDB($key)) { $input = array(); $input['id'] = $key; $input['entities_id'] = $ma->POST['entities_id']; $pfDeployPackage->update($input); } } break; case 'import': foreach ($ids as $key) { $item->importPackage($key); $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } break; } return; }
/** * @see CommonDBTM::getSpecificMassiveActions() **/ function getSpecificMassiveActions($checkitem = NULL) { $isadmin = static::canUpdate(); $actions = parent::getSpecificMassiveActions($checkitem); if ($_SESSION['glpiactiveprofile']['interface'] == 'central') { if (TicketFollowup::canCreate()) { $actions['TicketFollowup' . MassiveAction::CLASS_ACTION_SEPARATOR . 'add_followup'] = __('Add a new followup'); } if (TicketTask::canCreate()) { $actions[__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'add_task'] = __('Add a new task'); } if (TicketValidation::canCreate()) { $actions['TicketValidation' . MassiveAction::CLASS_ACTION_SEPARATOR . 'submit_validation'] = __('Approval request'); } if (Item_Ticket::canCreate()) { $actions['Item_Ticket' . MassiveAction::CLASS_ACTION_SEPARATOR . 'add_item'] = _x('button', 'Add an item'); } if (Item_Ticket::canDelete()) { $actions['Item_Ticket' . MassiveAction::CLASS_ACTION_SEPARATOR . 'delete_item'] = _x('button', 'Remove an item'); } if (Session::haveRight(self::$rightname, UPDATE)) { $actions[__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'add_actor'] = __('Add an actor'); $actions[__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'enable_notif'] = __('Set notifications for all actors'); $actions['Ticket_Ticket' . MassiveAction::CLASS_ACTION_SEPARATOR . 'add'] = _x('button', 'Link tickets'); } if (Session::haveRight(self::$rightname, UPDATE)) { MassiveAction::getAddTransferList($actions); } } return $actions; }
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { switch ($ma->getAction()) { case 'reset': if (Config::canUpdate()) { foreach ($ids as $key) { if ($item->getFromDB($key)) { if ($item->resetDate()) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION)); } } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND)); } } } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT); $ma->addMessage($item->getErrorMessage(ERROR_RIGHT)); } return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }
/** * @warning this is not valid if $itemtype_1 == $itemtype_2 ! * * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { global $DB; $action = $ma->getAction(); $input = $ma->getInput(); $specificities = static::getRelationMassiveActionsSpecificities(); // First, get normalized action : add or remove if (in_array($action, $specificities['normalized']['add'])) { $normalized_action = 'add'; } else { if (in_array($action, $specificities['normalized']['remove'])) { $normalized_action = 'remove'; } else { // If we cannot get normalized action, then, its not for this method ! parent::processMassiveActionsForOneItemtype($ma, $item, $ids); return; } } $link = new static(); // Get the default 'input' entries from the relation $input2 = static::getRelationInputForProcessingOfMassiveActions($action, $item, $ids, $input); // complete input2 with the right fields from input and define the peer with this information foreach (array(static::$itemtype_1, static::$items_id_1) as $field) { if (isset($input['peer_' . $field])) { $input2[$field] = $input['peer_' . $field]; $item_number = 2; } } foreach (array(static::$itemtype_2, static::$items_id_2) as $field) { if (isset($input['peer_' . $field])) { $input2[$field] = $input['peer_' . $field]; $item_number = 1; } } // If the fields provided by showMassiveActionsSubForm are not valid then quit ! if (!isset($item_number)) { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); $ma->addMessage($link->getErrorMessage(ERROR_NOT_FOUND)); return; } if ($item_number == 1) { $itemtype = static::$itemtype_1; $items_id = static::$items_id_1; $peertype = static::$itemtype_2; $peers_id = static::$items_id_2; } else { $itemtype = static::$itemtype_2; $items_id = static::$items_id_2; $peertype = static::$itemtype_1; $peers_id = static::$items_id_1; } if (preg_match('/^itemtype/', $itemtype)) { $input2[$itemtype] = $item->getType(); } // Get the peer from the $input2 and the name of its fields $peer = static::getItemFromArray($peertype, $peers_id, $input2, true, true, true); // $peer not valid => not in DB or try to remove all at once ! if ($peer === false || $peer->isNewItem()) { if (isset($input2[$peers_id]) && $input2[$peers_id] > 0) { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); if ($peer instanceof CommonDBTM) { $ma->addMessage($peer->getErrorMessage(ERROR_NOT_FOUND)); } else { $ma->addMessage($link->getErrorMessage(ERROR_NOT_FOUND)); } return; } if (!$specificities['can_remove_all_at_once'] && !$specificities['only_remove_all_at_once']) { return false; } $peer = false; } // Make a link between $item_1, $item_2 and $item and $peer. Thus, we will be able to update // $item without having to care about the number of the item if ($item_number == 1) { $item_1 =& $item; $item_2 =& $peer; } else { $item_1 =& $peer; $item_2 =& $item; } switch ($normalized_action) { case 'add': // remove all at once only available for remove ! if (!$peer) { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); $ma->addMessage($link->getErrorMessage(ERROR_ON_ACTION)); return; } foreach ($ids as $key) { if (!$item->getFromDB($key)) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND)); continue; } $input2[$items_id] = $item->getID(); // If 'can_link_several_times', then, we add the elements ! if ($specificities['can_link_several_times']) { if ($link->can(-1, CREATE, $input2)) { if ($link->add($input2)) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); $ma->addMessage($link->getErrorMessage(ERROR_ON_ACTION)); } } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT); $ma->addMessage($link->getErrorMessage(ERROR_RIGHT)); } } else { $link->getEmpty(); if (!$link->getFromDBForItems($item_1, $item_2)) { if ($specificities['check_both_items_if_same_type'] && $item_1->getType() == $item_2->getType()) { $link->getFromDBForItems($item_2, $item_1); } } if (!$link->isNewItem()) { if (!$specificities['update_if_different']) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); $ma->addMessage($link->getErrorMessage(ERROR_ALREADY_DEFINED)); continue; } $input2[static::getIndexName()] = $link->getID(); if ($link->can($link->getID(), UPDATE, $input2)) { if ($link->update($input2)) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); $ma->addMessage($link->getErrorMessage(ERROR_ON_ACTION)); } } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT); $ma->addMessage($link->getErrorMessage(ERROR_RIGHT)); } // if index defined, then cannot not add any other link due to index unicity unset($input2[static::getIndexName()]); } else { if ($link->can(-1, CREATE, $input2)) { if ($link->add($input2)) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); $ma->addMessage($link->getErrorMessage(ERROR_ON_ACTION)); } } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT); $ma->addMessage($link->getErrorMessage(ERROR_RIGHT)); } } } } return; case 'remove': foreach ($ids as $key) { // First, get the query to find all occurences of the link item<=>key if (!$peer) { $query = static::getSQLRequestToSearchForItem($item->getType(), $key); } else { if (!$item->getFromDB($key)) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND)); continue; } $query = 'SELECT `' . static::getIndexName() . '` FROM `' . static::getTable() . '`'; $WHERE = array(); if (preg_match('/^itemtype/', static::$itemtype_1)) { $WHERE[] = " `" . static::$itemtype_1 . "` = '" . $item_1->getType() . "'"; } $WHERE[] = " `" . static::$items_id_1 . "` = '" . $item_1->getID() . "'"; if (preg_match('/^itemtype/', static::$itemtype_2)) { $WHERE[] = " `" . static::$itemtype_2 . "` = '" . $item_2->getType() . "'"; } $WHERE[] = " `" . static::$items_id_2 . "` = '" . $item_2->getID() . "'"; $query .= 'WHERE (' . implode(' AND ', $WHERE) . ')'; if ($specificities['check_both_items_if_same_type'] && $item_1->getType() == $item_2->getType()) { $WHERE = array(); if (preg_match('/^itemtype/', static::$itemtype_1)) { $WHERE[] = " `" . static::$itemtype_1 . "` = '" . $item_2->getType() . "'"; } $WHERE[] = " `" . static::$items_id_1 . "` = '" . $item_2->getID() . "'"; if (preg_match('/^itemtype/', static::$itemtype_2)) { $WHERE[] = " `" . static::$itemtype_2 . "` = '" . $item_2->getType() . "'"; } $WHERE[] = " `" . static::$items_id_2 . "` = '" . $item_2->getID() . "'"; $query .= ' OR (' . implode(' AND ', $WHERE) . ')'; } } $request = $DB->request($query); $number_results = $request->numrows(); if ($number_results == 0) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); $ma->addMessage($link->getErrorMessage(ERROR_NOT_FOUND)); continue; } $ok = 0; $ko = 0; $noright = 0; foreach ($request as $line) { if ($link->can($line[static::getIndexName()], DELETE)) { if ($link->delete(array('id' => $line[static::getIndexName()]))) { $ok++; } else { $ko++; $ma->addMessage($link->getErrorMessage(ERROR_ON_ACTION)); } } else { $noright++; $ma->addMessage($link->getErrorMessage(ERROR_RIGHT)); } } if ($ok == $number_results) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } else { if ($noright > 0) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT); } else { if ($ko > 0) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); } } } } return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }
/** * @since version 0.90 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { switch ($ma->getAction()) { case 'merge': foreach ($ids as $key) { if ($item->can($key, UPDATE)) { if ($item->getEntityID() == $_SESSION['glpiactive_entity']) { if ($item->update(array('id' => $key, 'is_recursive' => 1))) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION)); } } else { $input2 = $item->fields; // Change entity $input2['entities_id'] = $_SESSION['glpiactive_entity']; $input2['is_recursive'] = 1; $input2 = Toolbox::addslashes_deep($input2); if (!$item->import($input2)) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION)); } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } } } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT); $ma->addMessage($item->getErrorMessage(ERROR_RIGHT)); } } return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { switch ($ma->getAction()) { case "transfer": $input = $ma->getInput(); if ($item->getType() == 'PluginRacksRack') { foreach ($ids as $key) { $values["id"] = $key; $values["entities_id"] = $input['entities_id']; if ($item->update($values)) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); } } } break; } }
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { switch ($ma->getAction()) { case "add_model": $model = new PluginManufacturersimportsModel(); $input = $ma->getInput(); foreach ($ma->items as $itemtype => $myitem) { foreach ($myitem as $key => $value) { $input = array('model_name' => $ma->POST['model_name'], 'items_id' => $key, 'itemtype' => $itemtype); if ($model->addModel($input)) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); } } } break; } }
/** * @see CommonDBTM::getSpecificMassiveActions() **/ function getSpecificMassiveActions($checkitem = NULL) { $isadmin = static::canUpdate(); $actions = parent::getSpecificMassiveActions($checkitem); if ($isadmin) { $actions['Computer_Item' . MassiveAction::CLASS_ACTION_SEPARATOR . 'add'] = _x('button', 'Connect'); $actions['Computer_SoftwareVersion' . MassiveAction::CLASS_ACTION_SEPARATOR . 'add'] = _x('button', 'Install'); } if ($isadmin) { MassiveAction::getAddTransferList($actions); } return $actions; }
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { global $CFG_GLPI; switch ($ma->getAction()) { case "transfert": $input = $ma->getInput(); $entities_id = $input['entities_id']; foreach ($ids as $id) { if ($item->getFromDB($id)) { $item->update(array("id" => $id, "entities_id" => $entities_id, "update" => __('Update'))); $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } } return; break; } return; }
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() * */ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { global $DB; switch ($ma->getAction()) { case "transfer": $input = $ma->getInput(); if ($item->getType() == 'PluginTasklistsTask') { foreach ($ids as $key) { $item->getFromDB($key); $type = PluginTasklistsTaskType::transfer($item->fields["plugin_tasklists_tasktypes_id"], $input['entities_id']); if ($type > 0) { $values["id"] = $key; $values["plugin_tasklists_tasktypes_id"] = $type; $item->update($values); } unset($values); $values["id"] = $key; $values["entities_id"] = $input['entities_id']; if ($item->update($values)) { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO); } } } return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { switch ($ma->getAction()) { case 'duplicate': // For calendar duplicate in another entity if (method_exists($item, 'duplicate')) { $input = $ma->getInput(); $options = array(); if ($item->isEntityAssign()) { $options = array('entities_id' => $input['entities_id']); } foreach ($ids as $id) { if ($item->getFromDB($id)) { if (!$item->isEntityAssign() || $input['entities_id'] != $item->getEntityID()) { if ($item->can(-1, CREATE, $options)) { if ($item->duplicate($options)) { $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_COMPAT)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND)); } } } else { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); } return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }
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 */ include '../inc/includes.php'; Session::checkCentralAccess(); header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); try { $ma = new MassiveAction($_POST, $_GET, 'process'); } catch (Exception $e) { Html::popHeader(__('Bulk modification error'), $_SERVER['PHP_SELF']); echo "<div class='center'><img src='" . $CFG_GLPI["root_doc"] . "/pics/warning.png' alt='" . __s('Warning') . "'><br><br>"; echo "<span class='b'>" . $e->getMessage() . "</span><br>"; Html::displayBackLink(); echo "</div>"; Html::popFooter(); exit; } Html::popHeader(__('Bulk modification'), $_SERVER['PHP_SELF']); $results = $ma->process(); $nbok = $results['ok']; $nbko = $results['ko']; $nbnoright = $results['noright']; if ($nbok == 0) {
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { global $DB; switch ($ma->getAction()) { case 'transform_to': $input = $ma->getInput(); if (isset($input["transform_to"]) && !empty($input["transform_to"])) { $networkport = new NetworkPort(); foreach ($ids as $id) { if ($networkport->canEdit($id) && $item->can($id, DELETE)) { if (empty($networkport->fields['instantiation_type'])) { if ($networkport->switchInstantiationType($input['transform_to']) !== false) { $instantiation = $networkport->getInstantiation(); $input2 = $item->fields; $input2['networkports_id'] = $input2['id']; unset($input2['id']); if ($instantiation->add($input2)) { $item->delete(array('id' => $id)); $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($networkport->getErrorMessage(ERROR_ON_ACTION)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($networkport->getErrorMessage(ERROR_ON_ACTION)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO); $ma->addMessage($networkport->getErrorMessage(ERROR_ON_ACTION)); } } else { $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT); $ma->addMessage($networkport->getErrorMessage(ERROR_RIGHT)); } } } else { $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); } return; } parent::processMassiveActionsForOneItemtype($ma, $item, $ids); }
/** * @see CommonDBTM::getSpecificMassiveActions() **/ function getSpecificMassiveActions($checkitem = NULL) { $actions = parent::getSpecificMassiveActions($checkitem); if (static::canUpdate()) { Computer_Item::getMassiveActionsForItemtype($actions, __CLASS__, 0, $checkitem); MassiveAction::getAddTransferList($actions); } return $actions; }
/** * @since version 0.85 * * @see CommonDBTM::processMassiveActionsForOneItemtype() **/ static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids) { switch ($ma->getAction()) { case 'changegroup': $input = $ma->getInput(); if (isset($input["field"]) && isset($input['groups_id'])) { foreach ($ids as $id) { if ($item->can($id, UPDATE)) { if ($item->update(array('id' => $id, $input["field"] => $input["groups_id"]))) { $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(), $ids, MassiveAction::ACTION_KO); $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION)); } return; } parent::processMassiveActionsForOneItemtype($ma, $baseitem, $ids); }
/** * @see CommonDBTM::getSpecificMassiveActions() **/ function getSpecificMassiveActions($checkitem = NULL) { $isadmin = static::canUpdate(); $actions = parent::getSpecificMassiveActions($checkitem); if ($isadmin) { MassiveAction::getAddTransferList($actions); } return $actions; }
/** * @since version 0.85 * * @see CommonDBRelation::showRelationMassiveActionsSubForm() **/ static function showRelationMassiveActionsSubForm(MassiveAction $ma, $peer_number) { if ($ma->getAction() == 'add' && $peer_number == 2) { echo "<br><br>" . sprintf(__('%1$s: %2$s'), _n('Entity', 'Entities', 1), ''); Entity::dropdown(array('entity' => $_SESSION['glpiactiveentities'])); echo "<br><br>" . sprintf(__('%1$s: %2$s'), __('Recursive'), ''); Html::showCheckbox(array('name' => 'is_recursive')); } }