[3999] | 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 | |
---|
[8956] | 38 | // Keeps file coded in UTF-8 without BOM : é |
---|
[4421] | 39 | |
---|
[3999] | 40 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 41 | |
---|
[4418] | 42 | global $template, $ec_conf, $page, $ec_lists; |
---|
[3999] | 43 | |
---|
| 44 | /****************************************************************************/ |
---|
| 45 | |
---|
| 46 | $code_list = array(); |
---|
| 47 | |
---|
| 48 | /**************************************************************** |
---|
| 49 | * Construction of array var to be transmitted to tpl file, * |
---|
| 50 | * containing all infos to be displayed in the code array table. * |
---|
| 51 | ****************************************************************/ |
---|
| 52 | |
---|
| 53 | $span_err_pre = '<span style = "color: red; font-weight: bold;">'; |
---|
| 54 | $span_err_end = '</span>'; |
---|
| 55 | |
---|
| 56 | foreach ($ec_lists['ec_table'] as $ec_entry) { |
---|
| 57 | |
---|
| 58 | $a = NULL; |
---|
| 59 | $dspl = ''; |
---|
| 60 | $url_end = ''; |
---|
| 61 | $i = intval($ec_entry['id']); |
---|
| 62 | $arg1 = $ec_entry['arg1']; |
---|
| 63 | $arg1_int = intval($arg1); |
---|
| 64 | $arg2 = $ec_entry['arg2']; |
---|
| 65 | $arg2_int = intval($arg2); |
---|
| 66 | $log_OK = is_in($ec_entry['action'], 'ec_ok'); |
---|
| 67 | |
---|
| 68 | // No specific need for "code" displaying |
---|
| 69 | |
---|
| 70 | // "username" displaying |
---|
| 71 | $username = ($log_OK) ? |
---|
| 72 | $ec_lists['user_ids'][intval($ec_entry['user_id'])] : ''; |
---|
| 73 | |
---|
| 74 | // No specific need for "action" displaying |
---|
| 75 | |
---|
| 76 | // "displayed page" : # of the AP, or of the category... |
---|
| 77 | switch ($ec_entry['action']) { |
---|
| 78 | |
---|
| 79 | case 'ec_ok' : |
---|
| 80 | case 'ec_ok_img_pb' : |
---|
| 81 | $a = 0; |
---|
| 82 | if (!empty($ec_entry['arg1'])) $a++; |
---|
| 83 | if (!empty($ec_entry['arg2'])) $a+= 2; |
---|
| 84 | switch ($a) { |
---|
| 85 | case 0: // Home |
---|
[4329] | 86 | $dspl = l10n('Home'); |
---|
[3999] | 87 | break; |
---|
| 88 | case 1: // Category |
---|
| 89 | case 3: // Image |
---|
[4228] | 90 | $url_end = ($ec_entry['forced'] == 'true') ? '' : '&cat='.$arg1; |
---|
[4329] | 91 | $dspl = sprintf( |
---|
| 92 | l10n('ec_dspl_ok_cat'), $arg1, $ec_lists['categories'][$arg1_int] |
---|
| 93 | ); |
---|
[3999] | 94 | if (is_in($ec_entry['action'], '_img_pb')) { |
---|
[4228] | 95 | $url_end.= ($url_end == '') ? '' : '&img='.$arg2; |
---|
[3999] | 96 | $page['errors'][] = |
---|
| 97 | $ec_entry['code'].' : '.l10n('ec_image_miss'); |
---|
| 98 | $dspl.= |
---|
| 99 | '<br>'.$span_err_pre. |
---|
[4329] | 100 | sprintf(l10n('ec_dspl_nok_img2'), $arg2, $arg1). |
---|
[3999] | 101 | $span_err_end |
---|
| 102 | ; |
---|
| 103 | } |
---|
| 104 | elseif ($a == 3) { // Image |
---|
[4228] | 105 | $url_end.= ($url_end == '') ? '' : '&img='.$arg2; |
---|
[8956] | 106 | $t = mysql_fetch_row(pwg_query(" |
---|
[3999] | 107 | SELECT `name`, `file` |
---|
[4329] | 108 | FROM `".IMAGES_TABLE."` |
---|
| 109 | WHERE `id` = $arg2 |
---|
| 110 | ")); |
---|
| 111 | $dspl.= '<br>'. |
---|
| 112 | sprintf(l10n('ec_dspl_ok_img2'), $arg2, $t[0], $t[1]); |
---|
[3999] | 113 | } |
---|
| 114 | break; |
---|
| 115 | case 2: // Additional Page |
---|
[4228] | 116 | $url_end = ($ec_entry['forced'] == 'true') ? '' : '&ap='.$arg2; |
---|
[4342] | 117 | $dspl = (defined('ADD_PAGES_TABLE')) ? sprintf( |
---|
[4329] | 118 | l10n('ec_dspl_ok_ap'), |
---|
| 119 | $arg2, $ec_lists['add_pages'][$arg2_int] |
---|
| 120 | ) : l10n('Home'); |
---|
[3999] | 121 | break; |
---|
| 122 | } |
---|
| 123 | break; |
---|
| 124 | |
---|
| 125 | case 'ec_nok' : |
---|
| 126 | if (empty($ec_entry['arg2'])) { |
---|
[4329] | 127 | $dspl = l10n('Access denied'); |
---|
[3999] | 128 | } |
---|
| 129 | else { |
---|
[4342] | 130 | $dspl = (defined('ADD_PAGES_TABLE')) ? sprintf( |
---|
[4329] | 131 | l10n('ec_dspl_ok_ap'), |
---|
| 132 | $arg2, $ec_lists['add_pages'][$arg2_int] |
---|
| 133 | ) : l10n('Access denied'); |
---|
[3999] | 134 | } |
---|
| 135 | break; |
---|
| 136 | |
---|
| 137 | case 'ec_nok_ap_pb' : // No need to check here if Additional Pages is |
---|
| 138 | case 'ec_ok_ap_pb' : // active : we can arrive here only when it is. |
---|
| 139 | $page['errors'][] = |
---|
| 140 | $ec_entry['code'].' : '.l10n('ec_add_page_miss'); |
---|
| 141 | if (is_in($ec_entry['action'], 'ec_ok')) { |
---|
[4228] | 142 | $url_end = ($ec_entry['forced'] == 'true') ? '' : '&ap='.$arg2; |
---|
[4329] | 143 | $dspl = l10n('Home'); |
---|
[3999] | 144 | } |
---|
| 145 | else { |
---|
[4329] | 146 | $dspl = l10n('Access denied'); |
---|
[3999] | 147 | } |
---|
| 148 | $dspl.= |
---|
| 149 | $span_err_pre. |
---|
[4329] | 150 | sprintf(l10n('ec_dspl_nok_ap'), $arg2). |
---|
[3999] | 151 | $span_err_end |
---|
| 152 | ; |
---|
| 153 | break; |
---|
| 154 | |
---|
| 155 | case 'ec_ok_cat_pb' : |
---|
[4228] | 156 | $url_end = ($ec_entry['forced'] == 'true') ? '' : '&cat='.$arg1; |
---|
[3999] | 157 | $page['errors'][] = |
---|
| 158 | $ec_entry['code'].' : '.l10n('ec_category_miss'); |
---|
| 159 | $dspl = |
---|
[4329] | 160 | l10n('Home'). |
---|
[3999] | 161 | $span_err_pre. |
---|
[4329] | 162 | sprintf(l10n('ec_dspl_nok_cat'), $arg1). |
---|
[3999] | 163 | $span_err_end |
---|
| 164 | ; |
---|
| 165 | break; |
---|
| 166 | |
---|
| 167 | case 'ec_nok_action_pb' : |
---|
| 168 | $page['errors'][$ec_entry['code']] = |
---|
| 169 | $ec_entry['code'].' : '.l10n('ec_action_pb'); |
---|
| 170 | $username = |
---|
| 171 | $span_err_pre. |
---|
| 172 | l10n('ec_dspl_nok_actn'). |
---|
| 173 | $span_err_end |
---|
| 174 | ; |
---|
[4329] | 175 | $dspl = l10n('Home'); |
---|
[3999] | 176 | break; |
---|
| 177 | |
---|
| 178 | case 'ec_nok_userid_pb' : |
---|
| 179 | $page['errors'][$ec_entry['code']] = |
---|
| 180 | $ec_entry['code'].' : '.l10n('ec_username_pb'); |
---|
| 181 | $username = |
---|
| 182 | $span_err_pre. |
---|
| 183 | l10n('ec_dspl_usr_pb'). |
---|
| 184 | $span_err_end |
---|
| 185 | ; |
---|
[4329] | 186 | $dspl = l10n('Home'); |
---|
[3999] | 187 | break; |
---|
| 188 | |
---|
| 189 | case 'ec_nok_userid_miss' : |
---|
| 190 | $page['errors'][$ec_entry['code']] = |
---|
| 191 | $ec_entry['code'].' : '.l10n('ec_username_miss'); |
---|
| 192 | $username = |
---|
| 193 | $span_err_pre. |
---|
[4329] | 194 | sprintf(l10n('ec_dspl_nok_usr'), $ec_entry['user_id']). |
---|
[3999] | 195 | $span_err_end |
---|
| 196 | ; |
---|
[4329] | 197 | $dspl = l10n('Home'); |
---|
[3999] | 198 | break; |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | // construction of $code_URL |
---|
| 202 | $code_URL = |
---|
[8956] | 203 | EC_ROOT_URL. |
---|
[3999] | 204 | 'index.php?autolog='. |
---|
| 205 | $ec_entry['code']. |
---|
| 206 | $url_end |
---|
| 207 | ; |
---|
| 208 | |
---|
| 209 | $code_list[$i] = array( |
---|
| 210 | 'id' => $i, |
---|
| 211 | 'Code' => (isset($page['errors'][$ec_entry['code']])) ? |
---|
| 212 | $span_err_pre.$ec_entry['code'].$span_err_end : $ec_entry['code'], |
---|
| 213 | 'Username' => $username, |
---|
| 214 | 'Action' => (is_in($ec_entry['action'], 'ec_nok_')) ? |
---|
[4170] | 215 | $span_err_pre.l10n($ec_entry['action']).$span_err_end : |
---|
| 216 | l10n($ec_entry['action']), |
---|
[3999] | 217 | 'Arg1' => $dspl, |
---|
| 218 | 'Forced' => $ec_entry['forced'], |
---|
| 219 | 'code_URL' => $code_URL, |
---|
| 220 | 'log_OK' => $log_OK, |
---|
[4418] | 221 | 'Comment' => $ec_entry['comment'], |
---|
[3999] | 222 | ); |
---|
| 223 | } |
---|
| 224 | |
---|
[4470] | 225 | $template->assign('ec_help_banner_in_foot', true); |
---|
[4437] | 226 | $template->assign('ec_help_banner1', l10n('ec_help_banner1_entries')); |
---|
[4342] | 227 | $template->assign('ec_ap_ok', defined('ADD_PAGES_TABLE')); |
---|
[4418] | 228 | $template->assign('comment_tooltip', (read_ec_conf('comment_display') == '0')); |
---|
[4329] | 229 | $template->assign('ec_ap_ok2', (count($ec_lists['add_pages']) > 0)); |
---|
| 230 | $template->assign('code_list', $code_list); |
---|
[3999] | 231 | |
---|
| 232 | ?> |
---|