예제 #1
0
 function triggerEvent($category, $item_id, $event, $extra_tags = array(), $user_list = array(), $module_id = null, $omit_user_id = null)
 {
     if (!isset($module_id)) {
         global $xoopsModule;
         $module =& $xoopsModule;
         $module_id = !empty($xoopsModule) ? $xoopsModule->getVar('mid') : 0;
     } else {
         $module_handler = xoops_gethandler('module');
         $module =& $module_handler->get($module_id);
     }
     // Get Config Array form xoops_version.php
     $not_config = $module->getInfo('notification');
     //
     $event_correct = false;
     foreach ($not_config['event'] as $event_config) {
         if ($event_config['name'] == $event && $event_config['category'] == $category) {
             $event_correct = true;
             break;
         }
     }
     // RaiseEvent 'XoopsNotificationHandler.Trigger' ('Legacy.Notify.Trigger')
     //  Delegate may hanldle notified event
     //  varArgs :
     //      'category'     [I] : Paramater $category of triggerEvent()
     //      'event'        [I] : Paramater $event of triggerEvent()
     //      'itemId'       [I] : Paramater $item_id of triggerEvent()
     //      'extraTags'    [I] : Paramater $extra_tags of triggerEvent()
     //      'userList'     [I] : Paramater $user_list of triggerEvent()
     //      'omitUid'      [I] : Paramater $omit_user_id of triggerEvent()
     //      'module'       [I] : Paramater $module_id of triggerEvent() , or currenr $xoopsModule
     //      'eventConfig'  [I] : $modversion['notification'] Array , defined in xoops_version.php
     //      'force_return' [O] : If force return this triggerEvents method, set it True
     //
     if ($event_correct) {
         /*
         			$varArgs  = array('category' => $category,
         							'event' => $event,
         							'itemId' => $item_id,
         							'extraTags' => $extra_tags,
         							'module' => &$module,
         							'userList' => $user_list,
         							'omitUid' => $omit_user_id,
         							'eventConfig' => $not_config,
         							'force_return' => false,
         						);*/
         $force_return = false;
         $this->mTriggerPreAction->call(new XCube_Ref($category), new XCube_Ref($event), new XCube_Ref($item_id), new XCube_Ref($extra_tags), new XCube_Ref($module), new XCube_Ref($user_list), new XCube_Ref($omit_user_id), new XCube_Ref($not_config), new XCube_Ref($force_return));
         $this->mTrigger->call($category, $event, $item_id, $extra_tags, new XCube_Ref($module), $user_list, $omit_user_id, $not_config, new XCube_Ref($force_return));
         if ($force_return) {
             return;
         }
     }
     // Check if event is enabled
     $config_handler = xoops_gethandler('config');
     $mod_config =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
     if (empty($mod_config['notification_enabled'])) {
         return false;
     }
     $category_info =& notificationCategoryInfo($category, $module_id);
     $event_info =& notificationEventInfo($category, $event, $module_id);
     if (!in_array(notificationGenerateConfig($category_info, $event_info, 'option_name'), $mod_config['notification_events']) && empty($event_info['invisible'])) {
         return false;
     }
     if (!isset($omit_user_id)) {
         global $xoopsUser;
         if (!empty($xoopsUser)) {
             $omit_user_id = $xoopsUser->getVar('uid');
         } else {
             $omit_user_id = 0;
         }
     }
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('not_modid', (int) $module_id));
     $criteria->add(new Criteria('not_category', $this->_escapeValue($category)));
     $criteria->add(new Criteria('not_itemid', (int) $item_id));
     $criteria->add(new Criteria('not_event', $this->_escapeValue($event)));
     $mode_criteria = new CriteriaCompo();
     $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDALWAYS), 'OR');
     $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE), 'OR');
     $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT), 'OR');
     $criteria->add($mode_criteria);
     if (!empty($user_list)) {
         $user_criteria = new CriteriaCompo();
         foreach ($user_list as $user) {
             $user_criteria->add(new Criteria('not_uid', $user), 'OR');
         }
         $criteria->add($user_criteria);
     }
     $notifications =& $this->getObjects($criteria);
     if (empty($notifications)) {
         return;
     }
     // Add some tag substitutions here
     $tags = array();
     if (!empty($not_config)) {
         if (!empty($not_config['tags_file'])) {
             $tags_file = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname') . '/' . $not_config['tags_file'];
             if (file_exists($tags_file)) {
                 include_once $tags_file;
                 if (!empty($not_config['tags_func'])) {
                     $tags_func = $not_config['tags_func'];
                     if (function_exists($tags_func)) {
                         $tags = $tags_func($category, (int) $item_id, $event);
                     }
                 }
             }
         }
         // RMV-NEW
         if (!empty($not_config['lookup_file'])) {
             $lookup_file = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname') . '/' . $not_config['lookup_file'];
             if (file_exists($lookup_file)) {
                 include_once $lookup_file;
                 if (!empty($not_config['lookup_func'])) {
                     $lookup_func = $not_config['lookup_func'];
                     if (function_exists($lookup_func)) {
                         $item_info = $lookup_func($category, (int) $item_id);
                     }
                 }
             }
         }
     }
     $tags['X_ITEM_NAME'] = !empty($item_info['name']) ? $item_info['name'] : '[' . _NOT_ITEMNAMENOTAVAILABLE . ']';
     $tags['X_ITEM_URL'] = !empty($item_info['url']) ? $item_info['url'] : '[' . _NOT_ITEMURLNOTAVAILABLE . ']';
     $tags['X_ITEM_TYPE'] = !empty($category_info['item_name']) ? $category_info['title'] : '[' . _NOT_ITEMTYPENOTAVAILABLE . ']';
     $tags['X_MODULE'] = $module->getVar('name', 'n');
     $tags['X_MODULE_URL'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/';
     $tags['X_NOTIFY_CATEGORY'] = $category;
     $tags['X_NOTIFY_EVENT'] = $event;
     $template_dir = $event_info['mail_template_dir'];
     $template = $event_info['mail_template'] . '.tpl';
     $subject = $event_info['mail_subject'];
     foreach ($notifications as $notification) {
         if (empty($omit_user_id) || $notification->getVar('not_uid') != $omit_user_id) {
             // user-specific tags
             //$tags['X_UNSUBSCRIBE_URL'] = 'TODO';
             // TODO: don't show unsubscribe link if it is 'one-time' ??
             $tags['X_UNSUBSCRIBE_URL'] = XOOPS_URL . '/notifications.php';
             $tags = array_merge($tags, $extra_tags);
             $notification->notifyUser($template_dir, $template, $subject, $tags);
         }
     }
 }
예제 #2
0
         $prev_category = $category;
         $prev_item = -1;
         $category_info =& notificationCategoryInfo($category, $modid);
         $modules[$modid]['categories'][$category] = array('name' => $category, 'title' => $category_info['title'], 'items' => array());
     }
     $item = $n->getVar('not_itemid');
     if ($item != $prev_item) {
         $prev_item = $item;
         if (!empty($lookup_func)) {
             $item_info = $lookup_func($category, $item);
         } else {
             $item_info = array('name' => '[' . _NOT_NAMENOTAVAILABLE . ']', 'url' => '');
         }
         $modules[$modid]['categories'][$category]['items'][$item] = array('id' => $item, 'name' => $item_info['name'], 'url' => $item_info['url'], 'notifications' => array());
     }
     $event_info =& notificationEventInfo($category, $n->getVar('not_event'), $n->getVar('not_modid'));
     $modules[$modid]['categories'][$category]['items'][$item]['notifications'][] = array('id' => $n->getVar('not_id'), 'module_id' => $n->getVar('not_modid'), 'category' => $n->getVar('not_category'), 'category_title' => $category_info['title'], 'item_id' => $n->getVar('not_itemid'), 'event' => $n->getVar('not_event'), 'event_title' => $event_info['title'], 'user_id' => $n->getVar('not_uid'));
 }
 $xoopsOption['template_main'] = 'system_notification_list.html';
 include $GLOBALS['xoops']->path('header.php');
 $xoopsTpl->assign('modules', $modules);
 $user_info = array('uid' => $xoopsUser->getVar('uid'));
 $xoopsTpl->assign('user', $user_info);
 $xoopsTpl->assign('lang_cancel', _CANCEL);
 $xoopsTpl->assign('lang_clear', _NOT_CLEAR);
 $xoopsTpl->assign('lang_delete', _DELETE);
 $xoopsTpl->assign('lang_checkall', _NOT_CHECKALL);
 $xoopsTpl->assign('lang_module', _NOT_MODULE);
 $xoopsTpl->assign('lang_event', _NOT_EVENT);
 $xoopsTpl->assign('lang_events', _NOT_EVENTS);
 $xoopsTpl->assign('lang_category', _NOT_CATEGORY);
예제 #3
0
 function getDefaultView(&$contoller, &$xoopsUser)
 {
     $criteria = new Criteria('not_uid', $xoopsUser->get('uid'));
     $criteria->setSort('not_modid, not_category, not_itemid');
     $handler =& xoops_gethandler('notification');
     $notificationArr =& $handler->getObjects($criteria);
     $moduleHandler =& xoops_gethandler('module');
     $prev_modid = -1;
     $prev_category = -1;
     $prev_item = -1;
     foreach ($notificationArr as $notify) {
         $t_modid = $notify->get('not_modid');
         $module =& $moduleHandler->get($t_modid);
         if (!is_object($module)) {
             continue;
         }
         if ($t_modid != $prev_modid) {
             $prev_modid = $t_modid;
             $prev_category = -1;
             $prev_item = -1;
             $this->mModules[$t_modid] = array('id' => $t_modid, 'name' => $module->getShow('name'), 'categories' => array());
             //
             // [ToDo] (Original)
             // note, we could auto-generate the url from the id
             // and category info... (except when category has multiple
             // subscription scripts defined...)
             // OR, add one more option to xoops_version 'view_from'
             // which tells us where to redirect... BUT, e.g. forums, it
             // still wouldn't give us all the required info... e.g. the
             // topic ID doesn't give us the ID of the forum which is
             // a required argument...
             //
             // Get the lookup function, if exists
             //
             $notifyConfig = $module->getInfo('notification');
             $lookupFunc = '';
             if (!empty($notifyConfig['lookup_file'])) {
                 $t_filepath = XOOPS_ROOT_PATH . '/modules/' . $module->get('dirname') . '/' . $notifyConfig['lookup_file'];
                 if (file_exists($t_filepath)) {
                     require_once $t_filepath;
                     if (!empty($notifyConfig['lookup_func']) && function_exists($notifyConfig['lookup_func'])) {
                         $lookupFunc = $notifyConfig['lookup_func'];
                     }
                 }
             }
         }
         $t_category = $notify->get('not_category');
         if ($t_category != $prev_category) {
             $prev_category = $t_category;
             $prev_item = -1;
             $categoryInfo =& notificationCategoryInfo($t_category, $t_modid);
         }
         $t_item = $notify->get('not_itemid');
         if ($t_item != $prev_item) {
             $prev_item = $t_item;
             if (!empty($lookupFunc)) {
                 $itemInfo = $lookupFunc($t_category, $t_item);
             } else {
                 $itemInfo = array('name' => '[' . _NOT_NAMENOTAVAILABLE . ']', 'url' => '');
             }
             $this->mModules[$t_modid]['categories'][$t_category]['items'][$t_item] = array('id' => $t_item, 'name' => $itemInfo['name'], 'url' => $itemInfo['url'], 'notifications' => array());
         }
         $eventInfo =& notificationEventInfo($t_category, $notify->get('not_event'), $notify->get('not_modid'));
         $this->mModules[$t_modid]['categories'][$t_category]['items'][$t_item]['notifications'][] = array('id' => $notify->get('not_id'), 'module_id' => $notify->get('not_modid'), 'category' => $notify->get('not_category'), 'category_title' => $categoryInfo['title'], 'item_id' => $notify->get('not_itemid'), 'event' => $notify->get('not_event'), 'event_title' => $eventInfo['title'], 'user_id' => $notify->get('not_uid'));
     }
     return LEGACY_FRAME_VIEW_INDEX;
 }
예제 #4
0
function xsns_main_trigger_event( $category , $item_id , $event , $extra_tags=array() , $user_list=array() , $omit_user_id=null )
{
	global $xoopsModule , $xoopsConfig , $mydirname , $mydirpath;

	$notification_handler =& xoops_gethandler('notification') ;

	$mid = $xoopsModule->getVar('mid') ;

	// language
	$language = empty($xoopsConfig['language']) ? 'japanese' : $xoopsConfig['language'] ;
	$trustdirpath = dirname(dirname(__FILE__));
	if( file_exists( "$mydirpath/language/$language/mail_template/" ) ) {
		$mail_template_dir = "$mydirpath/language/$language/mail_template/" ;
	}
	else if( file_exists( $trustdirpath."/language/$language/mail_template/" ) ) {
		$mail_template_dir = $trustdirpath."/language/$language/mail_template/";
	}
	else {
		$mail_template_dir = $trustdirpath."/language/japanese/mail_template/";
	}
	
	// Check if event is enabled
	$config_handler =& xoops_gethandler('config');
	$mod_config =& $config_handler->getConfigsByCat(0,$mid);
	if (empty($mod_config['notification_enabled'])) {
		return false;
	}
	$category_info =& notificationCategoryInfo ($category, $mid);
	$event_info =& notificationEventInfo ($category, $event, $mid);
	if (!in_array(notificationGenerateConfig($category_info,$event_info,'option_name'),$mod_config['notification_events']) && empty($event_info['invisible'])) {
		return false;
	}

	if (!isset($omit_user_id)) {
		global $xoopsUser;
		if (!empty($xoopsUser)) {
			$omit_user_id = $xoopsUser->getVar('uid');
		} else {
			$omit_user_id = 0;
		}
	}
	$criteria = new CriteriaCompo();
	$criteria->add(new Criteria('not_modid', intval($mid)));
	$criteria->add(new Criteria('not_category', $category));
	$criteria->add(new Criteria('not_itemid', intval($item_id)));
	$criteria->add(new Criteria('not_event', $event));
	$mode_criteria = new CriteriaCompo();
	$mode_criteria->add (new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDALWAYS), 'OR');
	$mode_criteria->add (new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE), 'OR');
	$mode_criteria->add (new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT), 'OR');
	$criteria->add($mode_criteria);
	if (!empty($user_list)) {
		$user_criteria = new CriteriaCompo();
		foreach ($user_list as $user) {
			$user_criteria->add (new Criteria('not_uid', $user), 'OR');
		}
		$criteria->add($user_criteria);
	}
	$notifications =& $notification_handler->getObjects($criteria);
	if (empty($notifications)) {
		return;
	}

	// Add some tag substitutions here
	$tags = array();
	// {X_ITEM_NAME} {X_ITEM_URL} {X_ITEM_TYPE} from lookup_func are disabled
	$tags['X_MODULE'] = $xoopsModule->getVar('name','n');
	$tags['X_MODULE_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/';
	$tags['X_NOTIFY_CATEGORY'] = $category;
	$tags['X_NOTIFY_EVENT'] = $event;

	$template = $event_info['mail_template'] . '.tpl';
	$subject = $event_info['mail_subject'];

	foreach ($notifications as $notification) {
		if (empty($omit_user_id) || $notification->getVar('not_uid') != $omit_user_id) {
			$tags['X_UNSUBSCRIBE_URL'] = XOOPS_URL . '/notifications.php';
			$tags = array_merge($tags, $extra_tags);
			
			$notification->notifyUser($mail_template_dir, $template, $subject, $tags);
		}
	}
}
예제 #5
0
 function triggerEvent($category, $item_id, $event, $extra_tags = array(), $user_list = array(), $module_id = null, $omit_user_id = null)
 {
     if (!isset($module_id)) {
         global $xoopsModule;
         $module =& $xoopsModule;
         $module_id = !empty($xoopsModule) ? $xoopsModule->getVar('mid') : 0;
     } else {
         $module_handler =& xoops_gethandler('module');
         $module =& $module_handler->get($module_id);
     }
     // Check if event is enabled
     $config_handler =& xoops_gethandler('config');
     $mod_config =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
     if (empty($mod_config['notification_enabled'])) {
         return false;
     }
     $category_info =& notificationCategoryInfo($category, $module_id);
     $event_info =& notificationEventInfo($category, $event, $module_id);
     if (!in_array(notificationGenerateConfig($category_info, $event_info, 'option_name'), $mod_config['notification_events']) && empty($event_info['invisible'])) {
         return false;
     }
     if (!isset($omit_user_id)) {
         global $xoopsUser;
         if (!empty($xoopsUser)) {
             $omit_user_id = $xoopsUser->getVar('uid');
         } else {
             $omit_user_id = 0;
         }
     }
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('not_modid', intval($module_id)));
     $criteria->add(new Criteria('not_category', $category));
     $criteria->add(new Criteria('not_itemid', intval($item_id)));
     $criteria->add(new Criteria('not_event', $event));
     $mode_criteria = new CriteriaCompo();
     $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDALWAYS), 'OR');
     $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE), 'OR');
     $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT), 'OR');
     $criteria->add($mode_criteria);
     if (!empty($user_list)) {
         $user_criteria = new CriteriaCompo();
         foreach ($user_list as $user) {
             $user_criteria->add(new Criteria('not_uid', $user), 'OR');
         }
         $criteria->add($user_criteria);
     }
     $notifications =& $this->getObjects($criteria);
     if (empty($notifications)) {
         return;
     }
     // Add some tag substitutions here
     $not_config = $module->getInfo('notification');
     $tags = array();
     if (!empty($not_config)) {
         if (!empty($not_config['tags_file'])) {
             $tags_file = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname') . '/' . $not_config['tags_file'];
             if (file_exists($tags_file)) {
                 include_once $tags_file;
                 if (!empty($not_config['tags_func'])) {
                     $tags_func = $not_config['tags_func'];
                     if (function_exists($tags_func)) {
                         $tags = $tags_func($category, intval($item_id), $event);
                     }
                 }
             }
         }
         // RMV-NEW
         if (!empty($not_config['lookup_file'])) {
             $lookup_file = XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname') . '/' . $not_config['lookup_file'];
             if (file_exists($lookup_file)) {
                 include_once $lookup_file;
                 if (!empty($not_config['lookup_func'])) {
                     $lookup_func = $not_config['lookup_func'];
                     if (function_exists($lookup_func)) {
                         $item_info = $lookup_func($category, intval($item_id));
                     }
                 }
             }
         }
     }
     $tags['X_ITEM_NAME'] = !empty($item_info['name']) ? $item_info['name'] : '[' . _NOT_ITEMNAMENOTAVAILABLE . ']';
     $tags['X_ITEM_URL'] = !empty($item_info['url']) ? $item_info['url'] : '[' . _NOT_ITEMURLNOTAVAILABLE . ']';
     $tags['X_ITEM_TYPE'] = !empty($category_info['item_name']) ? $category_info['title'] : '[' . _NOT_ITEMTYPENOTAVAILABLE . ']';
     $tags['X_MODULE'] = $module->getVar('name');
     $tags['X_MODULE_URL'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/';
     $tags['X_NOTIFY_CATEGORY'] = $category;
     $tags['X_NOTIFY_EVENT'] = $event;
     $template_dir = $event_info['mail_template_dir'];
     $template = $event_info['mail_template'] . '.tpl';
     $subject = $event_info['mail_subject'];
     foreach ($notifications as $notification) {
         if (empty($omit_user_id) || $notification->getVar('not_uid') != $omit_user_id) {
             // user-specific tags
             //$tags['X_UNSUBSCRIBE_URL'] = 'TODO';
             // TODO: don't show unsubscribe link if it is 'one-time' ??
             $tags['X_UNSUBSCRIBE_URL'] = XOOPS_URL . '/notifications.php';
             $tags = array_merge($tags, $extra_tags);
             $notification->notifyUser($template_dir, $template, $subject, $tags);
         }
     }
 }
 function triggerEvent($mydirname, $mytrustdirname, $category, $item_id, $event, $extra_tags = array(), $user_list = array(), $omit_user_id = null)
 {
     $module_hanlder =& xoops_gethandler('module');
     $module =& $module_hanlder->getByDirname($mydirname);
     $notification_handler =& xoops_gethandler('notification');
     $mail_template_dir = $this->getMailTemplateDir($mydirname, $mytrustdirname);
     // calling a delegate before
     if (class_exists('XCube_DelegateUtils')) {
         $force_return = false;
         XCube_DelegateUtils::raiseEvent('D3NotificationHandler.Trigger', new XCube_Ref($category), new XCube_Ref($event), new XCube_Ref($item_id), new XCube_Ref($extra_tags), new XCube_Ref($module), new XCube_Ref($user_list), new XCube_Ref($omit_user_id), $module->getInfo('notification'), new XCube_Ref($force_return), new XCube_Ref($mail_template_dir), $mydirname, $mytrustdirname);
         if ($force_return) {
             return;
         }
     }
     $mid = $module->getVar('mid');
     // Check if event is enabled
     $config_handler =& xoops_gethandler('config');
     $mod_config =& $config_handler->getConfigsByCat(0, $mid);
     if (empty($mod_config['notification_enabled'])) {
         return false;
     }
     $category_info =& notificationCategoryInfo($category, $mid);
     $event_info =& notificationEventInfo($category, $event, $mid);
     if (!in_array(notificationGenerateConfig($category_info, $event_info, 'option_name'), $mod_config['notification_events']) && empty($event_info['invisible'])) {
         return false;
     }
     if (!isset($omit_user_id)) {
         global $xoopsUser;
         if (!empty($xoopsUser)) {
             $omit_user_id = $xoopsUser->getVar('uid');
         } else {
             $omit_user_id = 0;
         }
     }
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('not_modid', intval($mid)));
     $criteria->add(new Criteria('not_category', $category));
     $criteria->add(new Criteria('not_itemid', intval($item_id)));
     $criteria->add(new Criteria('not_event', $event));
     $mode_criteria = new CriteriaCompo();
     $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDALWAYS), 'OR');
     $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE), 'OR');
     $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT), 'OR');
     $criteria->add($mode_criteria);
     if (!empty($user_list)) {
         $user_criteria = new CriteriaCompo();
         foreach ($user_list as $user) {
             $user_criteria->add(new Criteria('not_uid', $user), 'OR');
         }
         $criteria->add($user_criteria);
     }
     $notifications =& $notification_handler->getObjects($criteria);
     if (empty($notifications)) {
         return;
     }
     // Add some tag substitutions here
     $tags = array();
     // {X_ITEM_NAME} {X_ITEM_URL} {X_ITEM_TYPE} from lookup_func are disabled
     $tags['X_MODULE'] = $module->getVar('name', 'n');
     $tags['X_MODULE_URL'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/';
     $tags['X_NOTIFY_CATEGORY'] = $category;
     $tags['X_NOTIFY_EVENT'] = $event;
     $template = $event_info['mail_template'] . '.tpl';
     $subject = $event_info['mail_subject'];
     foreach ($notifications as $notification) {
         if (empty($omit_user_id) || $notification->getVar('not_uid') != $omit_user_id) {
             // user-specific tags
             //$tags['X_UNSUBSCRIBE_URL'] = 'TODO';
             // TODO: don't show unsubscribe link if it is 'one-time' ??
             $tags['X_UNSUBSCRIBE_URL'] = XOOPS_URL . '/notifications.php';
             $tags = array_merge($tags, $extra_tags);
             $notification->notifyUser($mail_template_dir, $template, $subject, $tags);
         }
     }
 }
예제 #7
0
 function system_notification($page, $category, $item_id, $event, $extra_tags = array(), $user_list = array(), $omit_user_id = null)
 {
     //global $xoopsModule , $xoopsConfig , $mydirname , $mydirpath , $mytrustdirname , $mytrustdirpath ;
     // RMV-NOTIFY
     include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
     include_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
     $config_handler =& xoops_gethandler('config');
     $xoopsConfig =& $config_handler->getConfigsByCat(XOOPS_CONF);
     $mid = $this->root->module['mid'];
     // Check if event is enabled
     $config_handler =& xoops_gethandler('config');
     $mod_config =& $config_handler->getConfigsByCat(0, $mid);
     if (empty($mod_config['notification_enabled'])) {
         return false;
     }
     $category_info =& notificationCategoryInfo($category, $mid);
     $event_info =& notificationEventInfo($category, $event, $mid);
     if (!in_array(notificationGenerateConfig($category_info, $event_info, 'option_name'), $mod_config['notification_events']) && empty($event_info['invisible'])) {
         return false;
     }
     if (is_null($omit_user_id)) {
         $omit_user_id = $this->root->userinfo['uid'];
     }
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('not_modid', intval($mid)));
     $criteria->add(new Criteria('not_category', $category));
     $criteria->add(new Criteria('not_itemid', intval($item_id)));
     $criteria->add(new Criteria('not_event', $event));
     $mode_criteria = new CriteriaCompo();
     $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDALWAYS), 'OR');
     $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE), 'OR');
     $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT), 'OR');
     $criteria->add($mode_criteria);
     if (!empty($user_list)) {
         $user_criteria = new CriteriaCompo();
         foreach ($user_list as $user) {
             $user_criteria->add(new Criteria('not_uid', $user), 'OR');
         }
         $criteria->add($user_criteria);
     }
     $notification_handler =& xoops_gethandler('notification');
     $notifications =& $notification_handler->getObjects($criteria);
     if (empty($notifications)) {
         return;
     }
     // language file
     $language = empty($xoopsConfig['language']) ? 'english' : $xoopsConfig['language'];
     if (is_dir($this->root->mydirpath . "/language/{$language}/mail_template")) {
         // user customized language file
         $mail_template_dir = $this->root->mydirpath . "/language/{$language}/mail_template/";
     } else {
         if (is_dir($this->root->mytrustdirpath . "/language/{$language}/mail_template")) {
             // default language file
             $mail_template_dir = $this->root->mytrustdirpath . "/language/{$language}/mail_template/";
         } else {
             // fallback english
             $mail_template_dir = $this->root->mytrustdirpath . "/language/english/mail_template/";
         }
     }
     // Add some tag substitutions here
     $tags = array();
     // {X_ITEM_NAME} {X_ITEM_URL} {X_ITEM_TYPE} from lookup_func are disabled
     $tags['X_MODULE'] = $this->root->module['name'];
     $tags['X_MODULE_URL'] = $this->root->script;
     $tags['X_NOTIFY_CATEGORY'] = $category;
     $tags['X_NOTIFY_EVENT'] = $event;
     $template = $event_info['mail_template'] . '.tpl';
     $subject = $event_info['mail_subject'];
     foreach ($notifications as $notification) {
         if (empty($omit_user_id) || $notification->getVar('not_uid') != $omit_user_id) {
             // 表示権限チェック
             if ($this->check_readable_page($page, false, false, $notification->getVar('not_uid'))) {
                 // user-specific tags
                 //$tags['X_UNSUBSCRIBE_URL'] = 'TODO';
                 // TODO: don't show unsubscribe link if it is 'one-time' ??
                 $tags['X_UNSUBSCRIBE_URL'] = XOOPS_URL . '/notifications.php';
                 $tags = array_merge($tags, $extra_tags);
                 $notification->notifyUser($mail_template_dir, $template, $subject, $tags);
             }
         }
     }
 }