本文整理汇总了PHP中Notification::getField方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::getField方法的具体用法?PHP Notification::getField怎么用?PHP Notification::getField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notification
的用法示例。
在下文中一共展示了Notification::getField方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showNotificationTargets
/**
* Display notification targets
*
* @param $notification the Notification object
**/
function showNotificationTargets(Notification $notification)
{
global $LANG, $DB;
if ($notification->getField('itemtype') != '') {
$notifications_id = $notification->fields['id'];
$this->getNotificationTargets($_SESSION['glpiactive_entity']);
$canedit = $notification->can($notifications_id, 'w');
$options = "";
// Get User mailing
$query = "SELECT `glpi_notificationtargets`.`items_id`,\n `glpi_notificationtargets`.`id`\n FROM `glpi_notificationtargets`\n WHERE `glpi_notificationtargets`.`notifications_id` = '{$notifications_id}'\n AND `glpi_notificationtargets`.`type` = '" . Notification::USER_TYPE . "'\n ORDER BY `glpi_notificationtargets`.`items_id`";
foreach ($DB->request($query) as $data) {
if (isset($this->notification_targets[Notification::USER_TYPE . "_" . $data["items_id"]])) {
unset($this->notification_targets[Notification::USER_TYPE . "_" . $data["items_id"]]);
}
if (isset($this->notification_targets_labels[Notification::USER_TYPE][$data["items_id"]])) {
$name = $this->notification_targets_labels[Notification::USER_TYPE][$data["items_id"]];
} else {
$name = " ";
}
$options .= "<option value='" . $data["id"] . "'>" . $name . "</option>";
}
// Get Profile mailing
$query = "SELECT `glpi_notificationtargets`.`items_id`,\n `glpi_notificationtargets`.`id`,\n `glpi_profiles`.`name` AS `prof`\n FROM `glpi_notificationtargets`\n LEFT JOIN `glpi_profiles`\n ON (`glpi_notificationtargets`.`items_id` = `glpi_profiles`.`id`)\n WHERE `glpi_notificationtargets`.`notifications_id` = '{$notifications_id}'\n AND `glpi_notificationtargets`.`type` = '" . Notification::PROFILE_TYPE . "'\n ORDER BY `prof`";
foreach ($DB->request($query) as $data) {
$options .= "<option value='" . $data["id"] . "'>" . $LANG['profiles'][22] . " " . $data["prof"] . "</option>";
if (isset($this->notification_targets[Notification::PROFILE_TYPE . "_" . $data["items_id"]])) {
unset($this->notification_targets[Notification::PROFILE_TYPE . "_" . $data["items_id"]]);
}
}
// Get Group mailing
$query = "SELECT `glpi_notificationtargets`.`items_id`,\n `glpi_notificationtargets`.`id`,\n `glpi_groups`.`name` AS `name`\n FROM `glpi_notificationtargets`\n LEFT JOIN `glpi_groups`\n ON (`glpi_notificationtargets`.`items_id` = `glpi_groups`.`id`)\n WHERE `glpi_notificationtargets`.`notifications_id`='{$notifications_id}'\n AND `glpi_notificationtargets`.`type` = '" . Notification::GROUP_TYPE . "'\n ORDER BY `name`;";
foreach ($DB->request($query) as $data) {
$options .= "<option value='" . $data["id"] . "'>" . $LANG['common'][35] . " " . $data["name"] . "</option>";
if (isset($this->notification_targets[Notification::GROUP_TYPE . "_" . $data["items_id"]])) {
unset($this->notification_targets[Notification::GROUP_TYPE . "_" . $data["items_id"]]);
}
}
// Get Group mailing
$query = "SELECT `glpi_notificationtargets`.`items_id`,\n `glpi_notificationtargets`.`id`,\n `glpi_groups`.`name` AS `name`\n FROM `glpi_notificationtargets`\n LEFT JOIN `glpi_groups`\n ON (`glpi_notificationtargets`.`items_id` = `glpi_groups`.`id`)\n WHERE `glpi_notificationtargets`.`notifications_id`='{$notifications_id}'\n AND `glpi_notificationtargets`.`type`\n = '" . Notification::SUPERVISOR_GROUP_TYPE . "'\n ORDER BY `name`;";
foreach ($DB->request($query) as $data) {
$options .= "<option value='" . $data["id"] . "'>" . $LANG['common'][64] . ' ' . $LANG['common'][35] . " " . $data["name"] . "</option>";
if (isset($this->notification_targets[Notification::SUPERVISOR_GROUP_TYPE . "_" . $data["items_id"]])) {
unset($this->notification_targets[Notification::SUPERVISOR_GROUP_TYPE . "_" . $data["items_id"]]);
}
}
if ($canedit) {
echo "<td class='right'>";
if (count($this->notification_targets)) {
echo "<select name='mailing_to_add[]' multiple size='5'>";
foreach ($this->notification_targets as $key => $val) {
list($type, $items_id) = explode("_", $key);
echo "<option value='{$key}'>" . $this->notification_targets_labels[$type][$items_id] . "</option>";
}
echo "</select>";
}
echo "</td><td class='center'>";
if (count($this->notification_targets)) {
echo "<input type='submit' class='submit' name='mailing_add' value='" . $LANG['buttons'][8] . " >>'>";
}
echo "<br><br>";
if (!empty($options)) {
echo "<input type='submit' class='submit' name='mailing_delete' value='<< " . $LANG['buttons'][6] . "'>";
}
echo "</td><td>";
} else {
echo "<td class='center'>";
}
if (!empty($options)) {
echo "<select name='mailing_to_delete[]' multiple size='5'>";
echo $options . "</select>";
} else {
echo " ";
}
echo "</td>";
}
}
示例2: showForGroup
/**
* Display notification registered for a group
*
* @since version 0.83
*
* @param $group Group object
*
* @return nothing
**/
static function showForGroup(Group $group)
{
global $DB;
if (!Notification::canView()) {
return false;
}
$sql = "SELECT `glpi_notifications`.`id`\n FROM `glpi_notificationtargets`\n INNER JOIN `glpi_notifications`\n ON (`glpi_notifications`.`id` = `glpi_notificationtargets`.`notifications_id`)\n WHERE `items_id` = '" . $group->getID() . "'\n AND (`type` = '" . Notification::SUPERVISOR_GROUP_TYPE . "'\n OR `type` = '" . Notification::GROUP_TYPE . "') " . getEntitiesRestrictRequest('AND', 'glpi_notifications', '', '', true);
$req = $DB->request($sql);
echo "<table class='tab_cadre_fixe'>";
if ($req->numrows()) {
echo "<tr><th>" . __('Name') . "</th>";
echo "<th>" . Entity::getTypeName(1) . "</th>";
echo "<th>" . __('Active') . "</th>";
echo "<th>" . __('Type') . "</th>";
echo "<th>" . __('Notification method') . "</th>";
echo "<th>" . NotificationEvent::getTypeName(1) . "</th>";
echo "<th>" . NotificationTemplate::getTypeName(1) . "</th></tr>";
$notif = new Notification();
Session::initNavigateListItems('Notification', sprintf(__('%1$s = %2$s'), Group::getTypeName(1), $group->getName()));
foreach ($req as $data) {
Session::addToNavigateListItems('Notification', $data['id']);
if ($notif->getFromDB($data['id'])) {
echo "<tr class='tab_bg_2'><td>" . $notif->getLink();
echo "</td><td>" . Dropdown::getDropdownName('glpi_entities', $notif->getEntityID());
echo "</td><td>" . Dropdown::getYesNo($notif->getField('is_active')) . "</td><td>";
$itemtype = $notif->getField('itemtype');
if ($tmp = getItemForItemtype($itemtype)) {
echo $tmp->getTypeName(1);
} else {
echo " ";
}
echo "</td><td>" . Notification::getMode($notif->getField('mode'));
echo "</td><td>" . NotificationEvent::getEventName($itemtype, $notif->getField('event'));
echo "</td>" . "<td>" . Dropdown::getDropdownName('glpi_notificationtemplates', $notif->getField('notificationtemplates_id'));
echo "</td></tr>";
}
}
} else {
echo "<tr class='tab_bg_2'><td class='b center'>" . __('No item found') . "</td></tr>";
}
echo "</table>";
}
示例3: Notification
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file:
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
header("Content-Type: text/html; charset=UTF-8");
header_nocache();
$notification = new Notification();
if (isset($_POST['id']) && $_POST['id'] > 0 && $notification->can($_POST['id'], 'r')) {
if (!isset($_REQUEST['glpi_tab'])) {
exit;
}
$target = NotificationTarget::getInstanceByType($notification->getField('itemtype'), $notification->getField('event'), array('entities_id' => $notification->getField('entities_id')));
switch ($_REQUEST['glpi_tab']) {
case -1:
if ($target) {
$target->showForNotification($notification);
}
Plugin::displayAction($notification, $_REQUEST['glpi_tab']);
break;
case 1:
if ($target) {
$target->showForNotification($notification);
}
break;
case 12:
$notification->getFromDB($_POST["id"]);
Log::showForItem($notification);