예제 #1
0
/**
 * Shows The latest notifications
 *
 * @param array $options The block options
 * @return array $block the block array
 */
function b_system_notification_show() {
	global $icmsConfig, $icmsModule;
	icms_loadLanguageFile('core', 'notification');
	// Notification must be enabled, and user must be logged in
	if (empty(icms::$user) || !icms_data_notification_Handler::isEnabled('block')) {
		return FALSE; // do not display block
	}
	$notification_handler = icms::handler('icms_data_notification');
	// Now build the a nested associative array of info to pass
	// to the block template.
	$block = array();
	$categories =& $notification_handler->subscribableCategoryInfo();
	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'], $icmsModule->getVar('mid'), icms::$user->getVar('uid'));
		foreach ($notification_handler->categoryEvents($category['name'], TRUE) as $event) {
			if (!empty($event['admin_only']) && !icms::$user->isAdmin($icmsModule->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'] = icms::$security->createToken();
	return $block;
}
예제 #2
0
 * @copyright	http://www.xoops.org/ The XOOPS Project
 * @copyright	XOOPS_copyrights.txt
 * @copyright	http://www.impresscms.org/ The ImpressCMS Project
 * @license	LICENSE.txt
 * @package	core
 * @since	XOOPS
 * @author	http://www.xoops.org The XOOPS Project
 * @author	modified by UnderDog <*****@*****.**>
 * @version	$Id: notification_select.php 10825 2010-12-03 00:01:23Z skenow $
 */
if (!defined('ICMS_ROOT_PATH')) {
    exit;
}
include_once ICMS_ROOT_PATH . '/include/notification_constants.php';
$xoops_notification = array();
$xoops_notification['show'] = isset($icmsModule) && is_object(icms::$user) && icms_data_notification_Handler::isEnabled('inline') ? 1 : 0;
if ($xoops_notification['show']) {
    icms_loadLanguageFile('core', 'notification');
    $notification_handler = icms::handler('icms_data_notification');
    $categories =& $notification_handler->subscribableCategoryInfo();
    $event_count = 0;
    if (!empty($categories)) {
        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'], $icmsModule->getVar('mid'), icms::$user->getVar('uid'));
            foreach ($notification_handler->categoryEvents($category['name'], true) as $event) {
                if (!empty($event['admin_only']) && !icms::$user->isAdmin($icmsModule->getVar('mid'))) {
/**
 * Determine if notification is enabled for the selected module.
 *
 * @param  string  $style	  Subscription style: 'block' or 'inline'
 * @param  int	 $module_id  ID of the module  (default current module)
 * @return bool
 * @deprecated	Use the notification class method instead - isEnabled
 * @todo
 */
function notificationEnabled($style, $module_id = null)
{
    icms_core_Debug::setDeprecated('icms_data_notification_Handler::isEnabled', sprintf(_CORE_REMOVE_IN_VERSION, '1.4'));
    return icms_data_notification_Handler::isEnabled($style);
}