Documentation TYPO3 par Ameos

class.tx_belog_webinfo.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 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 ***************************************************************/
00032 require_once(PATH_t3lib."class.t3lib_pagetree.php");
00033 require_once(PATH_t3lib."class.t3lib_bedisplaylog.php");
00034 class logFunctions_ext extends t3lib_BEDisplayLog {
00035         function initArray()    {
00036                 global $LANG;
00037                 $codeArr=Array();
00038                 $codeArr[$i][]=$LANG->getLL("chLog_l_time");
00039                 $codeArr[$i][]=$LANG->getLL("chLog_l_user");
00040                 $codeArr[$i][]=$LANG->getLL("chLog_l_error");
00041                 $codeArr[$i][]=$LANG->getLL("chLog_l_action");
00042                 $codeArr[$i][]=$LANG->getLL("chLog_l_table");
00043                 $codeArr[$i][]=$LANG->getLL("chLog_l_details");
00044                 return $codeArr;
00045         }
00046 }
00047 
00048 
00049 require_once(PATH_t3lib."class.t3lib_extobjbase.php");
00050 
00051 class tx_belog_webinfo extends t3lib_extobjbase {
00052         var $localLangFile = "locallang.php";
00053 
00054         function modMenu()      {
00055                 global $LANG;
00056 
00057                 return array(
00058                         "log_users" => array(
00059                                 0 => $LANG->getLL("chLog_users_0"),
00060                                 "-1" => $LANG->getLL("chLog_users_-1")
00061                         ),
00062                         "log_time" => array(
00063                                 0 => $LANG->getLL("chLog_time_0"),
00064                                 1 => $LANG->getLL("chLog_time_1"),
00065                                 2 => $LANG->getLL("chLog_time_2"),
00066                                 10 => $LANG->getLL("chLog_time_10"),
00067                                 11 => $LANG->getLL("chLog_time_11"),
00068                                 12 => $LANG->getLL("chLog_time_12"),
00069                                 20 => $LANG->getLL("chLog_time_20")
00070                         ),
00071                         "depth" => array(
00072                                 0 => $LANG->getLL("depth_0"),
00073                                 1 => $LANG->getLL("depth_1"),
00074                                 2 => $LANG->getLL("depth_2"),
00075                                 3 => $LANG->getLL("depth_3")
00076                         )
00077                 );
00078         }
00079 
00080         // ***********************************
00081         // MAIN function for log display
00082         // ***********************************
00083         function localLang()    {
00084                 include_once($this->thisPath."/mod/locallang.php");
00085                 $GLOBALS["LOCAL_LANG"]=t3lib_div::array_merge_recursive_overrule($GLOBALS["LOCAL_LANG"],$LOCAL_LANG);
00086         }
00087 
00093         function main() {
00094                 global $SOBE,$LANG;
00095 
00096                 $this->localLang();
00097 
00098                 $lF = t3lib_div::makeInstance("logFunctions_ext");
00099 
00100                 $theOutput="";
00101                 $menu="";
00102                 $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"]);
00103                 $menu.=  "&nbsp;".$LANG->getLL("chLog_menuDepth").": ".t3lib_BEfunc::getFuncMenu($this->pObj->id,"SET[depth]",$this->pObj->MOD_SETTINGS["depth"],$this->pObj->MOD_MENU["depth"]);
00104                 $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"]);
00105                 $theOutput.=$this->pObj->doc->section($LANG->getLL("chLog_title"),'<span class="nobr">'.$menu.'</span>',0,1);
00106 
00107                 // Build query
00108 
00109                 $where_part="";
00110 
00111                 // Get the idlist of pages for the treestructure.
00112                 $tree = t3lib_div::makeInstance("t3lib_pageTree");
00113                 $tree->init("AND ".$this->pObj->perms_clause);
00114                 $tree->makeHTML=0;
00115                 $tree->fieldArray = Array("uid");
00116                 if ($this->pObj->MOD_SETTINGS["depth"]) {
00117                         $tree->getTree($this->pObj->id, $this->pObj->MOD_SETTINGS["depth"], "");
00118                 }
00119                 $tree->ids[]=$this->pObj->id;
00120                 $idList = implode($tree->ids,",");
00121 
00122                 //$where_part.=" AND ((tablename='pages' and recuid in (".$idList.")) OR (tablename!='pages' and recpid in (".$idList.")))";            // DB
00123                 $where_part.=" AND (event_pid in (".$idList."))";               // DB
00124 
00125                 // Time:
00126                 $starttime=0;
00127                 $endtime=time();
00128                 switch($this->pObj->MOD_SETTINGS["log_time"])           {
00129                         case 0:
00130                                 // This week
00131                                 $week = (date("w") ? date("w") : 7)-1;
00132                                 $starttime = mktime (0,0,0)-$week*3600*24;
00133                         break;
00134                         case 1:
00135                                 // Last week
00136                                 $week = (date("w") ? date("w") : 7)-1;
00137                                 $starttime = mktime (0,0,0)-($week+7)*3600*24;
00138                                 $endtime = mktime (0,0,0)-$week*3600*24;
00139                         break;
00140                         case 2:
00141                                 // Last 7 days
00142                                 $starttime = mktime (0,0,0)-7*3600*24;
00143                         break;
00144                         case 10:
00145                                 // This month
00146                                 $starttime = mktime (0,0,0, date("m"),1);
00147                         break;
00148                         case 11:
00149                                 // Last month
00150                                 $starttime = mktime (0,0,0, date("m")-1,1);
00151                                 $endtime = mktime (0,0,0, date("m"),1);
00152                         break;
00153                         case 12:
00154                                 // Last 31 days
00155                                 $starttime = mktime (0,0,0)-31*3600*24;
00156                         break;
00157                 }
00158                 if ($starttime) {
00159                         $where_part.=" AND tstamp>=".$starttime." AND tstamp<".$endtime;
00160                 }
00161 
00162                 $where_part.=" AND type=1";             // DB
00163 
00164 
00165                         // Users
00166                 $this->pObj->be_user_Array = t3lib_BEfunc::getUserNames();
00167                 if (!$this->pObj->MOD_SETTINGS["log_users"])    {       // All users
00168                                 // Get usernames and groupnames
00169                         if (!$GLOBALS["BE_USER"]->isAdmin())            {
00170                                 $groupArray = explode(",",$GLOBALS["BE_USER"]->user["usergroup_cached_list"]);
00171                                 $this->pObj->be_user_Array = t3lib_BEfunc::blindUserNames($this->pObj->be_user_Array,$groupArray,1);
00172                         }
00173 
00174                         if (is_array($this->pObj->be_user_Array))       {
00175                                 while(list(,$val)=each($this->pObj->be_user_Array))     {
00176                                         $selectUsers[]=$val["uid"];
00177                                 }
00178                         }
00179                         $selectUsers[] = $GLOBALS["BE_USER"]->user["uid"];
00180                         $where_part.=" AND userid in (".implode($selectUsers,",").")";
00181                 } else {
00182                         $where_part.=" AND userid=".$GLOBALS["BE_USER"]->user["uid"];   // Self user
00183                 }
00184 
00185 
00186 
00187 
00188 
00189                 $log = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', '1=1'.$where_part, '', 'uid DESC', 100);
00190 
00191                 $codeArr = $lF->initArray();
00192                 $oldHeader = "";
00193                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($log))       {
00194                         $header = $this->pObj->doc->formatTime($row["tstamp"],10);
00195                         if (!$oldHeader)        $oldHeader = $header;
00196 
00197                         if ($header!=$oldHeader)        {
00198                                 $theOutput.=$this->pObj->doc->spacer(10);
00199                                 $theOutput.=$this->pObj->doc->section($oldHeader,$this->pObj->doc->table($codeArr));
00200                                 $codeArr=$lF->initArray();
00201                                 $oldHeader=$header;
00202                                 $lF->reset();
00203                         }
00204 
00205                         $i++;
00206                         $codeArr[$i][]=$lF->getTimeLabel($row["tstamp"]);
00207                         $codeArr[$i][]=$lF->getUserLabel($row["userid"]);
00208                         $codeArr[$i][]=$row["error"] ? $lF->getErrorFormatting($lF->errorSign[$row["error"]]) : "";
00209                         $codeArr[$i][]=$lF->getActionLabel($row["type"]."_".$row["action"]);
00210                         $codeArr[$i][]=$row["tablename"];
00211                         $codeArr[$i][]=$lF->formatDetailsForList($row);
00212                 }
00213                 $theOutput.=$this->pObj->doc->spacer(10);
00214                 $theOutput.=$this->pObj->doc->section($header,$this->pObj->doc->table($codeArr));
00215 
00216                 $GLOBALS['TYPO3_DB']->sql_free_result($log);
00217 
00218                 return $theOutput;
00219         }
00220 }
00221 
00222 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/belog/class.tx_belog_webinfo.php"])    {
00223         include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/belog/class.tx_belog_webinfo.php"]);
00224 }
00225 
00226 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6