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

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

[Event Cats] Begin duplication management

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();
57
58/****************************************************************
59* Construction of array var to be transmitted to tpl file,      *
60* containing all infos to be displayed in the code array table. *
61****************************************************************/
62
63$span_err_pre = '<span style = "color: red; font-weight: bold;">';
64$span_err_end = '</span>';
65
66foreach ($ec_lists['ec_table'] as $ec_entry) {
67   
68  $a = NULL;
69  $dspl     = '';
70  $url_end  = '';
71  $i        = intval($ec_entry['id']);
72  $arg1     = $ec_entry['arg1'];
73  $arg1_int = intval($arg1);
74  $arg2     = $ec_entry['arg2'];
75  $arg2_int = intval($arg2);
76  $log_OK   = is_in($ec_entry['action'], 'ec_ok');
77 
78  // No specific need for "code" displaying
79 
80  // "username" displaying
81  $username = ($log_OK) ?
82   $ec_lists['user_ids'][intval($ec_entry['user_id'])] : '';
83 
84  // No specific need for "action" displaying
85 
86  // "displayed page" : # of the AP, or of the category...
87  switch ($ec_entry['action']) {
88   
89    case 'ec_ok' :
90    case 'ec_ok_img_pb' :
91      $a = 0;
92      if (!empty($ec_entry['arg1'])) $a++;
93      if (!empty($ec_entry['arg2'])) $a+= 2;
94      switch ($a) {
95        case 0: // Home
96          $dspl = l10n('ec_dspl_ok_home');
97        break;
98        case 1: // Category
99        case 3: // Image
100          $url_end = ($ec_entry['forced'] == 'true') ? '' : '&amp;cat='.$arg1;
101          $dspl =
102           l10n('ec_dspl_ok_cat_pre').
103           $arg1.
104           l10n('ec_dspl_ok_cat_mid').
105           $ec_lists['categories'][$arg1_int].
106           l10n('ec_dspl_ok_cat_end')
107          ;
108          if (is_in($ec_entry['action'], '_img_pb')) {
109            $url_end.= ($url_end == '') ? '' : '&amp;img='.$arg2;
110            $page['errors'][] = 
111             $ec_entry['code'].' : '.l10n('ec_image_miss');
112            $dspl.=
113             '<br>'.$span_err_pre.
114             l10n('ec_dspl_nok_img2_pre').
115             $arg2.
116             l10n('ec_dspl_nok_img2_mid').
117             $arg1.
118             l10n('ec_dspl_nok_img2_end').
119             $span_err_end
120            ;
121          }
122          elseif ($a == 3) { // Image
123            $url_end.= ($url_end == '') ? '' : '&amp;img='.$arg2;
124            $t = mysql_fetch_row(pwg_query('
125             SELECT `name`, `file`
126             FROM `'.IMAGES_TABLE.'`
127             WHERE `id` = "'.$arg2.'"
128            '));
129            $dspl.=
130             '<br>'.
131             l10n('ec_dspl_ok_img2_pre').
132             $arg2.
133             l10n('ec_dspl_ok_img2_mid1').
134             $t[0].
135             l10n('ec_dspl_ok_img2_mid2').
136             $t[1].
137             l10n('ec_dspl_ok_img2_end')
138            ;
139          }
140        break;
141        case 2: // Additional Page
142          $url_end = ($ec_entry['forced'] == 'true') ? '' : '&amp;ap='.$arg2;
143          $dspl = ($ec_ap_ok) ?
144           l10n('ec_dspl_ok_ap_pre').
145           $arg2.
146           l10n('ec_dspl_ok_ap_mid').
147           $ec_lists['add_pages'][$arg2_int].
148           l10n('ec_dspl_ok_ap_end')
149          :
150           l10n('ec_dspl_ok_home')
151          ;
152        break;
153      }
154    break;
155   
156    case 'ec_nok' :
157      if (empty($ec_entry['arg2'])) {
158        $dspl = l10n('ec_dspl_nok_acc_denied');
159      }
160      else {
161        $dspl = ($ec_ap_ok) ?
162         l10n('ec_dspl_ok_ap_pre').
163         $arg2.
164         l10n('ec_dspl_ok_ap_mid').
165         $ec_lists['add_pages'][$arg2_int].
166         l10n('ec_dspl_ok_ap_end')
167        :
168         l10n('ec_dspl_nok_acc_denied')
169        ;
170      }
171    break;
172   
173    case 'ec_nok_ap_pb' : // No need to check here if Additional Pages is
174    case 'ec_ok_ap_pb' :  // active : we can arrive here only when it is.
175      $page['errors'][] = 
176       $ec_entry['code'].' : '.l10n('ec_add_page_miss');
177      if (is_in($ec_entry['action'], 'ec_ok')) {
178        $url_end = ($ec_entry['forced'] == 'true') ? '' : '&amp;ap='.$arg2;
179        $dspl = l10n('ec_dspl_ok_home');
180      }
181      else {
182        $dspl = l10n('ec_dspl_nok_acc_denied');
183      }
184      $dspl.=
185       $span_err_pre.
186       l10n('ec_dspl_nok_ap_pre').
187       $arg2.
188       l10n('ec_dspl_nok_ap_end').
189       $span_err_end
190      ;
191    break;
192   
193    case 'ec_ok_cat_pb' :
194      $url_end = ($ec_entry['forced'] == 'true') ? '' : '&amp;cat='.$arg1;
195      $page['errors'][] = 
196       $ec_entry['code'].' : '.l10n('ec_category_miss');
197      $dspl =
198       l10n('ec_dspl_nok_home').
199       $span_err_pre.
200       l10n('ec_dspl_nok_img1_pre').
201       $arg1.
202       l10n('ec_dspl_nok_img1_end').
203       $span_err_end
204      ;
205    break;
206   
207    case 'ec_nok_action_pb' :
208      $page['errors'][$ec_entry['code']] = 
209       $ec_entry['code'].' : '.l10n('ec_action_pb');
210      $username =
211       $span_err_pre.
212       l10n('ec_dspl_nok_actn').
213       $span_err_end
214      ;
215      $dspl = l10n('ec_dspl_ok_home');
216    break;
217   
218    case 'ec_nok_userid_pb' :
219      $page['errors'][$ec_entry['code']] = 
220       $ec_entry['code'].' : '.l10n('ec_username_pb');
221      $username =
222       $span_err_pre.
223       l10n('ec_dspl_usr_pb').
224       $span_err_end
225      ;
226      $dspl = l10n('ec_dspl_ok_home');
227    break;
228   
229    case 'ec_nok_userid_miss' :
230      $page['errors'][$ec_entry['code']] = 
231       $ec_entry['code'].' : '.l10n('ec_username_miss');
232      $username =
233       $span_err_pre.
234       l10n('ec_dspl_nok_usr_pre').
235       $ec_entry['user_id'].
236       l10n('ec_dspl_nok_usr_end').
237       $span_err_end
238      ;
239      $dspl = l10n('ec_dspl_ok_home');
240    break;
241  }
242 
243  // construction of $code_URL
244  $code_URL =
245   ROOT_URL.
246   'index.php?autolog='.
247   $ec_entry['code'].
248   $url_end
249  ;
250 
251  $code_list[$i] = array(
252   'id'       => $i,
253   'Code'     => (isset($page['errors'][$ec_entry['code']])) ?
254    $span_err_pre.$ec_entry['code'].$span_err_end : $ec_entry['code'],
255   'Username' => $username,
256   'Action'   => (is_in($ec_entry['action'], 'ec_nok_')) ?
257    $span_err_pre.l10n($ec_entry['action']).$span_err_end :
258    l10n($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.