more work on the plugins system
[diogenes.git] / include / admin / index.php
... / ...
CommitLineData
1<?php
2require_once 'diogenes.common.inc.php';
3require_once 'diogenes.admin.inc.php';
4require_once 'diogenes.icons.inc.php';
5
6$page = new DiogenesAdmin;
7$bbarrel =& $page->barrel;
8$homepage = $bbarrel->getPID('');
9
10// filename transformations
11function makeFileLoc($log_file) {
12 global $homepage, $bbarrel;
13
14 if (stristr($log_file, '/') == FALSE ) {
15 // this is a directory
16 $mydir = $log_file;
17 $myfile = '';
18 } else {
19 $myfile = basename($log_file);
20 $mydir = dirname($log_file);
21 }
22
23 $myloc = $bbarrel->getLocation($mydir);
24 if ($myloc or ($mydir == $homepage))
25 {
26 $log_file = $myloc ? "$myloc/$myfile" : $myfile;
27 }
28
29 return array($log_file, $mydir, $myfile);
30}
31
32
33// retrieve recent events
34$res = $globals->db->query("select e.action,e.stamp,e.data,a.text,s.auth,s.uid "
35 ."from {$globals->table_log_events} as e "
36 ."left join {$globals->table_log_actions} as a on e.action=a.id "
37 ."left join {$globals->table_log_sessions} as s on e.session=s.id "
38 ."where e.data like '{$bbarrel->alias}:%' "
39 ."order by stamp desc limit 0,10");
40while ($myarr = mysql_fetch_array($res)) {
41 $myarr['username'] = call_user_func(array($globals->session,'getUsername'),$myarr['auth'],$myarr['uid']);
42 list($op_alias, $op_file) = split(":",$myarr['data']);
43
44 switch($myarr['text']) {
45 case "barrel_create":
46 $myarr['icon'] = $globals->icons->get_action_icon('add');
47 $myarr['desc'] = __("site created");
48 break;
49
50 case "barrel_options":
51 $myarr['icon'] = $globals->icons->get_action_icon('properties');
52 $myarr['desc'] = array(__("barrel options"), "options");
53 break;
54
55 case "barrel_plugins":
56 $myarr['icon'] = $globals->icons->get_action_icon('plugins');
57 $myarr['desc'] = array(__("barrel plugins"), "plugins");
58 break;
59
60 case "page_create":
61 $myarr['icon'] = $globals->icons->get_action_icon('add');
62 list($op_file, $mydir, $myfile) = makeFileLoc($op_file);
63 $myarr['desc'] = array(__("page created"), "pages?dir=$mydir");
64 break;
65
66 case "page_delete":
67 $myarr['icon'] = $globals->icons->get_action_icon('remove');
68 $myarr['desc'] = __("page removed");
69 break;
70
71 case "page_props":
72 $myarr['icon'] = $globals->icons->get_action_icon('properties');
73 list($op_file, $mydir, $myfile) = makeFileLoc($op_file);
74 $myarr['desc'] = array(__("page properties"), "pages?dir=$mydir");
75 break;
76
77 case "page_plugins":
78 $myarr['icon'] = $globals->icons->get_action_icon('plugins');
79 list($op_file, $mydir, $myfile) = makeFileLoc($op_file);
80 $myarr['desc'] = array(__("page plugins"), "plugins?plug_page=$mydir");
81 break;
82
83 case "rcs_commit":
84 $myarr['icon'] = $globals->icons->get_action_icon('update');
85 list($op_file, $mydir, $myfile) = makeFileLoc($op_file);
86 $myarr['desc'] = array(__("file updated"), "files?action=revs&amp;dir=$mydir&amp;target=$myfile");
87 break;
88
89 case "rcs_delete":
90 $myarr['icon'] = $globals->icons->get_action_icon('delete');
91 list($op_file, $mydir, $myfile) = makeFileLoc($op_file);
92 $myarr['desc'] = __("file deleted");
93 break;
94
95 }
96
97 $myarr['file'] = $op_file;
98
99 if (isset($myarr['desc']))
100 $page->append('events',$myarr);
101}
102mysql_free_result($res);
103
104// do display
105$page->assign('greeting',__("Welcome to the Diogenes backoffice"));
106$page->assign('msg_date',__("date"));
107$page->assign('msg_user',__("user"));
108$page->assign('msg_event',__("event"));
109$page->display('admin-index.tpl');
110?>