本文整理汇总了PHP中Notifications::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Notifications::getInstance方法的具体用法?PHP Notifications::getInstance怎么用?PHP Notifications::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notifications
的用法示例。
在下文中一共展示了Notifications::getInstance方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: userMenus
public function userMenus()
{
$helper = Notifications::getInstance();
$ret['name'] = $helper->getModule()->getVar('name');
$ret['link'] = 'index.php';
$ret['image'] = $helper->url('icons/logo_small.png');
return $ret;
}
示例2: xoops_module_pre_uninstall_notifications
function xoops_module_pre_uninstall_notifications(&$module)
{
$xoops = Xoops::getInstance();
XoopsLoad::loadFile($xoops->path('modules/notifications/class/helper.php'));
$helper = Notifications::getInstance();
$plugins = \Xoops\Module\Plugin::getPlugins('notifications');
foreach (array_keys($plugins) as $dirname) {
$helper->deleteModuleRelations($xoops->getModuleByDirname($dirname));
}
return true;
}
示例3: b_notification_show
/**
* @copyright XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @author trabis <lusopoemas@gmail.com>
* @version $Id$
*/
function b_notification_show()
{
$xoops = Xoops::getInstance();
$helper = Notifications::getInstance();
include_once $helper->path('include/notification_functions.php');
$helper->loadLanguage('main');
// Notification must be enabled, and user must be logged in
if (!$xoops->isUser() || !notificationEnabled('block')) {
return false;
// do not display block
}
$notification_handler = $helper->getHandlerNotification();
// Now build the a nested associative array of info to pass
// to the block template.
$block = array();
$categories = notificationSubscribableCategoryInfo();
if (empty($categories)) {
return false;
}
foreach ($categories as $category) {
$section['name'] = $category['name'];
$section['title'] = $category['title'];
$section['description'] = $category['description'];
$section['itemid'] = $category['item_id'];
$section['events'] = array();
$subscribed_events = $notification_handler->getSubscribedEvents($category['name'], $category['item_id'], $xoops->module->getVar('mid'), $xoops->user->getVar('uid'));
foreach (notificationEvents($category['name'], true) as $event) {
if (!empty($event['admin_only']) && !$xoops->user->isAdmin($xoops->module->getVar('mid'))) {
continue;
}
$subscribed = in_array($event['name'], $subscribed_events) ? 1 : 0;
$section['events'][$event['name']] = array('name' => $event['name'], 'title' => $event['title'], 'caption' => $event['caption'], 'description' => $event['description'], 'subscribed' => $subscribed);
}
$block['categories'][$category['name']] = $section;
}
// Additional form data
$block['target_page'] = "notification_update.php";
// FIXME: better or more standardized way to do this?
$script_url = explode('/', $_SERVER['PHP_SELF']);
$script_name = $script_url[count($script_url) - 1];
$block['redirect_script'] = $script_name;
$block['submit_button'] = _MD_NOTIFICATIONS_UPDATENOW;
$block['notification_token'] = $xoops->security()->createToken();
return $block;
}
示例4: foreach
$error = '';
foreach ($_REQUEST['memberslist_id'] as $del) {
$del = (int) $del;
$user = $member_handler->getUser($del);
$groups = $user->getGroups();
if (in_array(FixedGroups::ADMIN, $groups)) {
$error .= sprintf(SystemLocale::EF_CAN_NOT_DELETE_ADMIN_USER, $user->getVar("uname"));
$error .= '<br />';
} elseif (!$member_handler->deleteUser($user)) {
$error .= sprintf(SystemLocale::EF_COULD_NOT_DELETE_USER, $user->getVar("uname"));
$error .= '<br />';
} else {
$xoops->getHandlerOnline()->destroy($del);
// RMV-NOTIFY
if ($xoops->isActiveModule('notifications')) {
Notifications::getInstance()->getHandlerNotification()->unsubscribeByUser($del);
}
}
}
if ($error != '') {
$xoops->redirect("admin.php?fct=users", 3, sprintf(XoopsLocale::F_ERROR, $error));
} else {
$xoops->redirect("admin.php?fct=users", 1, XoopsLocale::S_DATABASE_UPDATED);
}
}
break;
// Save user
// Save user
case "users_save":
if (isset($_REQUEST['uid'])) {
//Update user
示例5: displayPost
public function displayPost()
{
$xoops = Xoops::getInstance();
if (Request::getMethod() !== 'POST') {
$xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
}
$id = Request::getInt('com_id');
$modid = Request::getInt('com_modid');
if (empty($modid)) {
$xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
}
/* @var $comment CommentsComment */
$comment = $this->getHandlerComment()->get($id);
if (!is_object($comment)) {
$xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
}
if (!$comment->isNew()) {
$modid = $comment->getVar('modid');
} else {
$comment->setVar('modid', $modid);
}
$module = $xoops->getModuleById($modid);
if (!is_object($module)) {
$xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
}
$moddir = $module->getVar('dirname');
if ($xoops->isAdminSide) {
if (empty($id)) {
$xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
}
$redirect_page = $this->url('admin/main.php?com_modid=' . $modid . '&com_itemid');
} else {
if (COMMENTS_APPROVENONE == $xoops->getModuleConfig('com_rule', $module->getVar('dirname'))) {
$xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION);
}
$redirect_page = '';
}
/* @var $plugin CommentsPluginInterface */
if ($plugin = \Xoops\Module\Plugin::getPlugin($moddir, 'comments')) {
if (!$xoops->isAdminSide) {
$redirect_page = $xoops->url('modules/' . $moddir . '/' . $plugin->pageName() . '?');
if (is_array($extraParams = $plugin->extraParams())) {
$extra_params = '';
foreach ($extraParams as $extra_param) {
$extra_params .= isset($_POST[$extra_param]) ? $extra_param . '=' . htmlspecialchars($_POST[$extra_param]) . '&' : $extra_param . '=amp;';
}
$redirect_page .= $extra_params;
}
$redirect_page .= $plugin->itemName();
}
$comment_url = $redirect_page;
$op = Request::getBool('com_dopost') ? 'post' : '';
$op = Request::getBool('com_dopreview') ? 'preview' : $op;
$op = Request::getBool('com_dodelete') ? 'delete' : $op;
if ($op === 'preview' || $op === 'post') {
if (!$xoops->security()->check()) {
$op = '';
}
}
if ($op === 'post' && !$xoops->isUser()) {
$xoopsCaptcha = XoopsCaptcha::getInstance();
if (!$xoopsCaptcha->verify()) {
$captcha_message = $xoopsCaptcha->getMessage();
$op = 'preview';
}
}
$title = XoopsLocale::trim(Request::getString('com_title'));
$text = XoopsLocale::trim(Request::getString('com_text'));
$mode = XoopsLocale::trim(Request::getString('com_mode', 'flat'));
$order = XoopsLocale::trim(Request::getString('com_order', COMMENTS_OLD1ST));
$itemid = Request::getInt('com_itemid');
$pid = Request::getInt('com_pid');
$rootid = Request::getInt('com_rootid');
$status = Request::getInt('com_status');
$dosmiley = Request::getBool('com_dosmiley');
$doxcode = Request::getBool('com_doxcode');
$dobr = Request::getBool('com_dobr');
$dohtml = Request::getBool('com_html');
$doimage = Request::getBool('com_doimage');
$icon = XoopsLocale::trim(Request::getString('com_icon'));
$comment->setVar('title', $title);
$comment->setVar('text', $text);
$comment->setVar('itemid', $itemid);
$comment->setVar('pid', $pid);
$comment->setVar('rootid', $rootid);
$comment->setVar('status', $status);
$comment->setVar('dosmiley', $dosmiley);
$comment->setVar('doxcode', $doxcode);
$comment->setVar('dobr', $dobr);
$comment->setVar('dohtml', $dohtml);
$comment->setVar('doimage', $doimage);
$comment->setVar('icon', $icon);
switch ($op) {
case "delete":
$this->displayDelete();
break;
case "preview":
$comment->setVar('doimage', 1);
if ($comment->getVar('dohtml') != 0) {
if ($xoops->isUser()) {
//.........这里部分代码省略.........
示例6: getEvents
/**
* Get an array of info for all events (each event has associative array)
* in the selected category of the selected module.
*
* @param string $category_name Category name
* @param bool $enabled_only If true, return only enabled events
* @param string $dirname Dirname of the module (default current module)
*
* @return mixed
*/
public function getEvents($category_name, $enabled_only, $dirname = null)
{
$xoops = Xoops::getInstance();
$helper = Notifications::getInstance();
if (!isset($dirname)) {
$dirname = $xoops->isModule() ? $xoops->module->getVar('dirname') : '';
}
/* @var $plugin NotificationsPluginInterface */
if ($plugin = \Xoops\Module\Plugin::getPlugin($dirname, 'notifications')) {
$events = $plugin->events();
$category = $this->getCategory($category_name, $dirname);
$event_array = array();
$override_comment = false;
$override_commentsubmit = false;
$override_bookmark = false;
foreach ($events as $event) {
if ($event['category'] == $category_name) {
if (!is_dir($dir = \XoopsBaseConfig::get('root-path') . '/modules/' . $dirname . '/locale/' . $xoops->getConfig('locale') . '/templates/')) {
$dir = \XoopsBaseConfig::get('root-path') . '/modules/' . $dirname . '/locale/en_US/templates/';
}
$event['mail_template_dir'] = $dir;
if (!$enabled_only || $this->eventEnabled($category, $event, $dirname)) {
$event_array[] = $event;
}
if ($event['name'] === 'comment') {
$override_comment = true;
}
if ($event['name'] === 'comment_submit') {
$override_commentsubmit = true;
}
if ($event['name'] === 'bookmark') {
$override_bookmark = true;
}
}
}
$helper->loadLanguage('main');
// Insert comment info if applicable
/* @var $commentsPlugin CommentsPluginInterface */
if ($xoops->isActiveModule('comments') && ($commentsPlugin = \Xoops\Module\Plugin::getPlugin($dirname, 'comments'))) {
//todo replace this
if (!empty($category['item_name']) && $category['item_name'] == $commentsPlugin->itemName()) {
if (!is_dir($dir = \XoopsBaseConfig::get('root-path') . '/locale/' . $xoops->getConfig('locale') . '/templates/')) {
$dir = \XoopsBaseConfig::get('root-path') . '/locale/en_US/templates/';
}
$mail_template_dir = $dir;
$com_config = $xoops->getModuleConfigs($dirname);
if (!$enabled_only) {
$insert_comment = true;
$insert_submit = true;
} else {
$insert_comment = false;
$insert_submit = false;
switch ($com_config['com_rule']) {
case COMMENTS_APPROVENONE:
// comments disabled, no comment events
break;
case COMMENTS_APPROVEALL:
// all comments are automatically approved, no 'submit'
if (!$override_comment) {
$insert_comment = true;
}
break;
case COMMENTS_APPROVEUSER:
case COMMENTS_APPROVEADMIN:
// comments first submitted, require later approval
if (!$override_comment) {
$insert_comment = true;
}
if (!$override_commentsubmit) {
$insert_submit = true;
}
break;
}
}
if ($insert_comment) {
$event = array('name' => 'comment', 'category' => $category['name'], 'title' => _MD_NOTIFICATIONS_COMMENT_NOTIFY, 'caption' => _MD_NOTIFICATIONS_COMMENT_NOTIFYCAP, 'description' => _MD_NOTIFICATIONS_COMMENT_NOTIFYDSC, 'mail_template_dir' => $mail_template_dir, 'mail_template' => 'comment_notify', 'mail_subject' => _MD_NOTIFICATIONS_COMMENT_NOTIFYSBJ);
if (!$enabled_only || $this->eventEnabled($category, $event, $dirname)) {
$event_array[] = $event;
}
}
if ($insert_submit) {
$event = array('name' => 'comment_submit', 'category' => $category['name'], 'title' => _MD_NOTIFICATIONS_COMMENTSUBMIT_NOTIFY, 'caption' => _MD_NOTIFICATIONS_COMMENTSUBMIT_NOTIFYCAP, 'description' => _MD_NOTIFICATIONS_COMMENTSUBMIT_NOTIFYDSC, 'mail_template_dir' => $mail_template_dir, 'mail_template' => 'commentsubmit_notify', 'mail_subject' => _MD_NOTIFICATIONS_COMMENTSUBMIT_NOTIFYSBJ, 'admin_only' => 1);
if (!$enabled_only || $this->eventEnabled($category, $event, $dirname)) {
$event_array[] = $event;
}
}
}
}
// Insert bookmark info if appropriate
if (!empty($category['allow_bookmark'])) {
//.........这里部分代码省略.........
示例7: eventCoreIncludeCheckloginSuccess
/**
* core.include.checklogin.success
*
* @return void
*/
public static function eventCoreIncludeCheckloginSuccess()
{
// This was in include checklogin.php, moving here for now
// RMV-NOTIFY
// Perform some maintenance of notification records
$xoops = Xoops::getInstance();
if ($xoops->user instanceof XoopsUser) {
Notifications::getInstance()->getHandlerNotification()->doLoginMaintenance($xoops->user->getVar('uid'));
}
}
示例8: array
$error_message .= PageLocale::E_WEIGHT . '<br />';
$obj->setVar('content_weight', 0);
} else {
$obj->setVar('content_weight', Request::getInt('content_weight', 0));
}
if ($error == true) {
$xoops->tpl()->assign('error_message', $error_message);
} else {
if ($newcontent_id = $content_Handler->insert($obj)) {
// update permissions
$perm_id = $content_id > 0 ? $content_id : $newcontent_id;
$groups_view_item = Request::getArray('groups_view_item', array());
$gperm_Handler->updatePerms($perm_id, $groups_view_item);
//notifications
if ($content_id == 0 && $xoops->isActiveModule('notifications')) {
$notification_handler = Notifications::getInstance()->getHandlerNotification();
$tags = array();
$tags['MODULE_NAME'] = 'page';
$tags['ITEM_NAME'] = Request::getString('content_title', '');
$tags['ITEM_URL'] = \XoopsBaseConfig::get('url') . '/modules/page/viewpage.php?id=' . $newcontent_id;
$notification_handler->triggerEvent('global', 0, 'newcontent', $tags);
$notification_handler->triggerEvent('item', $newcontent_id, 'newcontent', $tags);
}
$xoops->redirect('content.php', 2, XoopsLocale::S_DATABASE_UPDATED);
}
echo $xoops->alert('error', $obj->getHtmlErrors());
}
$form = $helper->getForm($obj, 'page_content');
$xoops->tpl()->assign('form', $form->render());
break;
case 'delete':
示例9: triggerEvent
/**
* triggerEvent
*
* @param int $category notification category
* @param int $item_id ID of the item
* @param int $event notification event
* @param array $extra_tags array of substitutions for template
* @param array $user_list users to notify
* @param int $module_id module
* @param int $omit_user_id users to not notify
*
* @return bool
*/
public function triggerEvent($category, $item_id, $event, $extra_tags = array(), $user_list = array(), $module_id = null, $omit_user_id = null)
{
$xoops = xoops::getInstance();
$helper = Notifications::getInstance();
if (!isset($module_id)) {
$module = $xoops->module;
$module_id = $xoops->isModule() ? $xoops->module->getVar('mid') : 0;
} else {
$module = $xoops->getHandlerModule()->get($module_id);
}
// Check if event is enabled
$mod_config = $xoops->getHandlerConfig()->getConfigsByModule($module->getVar('mid'));
if (empty($mod_config['notifications_enabled'])) {
return false;
}
$category_info = $helper->getCategory($category, $module->getVar('dirname'));
$event_info = $helper->getEvent($category, $event, $module->getVar('dirname'));
if (!in_array($helper->generateConfig($category_info, $event_info, 'option_name'), $mod_config['notification_events']) && empty($event_info['invisible'])) {
return false;
}
if (!isset($omit_user_id)) {
if ($xoops->isUser()) {
$omit_user_id = $xoops->user->getVar('uid');
} else {
$omit_user_id = 0;
}
}
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('modid', (int) $module_id));
$criteria->add(new Criteria('category', $category));
$criteria->add(new Criteria('itemid', (int) $item_id));
$criteria->add(new Criteria('event', $event));
$mode_criteria = new CriteriaCompo();
$mode_criteria->add(new Criteria('mode', NOTIFICATIONS_MODE_SENDALWAYS), 'OR');
$mode_criteria->add(new Criteria('mode', NOTIFICATIONS_MODE_SENDONCETHENDELETE), 'OR');
$mode_criteria->add(new Criteria('mode', NOTIFICATIONS_MODE_SENDONCETHENWAIT), 'OR');
$criteria->add($mode_criteria);
if (!empty($user_list)) {
$user_criteria = new CriteriaCompo();
foreach ($user_list as $user) {
$user_criteria->add(new Criteria('uid', (int) $user), 'OR');
}
$criteria->add($user_criteria);
}
$notifications = $this->getObjectsArray($criteria);
if (empty($notifications)) {
return false;
}
$item_info = $helper->getEvent($category, $item_id, $module->getVar('dirname'));
// Add some tag substitutions here
$tags = $helper->getTags($category, $item_id, $event, $module->getVar('dirname'));
$tags['X_ITEM_NAME'] = !empty($item_info['name']) ? $item_info['name'] : '[' . _MD_NOTIFICATIONS_ITEMNAMENOTAVAILABLE . ']';
$tags['X_ITEM_URL'] = !empty($item_info['url']) ? $item_info['url'] : '[' . _MD_NOTIFICATIONS_ITEMURLNOTAVAILABLE . ']';
$tags['X_ITEM_TYPE'] = !empty($category_info['item_name']) ? $category_info['title'] : '[' . _MD_NOTIFICATIONS_ITEMTYPENOTAVAILABLE . ']';
$tags['X_MODULE'] = $module->getVar('name');
$tags['X_MODULE_URL'] = \XoopsBaseConfig::get('url') . '/modules/' . $module->getVar('dirname') . '/';
$tags['X_NOTIFY_CATEGORY'] = $category;
$tags['X_NOTIFY_EVENT'] = $event;
$template_dir = $event_info['mail_template_dir'];
$template = $event_info['mail_template'] . '.tpl';
$subject = $event_info['mail_subject'];
foreach ($notifications as $notification) {
/* @var $notification NotificationsNotification */
if (empty($omit_user_id) || $notification->getVar('uid') != $omit_user_id) {
// user-specific tags
//$tags['X_UNSUBSCRIBE_URL'] = 'TODO';
// TODO: don't show unsubscribe link if it is 'one-time' ??
$tags['X_UNSUBSCRIBE_URL'] = $helper->url('index.php');
$tags = array_merge($tags, $extra_tags);
$notification->notifyUser($template_dir, $template, $subject, $tags);
}
}
return true;
}
示例10: sendNotifications
/**
* Send notifications
*/
public function sendNotifications()
{
$xoops = Xoops::getInstance();
if ($xoops->isActiveModule('notifications')) {
$tags = array();
$tags['MODULE_NAME'] = $this->publisher->getModule()->getVar('name');
$tags['CATEGORY_NAME'] = $this->getVar('name');
$tags['CATEGORY_URL'] = $this->getCategoryUrl();
$notification_handler = Notifications::getInstance()->getHandlerNotification();
$notification_handler->triggerEvent('global', 0, 'category_created', $tags);
}
}
示例11: sendNotifications
/**
* @param array $notifications
*/
public function sendNotifications($notifications = array())
{
$xoops = Xoops::getInstance();
if ($xoops->isActiveModule('notifications')) {
$notification_handler = Notifications::getInstance()->getHandlerNotification();
$tags = array();
$tags['MODULE_NAME'] = $this->publisher->getModule()->getVar('name');
$tags['ITEM_NAME'] = $this->title();
$tags['CATEGORY_NAME'] = $this->getCategoryName();
$tags['CATEGORY_URL'] = PUBLISHER_URL . '/category.php?categoryid=' . $this->getVar('categoryid');
$tags['ITEM_BODY'] = $this->body();
$tags['DATESUB'] = $this->datesub();
foreach ($notifications as $notification) {
switch ($notification) {
case _PUBLISHER_NOT_ITEM_PUBLISHED:
$tags['ITEM_URL'] = PUBLISHER_URL . '/item.php?itemid=' . $this->getVar('itemid');
$notification_handler->triggerEvent('global', 0, 'published', $tags, array(), $this->publisher->getModule()->getVar('mid'));
$notification_handler->triggerEvent('category', $this->getVar('categoryid'), 'published', $tags, array(), $this->publisher->getModule()->getVar('mid'));
$notification_handler->triggerEvent('item', $this->getVar('itemid'), 'approved', $tags, array(), $this->publisher->getModule()->getVar('mid'));
break;
case _PUBLISHER_NOT_ITEM_SUBMITTED:
$tags['WAITINGFILES_URL'] = PUBLISHER_URL . '/admin/item.php?itemid=' . $this->getVar('itemid');
$notification_handler->triggerEvent('global', 0, 'submitted', $tags, array(), $this->publisher->getModule()->getVar('mid'));
$notification_handler->triggerEvent('category', $this->getVar('categoryid'), 'submitted', $tags, array(), $this->publisher->getModule()->getVar('mid'));
break;
case _PUBLISHER_NOT_ITEM_REJECTED:
$notification_handler->triggerEvent('item', $this->getVar('itemid'), 'rejected', $tags, array(), $this->publisher->getModule()->getVar('mid'));
break;
case -1:
default:
break;
}
}
}
}
示例12: dirname
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* XOOPS notification
*
* @copyright XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package core
* @since 2.0.0
* @version $Id$
*/
include dirname(dirname(__DIR__)) . '/mainfile.php';
$xoops = Xoops::getInstance();
$helper = Notifications::getInstance();
if (!$xoops->isUser()) {
$xoops->redirect('index.php', 3, _MD_NOTIFICATIONS_NOACCESS);
}
$uid = $xoops->user->getVar('uid');
$op = 'list';
if (isset($_POST['op'])) {
$op = trim($_POST['op']);
} else {
if (isset($_GET['op'])) {
$op = trim($_GET['op']);
}
}
if (isset($_POST['delete'])) {
$op = 'delete';
} else {