本文整理汇总了PHP中CommonDBTM::getEntityID方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonDBTM::getEntityID方法的具体用法?PHP CommonDBTM::getEntityID怎么用?PHP CommonDBTM::getEntityID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonDBTM
的用法示例。
在下文中一共展示了CommonDBTM::getEntityID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getEntityID
/**
* Get the ID of entity assigned to the object
*
* @return ID of the entity
**/
function getEntityID()
{
// Case of Duplicate Entity info to child
if (parent::isEntityAssign()) {
return parent::getEntityID();
}
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]) && $item->isEntityAssign()) {
return $item->getEntityID();
}
}
return -1;
}
示例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: processMassiveActionsForOneItemtype
//.........这里部分代码省略.........
if ($item->delete($delete_array, $force)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
break;
case 'update':
if (!isset($ma->POST['search_options']) || !isset($ma->POST['search_options'][$item->getType()])) {
return false;
}
$index = $ma->POST['search_options'][$item->getType()];
$searchopt = Search::getCleanedOptions($item->getType(), UPDATE);
$input = $ma->POST;
if (isset($searchopt[$index])) {
/// Infocoms case
if (!isPluginItemType($item->getType()) && Search::isInfocomOption($item->getType(), $index)) {
$ic = new Infocom();
$link_entity_type = -1;
/// Specific entity item
if ($searchopt[$index]["table"] == "glpi_suppliers") {
$ent = new Supplier();
if ($ent->getFromDB($input[$input["field"]])) {
$link_entity_type = $ent->fields["entities_id"];
}
}
foreach ($ids as $key) {
if ($item->getFromDB($key)) {
if ($link_entity_type < 0 || $link_entity_type == $item->getEntityID() || $ent->fields["is_recursive"] && in_array($link_entity_type, getAncestorsOf("glpi_entities", $item->getEntityID()))) {
$input2["items_id"] = $key;
$input2["itemtype"] = $item->getType();
if ($ic->can(-1, CREATE, $input2)) {
// Add infocom if not exists
if (!$ic->getFromDBforDevice($item->getType(), $key)) {
$input2["items_id"] = $key;
$input2["itemtype"] = $item->getType();
unset($ic->fields);
$ic->add($input2);
$ic->getFromDBforDevice($item->getType(), $key);
}
$id = $ic->fields["id"];
unset($ic->fields);
if ($ic->update(array('id' => $id, $input["field"] => $input[$input["field"]]))) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_COMPAT));
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_NOT_FOUND));
}
}
示例4: showForItem
/**
* Print an HTML array of contract associated to an object
*
* @since version 0.84
*
* @param $item CommonDBTM object wanted
* @param $withtemplate not used (to be deleted) (default '')
*
* @return Nothing (display)
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$itemtype = $item->getType();
$ID = $item->fields['id'];
if (!Contract::canView() || !$item->can($ID, READ)) {
return false;
}
$canedit = $item->can($ID, UPDATE);
$rand = mt_rand();
$query = "SELECT `glpi_contracts_items`.*\n FROM `glpi_contracts_items`,\n `glpi_contracts`\n LEFT JOIN `glpi_entities` ON (`glpi_contracts`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_contracts`.`id`=`glpi_contracts_items`.`contracts_id`\n AND `glpi_contracts_items`.`items_id` = '{$ID}'\n AND `glpi_contracts_items`.`itemtype` = '{$itemtype}'" . getEntitiesRestrictRequest(" AND", "glpi_contracts", '', '', true) . "\n ORDER BY `glpi_contracts`.`name`";
$result = $DB->query($query);
$contracts = array();
$used = array();
if ($number = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$contracts[$data['id']] = $data;
$used[$data['contracts_id']] = $data['contracts_id'];
}
}
if ($canedit && $withtemplate != 2) {
echo "<div class='firstbloc'>";
echo "<form name='contractitem_form{$rand}' id='contractitem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a contract') . "</th></tr>";
echo "<tr class='tab_bg_1'><td>";
Contract::dropdown(array('entity' => $item->getEntityID(), 'used' => $used));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($withtemplate != 2) {
if ($canedit && $number) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
}
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && $number && $withtemplate != 2) {
$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>";
$header_end .= "<th>" . __('Entity') . "</th>";
$header_end .= "<th>" . _x('phone', 'Number') . "</th>";
$header_end .= "<th>" . __('Contract type') . "</th>";
$header_end .= "<th>" . __('Supplier') . "</th>";
$header_end .= "<th>" . __('Start date') . "</th>";
$header_end .= "<th>" . __('Initial contract period') . "</th>";
$header_end .= "</tr>";
echo $header_begin . $header_top . $header_end;
if ($number > 0) {
Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach ($contracts as $data) {
$cID = $data["contracts_id"];
Session::addToNavigateListItems(__CLASS__, $cID);
$contracts[] = $cID;
$assocID = $data["id"];
$con = new Contract();
$con->getFromDB($cID);
echo "<tr class='tab_bg_1" . ($con->fields["is_deleted"] ? "_2" : "") . "'>";
if ($canedit && $withtemplate != 2) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
echo "</td>";
}
echo "<td class='center b'>";
$name = $con->fields["name"];
if ($_SESSION["glpiis_ids_visible"] || empty($con->fields["name"])) {
$name = sprintf(__('%1$s (%2$s)'), $name, $con->fields["id"]);
}
echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/contract.form.php?id={$cID}'>" . $name;
echo "</a></td>";
echo "<td class='center'>";
echo Dropdown::getDropdownName("glpi_entities", $con->fields["entities_id"]) . "</td>";
echo "<td class='center'>" . $con->fields["num"] . "</td>";
echo "<td class='center'>";
//.........这里部分代码省略.........
示例5: 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);
//.........这里部分代码省略.........
示例6: showForItem
/**
* Show Links for an item
*
* @param $item CommonDBTM object
* @param $withtemplate integer withtemplate param (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
if (!self::canView()) {
return false;
}
if ($item->isNewID($item->getID())) {
return false;
}
$restrict = $item->getEntityID();
if ($item->getType() == 'User') {
$restrict = Profile_User::getEntitiesForUser($item->getID());
}
$query = "SELECT `glpi_links`.`id`,\n `glpi_links`.`link` AS link,\n `glpi_links`.`name` AS name ,\n `glpi_links`.`data` AS data,\n `glpi_links`.`open_window` AS open_window\n FROM `glpi_links`\n INNER JOIN `glpi_links_itemtypes`\n ON `glpi_links`.`id` = `glpi_links_itemtypes`.`links_id`\n WHERE `glpi_links_itemtypes`.`itemtype`='" . $item->getType() . "' " . getEntitiesRestrictRequest(" AND", "glpi_links", "entities_id", $restrict, true) . "\n ORDER BY name";
$result = $DB->query($query);
echo "<div class='spaced'><table class='tab_cadre_fixe'>";
if ($DB->numrows($result) > 0) {
echo "<tr><th>" . self::getTypeName(Session::getPluralNumber()) . "</th></tr>";
while ($data = $DB->fetch_assoc($result)) {
$links = self::getAllLinksFor($item, $data);
foreach ($links as $link) {
echo "<tr class='tab_bg_2'>";
echo "<td class='center'>{$link}</td></tr>";
}
}
echo "</table></div>";
} else {
echo "<tr class='tab_bg_2'><th>" . self::getTypeName(Session::getPluralNumber()) . "</th></tr>";
echo "<tr class='tab_bg_2'><td class='center b'>" . __('No link defined') . "</td></tr>";
echo "</table></div>";
}
}
示例7: processMassiveActionsForOneItemtype
/**
* @since version 0.90
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'merge':
foreach ($ids as $key) {
if ($item->can($key, UPDATE)) {
if ($item->getEntityID() == $_SESSION['glpiactive_entity']) {
if ($item->update(array('id' => $key, 'is_recursive' => 1))) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$input2 = $item->fields;
// Change entity
$input2['entities_id'] = $_SESSION['glpiactive_entity'];
$input2['is_recursive'] = 1;
$input2 = Toolbox::addslashes_deep($input2);
if (!$item->import($input2)) {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
}
}
} else {
$ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例8: 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>";
//.........这里部分代码省略.........
示例9: showForItem
/**
* Show Infocom form for an item (not a standard showForm)
*
* @param $item CommonDBTM object
* @param $withtemplate integer: template or basic item
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $CFG_GLPI, $LANG;
// Show Infocom or blank form
if (!haveRight("infocom", "r")) {
return false;
}
if (!$item) {
echo "<div class='spaced'>" . $LANG['financial'][85] . "</div>";
} else {
$date_tax = $CFG_GLPI["date_tax"];
$dev_ID = $item->getField('id');
$ic = new self();
$option = "";
if ($withtemplate == 2) {
$option = " readonly ";
}
if (!strpos($_SERVER['PHP_SELF'], "infocoms-show") && in_array($item->getType(), array('CartridgeItem', 'ConsumableItem', 'Software'))) {
echo "<div class='firstbloc center'>" . $LANG['financial'][84] . "</div>";
}
if (!$ic->getFromDBforDevice($item->getType(), $dev_ID)) {
$input = array('itemtype' => $item->getType(), 'items_id' => $dev_ID, 'entities_id' => $item->getEntityID());
if ($ic->can(-1, "w", $input) && $withtemplate != 2) {
echo "<div class='spaced b'>";
echo "<table class='tab_cadre_fixe'><tr class='tab_bg_1'><th>";
echo $item->getTypeName() . " - " . $item->getName() . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='center'>";
echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/infocom.form.php?itemtype=" . $item->getType() . "&items_id={$dev_ID}&add=add'>" . $LANG['financial'][68];
echo "</a></td></tr></table></div>";
}
} else {
// getFromDBforDevice
$canedit = $ic->can($ic->fields['id'], "w") && $withtemplate != 2;
if ($canedit) {
echo "<form name='form_ic' method='post' action='" . $CFG_GLPI["root_doc"] . "/front/infocom.form.php'>";
}
echo "<div class='spaced'>";
echo "<table class='tab_cadre" . (!strpos($_SERVER['PHP_SELF'], "infocoms-show") ? "_fixe" : "") . "'>";
echo "<tr><th colspan='4'>" . $LANG['financial'][3] . "</th></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['financial'][26] . " :</td>";
echo "<td>";
if ($withtemplate == 2) {
echo Dropdown::getDropdownName("glpi_suppliers", $ic->fields["suppliers_id"]);
} else {
Dropdown::show('Supplier', array('value' => $ic->fields["suppliers_id"], 'entity' => $item->getEntityID()));
}
echo "</td>";
if (haveRight("budget", "r")) {
echo "<td>" . $LANG['financial'][87] . " :</td><td >";
Dropdown::show('Budget', array('value' => $ic->fields["budgets_id"], 'entity' => $item->getEntityID(), 'comments' => 1));
} else {
echo "<td colspan='2'>";
}
echo "</td></tr>";
// Can edit calendar ?
$editcalendar = $withtemplate != 2;
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['financial'][18] . " :</td>";
echo "<td >";
autocompletionTextField($ic, "order_number", array('option' => $option));
echo "</td>";
echo "<td>" . $LANG['financial'][28] . " :</td><td>";
showDateFormItem("order_date", $ic->fields["order_date"], true, $editcalendar);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['financial'][20] . "* :</td>";
echo "<td>";
$objectName = autoName($ic->fields["immo_number"], "immo_number", $withtemplate == 2, 'Infocom', $item->getEntityID());
autocompletionTextField($ic, "immo_number", array('value' => $objectName, 'option' => $option));
echo "</td>";
echo "<td>" . $LANG['financial'][14] . " :</td><td>";
showDateFormItem("buy_date", $ic->fields["buy_date"], true, $editcalendar);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['financial'][82] . " :</td>";
echo "<td>";
autocompletionTextField($ic, "bill", array('option' => $option));
echo "</td>";
echo "<td>" . $LANG['financial'][27] . " :</td><td>";
showDateFormItem("delivery_date", $ic->fields["delivery_date"], true, $editcalendar);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['financial'][19] . " :</td><td>";
autocompletionTextField($ic, "delivery_number", array('option' => $option));
echo "</td>";
echo "<td>" . $LANG['financial'][76] . " :</td><td>";
showDateFormItem("use_date", $ic->fields["use_date"], true, $editcalendar);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['financial'][21] . " :</td>";
echo "<td><input type='text' name='value' {$option} value='" . formatNumber($ic->fields["value"], true) . "' size='14'></td>";
echo "</td>";
echo "<td>" . $LANG['financial'][114] . " :</td><td>";
//.........这里部分代码省略.........
示例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
/**
* 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>";
}
示例12: 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>";
//.........这里部分代码省略.........
示例13: 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>";
//.........这里部分代码省略.........
示例14: showForItem
/**
* Show Links for an item
*
* @param $item CommonDBTM object
* @param $withtemplate integer withtemplate param (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
if (!Session::haveRight("link", "r")) {
return false;
}
if ($item->isNewID($item->getID())) {
return false;
}
$query = "SELECT `glpi_links`.`id`,\n `glpi_links`.`link` AS link,\n `glpi_links`.`name` AS name ,\n `glpi_links`.`data` AS data\n FROM `glpi_links`\n INNER JOIN `glpi_links_itemtypes`\n ON `glpi_links`.`id` = `glpi_links_itemtypes`.`links_id`\n WHERE `glpi_links_itemtypes`.`itemtype`='" . $item->getType() . "' " . getEntitiesRestrictRequest(" AND", "glpi_links", "entities_id", $item->getEntityID(), true) . "\n ORDER BY name";
$result = $DB->query($query);
echo "<div class='spaced'><table class='tab_cadre_fixe'>";
if ($DB->numrows($result) > 0) {
echo "<tr><th>" . self::getTypeName(2) . "</th></tr>";
while ($data = $DB->fetch_assoc($result)) {
$name = $data["name"];
if (empty($name)) {
$name = $data["link"];
}
$names = self::generateLinkContents($name, $item);
$file = trim($data["data"]);
if (empty($file)) {
// Generate links
$links = self::generateLinkContents($data['link'], $item);
$i = 1;
foreach ($links as $key => $link) {
$name = isset($names[$key]) ? $names[$key] : reset($names);
echo "<tr class='tab_bg_2'>";
$url = $link;
echo "<td class='center'><a href='{$url}' target='_blank'>";
$linkname = sprintf(__('%1$s #%2$s'), $name, $i);
$linkname = printf(__('%1$s: %2$s'), $linkname, $link);
echo "</a></td></tr>";
$i++;
}
} else {
// Generate files
$files = self::generateLinkContents($data['link'], $item);
$links = self::generateLinkContents($data['data'], $item);
$i = 1;
foreach ($links as $key => $link) {
$name = isset($names[$key]) ? $names[$key] : reset($names);
if (isset($files[$key])) {
// a different name for each file, ex name = foo-[IP].txt
$file = $files[$key];
} else {
// same name for all files, ex name = foo.txt
$file = reset($files);
}
echo "<tr class='tab_bg_2'>";
$url = $CFG_GLPI["root_doc"] . "/front/link.send.php?lID=" . $data['id'] . "&itemtype=" . $item->getType() . "&id=" . $item->getID() . "&rank={$key}";
echo "<td class='center'><a href='{$url}' target='_blank'>";
$linkname = sprintf(__('%1$s #%2$s'), $name, $i);
$linkname = printf(__('%1$s: %2$s'), $linkname, $file);
echo "</a></td></tr>";
$i++;
}
}
}
echo "</table></div>";
} else {
echo "<tr class='tab_bg_2'><th>" . self::getTypeName(2) . "</th></tr>";
echo "<tr class='tab_bg_2'><td class='center b'>" . __('No link defined') . "</td></tr>";
echo "</table></div>";
}
}
示例15: 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>";
}
//.........这里部分代码省略.........