index.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2008 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 ***************************************************************/
00027 /**
00028  * Module: Log-viewing
00029  *
00030  * This module lets you view the changelog.
00031  *
00032  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00033  */
00034 
00035 
00036 $GLOBALS['LANG']->includeLLFile('EXT:belog/mod/locallang.xml');
00037 require_once (PATH_t3lib.'class.t3lib_bedisplaylog.php');
00038 require_once (PATH_t3lib.'class.t3lib_pagetree.php');
00039 
00040 $BE_USER->modAccess($MCONF,1);
00041 
00042 
00043 
00044 
00045 /**
00046  * Tools log script class
00047  *
00048  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00049  * @package TYPO3
00050  * @subpackage tx_belog
00051  */
00052 class SC_mod_tools_log_index {
00053     var $MCONF=array();
00054     var $MOD_MENU=array();
00055     var $MOD_SETTINGS=array();
00056 
00057     /**
00058      * Document template object
00059      *
00060      * @var noDoc
00061      */
00062     var $doc;
00063 
00064     var $content;
00065     var $lF;
00066     var $be_user_Array;
00067 
00068     /**
00069      * Initialize module
00070      *
00071      * @return  void
00072      */
00073     function init() {
00074         global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00075         $this->MCONF = $GLOBALS['MCONF'];
00076 
00077         $this->lF = t3lib_div::makeInstance('t3lib_BEDisplayLog');
00078         $this->menuConfig();
00079 
00080         $this->doc = t3lib_div::makeInstance('template');
00081         $this->doc->backPath = $BACK_PATH;
00082         $this->doc->setModuleTemplate('templates/belog.html');
00083 
00084                 // JavaScript
00085         $this->doc->JScode = '
00086         <script language="javascript" type="text/javascript">
00087             script_ended = 0;
00088             function jumpToUrl(URL) {
00089                 window.location.href = URL;
00090             }
00091         </script>
00092         ';
00093 
00094         $this->doc->tableLayout = Array (
00095             '0' => Array (
00096                 'defCol' => Array('<td valign="top" class="c-headLineTable"><b>', '</b></td><td class="c-headLineTable"><img src="' . $this->doc->backPath . 'clear.gif" width="10" height="1" alt="" /></td>')
00097             ),
00098             'defRow' => Array (
00099                 '0' => Array('<td valign="top">','</td>'),
00100                 'defCol' => Array('<td><img src="' . $this->doc->backPath . 'clear.gif" width="10" height="1" alt="" /></td><td valign="top">', '</td>')
00101             )
00102         );
00103         $this->doc->table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist">';
00104         $this->doc->form = '<form action="" method="post">';
00105 
00106         $this->be_user_Array = t3lib_BEfunc::getUserNames();
00107         $this->lF->be_user_Array = &$this->be_user_Array;
00108     }
00109 
00110     /**
00111      * Menu configuration
00112      *
00113      * @return  void
00114      */
00115     function menuConfig()   {
00116         global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00117 
00118             // MENU-ITEMS:
00119             // If array, then it's a selector box menu
00120             // If empty string it's just a variable, that'll be saved.
00121             // Values NOT in this array will not be saved in the settings-array for the module.
00122         $this->MOD_MENU = array(
00123             'users' => array(
00124                 0 => $GLOBALS['LANG']->getLL('allUsers'),
00125                 '-1' => $GLOBALS['LANG']->getLL('self')
00126             ),
00127             'time' => array(
00128                 0 => $GLOBALS['LANG']->getLL('thisWeek'),
00129                 1 => $GLOBALS['LANG']->getLL('lastWeek'),
00130                 2 => $GLOBALS['LANG']->getLL('last7Days'),
00131                 10 => $GLOBALS['LANG']->getLL('thisMonth'),
00132                 11 => $GLOBALS['LANG']->getLL('lastMonth'),
00133                 12 => $GLOBALS['LANG']->getLL('last31Days'),
00134                 20 => $GLOBALS['LANG']->getLL('noLimit')
00135             ),
00136             'max' => array(
00137                 20 => $GLOBALS['LANG']->getLL('20'),
00138                 50 => $GLOBALS['LANG']->getLL('50'),
00139                 100 => $GLOBALS['LANG']->getLL('100'),
00140                 200 => $GLOBALS['LANG']->getLL('200'),
00141                 500 => $GLOBALS['LANG']->getLL('500')
00142             ),
00143             'action' => array(
00144                 0 => $GLOBALS['LANG']->getLL('actionAll'),
00145                 1 => $GLOBALS['LANG']->getLL('actionDatabase'),
00146                 2 => $GLOBALS['LANG']->getLL('actionFile'),
00147                 254 => $GLOBALS['LANG']->getLL('actionSettings'),
00148                 255 => $GLOBALS['LANG']->getLL('actionLogin'),
00149                 '-1' => $GLOBALS['LANG']->getLL('actionErrors')
00150             )
00151         );
00152 
00153             // Adding groups to the users_array
00154         $groups = t3lib_BEfunc::getGroupNames();
00155         if (is_array($groups))  {
00156             while(list(,$grVals)=each($groups)) {
00157                 $this->MOD_MENU['users'][$grVals['uid']] = $GLOBALS['LANG']->getLL('userGroup') . ' ' . $grVals['title'];
00158             }
00159         }
00160 
00161             // CLEANSE SETTINGS
00162         $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00163     }
00164 
00165     /**
00166      * Main function
00167      *
00168      * @return  void
00169      */
00170     function main() {
00171         global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00172 
00173         $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('adminLog'));
00174         $this->content.=$this->doc->spacer(5);
00175 
00176 
00177             // Menu compiled:
00178         $menuU= t3lib_BEfunc::getFuncMenu(0,'SET[users]',$this->MOD_SETTINGS['users'],$this->MOD_MENU['users']);
00179         $menuM= t3lib_BEfunc::getFuncMenu(0,'SET[max]',$this->MOD_SETTINGS['max'],$this->MOD_MENU['max']);
00180         $menuT= t3lib_BEfunc::getFuncMenu(0,'SET[time]',$this->MOD_SETTINGS['time'],$this->MOD_MENU['time']);
00181         $menuA= t3lib_BEfunc::getFuncMenu(0,'SET[action]',$this->MOD_SETTINGS['action'],$this->MOD_MENU['action']);
00182 
00183 
00184         $this->content.=$this->doc->section('',$this->doc->menuTable(
00185             array(
00186                 array($GLOBALS['LANG']->getLL('users'), $menuU),
00187                 array($GLOBALS['LANG']->getLL('time'), $menuT)
00188             ),
00189             array(
00190                 array($GLOBALS['LANG']->getLL('max'), $menuM),
00191                 array($GLOBALS['LANG']->getLL('action'), $menuA)
00192             )
00193         ));
00194         $this->content.=$this->doc->divider(5);
00195 
00196 
00197         $codeArr = $this->lF->initArray();
00198         $oldHeader='';
00199         $c=0;
00200 
00201         // Action (type):
00202         $where_part='';
00203         if ($this->MOD_SETTINGS['action'] > 0)  {
00204             $where_part.=' AND type='.intval($this->MOD_SETTINGS['action']);
00205         } elseif ($this->MOD_SETTINGS['action'] == -1)  {
00206             $where_part.=' AND error';
00207         }
00208 
00209 
00210         $starttime=0;
00211         $endtime=time();
00212 
00213         // Time:
00214         switch($this->MOD_SETTINGS['time'])     {
00215             case 0:
00216                 // This week
00217                 $week = (date('w') ? date('w') : 7)-1;
00218                 $starttime = mktime (0,0,0)-$week*3600*24;
00219             break;
00220             case 1:
00221                 // Last week
00222                 $week = (date('w') ? date('w') : 7)-1;
00223                 $starttime = mktime (0,0,0)-($week+7)*3600*24;
00224                 $endtime = mktime (0,0,0)-$week*3600*24;
00225             break;
00226             case 2:
00227                 // Last 7 days
00228                 $starttime = mktime (0,0,0)-7*3600*24;
00229             break;
00230             case 10:
00231                 // This month
00232                 $starttime = mktime (0,0,0, date('m'),1);
00233             break;
00234             case 11:
00235                 // Last month
00236                 $starttime = mktime (0,0,0, date('m')-1,1);
00237                 $endtime = mktime (0,0,0, date('m'),1);
00238             break;
00239             case 12:
00240                 // Last 31 days
00241                 $starttime = mktime (0,0,0)-31*3600*24;
00242             break;
00243         }
00244         if ($starttime) {
00245             $where_part.=' AND tstamp>='.$starttime.' AND tstamp<'.$endtime;
00246         }
00247 
00248 
00249             // Users
00250         if ($this->MOD_SETTINGS['users'] > 0)   {   // All users
00251             $this->be_user_Array = t3lib_BEfunc::blindUserNames($this->be_user_Array,array($this->MOD_SETTINGS['users']),1);
00252             if (is_array($this->be_user_Array)) {
00253                 while(list(,$val)=each($this->be_user_Array))   {
00254                     if ($val['uid']!=$BE_USER->user['uid']) {
00255                         $selectUsers[]=$val['uid'];
00256                     }
00257                 }
00258             }
00259             $selectUsers[] = 0;
00260             $where_part.=' AND userid in ('.implode($selectUsers,',').')';
00261         } elseif ($this->MOD_SETTINGS['users']==-1) {
00262             $where_part.=' AND userid='.$BE_USER->user['uid'];  // Self user
00263         }
00264 
00265         if ($GLOBALS['BE_USER']->workspace!==0) {
00266             $where_part.=' AND workspace='.intval($GLOBALS['BE_USER']->workspace);
00267         }
00268 
00269 
00270 
00271 
00272         $log = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', '1=1'.$where_part, '', 'uid DESC', intval($this->MOD_SETTINGS['max']));
00273 
00274         while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($log))   {
00275             $header=$this->doc->formatTime($row['tstamp'],10);
00276             if (!$oldHeader)    $oldHeader=$header;
00277 
00278             if ($header!=$oldHeader)    {
00279                 $this->content.=$this->doc->spacer(10);
00280                 $this->content.=$this->doc->section($oldHeader,$this->doc->table($codeArr));
00281                 $codeArr=$this->lF->initArray();
00282                 $oldHeader=$header;
00283                 $this->lF->reset();
00284             }
00285 
00286             $i++;
00287             $codeArr[$i][]=$this->lF->getTimeLabel($row['tstamp']);
00288             $codeArr[$i][]=$this->lF->getUserLabel($row['userid'],$row['workspace']);
00289             $codeArr[$i][]=$this->lF->getTypeLabel($row['type']);
00290             $codeArr[$i][]=$row['error'] ? $this->lF->getErrorFormatting($this->lF->errorSign[$row['error']],$row['error']) : '';
00291             $codeArr[$i][]=$this->lF->getActionLabel($row['type'].'_'.$row['action']);
00292             $codeArr[$i][]=$this->lF->formatDetailsForList($row);
00293         }
00294         $this->content.=$this->doc->spacer(10);
00295         $this->content.=$this->doc->section($header,$this->doc->table($codeArr));
00296 
00297         $GLOBALS['TYPO3_DB']->sql_free_result($log);
00298 
00299             // Setting up the buttons and markers for docheader
00300         $docHeaderButtons = $this->getButtons();
00301         //$markers['CSH'] = $docHeaderButtons['csh'];
00302         $markers['CONTENT'] = $this->content;
00303 
00304             // Build the <body> for the module
00305         $this->content = $this->doc->startPage('Administration log');
00306         $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
00307         $this->content.= $this->doc->endPage();
00308         $this->content = $this->doc->insertStylesAndJS($this->content);
00309     }
00310 
00311     /**
00312      * Output content
00313      *
00314      * @return  string      HTML
00315      */
00316     function printContent() {
00317         echo $this->content;
00318     }
00319 
00320     /**
00321      * Create the panel of buttons for submitting the form or otherwise perform operations.
00322      *
00323      * @return  array   all available buttons as an assoc. array
00324      */
00325     protected function getButtons() {
00326 
00327         $buttons = array(
00328             'csh' => '',
00329             'shortcut' => ''
00330         );
00331             // CSH
00332         //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']);
00333 
00334             // Shortcut
00335         if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
00336             $buttons['shortcut'] = $this->doc->makeShortcutIcon('','users,time,max,action',$this->MCONF['name']);
00337         }
00338 
00339         return $buttons;
00340     }
00341 }
00342 
00343 
00344 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/belog/mod/index.php']) {
00345     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/belog/mod/index.php']);
00346 }
00347 
00348 
00349 
00350 // Make instance:
00351 $SOBE = t3lib_div::makeInstance('SC_mod_tools_log_index');
00352 $SOBE->init();
00353 $SOBE->main();
00354 $SOBE->printContent();
00355 ?>

Generated on Sat Jan 3 04:23:25 2009 for TYPO3 API by  doxygen 1.4.7