本文整理汇总了PHP中Infocom::canUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP Infocom::canUpdate方法的具体用法?PHP Infocom::canUpdate怎么用?PHP Infocom::canUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Infocom
的用法示例。
在下文中一共展示了Infocom::canUpdate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayDatas
/**
* Display datas extracted from DB
*
* @param $data array of search datas prepared to get datas
*
* @return nothing
**/
static function displayDatas(array &$data)
{
global $CFG_GLPI;
$item = null;
if (class_exists($data['itemtype'])) {
$item = new $data['itemtype']();
}
$rand = mt_rand();
if (!isset($data['data']) || !isset($data['data']['totalcount'])) {
return false;
}
// Contruct Pager parameters
$globallinkto = Toolbox::append_params(array('criteria' => Toolbox::stripslashes_deep($data['search']['criteria']), 'metacriteria' => Toolbox::stripslashes_deep($data['search']['metacriteria'])), '&');
$parameters = "sort=" . $data['search']['sort'] . "&order=" . $data['search']['order'] . '&' . $globallinkto;
if (isset($_GET['_in_modal'])) {
$parameters .= "&_in_modal=1";
}
// Global search header
if ($data['display_type'] == self::GLOBAL_SEARCH) {
if ($data['item']) {
echo "<div class='center'><h2>" . $data['item']->getTypeName();
// More items
if ($data['data']['totalcount'] > $data['search']['start'] + self::GLOBAL_DISPLAY_COUNT) {
echo " <a href='" . $data['search']['target'] . "?{$parameters}'>" . __('All') . "</a>";
}
echo "</h2></div>\n";
} else {
return false;
}
}
// If the begin of the view is before the number of items
if ($data['data']['count'] > 0) {
// Display pager only for HTML
if ($data['display_type'] == self::HTML_OUTPUT) {
// For plugin add new parameter if available
if ($plug = isPluginItemType($data['itemtype'])) {
$function = 'plugin_' . $plug['plugin'] . '_addParamFordynamicReport';
if (function_exists($function)) {
$out = $function($data['itemtype']);
if (is_array($out) && count($out)) {
$parameters .= Toolbox::append_params($out, '&');
}
}
}
$search_config_top = "";
$search_config_bottom = "";
if (!isset($_GET['_in_modal']) && Session::haveRightsOr('search_config', array(DisplayPreference::PERSONAL, DisplayPreference::GENERAL))) {
$search_config_top = $search_config_bottom = "<div class='pager_controls'><img alt=\"" . __s('Select default items to show') . "\" title=\"" . __s('Select default items to show') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/options_search.png' ";
$search_config_top .= " class='pointer' onClick=\"";
$search_config_top .= Html::jsGetElementbyID('search_config_top') . ".dialog('open');\">";
$search_config_bottom .= " class='pointer' onClick=\"";
$search_config_bottom .= Html::jsGetElementbyID('search_config_bottom') . ".dialog('open');\">";
$search_config_top .= Ajax::createIframeModalWindow('search_config_top', $CFG_GLPI["root_doc"] . "/front/displaypreference.form.php?itemtype=" . $data['itemtype'], array('title' => __('Select default items to show'), 'reloadonclose' => true, 'display' => false));
$search_config_bottom .= Ajax::createIframeModalWindow('search_config_bottom', $CFG_GLPI["root_doc"] . "/front/displaypreference.form.php?itemtype=" . $data['itemtype'], array('title' => __('Select default items to show'), 'reloadonclose' => true, 'display' => false));
}
if ($item !== null && $item->maybeDeleted()) {
$delete_ctrl = self::isDeletedSwitch($data['search']['is_deleted']);
$search_config_top .= $delete_ctrl;
}
Html::printPager($data['search']['start'], $data['data']['totalcount'], $data['search']['target'], $parameters, $data['itemtype'], 0, $search_config_top);
$search_config_top .= "</div>";
$search_config_bottom .= "</div>";
}
// Define begin and end var for loop
// Search case
$begin_display = $data['data']['begin'];
$end_display = $data['data']['end'];
// Form to massive actions
$isadmin = $data['item'] && $data['item']->canUpdate();
if (!$isadmin && InfoCom::canApplyOn($data['itemtype'])) {
$isadmin = Infocom::canUpdate() || Infocom::canCreate();
}
if ($data['itemtype'] != 'AllAssets') {
$showmassiveactions = count(MassiveAction::getAllMassiveActions($data['item'], $data['search']['is_deleted']));
} else {
$showmassiveactions = true;
}
$massformid = 'massform' . $data['itemtype'];
if ($showmassiveactions && $data['display_type'] == self::HTML_OUTPUT) {
Html::openMassiveActionsForm($massformid);
$massiveactionparams = $data['search']['massiveactionparams'];
$massiveactionparams['num_displayed'] = $end_display - $begin_display;
$massiveactionparams['fixed'] = false;
$massiveactionparams['is_deleted'] = $data['search']['is_deleted'];
$massiveactionparams['container'] = $massformid;
Html::showMassiveActions($massiveactionparams);
}
// Compute number of columns to display
// Add toview elements
$nbcols = count($data['data']['cols']);
if ($data['display_type'] == self::HTML_OUTPUT && $showmassiveactions) {
// HTML display - massive modif
$nbcols++;
//.........这里部分代码省略.........
示例2: showInventoryOptions
/**
* @since version 0.84 (before in entitydata.class)
*
* @param $entity Entity object
**/
static function showInventoryOptions(Entity $entity)
{
$ID = $entity->getField('id');
if (!$entity->can($ID, READ)) {
return false;
}
// Notification right applied
$canedit = Infocom::canUpdate() && Session::haveAccessToEntity($ID);
echo "<div class='spaced'>";
if ($canedit) {
echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='4'>" . __('Autofill dates for financial and administrative information') . "</th></tr>";
$options[0] = __('No autofill');
if ($ID > 0) {
$options[self::CONFIG_PARENT] = __('Inheritance of the parent entity');
}
foreach (getAllDatasFromTable('glpi_states') as $state) {
$options[Infocom::ON_STATUS_CHANGE . '_' . $state['id']] = sprintf(__('Fill when shifting to state %s'), $state['name']);
}
$options[Infocom::COPY_WARRANTY_DATE] = __('Copy the start date of warranty');
//Buy date
echo "<tr class='tab_bg_2'>";
echo "<td> " . __('Date of purchase') . "</td>";
echo "<td>";
Dropdown::showFromArray('autofill_buy_date', $options, array('value' => $entity->getField('autofill_buy_date')));
echo "</td>";
//Order date
echo "<td> " . __('Order date') . "</td>";
echo "<td>";
$options[Infocom::COPY_BUY_DATE] = __('Copy the date of purchase');
Dropdown::showFromArray('autofill_order_date', $options, array('value' => $entity->getField('autofill_order_date')));
echo "</td></tr>";
//Delivery date
echo "<tr class='tab_bg_2'>";
echo "<td> " . __('Delivery date') . "</td>";
echo "<td>";
$options[Infocom::COPY_ORDER_DATE] = __('Copy the order date');
Dropdown::showFromArray('autofill_delivery_date', $options, array('value' => $entity->getField('autofill_delivery_date')));
echo "</td>";
//Use date
echo "<td> " . __('Startup date') . " </td>";
echo "<td>";
$options[Infocom::COPY_DELIVERY_DATE] = __('Copy the delivery date');
Dropdown::showFromArray('autofill_use_date', $options, array('value' => $entity->getField('autofill_use_date')));
echo "</td></tr>";
//Warranty date
echo "<tr class='tab_bg_2'>";
echo "<td> " . __('Start date of warranty') . "</td>";
echo "<td>";
$options = array(0 => __('No autofill'), Infocom::COPY_BUY_DATE => __('Copy the date of purchase'), Infocom::COPY_ORDER_DATE => __('Copy the order date'), Infocom::COPY_DELIVERY_DATE => __('Copy the delivery date'));
if ($ID > 0) {
$options[self::CONFIG_PARENT] = __('Inheritance of the parent entity');
}
Dropdown::showFromArray('autofill_warranty_date', $options, array('value' => $entity->getField('autofill_warranty_date')));
echo "</td><td colspan='2'></td></tr>";
echo "<tr><th colspan='4'>" . _n('Software', 'Software', Session::getPluralNumber()) . "</th></tr>";
echo "<tr class='tab_bg_2'>";
echo "<td> " . __('Entity for software creation') . "</td>";
echo "<td>";
$toadd = array(self::CONFIG_NEVER => __('No change of entity'));
// Keep software in PC entity
if ($ID > 0) {
$toadd[self::CONFIG_PARENT] = __('Inheritance of the parent entity');
}
$entities = array($entity->fields['entities_id']);
foreach (getAncestorsOf('glpi_entities', $entity->fields['entities_id']) as $ent) {
if (Session::haveAccessToEntity($ent)) {
$entities[] = $ent;
}
}
self::dropdown(array('name' => 'entities_id_software', 'value' => $entity->getField('entities_id_software'), 'toadd' => $toadd, 'entity' => $entities, 'comments' => false));
if ($entity->fields['entities_id_software'] == self::CONFIG_PARENT) {
$tid = self::getUsedConfig('entities_id_software', $entity->getField('entities_id'));
echo "<font class='green'> ";
echo self::getSpecificValueToDisplay('entities_id_software', $tid);
echo "</font>";
}
echo "</td><td colspan='2'></td></tr>";
if ($canedit) {
echo "<tr>";
echo "<td class='tab_bg_2 center' colspan='4'>";
echo "<input type='hidden' name='id' value='" . $entity->fields["id"] . "'>";
echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
} else {
echo "</table>";
}
echo "</div>";
}
示例3: showMassiveActionsSubForm
/**
* @see CommonDBTM::showMassiveActionsSubForm()
**/
static function showMassiveActionsSubForm(MassiveAction $ma)
{
global $CFG_GLPI;
switch ($ma->getAction()) {
case 'update':
if (!isset($ma->POST['id_field'])) {
$itemtypes = array_keys($ma->items);
$options_per_type = array();
$options_counts = array();
foreach ($itemtypes as $itemtype) {
$options_per_type[$itemtype] = array();
$group = '';
$show_all = true;
$show_infocoms = true;
$itemtable = getTableForItemType($itemtype);
if (InfoCom::canApplyOn($itemtype) && (!$itemtype::canUpdate() || !Infocom::canUpdate())) {
$show_all = false;
$show_infocoms = Infocom::canUpdate();
}
foreach (Search::getCleanedOptions($itemtype, UPDATE) as $index => $option) {
if (!is_array($option)) {
$group = $option;
$options_per_type[$itemtype][$group] = array();
} else {
if ($option['field'] != 'id' && $index != 1 && ($option["linkfield"] != 'entities_id' || isset($option['massiveaction']) && $option['massiveaction'])) {
if (!isset($option['massiveaction']) || $option['massiveaction']) {
if ($show_all || ($show_infocoms && Search::isInfocomOption($itemtype, $index) || !$show_infocoms && !Search::isInfocomOption($itemtype, $index))) {
$options_per_type[$itemtype][$group][$itemtype . ':' . $index] = $option['name'];
if ($itemtable == $option['table']) {
$field_key = 'MAIN:' . $option['field'] . ':' . $index;
} else {
$field_key = $option['table'] . ':' . $option['field'] . ':' . $index;
}
if (!isset($options_count[$field_key])) {
$options_count[$field_key] = array();
}
$options_count[$field_key][] = $itemtype . ':' . $index . ':' . $group;
if (isset($option['MA_common_field'])) {
if (!isset($options_count[$option['MA_common_field']])) {
$options_count[$option['MA_common_field']] = array();
}
$options_count[$option['MA_common_field']][] = $itemtype . ':' . $index . ':' . $group;
}
}
}
}
}
}
}
if (count($itemtypes) > 1) {
$common_options = array();
foreach ($options_count as $field => $users) {
if (count($users) > 1) {
$labels = array();
foreach ($users as $user) {
$user = explode(':', $user);
$itemtype = $user[0];
$index = $itemtype . ':' . $user[1];
$group = implode(':', array_slice($user, 2));
if (isset($options_per_type[$itemtype][$group][$index])) {
if (!in_array($options_per_type[$itemtype][$group][$index], $labels)) {
$labels[] = $options_per_type[$itemtype][$group][$index];
}
}
$common_options[$field][] = $index;
}
$options[$group][$field] = implode('/', $labels);
}
}
$choose_itemtype = true;
$itemtype_choices = array(-1 => Dropdown::EMPTY_VALUE);
foreach ($itemtypes as $itemtype) {
$itemtype_choices[$itemtype] = $itemtype::getTypeName(Session::getPluralNumber());
}
} else {
$options = $options_per_type[$itemtypes[0]];
$common_options = false;
$choose_itemtype = false;
}
$choose_field = count($options) > 1;
// Beware: "class='tab_cadre_fixe'" induce side effects ...
echo "<table width='100%'><tr>";
$colspan = 0;
if ($choose_field) {
$colspan++;
echo "<td>";
if ($common_options) {
echo __('Select the common field that you want to update');
} else {
echo __('Select the field that you want to update');
}
echo "</td>";
if ($choose_itemtype) {
$colspan++;
echo "<td rowspan='2'>" . __('or') . "</td>";
}
}
//.........这里部分代码省略.........
示例4: showDisplayLink
/**
* Show infocom link to display modal
*
* @param $itemtype integer item type
* @param $device_id integer item ID
*
* @return float
**/
static function showDisplayLink($itemtype, $device_id)
{
global $DB, $CFG_GLPI;
if (!Session::haveRight(self::$rightname, READ) || !($item = getItemForItemtype($itemtype))) {
return false;
}
$query = "SELECT COUNT(*)\n FROM `glpi_infocoms`\n WHERE `items_id` = '{$device_id}'\n AND `itemtype` = '{$itemtype}'";
$add = "add";
$text = __('Add');
$result = $DB->query($query);
if ($DB->result($result, 0, 0) > 0) {
$add = "";
$text = _x('button', 'Show');
} else {
if (!Infocom::canUpdate()) {
return false;
}
}
if ($item->canView()) {
echo "<span onClick=\"" . Html::jsGetElementbyID('infocom' . $itemtype . $device_id) . ".\n dialog('open');\" style='cursor:pointer'>\n <img src=\"" . $CFG_GLPI["root_doc"] . "/pics/dollar{$add}.png\" alt=\"{$text}\" title=\"{$text}\">\n </span>";
Ajax::createIframeModalWindow('infocom' . $itemtype . $device_id, $CFG_GLPI["root_doc"] . "/front/infocom.form.php" . "?itemtype={$itemtype}&items_id={$device_id}", array('height' => 600));
}
}
示例5: showList
//.........这里部分代码省略.........
}
}
}
}
$search_config = "";
if (Session::haveRight("search_config", DisplayPreference::GENERAL)) {
//|| Session::haveRight("search_config_global",CREATE)) {
// Ajax::createModalWindow('searchconfig_window',
// $CFG_GLPI['root_doc']."/ajax/searchconfig.php?itemtype=$itemtype",
// array('title' => __('Select default items to show'),
// 'width' => '1000'));
// $tmp = " class='pointer' onClick=\"searchconfig_window.show()\"";
$tmp = " class='pointer' onClick=\"var w = window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=search_config&itemtype={$itemtype}' ,'glpipopup', " . "'height=400, width=1000, top=100, left=100, scrollbars=yes'); w.focus();\"";
$search_config = "<img alt=\"" . __s('Select default items to show') . "\" title=\"" . __s('Select default items to show') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/options_search.png' ";
$search_config .= $tmp . ">";
}
Html::printPager($p['start'], $numrows, $target, $parameters, $itemtype, 0, $search_config);
}
// Define begin and end var for loop
// Search case
$begin_display = $p['start'];
$end_display = min($numrows, $p['start'] + $LIST_LIMIT);
// No search Case
if ($nosearch) {
$begin_display = 0;
$end_display = min($numrows - $p['start'], $LIST_LIMIT);
}
// Export All case
if ($p['export_all']) {
$begin_display = 0;
$end_display = $numrows;
}
// Form to massive actions
$isadmin = $item && $item->canUpdate();
if (!$isadmin && in_array($itemtype, $CFG_GLPI["infocom_types"])) {
$isadmin = Infocom::canUpdate() || Infocom::canCreate();
}
$showmassiveactions = false;
if ($itemtype != 'AllAssets') {
$showmassiveactions = count($item->getAllMassiveActions($p['is_deleted']));
if ($showmassiveactions && $output_type == self::HTML_OUTPUT) {
Html::openMassiveActionsForm('massform' . $itemtype);
$massiveactionparams = array('num_displayed' => $end_display - $begin_display, 'fixed' => false, 'is_deleted' => $p['is_deleted']);
Html::showMassiveActions($itemtype, $massiveactionparams);
}
}
// Compute number of columns to display
// Add toview elements
$nbcols = $toview_count;
$already_printed = array();
// Add meta search elements if real search (strlen>0) or only NOT search
if ($_SESSION["glpisearchcount2"][$itemtype] > 0 && is_array($p['itemtype2'])) {
for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
if (isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i]) && isset($p['contains2'][$i]) && strlen($p['contains2'][$i]) > 0 && (!isset($p['link2'][$i]) || !strstr($p['link2'][$i], "NOT"))) {
if (!isset($already_printed[$p['itemtype2'][$i] . $p['field2'][$i]])) {
$nbcols++;
$already_printed[$p['itemtype2'][$i] . $p['field2'][$i]] = 1;
}
}
}
}
if ($output_type == self::HTML_OUTPUT) {
// HTML display - massive modif
$nbcols++;
}
// Display List Header
示例6: Infocom
echo " <input type='submit' name='massiveaction' class='submit' value='" . $LANG['buttons'][2] . "'>";
break;
case "duplicate":
if ($item->isEntityAssign()) {
Dropdown::show('Entity');
}
echo " <input type='submit' name='massiveaction' class='submit' value='" . $LANG['buttons'][2] . "'>";
break;
case "update":
$first_group = true;
$newgroup = "";
$items_in_group = 0;
$show_all = true;
$show_infocoms = true;
$ic = new Infocom();
if (in_array($_POST["itemtype"], $CFG_GLPI["infocom_types"]) && (!$item->canUpdate() || !$ic->canUpdate())) {
$show_all = false;
$show_infocoms = $ic->canUpdate();
}
$searchopt = Search::getCleanedOptions($_POST["itemtype"], 'w');
echo "<select name='id_field' id='massiveaction_field'>";
echo "<option value='0' selected>" . DROPDOWN_EMPTY_VALUE . "</option>";
foreach ($searchopt as $key => $val) {
if (!is_array($val)) {
if (!empty($newgroup) && $items_in_group > 0) {
echo $newgroup;
$first_group = false;
}
$items_in_group = 0;
$newgroup = "";
if (!$first_group) {
示例7: getAllMassiveActions
/**
* Get the standard massive actions
*
* @since version 0.84
*
* This must not be overloaded in Class
* @param $is_deleted massive action for deleted items ? (default 0)
* @param $checkitem link item to check right (default NULL)
*
* @return an array of massive actions
**/
function getAllMassiveActions($is_deleted = 0, $checkitem = NULL)
{
global $CFG_GLPI, $PLUGIN_HOOKS;
if (!is_null($checkitem)) {
$isadmin = $checkitem->canUpdate();
} else {
$isadmin = static::canUpdate();
}
$itemtype = $this->getType();
$actions = array();
if ($is_deleted) {
if ($isadmin) {
$actions['purge'] = _x('button', 'Delete permanently');
$actions['restore'] = _x('button', 'Restore');
}
} else {
if ($isadmin || in_array($itemtype, $CFG_GLPI["infocom_types"]) && Infocom::canUpdate()) {
//TRANS: select action 'update' (before doing it)
$actions['update'] = _x('button', 'Update');
}
if (in_array($itemtype, $CFG_GLPI["infocom_types"]) && Infocom::canCreate()) {
$actions['activate_infocoms'] = __('Enable the financial and administrative information');
}
// No delete for entities and tracking of not have right
if ($isadmin) {
// do not take into account is_deleted if items may be dynamic
if ($this->maybeDeleted() && !$this->useDeletedToLockIfDynamic()) {
$actions['delete'] = _x('button', 'Put in dustbin');
} else {
$actions['purge'] = _x('button', 'Delete permanently');
}
}
if (in_array($itemtype, $CFG_GLPI["document_types"])) {
if (Document::canView()) {
$actions['add_document'] = _x('button', 'Add a document');
$actions['remove_document'] = _x('button', 'Remove a document');
}
}
if (in_array($itemtype, $CFG_GLPI["contract_types"])) {
if (Contract::canUpdate()) {
$actions['add_contract_item'] = _x('button', 'Add a contract');
$actions['remove_contract_item'] = _x('button', 'Remove a contract');
}
}
// Specific actions
$actions += $this->getSpecificMassiveActions($checkitem);
// Plugin Specific actions
if (isset($PLUGIN_HOOKS['use_massive_action'])) {
foreach ($PLUGIN_HOOKS['use_massive_action'] as $plugin => $val) {
$plug_actions = Plugin::doOneHook($plugin, 'MassiveActions', $itemtype);
if (count($plug_actions)) {
$actions += $plug_actions;
}
}
}
}
//Add unlock if needed
$actions += Lock::getUnlockMassiveActions($itemtype);
// Manage forbidden actions
$forbidden_actions = $this->getForbiddenStandardMassiveAction();
if (is_array($forbidden_actions) && count($forbidden_actions)) {
foreach ($forbidden_actions as $actiontodel) {
if (isset($actions[$actiontodel])) {
unset($actions[$actiontodel]);
}
}
}
return $actions;
}
示例8: showForMassiveAction
/**
* Dropdown of actions for massive action
*
* @param $itemtype item type
* @param $is_deleted massive action for deleted items ?
* @param $extraparams array of extra parameters
**/
static function showForMassiveAction($itemtype, $is_deleted = 0, $extraparams = array())
{
global $LANG, $CFG_GLPI, $PLUGIN_HOOKS;
/// TODO include in CommonDBTM defining only getAdditionalMassiveAction in sub classes
/// for specific actions (return a array of action name and title)
if (!class_exists($itemtype)) {
return false;
}
if ($itemtype == 'NetworkPort') {
echo "<select name='massiveaction' id='massiveaction'>";
echo "<option value='-1' selected>" . DROPDOWN_EMPTY_VALUE . "</option>";
echo "<option value='delete'>" . $LANG['buttons'][6] . "</option>";
echo "<option value='assign_vlan'>" . $LANG['networking'][55] . "</option>";
echo "<option value='unassign_vlan'>" . $LANG['networking'][58] . "</option>";
// Interest of this massive action ?
// echo "<option value='move'>".$LANG['buttons'][20]."</option>";
echo "</select>";
$params = array('action' => '__VALUE__', 'itemtype' => $itemtype);
ajaxUpdateItemOnSelectEvent("massiveaction", "show_massiveaction", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveActionPorts.php", $params);
echo "<span id='show_massiveaction'> </span>\n";
} else {
$item = new $itemtype();
$infocom = new Infocom();
$isadmin = $item->canUpdate();
echo "<select name='massiveaction' id='massiveaction'>";
echo "<option value='-1' selected>" . DROPDOWN_EMPTY_VALUE . "</option>";
if (!in_array($itemtype, $CFG_GLPI["massiveaction_noupdate_types"]) && ($isadmin && $itemtype != 'Ticket' || in_array($itemtype, $CFG_GLPI["infocom_types"]) && $infocom->canUpdate() || $itemtype == 'Ticket' && haveRight('update_ticket', 1))) {
echo "<option value='update'>" . $LANG['buttons'][14] . "</option>";
}
if (in_array($itemtype, $CFG_GLPI["infocom_types"]) && $infocom->canCreate()) {
echo "<option value='activate_infocoms'>" . $LANG['financial'][68] . "</option>";
}
if ($is_deleted && !in_array($itemtype, $CFG_GLPI["massiveaction_nodelete_types"])) {
if ($isadmin) {
echo "<option value='purge'>" . $LANG['buttons'][22] . "</option>";
echo "<option value='restore'>" . $LANG['buttons'][21] . "</option>";
}
} else {
// No delete for entities and tracking of not have right
if (!in_array($itemtype, $CFG_GLPI["massiveaction_nodelete_types"]) && ($isadmin && $itemtype != 'Ticket' || $itemtype == 'Ticket' && haveRight('delete_ticket', 1))) {
if ($item->maybeDeleted()) {
echo "<option value='delete'>" . $LANG['buttons'][6] . "</option>";
} else {
echo "<option value='purge'>" . $LANG['buttons'][22] . "</option>";
}
}
if ($isadmin && in_array($itemtype, array('Phone', 'Printer', 'Peripheral', 'Monitor'))) {
echo "<option value='connect'>" . $LANG['buttons'][9] . "</option>";
echo "<option value='disconnect'>" . $LANG['buttons'][10] . "</option>";
}
if (in_array($itemtype, $CFG_GLPI["document_types"])) {
$doc = new Document();
if ($doc->canView()) {
echo "<option value='add_document'>" . $LANG['document'][16] . "</option>";
}
}
if (in_array($itemtype, $CFG_GLPI["contract_types"])) {
$contract = new Contract();
if ($contract->canUpdate()) {
echo "<option value='add_contract'>" . $LANG['financial'][36] . "</option>";
}
}
if (haveRight('transfer', 'r') && isMultiEntitiesMode() && in_array($itemtype, array('CartridgeItem', 'Computer', 'ConsumableItem', 'Contact', 'Contract', 'Supplier', 'Monitor', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer', 'Software', 'SoftwareLicense', 'Ticket', 'Document', 'Group', 'Link')) && $isadmin) {
echo "<option value='add_transfer_list'>" . $LANG['buttons'][48] . "</option>";
}
switch ($itemtype) {
case 'Software':
if ($isadmin && countElementsInTable("glpi_rules", "sub_type='RuleSoftwareCategory'") > 0) {
echo "<option value='compute_software_category'>" . $LANG['rulesengine'][38] . " " . $LANG['rulesengine'][40] . "</option>";
}
if (haveRight("rule_dictionnary_software", "w") && countElementsInTable("glpi_rules", "sub_type='RuleDictionnarySoftware'") > 0) {
echo "<option value='replay_dictionnary'>" . $LANG['rulesengine'][76] . "</option>";
}
break;
case 'Computer':
if ($isadmin) {
echo "<option value='connect_to_computer'>" . $LANG['buttons'][9] . "</option>";
echo "<option value='install'>" . $LANG['buttons'][4] . "</option>";
if ($CFG_GLPI['use_ocs_mode']) {
if (haveRight("ocsng", "w") || haveRight("sync_ocsng", "w")) {
echo "<option value='force_ocsng_update'>" . $LANG['ocsng'][24] . "</option>";
}
echo "<option value='unlock_ocsng_field'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][16] . "</option>";
echo "<option value='unlock_ocsng_monitor'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][30] . "</option>";
echo "<option value='unlock_ocsng_peripheral'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][32] . "</option>";
echo "<option value='unlock_ocsng_printer'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][34] . "</option>";
echo "<option value='unlock_ocsng_software'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][52] . "</option>";
echo "<option value='unlock_ocsng_ip'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][50] . "</option>";
echo "<option value='unlock_ocsng_disk'>" . $LANG['buttons'][38] . " " . $LANG['Menu'][33] . " - " . $LANG['ocsng'][55] . "</option>";
}
}
break;
case 'Supplier':
//.........这里部分代码省略.........
示例9: seePreImport
/**
* Prints display pre import
*
* @param $type the type of device
* @param $configID the ID of the supplier config
* @param $start for pager display
* @param $complete to see all device (already imported and not)
* @return nothing (print out a table)
*
*/
static function seePreImport($params)
{
global $DB, $CFG_GLPI;
// Default values of parameters
$p['link'] = array();
$p['field'] = array();
$p['contains'] = array();
$p['searchtype'] = array();
$p['sort'] = '1';
$p['order'] = 'ASC';
$p['start'] = 0;
$p['export_all'] = 0;
$p['link2'] = '';
$p['contains2'] = '';
$p['field2'] = '';
$p['itemtype2'] = '';
$p['searchtype2'] = '';
$p['itemtype'] = '';
$p['manufacturers_id'] = '';
$p['imported'] = '';
foreach ($params as $key => $val) {
$p[$key] = $val;
}
$globallinkto = self::getArrayUrlLink("field", $p['field']) . self::getArrayUrlLink("link", $p['link']) . self::getArrayUrlLink("contains", $p['contains']) . self::getArrayUrlLink("searchtype", $p['searchtype']) . self::getArrayUrlLink("field2", $p['field2']) . self::getArrayUrlLink("contains2", $p['contains2']) . self::getArrayUrlLink("searchtype2", $p['searchtype2']) . self::getArrayUrlLink("itemtype2", $p['itemtype2']) . self::getArrayUrlLink("link2", $p['link2']);
$modeltable = "";
$target = $CFG_GLPI["root_doc"] . "/plugins/manufacturersimports/front/import.php";
if ($p['itemtype'] && $p['manufacturers_id']) {
$config = new PluginManufacturersimportsConfig();
$config->getFromDB($p['manufacturers_id']);
$suppliername = $config->fields["name"];
$supplierclass = "PluginManufacturersimports" . $suppliername;
$supplier = new $supplierclass();
$infocom = new Infocom();
$canedit = Session::haveRight(static::$rightname, UPDATE) && $infocom->canUpdate();
if (!$p['start']) {
$p['start'] = 0;
}
$modeltable = getTableForItemType($p['itemtype'] . "Model");
$modelfield = getForeignKeyFieldForTable(getTableForItemType($p['itemtype'] . "Model"));
$item = new $p['itemtype']();
$itemtable = getTableForItemType($p['itemtype']);
$query = "SELECT `" . $itemtable . "`.`id`,\n `" . $itemtable . "`.`name`, \n `" . $itemtable . "`.`serial`,\n `" . $itemtable . "`.`entities_id`,\n `glpi_plugin_manufacturersimports_logs`.`import_status`,\n `glpi_plugin_manufacturersimports_logs`.`items_id`,\n `glpi_plugin_manufacturersimports_logs`.`itemtype`, \n `glpi_plugin_manufacturersimports_logs`.`documents_id`,\n `glpi_plugin_manufacturersimports_logs`.`date_import`, \n '" . $p['itemtype'] . "' AS type,\n `{$modeltable}`.`name` AS model_name\n FROM `" . $itemtable . "` ";
//model device left join
$query .= "LEFT JOIN `{$modeltable}` ON (`{$modeltable}`.`id` = `" . $itemtable . "`.`" . $modelfield . "`) ";
$query .= " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `" . $itemtable . "`.`entities_id`)";
$query .= " LEFT JOIN `glpi_plugin_manufacturersimports_configs` \n ON (`glpi_plugin_manufacturersimports_configs`.`manufacturers_id` = `" . $itemtable . "`.`manufacturers_id`)";
$query .= " LEFT JOIN `glpi_plugin_manufacturersimports_logs` \n ON (`glpi_plugin_manufacturersimports_logs`.`items_id` = `" . $itemtable . "`.`id` \n AND `glpi_plugin_manufacturersimports_logs`.`itemtype` = '" . $p['itemtype'] . "')";
$query .= " LEFT JOIN `glpi_plugin_manufacturersimports_models` \n ON (`glpi_plugin_manufacturersimports_models`.`items_id` = `" . $itemtable . "`.`id` \n AND `glpi_plugin_manufacturersimports_models`.`itemtype` = '" . $p['itemtype'] . "')";
//serial must be not empty
$query .= " WHERE `" . $itemtable . "`.`is_deleted` = '0'\n AND `" . $itemtable . "`.`is_template` = '0'\n AND `glpi_plugin_manufacturersimports_configs`.`id` = '" . $p['manufacturers_id'] . "'\n AND `" . $itemtable . "`.`serial` != '' ";
//already imported
if ($p['imported'] == self::IMPORTED) {
$query .= " AND `import_status` != " . self::IMPORTED . "";
//not imported
} else {
if ($p['imported'] == self::NOT_IMPORTED) {
$query .= " AND (`date_import` IS NULL OR `import_status` = " . self::IMPORTED . " ";
$query .= ") ";
}
}
$entities = "";
if ($config->isRecursive()) {
$entities = getSonsOf('glpi_entities', $config->getEntityID());
} else {
$entities = $config->getEntityID();
}
$query .= "" . getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive());
//// 4 - ORDER
$ORDER = " ORDER BY `entities_id`,`" . $itemtable . "`.`name` ";
$toview = array("name" => 1);
foreach ($toview as $key => $val) {
if ($p['sort'] == $val) {
$ORDER = self::addOrderBy($p['itemtype'], $p['sort'], $p['order'], $key);
}
}
$query .= $ORDER;
$result = $DB->query($query);
$numrows = $DB->numrows($result);
if ($p['start'] < $numrows) {
// Set display type for export if define
$output_type = Search::HTML_OUTPUT;
if (isset($_GET["display_type"])) {
$output_type = $_GET["display_type"];
}
$parameters = "itemtype=" . $p['itemtype'] . "&manufacturers_id=" . $p['manufacturers_id'] . "&imported=" . $p['imported'];
$total = 0;
if ($output_type == Search::HTML_OUTPUT) {
self::printPager($p['start'], $numrows, $target, $parameters, $p['itemtype']);
}
// Define begin and end var for loop
//.........这里部分代码省略.........