function plugin_init_databases() { global $PLUGIN_HOOKS; $PLUGIN_HOOKS['csrf_compliant']['databases'] = true; $PLUGIN_HOOKS['change_profile']['databases'] = array('PluginDatabasesProfile', 'initProfile'); $PLUGIN_HOOKS['assign_to_ticket']['databases'] = true; //$PLUGIN_HOOKS['assign_to_ticket_dropdown']['databases'] = true; //$PLUGIN_HOOKS['assign_to_ticket_itemtype']['databases'] = array('PluginDatabasesDatabase_Item'); Plugin::registerClass('PluginDatabasesDatabase', array('linkgroup_tech_types' => true, 'linkuser_tech_types' => true, 'document_types' => true, 'ticket_types' => true, 'helpdesk_visible_types' => true, 'addtabon' => 'Supplier')); Plugin::registerClass('PluginDatabasesProfile', array('addtabon' => 'Profile')); //Plugin::registerClass('PluginDatabasesDatabase_Item', // array('ticket_types' => true)); if (class_exists('PluginAccountsAccount')) { PluginAccountsAccount::registerType('PluginDatabasesDatabase'); } if (Session::getLoginUserID()) { $plugin = new Plugin(); if (!$plugin->isActivated('environment') && Session::haveRight("plugin_databases", READ)) { $PLUGIN_HOOKS['menu_toadd']['databases'] = array('assets' => 'PluginDatabasesMenu'); } if (Session::haveRight("plugin_databases", UPDATE)) { $PLUGIN_HOOKS['use_massive_action']['databases'] = 1; } if (class_exists('PluginDatabasesDatabase_Item')) { // only if plugin activated $PLUGIN_HOOKS['plugin_datainjection_populate']['databases'] = 'plugin_datainjection_populate_databases'; } // End init, when all types are registered $PLUGIN_HOOKS['post_init']['databases'] = 'plugin_databases_postinit'; // Import from Data_Injection plugin $PLUGIN_HOOKS['migratetypes']['databases'] = 'plugin_datainjection_migratetypes_databases'; } }
/** * Initialize all classes and generic variables of the plugin */ function plugin_init_formcreator() { global $PLUGIN_HOOKS; // Add specific CSS $PLUGIN_HOOKS['add_css']['formcreator'][] = "css/styles.css"; if (strpos($_SERVER['REQUEST_URI'], "front/helpdesk.public.php") !== false) { $PLUGIN_HOOKS['add_javascript']['formcreator'][] = 'scripts/helpdesk.js'; } elseif (strpos($_SERVER['REQUEST_URI'], "front/central.php") !== false) { $PLUGIN_HOOKS['add_javascript']['formcreator'][] = 'scripts/homepage.js'; } if (isset($_SESSION['glpiactiveprofile'])) { if ($_SESSION['glpiactiveprofile']['interface'] == 'helpdesk') { $PLUGIN_HOOKS['add_javascript']['formcreator'][] = 'scripts/helpdesk-menu.js'; } } $PLUGIN_HOOKS['add_javascript']['formcreator'][] = 'scripts/forms-validation.js.php'; // Set the plugin CSRF compliance (required in GLPI 0.84) $PLUGIN_HOOKS['csrf_compliant']['formcreator'] = true; // Add a link in the main menu plugins for technician and admin panel $PLUGIN_HOOKS['menu_entry']['formcreator'] = 'front/formlist.php'; // Config page $plugin = new Plugin(); $links = array(); if (Session::haveRight('config', 'w') && $plugin->isActivated("formcreator")) { $PLUGIN_HOOKS['config_page']['formcreator'] = 'front/form.php'; $links['config'] = '/plugins/formcreator/front/form.php'; $links['add'] = '/plugins/formcreator/front/form.form.php'; } // Set options for pages (title, links, buttons...) $links['search'] = '/plugins/formcreator/front/formlist.php'; $PLUGIN_HOOKS['submenu_entry']['formcreator']['options'] = array('config' => array('title' => __('Setup'), 'page' => '/plugins/formcreator/front/form.php', 'links' => $links), 'options' => array('title' => _n('Form', 'Forms', 2, 'formcreator'), 'links' => $links)); // Load field class and all its method to manage fields Plugin::registerClass('PluginFormcreatorFields'); }
static function canView() { if (static::$rightname) { return Session::haveRight(static::$rightname, PluginTalkTicket::ACTIVE); } return false; }
/** * Function Init */ function plugin_init_uninstall() { global $PLUGIN_HOOKS, $CFG_GLPI, $UNINSTALL_TYPES, $UNINSTALL_DIRECT_CONNECTIONS_TYPE; $PLUGIN_HOOKS['csrf_compliant']['uninstall'] = true; Plugin::registerClass('PluginUninstallPreference', array('addtabon' => array('Preference'))); Plugin::registerClass('PluginUninstallProfile', array('addtabon' => array('Profile'))); $plugin = new Plugin(); if ($plugin->isActivated('uninstall')) { $UNINSTALL_TYPES = array('Computer', 'Monitor', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer'); $UNINSTALL_DIRECT_CONNECTIONS_TYPE = array('Monitor', 'Peripheral', 'Phone', 'Printer'); if (Session::getLoginUserID()) { if (Session::haveRight(PluginUninstallProfile::$rightname, READ)) { $PLUGIN_HOOKS['use_massive_action']['uninstall'] = true; if (Session::haveRight('uninstall:profile', READ)) { // Add link in GLPI plugins list : $PLUGIN_HOOKS["menu_toadd"]['uninstall'] = array('admin' => 'PluginUninstallModel'); // add to 'Admin' menu : $PLUGIN_HOOKS['config_page']['uninstall'] = "front/model.php"; } //Item actions $PLUGIN_HOOKS['item_update']['uninstall'] = array('PluginUninstallModel' => array('PluginUninstallPreference', 'afterUpdateModel')); $PLUGIN_HOOKS['item_delete']['uninstall'] = array('PluginUninstallModel' => array('PluginUninstallPreference', 'beforeItemPurge')); $PLUGIN_HOOKS['pre_item_purge']['uninstall'] = array('User' => array('PluginUninstallPreference', 'beforeItemPurge')); } } $PLUGIN_HOOKS['post_init']['uninstall'] = 'plugin_uninstall_postinit'; } }
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if (in_array($item->getType(), self::getTypes(true)) && Session::haveRight("plugin_financialreports", READ)) { return PluginFinancialreportsFinancialreport::getTypeName(); } return ''; }
static function afterAdd(Group_Ticket $item) { global $DB; //Toolbox::logDebug(__METHOD__, $item); $config = PluginBehaviorsConfig::getInstance(); if ($config->getField('add_notif')) { if ($item->getField('type') == CommonITILActor::ASSIGN) { $ticket = new Ticket(); if ($ticket->getFromDB($item->getField('tickets_id'))) { NotificationEvent::raiseEvent('plugin_behaviors_ticketnewgrp', $ticket); } } } // Check is the connected user is a tech if (!is_numeric(Session::getLoginUserID(false)) || !Session::haveRight('own_ticket', 1)) { return false; // No check } $config = PluginBehaviorsConfig::getInstance(); if ($config->getField('single_tech_mode') != 0 && $item->input['type'] == CommonITILActor::ASSIGN) { $crit = array('tickets_id' => $item->input['tickets_id'], 'type' => CommonITILActor::ASSIGN); foreach ($DB->request('glpi_groups_tickets', $crit) as $data) { if ($data['id'] != $item->getID()) { $gu = new Group_Ticket(); $gu->delete($data); } } if ($config->getField('single_tech_mode') == 2) { foreach ($DB->request('glpi_tickets_users', $crit) as $data) { $gu = new Ticket_User(); $gu->delete($data); } } } }
static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $ticket) { global $CFG_GLPI, $DB; $pdf->setColumnsSize(100); $pdf->displayTitle("<b>" . __('Approvals for the ticket') . "</b>"); if (!Session::haveRight('validate_request', 1) && !Session::haveRight('validate_incident', 1) && !Session::haveRight('create_incident_validation', 1) && !Session::haveRight('create_request_validation', 1)) { return false; } $ID = $ticket->getField('id'); $query = "SELECT *\n FROM `glpi_ticketvalidations`\n WHERE `tickets_id` = '" . $ticket->getField('id') . "'\n ORDER BY submission_date DESC"; $result = $DB->query($query); $number = $DB->numrows($result); if ($number) { $pdf->setColumnsSize(20, 19, 21, 19, 21); $pdf->displayTitle(_x('item', 'State'), __('Request date'), __('Approval requester'), __('Approval date'), __('Approver')); while ($row = $DB->fetch_assoc($result)) { $pdf->setColumnsSize(20, 19, 21, 19, 21); $pdf->displayLine(TicketValidation::getStatus($row['status']), Html::convDateTime($row["submission_date"]), getUserName($row["users_id"]), Html::convDateTime($row["validation_date"]), getUserName($row["users_id_validate"])); $tmp = trim($row["comment_submission"]); $pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Request comments') . "</i></b>", empty($tmp) ? __('None') : $tmp, 1)); if ($row["validation_date"]) { $tmp = trim($row["comment_validation"]); $pdf->displayText("<b><i>" . sprintf(__('%1$s: %2$s'), __('Approval comments') . "</i></b>", empty($tmp) ? __('None') : $tmp, 1)); } } } else { $pdf->displayLine(__('No item found')); } $pdf->displaySpace(); }
function plugin_tag_getAddSearchOptions($itemtype) { $sopt = array(); if (!Session::haveRight("itilcategory", READ)) { return array(); } if (strpos($itemtype, 'Plugin') !== false && strpos($itemtype, 'CronTask') !== false) { return array(); } if ($itemtype === 'PluginTagTag' || $itemtype === 'TicketTemplate' || strpos($itemtype, 'PluginPrintercounters') !== false) { return array(); } $rng1 = 10500; //$sopt[strtolower($itemtype)] = ''; //self::getTypeName(2); $sopt[$rng1]['table'] = getTableForItemType('PluginTagTag'); $sopt[$rng1]['field'] = 'name'; $sopt[$rng1]['name'] = _n('Tag', 'Tag', 2, 'tag'); $sopt[$rng1]['datatype'] = 'string'; $sopt[$rng1]['searchtype'] = "contains"; $sopt[$rng1]['massiveaction'] = false; $sopt[$rng1]['forcegroupby'] = true; $sopt[$rng1]['usehaving'] = true; $sopt[$rng1]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_tag_tagitems', 'joinparams' => array('jointype' => "itemtype_item"))); //array('jointype' => "itemtype_item"); return $sopt; }
function plugin_init_certificates() { global $PLUGIN_HOOKS; $PLUGIN_HOOKS['csrf_compliant']['certificates'] = true; $PLUGIN_HOOKS['change_profile']['certificates'] = array('PluginCertificatesProfile', 'initProfile'); $PLUGIN_HOOKS['assign_to_ticket']['certificates'] = true; if (Session::getLoginUserID()) { // Params : plugin name - string type - number - attributes Plugin::registerClass('PluginCertificatesCertificate', array('linkgroup_tech_types' => true, 'linkuser_tech_types' => true, 'document_types' => true, 'helpdesk_visible_types' => true, 'ticket_types' => true, 'contract_types' => true, 'notificationtemplates_types' => true)); Plugin::registerClass('PluginCertificatesConfig', array('addtabon' => 'CronTask')); Plugin::registerClass('PluginCertificatesProfile', array('addtabon' => 'Profile')); if (class_exists('PluginAccountsAccount')) { PluginAccountsAccount::registerType('PluginCertificatesCertificate'); } $plugin = new Plugin(); if (!$plugin->isActivated('environment') && Session::haveRight("plugin_certificates", READ)) { $PLUGIN_HOOKS['menu_toadd']['certificates'] = array('assets' => 'PluginCertificatesMenu'); } if (Session::haveRight("plugin_certificates", UPDATE)) { $PLUGIN_HOOKS['use_massive_action']['certificates'] = 1; } // End init, when all types are registered $PLUGIN_HOOKS['post_init']['certificates'] = 'plugin_certificates_postinit'; } }
function plugin_init_barcode() { global $PLUGIN_HOOKS, $LANG, $CFG_GLPI; $PLUGIN_HOOKS['csrf_compliant']['barcode'] = true; // Params : plugin name - string type - ID - Array of attributes Plugin::registerClass('PluginBarcodeDropdown'); Plugin::registerClass('PluginBarcodeProfile', array('addtabon' => array('Profile'))); Plugin::registerClass('PluginBarcode'); // Display a menu entry ? if (Session::haveRight('plugin_barcode_barcode', CREATE) || Session::haveRight('plugin_barcode_config', UPDATE)) { $PLUGIN_HOOKS['pre_item_purge']['barcode'] = array('Profile' => array('PluginBarcodeProfile', 'cleanProfiles')); // Massive Action definition $PLUGIN_HOOKS['use_massive_action']['barcode'] = 1; $PLUGIN_HOOKS['submenu_entry']['barcode']['options']['optionname']['title'] = "Search"; $PLUGIN_HOOKS['submenu_entry']['barcode']['options']['optionname']['page'] = '/plugins/barcode/front/barcode.php'; $PLUGIN_HOOKS['submenu_entry']['barcode']['options']['optionname']['links']['search'] = '/plugins/barcode/front/barcode.php'; $PLUGIN_HOOKS['submenu_entry']['barcode']['options']['optionname']['links']['add'] = '/plugins/barcode/front/barcode.form.php'; $PLUGIN_HOOKS['submenu_entry']['barcode']['options']['optionname']['links']['config'] = '/plugins/barcode/index.php'; $PLUGIN_HOOKS["helpdesk_menu_entry"]['barcode'] = true; } // Config page if (Session::haveRight('config', UPDATE)) { $PLUGIN_HOOKS['config_page']['barcode'] = 'front/config.php'; } //redirect appel http://localhost/glpi/index.php?redirect=plugin_example_2 (ID 2 du form) $PLUGIN_HOOKS['redirect_page']['barcode'] = 'barcode.form.php'; }
function plugin_init_moreticket() { global $PLUGIN_HOOKS; $PLUGIN_HOOKS['add_css']['moreticket'] = 'moreticket.css'; $PLUGIN_HOOKS['csrf_compliant']['moreticket'] = true; $PLUGIN_HOOKS['change_profile']['moreticket'] = array('PluginMoreticketProfile', 'initProfile'); if (Session::getLoginUserID()) { Plugin::registerClass('PluginMoreticketProfile', array('addtabon' => 'Profile')); if (class_exists('PluginMoreticketProfile')) { // only if plugin activated $config = new PluginMoreticketConfig(); if (Session::haveRight("plugin_moreticket", UPDATE)) { if (strpos($_SERVER['REQUEST_URI'], "ticket.form.php") !== false && ($config->useWaiting() == true || $config->useSolution() == true)) { $PLUGIN_HOOKS['add_javascript']['moreticket'][] = 'scripts/moreticket.js'; $PLUGIN_HOOKS['add_javascript']['moreticket'][] = 'scripts/moreticket.js.php'; } $PLUGIN_HOOKS['config_page']['moreticket'] = 'front/config.form.php'; $PLUGIN_HOOKS['pre_item_update']['moreticket'] = array('Ticket' => array('PluginMoreticketTicket', 'beforeUpdate')); $PLUGIN_HOOKS['pre_item_add']['moreticket'] = array('Ticket' => array('PluginMoreticketTicket', 'beforeAdd')); $PLUGIN_HOOKS['item_add']['moreticket'] = array('Ticket' => array('PluginMoreticketTicket', 'afterAdd')); $PLUGIN_HOOKS['item_update']['moreticket'] = array('Ticket' => array('PluginMoreticketTicket', 'afterUpdate')); $PLUGIN_HOOKS['item_empty']['moreticket'] = array('Ticket' => array('PluginMoreticketTicket', 'emptyTicket')); } if (Session::haveRight('plugin_moreticket', READ)) { Plugin::registerClass('PluginMoreticketWaitingTicket', array('addtabon' => 'Ticket')); Plugin::registerClass('PluginMoreticketCloseTicket', array('addtabon' => 'Ticket')); } } } }
function plugin_init_datainjection() { global $PLUGIN_HOOKS, $CFG_GLPI, $INJECTABLE_TYPES; $PLUGIN_HOOKS['csrf_compliant']['datainjection'] = true; $PLUGIN_HOOKS['migratetypes']['datainjection'] = 'plugin_datainjection_migratetypes_datainjection'; $plugin = new Plugin(); if ($plugin->isActivated("datainjection")) { Plugin::registerClass('PluginDatainjectionProfile', array('addtabon' => array('Profile'))); //If directory doesn't exists, create it if (!plugin_datainjection_checkDirectories()) { @mkdir(PLUGIN_DATAINJECTION_UPLOAD_DIR) or die(sprintf(__('%1$s %2$s'), __("Can't create folder", 'datainjection'), PLUGIN_DATAINJECTION_UPLOAD_DIR)); } if (Session::haveRight('plugin_datainjection_model', READ)) { $PLUGIN_HOOKS["menu_toadd"]['datainjection'] = array('tools' => 'PluginDatainjectionMenu'); } $PLUGIN_HOOKS['pre_item_purge']['datainjection'] = array('Profile' => array('PluginDatainjectionProfile', 'purgeProfiles')); // Css file $PLUGIN_HOOKS['add_css']['datainjection'] = 'css/datainjection.css'; // Javascript file $PLUGIN_HOOKS['add_javascript']['datainjection'] = 'javascript/datainjection.js'; // Inbtegration with Webservices plugin $PLUGIN_HOOKS['webservices']['datainjection'] = 'plugin_datainjection_registerMethods'; $INJECTABLE_TYPES = array(); } }
/** * Have I the global right to "create" the Object * May be overloaded if needed (ex KnowbaseItem) * * @return booleen **/ static function canCreate() { if (static::$rightname) { return Session::haveRight(static::$rightname, UPDATE); } return false; }
function plugin_init_badges() { global $PLUGIN_HOOKS; $PLUGIN_HOOKS['csrf_compliant']['badges'] = true; $PLUGIN_HOOKS['assign_to_ticket']['badges'] = true; $PLUGIN_HOOKS['change_profile']['badges'] = array('PluginBadgesProfile', 'initProfile'); if (Session::getLoginUserID()) { Plugin::registerClass('PluginBadgesBadge', array('linkuser_types' => true, 'document_types' => true, 'helpdesk_visible_types' => true, 'ticket_types' => true, 'notificationtemplates_types' => true)); Plugin::registerClass('PluginBadgesProfile', array('addtabon' => 'Profile')); Plugin::registerClass('PluginBadgesConfig', array('addtabon' => 'CronTask')); if (class_exists('PluginResourcesResource')) { PluginResourcesResource::registerType('PluginBadgesBadge'); } $plugin = new Plugin(); if (!$plugin->isActivated('environment') && Session::haveRight("plugin_badges", READ)) { $PLUGIN_HOOKS['menu_toadd']['badges'] = array('assets' => 'PluginBadgesMenu'); } if (Session::haveRight("plugin_badges", UPDATE)) { $PLUGIN_HOOKS['use_massive_action']['badges'] = 1; } if (class_exists('PluginBadgesBadge')) { // only if plugin activated $PLUGIN_HOOKS['plugin_datainjection_populate']['badges'] = 'plugin_datainjection_populate_badges'; } // Import from Data_Injection plugin $PLUGIN_HOOKS['migratetypes']['badges'] = 'plugin_datainjection_migratetypes_badges'; } }
/** * Initialize the plugin's hooks */ function plugin_init_customfields() { global $PLUGIN_HOOKS, $DB, $ACTIVE_CUSTOMFIELDS_TYPES, $ALL_CUSTOMFIELDS_TYPES; $PLUGIN_HOOKS['csrf_compliant']['customfields'] = true; $PLUGIN_HOOKS['change_profile']['customfields'] = array('PluginCustomfieldsProfile', 'changeprofile'); // Register classes Plugin::registerClass('PluginCustomfieldsDropdowns'); Plugin::registerClass('PluginCustomfieldsFields'); if (isset($_SESSION['glpiID'])) { $plugin = new Plugin(); if ($plugin->isInstalled("customfields") && $plugin->isActivated("customfields")) { // enable a tab for reading / setting access rights for the plugin Plugin::registerClass('PluginCustomfieldsProfile', array('addtabon' => 'Profile')); // Display a menu entry in the main menu if the user has // configuration rights if (Session::haveRight('config', UPDATE)) { // $PLUGIN_HOOKS['menu_entry']['customfields'] = true; $PLUGIN_HOOKS["menu_toadd"]['customfields'] = array('plugins' => 'PluginCustomfieldsConfig'); } // initiate empty dropdowns $PLUGIN_HOOKS['item_empty']['customfields'] = array('PluginCustomfieldsDropdownsItem' => 'PluginCustomfieldsDropdownsItem::item_empty'); } // Indicate where the configuration page can be found if (Session::haveRight('config', UPDATE)) { $PLUGIN_HOOKS['config_page']['customfields'] = 'front/config.form.php'; } // Hook for initialization after initialization of all other plugins $PLUGIN_HOOKS['post_init']['customfields'] = 'plugin_customfields_postinit'; } }
function plugin_init_addressing() { global $PLUGIN_HOOKS; $PLUGIN_HOOKS['csrf_compliant']['addressing'] = true; // $PLUGIN_HOOKS['change_profile']['addressing'] = array('PluginAddressingProfile', 'changeProfile'); // $PLUGIN_HOOKS['pre_item_purge']['addressing'] = array('Profile' => array('PluginAddressingProfile', // 'purgeProfiles')); Plugin::registerClass('PluginAddressingProfile', array('addtabon' => array('Profile'))); if (Session::getLoginUserID()) { if (Session::haveRight('plugin_addressing', READ)) { $PLUGIN_HOOKS["menu_toadd"]['addressing'] = array('tools' => 'PluginAddressingMenu'); } if (Session::haveRight('plugin_addressing', UPDATE)) { $PLUGIN_HOOKS['use_massive_action']['addressing'] = 1; } // Config page if (Session::haveRight("config", UPDATE)) { $PLUGIN_HOOKS['config_page']['addressing'] = 'front/config.form.php'; } // Add specific files to add to the header : javascript or css $PLUGIN_HOOKS['add_css']['addressing'] = "addressing.css"; $PLUGIN_HOOKS['add_javascript']['addressing'] = 'addressing.js'; $PLUGIN_HOOKS['post_init']['addressing'] = array('PluginAddressingPing_Equipment', 'postinit'); } }
function plugin_init_positions() { global $PLUGIN_HOOKS, $CFG_GLPI; $PLUGIN_HOOKS['csrf_compliant']['positions'] = true; $PLUGIN_HOOKS['change_profile']['positions'] = array('PluginPositionsProfile', 'initProfile'); if (Session::getLoginUserID()) { Plugin::registerClass('PluginPositionsProfile', array('addtabon' => 'Profile')); Plugin::registerClass('PluginPositionsPosition', array('addtabon' => 'Location')); if (Session::haveRight("plugin_positions", UPDATE)) { $PLUGIN_HOOKS['use_massive_action']['positions'] = 1; $PLUGIN_HOOKS['config_page']['positions'] = 'front/config.form.php'; } if (Session::haveRight("plugin_positions", READ)) { $PLUGIN_HOOKS['helpdesk_menu_entry']['positions'] = '/front/map.form.php'; $PLUGIN_HOOKS['menu_toadd']['positions'] = array('tools' => 'PluginPositionsMenu'); } // Add specific files to add to the header : javascript or css $PLUGIN_HOOKS['add_javascript']['positions'] = array("lib/plupload/plupload.full.js", "lib/extjs/adapter/ext/ext-base.js", "lib/extjs/ext-all.js", "upload.js", "positions.js", "geoloc.js", "lib/canvas/canvasXpress.min.js", "lib/canvas/ext-canvasXpress.js", "lib/canvas/color-field.js"); //css $PLUGIN_HOOKS['add_css']['positions'] = array("positions.css", "lib/canvas/color-field.css", "lib/extjs/resources/css/ext-all.css"); if (class_exists('PluginTreeviewConfig')) { $PLUGIN_HOOKS['treeview_params']['positions'] = array('PluginPositionsPosition', 'showPositionTreeview'); } } // End init, when all types are registered $PLUGIN_HOOKS['post_init']['positions'] = 'plugin_positions_postinit'; }
static function canCreate() { if (Session::haveRight('entity_dropdown', 'w') && plugin_resources_haveRight('dropdown_public', 'w')) { return true; } return false; }
static function getMenuContent() { global $CFG_GLPI; $menu = array(); $menu['title'] = self::getMenuName(); $menu['page'] = '/plugins/datainjection/front/clientinjection.form.php'; if (Session::haveRight(static::$rightname, READ)) { $image_model = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/rdv.png' title='"; $image_model .= PluginDatainjectionModel::getTypeName(); $image_model .= "' alt='" . PluginDatainjectionModel::getTypeName() . "'>"; $image_import = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/actualiser.png' title='"; $image_import .= __s('Injection of the file', 'datainjection'); $image_import .= "' alt='" . __s('Injection of the file', 'datainjection') . "'>"; $menu['options']['client']['title'] = self::getMenuName(); $menu['options']['client']['page'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false); $menu['options']['client']['links']['search'] = '/plugins/datainjection/front/clientinjection.form.php'; if (Session::haveRight('plugin_datainjection_model', READ)) { $menu['options']['model']['title'] = PluginDatainjectionModel::getTypeName(); $menu['options']['model']['page'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false); $menu['options']['model']['links']['search'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false); $menu['options']['client']['links'][$image_model] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false); } //$menu['options']['client']['links'][$image_model] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false); $menu['options']['model']['links'][$image_import] = '/plugins/datainjection/front/clientinjection.form.php'; if (Session::haveRight('plugin_datainjection_model', UPDATE) || Session::haveRight('plugin_datainjection_model', CREATE)) { $menu['options']['model']['links']['add'] = Toolbox::getItemTypeFormUrl('PluginDatainjectionModel', false); $menu['options']['client']['links'][$image_model] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false); } } return $menu; }
function plugin_init_consumables() { global $PLUGIN_HOOKS; $PLUGIN_HOOKS['csrf_compliant']['consumables'] = true; $PLUGIN_HOOKS['change_profile']['consumables'] = array('PluginConsumablesProfile', 'initProfile'); $PLUGIN_HOOKS['add_css']['consumables'] = array('consumables.css'); $PLUGIN_HOOKS['add_javascript']['consumables'][] = 'consumables.js'; if (Session::getLoginUserID()) { if (class_exists('PluginConsumablesField')) { foreach (PluginconsumablesField::$types as $item) { if (isset($_SERVER['REQUEST_URI']) && strpos(strtolower($_SERVER['REQUEST_URI']), strtolower($item)) !== false) { $PLUGIN_HOOKS['add_javascript']['consumables'][] = 'consumables.js.php'; } } } Plugin::registerClass('PluginConsumablesProfile', array('addtabon' => 'Profile')); Plugin::registerClass('PluginConsumablesRequest', array('addtabon' => 'User', 'notificationtemplates_types' => true)); Plugin::registerClass('PluginConsumablesRequest', array('addtabon' => 'ConsumableItem')); $PLUGIN_HOOKS['item_add']['consumables'] = array('ConsumableItem' => array('PluginConsumablesField', 'postAddConsumable')); $PLUGIN_HOOKS['pre_item_update']['consumables'] = array('ConsumableItem' => array('PluginConsumablesField', 'preUpdateConsumable')); if (Session::haveRight("plugin_consumables", UPDATE)) { $PLUGIN_HOOKS['use_massive_action']['consumables'] = 1; } if (Session::haveRight("plugin_consumables", READ)) { $PLUGIN_HOOKS['menu_toadd']['consumables'] = array('plugins' => 'PluginConsumablesMenu'); $PLUGIN_HOOKS['helpdesk_menu_entry']['consumables'] = '/front/wizard.php'; } // Post item purge $PLUGIN_HOOKS['item_purge']['consumables'] = array('ConsumableItem' => 'plugin_item_purge_consumables'); } }
static function beforeUpdate(Problem $problem) { if (!is_array($problem->input) || !count($problem->input)) { // Already cancel by another plugin return false; } // Toolbox::logDebug("PluginBehaviorsProblem::beforeUpdate(), Problem=", $problem); $config = PluginBehaviorsConfig::getInstance(); // Check is the connected user is a tech if (!is_numeric(Session::getLoginUserID(false)) || !Session::haveRight('problem', UPDATE)) { return false; // No check } $soltyp = isset($problem->input['solutiontypes_id']) ? $problem->input['solutiontypes_id'] : $problem->fields['solutiontypes_id']; // Wand to solve/close the problem if (isset($problem->input['solutiontypes_id']) && $problem->input['solutiontypes_id'] || isset($problem->input['solution']) && $problem->input['solution'] || isset($problem->input['status']) && in_array($problem->input['status'], array_merge(Problem::getSolvedStatusArray(), Problem::getClosedStatusArray()))) { if ($config->getField('is_problemsolutiontype_mandatory')) { if (!$soltyp) { unset($problem->input['status']); unset($problem->input['solution']); unset($problem->input['solutiontypes_id']); Session::addMessageAfterRedirect(__('You cannot close a problem without solution type', 'behaviors'), true, ERROR); } } } }
function plugin_init_addressing() { global $PLUGIN_HOOKS; $PLUGIN_HOOKS['csrf_compliant']['addressing'] = true; $PLUGIN_HOOKS['change_profile']['addressing'] = array('PluginAddressingProfile', 'changeProfile'); $PLUGIN_HOOKS['pre_item_purge']['addressing'] = array('Profile' => array('PluginAddressingProfile', 'purgeProfiles')); Plugin::registerClass('PluginAddressingProfile', array('addtabon' => array('Profile'))); if (Session::getLoginUserID()) { if (plugin_addressing_haveRight("addressing", "r")) { $PLUGIN_HOOKS['menu_entry']['addressing'] = 'front/addressing.php'; $PLUGIN_HOOKS['submenu_entry']['addressing']['search'] = 'front/addressing.php'; } if (plugin_addressing_haveRight("addressing", "w")) { $PLUGIN_HOOKS['submenu_entry']['addressing']['add'] = 'front/addressing.form.php?new=1'; $PLUGIN_HOOKS['use_massive_action']['addressing'] = 1; } // Config page if (Session::haveRight("config", "w")) { $PLUGIN_HOOKS['submenu_entry']['addressing']['config'] = 'front/config.form.php'; $PLUGIN_HOOKS['config_page']['addressing'] = 'front/config.form.php'; } // Add specific files to add to the header : javascript or css //$PLUGIN_HOOKS['add_javascript']['example']="example.js"; $PLUGIN_HOOKS['add_css']['addressing'] = "addressing.css"; $PLUGIN_HOOKS['add_javascript']['addressing'] = 'addressing.js'; $PLUGIN_HOOKS['post_init']['addressing'] = array('PluginAddressingPing_Equipment', 'postinit'); } }
/** * profiles modification **/ function showForm($id, $options = array()) { $target = $this->getFormURL(); if (isset($options['target'])) { $target = $options['target']; } if (!Session::haveRight("profile", "r")) { return false; } $canedit = Session::haveRight("profile", "w"); $prof = new Profile(); if ($id) { $this->getFromDB($id); $prof->getFromDB($id); } echo "<form action='" . $target . "' method='post'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='2' class='center b'>" . sprintf(__('%1$s %2$s'), __('Rights management'), $this->fields["name"]); echo "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . __('Use the tree', 'treeview') . "</td><td>"; Profile::dropdownNoneReadWrite("treeview", $this->fields["treeview"], 1, 1, 0); echo "</td></tr>"; if ($canedit) { echo "<tr class='tab_bg_1'>"; echo "<td class='center' colspan='2'>"; echo "<input type='hidden' name='id' value={$id}>"; echo "<input type='submit' name='update_user_profile' value='" . _sx('button', 'Update') . "'\n class='submit'>"; echo "</td></tr>"; } echo "</table>"; Html::closeForm(); }
/** * Configuration form **/ function showForm($id, $options = array()) { $target = $this->getFormURL(); if (isset($options['target'])) { $target = $options['target']; } if (!Session::haveRight("profile", "r")) { return false; } $canedit = Session::haveRight("profile", "w"); $prof = new Profile(); if ($id) { $this->getFromDB($id); $prof->getFromDB($id); } echo "<form action='" . $target . "' method='post'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='2' class='center b'>" . sprintf(_('%1$s %2$s'), 'gestion Vip :', Dropdown::getDropdownName("glpi_groups", $this->fields["id"])); echo "</th></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>Groupe Vip</td><td>"; Dropdown::showYesNo("isvip", $this->fields["isvip"]); echo "</td></tr>"; if ($canedit) { echo "<tr class='tab_bg_2'>"; echo "<td class='center' colspan='2'>"; echo "<input type='hidden' name='id' value={$id}>"; echo "<input type='submit' name='update_vip_group' value='Mettre à jour' class='submit'>"; echo "</td></tr>"; } echo "</table>"; Html::closeForm(); }
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(); }
/** * Display tab * * @param CommonGLPI $item * @param integer $withtemplate * * @return varchar name of the tab(s) to display */ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if ($item->getType() == 'Entity' && $item->getID() > -1 && Session::haveRight("entity", 'r')) { return "Escalade"; } return ''; }
function plugin_init_barcode() { global $PLUGIN_HOOKS, $LANG, $CFG_GLPI; $PLUGIN_HOOKS['csrf_compliant']['barcode'] = true; // Params : plugin name - string type - ID - Array of attributes Plugin::registerClass('PluginBarcodeDropdown'); Plugin::registerClass('PluginBarcodeProfile'); Plugin::registerClass('PluginBarcode'); $PLUGIN_HOOKS['change_profile']['barcode'] = array('PluginBarcodeProfile', 'changeprofile'); // Display a menu entry ? if (isset($_SESSION["glpi_plugin_barcode_profile"]) && $_SESSION["glpi_plugin_barcode_profile"]["generate"] or isset($_SESSION["glpi_plugin_barcode_profile"]) && $_SESSION["glpi_plugin_barcode_profile"]["config"]) { // Right set in change_profile hook $PLUGIN_HOOKS['pre_item_purge']['barcode'] = array('Profile' => array('PluginBarcodeProfile', 'cleanProfiles')); // Onglets management $PLUGIN_HOOKS['headings']['barcode'] = 'plugin_get_headings_barcode'; $PLUGIN_HOOKS['headings_action']['barcode'] = 'plugin_headings_actions_barcode'; // Massive Action definition $PLUGIN_HOOKS['use_massive_action']['barcode'] = 1; $PLUGIN_HOOKS['submenu_entry']['barcode']['options']['optionname']['title'] = "Search"; $PLUGIN_HOOKS['submenu_entry']['barcode']['options']['optionname']['page'] = '/plugins/barcode/front/barcode.php'; $PLUGIN_HOOKS['submenu_entry']['barcode']['options']['optionname']['links']['search'] = '/plugins/barcode/front/barcode.php'; $PLUGIN_HOOKS['submenu_entry']['barcode']['options']['optionname']['links']['add'] = '/plugins/barcode/front/barcode.form.php'; $PLUGIN_HOOKS['submenu_entry']['barcode']['options']['optionname']['links']['config'] = '/plugins/barcode/index.php'; //$PLUGIN_HOOKS['submenu_entry']['barcode']['options']['optionname']['links']["<img src='".$CFG_GLPI["root_doc"]."/pics/menu_showall.png' title='".$LANG['plugin_barcode']["test"]."' alt='".$LANG['plugin_barcode']["test"]."'>"] = '/plugins/barcode/index.php'; //$PLUGIN_HOOKS['submenu_entry']['barcode']['options']['optionname']['links'][$LANG['plugin_barcode']["test"]] = '/plugins/barcode/index.php'; $PLUGIN_HOOKS["helpdesk_menu_entry"]['barcode'] = true; } // Config page if (Session::haveRight('config', 'w')) { $PLUGIN_HOOKS['config_page']['barcode'] = 'front/config.php'; } //redirect appel http://localhost/glpi/index.php?redirect=plugin_example_2 (ID 2 du form) $PLUGIN_HOOKS['redirect_page']['barcode'] = 'barcode.form.php'; }
static function pdfMain(PluginPdfSimplePDF $pdf, KnowbaseItem $item) { global $DB; $ID = $item->getField('id'); if (!Session::haveRight('knowbase', 'r') || !Session::haveRight('faq', 'r')) { return false; } $knowbaseitemcategories_id = $item->getField('knowbaseitemcategories_id'); $fullcategoryname = Html::clean(getTreeValueCompleteName("glpi_knowbaseitemcategories", $knowbaseitemcategories_id)); $question = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($item->getField('name'), ENT_QUOTES, "UTF-8"))); $answer = Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($item->getField('answer'), ENT_QUOTES, "UTF-8"))); $pdf->setColumnsSize(100); if (Toolbox::strlen($fullcategoryname) > 0) { $pdf->displayTitle('<b>' . __('Category name') . '</b>'); $pdf->displayLine($fullcategoryname); } if (Toolbox::strlen($question) > 0) { $pdf->displayTitle('<b>' . __('Subject') . '</b>'); $pdf->displayText('', $question, 5); } else { $pdf->displayTitle('<b>' . __('No question found', 'pdf') . '</b>'); } if (Toolbox::strlen($answer) > 0) { $pdf->displayTitle('<b>' . __('Content') . '</b>'); $pdf->displayText('', $answer, 5); } else { $pdf->displayTitle('<b>' . __('No answer found') . '</b>'); } $pdf->setColumnsSize(50, 15, 15, 10, 10); $pdf->displayTitle(__('Writer'), __('Creation date'), __('Last update'), __('FAQ'), _n('View', 'Views', 2)); $pdf->displayLine(getUserName($item->fields["users_id"]), Html::convDateTime($item->fields["date"]), Html::convDateTime($item->fields["date_mod"]), Dropdown::getYesNo($item->fields["is_faq"]), $item->fields["view"]); $pdf->displaySpace(); }
function plugin_init_escalade() { global $PLUGIN_HOOKS; $PLUGIN_HOOKS['csrf_compliant']['escalade'] = true; $plugin = new Plugin(); if (isset($_SESSION['glpiID']) && $plugin->isInstalled('escalade') && $plugin->isActivated('escalade')) { //load config in session if (TableExists("glpi_plugin_escalade_configs")) { PluginEscaladeConfig::loadInSession(); // == Load js scripts == if (isset($_SESSION['plugins']['escalade']['config'])) { $escalade_config = $_SESSION['plugins']['escalade']['config']; $PLUGIN_HOOKS['add_javascript']['escalade'][] = 'scripts/function.js'; // on central page if (strpos($_SERVER['REQUEST_URI'], "central.php") !== false) { //history and climb feature if ($escalade_config['show_history']) { $PLUGIN_HOOKS['add_javascript']['escalade'][] = 'scripts/central.js.php'; } } // on ticket page (in edition) if (strpos($_SERVER['REQUEST_URI'], "ticket.form.php") !== false && isset($_GET['id'])) { //history and climb feature if ($escalade_config['show_history']) { $PLUGIN_HOOKS['add_javascript']['escalade'][] = 'scripts/escalade.js.php'; } //remove btn feature if (!$escalade_config['remove_delete_group_btn'] || !$escalade_config['remove_delete_user_btn']) { $PLUGIN_HOOKS['add_javascript']['escalade'][] = 'scripts/remove_btn.js.php'; } //clone ticket feature if ($escalade_config['cloneandlink_ticket']) { $PLUGIN_HOOKS['add_javascript']['escalade'][] = 'scripts/cloneandlink_ticket.js.php'; } //filter group feature if ($escalade_config['use_filter_assign_group']) { $PLUGIN_HOOKS['add_javascript']['escalade'][] = 'scripts/filtergroup.js.php'; } } Plugin::registerClass('PluginEscaladeGroup_Group', array('addtabon' => 'Group')); Plugin::registerClass('PluginEscaladeUser', array('addtabon' => array('User'))); } } $PLUGIN_HOOKS['add_css']['escalade'][] = 'escalade.css'; // == Ticket modifications $PLUGIN_HOOKS['item_update']['escalade'] = array('Ticket' => 'plugin_escalade_item_update'); $PLUGIN_HOOKS['item_add']['escalade'] = array('Group_Ticket' => 'plugin_escalade_item_add_group_ticket', 'Ticket_User' => 'plugin_escalade_item_add_user', 'Ticket' => 'plugin_escalade_item_add_ticket'); $PLUGIN_HOOKS['pre_item_add']['escalade'] = array('Group_Ticket' => 'plugin_escalade_pre_item_add_group_ticket', 'Ticket' => 'plugin_escalade_pre_item_add_ticket'); $PLUGIN_HOOKS['post_prepareadd']['escalade'] = array('Ticket' => 'plugin_escalade_post_prepareadd_ticket'); $PLUGIN_HOOKS['item_purge']['escalade'] = array('User' => 'plugin_escalade_item_purge'); $PLUGIN_HOOKS['item_add']['escalade']['User'] = '******'; // == Interface links == if (Session::haveRight('config', UPDATE)) { $PLUGIN_HOOKS['config_page']['escalade'] = 'front/config.form.php'; } $PLUGIN_HOOKS['use_massive_action']['escalade'] = 1; } }
public static function show($ID, $from_followup) { global $LANG, $CFG_GLPI, $DB, $content; if (!Session::haveRight("followup", TicketFollowup::SEEPUBLIC)) { return false; } $is_private = 0; $requesttypes_id = "1"; $content = ""; if (isset($_SESSION["helpdeskSaved"]["content"])) { $content = cleanPostForTextArea($_SESSION["helpdeskSaved"]["content"]); } if (isset($_SESSION["helpdeskSaved"]["requesttypes_id"])) { $requesttypes_id = stripslashes($_SESSION["helpdeskSaved"]["requesttypes_id"]); } if (isset($_SESSION["helpdeskSaved"]["is_private"])) { $is_private = stripslashes($_SESSION["helpdeskSaved"]["is_private"]); } unset($_SESSION["helpdeskSaved"]); //} if (isset($_REQUEST['new'])) { echo "<div style='text-align:center; margin-top:20px;'> <b> " . $LANG['plugin_mobile']['common'][13] . " </b></div>"; } echo "<form method='post' name='followupform' action=" . $CFG_GLPI["root_doc"] . "/plugins/mobile/front/followup.php?id=" . $_REQUEST['id'] . "&new=1 >"; echo "<table>"; echo "<tr class='tab_bg_1'>"; echo "<td> </td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['joblist'][6] . " :</td>"; echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='right' colspan='2'><textarea name='content' cols='78' rows='14' >{$content}</textarea>"; echo "</td></tr>"; echo "<input type='hidden' name='_from_followup' value='{$from_followup}'>"; echo "<input type='hidden' name='requesttypes_id' value='1'"; echo "<input type='hidden' name='is_private' value='0'"; echo "<input type='hidden' name='new' value='1'"; echo "<tr class='tab_bg_2'>"; echo "<td colspan='1' class='center'>"; echo "<input type='submit' value=\"" . $LANG['plugin_mobile']['common'][7] . "\" class='submit' onClick=\"'history.go(-1)'\">"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); if (Session::haveRight("followup", TicketFollowup::SEEPUBLIC)) { global $key, $new; $new = $_REQUEST['new']; if (isset($new) && $_POST['content'] != "") { $id = $_REQUEST['id']; $content = $_POST['content']; $query = "INSERT INTO glpi_ticketfollowups (tickets_id, date, users_id, content, is_private, requesttypes_id) \nVALUES (" . $id . ", NOW(), " . $ID . ", '" . $content . "', '" . $is_private . "', '" . $requesttypes_id . "') \n"; $result = $DB->query($query); } elseif (isset($new) && $_POST['content'] == "") { echo $LANG['plugin_mobile']['common'][8]; } } }