source: extensions/event_cats/admin/autolog_entries.inc.php @ 4092

Last change on this file since 4092 was 4092, checked in by LucMorizur, 14 years ago

[Event Cats] PNG, JS, TPL and CSS normally finished now. Remains "only" PHP and SQL...

File size: 9.4 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Plugin Name : Event Cats                                              |
4// | Plugin Version : 1.0                                                  |
5// | File Version : 1.0                                                    |
6// | Plugin Version author : LucMorizur                                    |
7// | Plugin description : (plugin for Piwigo, http://piwigo.org )          |
8// | This plugin allows an account to be automatically logged in ; and to  |
9// | let users duplicate the account they are logged with, to get benefits |
10// | of the groups of the previous account, immediately on their new acc.  |
11// | Ce plugin permet d'identifier automatiquement un compte ; et permet à |
12// | un utilisateur de dupliquer un compte, pour que le nouveau compte     |
13// | bénéficie immédiatement de l'affectation aux groupes de l'ancien cpte |
14// +-----------------------------------------------------------------------+
15
16// +-----------------------------------------------------------------------+
17// | Piwigo - a PHP based picture gallery                                  |
18// +-----------------------------------------------------------------------+
19// | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
20// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
21// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
22// +-----------------------------------------------------------------------+
23// | This program is free software; you can redistribute it and/or modify  |
24// | it under the terms of the GNU General Public License as published by  |
25// | the Free Software Foundation                                          |
26// |                                                                       |
27// | This program is distributed in the hope that it will be useful, but   |
28// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
29// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
30// | General Public License for more details.                              |
31// |                                                                       |
32// | You should have received a copy of the GNU General Public License     |
33// | along with this program; if not, write to the Free Software           |
34// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
35// | USA.                                                                  |
36// +-----------------------------------------------------------------------+
37
38if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
39
40global $template, $conf, $page,
41 $ec_lists,   // array of following arrays :
42              //   $ec_lists['ec_table'] :
43              //     Event Cats table, in function of each entry id
44              //   $ec_lists['ec_codes'] : // Used ?
45              //     array of useful data, in function of entries codes
46              //   $ec_lists['add_pages'] :
47              //     array of Add. Pages names in function of their id
48              //   $ec_lists['categories'] :
49              //     array of category names in function of their id
50              //   $ec_lists['user_ids'] :
51              //     array of usernames in function of their id
52 $ec_ap_ok;   // whether Additional Pages is installed and activated
53
54/****************************************************************************/
55
56$code_list = array();
57build_ec_lists(); // in evntcats_funcs.inc.php
58
59/****************************************************************
60* Construction of array var to be transmitted to tpl file,      *
61* containing all infos to be displayed in the code array table. *
62****************************************************************/
63
64$span_err_pre = '<span style = "color: red; font-weight: bold;">';
65$span_err_end = '</span>';
66
67foreach ($ec_lists['ec_table'] as $ec_entry) {
68   
69  $a = NULL;
70  $dspl     = '';
71  $url_end  = '';
72  $i        = intval($ec_entry['id']);
73  $arg1     = $ec_entry['arg1'];
74  $arg1_int = intval($arg1);
75  $arg2     = $ec_entry['arg2'];
76  $arg2_int = intval($arg2);
77  $log_OK   = is_in($ec_entry['action'], 'ec_ok');
78 
79  // No specific need for "code" displaying
80 
81  // "username" displaying
82  $username = ($log_OK) ?
83   $ec_lists['user_ids'][intval($ec_entry['user_id'])] : '';
84 
85  // No specific need for "action" displaying
86 
87  // "displayed page" : # of the AP, or of the category...
88  switch ($ec_entry['action']) {
89   
90    case 'ec_ok' :
91    case 'ec_ok_img_pb' :
92      $a = 0;
93      if (!empty($ec_entry['arg1'])) $a++;
94      if (!empty($ec_entry['arg2'])) $a+= 2;
95      switch ($a) {
96        case 0: // Home
97          $dspl = l10n('ec_dspl_ok_home');
98        break;
99        case 1: // Category
100        case 3: // Image
101          $url_end = ($ec_entry['forced'] == 'true') ? '' : '&cat='.$arg1;
102          $dspl =
103           l10n('ec_dspl_ok_cat_pre').
104           $arg1.
105           l10n('ec_dspl_ok_cat_mid').
106           $ec_lists['categories'][$arg1_int].
107           l10n('ec_dspl_ok_cat_end')
108          ;
109          if (is_in($ec_entry['action'], '_img_pb')) {
110            $url_end.= ($url_end == '') ? '' : '&img='.$arg2;
111            $page['errors'][] = 
112             $ec_entry['code'].' : '.l10n('ec_image_miss');
113            $dspl.=
114             '<br>'.$span_err_pre.
115             l10n('ec_dspl_nok_img2_pre').
116             $arg2.
117             l10n('ec_dspl_nok_img2_mid').
118             $arg1.
119             l10n('ec_dspl_nok_img2_end').
120             $span_err_end
121            ;
122          }
123          elseif ($a == 3) { // Image
124            $url_end.= ($url_end == '') ? '' : '&img='.$arg2;
125            $t = mysql_fetch_row(pwg_query('
126             SELECT `name`, `file`
127             FROM `'.IMAGES_TABLE.'`
128             WHERE `id` = "'.$arg2.'"
129            '));
130            $dspl.=
131             '<br>'.
132             l10n('ec_dspl_ok_img2_pre').
133             $arg2.
134             l10n('ec_dspl_ok_img2_mid1').
135             $t[0].
136             l10n('ec_dspl_ok_img2_mid2').
137             $t[1].
138             l10n('ec_dspl_ok_img2_end')
139            ;
140          }
141        break;
142        case 2: // Additional Page
143          $url_end = ($ec_entry['forced'] == 'true') ? '' : '&ap='.$arg2;
144          $dspl = ($ec_ap_ok) ?
145           l10n('ec_dspl_ok_ap_pre').
146           $arg2.
147           l10n('ec_dspl_ok_ap_mid').
148           $ec_lists['add_pages'][$arg2_int].
149           l10n('ec_dspl_ok_ap_end')
150          :
151           l10n('ec_dspl_ok_home')
152          ;
153        break;
154      }
155    break;
156   
157    case 'ec_nok' :
158      if (empty($ec_entry['arg2'])) {
159        $dspl = l10n('ec_dspl_nok_acc_denied');
160      }
161      else {
162        $dspl = ($ec_ap_ok) ?
163         l10n('ec_dspl_ok_ap_pre').
164         $arg2.
165         l10n('ec_dspl_ok_ap_mid').
166         $ec_lists['add_pages'][$arg2_int].
167         l10n('ec_dspl_ok_ap_end')
168        :
169         l10n('ec_dspl_nok_acc_denied')
170        ;
171      }
172    break;
173   
174    case 'ec_nok_ap_pb' : // No need to check here if Additional Pages is
175    case 'ec_ok_ap_pb' :  // active : we can arrive here only when it is.
176      $page['errors'][] = 
177       $ec_entry['code'].' : '.l10n('ec_add_page_miss');
178      if (is_in($ec_entry['action'], 'ec_ok')) {
179        $url_end = ($ec_entry['forced'] == 'true') ? '' : '&ap='.$arg2;
180        $dspl = l10n('ec_dspl_ok_home');
181      }
182      else {
183        $dspl = l10n('ec_dspl_nok_acc_denied');
184      }
185      $dspl.=
186       $span_err_pre.
187       l10n('ec_dspl_nok_ap_pre').
188       $arg2.
189       l10n('ec_dspl_nok_ap_end').
190       $span_err_end
191      ;
192    break;
193   
194    case 'ec_ok_cat_pb' :
195      $url_end = ($ec_entry['forced'] == 'true') ? '' : '&cat='.$arg1;
196      $page['errors'][] = 
197       $ec_entry['code'].' : '.l10n('ec_category_miss');
198      $dspl =
199       l10n('ec_dspl_nok_home').
200       $span_err_pre.
201       l10n('ec_dspl_nok_img1_pre').
202       $arg1.
203       l10n('ec_dspl_nok_img1_end').
204       $span_err_end
205      ;
206    break;
207   
208    case 'ec_nok_action_pb' :
209      $page['errors'][$ec_entry['code']] = 
210       $ec_entry['code'].' : '.l10n('ec_action_pb');
211      $username =
212       $span_err_pre.
213       l10n('ec_dspl_nok_actn').
214       $span_err_end
215      ;
216      $dspl = l10n('ec_dspl_ok_home');
217    break;
218   
219    case 'ec_nok_userid_pb' :
220      $page['errors'][$ec_entry['code']] = 
221       $ec_entry['code'].' : '.l10n('ec_username_pb');
222      $username =
223       $span_err_pre.
224       l10n('ec_dspl_usr_pb').
225       $span_err_end
226      ;
227      $dspl = l10n('ec_dspl_ok_home');
228    break;
229   
230    case 'ec_nok_userid_miss' :
231      $page['errors'][$ec_entry['code']] = 
232       $ec_entry['code'].' : '.l10n('ec_username_miss');
233      $username =
234       $span_err_pre.
235       l10n('ec_dspl_nok_usr_pre').
236       $ec_entry['user_id'].
237       l10n('ec_dspl_nok_usr_end').
238       $span_err_end
239      ;
240      $dspl = l10n('ec_dspl_ok_home');
241    break;
242  }
243 
244  // construction of $code_URL
245  $code_URL =
246   ROOT_URL.
247   'index.php?autolog='.
248   $ec_entry['code'].
249   $url_end
250  ;
251 
252  $code_list[$i] = array(
253   'id'       => $i,
254   'Code'     => (isset($page['errors'][$ec_entry['code']])) ?
255    $span_err_pre.$ec_entry['code'].$span_err_end : $ec_entry['code'],
256   'Username' => $username,
257   'Action'   => (is_in($ec_entry['action'], 'ec_nok_')) ?
258    $span_err_pre.$ec_entry['action'].$span_err_end : $ec_entry['action'],
259   'Arg1'     => $dspl,
260   'Forced'   => $ec_entry['forced'],
261   'code_URL' => $code_URL,
262   'log_OK'   => $log_OK,
263  );
264}
265
266$template->assign('ec_ap_ok',$ec_ap_ok);
267$template->assign('code_list',$code_list);
268
269?>
Note: See TracBrowser for help on using the repository browser.