29 define(
'NOTIFICATIONS_MODE_SENDALWAYS', 0);
30 define(
'NOTIFICATIONS_MODE_SENDONCETHENDELETE', 1);
31 define(
'NOTIFICATIONS_MODE_SENDONCETHENWAIT', 2);
32 define(
'NOTIFICATIONS_MODE_WAITFORLOGIN', 3);
34 define(
'NOTIFICATIONS_METHOD_DISABLE', 0);
35 define(
'NOTIFICATIONS_METHOD_PM', 1);
36 define(
'NOTIFICATIONS_METHOD_EMAIL', 2);
38 define(
'NOTIFICATIONS_DISABLE', 0);
39 define(
'NOTIFICATIONS_ENABLEBLOCK', 1);
40 define(
'NOTIFICATIONS_ENABLEINLINE', 2);
41 define(
'NOTIFICATIONS_ENABLEBOTH', 3);
49 return parent::getInstance();
66 public function enabled($style, $module_dirname = null)
69 if (
$status =
$xoops->getModuleConfig(
'notifications_enabled')) {
71 if (!isset($module_dirname)) {
75 if (!
$status =
$xoops->getModuleConfig(
'notifications_enabled', $module_dirname)) {
79 if (($style ==
'block') && (
$status == NOTIFICATIONS_ENABLEBLOCK ||
$status == NOTIFICATIONS_ENABLEBOTH)) {
82 if (($style ==
'inline') && (
$status == NOTIFICATIONS_ENABLEINLINE ||
$status == NOTIFICATIONS_ENABLEBOTH)) {
104 if ($plugin = \
Xoops\Module\Plugin::getPlugin(
$dirname,
'notifications')) {
105 return $plugin->item($category, intval($item_id));
126 if ($plugin = \
Xoops\Module\Plugin::getPlugin(
$dirname,
'notifications')) {
127 return $plugin->tags($category, intval($item_id), $event,
$dirname);
150 if ($plugin = \
Xoops\Module\Plugin::getPlugin(
$dirname,
'notifications')) {
151 $categories = $plugin->categories();
152 if (empty($category_name)) {
155 foreach ($categories as $category) {
156 if ($category[
'name'] == $category_name) {
178 if (empty($all_categories)) {
181 foreach ($all_categories as $category) {
183 if (empty($all_events)) {
186 foreach ($all_events as $event) {
187 if ($event[
'name'] ==
'comment') {
216 if ($plugin = \
Xoops\Module\Plugin::getPlugin(
$dirname,
'notifications')) {
218 $events = $plugin->events();
222 $event_array = array();
224 $override_comment =
false;
225 $override_commentsubmit =
false;
226 $override_bookmark =
false;
228 foreach ($events as $event) {
229 if ($event[
'category'] == $category_name) {
233 $event[
'mail_template_dir'] =
$dir;
235 $event_array[] = $event;
237 if ($event[
'name'] ==
'comment') {
238 $override_comment =
true;
240 if ($event[
'name'] ==
'comment_submit') {
241 $override_commentsubmit =
true;
243 if ($event[
'name'] ==
'bookmark') {
244 $override_bookmark =
true;
253 if (
$xoops->isActiveModule(
'comments') && $commentsPlugin = \Xoops\Module\Plugin::getPlugin(
$dirname,
'comments')) {
255 if (!empty($category[
'item_name']) && $category[
'item_name'] == $commentsPlugin->itemName()) {
259 $mail_template_dir =
$dir;
262 if (!$enabled_only) {
263 $insert_comment =
true;
264 $insert_submit =
true;
266 $insert_comment =
false;
267 $insert_submit =
false;
268 switch ($com_config[
'com_rule']) {
269 case COMMENTS_APPROVENONE:
272 case COMMENTS_APPROVEALL:
274 if (!$override_comment) {
275 $insert_comment =
true;
278 case COMMENTS_APPROVEUSER:
279 case COMMENTS_APPROVEADMIN:
281 if (!$override_comment) {
282 $insert_comment =
true;
284 if (!$override_commentsubmit) {
285 $insert_submit =
true;
290 if ($insert_comment) {
293 'category' => $category[
'name'],
297 'mail_template_dir' => $mail_template_dir,
298 'mail_template' =>
'comment_notify',
302 $event_array[] = $event;
305 if ($insert_submit) {
307 'name' =>
'comment_submit',
308 'category' => $category[
'name'],
312 'mail_template_dir' => $mail_template_dir,
313 'mail_template' =>
'commentsubmit_notify',
318 $event_array[] = $event;
326 if (!empty($category[
'allow_bookmark'])) {
327 if (!$override_bookmark) {
329 'name' =>
'bookmark',
330 'category' => $category[
'name'],
336 $event_array[] = $event;
365 if (is_array($mod_config[
'notification_events']) && $mod_config[
'notification_events'] != array()) {
366 $option_name = $this->
generateConfig($category, $event,
'option_name');
367 if (in_array($option_name, $mod_config[
'notification_events'])) {
384 public function getEvent($category_name, $event_name, $module_dirname = null)
386 $all_events = $this->
getEvents($category_name,
false, $module_dirname);
387 foreach ($all_events as $event) {
388 if ($event[
'name'] == $event_name) {
405 $all_categories = $this->
getCategory(
'', $module_dirname);
408 $script_url = explode(
'/',
$_SERVER[
'PHP_SELF']);
409 $script_name = $script_url[count($script_url) - 1];
411 $sub_categories = array();
412 foreach ($all_categories as $category) {
414 $subscribe_from = $category[
'subscribe_from'];
415 if (!is_array($subscribe_from)) {
416 if ($subscribe_from ==
'*') {
417 $subscribe_from = array(
422 $subscribe_from = array(
427 if (!in_array($script_name, $subscribe_from)) {
432 if (empty($category[
'item_name'])) {
433 $category[
'item_name'] =
'';
434 $category[
'item_id'] = 0;
435 $sub_categories[] = $category;
437 $item_name = $category[
'item_name'];
438 $id = ($item_name !=
'' && isset($_GET[$item_name])) ? intval($_GET[$item_name]) : 0;
440 $category[
'item_id'] =
$id;
441 $sub_categories[] = $category;
445 return $sub_categories;
466 return 'notify:' . $category[
'name'] .
'-' . $event[
'name'];
469 return $category[
'name'] .
'-' . $event[
'name'];
486 $order = count(
$xoops->getModuleConfigs($module->
getVar(
'dirname')));
489 $confobj->setVar(
'conf_modid', $module->
getVar(
'mid'));
490 $confobj->setVar(
'conf_catid', 0);
491 $confobj->setVar(
'conf_name', $config[
'name']);
492 $confobj->setVar(
'conf_title', $config[
'title'],
true);
493 $confobj->setVar(
'conf_desc', $config[
'description'],
true);
494 $confobj->setVar(
'conf_formtype', $config[
'formtype']);
495 $confobj->setVar(
'conf_valuetype', $config[
'valuetype']);
496 $confobj->setConfValueForInput($config[
'default'],
true);
497 $confobj->setVar(
'conf_order', $order);
498 if (isset($config[
'options']) && is_array($config[
'options'])) {
499 foreach ($config[
'options'] as $key => $value) {
501 $confop->setVar(
'confop_name', $key,
true);
502 $confop->setVar(
'confop_value', $value,
true);
503 $confobj->setConfOptions($confop);
521 $configNames = array(
'notifications_enabled',
'notification_events');
527 $criteria->add(
new Criteria(
'conf_name',
"('" . implode(
"','", $configNames) .
"')",
'IN'));
543 $options[
'_MD_NOTIFICATIONS_CONFIG_DISABLE'] = NOTIFICATIONS_DISABLE;
544 $options[
'_MD_NOTIFICATIONS_CONFIG_ENABLEBLOCK'] = NOTIFICATIONS_ENABLEBLOCK;
545 $options[
'_MD_NOTIFICATIONS_CONFIG_ENABLEINLINE'] = NOTIFICATIONS_ENABLEINLINE;
546 $options[
'_MD_NOTIFICATIONS_CONFIG_ENABLEBOTH'] = NOTIFICATIONS_ENABLEBOTH;
549 'name' =>
'notifications_enabled',
550 'title' =>
'_MD_NOTIFICATIONS_CONFIG_ENABLE',
551 'description' =>
'_MD_NOTIFICATIONS_CONFIG_ENABLEDSC',
552 'formtype' =>
'select',
553 'valuetype' =>
'int',
554 'default' => NOTIFICATIONS_ENABLEBOTH,
561 foreach ($categories as $category) {
562 $events = $this->
getEvents($category[
'name'],
false, $module->
getVar(
'dirname'));
563 foreach ($events as $event) {
564 if (!empty($event[
'invisible'])) {
567 $option_name = $category[
'title'] .
' : ' . $event[
'title'];
568 $option_value = $category[
'name'] .
'-' . $event[
'name'];
569 $options[$option_name] = $option_value;
575 'name' =>
'notification_events',
576 'title' =>
'_MD_NOTIFICATIONS_CONFIG_EVENTS',
577 'description' =>
'_MD_NOTIFICATIONS_CONFIG_EVENTSDSC',
578 'formtype' =>
'select_multi',
579 'valuetype' =>
'array',
580 'default' => array_values(
$options),
getPluginableConfigs(XoopsModule $module)
getEvent($category_name, $event_name, $module_dirname=null)
const _MD_NOTIFICATIONS_COMMENTSUBMIT_NOTIFYDSC
deleteModuleRelations(XoopsModule $module)
getCategory($category_name= '', $dirname=null)
const _MD_NOTIFICATIONS_COMMENT_NOTIFYDSC
const _MD_NOTIFICATIONS_COMMENTSUBMIT_NOTIFYSBJ
getSubscribableCategories($module_dirname=null)
insertModuleRelations(XoopsModule $module)
const _MD_NOTIFICATIONS_COMMENTSUBMIT_NOTIFY
getVar($key, $format= 's')
generateConfig(&$category, &$event, $type)
const _MD_NOTIFICATIONS_COMMENT_NOTIFYCAP
const _MD_NOTIFICATIONS_BOOKMARK_NOTIFYCAP
getEvents($category_name, $enabled_only, $dirname=null)
getItem($category, $item_id, $dirname=null)
eventEnabled(&$category, &$event, $dirname)
if($_SERVER['REQUEST_METHOD']== 'POST') $config_handler
getTags($category, $item_id, $event, $dirname=null)
getCommentsCategory($dirname=null)
enabled($style, $module_dirname=null)
const _MD_NOTIFICATIONS_COMMENT_NOTIFYSBJ
const _MD_NOTIFICATIONS_COMMENTSUBMIT_NOTIFYCAP
const _MD_NOTIFICATIONS_COMMENT_NOTIFY
const _MD_NOTIFICATIONS_BOOKMARK_NOTIFY
const _MD_NOTIFICATIONS_BOOKMARK_NOTIFYDSC