function plugin_genericobject_AssignToTicket($types) { foreach (PluginGenericobjectType::getTypes() as $tmp => $value) { $itemtype = $value['itemtype']; if ($value['use_tickets'] && plugin_genericobject_haveRight($itemtype . '_open_ticket', "1")) { $types[$itemtype] = $itemtype::getTypeName(); } } return $types; }
static function canCreate() { return plugin_genericobject_haveRight($this->{$itemtype_1}, 'w'); }
http://www.gnu.org/licenses/gpl.txt @link https://forge.indepnet.net/projects/genericobject @link http://www.glpi-project.org/ @since 2009 ---------------------------------------------------------------------- */ define('GLPI_ROOT', '../..'); include GLPI_ROOT . "/inc/includes.php"; if (isset($_GET['itemtypes_id']) && $_GET['itemtypes_id'] != '') { $type = new PluginGenericobjectType(); $type->getFromDB($_GET['itemtypes_id']); Html::redirect(Toolbox::getItemTypeSearchURL($type->fields['itemtype'])); } else { $types = PluginGenericobjectType::getTypesByFamily(); foreach ($types as $family => $typeData) { foreach ($typeData as $ID => $value) { if (!plugin_genericobject_haveRight($value['itemtype'], 'r')) { unset($types[$family][$ID]); } } } //There's only one family if (count($types) == 1) { //There's only one itemtype ? If yes, then automatically //redirect to the search engine if (key($types) == NULL) { $mytypes = $types; $tmp = array_pop($mytypes); if (count($tmp) == 1) { Html::redirect(Toolbox::getItemTypeSearchURL(key($tmp))); } }
static function registerType() { global $DB, $PLUGIN_HOOKS, $UNINSTALL_TYPES, $ORDER_TYPES, $CFG_GLPI, $GO_LINKED_TYPES; $class = get_called_class(); $item = new $class(); $fields = PluginGenericobjectSingletonObjectField::getInstance($class); PluginGenericobjectType::includeLocales($item->getObjectTypeName()); PluginGenericobjectType::includeConstants($item->getObjectTypeName()); $options = array("document_types" => $item->canUseDocuments(), "helpdesk_visible_types" => $item->canUseTickets(), "linkgroup_types" => $item->canUseTickets() && isset ($fields["groups_id"]), "linkuser_types" => $item->canUseTickets() && isset ($fields["users_id"]), "ticket_types" => $item->canUseTickets(), "infocom_types" => $item->canUseInfocoms(), "networkport_types" => $item->canUseNetworkPorts(), "reservation_types" => $item->canBeReserved(), "contract_types" => $item->canUseContracts(), "unicity_types" => $item->canUseUnicity()); Plugin::registerClass($class, $options); if (plugin_genericobject_haveRight($class, READ)) { //Change url for adding a new object, depending on template management activation if ($item->canUseTemplate()) { //Template management is active $add_url = "/front/setup.templates.php?itemtype=$class&add=1"; $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['template'] = "/front/setup.templates.php?itemtype=$class&add=0"; } else { //Template management is not active $add_url = Toolbox::getItemTypeFormURL($class, false); } //Menu management $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['title'] = $class::getTypeName(); $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['page'] = Toolbox::getItemTypeSearchURL($class, false); $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['search'] = Toolbox::getItemTypeSearchURL($class, false); if (plugin_genericobject_haveRight($class, "w")) { $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['add'] = $add_url; } //Add configuration icon, if user has right if (Session::haveRight('config', UPDATE)) { $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['config'] = Toolbox::getItemTypeSearchURL('PluginGenericobjectType',false)."?itemtype=$class"; } if ($item->canUsePluginUninstall()) { if (!in_array($class, $UNINSTALL_TYPES)) { array_push($UNINSTALL_TYPES, $class); } } if ($item->canUsePluginOrder()) { if (!in_array($class, $ORDER_TYPES)) { array_push($ORDER_TYPES, $class); } } if ($item->canUseGlobalSearch()) { if (!in_array($class, $CFG_GLPI['asset_types'])) { array_push($CFG_GLPI['asset_types'], $class); } if (!in_array($class, $CFG_GLPI['globalsearch_types'])) { array_push($CFG_GLPI['globalsearch_types'], $class); } } if ($item->canUseDirectConnections()) { if (!in_array($class, $GO_LINKED_TYPES)) { array_push($GO_LINKED_TYPES, $class); } $items_class = $class."_Item"; //if (class_exists($items_class)) { $items_class::registerType(); //} } } foreach(PluginGenericobjectType::getDropdownForItemtype($class) as $table) { $itemtype = getItemTypeForTable($table); if (class_exists($itemtype) ) { $item = new $itemtype(); //If entity dropdown, check rights to view & create if ($itemtype::canView()) { $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$itemtype]['links']['search'] = Toolbox::getItemTypeSearchURL($itemtype, false); if ($itemtype::canCreate()) { $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['add'] = Toolbox::getItemTypeFormURL($class, false); } } } } }
static function canViewAtLeastOneType() { $types = self::getTypes(); $view = false; foreach ($types as $ID => $value) { if (plugin_genericobject_haveRight($value['itemtype'], 'r')) { $view = true; break; } } return $view; }
/** * Display object preview form * @param type the object type */ static function showPrevisualisationForm(PluginGenericobjectType $type) { $itemtype = $type->fields['itemtype']; $item = new $itemtype(); if (plugin_genericobject_haveRight($itemtype, 'r')) { $item->showForm(-1, array(), true); } else { echo "<br><strong>" . __("You must configure rights to enable the preview", "genericobject") . "</strong><br>"; } }