/src/typo3_src-4.2.0alpha1/typo3/sysext/belog/mod/index.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00036 #unset($MCONF);
00037 #require ('conf.php');
00038 #require ($BACK_PATH.'init.php');
00039 #require ($BACK_PATH.'template.php');
00040 $LANG->includeLLFile('EXT:belog/mod/locallang.php');
00041 require_once (PATH_t3lib.'class.t3lib_bedisplaylog.php');
00042 require_once (PATH_t3lib.'class.t3lib_pagetree.php');
00043 
00044 $BE_USER->modAccess($MCONF,1);
00045 
00046 
00047 
00048 
00056 class SC_mod_tools_log_index {
00057         var $MCONF=array();
00058         var $MOD_MENU=array();
00059         var $MOD_SETTINGS=array();
00060 
00066         var $doc;
00067 
00068         var $content;
00069         var $lF;
00070         var $be_user_Array;
00071 
00077         function init() {
00078                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00079                 $this->MCONF = $GLOBALS['MCONF'];
00080 
00081                 $this->lF = t3lib_div::makeInstance('t3lib_BEDisplayLog');
00082                 $this->menuConfig();
00083 
00084                 $this->doc = t3lib_div::makeInstance('noDoc');
00085                 $this->doc->backPath = $BACK_PATH;
00086 
00087                                 // JavaScript
00088                 $this->doc->JScode = '
00089                 <script language="javascript" type="text/javascript">
00090                         script_ended = 0;
00091                         function jumpToUrl(URL) {
00092                                 window.location.href = URL;
00093                         }
00094                 </script>
00095                 ';
00096 
00097                 $this->doc->tableLayout = Array (
00098                         '0' => Array (
00099                                 '0' => Array('<td valign="top"><b>','</b></td>'),
00100                                 'defCol' => Array('<td><img src="'.$this->doc->backPath.'clear.gif" width="10" height="1"></td><td valign="top"><b>','</b></td>')
00101                         ),
00102                         'defRow' => Array (
00103                                 '0' => Array('<td valign="top">','</td>'),
00104                                 'defCol' => Array('<td><img src="'.$this->doc->backPath.'clear.gif" width="10" height="1"></td><td valign="top">','</td>')
00105                         )
00106                 );
00107                 $this->doc->form = '<form action="" method="post">';
00108 
00109                 $this->be_user_Array = t3lib_BEfunc::getUserNames();
00110                 $this->lF->be_user_Array = &$this->be_user_Array;
00111         }
00112 
00118         function menuConfig()   {
00119                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00120 
00121                         // MENU-ITEMS:
00122                         // If array, then it's a selector box menu
00123                         // If empty string it's just a variable, that'll be saved.
00124                         // Values NOT in this array will not be saved in the settings-array for the module.
00125                 $this->MOD_MENU = array(
00126                         'users' => array(
00127                                 0 => 'All users',
00128                                 '-1' => 'Self'
00129                         ),
00130                         'time' => array(
00131                                 0 => 'This week',
00132                                 1 => 'Last week',
00133                                 2 => 'Last 7 days',
00134                                 10 => 'This month',
00135                                 11 => 'Last month',
00136                                 12 => 'Last 31 days',
00137                                 20 => 'No limit'
00138                         ),
00139                         'max' => array(
00140                                 20 => '20',
00141                                 50 => '50',
00142                                 100 => '100',
00143                                 200 => '200',
00144                                 500 => '500'
00145                         ),
00146                         'action' => array(
00147                                 0 => 'All',
00148                                 1 => 'Database',
00149                                 2 => 'File',
00150                                 254 => 'Settings',
00151                                 255 => 'Login',
00152                                 '-1' => 'Errors'
00153                         )
00154                 );
00155 
00156                         // Adding groups to the users_array
00157                 $groups = t3lib_BEfunc::getGroupNames();
00158                 if (is_array($groups))  {
00159                         while(list(,$grVals)=each($groups))     {
00160                                 $this->MOD_MENU['users'][$grVals['uid']] = 'Group: '.$grVals['title'];
00161                         }
00162                 }
00163 
00164                         // CLEANSE SETTINGS
00165                 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00166         }
00167 
00173         function main() {
00174                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00175 
00176                 $this->content.=$this->doc->startPage('Administration log');
00177                 $this->content.=$this->doc->header('Administration log');
00178                 $this->content.=$this->doc->spacer(5);
00179 
00180 
00181                         // Menu compiled:
00182                 $menuU= t3lib_BEfunc::getFuncMenu(0,'SET[users]',$this->MOD_SETTINGS['users'],$this->MOD_MENU['users']);
00183                 $menuM= t3lib_BEfunc::getFuncMenu(0,'SET[max]',$this->MOD_SETTINGS['max'],$this->MOD_MENU['max']);
00184                 $menuT= t3lib_BEfunc::getFuncMenu(0,'SET[time]',$this->MOD_SETTINGS['time'],$this->MOD_MENU['time']);
00185                 $menuA= t3lib_BEfunc::getFuncMenu(0,'SET[action]',$this->MOD_SETTINGS['action'],$this->MOD_MENU['action']);
00186 
00187 
00188                 $this->content.=$this->doc->section('',$this->doc->menuTable(
00189                         array(
00190                                 array('Users:',$menuU),
00191                                 array('Time:',$menuT)
00192                         ),
00193                         array(
00194                                 array('Max:',$menuM),
00195                                 array('Action:',$menuA)
00196                         )
00197                 ));
00198                 $this->content.=$this->doc->divider(5);
00199 
00200 
00201                 $codeArr = $this->lF->initArray();
00202                 $oldHeader='';
00203                 $c=0;
00204 
00205                 // Action (type):
00206                 $where_part='';
00207                 if ($this->MOD_SETTINGS['action'] > 0)  {
00208                         $where_part.=' AND type='.intval($this->MOD_SETTINGS['action']);
00209                 } elseif ($this->MOD_SETTINGS['action'] == -1)  {
00210                         $where_part.=' AND error';
00211                 }
00212 
00213 
00214                 $starttime=0;
00215                 $endtime=time();
00216 
00217                 // Time:
00218                 switch($this->MOD_SETTINGS['time'])             {
00219                         case 0:
00220                                 // This week
00221                                 $week = (date('w') ? date('w') : 7)-1;
00222                                 $starttime = mktime (0,0,0)-$week*3600*24;
00223                         break;
00224                         case 1:
00225                                 // Last week
00226                                 $week = (date('w') ? date('w') : 7)-1;
00227                                 $starttime = mktime (0,0,0)-($week+7)*3600*24;
00228                                 $endtime = mktime (0,0,0)-$week*3600*24;
00229                         break;
00230                         case 2:
00231                                 // Last 7 days
00232                                 $starttime = mktime (0,0,0)-7*3600*24;
00233                         break;
00234                         case 10:
00235                                 // This month
00236                                 $starttime = mktime (0,0,0, date('m'),1);
00237                         break;
00238                         case 11:
00239                                 // Last month
00240                                 $starttime = mktime (0,0,0, date('m')-1,1);
00241                                 $endtime = mktime (0,0,0, date('m'),1);
00242                         break;
00243                         case 12:
00244                                 // Last 31 days
00245                                 $starttime = mktime (0,0,0)-31*3600*24;
00246                         break;
00247                 }
00248                 if ($starttime) {
00249                         $where_part.=' AND tstamp>='.$starttime.' AND tstamp<'.$endtime;
00250                 }
00251 
00252 
00253                         // Users
00254                 if ($this->MOD_SETTINGS['users'] > 0)   {       // All users
00255                         $this->be_user_Array = t3lib_BEfunc::blindUserNames($this->be_user_Array,array($this->MOD_SETTINGS['users']),1);
00256                         if (is_array($this->be_user_Array))     {
00257                                 while(list(,$val)=each($this->be_user_Array))   {
00258                                         if ($val['uid']!=$BE_USER->user['uid']) {
00259                                                 $selectUsers[]=$val['uid'];
00260                                         }
00261                                 }
00262                         }
00263                         $selectUsers[] = 0;
00264                         $where_part.=' AND userid in ('.implode($selectUsers,',').')';
00265                 } elseif ($this->MOD_SETTINGS['users']==-1) {
00266                         $where_part.=' AND userid='.$BE_USER->user['uid'];      // Self user
00267                 }
00268 
00269                 if ($GLOBALS['BE_USER']->workspace!==0) {
00270                         $where_part.=' AND workspace='.intval($GLOBALS['BE_USER']->workspace);
00271                 }
00272 
00273 
00274 
00275 
00276                 $log = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', '1=1'.$where_part, '', 'uid DESC', intval($this->MOD_SETTINGS['max']));
00277 
00278                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($log))       {
00279                         $header=$this->doc->formatTime($row['tstamp'],10);
00280                         if (!$oldHeader)        $oldHeader=$header;
00281 
00282                         if ($header!=$oldHeader)        {
00283                                 $this->content.=$this->doc->spacer(10);
00284                                 $this->content.=$this->doc->section($oldHeader,$this->doc->table($codeArr));
00285                                 $codeArr=$this->lF->initArray();
00286                                 $oldHeader=$header;
00287                                 $this->lF->reset();
00288                         }
00289 
00290                         $i++;
00291                         $codeArr[$i][]=$this->lF->getTimeLabel($row['tstamp']);
00292                         $codeArr[$i][]=$this->lF->getUserLabel($row['userid'],$row['workspace']);
00293                         $codeArr[$i][]=$this->lF->getTypeLabel($row['type']);
00294                         $codeArr[$i][]=$row['error'] ? $this->lF->getErrorFormatting($this->lF->errorSign[$row['error']],$row['error']) : '';
00295                         $codeArr[$i][]=$this->lF->getActionLabel($row['type'].'_'.$row['action']);
00296                         $codeArr[$i][]=$this->lF->formatDetailsForList($row);
00297                 }
00298                 $this->content.=$this->doc->spacer(10);
00299                 $this->content.=$this->doc->section($header,$this->doc->table($codeArr));
00300 
00301                 $GLOBALS['TYPO3_DB']->sql_free_result($log);
00302 
00303                 if ($BE_USER->mayMakeShortcut())        {
00304                         $this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon('','users,time,max,action',$this->MCONF['name']));
00305                 }
00306         }
00307 
00313         function printContent() {
00314 
00315                 $this->content.=$this->doc->spacer(20);
00316                 $this->content.=$this->doc->endPage();
00317                 echo $this->content;
00318         }
00319 }
00320 
00321 // Include extension?
00322 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/belog/mod/index.php']) {
00323         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/belog/mod/index.php']);
00324 }
00325 
00326 
00327 
00328 
00329 
00330 
00331 
00332 
00333 
00334 
00335 
00336 
00337 // Make instance:
00338 $SOBE = t3lib_div::makeInstance('SC_mod_tools_log_index');
00339 $SOBE->init();
00340 $SOBE->main();
00341 $SOBE->printContent();
00342 ?>

This documentation has been generated automatically from TYPO3 source code using Doxygen and is provided as is by Cast Iron Coding as a courtesy to other TYPO3 developers and users. Please consider Cast Iron Coding — a full-service web development agency in Portland, Oregon specializing in TYPO3 extension development — for all of your TYPO3 development and consulting needs!