20 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
36 if (isset(
$GLOBALS[
'xoopsModuleConfig'][
'notification_enabled'])) {
52 include_once
$GLOBALS[
'xoops']->path(
'include/notification_constants.php');
78 $module_id = !empty($xoopsModule) ? $xoopsModule->getVar(
'mid') : 0;
84 $not_config = &
$module->getInfo(
'notification');
85 if (empty($category_name)) {
86 return $not_config[
'category'];
88 foreach ($not_config[
'category'] as $category) {
89 if ($category[
'name'] == $category_name) {
114 if (empty($all_categories)) {
117 foreach ($all_categories as $category) {
119 if (empty($all_events)) {
122 foreach ($all_events as $event) {
123 if ($event[
'name'] ==
'comment') {
146 $module_id = !empty($xoopsModule) ? $xoopsModule->getVar(
'mid') : 0;
152 $not_config =
$module->getInfo(
'notification');
159 $event_array = array();
161 $override_comment =
false;
162 $override_commentsubmit =
false;
163 $override_bookmark =
false;
165 foreach ($not_config[
'event'] as $event) {
166 if ($event[
'category'] == $category_name) {
167 if (!is_dir(
$dir = XOOPS_ROOT_PATH .
'/modules/' .
$module->getVar(
'dirname') .
'/language/' . $xoopsConfig[
'language'] .
'/mail_template/')) {
168 $dir = XOOPS_ROOT_PATH .
'/modules/' .
$module->getVar(
'dirname') .
'/language/english/mail_template/';
170 $event[
'mail_template_dir'] =
$dir;
172 $event_array[] = $event;
174 if ($event[
'name'] ==
'comment') {
175 $override_comment =
true;
177 if ($event[
'name'] ==
'comment_submit') {
178 $override_commentsubmit =
true;
180 if ($event[
'name'] ==
'bookmark') {
181 $override_bookmark =
true;
189 if (
$module->getVar(
'hascomments')) {
190 $com_config =
$module->getInfo(
'comments');
191 if (!empty($category[
'item_name']) && $category[
'item_name'] == $com_config[
'itemName']) {
192 if (!is_dir(
$dir = XOOPS_ROOT_PATH .
'/language/' . $xoopsConfig[
'language'] .
'/mail_template/')) {
193 $dir = XOOPS_ROOT_PATH .
'/language/english/mail_template/';
195 $mail_template_dir =
$dir;
197 include_once
$GLOBALS[
'xoops']->path(
'include/comment_constants.php');
200 if (!$enabled_only) {
201 $insert_comment =
true;
202 $insert_submit =
true;
204 $insert_comment =
false;
205 $insert_submit =
false;
206 switch ($com_config[
'com_rule']) {
212 if (!$override_comment) {
213 $insert_comment =
true;
219 if (!$override_comment) {
220 $insert_comment =
true;
222 if (!$override_commentsubmit) {
223 $insert_submit =
true;
228 if ($insert_comment) {
230 'name' =>
'comment' ,
231 'category' => $category[
'name'] ,
235 'mail_template_dir' => $mail_template_dir ,
236 'mail_template' =>
'comment_notify' ,
239 $event_array[] = $event;
242 if ($insert_submit) {
244 'name' =>
'comment_submit' ,
245 'category' => $category[
'name'] ,
249 'mail_template_dir' => $mail_template_dir ,
250 'mail_template' =>
'commentsubmit_notify' ,
254 $event_array[] = $event;
264 if (!empty($category[
'allow_bookmark'])) {
265 if (!$override_bookmark) {
267 'name' =>
'bookmark' ,
268 'category' => $category[
'name'] ,
273 $event_array[] = $event;
299 if (is_array($mod_config[
'notification_events']) && $mod_config[
'notification_events'] != array()) {
301 if (in_array($option_name, $mod_config[
'notification_events'])) {
321 foreach($all_events as $event) {
322 if ($event[
'name'] == $event_name) {
343 $script_url = explode(
'/',
$_SERVER[
'PHP_SELF']);
344 $script_name = $script_url[count($script_url) - 1];
346 $sub_categories = array();
347 foreach ($all_categories as $category) {
349 $subscribe_from = $category[
'subscribe_from'];
350 if (!is_array($subscribe_from)) {
351 if ($subscribe_from ==
'*') {
352 $subscribe_from = array(
356 $subscribe_from = array(
360 if (!in_array($script_name, $subscribe_from)) {
365 if (empty($category[
'item_name'])) {
366 $category[
'item_name'] =
'';
367 $category[
'item_id'] = 0;
368 $sub_categories[] = $category;
370 $item_name = $category[
'item_name'];
371 $id = ($item_name !=
'' && isset(
$_GET[$item_name])) ? intval(
$_GET[$item_name]) : 0;
373 $category[
'item_id'] = $id;
374 $sub_categories[] = $category;
378 return $sub_categories;
399 return 'notify:' . $category[
'name'] .
'-' . $event[
'name'];
402 return $category[
'name'] .
'-' . $event[
'name'];