addForwardEntity() static public method

Specificy a plugin itemtype for which entities_id and is_recursive should be forwarded
Since: 0.83
static public addForwardEntity ( $for_itemtype, $to_itemtype ) : nothing
$for_itemtype change of entity for this itemtype will be forwarder
$to_itemtype change of entity will affect this itemtype
return nothing
Exemplo n.º 1
0
 /**
  * Define a new class managed by a plugin
  *
  * @param $itemtype        class name
  * @param $attrib    array of attributes, a hashtable with index in
  *                         (classname, typename, reservation_types)
  *
  * @return bool
  **/
 static function registerClass($itemtype, $attrib = array())
 {
     global $CFG_GLPI;
     $plug = isPluginItemType($itemtype);
     if (!$plug) {
         return false;
     }
     $plugin = strtolower($plug['plugin']);
     if (isset($attrib['doc_types'])) {
         $attrib['document_types'] = $attrib['doc_types'];
         unset($attrib['doc_types']);
     }
     if (isset($attrib['helpdesk_types'])) {
         $attrib['ticket_types'] = $attrib['helpdesk_types'];
         unset($attrib['helpdesk_types']);
     }
     if (isset($attrib['netport_types'])) {
         $attrib['networkport_types'] = $attrib['netport_types'];
         unset($attrib['netport_types']);
     }
     foreach (array('contract_types', 'directconnect_types', 'document_types', 'helpdesk_visible_types', 'infocom_types', 'linkgroup_tech_types', 'linkgroup_types', 'linkuser_tech_types', 'linkuser_types', 'location_types', 'networkport_instantiations', 'networkport_types', 'notificationtemplates_types', 'planning_types', 'reservation_types', 'rulecollections_types', 'systeminformations_types', 'ticket_types', 'unicity_types', 'link_types') as $att) {
         if (isset($attrib[$att]) && $attrib[$att]) {
             array_push($CFG_GLPI[$att], $itemtype);
             unset($attrib[$att]);
         }
     }
     if (isset($attrib['device_types']) && $attrib['device_types'] && method_exists($itemtype, 'getItem_DeviceType')) {
         if (class_exists($itemtype::getItem_DeviceType())) {
             array_push($CFG_GLPI['device_types'], $itemtype);
         }
         unset($attrib[$att]);
     }
     if (isset($attrib['addtabon'])) {
         if (!is_array($attrib['addtabon'])) {
             $attrib['addtabon'] = array($attrib['addtabon']);
         }
         foreach ($attrib['addtabon'] as $form) {
             CommonGLPI::registerStandardTab($form, $itemtype);
         }
     }
     //Manage entity forward from a source itemtype to this itemtype
     if (isset($attrib['forwardentityfrom'])) {
         CommonDBTM::addForwardEntity($attrib['forwardentityfrom'], $itemtype);
     }
     // Use it for plugin debug
     //       if (count($attrib)) {
     //          foreach ($attrib as $key => $val) {
     //             Toolbox::logInFile('debug',"Attribut $key used by $itemtype no more used for plugins\n");
     //          }
     //}
     return true;
 }