XOOPS  2.6.0
preload.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
13 
28 {
34  private static function getConfigs()
35  {
36  static $configs = null;
37 
38  if (is_null($configs)) {
40  $user_groups = $xoops->getUserGroups();
41  $moduleperm_handler = $xoops->getHandlerGroupperm();
42  $helper = $xoops->getModuleHelper('logger');
43  $mid = $helper->getModule()->getVar('mid');
44  if ($moduleperm_handler->checkRight('use_logger', 0, $user_groups, $mid)) {
45  // get default settings
46  $configs['logger_enable'] = $helper->getConfig('logger_enable');
47  $configs['logger_popup'] = $helper->getConfig('logger_popup');
48  $configs['debug_smarty_enable'] = $helper->getConfig('debug_smarty_enable');
49  // override with settings
50  $uchelper = $xoops->getModuleHelper('userconfigs');
51  if ($xoops->isUser() && $uchelper) {
52  $config_handler = $uchelper->getHandlerConfig();
53  $user_configs =
54  $config_handler->getConfigsByUser($xoops->user->getVar('uid'), $mid);
55  if (array_key_exists('logger_enable', $user_configs)) {
56  $configs['logger_enable'] = $user_configs['logger_enable'];
57  }
58  if (array_key_exists('logger_popup', $user_configs)) {
59  $configs['logger_popup'] = $user_configs['logger_popup'];
60  }
61  if (array_key_exists('debug_smarty_enable', $user_configs)) {
62  $configs['debug_smarty_enable'] = $user_configs['debug_smarty_enable'];
63  }
64  }
65  } else {
66  // user has no permissions, turn everything off
67  $configs['logger_enable'] = 0;
68  $configs['logger_popup'] = 0;
69  $configs['debug_smarty_enable'] = 0;
70  }
71  }
72 
73  return $configs;
74  }
75 
83  public static function eventCoreException($e)
84  {
85  LegacyLogger::getInstance()->addException($e);
86  }
87 
96  public static function eventCoreIncludeCommonClassmaps($args)
97  {
98  $path = dirname(__DIR__);
99  XoopsLoad::addMap(array(
100  'legacylogger' => $path . '/class/legacylogger.php',
101  ));
102  }
103 
111  public static function eventCoreIncludeCommonStart($args)
112  {
113  if (class_exists('LegacyLogger')) {
114  LegacyLogger::getInstance()->enable();//until we get a db connection debug is enabled
115  LegacyLogger::getInstance()->startTime();
116  LegacyLogger::getInstance()->startTime('XOOPS Boot');
117  }
118  }
119 
127  public static function eventCoreDatabaseNoconn($args)
128  {
129  if (!class_exists('LegacyLogger')) {
130  return;
131  }
132  /* @var $db Xoops\Core\Database\Connection */
133  $db = $args[0];
134  LegacyLogger::getInstance()->addQuery('', $db->error(), $db->errno());
135  }
136 
144  public static function eventCoreDatabaseNodb($args)
145  {
146  if (!class_exists('LegacyLogger')) {
147  return;
148  }
149  /* @var $db Xoops\Core\Database\Connection */
150  $db = $args[0];
151  LegacyLogger::getInstance()->addQuery('', $db->error(), $db->errno());
152  }
153 
161  public static function eventCoreDatabaseQueryComplete($args)
162  {
163  $sql = $args['sql'];
164  //XoopsLoad::addMap(array('legacylogger' => dirname(__DIR__) . '/class/legacylogger.php'));
165  LegacyLogger::getInstance()->addQuery($sql, null, null, $args['executionMS']);
166  }
167 
175  public static function eventCoreIncludeCommonConfigsSuccess($args)
176  {
177  /*
178  $xoops = Xoops::getInstance();
179  $logger = LegacyLogger::getInstance();
180  $configs = self::getConfigs();
181  if ($configs['logger_enable']) {
182  $xoops->loadLocale();
183  $xoops->loadLanguage('main', 'logger');
184  $logger->enable();
185  } else {
186  $xoops->disableErrorReporting();
187  }
188  */
189  }
190 
196  public static function eventCoreIncludeCommonAuthSuccess()
197  {
199  $logger = LegacyLogger::getInstance();
200  $configs = self::getConfigs();
201  if ($configs['logger_enable']) {
202  $xoops->loadLocale();
203  $xoops->loadLanguage('main', 'logger');
204  $logger->setConfigs($configs);
205  $logger->enable();
206  } else {
207  $logger->disable();
208  }
209  }
210 
218  public static function eventCoreIncludeCommonEnd($args)
219  {
220  $logger = LegacyLogger::getInstance();
221  $logger->stopTime('XOOPS Boot');
222  $logger->startTime('Module init');
223  }
224 
232  public static function eventCoreTemplateConstructStart($args)
233  {
234  $tpl = $args[0];
235  $configs = self::getConfigs();
236  if ($configs['logger_enable']) {
237  $tpl->debugging_ctrl = 'URL';
238  }
239  if ($configs['debug_smarty_enable']) {
240  $tpl->debugging = true;
241  }
242  }
243 
251  public static function eventCoreThemeRenderStart($args)
252  {
253  LegacyLogger::getInstance()->startTime('Page rendering');
254  }
255 
263  public static function eventCoreThemeRenderEnd($args)
264  {
265  LegacyLogger::getInstance()->stopTime('Page rendering');
266  }
267 
275  public static function eventCoreThemeCheckcacheSuccess($args)
276  {
277  $template = $args[0];
278  $theme = $args[1];
280  ->addExtra($template, sprintf('Cached (regenerates every %d seconds)', $theme->contentCacheLifetime));
281  }
282 
290  public static function eventCoreThemeblocksBuildblockStart($args)
291  {
292  /* @var $block XoopsBlock */
293  $block = $args[0];
294  $isCached= $args[1];
295  LegacyLogger::getInstance()->addBlock($block->getVar('name'), $isCached, $block->getVar('bcachetime'));
296  }
297 
305  public static function eventCoreDeprecated($args)
306  {
307  $message = $args[0];
308  LegacyLogger::getInstance()->addDeprecated($message);
309  }
310 
318  public static function eventCoreDisableerrorreporting($args)
319  {
320  LegacyLogger::getInstance()->disable();
321  }
322 
330  public static function eventCoreHeaderStart($args)
331  {
332  $logger = LegacyLogger::getInstance();
333  $logger->stopTime('Module init');
334  $logger->startTime('XOOPS output init');
335  }
336 
344  public static function eventCoreHeaderEnd($args)
345  {
346  $logger = LegacyLogger::getInstance();
347  $logger->stopTime('XOOPS output init');
348  $logger->startTime('Module display');
349  }
350 
358  public static function eventCoreFooterStart($args)
359  {
360  $logger = LegacyLogger::getInstance();
361  $logger->stopTime('Module display');
362  }
363 
371  public static function eventCoreFooterEnd($args)
372  {
373  $logger = LegacyLogger::getInstance();
374  $logger->stopTime();
375  }
376 
384  public static function eventCoreIncludeFunctionsRedirectheaderEnd($args)
385  {
387  $logger = LegacyLogger::getInstance();
388  $debug_mode = $xoops->getModuleConfig('debug_mode', 'logger');
389  if ($debug_mode == 2) {
390  //Should we give extra time ?
391  //$xoops->tpl()->assign('time', 300);
392  $xoops->tpl()->assign('xoops_logdump', $logger->dump());
393  }
394  }
395 
403  public static function eventCoreSecurityValidatetokenEnd($args)
404  {
405  $logger = LegacyLogger::getInstance();
406  $logs = $args[0];
407  foreach ($logs as $log) {
408  $logger->addExtra($log[0], $log[1]);
409  }
410  }
411 
419  public static function eventCoreModuleAddlog($args)
420  {
421  LegacyLogger::getInstance()->addExtra($args[0], $args[1]);
422  }
423 
431  public static function eventSystemPreferencesSave($args)
432  {
433  XoopsLoad::addMap(array('legacylogger' => dirname(__DIR__) . '/class/legacylogger.php'));
434  }
435 }
$mid
Definition: index.php:39
static eventCoreHeaderEnd($args)
Definition: preload.php:344
$tpl
Definition: backend.php:39
$path
Definition: execute.php:31
static eventCoreFooterStart($args)
Definition: preload.php:358
static eventCoreFooterEnd($args)
Definition: preload.php:371
static eventCoreThemeRenderEnd($args)
Definition: preload.php:263
static getInstance()
static eventCoreModuleAddlog($args)
Definition: preload.php:419
static eventCoreThemeRenderStart($args)
Definition: preload.php:251
static getInstance()
Definition: Xoops.php:160
static eventCoreThemeblocksBuildblockStart($args)
Definition: preload.php:290
static eventCoreIncludeCommonEnd($args)
Definition: preload.php:218
static eventCoreIncludeCommonAuthSuccess()
Definition: preload.php:196
static eventCoreDatabaseNoconn($args)
Definition: preload.php:127
$xoops
Definition: admin.php:25
static eventCoreIncludeCommonClassmaps($args)
Definition: preload.php:96
static eventCoreIncludeCommonStart($args)
Definition: preload.php:111
static eventCoreDatabaseQueryComplete($args)
Definition: preload.php:161
static eventCoreIncludeFunctionsRedirectheaderEnd($args)
Definition: preload.php:384
static eventCoreHeaderStart($args)
Definition: preload.php:330
if($_SERVER['REQUEST_METHOD']== 'POST') $config_handler
static eventCoreDatabaseNodb($args)
Definition: preload.php:144
static getConfigs()
Definition: preload.php:34
static eventCoreDeprecated($args)
Definition: preload.php:305
static eventCoreException($e)
Definition: preload.php:83
static eventCoreTemplateConstructStart($args)
Definition: preload.php:232
$configs
Definition: config.php:27
static eventCoreDisableerrorreporting($args)
Definition: preload.php:318
$sql
Definition: pda.php:32
$helper
static eventSystemPreferencesSave($args)
Definition: preload.php:431
static eventCoreIncludeCommonConfigsSuccess($args)
Definition: preload.php:175
static eventCoreSecurityValidatetokenEnd($args)
Definition: preload.php:403
$moduleperm_handler
Definition: cp_header.php:31
static addMap(array $map)
Definition: xoopsload.php:40
static eventCoreThemeCheckcacheSuccess($args)
Definition: preload.php:275