本文整理汇总了PHP中Computer::canView方法的典型用法代码示例。如果您正苦于以下问题:PHP Computer::canView方法的具体用法?PHP Computer::canView怎么用?PHP Computer::canView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Computer
的用法示例。
在下文中一共展示了Computer::canView方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTabNameForItem
/**
* @see CommonGLPI::getTabNameForItem()
**/
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
if (!$withtemplate && $item->getType() == 'Computer' && Computer::canView()) {
if ($_SESSION['glpishow_count_on_tabs']) {
return self::createTabEntry(self::getTypeName(Session::getPluralNumber()), countElementsInTable('glpi_computervirtualmachines', "computers_id = '" . $item->getID() . "'\n AND `is_deleted`='0'"));
}
return self::getTypeName(Session::getPluralNumber());
}
return '';
}
示例2: getTabNameForItem
/**
* @see CommonGLPI::getTabNameForItem()
**/
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
if (!$withtemplate && $item->getType() == 'Computer' && Computer::canView()) {
$nb = 0;
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = countElementsInTable('glpi_computervirtualmachines', ['computers_id' => $item->getID(), 'is_deleted' => 0]);
}
return self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $nb);
}
return '';
}
示例3: getTabNameForItem
/**
* @see CommonGLPI::getTabNameForItem()
**/
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
// can exists for template
if ($item->getType() == 'Computer' && Computer::canView()) {
$nb = 0;
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = countElementsInTable('glpi_computerantiviruses', "computers_id = '" . $item->getID() . "' AND `is_deleted`='0'");
}
return self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $nb);
}
return '';
}
示例4: 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>";
}
示例5: 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);
//.........这里部分代码省略.........
示例6: getTabNameForItem
/**
* @see CommonGLPI::getTabNameForItem()
**/
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
// can exists for Template
if ($item->can($item->getField('id'), READ)) {
$nb = 0;
switch ($item->getType()) {
case 'Phone':
case 'Printer':
case 'Peripheral':
case 'Monitor':
if (Computer::canView()) {
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = self::countForItem($item);
}
return self::createTabEntry(_n('Connection', 'Connections', Session::getPluralNumber()), $nb);
}
break;
case 'Computer':
if (Phone::canView() || Printer::canView() || Peripheral::canView() || Monitor::canView()) {
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = self::countForComputer($item);
}
return self::createTabEntry(_n('Connection', 'Connections', Session::getPluralNumber()), $nb);
}
break;
}
}
return '';
}