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


PHP Problem::canView方法代码示例

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


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

示例1: getItem

 /**
  * Return the instance fields of itemtype identified by id
  *
  * @param $itemtype    string  itemtype (class) of object
  * @param $id          integer identifier of object
  * @param $params      array   with theses options :
  *    - 'expand_dropdowns': Show dropdown's names instead of id. default: false. Optionnal
  *    - 'get_hateoas':      Show relation of current item in a links attribute. default: true. Optionnal
  *    - 'get_sha1':         Get a sha1 signature instead of the full answer. default: false. Optionnal
  *    - 'with_components':  Only for [Computer, NetworkEquipment, Peripheral, Phone, Printer], Optionnal.
  *    - 'with_disks':       Only for Computer, retrieve the associated filesystems. Optionnal.
  *    - 'with_softwares':   Only for Computer, retrieve the associated softwares installations. Optionnal.
  *    - 'with_connections': Only for Computer, retrieve the associated direct connections (like peripherals and printers) .Optionnal.
  *    - 'with_networkports':Retrieve all network connections and advanced network informations. Optionnal.
  *    - 'with_infocoms':    Retrieve financial and administrative informations. Optionnal.
  *    - 'with_contracts':   Retrieve associated contracts. Optionnal.
  *    - 'with_documents':   Retrieve associated external documents. Optionnal.
  *    - 'with_tickets':     Retrieve associated itil tickets. Optionnal.
  *    - 'with_problems':    Retrieve associated itil problems. Optionnal.
  *    - 'with_changes':     Retrieve associated itil changes. Optionnal.
  *    - 'with_notes':       Retrieve Notes (if exists, not all itemtypes have notes). Optionnal.
  *    - 'with_logs':        Retrieve historical. Optionnal.
  *
  * @return     array    fields of found object
  **/
 protected function getItem($itemtype, $id, $params = array())
 {
     global $CFG_GLPI, $DB;
     $this->initEndpoint();
     // default params
     $default = array('expand_dropdowns' => false, 'get_hateoas' => true, 'get_sha1' => false, 'with_components' => false, 'with_disks' => false, 'with_softwares' => false, 'with_connections' => false, 'with_networkports' => false, 'with_infocoms' => false, 'with_contracts' => false, 'with_documents' => false, 'with_tickets' => false, 'with_problems' => false, 'with_changes' => false, 'with_notes' => false, 'with_logs' => false);
     $params = array_merge($default, $params);
     $item = new $itemtype();
     if (!$item->getFromDB($id)) {
         return $this->messageNotfoundError();
     }
     if (!$item->can($id, READ)) {
         return $this->messageRightError();
     }
     $fields = $item->fields;
     // avoid disclosure of critical fields
     $item::unsetUndisclosedFields($fields);
     // retrieve devices
     if (isset($params['with_devices']) && $params['with_devices'] && in_array($itemtype, Item_Devices::getConcernedItems())) {
         $all_devices = array();
         foreach (Item_Devices::getItemAffinities($item->getType()) as $device_type) {
             $found_devices = getAllDatasFromTable($device_type::getTable(), "`items_id` = '" . $item->getID() . "'\n                                                   AND `itemtype` = '" . $item->getType() . "'\n                                                   AND `is_deleted` = '0'", true);
             foreach ($found_devices as $devices_id => &$device) {
                 unset($device['items_id']);
                 unset($device['itemtype']);
                 unset($device['is_deleted']);
             }
             if (!empty($found_devices)) {
                 $all_devices[$device_type] = $found_devices;
             }
         }
         $fields['_devices'] = $all_devices;
     }
     // retrieve computer disks
     if (isset($params['with_disks']) && $params['with_disks'] && $itemtype == "Computer") {
         // build query to retrive filesystems
         $query = "SELECT `glpi_filesystems`.`name` AS fsname,\n                          `glpi_computerdisks`.*\n                   FROM `glpi_computerdisks`\n                   LEFT JOIN `glpi_filesystems`\n                             ON (`glpi_computerdisks`.`filesystems_id` = `glpi_filesystems`.`id`)\n                   WHERE `computers_id` = '{$id}'\n                         AND `is_deleted` = '0'";
         $fields['_disks'] = array();
         if ($result = $DB->query($query)) {
             while ($data = $DB->fetch_assoc($result)) {
                 unset($data['computers_id']);
                 unset($data['is_deleted']);
                 $fields['_disks'][] = array('name' => $data);
             }
         }
     }
     // retrieve computer softwares
     if (isset($params['with_softwares']) && $params['with_softwares'] && $itemtype == "Computer") {
         $fields['_softwares'] = array();
         if (!Software::canView()) {
             $fields['_softwares'] = self::arrayRightError();
         } else {
             $query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n                             `glpi_softwares`.`id` AS softwares_id,\n                             `glpi_softwareversions`.`id` AS softwareversions_id,\n                             `glpi_computers_softwareversions`.`is_dynamic`,\n                             `glpi_softwareversions`.`states_id`,\n                             `glpi_softwares`.`is_valid`\n                      FROM `glpi_computers_softwareversions`\n                      LEFT JOIN `glpi_softwareversions`\n                           ON (`glpi_computers_softwareversions`.`softwareversions_id`\n                                 = `glpi_softwareversions`.`id`)\n                      LEFT JOIN `glpi_softwares`\n                           ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n                      WHERE `glpi_computers_softwareversions`.`computers_id` = '{$id}'\n                            AND `glpi_computers_softwareversions`.`is_deleted` = '0'\n                      ORDER BY `glpi_softwares`.`name`, `glpi_softwareversions`.`name`";
             if ($result = $DB->query($query)) {
                 while ($data = $DB->fetch_assoc($result)) {
                     $fields['_softwares'][] = $data;
                 }
             }
         }
     }
     // retrieve item connections
     if (isset($params['with_connections']) && $params['with_connections'] && $itemtype == "Computer") {
         $fields['_connections'] = array();
         foreach ($CFG_GLPI["directconnect_types"] as $connect_type) {
             $connect_item = new $connect_type();
             if ($connect_item->canView()) {
                 $query = "SELECT `glpi_computers_items`.`id` AS assoc_id,\n                         `glpi_computers_items`.`computers_id` AS assoc_computers_id,\n                         `glpi_computers_items`.`itemtype` AS assoc_itemtype,\n                         `glpi_computers_items`.`items_id` AS assoc_items_id,\n                         `glpi_computers_items`.`is_dynamic` AS assoc_is_dynamic,\n                         " . getTableForItemType($connect_type) . ".*\n                         FROM `glpi_computers_items`\n                         LEFT JOIN `" . getTableForItemType($connect_type) . "`\n                           ON (`" . getTableForItemType($connect_type) . "`.`id`\n                                 = `glpi_computers_items`.`items_id`)\n                         WHERE `computers_id` = '{$id}'\n                               AND `itemtype` = '" . $connect_type . "'\n                               AND `glpi_computers_items`.`is_deleted` = '0'";
                 if ($result = $DB->query($query)) {
                     while ($data = $DB->fetch_assoc($result)) {
                         $fields['_connections'][$connect_type][] = $data;
                     }
                 }
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:glpi-project,项目名称:glpi,代码行数:101,代码来源:api.class.php

示例2: title

 /**
  * @since version 0.84
  **/
 static function title()
 {
     global $PLUGIN_HOOKS, $CFG_GLPI;
     $opt_list["Ticket"] = __('Tickets');
     $stat_list["Ticket"]["Ticket_Global"]["name"] = __('Global');
     $stat_list["Ticket"]["Ticket_Global"]["file"] = "stat.global.php?itemtype=Ticket";
     $stat_list["Ticket"]["Ticket_Ticket"]["name"] = __('By ticket');
     $stat_list["Ticket"]["Ticket_Ticket"]["file"] = "stat.tracking.php?itemtype=Ticket";
     $stat_list["Ticket"]["Ticket_Location"]["name"] = __('By hardware characteristics');
     $stat_list["Ticket"]["Ticket_Location"]["file"] = "stat.location.php?itemtype=Ticket";
     $stat_list["Ticket"]["Ticket_Item"]["name"] = __('By hardware');
     $stat_list["Ticket"]["Ticket_Item"]["file"] = "stat.item.php";
     if (Problem::canView()) {
         $opt_list["Problem"] = _n('Problem', 'Problems', Session::getPluralNumber());
         $stat_list["Problem"]["Problem_Global"]["name"] = __('Global');
         $stat_list["Problem"]["Problem_Global"]["file"] = "stat.global.php?itemtype=Problem";
         $stat_list["Problem"]["Problem_Problem"]["name"] = __('By problem');
         $stat_list["Problem"]["Problem_Problem"]["file"] = "stat.tracking.php?itemtype=Problem";
     }
     if (Change::canView()) {
         $opt_list["Change"] = _n('Change', 'Changes', Session::getPluralNumber());
         $stat_list["Change"]["Change_Global"]["name"] = __('Global');
         $stat_list["Change"]["Change_Global"]["file"] = "stat.global.php?itemtype=Change";
         $stat_list["Change"]["Change_Change"]["name"] = __('By change');
         $stat_list["Change"]["Change_Change"]["file"] = "stat.tracking.php?itemtype=Change";
     }
     //Affichage du tableau de presentation des stats
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>" . __('Select statistics to be displayed') . "</th></tr>";
     echo "<tr class='tab_bg_1'><td class='center'>";
     $values = array($CFG_GLPI["root_doc"] . '/front/stat.php' => Dropdown::EMPTY_VALUE);
     $i = 0;
     $selected = -1;
     $count = count($stat_list);
     foreach ($opt_list as $opt => $group) {
         while ($data = each($stat_list[$opt])) {
             $name = $data[1]["name"];
             $file = $data[1]["file"];
             $comment = "";
             if (isset($data[1]["comment"])) {
                 $comment = $data[1]["comment"];
             }
             $key = $CFG_GLPI["root_doc"] . "/front/" . $file;
             $values[$group][$key] = $name;
             if (stripos($_SERVER['REQUEST_URI'], $key) !== false) {
                 $selected = $key;
             }
         }
     }
     // Manage plugins
     $names = array();
     $optgroup = array();
     if (isset($PLUGIN_HOOKS["stats"]) && is_array($PLUGIN_HOOKS["stats"])) {
         foreach ($PLUGIN_HOOKS["stats"] as $plug => $pages) {
             if (is_array($pages) && count($pages)) {
                 foreach ($pages as $page => $name) {
                     $names[$plug . '/' . $page] = array("name" => $name, "plug" => $plug);
                     $optgroup[$plug] = Plugin::getInfo($plug, 'name');
                 }
             }
         }
         asort($names);
     }
     foreach ($optgroup as $opt => $title) {
         $group = $title;
         foreach ($names as $key => $val) {
             if ($opt == $val["plug"]) {
                 $file = $CFG_GLPI["root_doc"] . "/plugins/" . $key;
                 $values[$group][$file] = $val["name"];
                 if (stripos($_SERVER['REQUEST_URI'], $file) !== false) {
                     $selected = $file;
                 }
             }
         }
     }
     Dropdown::showFromArray('statmenu', $values, array('on_change' => "window.location.href=this.options[this.selectedIndex].value", 'value' => $selected));
     echo "</td>";
     echo "</tr>";
     echo "</table>";
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:83,代码来源:stat.class.php

示例3: getItem

 /**
  * Return the instance fields of itemtype identified by id
  *
  * @since version 9.1
  *
  * @param      string   $itemtype  itemtype (class) of object
  * @param      integer  $id        identifier of object
  * @param      array   $params   array with theses options :
  *    - 'expand_dropdowns' : show dropdown's names instead of id. default: false. Optionnal
  *    - 'get_hateoas' :      show relation of current item in a links attribute. default: true. Optionnal
  *    - 'with_components' :  Only for [Computer, NetworkEquipment, Peripheral, Phone, Printer], Optionnal.
  *    - 'with_disks' :       Only for Computer, retrieve the associated filesystems. Optionnal.
  *    - 'with_softwares' :   Only for Computer, retrieve the associated softwares installations. Optionnal.
  *    - 'with_connections' : Only for Computer, retrieve the associated direct connections (like peripherals and printers) .Optionnal.
  *    - 'with_networkports' :Retrieve all network connections and advanced network informations. Optionnal.
  *    - 'with_infocoms' :    Retrieve financial and administrative informations. Optionnal.
  *    - 'with_contracts' :   Retrieve associated contracts. Optionnal.
  *    - 'with_documents' :   Retrieve associated external documents. Optionnal.
  *    - 'with_tickets' :     Retrieve associated itil tickets. Optionnal.
  *    - 'with_problems' :    Retrieve associated itil problems. Optionnal.
  *    - 'with_changes' :     Retrieve associated itil changes. Optionnal.
  *    - 'with_notes' :       Retrieve Notes (if exists, not all itemtypes have notes). Optionnal.
  *    - 'with_logs' :        Retrieve historical. Optionnal.
  *
  * @return     array    fields of found object
  */
 protected function getItem($itemtype, $id, $params = array())
 {
     global $CFG_GLPI, $DB;
     $this->initEndpoint();
     // default params
     $default = array('expand_dropdowns' => false, 'get_hateoas' => true, 'with_components' => false, 'with_disks' => false, 'with_softwares' => false, 'with_connections' => false, 'with_networkports' => false, 'with_infocoms' => false, 'with_contracts' => false, 'with_documents' => false, 'with_tickets' => false, 'with_problems' => false, 'with_changes' => false, 'with_notes' => false, 'with_logs' => false);
     $params = array_merge($default, $params);
     $item = new $itemtype();
     if (!$item->getFromDB($id)) {
         return $this->messageNotfoundError();
     }
     if (!$item->can($id, READ)) {
         return $this->messageRightError();
     }
     $fields = $item->fields;
     // retrieve devices
     if (isset($params['with_devices']) && $params['with_devices'] && in_array($itemtype, Item_Devices::getConcernedItems())) {
         $all_devices = array();
         foreach (Item_Devices::getItemAffinities($item->getType()) as $device_type) {
             $found_devices = getAllDatasFromTable($device_type::getTable(), "`items_id` = '" . $item->getID() . "'\n                                                   AND `itemtype` = '" . $item->getType() . "'\n                                                   AND `is_deleted` = '0'", true);
             foreach ($found_devices as $devices_id => &$device) {
                 unset($device['items_id']);
                 unset($device['itemtype']);
                 unset($device['is_deleted']);
             }
             if (!empty($found_devices)) {
                 $all_devices[$device_type] = $found_devices;
             }
         }
         $fields['_devices'] = $all_devices;
     }
     // retrieve computer disks
     if (isset($params['with_disks']) && $params['with_disks'] && $itemtype == "Computer") {
         // build query to retrive filesystems
         $query = "SELECT `glpi_filesystems`.`name` AS fsname,\n                          `glpi_computerdisks`.*\n                   FROM `glpi_computerdisks`\n                   LEFT JOIN `glpi_filesystems`\n                             ON (`glpi_computerdisks`.`filesystems_id` = `glpi_filesystems`.`id`)\n                   WHERE `computers_id` = '{$id}'\n                         AND `is_deleted` = '0'";
         if ($result = $DB->query($query)) {
             while ($data = $DB->fetch_assoc($result)) {
                 unset($data['computers_id']);
                 unset($data['is_deleted']);
                 $fields['_disks'][] = array('name' => $data);
             }
         }
     }
     // retrieve computer softwares
     if (isset($params['with_softwares']) && $params['with_softwares'] && $itemtype == "Computer") {
         $fields['_softwares'] = array();
         if (!Software::canView()) {
             $fields['_softwares'] = self::arrayRightError();
         } else {
             $query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n                             `glpi_softwares`.`id` AS softwares_id,\n                             `glpi_softwareversions`.`id` AS softwareversions_id,\n                             `glpi_computers_softwareversions`.`is_dynamic`,\n                             `glpi_softwareversions`.`states_id`,\n                             `glpi_softwares`.`is_valid`\n                      FROM `glpi_computers_softwareversions`\n                      LEFT JOIN `glpi_softwareversions`\n                           ON (`glpi_computers_softwareversions`.`softwareversions_id`\n                                 = `glpi_softwareversions`.`id`)\n                      LEFT JOIN `glpi_softwares`\n                           ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n                      WHERE `glpi_computers_softwareversions`.`computers_id` = '{$id}'\n                            AND `glpi_computers_softwareversions`.`is_deleted` = '0'\n                      ORDER BY `glpi_softwares`.`name`, `glpi_softwareversions`.`name`";
             if ($result = $DB->query($query)) {
                 while ($data = $DB->fetch_assoc($result)) {
                     $fields['_softwares'][] = $data;
                 }
             }
         }
     }
     // retrieve item connections
     if (isset($params['with_connections']) && $params['with_connections'] && $itemtype == "Computer") {
         $fields['_connections'] = array();
         foreach ($CFG_GLPI["directconnect_types"] as $connect_type) {
             $connect_item = new $connect_type();
             if ($connect_item->canView()) {
                 $query = "SELECT `glpi_computers_items`.`id` AS assoc_id,\n                         `glpi_computers_items`.`computers_id` AS assoc_computers_id,\n                         `glpi_computers_items`.`itemtype` AS assoc_itemtype,\n                         `glpi_computers_items`.`items_id` AS assoc_items_id,\n                         `glpi_computers_items`.`is_dynamic` AS assoc_is_dynamic,\n                         " . getTableForItemType($connect_type) . ".*\n                         FROM `glpi_computers_items`\n                         LEFT JOIN `" . getTableForItemType($connect_type) . "`\n                           ON (`" . getTableForItemType($connect_type) . "`.`id`\n                                 = `glpi_computers_items`.`items_id`)\n                         WHERE `computers_id` = '{$id}'\n                               AND `itemtype` = '" . $connect_type . "'\n                               AND `glpi_computers_items`.`is_deleted` = '0'";
                 if ($result = $DB->query($query)) {
                     while ($data = $DB->fetch_assoc($result)) {
                         $fields['_connections'][$connect_type][] = $data;
                     }
                 }
             }
         }
     }
     // retrieve item networkports
     if (isset($params['with_networkports']) && $params['with_networkports']) {
//.........这里部分代码省略.........
开发者ID:stweil,项目名称:glpi,代码行数:101,代码来源:api.class.php


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