"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/belog/class.tx_belog_webinfo.php Source File", "datetime" => "Sat Dec 2 19:22:27 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

class.tx_belog_webinfo.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 ***************************************************************/
00055 require_once(PATH_t3lib.'class.t3lib_pagetree.php');
00056 require_once(PATH_t3lib.'class.t3lib_bedisplaylog.php');
00057 
00065 class logFunctions_ext extends t3lib_BEDisplayLog {
00066 
00072         function initArray()    {
00073                 global $LANG;
00074                 $codeArr=Array();
00075                 $codeArr[$i][]=$LANG->getLL('chLog_l_time');
00076                 $codeArr[$i][]=$LANG->getLL('chLog_l_user');
00077                 $codeArr[$i][]=$LANG->getLL('chLog_l_error');
00078                 $codeArr[$i][]=$LANG->getLL('chLog_l_action');
00079                 $codeArr[$i][]=$LANG->getLL('chLog_l_table');
00080                 $codeArr[$i][]=$LANG->getLL('chLog_l_details');
00081                 return $codeArr;
00082         }
00083 }
00084 
00085 
00086 
00087 
00088 require_once(PATH_t3lib.'class.t3lib_extobjbase.php');
00089 
00097 class tx_belog_webinfo extends t3lib_extobjbase {
00098         var $localLangFile = 'locallang.php';
00099 
00105         function modMenu()      {
00106                 global $LANG;
00107 
00108                 return array(
00109                         'log_users' => array(
00110                                 0 => $LANG->getLL('chLog_users_0'),
00111                                 '-1' => $LANG->getLL('chLog_users_-1')
00112                         ),
00113                         'log_time' => array(
00114                                 0 => $LANG->getLL('chLog_time_0'),
00115                                 1 => $LANG->getLL('chLog_time_1'),
00116                                 2 => $LANG->getLL('chLog_time_2'),
00117                                 10 => $LANG->getLL('chLog_time_10'),
00118                                 11 => $LANG->getLL('chLog_time_11'),
00119                                 12 => $LANG->getLL('chLog_time_12'),
00120                                 20 => $LANG->getLL('chLog_time_20')
00121                         ),
00122                         'depth' => array(
00123                                 0 => $LANG->getLL('depth_0'),
00124                                 1 => $LANG->getLL('depth_1'),
00125                                 2 => $LANG->getLL('depth_2'),
00126                                 3 => $LANG->getLL('depth_3')
00127                         )
00128                 );
00129         }
00130 
00136         function localLang()    {
00137                 $LOCAL_LANG = $GLOBALS['LANG']->includeLLFile('EXT:belog/mod/locallang.xml',FALSE);
00138 
00139                 $GLOBALS['LOCAL_LANG']=t3lib_div::array_merge_recursive_overrule($GLOBALS['LOCAL_LANG'],$LOCAL_LANG);
00140         }
00141 
00147         function main() {
00148                 global $SOBE,$LANG;
00149 
00150                 $this->localLang();
00151 
00152                 $lF = t3lib_div::makeInstance('logFunctions_ext');
00153 
00154                 $theOutput='';
00155                 $menu='';
00156                 $menu.=  '&nbsp;'.$LANG->getLL('chLog_menuUsers').': '.t3lib_BEfunc::getFuncMenu($this->pObj->id,'SET[log_users]',$this->pObj->MOD_SETTINGS['log_users'],$this->pObj->MOD_MENU['log_users']);
00157                 $menu.=  '&nbsp;'.$LANG->getLL('chLog_menuDepth').': '.t3lib_BEfunc::getFuncMenu($this->pObj->id,'SET[depth]',$this->pObj->MOD_SETTINGS['depth'],$this->pObj->MOD_MENU['depth']);
00158                 $menu.=  '&nbsp;'.$LANG->getLL('chLog_menuTime').': '.t3lib_BEfunc::getFuncMenu($this->pObj->id,'SET[log_time]',$this->pObj->MOD_SETTINGS['log_time'],$this->pObj->MOD_MENU['log_time']);
00159                 $theOutput.=$this->pObj->doc->section($LANG->getLL('chLog_title'),'<span class="nobr">'.$menu.'</span>',0,1);
00160 
00161                         // Build query
00162                 $where_part='';
00163 
00164                         // Get the id-list of pages for the tree structure.
00165                 $tree = t3lib_div::makeInstance('t3lib_pageTree');
00166                 $tree->init('AND '.$this->pObj->perms_clause);
00167                 $tree->makeHTML=0;
00168                 $tree->fieldArray = Array('uid');
00169                 if ($this->pObj->MOD_SETTINGS['depth']) {
00170                         $tree->getTree($this->pObj->id, $this->pObj->MOD_SETTINGS['depth'], '');
00171                 }
00172                 $tree->ids[]=$this->pObj->id;
00173                 $idList = implode($tree->ids,',');
00174 
00175                 $where_part.=' AND (event_pid in ('.$idList.'))';               // DB
00176 
00177                         // Time:
00178                 $starttime=0;
00179                 $endtime=time();
00180                 switch($this->pObj->MOD_SETTINGS['log_time'])           {
00181                         case 0:
00182                                 // This week
00183                                 $week = (date('w') ? date('w') : 7)-1;
00184                                 $starttime = mktime (0,0,0)-$week*3600*24;
00185                         break;
00186                         case 1:
00187                                 // Last week
00188                                 $week = (date('w') ? date('w') : 7)-1;
00189                                 $starttime = mktime (0,0,0)-($week+7)*3600*24;
00190                                 $endtime = mktime (0,0,0)-$week*3600*24;
00191                         break;
00192                         case 2:
00193                                 // Last 7 days
00194                                 $starttime = mktime (0,0,0)-7*3600*24;
00195                         break;
00196                         case 10:
00197                                 // This month
00198                                 $starttime = mktime (0,0,0, date('m'),1);
00199                         break;
00200                         case 11:
00201                                 // Last month
00202                                 $starttime = mktime (0,0,0, date('m')-1,1);
00203                                 $endtime = mktime (0,0,0, date('m'),1);
00204                         break;
00205                         case 12:
00206                                 // Last 31 days
00207                                 $starttime = mktime (0,0,0)-31*3600*24;
00208                         break;
00209                 }
00210                 if ($starttime) {
00211                         $where_part.=' AND tstamp>='.$starttime.' AND tstamp<'.$endtime;
00212                 }
00213 
00214                 $where_part.=' AND type=1';             // DB
00215 
00216 
00217                         // Users
00218                 $this->pObj->be_user_Array = t3lib_BEfunc::getUserNames();
00219                 if (!$this->pObj->MOD_SETTINGS['log_users'])    {       // All users
00220                                 // Get usernames and groupnames
00221                         if (!$GLOBALS['BE_USER']->isAdmin())            {
00222                                 $groupArray = explode(',',$GLOBALS['BE_USER']->user['usergroup_cached_list']);
00223                                 $this->pObj->be_user_Array = t3lib_BEfunc::blindUserNames($this->pObj->be_user_Array,$groupArray,1);
00224                         }
00225 
00226                         if (is_array($this->pObj->be_user_Array))       {
00227                                 while(list(,$val)=each($this->pObj->be_user_Array))     {
00228                                         $selectUsers[]=$val['uid'];
00229                                 }
00230                         }
00231                         $selectUsers[] = $GLOBALS['BE_USER']->user['uid'];
00232                         $where_part.=' AND userid in ('.implode($selectUsers,',').')';
00233                 } else {
00234                         $where_part.=' AND userid='.$GLOBALS['BE_USER']->user['uid'];   // Self user
00235                 }
00236 
00237                 if ($GLOBALS['BE_USER']->workspace!==0) {
00238                         $where_part.=' AND workspace='.intval($GLOBALS['BE_USER']->workspace);
00239                 }
00240 
00241 
00242                         // Select 100 recent log entries:
00243                 $log = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', '1=1'.$where_part, '', 'uid DESC', 100);
00244 
00245                 $codeArr = $lF->initArray();
00246                 $oldHeader = '';
00247                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($log))       {
00248                         $header = $this->pObj->doc->formatTime($row['tstamp'],10);
00249                         if (!$oldHeader)        $oldHeader = $header;
00250 
00251                         if ($header!=$oldHeader)        {
00252                                 $theOutput.=$this->pObj->doc->spacer(10);
00253                                 $theOutput.=$this->pObj->doc->section($oldHeader,$this->pObj->doc->table($codeArr));
00254                                 $codeArr=$lF->initArray();
00255                                 $oldHeader=$header;
00256                                 $lF->reset();
00257                         }
00258 
00259                         $i++;
00260                         $codeArr[$i][]=$lF->getTimeLabel($row['tstamp']);
00261                         $codeArr[$i][]=$lF->getUserLabel($row['userid'],$row['workspace']);
00262                         $codeArr[$i][]=$row['error'] ? $lF->getErrorFormatting($lF->errorSign[$row['error']],$row['error']) : '';
00263                         $codeArr[$i][]=$lF->getActionLabel($row['type'].'_'.$row['action']);
00264                         $codeArr[$i][]=$row['tablename'];
00265                         $codeArr[$i][]=$lF->formatDetailsForList($row);
00266                 }
00267                 $theOutput.=$this->pObj->doc->spacer(10);
00268                 $theOutput.=$this->pObj->doc->section($header,$this->pObj->doc->table($codeArr));
00269 
00270                 $GLOBALS['TYPO3_DB']->sql_free_result($log);
00271 
00272                 return $theOutput;
00273         }
00274 }
00275 
00276 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/belog/class.tx_belog_webinfo.php'])    {
00277         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/belog/class.tx_belog_webinfo.php']);
00278 }
00279 
00280 ?>