/**
  * @see NetworkPortInstantiation::getInstantiationHTMLTable()
  **/
 function getInstantiationHTMLTable(NetworkPort $netport, HTMLTableRow $row, HTMLTableCell $father = NULL, array $options = array())
 {
     if (isset($this->fields['networkports_id_list']) && is_string($this->fields['networkports_id_list'])) {
         $this->fields['networkports_id_list'] = importArrayFromDB($this->fields['networkports_id_list']);
     }
     $row->addCell($row->getHeaderByName('Instantiation', 'Origin'), $this->getInstantiationNetworkPortHTMLTable());
     parent::getInstantiationHTMLTable($netport, $row, $father, $options);
     return NULL;
 }
示例#2
0
 /**
  * @param $output
  * @param $params
  **/
 function executeActions($output, $params)
 {
     if (count($this->actions)) {
         foreach ($this->actions as $action) {
             switch ($action->fields["action_type"]) {
                 case "send":
                     $ticket = new Ticket();
                     if ($ticket->getFromDB($output['id'])) {
                         NotificationEvent::raiseEvent('recall', $ticket);
                     }
                     break;
                 case "add_validation":
                     if (isset($output['_add_validation']) && !is_array($output['_add_validation'])) {
                         $output['_add_validation'] = array($output['_add_validation']);
                     }
                     switch ($action->fields['field']) {
                         case 'users_id_validate_requester_supervisor':
                             $output['_add_validation'][] = 'requester_supervisor';
                             break;
                         case 'users_id_validate_assign_supervisor':
                             $output['_add_validation'][] = 'assign_supervisor';
                             break;
                         case 'groups_id_validate':
                             $output['_add_validation']['group'][] = $action->fields["value"];
                             break;
                         case 'users_id_validate':
                             $output['_add_validation'][] = $action->fields["value"];
                             break;
                         case 'validation_percent':
                             $output[$action->fields["field"]] = $action->fields["value"];
                             break;
                         default:
                             $output['_add_validation'][] = $action->fields["value"];
                             break;
                     }
                     break;
                 case "assign":
                     $output[$action->fields["field"]] = $action->fields["value"];
                     // Special case of users_id_requester
                     if ($action->fields["field"] === '_users_id_requester') {
                         // Add groups of requester
                         if (!isset($output['_groups_id_of_requester'])) {
                             $output['_groups_id_of_requester'] = array();
                         }
                         foreach (Group_User::getUserGroups($action->fields["value"]) as $g) {
                             $output['_groups_id_of_requester'][$g['id']] = $g['id'];
                         }
                     }
                     break;
                 case "append":
                     $actions = $this->getActions();
                     $value = $action->fields["value"];
                     if (isset($actions[$action->fields["field"]]["appendtoarray"]) && isset($actions[$action->fields["field"]]["appendtoarrayfield"])) {
                         $value = $actions[$action->fields["field"]]["appendtoarray"];
                         $value[$actions[$action->fields["field"]]["appendtoarrayfield"]] = $action->fields["value"];
                     }
                     $output[$actions[$action->fields["field"]]["appendto"]][] = $value;
                     // Special case of users_id_requester
                     if ($action->fields["field"] === '_users_id_requester') {
                         // Add groups of requester
                         if (!isset($output['_groups_id_of_requester'])) {
                             $output['_groups_id_of_requester'] = array();
                         }
                         foreach (Group_User::getUserGroups($action->fields["value"]) as $g) {
                             $output['_groups_id_of_requester'][$g['id']] = $g['id'];
                         }
                     }
                     break;
                 case 'fromuser':
                     if ($action->fields['field'] == 'locations_id' && isset($output['users_locations'])) {
                         $output['locations_id'] = $output['users_locations'];
                     }
                     break;
                 case 'fromitem':
                     if ($action->fields['field'] == 'locations_id' && isset($output['items_locations'])) {
                         $output['locations_id'] = $output['items_locations'];
                     }
                     if ($action->fields['field'] == 'groups_id' && isset($output['items_groups'])) {
                         $output['groups_id'] = $output['items_groups'];
                     }
                     break;
                 case 'compute':
                     // Value could be not set (from test)
                     $urgency = isset($output['urgency']) ? $output['urgency'] : 3;
                     $impact = isset($output['impact']) ? $output['impact'] : 3;
                     // Apply priority_matrix from config
                     $output['priority'] = Ticket::computePriority($urgency, $impact);
                     break;
                 case "affectbyip":
                 case "affectbyfqdn":
                 case "affectbymac":
                     if (!isset($output["entities_id"])) {
                         $output["entities_id"] = $params["entities_id"];
                     }
                     if (isset($this->regex_results[0])) {
                         $regexvalue = RuleAction::getRegexResultById($action->fields["value"], $this->regex_results[0]);
                     } else {
                         $regexvalue = $action->fields["value"];
                     }
                     switch ($action->fields["action_type"]) {
                         case "affectbyip":
                             $result = IPAddress::getUniqueItemByIPAddress($regexvalue, $output["entities_id"]);
                             break;
                         case "affectbyfqdn":
                             $result = FQDNLabel::getUniqueItemByFQDN($regexvalue, $output["entities_id"]);
                             break;
                         case "affectbymac":
                             $result = NetworkPortInstantiation::getUniqueItemByMac($regexvalue, $output["entities_id"]);
                             break;
                         default:
                             $result = array();
                     }
                     if (!empty($result)) {
                         $output["items_id"][$result["itemtype"]][] = $result["id"];
                     }
                     break;
             }
         }
     }
     return $output;
 }
示例#3
0
 /**
  * @param $field
  * @param $name            (default'')
  * @param $values           (default '')
  * @param $options   array
  **/
 static function getSpecificValueToSelect($field, $name = '', $values = '', array $options = array())
 {
     if (!is_array($values)) {
         $values = array($field => $values);
     }
     $options['display'] = false;
     switch ($field) {
         case 'mode':
             $options['value'] = $values[$field];
             return Dropdown::showFromArray($name, WifiNetwork::getWifiCardModes(), $options);
         case 'version':
             $options['value'] = $values[$field];
             return Dropdown::showFromArray($name, WifiNetwork::getWifiCardVersion(), $options);
     }
     return parent::getSpecificValueToSelect($field, $name, $values, $options);
 }
示例#4
0
 /**
  * Get available display options array
  *
  * @since version 0.84
  *
  * @return all the options
  **/
 static function getAvailableDisplayOptions()
 {
     $options[__('Global displays')] = array('characteristics' => array('name' => __('Characteristics'), 'default' => true), 'internet' => array('name' => __('Internet information'), 'default' => true), 'dynamic_import' => array('name' => __('Automatic inventory'), 'default' => false));
     $options[__('Common options')] = NetworkPortInstantiation::getGlobalInstantiationNetworkPortDisplayOptions();
     $options[__('Internet information')] = array('names' => array('name' => NetworkName::getTypeName(2), 'default' => false), 'aliases' => array('name' => NetworkAlias::getTypeName(2), 'default' => false), 'ipaddresses' => array('name' => IPAddress::getTypeName(2), 'default' => true), 'ipnetworks' => array('name' => IPNetwork::getTypeName(2), 'default' => true));
     foreach (self::getNetworkPortInstantiations() as $portType) {
         $portTypeName = $portType::getTypeName(0);
         $options[$portTypeName] = $portType::getInstantiationNetworkPortDisplayOptions();
     }
     return $options;
 }
示例#5
0
 /**
  * @see NetworkPortInstantiation::getInstantiationHTMLTable()
  **/
 function getInstantiationHTMLTable(NetworkPort $netport, HTMLTableRow $row, HTMLTableCell $father = NULL, array $options = array())
 {
     $row->addCell($row->getHeaderByName('Instantiation', 'Origin'), $this->getInstantiationNetworkPortHTMLTable());
     parent::getInstantiationHTMLTable($netport, $row, $father, $options);
     return NULL;
 }
 /**
  * @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)
 {
     switch ($ma->getAction()) {
         case "plugin_ocsinventoryng_update_networkport_type":
             $networkport = new PluginOcsinventoryngNetworkPort();
             $input = $ma->getInput();
             foreach ($ids as $id) {
                 if ($networkport->getFromDBByQuery("WHERE `networkports_id` = '{$id}'")) {
                     if ($networkport->transformAccordingTypes()) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
                     }
                 } else {
                     $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
示例#7
0
 /**
  * @param $field
  * @param $name            (default '')
  * @param $values          (defaul '')
  * @param $options   array
  */
 static function getSpecificValueToSelect($field, $name = '', $values = '', array $options = array())
 {
     if (!is_array($values)) {
         $values = array($field => $values);
     }
     $options['display'] = false;
     switch ($field) {
         case 'type':
             $options['value'] = $values[$field];
             return Dropdown::showFromArray($name, self::getPortTypeName(), $options);
         case 'speed':
             $options['value'] = $values[$field];
             return Dropdown::showFromArray($name, self::getPortSpeed(), $options);
     }
     return parent::getSpecificValueToSelect($field, $name, $values, $options);
 }
示例#8
0
 /**
  * @see NetworkPortInstantiation::getInstantiationHTMLTable()
  **/
 function getInstantiationHTMLTable(NetworkPort $netport, HTMLTableRow $row, HTMLTableCell $father = NULL, array $options = array())
 {
     return parent::getInstantiationHTMLTableWithPeer($netport, $row, $father, $options);
 }
示例#9
0
 /**
  * @see NetworkPortInstantiation::getInstantiationHTMLTable()
  **/
 function getInstantiationHTMLTable(NetworkPort $netport, HTMLTableRow $row, HTMLTableCell $father = NULL, array $options = array())
 {
     DeviceNetworkCard::getHTMLTableCellsForItem($row, $this, NULL, $options);
     $row->addCell($row->getHeaderByName('Instantiation', 'TYPE'), $this->fields['TYPE']);
     $row->addCell($row->getHeaderByName('Instantiation', 'TYPEMIB'), $this->fields['TYPEMIB']);
     $link = PluginOcsinventoryngNetworkPortType::getFormURL(true) . '?' . $this->getForeignKeyField() . '=' . $this->getID();
     $value = "<a href='{$link}'>" . __('Create', 'ocsinventoryng') . "</a>";
     $row->addCell($row->getHeaderByName('Instantiation', 'Generate'), $value);
     parent::getInstantiationHTMLTable($netport, $row, $father, $options);
     return NULL;
 }