本文整理汇总了PHP中CommonDBTM::isNewID方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonDBTM::isNewID方法的具体用法?PHP CommonDBTM::isNewID怎么用?PHP CommonDBTM::isNewID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonDBTM
的用法示例。
在下文中一共展示了CommonDBTM::isNewID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showForItem
/**
* Show documents associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated documents must be displayed
* @param $withtemplate (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if ($item->getType() != 'Ticket' && $item->getType() != 'KnowbaseItem' && $item->getType() != 'Reminder' && !Document::canView()) {
return false;
}
$params = array();
$params['rand'] = mt_rand();
self::showAddFormForItem($item, $withtemplate, $params);
self::showListForItem($item, $withtemplate, $params);
}
示例2: showForItem
/**
* Show certificates associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated certificates must be displayed
* @param $withtemplate (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate='') {
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if (!Session::haveRight("plugin_certificates", READ)) {
return false;
}
if (!$item->can($item->fields['id'], READ)) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
$canedit = $item->canadditem('PluginCertificatesCertificate');
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$query = "SELECT `glpi_plugin_certificates_certificates_items`.`id` AS assocID,
`glpi_entities`.`id` AS entity,
`glpi_plugin_certificates_certificates`.`name` AS assocName,
`glpi_plugin_certificates_certificates`.*
FROM `glpi_plugin_certificates_certificates_items`
LEFT JOIN `glpi_plugin_certificates_certificates`
ON (`glpi_plugin_certificates_certificates_items`.`plugin_certificates_certificates_id`=`glpi_plugin_certificates_certificates`.`id`)
LEFT JOIN `glpi_entities` ON (`glpi_plugin_certificates_certificates`.`entities_id`=`glpi_entities`.`id`)
WHERE `glpi_plugin_certificates_certificates_items`.`items_id` = '$ID'
AND `glpi_plugin_certificates_certificates_items`.`itemtype` = '".$item->getType()."' ";
$query .= getEntitiesRestrictRequest(" AND","glpi_plugin_certificates_certificates",'','',true);
$query .= " ORDER BY `assocName`";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$certificates = array();
$certificate = new PluginCertificatesCertificate();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$certificates[$data['assocID']] = $data;
$used[$data['id']] = $data['id'];
}
}
if ($canedit && $withtemplate < 2) {
// Restrict entity for knowbase
$entities = "";
$entity = $_SESSION["glpiactive_entity"];
if ($item->isEntityAssign()) {
/// Case of personal items : entity = -1 : create on active entity (Reminder case))
if ($item->getEntityID() >=0 ) {
$entity = $item->getEntityID();
}
if ($item->isRecursive()) {
$entities = getSonsOf('glpi_entities',$entity);
} else {
$entities = $entity;
}
}
$limit = getEntitiesRestrictRequest(" AND ","glpi_plugin_certificates_certificates",'',$entities,true);
$q = "SELECT COUNT(*)
FROM `glpi_plugin_certificates_certificates`
WHERE `is_deleted` = '0'
$limit";
$result = $DB->query($q);
$nb = $DB->result($result,0,0);
echo "<div class='firstbloc'>";
if (Session::haveRight("plugin_certificates", READ)
&& ($nb > count($used))) {
echo "<form name='certificate_form$rand' id='certificate_form$rand' method='post'
action='".Toolbox::getItemTypeFormURL('PluginCertificatesCertificate')."'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='4' class='center'>";
echo "<input type='hidden' name='entities_id' value='$entity'>";
echo "<input type='hidden' name='is_recursive' value='$is_recursive'>";
echo "<input type='hidden' name='itemtype' value='".$item->getType()."'>";
//.........这里部分代码省略.........
示例3: showForItem
/**
* Show projet associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated projet must be displayed
* @param $withtemplate (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if (!plugin_projet_haveRight('projet', 'r')) {
return false;
}
if (!$item->can($item->fields['id'], 'r')) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
$canedit = $item->canadditem('PluginProjetProjet');
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$query = "SELECT `glpi_plugin_projet_projets_items`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_plugin_projet_projets`.`name` AS assocName,\n `glpi_plugin_projet_projets`.*\n FROM `glpi_plugin_projet_projets_items`\n LEFT JOIN `glpi_plugin_projet_projets`\n ON (`glpi_plugin_projet_projets_items`.`plugin_projet_projets_id`=`glpi_plugin_projet_projets`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_plugin_projet_projets`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_plugin_projet_projets_items`.`items_id` = '{$ID}'\n AND `glpi_plugin_projet_projets_items`.`itemtype` = '" . $item->getType() . "' ";
$query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_projet_projets", '', '', true);
$query .= " ORDER BY `assocName`";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$projets = array();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$projets[$data['assocID']] = $data;
$used[$data['id']] = $data['id'];
}
}
$projet = new PluginProjetProjet();
if ($canedit && $withtemplate < 2) {
// Restrict entity for knowbase
$entities = "";
$entity = $_SESSION["glpiactive_entity"];
if ($item->isEntityAssign()) {
/// Case of personal items : entity = -1 : create on active entity (Reminder case))
if ($item->getEntityID() >= 0) {
$entity = $item->getEntityID();
}
if ($item->isRecursive()) {
$entities = getSonsOf('glpi_entities', $entity);
} else {
$entities = $entity;
}
}
$limit = getEntitiesRestrictRequest(" AND ", "glpi_plugin_projet_projets", '', $entities, true);
$q = "SELECT COUNT(*)\n FROM `glpi_plugin_projet_projets`\n WHERE `is_deleted` = '0'\n AND `is_template` = '0' ";
if ($item->getType() != 'User') {
$q .= " {$limit}";
}
$result = $DB->query($q);
$nb = $DB->result($result, 0, 0);
echo "<div class='firstbloc'>";
if (plugin_projet_haveRight('projet', 'r') && $nb > count($used)) {
echo "<form name='projet_form{$rand}' id='projet_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('PluginProjetProjet') . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='4' class='center'>";
echo "<input type='hidden' name='entities_id' value='{$entity}'>";
echo "<input type='hidden' name='is_recursive' value='{$is_recursive}'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
if ($item->getType() == 'Ticket') {
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
}
if ($item->getType() != 'User') {
$projet->dropdownProjet("plugin_projet_projets_id", $entities, $used);
} else {
$strict_entities = Profile_User::getUserEntities($ID, true);
if (!Session::haveAccessToOneOfEntities($strict_entities) && !isViewAllEntities()) {
$canedit = false;
}
if (countElementsInTableForEntity("glpi_plugin_projet_projets", $strict_entities) > count($used)) {
Dropdown::show('PluginProjetProjet', array('name' => "plugin_projet_projets_id", 'used' => $used, 'entity' => $strict_entities));
}
}
echo "</td><td class='center' width='20%'>";
echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Associate a project', 'projet') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
}
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number && $withtemplate < 2) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
//.........这里部分代码省略.........
示例4: showUsers
static function showUsers(CommonDBTM $item)
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if (!plugin_projet_haveRight('projet', 'r')) {
return false;
}
if (!$item->can($item->fields['id'], 'r')) {
return false;
}
$canread = $item->can($ID, 'r');
$query = "SELECT `glpi_plugin_projet_projets`.* FROM `glpi_plugin_projet_projets` " . " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_projet_projets`.`entities_id`) ";
if ($item->getType() == 'User') {
$query .= " WHERE `glpi_plugin_projet_projets`.`users_id` = '" . $ID . "' ";
} else {
$query .= " WHERE `glpi_plugin_projet_projets`.`groups_id` = '" . $ID . "' ";
}
$query .= "AND `glpi_plugin_projet_projets`.`is_template` = 0 " . getEntitiesRestrictRequest(" AND ", "glpi_plugin_projet_projets", '', '', $item->maybeRecursive());
$result = $DB->query($query);
$number = $DB->numrows($result);
if (Session::isMultiEntitiesMode()) {
$colsup = 1;
} else {
$colsup = 0;
}
if ($number > 0) {
echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/plugins/projet/front/projet.form.php\">";
echo "<div align='center'><table class='tab_cadre_fixe'>";
echo "<tr><th colspan='" . (4 + $colsup) . "'>" . __('Responsible of projects', 'projet') . ":</th></tr>";
echo "<tr><th>" . __('Name') . "</th>";
if (Session::isMultiEntitiesMode()) {
echo "<th>" . __('Entity') . "</th>";
}
echo "<th>" . __('Description') . "</th>";
echo "<th>" . __('Progress') . "</th>";
echo "</tr>";
while ($data = $DB->fetch_array($result)) {
echo "<tr class='tab_bg_1" . ($data["is_deleted"] == '1' ? "_2" : "") . "'>";
if ($canread && (in_array($data['entities_id'], $_SESSION['glpiactiveentities']) || $data["recursive"])) {
echo "<td class='center'><a href='" . $CFG_GLPI["root_doc"] . "/plugins/projet/front/projet.form.php?id=" . $data["id"] . "'>" . $data["name"];
if ($_SESSION["glpiis_ids_visible"]) {
echo " (" . $data["id"] . ")";
}
echo "</a></td>";
} else {
echo "<td class='center'>" . $data["name"];
if ($_SESSION["glpiis_ids_visible"]) {
echo " (" . $data["id"] . ")";
}
echo "</td>";
}
if (Session::isMultiEntitiesMode()) {
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
}
echo "<td align='center'>" . Html::resume_text($data["description"], 250) . "</td>";
echo "<td align='center'>" . $data["advance"] . " %</td>";
echo "</tr>";
}
echo "</table></div>";
Html::closeForm();
echo "<br>";
} else {
echo "<div align='center'><table class='tab_cadre_fixe' style='text-align:center'>";
echo "<tr><th>" . __('Responsible of projects', 'projet') . " - " . __('No item found');
echo "</th></tr></table></div><br>";
}
}
示例5: getAssociatedDocuments
/**
* Get documents associated to an item
*
* @param $item CommonDBTM object for which associated documents must be displayed
* @param $withtemplate (default '')
**/
static function getAssociatedDocuments(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
if (!($item instanceof KnowbaseItem && $CFG_GLPI["use_public_faq"] && !$item->getEntityID())) {
if ($item->isNewID($item->getField('id'))) {
return array();
}
switch ($item->getType()) {
case 'Ticket':
case 'KnowbaseItem':
break;
default:
if (Session::haveRight('document', READ)) {
return array();
}
}
if (!$item->can($item->fields['id'], READ)) {
return array();
}
}
$query = "SELECT `glpi_documents_items`.`id` as assocID,\n `glpi_documents`.*\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_documents`\n ON (`glpi_documents_items`.`documents_id`=`glpi_documents`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_documents`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_documents_items`.`items_id` = '" . $item->getField('id') . "'\n AND `glpi_documents_items`.`itemtype` = '" . $item->getType() . "' ";
if (Session::getLoginUserID()) {
$query .= getEntitiesRestrictRequest(" AND", "glpi_documents", '', '', true);
} else {
// Anonymous access from FAQ
$query .= " AND `glpi_documents`.`entities_id`= '0' ";
}
$docs = array();
foreach ($DB->request($query) as $data) {
$docs[] = $data;
}
return $docs;
}
示例6: showListForItem
/**
* Display changes for an item
*
* Will also display changes of linked items
*
* @param $item CommonDBTM object
*
* @return nothing (display a table)
**/
static function showListForItem(CommonDBTM $item)
{
global $DB, $CFG_GLPI;
if (!Session::haveRight(self::$rightname, self::READALL)) {
return false;
}
if ($item->isNewID($item->getID())) {
return false;
}
$restrict = '';
$order = '';
$options['reset'] = 'reset';
switch ($item->getType()) {
case 'User':
$restrict = "(`glpi_changes_users`.`users_id` = '" . $item->getID() . "')";
$order = '`glpi_changes`.`date_mod` DESC';
$options['criteria'][0]['field'] = 4;
// status
$options['criteria'][0]['searchtype'] = 'equals';
$options['criteria'][0]['value'] = $item->getID();
$options['criteria'][0]['link'] = 'OR';
$options['criteria'][1]['field'] = 66;
// status
$options['criteria'][1]['searchtype'] = 'equals';
$options['criteria'][1]['value'] = $item->getID();
$options['criteria'][1]['link'] = 'OR';
$options['criteria'][5]['field'] = 5;
// status
$options['criteria'][5]['searchtype'] = 'equals';
$options['criteria'][5]['value'] = $item->getID();
$options['criteria'][5]['link'] = 'OR';
break;
case 'Supplier':
$restrict = "(`glpi_changes_suppliers`.`suppliers_id` = '" . $item->getID() . "')";
$order = '`glpi_changes`.`date_mod` DESC';
$options['criteria'][0]['field'] = 6;
$options['criteria'][0]['searchtype'] = 'equals';
$options['criteria'][0]['value'] = $item->getID();
$options['criteria'][0]['link'] = 'AND';
break;
case 'Group':
// Mini search engine
if ($item->haveChildren()) {
$tree = Session::getSavedOption(__CLASS__, 'tree', 0);
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th>" . __('Last changes') . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='center'>";
_e('Child groups');
Dropdown::showYesNo('tree', $tree, -1, array('on_change' => 'reloadTab("start=0&tree="+this.value)'));
} else {
$tree = 0;
}
echo "</td></tr></table>";
if ($tree) {
$restrict = "IN (" . implode(',', getSonsOf('glpi_groups', $item->getID())) . ")";
} else {
$restrict = "='" . $item->getID() . "'";
}
$restrict = "(`glpi_changes_groups`.`groups_id` {$restrict}\n AND `glpi_changes_groups`.`type` = " . CommonITILActor::REQUESTER . ")";
$order = '`glpi_changes`.`date_mod` DESC';
$options['criteria'][0]['field'] = 71;
$options['criteria'][0]['searchtype'] = $tree ? 'under' : 'equals';
$options['criteria'][0]['value'] = $item->getID();
$options['criteria'][0]['link'] = 'AND';
break;
default:
$restrict = "(`items_id` = '" . $item->getID() . "'\n AND `itemtype` = '" . $item->getType() . "')";
$order = '`glpi_changes`.`date_mod` DESC';
break;
}
$query = "SELECT " . self::getCommonSelect() . "\n FROM `glpi_changes`\n LEFT JOIN `glpi_changes_items`\n ON (`glpi_changes`.`id` = `glpi_changes_items`.`changes_id`) " . self::getCommonLeftJoin() . "\n WHERE {$restrict} " . getEntitiesRestrictRequest("AND", "glpi_changes") . "\n ORDER BY {$order}\n LIMIT " . intval($_SESSION['glpilist_limit']);
$result = $DB->query($query);
$number = $DB->numrows($result);
// Ticket for the item
echo "<div class='firstbloc'><table class='tab_cadre_fixe'>";
$colspan = 11;
if (count($_SESSION["glpiactiveentities"]) > 1) {
$colspan++;
}
if ($number > 0) {
Session::initNavigateListItems('Change', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
echo "<tr><th colspan='{$colspan}'>";
//TRANS : %d is the number of problems
echo sprintf(_n('Last %d change', 'Last %d changes', $number), $number);
// echo "<span class='small_space'><a href='".$CFG_GLPI["root_doc"]."/front/ticket.php?".
// Toolbox::append_params($options,'&')."'>".__('Show all')."</a></span>";
echo "</th></tr>";
} else {
echo "<tr><th>" . __('No change found.') . "</th></tr>";
}
// Ticket list
//.........这里部分代码省略.........
示例7: showForItem
/**
* Show documents associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated documents must be displayed
* @param $withtemplate (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if ($item->getType() != 'Ticket' && $item->getType() != 'KnowbaseItem' && !Session::haveRight('document', 'r')) {
return false;
}
if (!$item->can($item->fields['id'], 'r')) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
$linkparam = '';
if (get_class($item) == 'Ticket') {
$linkparam = "&tickets_id=" . $item->fields['id'];
}
$canedit = $item->canadditem('Document');
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$query = "SELECT `glpi_documents_items`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_documents`.`name` AS assocName,\n `glpi_documents`.*\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_documents`\n ON (`glpi_documents_items`.`documents_id`=`glpi_documents`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_documents`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_documents_items`.`items_id` = '{$ID}'\n AND `glpi_documents_items`.`itemtype` = '" . $item->getType() . "' ";
if (Session::getLoginUserID()) {
$query .= getEntitiesRestrictRequest(" AND", "glpi_documents", '', '', true);
} else {
// Anonymous access from FAQ
$query .= " AND `glpi_documents`.`entities_id`= '0' ";
}
// Document : search links in both order using union
if ($item->getType() == 'Document') {
$query .= "UNION\n SELECT `glpi_documents_items`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_documents`.`name` AS assocName,\n `glpi_documents`.*\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_documents`\n ON (`glpi_documents_items`.`items_id`=`glpi_documents`.`id`)\n LEFT JOIN `glpi_entities`\n ON (`glpi_documents`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_documents_items`.`documents_id` = '{$ID}'\n AND `glpi_documents_items`.`itemtype` = '" . $item->getType() . "' ";
if (Session::getLoginUserID()) {
$query .= getEntitiesRestrictRequest(" AND", "glpi_documents", '', '', true);
} else {
// Anonymous access from FAQ
$query .= " AND `glpi_documents`.`entities_id`='0' ";
}
}
$query .= " ORDER BY `assocName`";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$documents = array();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$documents[$data['assocID']] = $data;
$used[$data['id']] = $data['id'];
}
}
if ($canedit && $withtemplate < 2) {
// Restrict entity for knowbase
$entities = "";
$entity = $_SESSION["glpiactive_entity"];
if ($item->isEntityAssign()) {
/// Case of personal items : entity = -1 : create on active entity (Reminder case))
if ($item->getEntityID() >= 0) {
$entity = $item->getEntityID();
}
if ($item->isRecursive()) {
$entities = getSonsOf('glpi_entities', $entity);
} else {
$entities = $entity;
}
}
$limit = getEntitiesRestrictRequest(" AND ", "glpi_documents", '', $entities, true);
$q = "SELECT COUNT(*)\n FROM `glpi_documents`\n WHERE `is_deleted` = '0'\n {$limit}";
$result = $DB->query($q);
$nb = $DB->result($result, 0, 0);
if ($item->getType() == 'Document') {
$used[$ID] = $ID;
}
echo "<div class='firstbloc'>";
echo "<form name='documentitem_form{$rand}' id='documentitem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('Document') . "' enctype=\"multipart/form-data\">";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='5'>" . __('Add a document') . "</th></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td class='center'>";
_e('Heading');
echo '</td><td>';
DocumentCategory::dropdown(array('entity' => $entities));
echo "</td>";
echo "<td class='right'>";
echo "<input type='hidden' name='entities_id' value='{$entity}'>";
echo "<input type='hidden' name='is_recursive' value='{$is_recursive}'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
if ($item->getType() == 'Ticket') {
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
}
//.........这里部分代码省略.........
示例8: showForItem
/**
* Show resource associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated resource must be displayed
* @param $withtemplate (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if (!plugin_resources_haveRight('resources', 'r')) {
return false;
}
if (!$item->can($item->fields['id'], 'r')) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
$canedit = $item->canadditem('PluginResourcesResource');
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$query = "SELECT `glpi_plugin_resources_resources_items`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_plugin_resources_resources`.`name` AS assocName,\n `glpi_plugin_resources_resources`.*\n FROM `glpi_plugin_resources_resources_items`\n LEFT JOIN `glpi_plugin_resources_resources`\n ON (`glpi_plugin_resources_resources_items`.`plugin_resources_resources_id`=`glpi_plugin_resources_resources`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_plugin_resources_resources`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_plugin_resources_resources_items`.`items_id` = '{$ID}'\n AND `glpi_plugin_resources_resources_items`.`itemtype` = '" . $item->getType() . "' ";
$query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_resources_resources", '', '', true);
$query .= " ORDER BY `assocName`";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$resources = array();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$resources[$data['assocID']] = $data;
$used[$data['id']] = $data['id'];
}
}
$resource = new PluginResourcesResource();
$more = true;
if ($item->getType() == "User" && $number != 0) {
$more = false;
}
if ($canedit && $withtemplate < 2 && $more) {
// Restrict entity for knowbase
$entities = "";
$entity = $_SESSION["glpiactive_entity"];
if ($item->isEntityAssign()) {
/// Case of personal items : entity = -1 : create on active entity (Reminder case))
if ($item->getEntityID() >= 0) {
$entity = $item->getEntityID();
}
if ($item->isRecursive()) {
$entities = getSonsOf('glpi_entities', $entity);
} else {
$entities = $entity;
}
}
$limit = getEntitiesRestrictRequest(" AND ", "glpi_plugin_resources_resources", '', $entities, true);
$q = "SELECT COUNT(*)\n FROM `glpi_plugin_resources_resources`\n WHERE `is_deleted` = '0'\n AND `is_template` = '0' ";
if ($item->getType() != 'User') {
$q .= " {$limit}";
}
$result = $DB->query($q);
$nb = $DB->result($result, 0, 0);
echo "<div class='firstbloc'>";
if (plugin_resources_haveRight('resources', 'r') && $nb > count($used)) {
echo "<form name='resource_form{$rand}' id='resource_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('PluginResourcesResource') . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='4' class='center'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
if ($item->getType() == 'Ticket') {
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
}
PluginResourcesResource::dropdown(array('entity' => $entities, 'used' => $used));
echo "</td><td class='center' width='20%'>";
echo "<input type='submit' name='additem' value=\"" . __s('Associate a resource', 'resources') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
}
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number && $withtemplate < 2) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number);
Html::showMassiveActions(__CLASS__, $massiveactionparams);
}
echo "<table class='tab_cadre_fixe'>";
if (Session::isMultiEntitiesMode()) {
$colsup = 1;
} else {
$colsup = 0;
//.........这里部分代码省略.........
示例9: showForSupplier
/**
* Show domains associated to a supplier
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated domains must be displayed
* @param $withtemplate (default '')
**/
static function showForSupplier(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if (!plugin_domains_haveRight('domains', 'r')) {
return false;
}
if (!$item->can($item->fields['id'], 'r')) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$query = "SELECT `glpi_plugin_domains_domains`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_plugin_domains_domains`.`name` AS assocName,\n `glpi_plugin_domains_domains`.* " . "FROM `glpi_plugin_domains_domains` " . " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_domains_domains`.`entities_id`) " . " WHERE `suppliers_id` = '{$ID}' " . getEntitiesRestrictRequest(" AND ", "glpi_plugin_domains_domains", '', '', true);
$query .= " ORDER BY `assocName` ";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$domains = array();
$domain = new PluginDomainsDomain();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$domains[$data['assocID']] = $data;
$used[$data['id']] = $data['id'];
}
}
echo "<div class='spaced'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
echo "<th>" . __('Name') . "</th>";
if (Session::isMultiEntitiesMode()) {
echo "<th>" . __('Entity') . "</th>";
}
echo "<th>" . __('Group in charge of the hardware') . "</th>";
echo "<th>" . __('Supplier') . "</th>";
echo "<th>" . __('Technician in charge of the hardware') . "</th>";
echo "<th>" . __('Type') . "</th>";
echo "<th>" . __('Creation date') . "</th>";
echo "<th>" . __('Expiration date') . "</th>";
echo "</tr>";
$used = array();
if ($number) {
Session::initNavigateListItems('PluginDomainsDomain', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach ($domains as $data) {
$domainID = $data["id"];
$link = NOT_AVAILABLE;
if ($domain->getFromDB($domainID)) {
$link = $domain->getLink();
}
Session::addToNavigateListItems('PluginDomainsDomain', $domainID);
$used[$domainID] = $domainID;
$assocID = $data["assocID"];
echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
echo "<td class='center'>{$link}</td>";
if (Session::isMultiEntitiesMode()) {
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
}
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_groups", $data["groups_id_tech"]) . "</td>";
echo "<td>";
echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/enterprise.form.php?ID=" . $data["suppliers_id"] . "\">";
echo Dropdown::getDropdownName("glpi_suppliers", $data["suppliers_id"]);
if ($_SESSION["glpiis_ids_visible"] == 1) {
echo " (" . $data["suppliers_id"] . ")";
}
echo "</a></td>";
echo "<td class='center'>" . getUsername($data["users_id_tech"]) . "</td>";
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_plugin_domains_domaintypes", $data["plugin_domains_domaintypes_id"]) . "</td>";
echo "<td class='center'>" . Html::convdate($data["date_creation"]) . "</td>";
if ($data["date_expiration"] <= date('Y-m-d') && !empty($data["date_expiration"])) {
echo "<td class='center'><div class='deleted'>" . convdate($data["date_expiration"]) . "</div></td>";
} else {
if (empty($data["date_expiration"])) {
echo "<td class='center'>" . __('Does not expire', 'domains') . "</td>";
} else {
echo "<td class='center'>" . Html::convdate($data["date_expiration"]) . "</td>";
}
}
echo "</tr>";
$i++;
}
}
echo "</table>";
echo "</div>";
}
示例10: showForItem
/**
* Show routetables associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated routetables must be displayed
* @param $withtemplate (default '')
* */
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if (!plugin_routetables_haveRight('routetables', 'r')) {
return false;
}
if (!$item->can($item->fields['id'], 'r')) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
$canedit = $item->canadditem('PluginRoutetablesRoutetable');
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$query = "SELECT `glpi_plugin_routetables_routetables_items`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_plugin_routetables_routetables`.`name` AS assocName,\n `glpi_plugin_routetables_routetables`.*\n FROM `glpi_plugin_routetables_routetables_items`\n LEFT JOIN `glpi_plugin_routetables_routetables`\n ON (`glpi_plugin_routetables_routetables_items`.`plugin_routetables_routetables_id`=`glpi_plugin_routetables_routetables`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_plugin_routetables_routetables`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_plugin_routetables_routetables_items`.`items_id` = '{$ID}'\n AND `glpi_plugin_routetables_routetables_items`.`itemtype` = '" . $item->getType() . "' ";
$query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_routetables_routetables", '', '', false);
$query .= " ORDER BY `assocName`";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$routetables = array();
$routetable = new PluginRoutetablesRoutetable();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$routetables[$data['id']] = $data;
$used[$data['id']] = $data['id'];
}
}
if ($canedit && $withtemplate < 2) {
// Restrict entity for knowbase
$entities = "";
$entity = $_SESSION["glpiactive_entity"];
if ($item->isEntityAssign()) {
/// Case of personal items : entity = -1 : create on active entity (Reminder case))
if ($item->getEntityID() >= 0) {
$entity = $item->getEntityID();
}
if ($item->isRecursive()) {
$entities = getSonsOf('glpi_entities', $entity);
} else {
$entities = $entity;
}
}
$limit = getEntitiesRestrictRequest(" AND ", "glpi_plugin_routetables_routetables", '', $entities, false);
$q = "SELECT COUNT(*)\n FROM `glpi_plugin_routetables_routetables`\n WHERE `is_deleted` = '0'\n {$limit}";
$result = $DB->query($q);
$nb = $DB->result($result, 0, 0);
echo "<div class='firstbloc'>";
if (plugin_routetables_haveRight('routetables', 'r') && $nb > count($used)) {
echo "<form name='routetable_form{$rand}' id='routetable_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('PluginRoutetablesRoutetable') . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='4' class='center'>";
echo "<input type='hidden' name='entities_id' value='{$entity}'>";
echo "<input type='hidden' name='is_recursive' value='{$is_recursive}'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
if ($item->getType() == 'Ticket') {
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
}
$routetable->dropdownRouteTables("plugin_routetables_routetables_id", $entities, $used);
echo "</td><td class='center' width='20%'>";
echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Associate a routing table', 'routetables') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
}
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number && $withtemplate < 2) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number);
Html::showMassiveActions(__CLASS__, $massiveactionparams);
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
if ($canedit && $number && $withtemplate < 2) {
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
}
echo "<th>" . __('Name') . "</th>";
if (Session::isMultiEntitiesMode()) {
echo "<th>" . __('Entity') . "</th>";
}
echo "<th>" . __('Network') . "</th>";
//.........这里部分代码省略.........
示例11: showForItem
/**
* Show domains associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated domains must be displayed
* @param $withtemplate (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if (!plugin_domains_haveRight('domains', 'r')) {
return false;
}
if (!$item->can($item->fields['id'], 'r')) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
$canedit = $item->canadditem('PluginDomainsDomain');
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$query = "SELECT `glpi_plugin_domains_domains_items`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_plugin_domains_domains`.`name` AS assocName,\n `glpi_plugin_domains_domains`.*\n FROM `glpi_plugin_domains_domains_items`\n LEFT JOIN `glpi_plugin_domains_domains`\n ON (`glpi_plugin_domains_domains_items`.`plugin_domains_domains_id`=`glpi_plugin_domains_domains`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_plugin_domains_domains`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_plugin_domains_domains_items`.`items_id` = '{$ID}'\n AND `glpi_plugin_domains_domains_items`.`itemtype` = '" . $item->getType() . "' ";
$query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_domains_domains", '', '', true);
$query .= " ORDER BY `assocName`";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$domains = array();
$domain = new PluginDomainsDomain();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$domains[$data['assocID']] = $data;
$used[$data['id']] = $data['id'];
}
}
if ($canedit && $withtemplate < 2) {
// Restrict entity for knowbase
$entities = "";
$entity = $_SESSION["glpiactive_entity"];
if ($item->isEntityAssign()) {
/// Case of personal items : entity = -1 : create on active entity (Reminder case))
if ($item->getEntityID() >= 0) {
$entity = $item->getEntityID();
}
if ($item->isRecursive()) {
$entities = getSonsOf('glpi_entities', $entity);
} else {
$entities = $entity;
}
}
$limit = getEntitiesRestrictRequest(" AND ", "glpi_plugin_domains_domains", '', $entities, true);
$q = "SELECT COUNT(*)\n FROM `glpi_plugin_domains_domains`\n WHERE `is_deleted` = '0'\n {$limit}";
$result = $DB->query($q);
$nb = $DB->result($result, 0, 0);
echo "<div class='firstbloc'>";
if (plugin_domains_haveRight('domains', 'r') && $nb > count($used)) {
echo "<form name='domain_form{$rand}' id='domain_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('PluginDomainsDomain') . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='4' class='center'>";
echo "<input type='hidden' name='entities_id' value='{$entity}'>";
echo "<input type='hidden' name='is_recursive' value='{$is_recursive}'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
if ($item->getType() == 'Ticket') {
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
}
$domain->dropdownDomains("plugin_domains_domains_id", $entities, $used);
echo "</td><td class='center' width='20%'>";
echo "<input type='submit' name='additem' value=\"" . __s('Associate a domain', 'domains') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
}
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number && $withtemplate < 2) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number);
Html::showMassiveActions(__CLASS__, $massiveactionparams);
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
if ($canedit && $number && $withtemplate < 2) {
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
}
echo "<th>" . __('Name') . "</th>";
if (Session::isMultiEntitiesMode()) {
echo "<th>" . __('Entity') . "</th>";
}
echo "<th>" . __('Group in charge of the hardware') . "</th>";
//.........这里部分代码省略.........
示例12: showForItem
/**
* Show accounts associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated accounts must be displayed
* @param $withtemplate (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if (!Session::haveRight("plugin_accounts", READ)) {
return false;
}
if (!$item->can($item->fields['id'], READ)) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
$canedit = $item->canadditem('PluginAccountsAccount');
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$who = Session::getLoginUserID();
if (count($_SESSION["glpigroups"]) && Session::haveRight("plugin_accounts_my_groups", 1)) {
$first_groups = true;
$groups = "";
foreach ($_SESSION['glpigroups'] as $val) {
if (!$first_groups) {
$groups .= ",";
} else {
$first_groups = false;
}
$groups .= "'" . $val . "'";
}
$ASSIGN = "( `groups_id` IN ({$groups}) OR `users_id` = '{$who}') ";
} else {
// Only personal ones
$ASSIGN = " `users_id` = '{$who}' ";
}
$query = "SELECT `glpi_plugin_accounts_accounts_items`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_plugin_accounts_accounts`.`name` AS assocName,\n `glpi_plugin_accounts_accounts`.*\n FROM `glpi_plugin_accounts_accounts_items`\n LEFT JOIN `glpi_plugin_accounts_accounts`\n ON (`glpi_plugin_accounts_accounts_items`.`plugin_accounts_accounts_id`=`glpi_plugin_accounts_accounts`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_plugin_accounts_accounts`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_plugin_accounts_accounts_items`.`items_id` = '{$ID}'\n AND `glpi_plugin_accounts_accounts_items`.`itemtype` = '" . $item->getType() . "' ";
$query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_accounts_accounts", '', '', true);
if (!Session::haveRight("plugin_accounts_see_all_users", 1)) {
$query .= " AND {$ASSIGN} ";
}
$query .= " ORDER BY `assocName`";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$accounts = array();
$account = new PluginAccountsAccount();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$accounts[$data['assocID']] = $data;
$used[$data['id']] = $data['id'];
}
}
if ($canedit && $withtemplate < 2) {
// Restrict entity for knowbase
$entities = "";
$entity = $_SESSION["glpiactive_entity"];
if ($item->isEntityAssign()) {
/// Case of personal items : entity = -1 : create on active entity (Reminder case))
if ($item->getEntityID() >= 0) {
$entity = $item->getEntityID();
}
if ($item->isRecursive()) {
$entities = getSonsOf('glpi_entities', $entity);
} else {
$entities = $entity;
}
}
$limit = getEntitiesRestrictRequest(" AND ", "glpi_plugin_accounts_accounts", '', $entities, true);
$q = "SELECT COUNT(*)\n FROM `glpi_plugin_accounts_accounts`\n WHERE `is_deleted` = '0'\n {$limit}";
$result = $DB->query($q);
$nb = $DB->result($result, 0, 0);
echo "<div class='firstbloc'>";
if (Session::haveRight('plugin_accounts', READ) && $nb > count($used)) {
echo "<form name='account_form{$rand}' id='account_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('PluginAccountsAccount') . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='4' class='center'>";
echo "<input type='hidden' name='entities_id' value='{$entity}'>";
echo "<input type='hidden' name='is_recursive' value='{$is_recursive}'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
if ($item->getType() == 'Ticket') {
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
}
PluginAccountsAccount::dropdownAccount(array('entity' => $entities, 'used' => $used));
echo "</td><td class='center' width='20%'>";
echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Associate a account', 'accounts') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
//.........这里部分代码省略.........
示例13: showForItem
/**
* Show documents associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated documents must be displayed
* @param $withtemplate (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if ($item->getType() != 'Ticket' && $item->getType() != 'KnowbaseItem' && $item->getType() != 'Reminder' && !Document::canView()) {
return false;
}
if (!$item->can($item->fields['id'], READ)) {
return false;
}
$columns = array('name' => __('Name'), 'entity' => __('Entity'), 'filename' => __('File'), 'link' => __('Web link'), 'headings' => __('Heading'), 'mime' => __('MIME type'));
if ($CFG_GLPI['use_rich_text']) {
$columns['tag'] = __('Tag');
}
$columns['assocdate'] = __('Date');
if (empty($withtemplate)) {
$withtemplate = 0;
}
$linkparam = '';
if (get_class($item) == 'Ticket') {
$linkparam = "&tickets_id=" . $item->fields['id'];
}
if (isset($_GET["order"]) && $_GET["order"] == "ASC") {
$order = "ASC";
} else {
$order = "DESC";
}
if (isset($_GET["sort"]) && !empty($_GET["sort"]) && isset($columns[$_GET["sort"]])) {
$sort = "`" . $_GET["sort"] . "`";
} else {
$sort = "`assocdate`";
}
$canedit = $item->canAddItem('Document') && Document::canView();
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$query = "SELECT `glpi_documents_items`.`id` AS assocID,\n `glpi_documents_items`.`date_mod` AS assocdate,\n `glpi_entities`.`id` AS entityID,\n `glpi_entities`.`completename` AS entity,\n `glpi_documentcategories`.`completename` AS headings,\n `glpi_documents`.*\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_documents`\n ON (`glpi_documents_items`.`documents_id`=`glpi_documents`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_documents`.`entities_id`=`glpi_entities`.`id`)\n LEFT JOIN `glpi_documentcategories`\n ON (`glpi_documents`.`documentcategories_id`=`glpi_documentcategories`.`id`)\n WHERE `glpi_documents_items`.`items_id` = '{$ID}'\n AND `glpi_documents_items`.`itemtype` = '" . $item->getType() . "' ";
if (Session::getLoginUserID()) {
$query .= getEntitiesRestrictRequest(" AND", "glpi_documents", '', '', true);
} else {
// Anonymous access from FAQ
$query .= " AND `glpi_documents`.`entities_id`= '0' ";
}
// Document : search links in both order using union
if ($item->getType() == 'Document') {
$query .= "UNION\n SELECT `glpi_documents_items`.`id` AS assocID,\n `glpi_documents_items`.`date_mod` AS assocdate,\n `glpi_entities`.`id` AS entityID,\n `glpi_entities`.`completename` AS entity,\n `glpi_documentcategories`.`completename` AS headings,\n `glpi_documents`.*\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_documents`\n ON (`glpi_documents_items`.`items_id`=`glpi_documents`.`id`)\n LEFT JOIN `glpi_entities`\n ON (`glpi_documents`.`entities_id`=`glpi_entities`.`id`)\n LEFT JOIN `glpi_documentcategories`\n ON (`glpi_documents`.`documentcategories_id`=`glpi_documentcategories`.`id`)\n WHERE `glpi_documents_items`.`documents_id` = '{$ID}'\n AND `glpi_documents_items`.`itemtype` = '" . $item->getType() . "' ";
if (Session::getLoginUserID()) {
$query .= getEntitiesRestrictRequest(" AND", "glpi_documents", '', '', true);
} else {
// Anonymous access from FAQ
$query .= " AND `glpi_documents`.`entities_id`='0' ";
}
}
$query .= " ORDER BY {$sort} {$order}";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$documents = array();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$documents[$data['assocID']] = $data;
$used[$data['id']] = $data['id'];
}
}
if ($item->canAddItem('Document') && $withtemplate < 2) {
// Restrict entity for knowbase
$entities = "";
$entity = $_SESSION["glpiactive_entity"];
if ($item->isEntityAssign()) {
/// Case of personal items : entity = -1 : create on active entity (Reminder case))
if ($item->getEntityID() >= 0) {
$entity = $item->getEntityID();
}
if ($item->isRecursive()) {
$entities = getSonsOf('glpi_entities', $entity);
} else {
$entities = $entity;
}
}
$limit = getEntitiesRestrictRequest(" AND ", "glpi_documents", '', $entities, true);
$q = "SELECT COUNT(*)\n FROM `glpi_documents`\n WHERE `is_deleted` = '0'\n {$limit}";
$result = $DB->query($q);
$nb = $DB->result($result, 0, 0);
if ($item->getType() == 'Document') {
$used[$ID] = $ID;
}
echo "<div class='firstbloc'>";
echo "<form name='documentitem_form{$rand}' id='documentitem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('Document') . "' enctype=\"multipart/form-data\">";
echo "<table class='tab_cadre_fixe'>";
//.........这里部分代码省略.........
示例14: showForm
function showForm(CommonDBTM $item, $options = array())
{
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if (!$item->can($item->fields['id'], READ)) {
return false;
}
$rand = mt_rand();
$a_data = getAllDatasFromTable('glpi_plugin_fusioninventory_ipranges_configsecurities', "`plugin_fusioninventory_ipranges_id`='" . $item->getID() . "'", false, '`rank`');
$a_used = array();
foreach ($a_data as $data) {
$a_used[] = $data['plugin_fusioninventory_configsecurities_id'];
}
echo "<div class='firstbloc'>";
echo "<form name='iprange_configsecurity_form{$rand}' id='iprange_configsecurity_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('PluginFusioninventoryIPRange_ConfigSecurity') . "' >";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'>";
echo "<th colspan='2'>" . __('Add a SNMP authentication') . "</th>";
echo "</tr>";
echo "<tr class='tab_bg_2'>";
echo "<td>";
Dropdown::show('PluginFusioninventoryConfigSecurity', array('used' => $a_used));
echo "</td>";
echo "<td>";
echo Html::hidden('plugin_fusioninventory_ipranges_id', array('value' => $item->getID()));
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Associate') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
// Display list of auth associated with IP range
$rand = mt_rand();
echo "<div class='spaced'>";
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'>";
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
echo "<th>";
echo __('SNMP Authentication', 'fusioninventory');
echo "</th>";
echo "<th>";
echo __('Version', 'fusioninventory');
echo "</th>";
echo "<th>";
echo __('Rank');
echo "</th>";
echo "</tr>";
$pfConfigSecurity = new PluginFusioninventoryConfigSecurity();
foreach ($a_data as $data) {
echo "<tr class='tab_bg_2'>";
echo "<td>";
Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
echo "</td>";
echo "<td>";
$pfConfigSecurity->getFromDB($data['plugin_fusioninventory_configsecurities_id']);
echo $pfConfigSecurity->getLink();
echo "</td>";
echo "<td>";
echo $pfConfigSecurity->getSNMPVersion($pfConfigSecurity->fields['snmpversion']);
echo "</td>";
echo "<td>";
echo $data['rank'];
echo "</td>";
echo "</tr>";
}
echo "</table>";
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
echo "</div>";
}
示例15: showForItem
/**
* Show shellcommands associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated shellcommands must be displayed
* @param $withtemplate (default '')
* */
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if (!self::canView()) {
return false;
}
if (!$item->can($item->fields['id'], READ)) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
$width = 200;
$canedit = $item->canadditem('PluginShellcommandsShellcommand');
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$query = "SELECT `glpi_plugin_shellcommands_shellcommands_items`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_plugin_shellcommands_shellcommands`.`name` AS assocName,\n `glpi_plugin_shellcommands_shellcommands`.*\n FROM `glpi_plugin_shellcommands_shellcommands_items`\n LEFT JOIN `glpi_plugin_shellcommands_shellcommands`\n ON (`glpi_plugin_shellcommands_shellcommands_items`.`plugin_shellcommands_shellcommands_id`=`glpi_plugin_shellcommands_shellcommands`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_plugin_shellcommands_shellcommands`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_plugin_shellcommands_shellcommands_items`.`itemtype` = '" . $item->getType() . "' \n AND !`glpi_plugin_shellcommands_shellcommands`.`is_deleted`";
$query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_shellcommands_shellcommands", '', '', true);
$query .= " ORDER BY `assocName`";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$shells = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$shells[$data['assocID']] = $data;
}
}
echo "<div class='spaced'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
echo "<th>" . __('Associated Commands', 'shellcommands') . "</th>";
echo "</tr>";
if ($number) {
Session::initNavigateListItems('PluginShellcommandsShellcommand', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
$selectCommandName[0] = Dropdown::EMPTY_VALUE;
// $countCommand = self::countForItem($item, array('type' => 'ALL'));
foreach ($shells as $data) {
// if(isset($countCommand[$data['link'].$data['id']]))
$selectCommandName[$data['link'] . '-' . $data['id']] = $data['assocName'];
}
echo "<tr class='tab_bg_2'>\n <td class='center'>" . PluginShellcommandsShellcommand::getTypeName(1) . " ";
$randSelect = Dropdown::showFromArray("name", $selectCommandName, array('width' => $width));
echo "<span id='command_name{$randSelect}'></span></td>";
echo "</tr>";
Ajax::updateItemOnSelectEvent("dropdown_name{$randSelect}", "command_name{$randSelect}", $CFG_GLPI["root_doc"] . "/plugins/shellcommands/ajax/dropdownCommandValue.php", array('idtable' => $item->getType(), 'width' => $width, 'value' => '__VALUE__', 'itemID' => $ID, 'countItem' => 1, 'itemtype' => $item->getType(), 'toupdate' => 'shellcommand_result', 'command_type' => 'PluginShellcommandsShellcommand', 'myname' => "command_name"));
}
echo "</table>";
echo "</div>";
echo "<div class='spaced' id='shellcommand_result'></div>";
}