Index: trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/notify_functions.php
===================================================================
--- trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/notify_functions.php	(revision 350)
+++ trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/notify_functions.php	(revision 352)
@@ -40,7 +40,9 @@
 	//When notifying by a private message, 
 	//it is evaded that the data base becomes read-only as a result of the check on the referrer and the method. 
+	if ( defined("XPRESS_EVENT_DEBUG")) xpress_debug_message($message = 'call $notification_handler->triggerEvent');
 	if (is_wp_cron_page_call() ){
 		$_SERVER['HTTP_REFERER'] = 'http://'. $_SERVER[HTTP_HOST]  . $_SERVER['PHP_SELF'];
 		$_SERVER['REQUEST_METHOD'] = 'POST';
+		if (function_exists('xpress_debug')) xpress_debug($title = 'wp_cron_page_call',true);
 	}
 	if (is_xmlrpc_call() ){
@@ -49,13 +51,18 @@
 	}
 //	set_error_handler("xpress_error_handler");
-	if ($xoops_config->is_impress != true){  // impress cms is error
-		if ( !defined("XOOPS_MAINFILE_INCLUDED")) {
-			require_once $xoops_config->xoops_mainfile_path;	// load XOOPS System
-		}
-	}
+//	if ($xoops_config->is_impress != true){  // impress cms is error
+//		if ( !defined("XOOPS_MAINFILE_INCLUDED")) {
+//			require_once $xoops_config->xoops_mainfile_path;	// load XOOPS System
+//		}
+//	}
 	if ( defined("XOOPS_MAINFILE_INCLUDED")) {
+		if ( defined("XPRESS_EVENT_DEBUG")) xpress_debug_message($message = 'call $notification_handler->triggerEvent');
 		$module_id = get_xpress_modid() ;
 		$notification_handler =& xoops_gethandler( 'notification' ) ;
 		$notification_handler->triggerEvent($category, $item_id, $event, $extra_tags, $user_list, $module_id, $omit_user_id);
+	} else {
+		if ( defined("XPRESS_EVENT_DEBUG")) xpress_debug_message($message = 'not call $notification_handler->triggerEvent');
+		$module_id = get_xpress_modid() ;
+		Notification_reserve($category, $item_id, $event, $extra_tags, $user_list, $module_id, $omit_user_id);
 	}
 }
@@ -177,5 +184,71 @@
 		default :
 	}
-}		
+}
+
+//When the event cannot notify because the XOOPS system is not loaded, the event is stacked. 
+function Notification_reserve($category, $item_id=0, $event, $extra_tags=array(), $user_list=array(), $module_id=0, $omit_user_id=null)
+{
+	global $xpress_config,$xoops_db;
+	
+	$xpress_prefix = get_wp_prefix();
+	$notfiy_reserve = $xpress_prefix . 'notify_reserve';
+
+	$extra_tags_arry = addslashes(serialize($extra_tags));
+	$user_list_arry = addslashes(serialize($user_list));
+//	$extra_tags_arry = mysql_real_escape_string(serialize($extra_tags));
+//	$user_list_arry = mysql_real_escape_string(serialize($user_list));
+	
+	$notify_reserve_status = 'reserve';
+
+	$sql  = "INSERT INTO $notfiy_reserve ";
+	$sql .=    "(notify_reserve_status , category , item_id , event , extra_tags_arry , user_list_arry , module_id , omit_user_id)";
+	$sql .=  "VALUES ";
+	$sql .=    "('$notify_reserve_status' , '$category' , $item_id , '$event' , '$extra_tags_arry' , '$user_list_arry' , $module_id , '$omit_user_id')";
+	if ( defined("XPRESS_EVENT_DEBUG")) xpress_debug_message($message = $sql);
+
+	$xoops_db->query($sql);
+}
+
+//It calls when the XOOPS system is loaded, and the stacked event notification processing is done. 
+function Notification_reserve_send()
+{
+	global $xpress_config,$xoops_db;
+	if ( ! defined("XOOPS_MAINFILE_INCLUDED")) return;
+	
+	$notification_handler =& xoops_gethandler( 'notification' ) ;
+	
+	$xpress_prefix = get_wp_prefix();
+	$notfiy_reserve_db = $xpress_prefix . 'notify_reserve';
+
+	$extra_tags_arry = addslashes(serialize($extra_tags));
+	$user_list_arry = addslashes(serialize($user_list));
+	
+	$sql  = "SELECT * ";
+	$sql .= "FROM $notfiy_reserve_db ";
+	$sql .= "WHERE  notify_reserve_status = 'reserve'";
+
+	$notify_reserves = $xoops_db->get_results($sql);
+
+	//So as not to process it by other sessions while processing it, status is changed. 
+	foreach($notify_reserves as $notify){
+		$notify_reserve_id = $notify->notify_reserve_id;
+		$sql  = "UPDATE $notfiy_reserve_db SET  notify_reserve_status = 'sending' WHERE notify_reserve_id = $notify_reserve_id";
+		$xoops_db->query($sql);
+	}
+
+	foreach($notify_reserves as $notify){
+		$notify_reserve_id = $notify->notify_reserve_id;
+		$category = $notify->category;
+		$item_id = $notify->item_id;
+		$event = $notify->event;
+		$extra_tags = unserialize($notify->extra_tags_arry);
+		$user_list = unserialize($notify->user_list_arry);
+		$module_id = $notify->module_id;
+		$omit_user_id = $notify->omit_user_id;
+		$notification_handler->triggerEvent($category, $item_id, $event, $extra_tags, $user_list, $module_id, $omit_user_id);
+		$sql  = "DELETE FROM  $notfiy_reserve_db WHERE notify_reserve_id = $notify_reserve_id";
+		$xoops_db->query($sql);
+	}
+}
 
 ?>
