*** empty log message ***
[Packages/TYPO3.CMS.git] / typo3 / sysext / belog / class.tx_belog_webinfo.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 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 include_once($this->thisPath."/mod/locallang.php");
85 $GLOBALS["LOCAL_LANG"]=t3lib_div::array_merge_recursive_overrule($GLOBALS["LOCAL_LANG"],$LOCAL_LANG);
86 }
87
88 /**
89 * [Describe function...]
90 *
91 * @return [type] ...
92 */
93 function main() {
94 global $SOBE,$LANG;
95
96 $this->localLang();
97
98 $lF = t3lib_div::makeInstance("logFunctions_ext");
99
100 $theOutput="";
101 $menu="";
102 $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"]);
103 $menu.= "&nbsp;".$LANG->getLL("chLog_menuDepth").": ".t3lib_BEfunc::getFuncMenu($this->pObj->id,"SET[depth]",$this->pObj->MOD_SETTINGS["depth"],$this->pObj->MOD_MENU["depth"]);
104 $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"]);
105 $theOutput.=$this->pObj->doc->section($LANG->getLL("chLog_title"),'<span class="nobr">'.$menu.'</span>',0,1);
106
107 // Build query
108
109 $where_part="";
110
111 // Get the idlist of pages for the treestructure.
112 $tree = t3lib_div::makeInstance("t3lib_pageTree");
113 $tree->init("AND ".$this->pObj->perms_clause);
114 $tree->makeHTML=0;
115 $tree->fieldArray = Array("uid");
116 if ($this->pObj->MOD_SETTINGS["depth"]) {
117 $tree->getTree($this->pObj->id, $this->pObj->MOD_SETTINGS["depth"], "");
118 }
119 $tree->ids[]=$this->pObj->id;
120 $idList = implode($tree->ids,",");
121
122 //$where_part.=" AND ((tablename='pages' and recuid in (".$idList.")) OR (tablename!='pages' and recpid in (".$idList.")))"; // DB
123 $where_part.=" AND (event_pid in (".$idList."))"; // DB
124
125 // Time:
126 $starttime=0;
127 $endtime=time();
128 switch($this->pObj->MOD_SETTINGS["log_time"]) {
129 case 0:
130 // This week
131 $week = (date("w") ? date("w") : 7)-1;
132 $starttime = mktime (0,0,0)-$week*3600*24;
133 break;
134 case 1:
135 // Last week
136 $week = (date("w") ? date("w") : 7)-1;
137 $starttime = mktime (0,0,0)-($week+7)*3600*24;
138 $endtime = mktime (0,0,0)-$week*3600*24;
139 break;
140 case 2:
141 // Last 7 days
142 $starttime = mktime (0,0,0)-7*3600*24;
143 break;
144 case 10:
145 // This month
146 $starttime = mktime (0,0,0, date("m"),1);
147 break;
148 case 11:
149 // Last month
150 $starttime = mktime (0,0,0, date("m")-1,1);
151 $endtime = mktime (0,0,0, date("m"),1);
152 break;
153 case 12:
154 // Last 31 days
155 $starttime = mktime (0,0,0)-31*3600*24;
156 break;
157 }
158 if ($starttime) {
159 $where_part.=" AND tstamp>=".$starttime." AND tstamp<".$endtime;
160 }
161
162 $where_part.=" AND type=1"; // DB
163
164
165 // Users
166 $this->pObj->be_user_Array = t3lib_BEfunc::getUserNames();
167 if (!$this->pObj->MOD_SETTINGS["log_users"]) { // All users
168 // Get usernames and groupnames
169 if (!$GLOBALS["BE_USER"]->isAdmin()) {
170 $groupArray = explode(",",$GLOBALS["BE_USER"]->user["usergroup_cached_list"]);
171 $this->pObj->be_user_Array = t3lib_BEfunc::blindUserNames($this->pObj->be_user_Array,$groupArray,1);
172 }
173
174 if (is_array($this->pObj->be_user_Array)) {
175 while(list(,$val)=each($this->pObj->be_user_Array)) {
176 $selectUsers[]=$val["uid"];
177 }
178 }
179 $selectUsers[] = $GLOBALS["BE_USER"]->user["uid"];
180 $where_part.=" AND userid in (".implode($selectUsers,",").")";
181 } else {
182 $where_part.=" AND userid=".$GLOBALS["BE_USER"]->user["uid"]; // Self user
183 }
184
185
186
187
188
189 $log = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', '1=1'.$where_part, '', 'uid DESC', 100);
190
191 $codeArr = $lF->initArray();
192 $oldHeader = "";
193 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($log)) {
194 $header = $this->pObj->doc->formatTime($row["tstamp"],10);
195 if (!$oldHeader) $oldHeader = $header;
196
197 if ($header!=$oldHeader) {
198 $theOutput.=$this->pObj->doc->spacer(10);
199 $theOutput.=$this->pObj->doc->section($oldHeader,$this->pObj->doc->table($codeArr));
200 $codeArr=$lF->initArray();
201 $oldHeader=$header;
202 $lF->reset();
203 }
204
205 $i++;
206 $codeArr[$i][]=$lF->getTimeLabel($row["tstamp"]);
207 $codeArr[$i][]=$lF->getUserLabel($row["userid"]);
208 $codeArr[$i][]=$row["error"] ? $lF->getErrorFormatting($lF->errorSign[$row["error"]]) : "";
209 $codeArr[$i][]=$lF->getActionLabel($row["type"]."_".$row["action"]);
210 $codeArr[$i][]=$row["tablename"];
211 $codeArr[$i][]=$lF->formatDetailsForList($row);
212 }
213 $theOutput.=$this->pObj->doc->spacer(10);
214 $theOutput.=$this->pObj->doc->section($header,$this->pObj->doc->table($codeArr));
215
216 $GLOBALS['TYPO3_DB']->sql_free_result($log);
217
218 return $theOutput;
219 }
220 }
221
222 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/belog/class.tx_belog_webinfo.php"]) {
223 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/belog/class.tx_belog_webinfo.php"]);
224 }
225
226 ?>