function Notification_triggerEvent($force_reserve = false,$category, $item_id, $event, $extra_tags=array(), $user_list=array(), $omit_user_id=null) { global $xoops_db,$xoops_config; global $xoopsModule,$xoopsUser,$xoopsUserIsAdmin; //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() ){ $_SERVER['HTTP_REFERER'] = 'http://'. $_SERVER[HTTP_HOST] . $_SERVER['PHP_SELF']; $_SERVER['REQUEST_METHOD'] = 'POST'; } // 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 (!$force_reserve && 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); } }
function xpress_unnecessary_block_cache_delete($mydirname) { global $xoops_db, $xoops_config; $mid = get_xpress_modid(); $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = {$mid} AND visible = 1"; $blocks = $xoops_db->get_results($sql); require_once get_xpress_dir_path() . '/include/xpress_block_render.php'; $pattern = $mydirname . '_block_header'; foreach ($blocks as $block) { $cache_file_name = $mydirname . '_' . str_replace(".php", "", $block->func_file) . $block->bid; if (!empty($pattern)) { $pattern .= '|'; } $pattern .= $cache_file_name; } $pattern = '(' . $pattern . ')'; $cache_dir = $xoops_config->xoops_cache_path . '/'; $cache_time = 0; if ($dh = opendir($cache_dir)) { while (($file = readdir($dh)) !== false) { if (preg_match('/^' . preg_quote($mydirname) . '_/', $file)) { if (!preg_match('/' . $pattern . '/', $file)) { unlink($cache_dir . $file); } } } closedir($dh); } }
function GroupeRoleCheck($blog_id = 0) { global $xoops_db; if (empty($blog_id)) { if (defined('BLOG_ID_CURRENT_SITE')) { $blog_id = BLOG_ID_CURRENT_SITE; } else { $blog_id = 1; } } if (xpress_is_multiblog() && $blog_id == BLOG_ID_CURRENT_SITE) { $set_blog_admin = true; } else { $set_blog_admin = !$this->admin_select_groupe_role(); } $module_id = get_xpress_modid(); $group_role_table = get_wp_prefix() . 'group_role'; $xoops_group_table = get_xoops_prefix() . 'groups'; $xoops_group_permission_table = get_xoops_prefix() . 'group_permission'; $sql = "SELECT * FROM {$xoops_group_permission_table} WHERE gperm_itemid = {$module_id}"; $gperms = $xoops_db->get_results($sql); $sql = "SELECT * FROM {$xoops_group_table} WHERE group_type <> 'Anonymous' ORDER BY groupid"; $groupes = $xoops_db->get_results($sql); // list of groups registered with XOOPS $xoops_groupid_list = ''; foreach ($groupes as $groupe) { if (!empty($xoops_groupid_list)) { $xoops_groupid_list .= ','; } $xoops_groupid_list .= $groupe->groupid; } // delete the group deleted by the XOOPS group from a group role database if (!empty($xoops_groupid_list)) { $del_sql = "DELETE FROM {$group_role_table} WHERE groupid NOT IN ({$xoops_groupid_list})"; $xoops_db->query($del_sql); } $sql = "SELECT * FROM {$group_role_table} WHERE blog_id = {$blog_id}"; $groupes_role = $xoops_db->get_results($sql); foreach ($groupes as $groupe) { //get group parmission $group_type = ''; foreach ($gperms as $gperm) { if ($gperm->gperm_groupid == $groupe->groupid) { $group_type = $gperm->gperm_name; if ($group_type == 'module_admin') { break; } } } if (empty($group_type)) { $group_type = 'module_inhibit'; } $found = false; foreach ($groupes_role as $groupe_role) { if ($groupe_role->groupid == $groupe->groupid) { $role = $groupe_role->role; if ($group_type == 'module_admin' && $set_blog_admin) { $role = 'administrator'; } if ($group_type == 'module_inhibit') { $role = ''; } $edit_sql = "UPDATE {$group_role_table} SET group_type='{$group_type}',role='{$role}' WHERE groupid = {$groupe->groupid} AND blog_id = {$blog_id}"; $found = true; break; } } if (!$found) { $role = ''; if ($group_type == 'module_admin') { $role = 'administrator'; } $edit_sql = "INSERT INTO {$group_role_table} "; $edit_sql .= "(groupid , blog_id , name , description , group_type , role , login_all) "; $edit_sql .= "VALUES ("; $edit_sql .= $groupe->groupid . ', '; $edit_sql .= $blog_id . ', '; $edit_sql .= "'" . $groupe->name . "' , "; $edit_sql .= "'" . $groupe->description . "' , "; $edit_sql .= "'" . $group_type . "' , "; $edit_sql .= "'" . $role . "' , '"; $edit_sql .= $login_all . "')"; } $xoops_db->query($edit_sql); } $this->GroupeRoleRead(); }
function block_cache_refresh() { global $xoops_db; $mid = get_xpress_modid(); $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = {$mid}"; $blocks = $xoops_db->get_results($sql); $mydirname = get_xpress_dir_name(); require_once get_xpress_dir_path() . '/include/xpress_block_render.php'; foreach ($blocks as $block) { $func_file = $block->func_file; // Avoid the failure of the operation when switch_to_blog() and other plugin code is called on the admin page. $excludes = 'global_recent_posts_list_block\\.php|enhanced_block\\.php|global_recent_comments_block\\.php|global_popular_posts_block\\.php'; if (preg_match('/' . $excludes . '/', $func_file)) { continue; } $call_theme_function_name = str_replace(".php", "", $func_file); $inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php'; $cache_title = str_replace(".php", "", $func_file); $blockID = $block->bid; $options = explode("|", $block->options); $block_theme_file = get_block_file_path($mydirname, $inc_theme_file_name); require_once $block_theme_file['file_path']; $block_render = $call_theme_function_name($options); //The block name and the called function name should be assumed to be the same name. $xml['block'] = $block_render; $xml['block']['options'] = $block->options; xpress_block_cache_write($mydirname, $cache_title . $blockID, $xml); } }