本文整理汇总了PHP中CommonDBTM::isField方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonDBTM::isField方法的具体用法?PHP CommonDBTM::isField怎么用?PHP CommonDBTM::isField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonDBTM
的用法示例。
在下文中一共展示了CommonDBTM::isField方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateLinkContents
/**
* Generate link
*
* @param $link string original string content
* @param $item CommonDBTM object: item used to make replacements
*
* @return array of link contents (may have several when item have several IP / MAC cases)
**/
static function generateLinkContents($link, CommonDBTM $item)
{
global $DB;
if (strstr($link, "[ID]")) {
$link = str_replace("[ID]", $item->fields['id'], $link);
}
if (strstr($link, "[LOGIN]") && isset($_SESSION["glpiname"])) {
$link = str_replace("[LOGIN]", $_SESSION["glpiname"], $link);
}
if (strstr($link, "[NAME]")) {
$link = str_replace("[NAME]", $item->getName(), $link);
}
if (strstr($link, "[SERIAL]") && $item->isField('serial')) {
$link = str_replace("[SERIAL]", $item->getField('serial'), $link);
}
if (strstr($link, "[OTHERSERIAL]") && $item->isField('otherserial')) {
$link = str_replace("[OTHERSERIAL]", $item->getField('otherserial'), $link);
}
if (strstr($link, "[LOCATIONID]") && $item->isField('locations_id')) {
$link = str_replace("[LOCATIONID]", $item->getField('locations_id'), $link);
}
if (strstr($link, "[LOCATION]") && $item->isField('locations_id')) {
$link = str_replace("[LOCATION]", Dropdown::getDropdownName("glpi_locations", $item->getField('locations_id')), $link);
}
if (strstr($link, "[NETWORK]") && $item->isField('networks_id')) {
$link = str_replace("[NETWORK]", Dropdown::getDropdownName("glpi_networks", $item->getField('networks_id')), $link);
}
if (strstr($link, "[DOMAIN]") && $item->isField('domains_id')) {
$link = str_replace("[DOMAIN]", Dropdown::getDropdownName("glpi_domains", $item->getField('domains_id')), $link);
}
if (strstr($link, "[USER]") && $item->isField('users_id')) {
$link = str_replace("[USER]", Dropdown::getDropdownName("glpi_users", $item->getField('users_id')), $link);
}
if (strstr($link, "[GROUP]") && $item->isField('groups_id')) {
$link = str_replace("[GROUP]", Dropdown::getDropdownName("glpi_groups", $item->getField('groups_id')), $link);
}
if (strstr($link, "[REALNAME]") && $item->isField('realname')) {
$link = str_replace("[REALNAME]", $item->getField('realname'), $link);
}
if (strstr($link, "[FIRSTNAME]") && $item->isField('firstname')) {
$link = str_replace("[FIRSTNAME]", $item->getField('firstname'), $link);
}
$replace_IP = strstr($link, "[IP]");
$replace_MAC = strstr($link, "[MAC]");
if (!$replace_IP && !$replace_MAC) {
return array($link);
}
// Return several links id several IP / MAC
$ipmac = array();
if (get_class($item) == 'NetworkEquipment') {
if ($replace_IP) {
$query2 = "SELECT `glpi_ipaddresses`.`id`,\n `glpi_ipaddresses`.`name` AS ip\n FROM `glpi_networknames`, `glpi_ipaddresses`\n WHERE `glpi_networknames`.`items_id` = '" . $item->getID() . "'\n AND `glpi_networknames`.`itemtype` = 'NetworkEquipment'\n AND `glpi_ipaddresses`.`itemtype` = 'NetworkName'\n AND `glpi_ipaddresses`.`items_id` = `glpi_networknames`.`id`";
foreach ($DB->request($query2) as $data2) {
$ipmac['ip' . $data2['id']]['ip'] = $data2["ip"];
$ipmac['ip' . $data2['id']]['mac'] = $item->getField('mac');
}
}
if ($replace_MAC) {
// If there is no entry, then, we must at least define the mac of the item ...
if (count($ipmac) == 0) {
$ipmac['mac0']['ip'] = '';
$ipmac['mac0']['mac'] = $item->getField('mac');
}
}
}
if ($replace_IP) {
$query2 = "SELECT `glpi_ipaddresses`.`id`,\n `glpi_networkports`.`mac`,\n `glpi_ipaddresses`.`name` AS ip\n FROM `glpi_networkports`, `glpi_networknames`, `glpi_ipaddresses`\n WHERE `glpi_networkports`.`items_id` = '" . $item->getID() . "'\n AND `glpi_networkports`.`itemtype` = '" . $item->getType() . "'\n AND `glpi_networknames`.`itemtype` = 'NetworkPort'\n AND `glpi_networknames`.`items_id` = `glpi_networkports`.`id`\n AND `glpi_ipaddresses`.`itemtype` = 'NetworkName'\n AND `glpi_ipaddresses`.`items_id` = `glpi_networknames`.`id`";
foreach ($DB->request($query2) as $data2) {
$ipmac['ip' . $data2['id']]['ip'] = $data2["ip"];
$ipmac['ip' . $data2['id']]['mac'] = $data2["mac"];
}
}
if ($replace_MAC) {
$left = '';
$where = '';
if ($replace_IP) {
$left = " LEFT JOIN `glpi_networknames`\n ON (`glpi_networknames`.`items_id` = `glpi_networkports`.`id`\n AND `glpi_networknames`.`itemtype` = 'NetworkPort')";
$where = " AND `glpi_networknames`.`id` IS NULL";
}
$query2 = "SELECT `glpi_networkports`.`id`,\n `glpi_networkports`.`mac`\n FROM `glpi_networkports`\n {$left}\n WHERE `glpi_networkports`.`items_id` = '" . $item->getID() . "'\n AND `glpi_networkports`.`itemtype` = '" . $item->getType() . "'\n {$where}\n GROUP BY `glpi_networkports`.`mac`";
foreach ($DB->request($query2) as $data2) {
$ipmac['mac' . $data2['id']]['ip'] = '';
$ipmac['mac' . $data2['id']]['mac'] = $data2["mac"];
}
}
$links = array();
if (count($ipmac) > 0) {
foreach ($ipmac as $key => $val) {
$tmplink = $link;
$disp = 1;
if (strstr($link, "[IP]")) {
if (empty($val['ip'])) {
//.........这里部分代码省略.........
示例2: processMassiveActionsForOneItemtype
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $CFG_GLPI;
switch ($ma->getAction()) {
case 'Generate':
$pbQRcode = new PluginBarcodeQRcode();
$rand = mt_rand();
$number = 0;
$codes = array();
if ($ma->POST['eliminate'] > 0) {
for ($nb = 0; $nb < $ma->POST['eliminate']; $nb++) {
$codes[] = '';
}
}
if ($ma->POST['type'] == 'QRcode') {
foreach ($ids as $key) {
$filename = $pbQRcode->generateQRcode($item->getType(), $key, $rand, $number, $ma->POST);
if ($filename) {
$codes[] = $filename;
$number++;
}
}
} else {
foreach ($ids as $key) {
$item->getFromDB($key);
if ($item->isField('otherserial')) {
$codes[] = $item->getField('otherserial');
}
}
}
if (count($codes) > 0) {
$params['codes'] = $codes;
$params['type'] = $ma->POST['type'];
$params['size'] = $ma->POST['size'];
$params['border'] = $ma->POST['border'];
$params['orientation'] = $ma->POST['orientation'];
$barcode = new PluginBarcodeBarcode();
$file = $barcode->printPDF($params);
$filePath = explode('/', $file);
$filename = $filePath[count($filePath) - 1];
$msg = "<a href='" . $CFG_GLPI['root_doc'] . '/plugins/barcode/front/send.php?file=' . urlencode($filename) . "'>" . __('Generated file', 'barcode') . "</a>";
Session::addMessageAfterRedirect($msg);
$pbQRcode->cleanQRcodefiles($rand, $number);
}
$ma->itemDone($item->getType(), 0, MassiveAction::ACTION_OK);
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例3: showSimpleForChild
/**
* Show simple inventory information of an computer child item
*
* @param $item CommonDBTM object
*
* @return nothing
**/
static function showSimpleForChild(CommonDBTM $item)
{
if ($item->isDynamic() && $item->isField('computers_id') && countElementsInTable('glpi_plugin_ocsinventoryng_ocslinks', "`computers_id`='" . $item->getField('computers_id') . "'") > 0) {
_e('OCS Inventory NG');
}
}
示例4: getCommentsForReplacement
/**
* Build the comments associated with an item
*
* @param $item CommonDBTM object
* @param $new is the item a new item (true) or the old one (false) (true by default)
* @param $display_message (true by default)
*
* @return the comments generated
**/
static function getCommentsForReplacement(CommonDBTM $item, $new = true, $display_message = true)
{
if (!empty($item->fields['comment'])) {
$string = stripslashes($item->fields['comment']);
} else {
$string = "";
}
if ($display_message) {
if ($new) {
$string .= "\n" . __('This item is a replacement for item', 'uninstall') . " ";
} else {
$string .= "\n" . __('This item was replaced by', 'uninstall') . " ";
}
}
if ($item->isField('name')) {
$string .= "\n " . sprintf(__('%1$s: %2$s'), __('Name'), $item->getField('name'));
}
if ($item->isField('serial')) {
$string .= "\n " . sprintf(__('%1$s: %2$s'), __('Serial number'), $item->getField('serial'));
}
if ($item->isField('otherserial')) {
$string .= "\n " . sprintf(__('%1$s: %2$s'), __('Inventory number'), $item->getField('otherserial'));
}
return $string;
}
示例5: generateLinkContents
/**
* Generate link
*
* @param $link string : original string content
* @param $item CommonDBTM : item used to make replacements
* @param $name string : name used for multi link generation
* @param $noip boolean : true to not evaluate IP/MAC
*
* @return array of link contents (may have several when item have several IP / MAC cases)
*/
static function generateLinkContents($link, CommonDBTM $item, $name = '', $noip = false)
{
global $DB;
if (strstr($link, "[ID]")) {
$link = str_replace("[ID]", $item->fields['id'], $link);
}
if (strstr($link, "[LOGIN]") && isset($_SESSION["glpiname"])) {
if (isset($_SESSION["glpiname"])) {
$link = str_replace("[LOGIN]", $_SESSION["glpiname"], $link);
}
}
if (strstr($link, "[NAME]")) {
$link = str_replace("[NAME]", $item->getName(), $link);
}
if (strstr($link, "[SERIAL]")) {
if ($item->isField('serial')) {
$link = str_replace("[SERIAL]", $item->getField('serial'), $link);
}
}
if (strstr($link, "[OTHERSERIAL]")) {
if ($item->isField('otherserial')) {
$link = str_replace("[OTHERSERIAL]", $item->getField('otherserial'), $link);
}
}
if (strstr($link, "[LOCATIONID]")) {
if ($item->isField('locations_id')) {
$link = str_replace("[LOCATIONID]", $item->getField('locations_id'), $link);
}
}
if (strstr($link, "[LOCATION]")) {
if ($item->isField('locations_id')) {
$link = str_replace("[LOCATION]", Dropdown::getDropdownName("glpi_locations", $item->getField('locations_id')), $link);
}
}
if (strstr($link, "[NETWORK]")) {
if ($item->isField('networks_id')) {
$link = str_replace("[NETWORK]", Dropdown::getDropdownName("glpi_networks", $item->getField('networks_id')), $link);
}
}
if (strstr($link, "[DOMAIN]")) {
if ($item->isField('domains_id')) {
$link = str_replace("[DOMAIN]", Dropdown::getDropdownName("glpi_domains", $item->getField('domains_id')), $link);
}
}
if (strstr($link, "[USER]")) {
if ($item->isField('users_id')) {
$link = str_replace("[USER]", Dropdown::getDropdownName("glpi_users", $item->getField('users_id')), $link);
}
}
if (strstr($link, "[GROUP]")) {
if ($item->isField('groups_id')) {
$link = str_replace("[GROUP]", Dropdown::getDropdownName("glpi_groups", $item->getField('groups_id')), $link);
}
}
$ipmac = array();
$i = 0;
if ($noip || !strstr($link, "[IP]") && !strstr($link, "[MAC]")) {
return array($link);
} else {
// Return sevral links id several IP / MAC
$links = array();
$query2 = "SELECT `ip`, `mac`, `logical_number`\n FROM `glpi_networkports`\n WHERE `items_id` = '" . $item->fields['id'] . "'\n AND `itemtype` = '" . get_class($item) . "'\n ORDER BY `logical_number`";
$result2 = $DB->query($query2);
if ($DB->numrows($result2) > 0) {
while ($data2 = $DB->fetch_array($result2)) {
$ipmac[$i]['ip'] = $data2["ip"];
$ipmac[$i]['mac'] = $data2["mac"];
$ipmac[$i]['number'] = $data2["logical_number"];
$i++;
}
}
// Add IP/MAC internal switch
if (get_class($item) == 'NetworkEquipment') {
$tmplink = $link;
$tmplink = str_replace("[IP]", $item->getField('ip'), $tmplink);
$tmplink = str_replace("[MAC]", $item->getField('mac'), $tmplink);
$links["{$name} - {$tmplink}"] = $tmplink;
}
if (count($ipmac) > 0) {
foreach ($ipmac as $key => $val) {
$tmplink = $link;
$disp = 1;
if (strstr($link, "[IP]")) {
if (empty($val['ip'])) {
$disp = 0;
} else {
$tmplink = str_replace("[IP]", $val['ip'], $tmplink);
}
}
if (strstr($link, "[MAC]")) {
//.........这里部分代码省略.........