PHP Classes

File: htdocs/include/notification_select.php

Recommend this page to a friend!
  Packages of Michael Beck   Xoops 2.5   htdocs/include/notification_select.php   Download  
File: htdocs/include/notification_select.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Xoops 2.5
Modular content management publication system
Author: By
Last change: Merge pull request #1586 from mambax7/feature/Cannot_use_bool_as_array

fix for Cannot use bool as array
copyright update
PER-CS formatting
short array
Merge pull request #1239 from Andrew-Staves-Activ/notificationhandler_subscribe_success

Merge branch 'feature/php8_templates' of https://github.com/mambax7/XoopsCore25 into feature/php8_templates

# Conflicts:
# htdocs/themes/xswatch4/modules/publisher/publisher_item.tpl
Merge xswatch4
Date: 2 months ago
Size: 4,614 bytes
 

Contents

Class file image Download
<?php
/**
 * XOOPS Notifications
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * 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.
 *
 * @copyright (c) 2000-2025 XOOPS Project (https://xoops.org)
 * @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html)
 * @package kernel
 * @subpackage Xoop Notifications Select
 * @since 2.0.0
 * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/
 */
if (!defined('XOOPS_ROOT_PATH')) {
    throw new \
RuntimeException('Restricted access');
}

include_once
$GLOBALS['xoops']->path('include/notification_constants.php');
include_once
$GLOBALS['xoops']->path('include/notification_functions.php');

$xoops_notification = [];
$xoops_notification['show'] = isset($xoopsModule) && is_object($xoopsUser) && notificationEnabled('inline') ? 1 : 0;
if (
$xoops_notification['show']) {
   
xoops_loadLanguage('notification');
   
$categories = & notificationSubscribableCategoryInfo();
   
$event_count = 0;
    if (!empty(
$categories)) {
       
/** @var XoopsNotificationHandler $notification_handler */
       
$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'] = [];
           
$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'])) {
                    continue;
                }
               
$subscribed = in_array($event['name'], $subscribed_events) ? 1 : 0;
               
$section['events'][$event['name']] = [
                   
'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');
       
$xoopsTpl->assign(
            [
               
'lang_activenotifications' => _NOT_ACTIVENOTIFICATIONS,
               
'lang_notificationoptions' => _NOT_NOTIFICATIONOPTIONS,
               
'lang_updateoptions' => _NOT_UPDATEOPTIONS,
               
'lang_updatenow' => _NOT_UPDATENOW,
               
'lang_category' => _NOT_CATEGORY,
               
'lang_event' => _NOT_EVENT,
               
'lang_events' => _NOT_EVENTS,
               
'lang_checkall' => _NOT_CHECKALL,
               
'lang_notificationmethodis' => _NOT_NOTIFICATIONMETHODIS,
               
'lang_change' => _NOT_CHANGE,
               
'editprofile_url' => XOOPS_URL . '/edituser.php?uid=' . $xoopsUser->getVar('uid'),
            ],
        );
        switch (
$xoopsUser->getVar('notify_method')) {
            case
XOOPS_NOTIFICATION_METHOD_DISABLE:
               
$xoopsTpl->assign('user_method', _NOT_DISABLE);
                break;
            case
XOOPS_NOTIFICATION_METHOD_PM:
               
$xoopsTpl->assign('user_method', _NOT_PM);
                break;
            case
XOOPS_NOTIFICATION_METHOD_EMAIL:
               
$xoopsTpl->assign('user_method', _NOT_EMAIL);
                break;
        }
    } else {
       
$xoops_notification['show'] = 0;
    }
    if (
$event_count == 0) {
       
$xoops_notification['show'] = 0;
    }
}
$xoopsTpl->assign('xoops_notification', $xoops_notification);