/** * @copyright XOOPS Project (http://xoops.org) * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) * @author trabis <*****@*****.**> * @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; }
function b_legacy_notification_show() { global $xoopsConfig, $xoopsUser, $xoopsModule; include_once XOOPS_ROOT_PATH . '/include/notification_functions.php'; $root =& XCube_Root::getSingleton(); $root->mLanguageManager->loadPageTypeMessageCatalog('notification'); // Notification must be enabled, and user must be logged in if (empty($xoopsUser) || !notificationEnabled('block')) { return false; // do not display block } $notification_handler =& xoops_gethandler('notification'); // 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'], $xoopsModule->getVar('mid'), $xoopsUser->getVar('uid')); foreach (notificationEvents($category['name'], true) as $event) { if (!empty($event['admin_only']) && !$xoopsUser->isAdmin($xoopsModule->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('/', xoops_getenv('PHP_SELF')); $script_name = $script_url[count($script_url) - 1]; $block['redirect_script'] = $script_name; $block['submit_button'] = _NOT_UPDATENOW; return $block; }
// GNU General Public License for more details. // // // // You should have received a copy of the GNU General Public License // // along with this program; if not, write to the Free Software // // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // if (!defined('XOOPS_ROOT_PATH')) { exit; } include_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; include_once XOOPS_ROOT_PATH . '/include/notification_functions.php'; $xoops_notification = array(); $xoops_notification['show'] = isset($xoopsModule) && is_object($xoopsUser) && notificationEnabled('inline') ? 1 : 0; if ($xoops_notification['show']) { include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/notification.php'; $categories =& notificationSubscribableCategoryInfo(); $event_count = 0; if (!empty($categories)) { $notification_handler =& xoops_gethandler('notification'); 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'], $xoopsModule->getVar('mid'), $xoopsUser->getVar('uid')); foreach (notificationEvents($category['name'], true) as $event) { if (!empty($event['admin_only']) && !$xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { continue; } if (!empty($event['invisible'])) {
/** * @return array|bool */ function b_system_notification_show() { global $xoopsConfig, $xoopsUser, $xoopsModule; include_once XOOPS_ROOT_PATH . '/include/notification_functions.php'; include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/notification.php'; // Notification must be enabled, and user must be logged in if (empty($xoopsUser) || !notificationEnabled('block')) { return false; // do not display block } $notification_handler = xoops_getHandler('notification'); // 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'], $xoopsModule->getVar('mid'), $xoopsUser->getVar('uid')); foreach (notificationEvents($category['name'], true) as $event) { if (!empty($event['admin_only']) && !$xoopsUser->isAdmin($xoopsModule->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'] = _NOT_UPDATENOW; $block['notification_token'] = $GLOBALS['xoopsSecurity']->createToken(); return $block; }
/** * This functions is add to 'Legacyfunction.Notifications.Select'. * * @param XCube_RenderBuffer $render */ function notifications_select(&$render) { require_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; require_once XOOPS_ROOT_PATH . '/include/notification_functions.php'; $root =& XCube_Root::getSingleton(); $xoopsModule =& $root->mContext->mXoopsModule; $moduleConfig =& $root->mContext->mModuleConfig; $xoopsUser =& $root->mContext->mXoopsUser; $xoops_notification = array(); $xoops_notification['show'] = is_object($xoopsModule) && is_object($xoopsUser) && notificationEnabled('inline') ? 1 : 0; if ($xoops_notification['show']) { $root->mLanguageManager->loadPageTypeMessageCatalog('notification'); $categories =& notificationSubscribableCategoryInfo(); $event_count = 0; if (!empty($categories)) { $notification_handler =& xoops_gethandler('notification'); 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'], $xoopsModule->get('mid'), $xoopsUser->get('uid')); foreach (notificationEvents($category['name'], true) as $event) { if (!empty($event['admin_only']) && !$xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { continue; } if (!empty($event['invisible'])) { 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); $event_count++; } $xoops_notification['categories'][$category['name']] = $section; } $xoops_notification['target_page'] = "notification_update.php"; $xoops_notification['redirect_script'] = xoops_getenv('PHP_SELF'); $render->setAttribute('editprofile_url', XOOPS_URL . '/edituser.php?uid=' . $xoopsUser->getShow('uid')); switch ($xoopsUser->getVar('notify_method')) { case XOOPS_NOTIFICATION_METHOD_DISABLE: $render->setAttribute('user_method', _NOT_DISABLE); break; case XOOPS_NOTIFICATION_METHOD_PM: $render->setAttribute('user_method', _NOT_PM); break; case XOOPS_NOTIFICATION_METHOD_EMAIL: $render->setAttribute('user_method', _NOT_EMAIL); break; } } else { $xoops_notification['show'] = 0; } if ($event_count == 0) { $xoops_notification['show'] = 0; } } $render->setAttribute('xoops_notification', $xoops_notification); }