Documentation TYPO3 par Ameos

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 ***************************************************************/
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                 $LOCAL_LANG = $GLOBALS['LANG']->includeLLFile('EXT:belog/mod/locallang.xml',FALSE);
00085 
00086                 $GLOBALS["LOCAL_LANG"]=t3lib_div::array_merge_recursive_overrule($GLOBALS["LOCAL_LANG"],$LOCAL_LANG);
00087         }
00088 
00094         function main() {
00095                 global $SOBE,$LANG;
00096 
00097                 $this->localLang();
00098 
00099                 $lF = t3lib_div::makeInstance("logFunctions_ext");
00100 
00101                 $theOutput="";
00102                 $menu="";
00103                 $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"]);
00104                 $menu.=  "&nbsp;".$LANG->getLL("chLog_menuDepth").": ".t3lib_BEfunc::getFuncMenu($this->pObj->id,"SET[depth]",$this->pObj->MOD_SETTINGS["depth"],$this->pObj->MOD_MENU["depth"]);
00105                 $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"]);
00106                 $theOutput.=$this->pObj->doc->section($LANG->getLL("chLog_title"),'<span class="nobr">'.$menu.'</span>',0,1);
00107 
00108                 // Build query
00109 
00110                 $where_part="";
00111 
00112                 // Get the idlist of pages for the treestructure.
00113                 $tree = t3lib_div::makeInstance("t3lib_pageTree");
00114                 $tree->init("AND ".$this->pObj->perms_clause);
00115                 $tree->makeHTML=0;
00116                 $tree->fieldArray = Array("uid");
00117                 if ($this->pObj->MOD_SETTINGS["depth"]) {
00118                         $tree->getTree($this->pObj->id, $this->pObj->MOD_SETTINGS["depth"], "");
00119                 }
00120                 $tree->ids[]=$this->pObj->id;
00121                 $idList = implode($tree->ids,",");
00122 
00123                 //$where_part.=" AND ((tablename='pages' and recuid in (".$idList.")) OR (tablename!='pages' and recpid in (".$idList.")))";            // DB
00124                 $where_part.=" AND (event_pid in (".$idList."))";               // DB
00125 
00126                 // Time:
00127                 $starttime=0;
00128                 $endtime=time();
00129                 switch($this->pObj->MOD_SETTINGS["log_time"])           {
00130                         case 0:
00131                                 // This week
00132                                 $week = (date("w") ? date("w") : 7)-1;
00133                                 $starttime = mktime (0,0,0)-$week*3600*24;
00134                         break;
00135                         case 1:
00136                                 // Last week
00137                                 $week = (date("w") ? date("w") : 7)-1;
00138                                 $starttime = mktime (0,0,0)-($week+7)*3600*24;
00139                                 $endtime = mktime (0,0,0)-$week*3600*24;
00140                         break;
00141                         case 2:
00142                                 // Last 7 days
00143                                 $starttime = mktime (0,0,0)-7*3600*24;
00144                         break;
00145                         case 10:
00146                                 // This month
00147                                 $starttime = mktime (0,0,0, date("m"),1);
00148                         break;
00149                         case 11:
00150                                 // Last month
00151                                 $starttime = mktime (0,0,0, date("m")-1,1);
00152                                 $endtime = mktime (0,0,0, date("m"),1);
00153                         break;
00154                         case 12:
00155                                 // Last 31 days
00156                                 $starttime = mktime (0,0,0)-31*3600*24;
00157                         break;
00158                 }
00159                 if ($starttime) {
00160                         $where_part.=" AND tstamp>=".$starttime." AND tstamp<".$endtime;
00161                 }
00162 
00163                 $where_part.=" AND type=1";             // DB
00164 
00165 
00166                         // Users
00167                 $this->pObj->be_user_Array = t3lib_BEfunc::getUserNames();
00168                 if (!$this->pObj->MOD_SETTINGS["log_users"])    {       // All users
00169                                 // Get usernames and groupnames
00170                         if (!$GLOBALS["BE_USER"]->isAdmin())            {
00171                                 $groupArray = explode(",",$GLOBALS["BE_USER"]->user["usergroup_cached_list"]);
00172                                 $this->pObj->be_user_Array = t3lib_BEfunc::blindUserNames($this->pObj->be_user_Array,$groupArray,1);
00173                         }
00174 
00175                         if (is_array($this->pObj->be_user_Array))       {
00176                                 while(list(,$val)=each($this->pObj->be_user_Array))     {
00177                                         $selectUsers[]=$val["uid"];
00178                                 }
00179                         }
00180                         $selectUsers[] = $GLOBALS["BE_USER"]->user["uid"];
00181                         $where_part.=" AND userid in (".implode($selectUsers,",").")";
00182                 } else {
00183                         $where_part.=" AND userid=".$GLOBALS["BE_USER"]->user["uid"];   // Self user
00184                 }
00185 
00186 
00187 
00188 
00189 
00190                 $log = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', '1=1'.$where_part, '', 'uid DESC', 100);
00191 
00192                 $codeArr = $lF->initArray();
00193                 $oldHeader = "";
00194                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($log))       {
00195                         $header = $this->pObj->doc->formatTime($row["tstamp"],10);
00196                         if (!$oldHeader)        $oldHeader = $header;
00197 
00198                         if ($header!=$oldHeader)        {
00199                                 $theOutput.=$this->pObj->doc->spacer(10);
00200                                 $theOutput.=$this->pObj->doc->section($oldHeader,$this->pObj->doc->table($codeArr));
00201                                 $codeArr=$lF->initArray();
00202                                 $oldHeader=$header;
00203                                 $lF->reset();
00204                         }
00205 
00206                         $i++;
00207                         $codeArr[$i][]=$lF->getTimeLabel($row["tstamp"]);
00208                         $codeArr[$i][]=$lF->getUserLabel($row["userid"]);
00209                         $codeArr[$i][]=$row["error"] ? $lF->getErrorFormatting($lF->errorSign[$row["error"]]) : "";
00210                         $codeArr[$i][]=$lF->getActionLabel($row["type"]."_".$row["action"]);
00211                         $codeArr[$i][]=$row["tablename"];
00212                         $codeArr[$i][]=$lF->formatDetailsForList($row);
00213                 }
00214                 $theOutput.=$this->pObj->doc->spacer(10);
00215                 $theOutput.=$this->pObj->doc->section($header,$this->pObj->doc->table($codeArr));
00216 
00217                 $GLOBALS['TYPO3_DB']->sql_free_result($log);
00218 
00219                 return $theOutput;
00220         }
00221 }
00222 
00223 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/belog/class.tx_belog_webinfo.php"])    {
00224         include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/belog/class.tx_belog_webinfo.php"]);
00225 }
00226 
00227 ?>


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