Updated years from 2004 to 2005 + all function indexes. NO actual code changes done!
[Packages/TYPO3.CMS.git] / typo3 / sysext / belog / class.tx_belog_webinfo.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
29 */
30
31
32 require_once(PATH_t3lib."class.t3lib_pagetree.php");
33 require_once(PATH_t3lib."class.t3lib_bedisplaylog.php");
34 class logFunctions_ext extends t3lib_BEDisplayLog {
35 function initArray() {
36 global $LANG;
37 $codeArr=Array();
38 $codeArr[$i][]=$LANG->getLL("chLog_l_time");
39 $codeArr[$i][]=$LANG->getLL("chLog_l_user");
40 $codeArr[$i][]=$LANG->getLL("chLog_l_error");
41 $codeArr[$i][]=$LANG->getLL("chLog_l_action");
42 $codeArr[$i][]=$LANG->getLL("chLog_l_table");
43 $codeArr[$i][]=$LANG->getLL("chLog_l_details");
44 return $codeArr;
45 }
46 }
47
48
49 require_once(PATH_t3lib."class.t3lib_extobjbase.php");
50
51 class tx_belog_webinfo extends t3lib_extobjbase {
52 var $localLangFile = "locallang.php";
53
54 function modMenu() {
55 global $LANG;
56
57 return array(
58 "log_users" => array(
59 0 => $LANG->getLL("chLog_users_0"),
60 "-1" => $LANG->getLL("chLog_users_-1")
61 ),
62 "log_time" => array(
63 0 => $LANG->getLL("chLog_time_0"),
64 1 => $LANG->getLL("chLog_time_1"),
65 2 => $LANG->getLL("chLog_time_2"),
66 10 => $LANG->getLL("chLog_time_10"),
67 11 => $LANG->getLL("chLog_time_11"),
68 12 => $LANG->getLL("chLog_time_12"),
69 20 => $LANG->getLL("chLog_time_20")
70 ),
71 "depth" => array(
72 0 => $LANG->getLL("depth_0"),
73 1 => $LANG->getLL("depth_1"),
74 2 => $LANG->getLL("depth_2"),
75 3 => $LANG->getLL("depth_3")
76 )
77 );
78 }
79
80 // ***********************************
81 // MAIN function for log display
82 // ***********************************
83 function localLang() {
84 $LOCAL_LANG = $GLOBALS['LANG']->includeLLFile('EXT:belog/mod/locallang.xml',FALSE);
85
86 $GLOBALS["LOCAL_LANG"]=t3lib_div::array_merge_recursive_overrule($GLOBALS["LOCAL_LANG"],$LOCAL_LANG);
87 }
88
89 /**
90 * [Describe function...]
91 *
92 * @return [type] ...
93 */
94 function main() {
95 global $SOBE,$LANG;
96
97 $this->localLang();
98
99 $lF = t3lib_div::makeInstance("logFunctions_ext");
100
101 $theOutput="";
102 $menu="";
103 $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"]);
104 $menu.= "&nbsp;".$LANG->getLL("chLog_menuDepth").": ".t3lib_BEfunc::getFuncMenu($this->pObj->id,"SET[depth]",$this->pObj->MOD_SETTINGS["depth"],$this->pObj->MOD_MENU["depth"]);
105 $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"]);
106 $theOutput.=$this->pObj->doc->section($LANG->getLL("chLog_title"),'<span class="nobr">'.$menu.'</span>',0,1);
107
108 // Build query
109
110 $where_part="";
111
112 // Get the idlist of pages for the treestructure.
113 $tree = t3lib_div::makeInstance("t3lib_pageTree");
114 $tree->init("AND ".$this->pObj->perms_clause);
115 $tree->makeHTML=0;
116 $tree->fieldArray = Array("uid");
117 if ($this->pObj->MOD_SETTINGS["depth"]) {
118 $tree->getTree($this->pObj->id, $this->pObj->MOD_SETTINGS["depth"], "");
119 }
120 $tree->ids[]=$this->pObj->id;
121 $idList = implode($tree->ids,",");
122
123 //$where_part.=" AND ((tablename='pages' and recuid in (".$idList.")) OR (tablename!='pages' and recpid in (".$idList.")))"; // DB
124 $where_part.=" AND (event_pid in (".$idList."))"; // DB
125
126 // Time:
127 $starttime=0;
128 $endtime=time();
129 switch($this->pObj->MOD_SETTINGS["log_time"]) {
130 case 0:
131 // This week
132 $week = (date("w") ? date("w") : 7)-1;
133 $starttime = mktime (0,0,0)-$week*3600*24;
134 break;
135 case 1:
136 // Last week
137 $week = (date("w") ? date("w") : 7)-1;
138 $starttime = mktime (0,0,0)-($week+7)*3600*24;
139 $endtime = mktime (0,0,0)-$week*3600*24;
140 break;
141 case 2:
142 // Last 7 days
143 $starttime = mktime (0,0,0)-7*3600*24;
144 break;
145 case 10:
146 // This month
147 $starttime = mktime (0,0,0, date("m"),1);
148 break;
149 case 11:
150 // Last month
151 $starttime = mktime (0,0,0, date("m")-1,1);
152 $endtime = mktime (0,0,0, date("m"),1);
153 break;
154 case 12:
155 // Last 31 days
156 $starttime = mktime (0,0,0)-31*3600*24;
157 break;
158 }
159 if ($starttime) {
160 $where_part.=" AND tstamp>=".$starttime." AND tstamp<".$endtime;
161 }
162
163 $where_part.=" AND type=1"; // DB
164
165
166 // Users
167 $this->pObj->be_user_Array = t3lib_BEfunc::getUserNames();
168 if (!$this->pObj->MOD_SETTINGS["log_users"]) { // All users
169 // Get usernames and groupnames
170 if (!$GLOBALS["BE_USER"]->isAdmin()) {
171 $groupArray = explode(",",$GLOBALS["BE_USER"]->user["usergroup_cached_list"]);
172 $this->pObj->be_user_Array = t3lib_BEfunc::blindUserNames($this->pObj->be_user_Array,$groupArray,1);
173 }
174
175 if (is_array($this->pObj->be_user_Array)) {
176 while(list(,$val)=each($this->pObj->be_user_Array)) {
177 $selectUsers[]=$val["uid"];
178 }
179 }
180 $selectUsers[] = $GLOBALS["BE_USER"]->user["uid"];
181 $where_part.=" AND userid in (".implode($selectUsers,",").")";
182 } else {
183 $where_part.=" AND userid=".$GLOBALS["BE_USER"]->user["uid"]; // Self user
184 }
185
186
187
188
189
190 $log = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', '1=1'.$where_part, '', 'uid DESC', 100);
191
192 $codeArr = $lF->initArray();
193 $oldHeader = "";
194 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($log)) {
195 $header = $this->pObj->doc->formatTime($row["tstamp"],10);
196 if (!$oldHeader) $oldHeader = $header;
197
198 if ($header!=$oldHeader) {
199 $theOutput.=$this->pObj->doc->spacer(10);
200 $theOutput.=$this->pObj->doc->section($oldHeader,$this->pObj->doc->table($codeArr));
201 $codeArr=$lF->initArray();
202 $oldHeader=$header;
203 $lF->reset();
204 }
205
206 $i++;
207 $codeArr[$i][]=$lF->getTimeLabel($row["tstamp"]);
208 $codeArr[$i][]=$lF->getUserLabel($row["userid"]);
209 $codeArr[$i][]=$row["error"] ? $lF->getErrorFormatting($lF->errorSign[$row["error"]]) : "";
210 $codeArr[$i][]=$lF->getActionLabel($row["type"]."_".$row["action"]);
211 $codeArr[$i][]=$row["tablename"];
212 $codeArr[$i][]=$lF->formatDetailsForList($row);
213 }
214 $theOutput.=$this->pObj->doc->spacer(10);
215 $theOutput.=$this->pObj->doc->section($header,$this->pObj->doc->table($codeArr));
216
217 $GLOBALS['TYPO3_DB']->sql_free_result($log);
218
219 return $theOutput;
220 }
221 }
222
223 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/belog/class.tx_belog_webinfo.php"]) {
224 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/belog/class.tx_belog_webinfo.php"]);
225 }
226
227 ?>