本文整理汇总了PHP中Software::canView方法的典型用法代码示例。如果您正苦于以下问题:PHP Software::canView方法的具体用法?PHP Software::canView怎么用?PHP Software::canView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Software
的用法示例。
在下文中一共展示了Software::canView方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showForLicense
/**
* Show computers linked to a License
*
* @param $license SoftwareLicense object
*
* @return nothing
**/
static function showForLicense(SoftwareLicense $license)
{
global $DB, $CFG_GLPI;
$searchID = $license->getField('id');
if (!Software::canView() || !$searchID) {
return false;
}
$canedit = Session::haveRightsOr("software", array(CREATE, UPDATE, DELETE, PURGE));
$canshowcomputer = Computer::canView();
if (isset($_GET["start"])) {
$start = $_GET["start"];
} else {
$start = 0;
}
if (isset($_GET["order"]) && $_GET["order"] == "DESC") {
$order = "DESC";
} else {
$order = "ASC";
}
if (isset($_GET["sort"]) && !empty($_GET["sort"])) {
// manage several param like location,compname : order first
$tmp = explode(",", $_GET["sort"]);
$sort = "`" . implode("` {$order},`", $tmp) . "`";
} else {
$sort = "`entity` {$order}, `compname`";
}
//SoftwareLicense ID
$query_number = "SELECT COUNT(*) AS cpt\n FROM `glpi_computers_softwarelicenses`\n INNER JOIN `glpi_computers`\n ON (`glpi_computers_softwarelicenses`.`computers_id`\n = `glpi_computers`.`id`)\n WHERE `glpi_computers_softwarelicenses`.`softwarelicenses_id` = '{$searchID}'" . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n AND `glpi_computers`.`is_deleted` = '0'\n AND `glpi_computers`.`is_template` = '0'\n AND `glpi_computers_softwarelicenses`.`is_deleted` = '0'";
$number = 0;
if ($result = $DB->query($query_number)) {
$number = $DB->result($result, 0, 0);
}
echo "<div class='center'>";
if ($canedit) {
echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwarelicense.form.php'>";
echo "<input type='hidden' name='softwarelicenses_id' value='{$searchID}'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2 center'>";
echo "<td>";
Computer::dropdown(array('entity' => $license->fields['entities_id'], 'entity_sons' => $license->fields['is_recursive']));
echo "</td>";
echo "<td><input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
}
if ($number < 1) {
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>" . __('No item found') . "</th></tr>";
echo "</table></div>\n";
return;
}
// Display the pager
Html::printAjaxPager(__('Affected computers'), $start, $number);
$query = "SELECT `glpi_computers_softwarelicenses`.*,\n `glpi_computers`.`name` AS compname,\n `glpi_computers`.`id` AS cID,\n `glpi_computers`.`serial`,\n `glpi_computers`.`otherserial`,\n `glpi_users`.`name` AS username,\n `glpi_users`.`id` AS userid,\n `glpi_users`.`realname` AS userrealname,\n `glpi_users`.`firstname` AS userfirstname,\n `glpi_softwarelicenses`.`name` AS license,\n `glpi_softwarelicenses`.`id` AS vID,\n `glpi_softwarelicenses`.`name` AS vername,\n `glpi_entities`.`completename` AS entity,\n `glpi_locations`.`completename` AS location,\n `glpi_states`.`name` AS state,\n `glpi_groups`.`name` AS groupe,\n `glpi_softwarelicenses`.`name` AS lname,\n `glpi_softwarelicenses`.`id` AS lID,\n `glpi_softwarelicenses`.`softwares_id` AS softid\n FROM `glpi_computers_softwarelicenses`\n INNER JOIN `glpi_softwarelicenses`\n ON (`glpi_computers_softwarelicenses`.`softwarelicenses_id`\n = `glpi_softwarelicenses`.`id`)\n INNER JOIN `glpi_computers`\n ON (`glpi_computers_softwarelicenses`.`computers_id` = `glpi_computers`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_computers`.`entities_id` = `glpi_entities`.`id`)\n LEFT JOIN `glpi_locations`\n ON (`glpi_computers`.`locations_id` = `glpi_locations`.`id`)\n LEFT JOIN `glpi_states` ON (`glpi_computers`.`states_id` = `glpi_states`.`id`)\n LEFT JOIN `glpi_groups` ON (`glpi_computers`.`groups_id` = `glpi_groups`.`id`)\n LEFT JOIN `glpi_users` ON (`glpi_computers`.`users_id` = `glpi_users`.`id`)\n WHERE (`glpi_softwarelicenses`.`id` = '{$searchID}') " . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n AND `glpi_computers`.`is_deleted` = '0'\n AND `glpi_computers`.`is_template` = '0'\n AND `glpi_computers_softwarelicenses`.`is_deleted` = '0'\n ORDER BY {$sort} {$order}\n LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
$rand = mt_rand();
if ($result = $DB->query($query)) {
if ($data = $DB->fetch_assoc($result)) {
if ($canedit) {
$rand = mt_rand();
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $_SESSION['glpilist_limit'], 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('purge' => _x('button', 'Delete permanently')));
// show transfer only if multi licenses for this software
if (self::countLicenses($data['softid']) > 1) {
$massiveactionparams['specific_actions'][__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'move_license'] = _x('button', 'Move');
}
// Options to update license
$massiveactionparams['extraparams']['options']['move']['used'] = array($searchID);
$massiveactionparams['extraparams']['options']['move']['softwares_id'] = $license->fields['softwares_id'];
Html::showMassiveActions($massiveactionparams);
}
$soft = new Software();
$soft->getFromDB($license->fields['softwares_id']);
$showEntity = $license->isRecursive();
$linkUser = User::canView();
$text = sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $soft->fields["name"]);
$text = sprintf(__('%1$s - %2$s'), $text, $data["vername"]);
Session::initNavigateListItems('Computer', $text);
$sort_img = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "' alt='' title=''>";
echo "<table class='tab_cadre_fixehov'>";
$columns = array('compname' => __('Name'), 'entity' => __('Entity'), 'serial' => __('Serial number'), 'otherserial' => __('Inventory number'), 'location,compname' => __('Location'), 'state,compname' => __('Status'), 'groupe,compname' => __('Group'), 'username,compname' => __('User'));
if (!$showEntity) {
unset($columns['entity']);
}
$sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit) {
$header_begin .= "<th width='10'>";
$header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
//.........这里部分代码省略.........
示例2: 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;
}
}
}
}
}
//.........这里部分代码省略.........
示例3: showForLicense
/**
* Show users linked to a License
*
* @param $license SoftwareLicense object
*
* @return nothing
**/
static function showForLicense(SoftwareLicense $license)
{
global $DB, $CFG_GLPI;
$searchID = $license->getField('id');
if (!Software::canView() || !$searchID) {
return false;
}
$canedit = PluginFpsoftwareVersionhelper::checkRights("software", array(CREATE, UPDATE, DELETE, PURGE), "Or");
$canshowuser = User::canView();
if (isset($_GET["start"])) {
$start = $_GET["start"];
} else {
$start = 0;
}
if (isset($_GET["order"]) && $_GET["order"] == "DESC") {
$order = "DESC";
} else {
$order = "ASC";
}
//SoftwareLicense ID
$query_number = "SELECT COUNT(*) AS cpt\n FROM `glpi_users_softwarelicenses`\n INNER JOIN `glpi_users`\n ON (`glpi_users_softwarelicenses`.`users_id`\n = `glpi_users`.`id`)\n WHERE `glpi_users_softwarelicenses`.`softwarelicenses_id` = '{$searchID}'";
$number = 0;
if ($result = $DB->query($query_number)) {
$number = $DB->result($result, 0, 0);
}
echo "<div class='center'>";
if ($canedit) {
echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . self::$front_url . "/front/user_softwarelicense.form.php'>";
echo "<input type='hidden' name='softwarelicenses_id' value='{$searchID}'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2 center'>";
echo "<td>";
//FOR NOW ALL USERS ARE SHOWN, DON'T KNOW IF THERE SHOULD BE ANY RESTRICTION.
//ALSO IT CAUSES A POSSIBILITY TO ONE USER MANY TIMES.
User::dropdown(array('right' => 'all'));
echo "</td>";
echo "<td><input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
}
if ($number < 1) {
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>" . __('No item found') . "</th></tr>";
echo "</table></div>\n";
return;
}
// Display the pager
Html::printAjaxPager(__('Affected users'), $start, $number);
$query = "SELECT `glpi_users_softwarelicenses`.*,\n `glpi_users`.`name` AS username,\n `glpi_users`.`id` AS userid,\n `glpi_users`.`realname` AS userrealname,\n `glpi_users`.`firstname` AS userfirstname,\n `glpi_softwarelicenses`.`name` AS license,\n `glpi_softwarelicenses`.`id` AS lID\n FROM `glpi_users_softwarelicenses`\n INNER JOIN `glpi_softwarelicenses`\n ON (`glpi_users_softwarelicenses`.`softwarelicenses_id`\n = `glpi_softwarelicenses`.`id`)\n INNER JOIN `glpi_users`\n ON (`glpi_users_softwarelicenses`.`users_id` = `glpi_users`.`id`)\n WHERE `glpi_softwarelicenses`.`id` = '{$searchID}'\n LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
$rand = mt_rand();
if ($result = $DB->query($query)) {
if ($data = $DB->fetch_assoc($result)) {
if ($canedit) {
$rand = mt_rand();
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
list($higher_version, $massiveactionparams) = PluginFpsoftwareVersionhelper::massiveActionParams($rand, __CLASS__);
// Options to update license
$massiveactionparams['extraparams']['options']['move']['used'] = array($searchID);
$massiveactionparams['extraparams']['options']['move']['softwares_id'] = $license->fields['softwares_id'];
Html::showMassiveActions($higher_version ? $massiveactionparams : __CLASS__, $massiveactionparams);
}
$soft = new Software();
$soft->getFromDB($license->fields['softwares_id']);
$text = sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $soft->fields["name"]);
$text = sprintf(__('%1$s - ID %2$s'), $text, $license->fields['softwares_id']);
Session::initNavigateListItems('User', $text);
echo "<table class='tab_cadre_fixehov'>";
$columns = array('username' => __('Username'), 'userrealname' => __('Surname'), 'userfirstname' => __('First name'), 'added' => __('Added'));
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit) {
$header_begin .= "<th width='10'>";
$header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_end .= "</th>";
}
foreach ($columns as $key => $val) {
// Non order column
$header_end .= "<th>{$val}</th>";
}
$header_end .= "</tr>\n";
echo $header_begin . $header_top . $header_end;
do {
Session::addToNavigateListItems('User', $data["userid"]);
echo "<tr class='tab_bg_2'>";
if ($canedit) {
echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
}
if ($canshowuser) {
echo "<td><a href='user.form.php?id=" . $data['userid'] . "'>" . $data['username'] . "</a></td>";
//.........这里部分代码省略.........
示例4: getTabNameForItem
/**
* @see CommonGLPI::getTabNameForItem()
**/
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
switch ($item->getType()) {
case 'Software':
if (!$withtemplate) {
if ($_SESSION['glpishow_count_on_tabs']) {
return self::createTabEntry(self::getTypeName(Session::getPluralNumber()), self::countForSoftware($item->getID()));
}
return self::getTypeName(Session::getPluralNumber());
}
break;
case 'SoftwareVersion':
if (!$withtemplate) {
$nb = 0;
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = self::countForVersion($item->getID());
}
return array(1 => __('Summary'), 2 => self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $nb));
}
break;
case 'Computer':
// Installation allowed for template
if (Software::canView()) {
if ($_SESSION['glpishow_count_on_tabs']) {
return self::createTabEntry(Software::getTypeName(Session::getPluralNumber()), countElementsInTable('glpi_computers_softwareversions', "computers_id = '" . $item->getID() . "'\n AND `is_deleted`='0'"));
}
return Software::getTypeName(Session::getPluralNumber());
}
break;
}
return '';
}
示例5: 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']) {
//.........这里部分代码省略.........