/** * Get dropdowns for plugins * * @return Array containing plugin dropdowns */ function getPluginsDropdowns() { $dps = array(); if (isset($_SESSION["glpi_plugins"]) && is_array($_SESSION["glpi_plugins"])) { foreach ($_SESSION["glpi_plugins"] as $plug) { $tab = doOneHook($plug, 'getDropdown'); if (is_array($tab)) { $function = "plugin_version_{$plug}"; $name = $function(); $dps = array_merge($dps, array($name['name'] => $tab)); } } } return $dps; }
/** * Check if it's possible to assign ticket to a type (core or plugin) * * @param $itemtype the object's type * * @return true if ticket can be assign to this type, false if not **/ static function isPossibleToAssignType($itemtype) { global $PLUGIN_HOOKS; // Plugin case if (isPluginItemType($itemtype)) { /// TODO maybe only check plugin of itemtype ? //If it's not a core's type, then check plugins $types = array(); if (isset($PLUGIN_HOOKS['assign_to_ticket'])) { foreach ($PLUGIN_HOOKS['assign_to_ticket'] as $plugin => $value) { $types = doOneHook($plugin, 'AssignToTicket', $types); } if (array_key_exists($itemtype, $types)) { return true; } } // standard case } else { if (in_array($itemtype, $_SESSION["glpiactiveprofile"]["helpdesk_item_type"])) { return true; } } return false; }
} else { $mailcollector->deleteOrImportSeveralEmails($emails_ids, 1, $_POST['entities_id']); } } break; default: // Plugin specific actions $split = explode('_', $_POST["action"]); if ($split[0] == 'plugin' && isset($split[1])) { // Normalized name plugin_name_action // Allow hook from any plugin on any (core or plugin) type doOneHook($split[1], 'MassiveActionsProcess', $_POST); } else { if ($plug = isPluginItemType($_POST["itemtype"])) { // non-normalized name // hook from the plugin defining the type doOneHook($plug['plugin'], 'MassiveActionsProcess', $_POST); } } } addMessageAfterRedirect($LANG['common'][23]); glpi_header($REDIRECT); } else { //action, itemtype or item not defined echo "<div class='center'>" . "<img src='" . $CFG_GLPI["root_doc"] . "/pics/warning.png' alt='warning'><br><br>"; echo "<b>" . $LANG['common'][24] . "</b></div>"; displayBackLink(); } commonFooter(); } // itemtype defined
echo $newgroup; } if (!$first_group) { echo "</optgroup>"; } echo "</select>"; $paramsmassaction = array('id_field' => '__VALUE__', 'itemtype' => $_POST["itemtype"]); foreach ($_POST as $key => $val) { if (preg_match("/extra_/", $key, $regs)) { $paramsmassaction[$key] = $val; } } ajaxUpdateItemOnSelectEvent("massiveaction_field", "show_massiveaction_field", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveActionField.php", $paramsmassaction); echo "<span id='show_massiveaction_field'> </span>\n"; break; default: // Plugin specific actions $split = explode('_', $_POST["action"]); if ($split[0] == 'plugin' && isset($split[1])) { // Normalized name plugin_name_action // Allow hook from any plugin on any (core or plugin) type doOneHook($split[1], 'MassiveActionsDisplay', array('itemtype' => $_POST["itemtype"], 'action' => $_POST["action"])); } else { if ($plug = isPluginItemType($_POST["itemtype"])) { // non-normalized name // hook from the plugin defining the type doOneHook($plug['plugin'], 'MassiveActionsDisplay', $_POST["itemtype"], $_POST["action"]); } } } }
$params = unserialize(stripslashes($_GET["item_type_param"])); switch ($params["type"]) { case "comp_champ": $val = Stat::getItems($params["date1"], $params["date2"], $params["dropdown"]); Stat::show($params["type"], $params["date1"], $params["date2"], $params["start"], $val, $params["dropdown"]); break; case "device": $val = Stat::getItems($params["date1"], $params["date2"], $params["dropdown"]); Stat::show($params["type"], $params["date1"], $params["date2"], $params["start"], $val, $params["dropdown"]); break; default: $val = Stat::getItems($params["date1"], $params["date2"], $params["type"]); Stat::show($params["type"], $params["date1"], $params["date2"], $params["start"], $val); } } else { if (isset($_GET["type"]) && $_GET["type"] == "hardwares") { Stat::showItems("", $_GET["date1"], $_GET["date2"], $_GET['start']); } } break; default: // Plugin case if ($plug = isPluginItemType($_GET["item_type"])) { if (doOneHook($plug['plugin'], 'dynamicReport', $_GET)) { exit; } } Search::manageGetValues($_GET["item_type"]); Search::showList($_GET["item_type"], $_GET); } }
/** * Dropdown of actions for massive action * * @param $itemtype item type * @param $is_deleted massive action for deleted items ? * @param $extraparams array of extra parameters **/ static function showForMassiveAction($itemtype, $is_deleted = 0, $extraparams = array()) { global $LANG, $CFG_GLPI, $PLUGIN_HOOKS; /// TODO include in CommonDBTM defining only getAdditionalMassiveAction in sub classes /// for specific actions (return a array of action name and title) if (!class_exists($itemtype)) { return false; } if ($itemtype == 'NetworkPort') { echo "<select name='massiveaction' id='massiveaction'>"; echo "<option value='-1' selected>" . DROPDOWN_EMPTY_VALUE . "</option>"; echo "<option value='delete'>" . $LANG['buttons'][6] . "</option>"; echo "<option value='assign_vlan'>" . $LANG['networking'][55] . "</option>"; echo "<option value='unassign_vlan'>" . $LANG['networking'][58] . "</option>"; // Interest of this massive action ? // echo "<option value='move'>".$LANG['buttons'][20]."</option>"; echo "</select>"; $params = array('action' => '__VALUE__', 'itemtype' => $itemtype); ajaxUpdateItemOnSelectEvent("massiveaction", "show_massiveaction", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveActionPorts.php", $params); echo "<span id='show_massiveaction'> </span>\n"; } else { $item = new $itemtype(); $infocom = new Infocom(); $isadmin = $item->canUpdate(); echo "<select name='massiveaction' id='massiveaction'>"; echo "<option value='-1' selected>" . DROPDOWN_EMPTY_VALUE . "</option>"; if (!in_array($itemtype, $CFG_GLPI["massiveaction_noupdate_types"]) && ($isadmin && $itemtype != 'Ticket' || in_array($itemtype, $CFG_GLPI["infocom_types"]) && $infocom->canUpdate() || $itemtype == 'Ticket' && haveRight('update_ticket', 1))) { echo "<option value='update'>" . $LANG['buttons'][14] . "</option>"; } if (in_array($itemtype, $CFG_GLPI["infocom_types"]) && $infocom->canCreate()) { echo "<option value='activate_infocoms'>" . $LANG['financial'][68] . "</option>"; } if ($is_deleted && !in_array($itemtype, $CFG_GLPI["massiveaction_nodelete_types"])) { if ($isadmin) { echo "<option value='purge'>" . $LANG['buttons'][22] . "</option>"; echo "<option value='restore'>" . $LANG['buttons'][21] . "</option>"; } } else { // No delete for entities and tracking of not have right if (!in_array($itemtype, $CFG_GLPI["massiveaction_nodelete_types"]) && ($isadmin && $itemtype != 'Ticket' || $itemtype == 'Ticket' && haveRight('delete_ticket', 1))) { if ($item->maybeDeleted()) { echo "<option value='delete'>" . $LANG['buttons'][6] . "</option>"; } else { echo "<option value='purge'>" . $LANG['buttons'][22] . "</option>"; } } if ($isadmin && in_array($itemtype, array('Phone', 'Printer', 'Peripheral', 'Monitor'))) { echo "<option value='connect'>" . $LANG['buttons'][9] . "</option>"; echo "<option value='disconnect'>" . $LANG['buttons'][10] . "</option>"; } if (in_array($itemtype, $CFG_GLPI["document_types"])) { $doc = new Document(); if ($doc->canView()) { echo "<option value='add_document'>" . $LANG['document'][16] . "</option>"; } } if (in_array($itemtype, $CFG_GLPI["contract_types"])) { $contract = new Contract(); if ($contract->canUpdate()) { echo "<option value='add_contract'>" . $LANG['financial'][36] . "</option>"; } } if (haveRight('transfer', 'r') && isMultiEntitiesMode() && in_array($itemtype, array('CartridgeItem', 'Computer', 'ConsumableItem', 'Contact', 'Contract', 'Supplier', 'Monitor', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer', 'Software', 'SoftwareLicense', 'Ticket', 'Document', 'Group', 'Link')) && $isadmin) { echo "<option value='add_transfer_list'>" . $LANG['buttons'][48] . "</option>"; } switch ($itemtype) { case 'Software': if ($isadmin && countElementsInTable("glpi_rules", "sub_type='RuleSoftwareCategory'") > 0) { echo "<option value='compute_software_category'>" . $LANG['rulesengine'][38] . " " . $LANG['rulesengine'][40] . "</option>"; } if (haveRight("rule_dictionnary_software", "w") && countElementsInTable("glpi_rules", "sub_type='RuleDictionnarySoftware'") > 0) { echo "<option value='replay_dictionnary'>" . $LANG['rulesengine'][76] . "</option>"; } break; case 'Computer': if ($isadmin) { echo "<option value='connect_to_computer'>" . $LANG['buttons'][9] . "</option>"; echo "<option value='install'>" . $LANG['buttons'][4] . "</option>"; if ($CFG_GLPI['use_ocs_mode']) { if (haveRight("ocsng", "w") || haveRight("sync_ocsng", "w")) { echo "<option value='force_ocsng_update'>" . $LANG['ocsng'][24] . "</option>"; } echo "<option value='unlock_ocsng_field'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][16] . "</option>"; echo "<option value='unlock_ocsng_monitor'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][30] . "</option>"; echo "<option value='unlock_ocsng_peripheral'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][32] . "</option>"; echo "<option value='unlock_ocsng_printer'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][34] . "</option>"; echo "<option value='unlock_ocsng_software'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][52] . "</option>"; echo "<option value='unlock_ocsng_ip'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][50] . "</option>"; echo "<option value='unlock_ocsng_disk'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][55] . "</option>"; } } break; case 'Supplier': if ($isadmin) { echo "<option value='add_contact'>" . $LANG['financial'][24] . "</option>"; } break; case 'Calendar': echo "<option value='duplicate'>" . $LANG['buttons'][54] . "</option>"; break; case 'Contact': if ($isadmin) { echo "<option value='add_enterprise'>" . $LANG['financial'][25] . "</option>"; } break; case 'User': if ($isadmin) { echo "<option value='add_group'>" . $LANG['setup'][604] . "</option>"; echo "<option value='add_userprofile'>" . $LANG['setup'][607] . "</option>"; } if (haveRight("user_authtype", "w")) { echo "<option value='change_authtype'>" . $LANG['login'][30] . "</option>"; echo "<option value='force_user_ldap_update'>" . $LANG['ocsng'][24] . "</option>"; } break; case 'Ticket': $tmp = new TicketFollowup(); if ($tmp->canCreate()) { echo "<option value='add_followup'>" . $LANG['job'][29] . "</option>"; } $tmp = new TicketTask(); if ($tmp->canCreate()) { echo "<option value='add_task'>" . $LANG['job'][30] . "</option>"; } $tmp = new TicketValidation(); if ($tmp->canCreate()) { echo "<option value='submit_validation'>" . $LANG['validation'][26] . "</option>"; } if (haveRight("update_ticket", "1")) { echo "<option value='add_actor'>" . $LANG['job'][27] . "</option>"; echo "<option value='link_ticket'>" . $LANG['job'][56] . "</option>"; } break; case 'CronTask': echo "<option value='reset'>" . $LANG['buttons'][16] . " (" . $LANG['crontask'][40] . ")"; echo "</option>"; break; case 'NotImportedEmail': echo "<option value='delete_email'>" . $LANG['mailing'][133] . "</option>"; echo "<option value='import_email'>" . $LANG['buttons'][37] . "</option>"; break; } if ($item instanceof CommonTreeDropdown) { if ($isadmin) { echo "<option value='move_under'>" . $LANG['buttons'][20] . "</option>"; } } if ($itemtype != 'Entity' && $itemtype != 'Calendar' && $item instanceof CommonDropdown && $item->maybeRecursive()) { if ($isadmin) { echo "<option value='merge'>" . $LANG['buttons'][48] . " - " . $LANG['software'][48]; echo "</option>"; } } // Plugin Specific actions if (isset($PLUGIN_HOOKS['use_massive_action'])) { foreach ($PLUGIN_HOOKS['use_massive_action'] as $plugin => $val) { $actions = doOneHook($plugin, 'MassiveActions', $itemtype); if (count($actions)) { foreach ($actions as $key => $val) { echo "<option value = '{$key}'>{$val}</option>"; } } } } } echo "</select>"; $params = array('action' => '__VALUE__', 'is_deleted' => $is_deleted, 'itemtype' => $itemtype); if (count($extraparams)) { foreach ($extraparams as $key => $val) { $params['extra_' . $key] = $val; } } ajaxUpdateItemOnSelectEvent("massiveaction", "show_massiveaction", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveAction.php", $params); echo "<span id='show_massiveaction'> </span>\n"; } }
case "glpi_softwareversions": switch ($search["linkfield"]) { case "softwareversions_id_use": case "softwareversions_id_buy": $_POST['softwares_id'] = $_POST['extra_softwares_id']; $_POST['myname'] = $search['linkfield']; include "dropdownInstallVersion.php"; break; } break; default: // dropdown case $plugdisplay = false; // Specific plugin Type case if (($plug = isPluginItemType($_POST["itemtype"])) || ($plug = isPluginItemType(getItemTypeForTable($search['table'])))) { $plugdisplay = doOneHook($plug['plugin'], 'MassiveActionsFieldsDisplay', array('itemtype' => $_POST["itemtype"], 'options' => $search)); } $already_display = false; if (isset($search['datatype'])) { switch ($search['datatype']) { case "date": showDateFormItem($search["field"]); $already_display = true; break; case "datetime": showDateTimeFormItem($search["field"]); $already_display = true; break; case "bool": Dropdown::showYesNo($search["linkfield"]); $already_display = true;