当前位置: 首页>>代码示例>>PHP>>正文


PHP Location::getField方法代码示例

本文整理汇总了PHP中Location::getField方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::getField方法的具体用法?PHP Location::getField怎么用?PHP Location::getField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Location的用法示例。


在下文中一共展示了Location::getField方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDatasForObject

 /**
  * @see NotificationTargetCommonITILObject::getDatasForObject()
  **/
 function getDatasForObject(CommonDBTM $item, array $options, $simple = false)
 {
     global $CFG_GLPI;
     // Common ITIL datas
     $datas = parent::getDatasForObject($item, $options, $simple);
     $datas['##ticket.description##'] = Html::clean($datas['##ticket.description##']);
     $datas['##ticket.description##'] = $item->convertContentForNotification($datas['##ticket.description##'], $item);
     $datas['##ticket.content##'] = $datas['##ticket.description##'];
     // Specific datas
     $datas['##ticket.urlvalidation##'] = $this->formatURL($options['additionnaloption']['usertype'], "ticket_" . $item->getField("id") . "_TicketValidation\$1");
     $datas['##ticket.globalvalidation##'] = TicketValidation::getStatus($item->getField('global_validation'));
     $datas['##ticket.type##'] = Ticket::getTicketTypeName($item->getField('type'));
     $datas['##ticket.requesttype##'] = Dropdown::getDropdownName('glpi_requesttypes', $item->getField('requesttypes_id'));
     $autoclose_value = Entity::getUsedConfig('autoclose_delay', $this->getEntity(), '', Entity::CONFIG_NEVER);
     $datas['##ticket.autoclose##'] = __('Never');
     $datas['##lang.ticket.autoclosewarning##'] = "";
     if ($autoclose_value > 0) {
         $datas['##ticket.autoclose##'] = $autoclose_value;
         $datas['##lang.ticket.autoclosewarning##'] = sprintf(_n('Without a reply, the ticket will be automatically closed after %s day', 'Without a reply, the ticket will be automatically closed after %s days', $autoclose_value), $autoclose_value);
     }
     $datas['##ticket.sla##'] = '';
     if ($item->getField('slas_id')) {
         $datas['##ticket.sla##'] = Dropdown::getDropdownName('glpi_slas', $item->getField('slas_id'));
     }
     $datas['##ticket.location##'] = '';
     if ($item->getField('locations_id')) {
         $datas['##ticket.location##'] = Dropdown::getDropdownName('glpi_locations', $item->getField('locations_id'));
         $locations = new Location();
         $locations->getFromDB($item->getField('locations_id'));
         if ($locations->getField('comment')) {
             $datas['##ticket.location.comment##'] = $locations->getField('comment');
         }
         if ($locations->getField('room')) {
             $datas['##ticket.location.room##'] = $locations->getField('room');
         }
         if ($locations->getField('building')) {
             $datas['##ticket.location.building##'] = $locations->getField('building');
         }
         if ($locations->getField('latitude')) {
             $datas['##ticket.location.latitude##'] = $locations->getField('latitude');
         }
         if ($locations->getField('longitude')) {
             $datas['##ticket.location.longitude##'] = $locations->getField('longitude');
         }
         if ($locations->getField('altitude')) {
             $datas['##ticket.location.altitude##'] = $locations->getField('altitude');
         }
     }
     // is ticket deleted
     $datas['##ticket.isdeleted##'] = Dropdown::getYesNo($item->getField('is_deleted'));
     //Tags associated with the object linked to the ticket
     $datas['##ticket.itemtype##'] = '';
     $datas['##ticket.item.name##'] = '';
     $datas['##ticket.item.serial##'] = '';
     $datas['##ticket.item.otherserial##'] = '';
     $datas['##ticket.item.location##'] = '';
     $datas['##ticket.item.locationcomment##'] = '';
     $datas['##ticket.item.locationroom##'] = '';
     $datas['##ticket.item.locationbuilding##'] = '';
     $datas['##ticket.item.locationlatitude##'] = '';
     $datas['##ticket.item.locationlongitude##'] = '';
     $datas['##ticket.item.locationaltitude##'] = '';
     $datas['##ticket.item.contact##'] = '';
     $datas['##ticket.item.contactnumber##'] = '';
     $datas['##ticket.item.user##'] = '';
     $datas['##ticket.item.group##'] = '';
     $datas['##ticket.item.model##'] = '';
     $item_ticket = new Item_Ticket();
     $items = $item_ticket->find("`tickets_id` = '" . $item->getField('id') . "'");
     $datas['items'] = array();
     if (count($items)) {
         foreach ($items as $val) {
             if (isset($val['itemtype']) && ($hardware = getItemForItemtype($val['itemtype'])) && isset($val["items_id"]) && $hardware->getFromDB($val["items_id"])) {
                 $tmp = array();
                 //Object type
                 $tmp['##ticket.itemtype##'] = $hardware->getTypeName();
                 //Object name
                 $tmp['##ticket.item.name##'] = $hardware->getField('name');
                 //Object serial
                 if ($hardware->isField('serial')) {
                     $tmp['##ticket.item.serial##'] = $hardware->getField('serial');
                 }
                 //Object contact
                 if ($hardware->isField('contact')) {
                     $tmp['##ticket.item.contact##'] = $hardware->getField('contact');
                 }
                 //Object contact num
                 if ($hardware->isField('contact_num')) {
                     $tmp['##ticket.item.contactnumber##'] = $hardware->getField('contact_num');
                 }
                 //Object otherserial
                 if ($hardware->isField('otherserial')) {
                     $tmp['##ticket.item.otherserial##'] = $hardware->getField('otherserial');
                 }
                 //Object location
                 if ($hardware->isField('locations_id')) {
                     $tmp['##ticket.item.location##'] = Dropdown::getDropdownName('glpi_locations', $hardware->getField('locations_id'));
//.........这里部分代码省略.........
开发者ID:stweil,项目名称:glpi,代码行数:101,代码来源:notificationtargetticket.class.php

示例2: testTreeImport

 /**
  * @covers Dropdown::import
  * @covers CommonTreeDropdown::import
  * @dataProvider dataTestTreeImport
  */
 public function testTreeImport($input, $result, $complete, $msg)
 {
     $id = Dropdown::import('Location', $input);
     if ($result) {
         $this->assertGreaterThan(0, $id, $msg);
         $ut = new Location();
         $this->assertTrue($ut->getFromDB($id), $msg);
         $this->assertEquals($result, $ut->getField('name'), $msg);
         $this->assertEquals($complete, $ut->getField('completename'), $msg);
     } else {
         $this->assertLessThanOrEqual(0, $id, $msg);
     }
 }
开发者ID:btry,项目名称:glpi,代码行数:18,代码来源:DropdownTest.php

示例3: addNetworkEthernetPort

/**  Generate bigdump : Create networkport ethernet
 *
 * @since version 0.84
 *
 * @param $itemtype        item type
 * @param $items_id        item ID
 * @param $entities_id     item entity ID
 * @param $locations_id    ID of the location trying to link with network equipment (default 0)
**/
function addNetworkEthernetPort($itemtype, $items_id, $entities_id, $locations_id=0) {
   global $NET_LOC, $NET_PORT, $MAX, $VLAN_LOC;

   // Add networking ports
   $newIP   = getNextIP();
   $newMAC  = getNextMAC();

   if (($itemtype == 'NetworkEquipment') && $locations_id) {
      // Find father locations_id;
      $loc = new Location();
      if ($loc->getFromDB($locations_id)) {
         $locations_id = $loc->getField('locations_id');
      } else {
         $locations_id = 0;
      }
   }

   //insert netpoint
   $netpoint   = new NetPoint();
   $netpointID = $netpoint->add(toolbox::addslashes_deep(
                                array('entities_id'  => $entities_id,
                                      'locations_id' => $locations_id,
                                      'name'         => getNextNETPOINT(),
                                      'comment'      => "comment 'netpoint $locations_id")));

   if ($locations_id && !isset($VLAN_LOC[$locations_id])) {
      $vlanID                  = mt_rand(1,$MAX["vlan"]);
      $VLAN_LOC[$locations_id] = $vlanID;
   }
   if (!isset($NET_PORT[$itemtype][$items_id])) {
      $NET_PORT[$itemtype][$items_id]=0;
   }
   $np          = new NetworkPort();
   $nv          = new NetworkPort_Vlan();
   $newportname = "port of $itemtype-$items_id";
   $refportID   = 0;

   if ($locations_id && isset($NET_LOC[$locations_id]) && $NET_LOC[$locations_id]) {
      $refportname  = "link 'port to  $itemtype-$items_id";
      $newportname .= " link to 'NetworkEquipment' -".$NET_LOC[$locations_id];
      $newMAC2      = getNextMAC();
      $newIP2      = getNextIP();

      // Create new port on ref item
      $param = toolbox::addslashes_deep(
               array('itemtype'                 => 'NetworkEquipment',
                     'items_id'                 => $NET_LOC[$locations_id],
                     'entities_id'              => $entities_id,
                     'logical_number'  => $NET_PORT['NetworkEquipment'][$NET_LOC[$locations_id]]++,
                     'name'                     => "name '$refportname",
                     'instantiation_type'       => 'NetworkPortEthernet',
                     'mac'                      => $newMAC2,
                     'comment'                  => "comment '$refportname",
                     'netpoints_id'             => $netpointID,
                     'NetworkName_name'         => "NetworkEquipment$itemtype-$items_id-$entities_id",
                     'NetworkName__ipaddresses' => array(-100 => $newIP2['ip']),
                     ));

                     $np->splitInputForElements($param);
      $refportID = $np->add($param);
      $np->updateDependencies(1);
      if (isset($VLAN_LOC[$locations_id]) && $refportID) {
         $nv->add(array('networkports_id' => $refportID,
                        'vlans_id'        => $VLAN_LOC[$locations_id]));
      }
   }

//    $query = "INSERT INTO `glpi_networkports`
//                VALUES (NULL, '$netwID', 'NetworkEquipment', '$ID_entity', '0',
//                      '".$NET_PORT['NetworkEquipment'][$netwID]++."',
//                      'link port to netw ".$NET_LOC[$data['locations_id']]."',
//                      '".$newIP['ip']."', '$newMAC', '$iface', '$netpointID',
//                      '".$newIP['netwmask']."', '".$newIP['gateway']."',
//                      '".$newIP['subnet']."','comment')";
//    $DB->query($query) or die("PB REQUETE ".$query);

   $param = toolbox::addslashes_deep(
            array('itemtype'                 => $itemtype,
                  'items_id'                 => $items_id,
                  'entities_id'              => $entities_id,
                  'logical_number'           => $NET_PORT[$itemtype][$items_id]++,
                  'name'                     => "name '$newportname",
                  'instantiation_type'       => 'NetworkPortEthernet',
                  'mac'                      => $newMAC,
                  'comment'                  => "comment '$newportname",
                  'netpoints_id'             => $netpointID,
                  'NetworkName_name'         => "$itemtype-$items_id-$entities_id",
                  'NetworkName__ipaddresses' => array(-100 => $newIP['ip']),
                  ));

                  $np->splitInputForElements($param);
//.........这里部分代码省略.........
开发者ID:KaneoGmbH,项目名称:glpi,代码行数:101,代码来源:generate_bigdump.function.php

示例4: testTreeImport

 /**
  * @covers Dropdown::import
  * @covers CommonTreeDropdown::import
  * @dataProvider dataTestTreeImport
  */
 public function testTreeImport($input, $result, $complete, $msg)
 {
     $input['entities_id'] = getItemByTypeName('Entity', '_test_root_entity', true);
     $id = Dropdown::import('Location', $input);
     if ($result) {
         $this->assertGreaterThan(0, $id, $msg);
         $ut = new Location();
         $this->assertTrue($ut->getFromDB($id), $msg);
         $this->assertEquals($result, $ut->getField('name'), $msg);
         $this->assertEquals($complete, $ut->getField('completename'), $msg);
     } else {
         $this->assertLessThanOrEqual(0, $id, $msg);
     }
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:19,代码来源:DropdownTest.php


注:本文中的Location::getField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。