本文整理汇总了PHP中CommonDBTM::isRecursive方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonDBTM::isRecursive方法的具体用法?PHP CommonDBTM::isRecursive怎么用?PHP CommonDBTM::isRecursive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonDBTM
的用法示例。
在下文中一共展示了CommonDBTM::isRecursive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showActivationFormForItem
/**
* @param $item CommonDBTM object
**/
static function showActivationFormForItem(CommonDBTM $item)
{
if (!self::canUpdate()) {
return false;
}
if ($item->getID()) {
// Recursive type case => need entity right
if ($item->isRecursive()) {
if (!Session::haveAccessToEntity($item->fields["entities_id"])) {
return false;
}
}
} else {
return false;
}
$ri = new self();
echo "<div>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='2'>" . __('Reserve an item') . "</th></tr>";
echo "<tr class='tab_bg_1'>";
if ($ri->getFromDBbyItem($item->getType(), $item->getID())) {
echo "<td class='center'>";
//Switch reservation state
if ($ri->fields["is_active"]) {
Html::showSimpleForm(static::getFormURL(), 'update', __('Make unavailable'), array('id' => $ri->fields['id'], 'is_active' => 0));
} else {
Html::showSimpleForm(static::getFormURL(), 'update', __('Make available'), array('id' => $ri->fields['id'], 'is_active' => 1));
}
echo '</td><td>';
Html::showSimpleForm(static::getFormURL(), 'purge', __('Prohibit reservations'), array('id' => $ri->fields['id']), '', '', array(__('Are you sure you want to return this non-reservable item?'), __('That will remove all the reservations in progress.')));
echo "</td>";
} else {
echo "<td class='center'>";
Html::showSimpleForm(static::getFormURL(), 'add', __('Authorize reservations'), array('items_id' => $item->getID(), 'itemtype' => $item->getType(), 'entities_id' => $item->getEntityID(), 'is_recursive' => $item->isRecursive()));
echo "</td>";
}
echo "</tr></table>";
echo "</div>";
}
示例2: 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;
//.........这里部分代码省略.........
示例3: showForItem
/**
* Show webapplications associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated webapplications 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_webapplications", READ)) {
return false;
}
if (!$item->can($item->fields['id'], READ)) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
$canedit = $item->canadditem('PluginWebapplicationsWebapplication');
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$query = "SELECT `glpi_plugin_webapplications_webapplications_items`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_plugin_webapplications_webapplications`.`name` AS assocName,\n `glpi_plugin_webapplications_webapplications`.*\n FROM `glpi_plugin_webapplications_webapplications_items`\n LEFT JOIN `glpi_plugin_webapplications_webapplications`\n ON (`glpi_plugin_webapplications_webapplications_items`.`plugin_webapplications_webapplications_id`=`glpi_plugin_webapplications_webapplications`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_plugin_webapplications_webapplications`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_plugin_webapplications_webapplications_items`.`items_id` = '{$ID}'\n AND `glpi_plugin_webapplications_webapplications_items`.`itemtype` = '" . $item->getType() . "' ";
$query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_webapplications_webapplications", '', '', true);
$query .= " ORDER BY `assocName`";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$webs = array();
$web = new PluginWebapplicationsWebapplication();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$webs[$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_webapplications_webapplications", '', $entities, true);
$q = "SELECT COUNT(*)\n FROM `glpi_plugin_webapplications_webapplications`\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_webapplications", READ) && $nb > count($used)) {
echo "<form name='webapplication_form{$rand}' id='webapplication_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('PluginWebapplicationsWebapplication') . "'>";
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}'>";
}
PluginWebapplicationsWebapplication::dropdownWebapplication(array('entity' => $entities, 'used' => $used));
echo "</td><td class='center' width='20%'>";
echo "<input type='submit' name='additem' value=\"" . __s('Associate a web application', 'webapplications') . "\" 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($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>" . PluginWebapplicationsWebapplicationType::getTypeName(1) . "</th>";
//.........这里部分代码省略.........
示例4: showAddFormForItem
/**
* @since version 0.90
*
* @param $item
* @param $withtemplate (default '')
* @param $options array
*
* @return boolean
**/
static function showAddFormForItem(CommonDBTM $item, $withtemplate = '', $options = array())
{
global $DB, $CFG_GLPI;
//default options
$params['rand'] = mt_rand();
if (is_array($options) && count($options)) {
foreach ($options as $key => $val) {
$params[$key] = $val;
}
}
if (!$item->can($item->fields['id'], READ)) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
// find documents already associated to the item
$doc_item = new self();
$used_found = $doc_item->find("`items_id` = '" . $item->getID() . "'\n AND `itemtype` = '" . $item->getType() . "'");
$used = array_keys($used_found);
$used = array_combine($used, $used);
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[$item->getID()] = $item->getID();
}
echo "<div class='firstbloc'>";
echo "<form name='documentitem_form" . $params['rand'] . "' id='documentitem_form" . $params['rand'] . "' method='post' 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 width='20%'>";
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='" . $item->isRecursive() . "'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
echo "<input type='hidden' name='items_id' value='" . $item->getID() . "'>";
if ($item->getType() == 'Ticket') {
echo "<input type='hidden' name='tickets_id' value='" . $item->getID() . "'>";
}
echo Html::file(array('multiple' => true));
echo "</td><td class='left'>(" . Document::getMaxUploadSize() . ") </td>";
echo "<td class='center' width='20%'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add a new file') . "\"\n class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
if (Document::canView() && $nb > count($used)) {
echo "<form name='document_form" . $params['rand'] . "' id='document_form" . $params['rand'] . "' method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
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='" . $item->getID() . "'>";
if ($item->getType() == 'Ticket') {
echo "<input type='hidden' name='tickets_id' value='" . $item->getID() . "'>";
echo "<input type='hidden' name='documentcategories_id' value='" . $CFG_GLPI["documentcategories_id_forticket"] . "'>";
}
Document::dropdown(array('entity' => $entities, 'used' => $used));
echo "</td><td class='center' width='20%'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Associate an existing document') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
}
echo "</div>";
}
}
示例5: 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()."'>";
//.........这里部分代码省略.........
示例6: 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 (!plugin_accounts_haveRight('accounts', 'r')) {
return false;
}
if (!$item->can($item->fields['id'], 'r')) {
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"]) && plugin_accounts_haveRight("my_groups", "r")) {
$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 (!plugin_accounts_haveRight("all_users", "r")) {
$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 (plugin_accounts_haveRight('accounts', 'r') && $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}'>";
}
$account->dropdownAccounts("plugin_accounts_accounts_id", $entities, $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>";
//.........这里部分代码省略.........
示例7: showForItem
/**
* Show rack associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated rack must be displayed
* @param $withtemplate (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID) || !self::canView() || !$item->can($item->fields['id'], READ)) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
$canedit = $item->canadditem('PluginRacksRack');
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$itemtype = $item->getType() . "Model";
$query = "SELECT `glpi_plugin_racks_racks_items`.`id` AS assocID,\n `glpi_plugin_racks_racks_items`.`faces_id`,\n `glpi_plugin_racks_racks_items`.`position`,\n `glpi_entities`.`id` AS entity,\n `glpi_plugin_racks_racks`.`name` AS assocName,\n `glpi_plugin_racks_racks`.*\n FROM `glpi_plugin_racks_racks_items`\n LEFT JOIN `glpi_plugin_racks_racks`\n ON (`glpi_plugin_racks_racks_items`.`plugin_racks_racks_id`=`glpi_plugin_racks_racks`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_plugin_racks_racks`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_plugin_racks_racks_items`.`items_id` = '{$ID}'\n AND `glpi_plugin_racks_racks_items`.`itemtype` = '" . $itemtype . "' ";
$query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_racks_racks", '', '', true);
$query .= " ORDER BY `assocName`";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$racks = array();
$rack = new PluginRacksRack();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$racks[$data['assocID']] = $data;
$used[$data['id']] = $data['id'];
}
}
echo "<div class='spaced'>";
if ($canedit && $number && $withtemplate < 2) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number);
Html::showMassiveActions($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>" . __('Disposition', 'racks') . "</th>";
echo "<th>" . __('Position', 'racks') . "</th>";
echo "<th>" . __('Location') . "</th>";
echo "<th>" . __('Place', 'racks') . "</th>";
echo "<th>" . __('Manufacturer') . "</th>";
echo "</tr>";
$used = array();
if ($number) {
Session::initNavigateListItems('PluginRacksRack', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach ($racks as $data) {
$rackID = $data["id"];
$link = NOT_AVAILABLE;
if ($rack->getFromDB($rackID)) {
$link = $rack->getLink();
}
Session::addToNavigateListItems('PluginRacksRack', $rackID);
$used[$rackID] = $rackID;
$assocID = $data["assocID"];
echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
if ($canedit && $withtemplate < 2) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
echo "</td>";
}
echo "<td class='center'>{$link}</td>";
if (Session::isMultiEntitiesMode()) {
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
}
if ($data["faces_id"] == PluginRacksRack::FRONT_FACE) {
$faces_id = __('Front', 'racks');
} else {
$faces_id = _x('Rack enclosure', 'Back', 'racks');
}
echo "<td class='center'>" . $faces_id . "</td>";
echo "<td class='center'>" . $data["position"] . "</td>";
echo "<td>" . Dropdown::getDropdownName("glpi_locations", $data["locations_id"]) . "</td>";
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_plugin_racks_roomlocations", $data["plugin_racks_roomlocations_id"], 0) . "</td>";
echo "<td>" . Dropdown::getDropdownName("glpi_manufacturers", $data["manufacturers_id"]) . "</td>";
echo "</tr>";
$i++;
}
}
echo "</table>";
if ($canedit && $number && $withtemplate < 2) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
//.........这里部分代码省略.........
示例8: 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>";
}
示例9: showForItem
/**
* Prints a direct connection to a computer
*
* @param $item CommonDBTM object: the Monitor/Phone/Peripheral/Printer
* @param $withtemplate integer withtemplate param (default '')
*
* @return nothing (print out a table)
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
// Prints a direct connection to a computer
global $DB;
$comp = new Computer();
$ID = $item->getField('id');
if (!$item->can($ID, READ)) {
return false;
}
$canedit = $item->canEdit($ID);
$rand = mt_rand();
// Is global connection ?
$global = $item->getField('is_global');
$used = array();
$compids = array();
$crit = array('FIELDS' => array('id', 'computers_id', 'is_dynamic'), 'itemtype' => $item->getType(), 'items_id' => $ID, 'is_deleted' => 0);
foreach ($DB->request('glpi_computers_items', $crit) as $data) {
$compids[$data['id']] = $data['computers_id'];
$dynamic[$data['id']] = $data['is_dynamic'];
$used['Computer'][] = $data['computers_id'];
}
$number = count($compids);
if ($canedit && ($global || !$number)) {
echo "<div class='firstbloc'>";
echo "<form name='computeritem_form{$rand}' id='computeritem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Connect a computer') . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='right'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
if ($item->isRecursive()) {
self::dropdownConnect('Computer', $item->getType(), "computers_id", getSonsOf("glpi_entities", $item->getEntityID()), 0, $used);
} else {
self::dropdownConnect('Computer', $item->getType(), "computers_id", $item->getEntityID(), 0, $used);
}
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Connect') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number, 'specific_actions' => array('purge' => _x('button', 'Disconnect')), 'container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
if ($number > 0) {
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit) {
$header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_top .= "</th>";
$header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= "</th>";
}
$header_end .= "<th>" . __('Name') . "</th>";
if (Plugin::haveImport()) {
$header_end .= "<th>" . __('Automatic inventory') . "</th>";
}
$header_end .= "<th>" . __('Entity') . "</th>";
$header_end .= "<th>" . __('Serial number') . "</th>";
$header_end .= "<th>" . __('Inventory number') . "</th>";
$header_end .= "</tr>";
echo $header_begin . $header_top . $header_end;
foreach ($compids as $key => $compid) {
$comp->getFromDB($compid);
echo "<tr class='tab_bg_1'>";
if ($canedit) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $key);
echo "</td>";
}
echo "<td " . ($comp->getField('is_deleted') ? "class='tab_bg_2_2'" : "") . ">" . $comp->getLink() . "</td>";
if (Plugin::haveImport()) {
echo "<td>" . Dropdown::getYesNo($dynamic[$key]) . "</td>";
}
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $comp->getField('entities_id'));
echo "</td>";
echo "<td class='center'>" . $comp->getField('serial') . "</td>";
echo "<td class='center'>" . $comp->getField('otherserial') . "</td>";
echo "</tr>";
}
echo $header_begin . $header_bottom . $header_end;
} else {
echo "<tr><td class='tab_bg_1 b'><i>" . __('Not connected') . "</i>";
echo "</td></tr>";
}
//.........这里部分代码省略.........
示例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: isRecursive
/**
* Is the object recursive
*
* @return boolean
**/
function isRecursive()
{
// Case of Duplicate Entity info to child
if (parent::maybeRecursive()) {
return parent::isRecursive();
}
if (preg_match('/^itemtype/', $this->itemtype)) {
$type = $this->fields[$this->itemtype];
} else {
$type = $this->itemtype;
}
if (class_exists($type)) {
$item = new $type();
if ($item->getFromDB($this->fields[$this->items_id])) {
return $item->isRecursive();
}
}
return false;
}
示例12: showForItem
/**
* Prints a direct connection to a computer
*
* @param $item the Monitor/Phone/Peripheral/Printer
*
* @return nothing (print out a table)
*/
static function showForItem(CommonDBTM $item)
{
// Prints a direct connection to a computer
global $DB, $LANG;
$comp = new Computer();
$target = $comp->getFormURL();
$ID = $item->getField('id');
if (!$item->can($ID, "r")) {
return false;
}
$canedit = $item->can($ID, "w");
// Is global connection ?
$global = $item->getField('is_global');
$used = array();
$compids = array();
$crit = array('FIELDS' => array('id', 'computers_id'), 'itemtype' => $item->getType(), 'items_id' => $ID);
foreach ($DB->request('glpi_computers_items', $crit) as $data) {
$compids[$data['id']] = $data['computers_id'];
}
echo "<div class='spaced'><table width='50%' class='tab_cadre_fixe'>";
echo "<tr><th colspan='2'>";
if (count($compids) == 0) {
echo $LANG['connect'][4];
} else {
if (count($compids) == 1) {
echo $LANG['connect'][3] . " : " . count($compids);
} else {
echo $LANG['connect'][2] . " : " . count($compids);
}
}
echo "</th></tr>";
if (count($compids) > 0) {
foreach ($compids as $key => $compid) {
$comp->getFromDB($compid);
echo "<tr><td class='b tab_bg_1" . ($comp->getField('is_deleted') ? "_2" : "") . "'>";
echo $LANG['help'][25] . " : " . $comp->getLink() . "</td>";
echo "<td class='tab_bg_2" . ($comp->getField('is_deleted') ? "_2" : "") . " center b'>";
if ($canedit) {
echo "<a href=\"{$target}?disconnect=1&computers_id={$compid}&id={$key}\">" . $LANG['buttons'][10] . "</a>";
} else {
echo " ";
}
$used[] = $compid;
}
} else {
echo "<tr><td class='tab_bg_1 b'>" . $LANG['help'][25] . " : ";
echo "<i>" . $LANG['connect'][1] . "</i></td>";
echo "<td class='tab_bg_2' class='center'>";
if ($canedit) {
echo "<form method='post' action=\"{$target}\">";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
if ($item->isRecursive()) {
self::dropdownConnect('Computer', $item->getType(), "computers_id", getSonsOf("glpi_entities", $item->getEntityID()), 0, $used);
} else {
self::dropdownConnect('Computer', $item->getType(), "computers_id", $item->getEntityID(), 0, $used);
}
echo "<input type='submit' name='connect' value=\"" . $LANG['buttons'][9] . "\"\n class='submit'>";
echo "</form>";
} else {
echo " ";
}
}
if ($global && count($compids) > 0) {
echo "</td></tr>";
echo "<tr><td class='tab_bg_1'> </td>";
echo "<td class='tab_bg_2' class='center'>";
if ($canedit) {
echo "<form method='post' action=\"{$target}\">";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
if ($item->isRecursive()) {
self::dropdownConnect('Computer', $item->getType(), "computers_id", getSonsOf("glpi_entities", $item->getEntityID()), 0, $used);
} else {
self::dropdownConnect('Computer', $item->getType(), "computers_id", $item->getEntityID(), 0, $used);
}
echo "<input type='submit' name='connect' value=\"" . $LANG['buttons'][9] . "\"\n class='submit'>";
echo "</form>";
} else {
echo " ";
}
}
echo "</td></tr>";
echo "</table></div>";
}
示例13: 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>";
}
示例14: 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>";
//.........这里部分代码省略.........
示例15: 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>";
//.........这里部分代码省略.........