XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
core.php
Go to the documentation of this file.
1 <?php
2 // $Id: core.php 1064 2012-09-17 16:46:12Z i.bitcero $
3 // --------------------------------------------------------------
4 // Red México Common Utilities
5 // A framework for Red México Modules
6 // Author: Eduardo Cortés <i.bitcero@gmail.com>
7 // Email: i.bitcero@gmail.com
8 // License: GPL 2.0
9 // --------------------------------------------------------------
10 
11 class RmcommonCorePreload extends XoopsPreloadItem
12 {
13 
14  public function eventCoreHeaderStart(){
15 
16  }
17 
18  public function eventCoreHeaderEnd(){
19 
23  $config = RMFunctions::configs();
24  if($config['blocks_enable']){
25  global $xoopsTpl;
27  $bks = RMEvents::get()->run_event('rmcommon.retrieve.xoops.blocks', $bks);
28  $b =& $xoopsTpl->get_template_vars('xoBlocks');
29  $blocks = array_merge($b, $bks);
30  $xoopsTpl->assign_by_ref('xoBlocks',$blocks);
31  unset($b,$bks);
32  }
33 
34  }
35 
36  static function eventCoreIncludeCommonStart($args){
37  global $xoopsOption;
38 
39  if(substr($_SERVER['REQUEST_URI'], -10)=='/admin.php' && strpos($_SERVER['REQUEST_URI'], 'modules')===FALSE){
40  header('location: '.XOOPS_URL.'/modules/rmcommon/');
41  die();
42  }
43 
44  if(substr($_SERVER['REQUEST_URI'], -16)=='system/admin.php' && empty($_POST)){
45  header('location: '.XOOPS_URL.'/modules/rmcommon/');
46  die();
47  }
48 
49  require_once XOOPS_ROOT_PATH.'/modules/rmcommon/loader.php';
50 
51  }
52 
56  public function eventCoreIncludeCommonLanguage(){
57  global $xoopsConfig;
58 
59  if($xoopsConfig['cpanel']!='redmexico'){
60  $db = XoopsDatabaseFactory::getDatabaseConnection();
61  $db->queryF("UPDATE ".$db->prefix("config")." SET conf_value='redmexico' WHERE conf_modid=0 AND conf_catid=1 AND conf_name='cpanel'");
62  }
63 
64  if (RMFunctions::current_url()==RMCURL.'/include/upload.php' && $xoopsConfig['closesite']){
65  $security = rmc_server_var($_POST, 'rmsecurity', 0);
66  $data = TextCleaner::getInstance()->decrypt($security, true);
67  $data = explode("|", $data); // [0] = referer, [1] = session_id(), [2] = user, [3] = token
68  $xoopsUser = new XoopsUser($data[0]);
69  if ($xoopsUser->isAdmin()) $xoopsConfig['closesite'] = 0;
70  }
71 
72  RMEvents::get()->run_event('rmcommon.include.common.language');
73 
74  }
75 
76  public function eventCoreFooterStart(){
77  RMEvents::get()->run_event('rmcommon.footer.start');
78  }
79 
80  public function eventCoreFooterEnd(){
81  ob_end_flush();
82  }
83 
84  public function eventCoreClassTheme_blocksRetrieveBlocks($params){
85  // xos_logos_PageBuilder
86  $xpb = $params[0];
87  // Template
88  $tpl = $params[1];
89  // Blocks
90  $blocks =& $params[2];
91 
92  $blocks = RMEvents::get()->run_event('rmcommon.retrieve.xoops.blocks', $blocks, $xpb, $tpl);
93 
94  }
95 
96  public function eventCoreIncludeFunctionsRedirectheader($params){
97 
98  // 0 = URL
99  // 1 = Time
100  // 2 = Message
101  // 3 = Add redirect
102  // 4 = Allow external link
103  RMEvents::get()->run_event('rmcommon.redirect.header', $params[0], $params[1], $params[2], $params[3], $params[4]);
104  if(!defined('XOOPS_CPFUNC_LOADED')) return;
105 
106  redirectMsg($params[0], $params[2]);
107  die();
108 
109  }
110 
114  public function eventCoreIncludeCommonEnd(){
115  global $xoopsOption;
116 
117  if(defined('RMC_CHECK_UPDATES') && $xoopsOption['pagetype']=='admin'){
118 
119  global $xoopsSecurity, $rmTpl;
120  $rmTpl->add_head_script('var xoToken = "'.$xoopsSecurity->createToken().'";');
121  }
122  RMEvents::get()->run_event('rmcommon.xoops.common.end');
123 
124  }
125 
126  public function eventCoreHeaderAddmeta(){
127  global $xoopsTpl, $xoopsConfig, $xoTheme, $rmc_config;
128 
129  if(!$xoopsTpl) return;
130 
131  $xoopsTpl->plugins_dir[] = RMCPATH.'/include';
132 
133  }
134 
138  public function eventCoreIndexStart(){
139  global $xoopsOption;
140  $xoopsOption['module_subpage'] = 'home-page';
141  }
142  public function eventCoreEdituserStart(){
143  global $xoopsOption;
144  $xoopsOption['module_subpage'] = 'edit-user';
145  }
146  public function eventCoreReadpmsgStart(){
147  global $xoopsOption;
148  $xoopsOption['module_subpage'] = 'readpm';
149  }
150  public function eventCoreRegisterStart(){
151  global $xoopsOption;
152  $xoopsOption['module_subpage'] = 'register';
153  }
154  public function eventCoreUserStart(){
155  global $xoopsOption;
156  $xoopsOption['module_subpage'] = 'user';
157  }
158  public function eventCoreUserinfoStart(){
159  global $xoopsOption;
160  $xoopsOption['module_subpage'] = 'profile';
161  }
162  public function eventCoreViewpmsgStart(){
163  global $xoopsOption;
164  $xoopsOption['module_subpage'] = 'pm';
165  }
166 
167 }