5a20fed66ffe78f624f5a2f1fc4bc2967b265ed8
3 * Copyright (C) 2003-2006 Polytechnique.org
4 * http://opensource.polytechnique.org/
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 define('EVENT_FLAG_NONE', 0);
22 define('EVENT_FLAG_PUBLIC', 1);
24 /** This class is used to generate the menu of a Diogenes barrel page.
26 class Diogenes_Barrel_Events
28 /** The barrel we are watching */
33 function Diogenes_Barrel_Events(&$barrel)
35 $this->barrel
= $barrel;
39 /** Filename transformations.
41 function makeFileLoc($log_file, &$caller)
43 $homepage = $this->barrel
->getPID('');
44 if (stristr($log_file, '/') == FALSE
) {
45 // this is a directory
49 $myfile = basename($log_file);
50 $mydir = dirname($log_file);
53 $myloc = $this->barrel
->getLocation($mydir);
54 if ($myloc or ($mydir == $homepage))
56 $log_file = $myloc ?
"$myloc/$myfile" : $myfile;
57 $url_loc = $myloc ?
"$myloc/" : '';
58 $link = $caller->urlBarrel($this->barrel
->alias
, $this->barrel
->vhost
, $url_loc);
63 return array($log_file, $mydir, $myfile, $link);
66 /** Retrieve recent events.
68 function getEvents($caller)
72 $res = $globals->db
->query("select e.action,e.stamp,e.data,a.text,s.auth,s.uid "
73 ."from {$globals->table_log_events} as e "
74 ."left join {$globals->table_log_actions} as a on e.action=a.id "
75 ."left join {$globals->table_log_sessions} as s on e.session=s.id "
76 ."where e.data like '{$this->barrel->alias}:%' "
77 ."order by stamp desc limit 0,10");
78 while ($myarr = mysql_fetch_array($res)) {
79 $myarr['author'] = call_user_func(array($globals->session
,'getUsername'),$myarr['auth'],$myarr['uid']);
80 $myarr['flags'] = EVENT_FLAG_NONE
;
81 list($op_alias, $op_file) = split(":",$myarr['data']);
83 switch($myarr['text']) {
85 $myarr['title'] = __("site created");
86 $myarr['icon'] = $globals->icons
->get_action_icon('add');
89 case "barrel_options":
90 $myarr['title'] = __("barrel options");
91 $myarr['icon'] = $globals->icons
->get_action_icon('properties');
94 case "barrel_plugins":
95 $myarr['title'] = __("barrel plugins");
96 $myarr['icon'] = $globals->icons
->get_action_icon('plugins');
97 $myarr['link_admin'] = "plugins";
101 $myarr['title'] = __("page created");
102 $myarr['icon'] = $globals->icons
->get_action_icon('add');
103 list($op_file, $myarr['dir'], $myarr['file'], $myarr['link']) = $this->makeFileLoc($op_file, $caller);
104 $myarr['link_admin'] = "pages?dir={$myarr['dir']}";
105 $myarr['flags'] |
= EVENT_FLAG_PUBLIC
;
109 $myarr['title'] = __("page removed");
110 $myarr['icon'] = $globals->icons
->get_action_icon('remove');
114 $myarr['title'] = __("page properties");
115 $myarr['icon'] = $globals->icons
->get_action_icon('properties');
116 list($op_file, $myarr['dir'], $myarr['file']) = $this->makeFileLoc($op_file, $caller);
117 $myarr['link_admin'] = "pages?dir={$myarr['dir']}";
121 $myarr['title'] = __("page plugins");
122 $myarr['icon'] = $globals->icons
->get_action_icon('plugins');
123 list($op_file, $myarr['dir'], $myarr['file']) = $this->makeFileLoc($op_file, $caller);
124 $myarr['link_admin'] = "plugins?plug_page={$myarr['dir']}";
128 $myarr['title'] = __("file updated");
129 $myarr['icon'] = $globals->icons
->get_action_icon('update');
130 list($op_file, $myarr['dir'], $myarr['file'], $myarr['link']) = $this->makeFileLoc($op_file, $caller);
131 $myarr['link_admin'] = "files?action=revs&dir={$myarr['dir']}&target={$myarr['file']}";
132 $myarr['flags'] |
= EVENT_FLAG_PUBLIC
;
137 $myarr['title'] = __("file deleted");
138 $myarr['icon'] = $globals->icons
->get_action_icon('delete');
139 list($op_file, $myarr['dir'], $myarr['file']) = $this->makeFileLoc($op_file, $caller);
142 $myarr['opfile'] = $op_file;
144 if (isset($myarr['title']))
145 array_push($events, $myarr);
147 mysql_free_result($res);