本文整理汇总了PHP中Infocom::canView方法的典型用法代码示例。如果您正苦于以下问题:PHP Infocom::canView方法的具体用法?PHP Infocom::canView怎么用?PHP Infocom::canView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Infocom
的用法示例。
在下文中一共展示了Infocom::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;
}
}
}
}
}
//.........这里部分代码省略.........
示例2: title
/**
* Show report title
**/
static function title()
{
global $PLUGIN_HOOKS, $CFG_GLPI;
// Report generation
// Default Report included
$report_list["default"]["name"] = __('Default report');
$report_list["default"]["file"] = "report.default.php";
if (Contract::canView()) {
// Rapport ajoute par GLPI V0.2
$report_list["Contrats"]["name"] = __('By contract');
$report_list["Contrats"]["file"] = "report.contract.php";
}
if (Infocom::canView()) {
$report_list["Par_annee"]["name"] = __('By year');
$report_list["Par_annee"]["file"] = "report.year.php";
$report_list["Infocoms"]["name"] = __('Hardware financial and administrative information');
$report_list["Infocoms"]["file"] = "report.infocom.php";
$report_list["Infocoms2"]["name"] = __('Other financial and administrative information (licenses, cartridges, consumables)');
$report_list["Infocoms2"]["file"] = "report.infocom.conso.php";
}
if (Session::haveRight("networking", READ)) {
$report_list["Rapport prises reseau"]["name"] = __('Network report');
$report_list["Rapport prises reseau"]["file"] = "report.networking.php";
}
if (Session::haveRight("reservation", READ)) {
$report_list["reservation"]["name"] = __('Loan');
$report_list["reservation"]["file"] = "report.reservation.php";
}
if (Computer::canView() || Monitor::canView() || Session::haveRight("networking", READ) || Peripheral::canView() || Printer::canView() || Phone::canView()) {
$report_list["state"]["name"] = _n('Status', 'Statuses', Session::getPluralNumber());
$report_list["state"]["file"] = "report.state.php";
}
//Affichage du tableau de presentation des stats
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='2'>" . __('Select the report you want to generate') . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='center'>";
$count = count($report_list);
$selected = -1;
$values = array($CFG_GLPI["root_doc"] . '/front/report.php' => Dropdown::EMPTY_VALUE);
while ($data = each($report_list)) {
$val = $data[0];
$name = $report_list["{$val}"]["name"];
$file = $report_list["{$val}"]["file"];
$key = $CFG_GLPI["root_doc"] . "/front/" . $file;
$values[$key] = $name;
if (stripos($_SERVER['REQUEST_URI'], $key) !== false) {
$selected = $key;
}
}
$names = array();
$optgroup = array();
if (isset($PLUGIN_HOOKS["reports"]) && is_array($PLUGIN_HOOKS["reports"])) {
foreach ($PLUGIN_HOOKS["reports"] 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>";
}
示例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']) {
//.........这里部分代码省略.........