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

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

[Event Cats] ≈ finish existing/new entries separation

File size: 10.2 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, $lang, $test1, $prefixeTable, $ec_err, $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_f_pb' :
91    case 'ec_ok_f_pb_img_pb' :
92      $page['errors'][$ec_entry['code']] =
93       $ec_entry['code'].' : '.l10n('ec_forced_pb');
94    case 'ec_ok' :
95    case 'ec_ok_img_pb' :
96      $a = 0;
97      if (!empty($ec_entry['arg1'])) $a++;
98      if (!empty($ec_entry['arg2'])) $a+= 2;
99      switch ($a) {
100        case 0: // Home
101          $dspl = l10n('ec_dspl_ok_home');
102        break;
103        case 1: // Category
104        case 3: // Image
105          $url_end = (
106           $ec_entry['forced'] == 'true' and
107           !is_in($ec_entry['action'], '_f_pb')
108          ) ? '' : '&cat='.$arg1;
109          $dspl =
110           l10n('ec_dspl_ok_cat_pre').
111           $arg1.
112           l10n('ec_dspl_ok_cat_mid').
113           $ec_lists['categories'][$arg1_int].
114           l10n('ec_dspl_ok_cat_end')
115          ;
116          if (is_in($ec_entry['action'], '_img_pb')) {
117            $url_end.= ($url_end == '') ? '' : '&img='.$arg2;
118            $page['errors'][] = 
119             $ec_entry['code'].' : '.l10n('ec_image_miss');
120            $dspl.=
121             '<br>'.$span_err_pre.
122             l10n('ec_dspl_nok_img2_pre').
123             $arg2.
124             l10n('ec_dspl_nok_img2_mid').
125             $arg1.
126             l10n('ec_dspl_nok_img2_end').
127             $span_err_end
128            ;
129          }
130          elseif ($a == 3) { // Image
131            $url_end.= ($url_end == '') ? '' : '&img='.$arg2;
132            $t = mysql_fetch_row(pwg_query('
133             SELECT `name`, `file`
134             FROM `'.IMAGES_TABLE.'`
135             WHERE `id` = "'.$arg2.'"
136            '));
137            $dspl.=
138             '<br>'.
139             l10n('ec_dspl_ok_img2_pre').
140             $arg2.
141             l10n('ec_dspl_ok_img2_mid1').
142             $t[0].
143             l10n('ec_dspl_ok_img2_mid2').
144             $t[1].
145             l10n('ec_dspl_ok_img2_end')
146            ;
147          }
148        break;
149        case 2: // Additional Page
150          $url_end = (
151           $ec_entry['forced'] == 'true' and
152           !is_in($ec_entry['action'], '_f_pb')
153          ) ? '' : '&ap='.$arg2;
154          $dspl = ($ec_ap_ok) ?
155           l10n('ec_dspl_ok_ap_pre').
156           $arg2.
157           l10n('ec_dspl_ok_ap_mid').
158           $ec_lists['add_pages'][$arg2_int].
159           l10n('ec_dspl_ok_ap_end')
160          :
161           l10n('ec_dspl_ok_home')
162          ;
163        break;
164      }
165    break;
166   
167    case 'ec_nok' :
168      if (empty($ec_entry['arg2'])) {
169        $dspl = l10n('ec_dspl_nok_acc_denied');
170      }
171      else {
172        $dspl = ($ec_ap_ok) ?
173         l10n('ec_dspl_ok_ap_pre').
174         $arg2.
175         l10n('ec_dspl_ok_ap_mid').
176         $ec_lists['add_pages'][$arg2_int].
177         l10n('ec_dspl_ok_ap_end')
178        :
179         l10n('ec_dspl_nok_acc_denied')
180        ;
181      }
182    break;
183   
184    case 'ec_ok_f_pb_ap_pb' :
185      $page['errors'][$ec_entry['code']] =
186       $ec_entry['code'].' : '.l10n('ec_forced_pb');
187    case 'ec_nok_ap_pb' : // No need to check here if Additional Pages is
188    case 'ec_ok_ap_pb' :  // active : we can arrive here only when it is.
189      $page['errors'][] = 
190       $ec_entry['code'].' : '.l10n('ec_add_page_miss');
191      if (is_in($ec_entry['action'], 'ec_ok')) {
192        $url_end = (
193         $ec_entry['forced'] == 'true' and
194         !is_in($ec_entry['action'], '_f_pb')
195        ) ? '' : '&ap='.$arg2;
196        $dspl = l10n('ec_dspl_ok_home');
197      }
198      else {
199        $dspl = l10n('ec_dspl_nok_acc_denied');
200      }
201      $dspl.=
202       $span_err_pre.
203       l10n('ec_dspl_nok_ap_pre').
204       $arg2.
205       l10n('ec_dspl_nok_ap_end').
206       $span_err_end
207      ;
208    break;
209   
210    case 'ec_ok_f_pb_cat_pb' :
211      $page['errors'][$ec_entry['code']] =
212       $ec_entry['code'].' : '.l10n('ec_forced_pb');
213    case 'ec_ok_cat_pb' :
214      $url_end = (
215       $ec_entry['forced'] == 'true' and
216       !is_in($ec_entry['action'], '_f_pb')
217      ) ? '' : '&cat='.$arg1;
218      $page['errors'][] = 
219       $ec_entry['code'].' : '.l10n('ec_category_miss');
220      $dspl =
221       l10n('ec_dspl_nok_home').
222       $span_err_pre.
223       l10n('ec_dspl_nok_img1_pre').
224       $arg1.
225       l10n('ec_dspl_nok_img1_end').
226       $span_err_end
227      ;
228    break;
229   
230    case 'ec_nok_action_pb' :
231      $page['errors'][$ec_entry['code']] = 
232       $ec_entry['code'].' : '.l10n('ec_action_pb');
233      $username =
234       $span_err_pre.
235       l10n('ec_dspl_nok_actn').
236       $span_err_end
237      ;
238      $dspl = l10n('ec_dspl_ok_home');
239    break;
240   
241    case 'ec_nok_userid_pb' :
242      $page['errors'][$ec_entry['code']] = 
243       $ec_entry['code'].' : '.l10n('ec_username_pb');
244      $username =
245       $span_err_pre.
246       l10n('ec_dspl_usr_pb').
247       $span_err_end
248      ;
249      $dspl = l10n('ec_dspl_ok_home');
250    break;
251   
252    case 'ec_nok_userid_miss' :
253      $page['errors'][$ec_entry['code']] = 
254       $ec_entry['code'].' : '.l10n('ec_username_miss');
255      $username =
256       $span_err_pre.
257       l10n('ec_dspl_nok_usr_pre').
258       $ec_entry['user_id'].
259       l10n('ec_dspl_nok_usr_end').
260       $span_err_end
261      ;
262      $dspl = l10n('ec_dspl_ok_home');
263    break;
264  }
265 
266  // construction of $code_URL
267  $code_URL =
268   ROOT_URL.
269   'index.php?autolog='.
270   $ec_entry['code'].
271   $url_end
272  ;
273 
274  $code_list[$i] = array(
275   'id'       => $i,
276   'Code'     => (isset($page['errors'][$ec_entry['code']])) ?
277    $span_err_pre.$ec_entry['code'].$span_err_end : $ec_entry['code'],
278   'Username' => $username,
279   'Action'   => (is_in($ec_entry['action'], 'ec_nok_')) ?
280    $span_err_pre.$ec_entry['action'].$span_err_end : $ec_entry['action'],
281   'Arg1'     => $dspl,
282   'Forced'   => $ec_entry['forced'],
283   'code_URL' => $code_URL,
284   'log_OK'   => $log_OK,
285   'f_pb'     => is_in($ec_entry['action'], '_f_pb'),
286  );
287}
288
289$template->assign('ec_ap_ok',$ec_ap_ok);
290$template->assign('code_list',$code_list);
291
292?>
Note: See TracBrowser for help on using the repository browser.