[3970] | 1 | <?php |
---|
[3960] | 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 | |
---|
| 38 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 39 | |
---|
[4219] | 40 | global $template, $conf, $lang, $test1, $prefixeTable, $ec_conf, $page, $ec_debug, |
---|
[3960] | 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 | load_language('plugin.lang', EVNTCATS_PATH); |
---|
| 55 | |
---|
| 56 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 57 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
| 58 | include_once(PHPWG_ROOT_PATH.'include/functions_url.inc.php'); |
---|
[4169] | 59 | include_once(EVNTCATS_PATH.'include/evntcats_main_funcs.inc.php'); |
---|
| 60 | include_once(EVNTCATS_PATH.'include/evntcats_admin_funcs.inc.php'); |
---|
[3960] | 61 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
| 62 | |
---|
[3999] | 63 | $template->assign('EVNTCATS_VERSION', EVNTCATS_INFO_VERSION); |
---|
[3960] | 64 | $me = get_plugin_data($plugin_id); |
---|
| 65 | $template->clear_assign('ec_infos'); |
---|
| 66 | $template->append('head_elements', |
---|
| 67 | '<link rel="stylesheet" type="text/css" href="'. |
---|
| 68 | EVNTCATS_PATH.'admin/evntcats_theme.css">' |
---|
| 69 | ); |
---|
[4219] | 70 | $ec_debug = array(); |
---|
[3960] | 71 | |
---|
[4027] | 72 | if ( |
---|
| 73 | isset($_POST['ec_in_up_auto_code_length']) and |
---|
| 74 | $_POST['ec_in_up_auto_code_length'] != read_ec_conf('auto_code_dg_nb') |
---|
| 75 | ) change_ec_conf('auto_code_dg_nb', $_POST['ec_in_up_auto_code_length']); |
---|
| 76 | |
---|
[4092] | 77 | $ec_howto = (read_ec_conf('howto') == '0'); |
---|
| 78 | if ($ec_howto) change_ec_conf('howto', '1'); |
---|
| 79 | |
---|
[4169] | 80 | build_ec_lists(); // in evntcats_main_funcs.php |
---|
[4115] | 81 | |
---|
[3960] | 82 | // +-----------------------------------------------------------------------+ |
---|
| 83 | // | Tabsheet |
---|
| 84 | // +-----------------------------------------------------------------------+ |
---|
[4011] | 85 | |
---|
[4219] | 86 | $page['tab'] = (!($ec_exist_entries = (mysql_num_rows(pwg_query(" |
---|
| 87 | SELECT * FROM `".EVNTCATS_TABLE."` |
---|
[3999] | 88 | WHERE `code` IS NOT NULL |
---|
[4219] | 89 | ")) != 0))) ? 'autolog_new' : 'autolog_entries'; |
---|
[4058] | 90 | |
---|
| 91 | // Rajouter un test pour que si $ec_exist_entries est faux, mais qu'il y a |
---|
| 92 | // quand même des entrées dans la table (donc pour gérer la duplication de |
---|
| 93 | // compte), l'onglet sélectionné par défaut soit celui de la gestion de la |
---|
| 94 | // duplication de compte. |
---|
| 95 | |
---|
[4019] | 96 | if (isset($_POST['ec_act1'])) { |
---|
[4092] | 97 | if ( |
---|
[4157] | 98 | $_POST['ec_act1'] == 'disable' and |
---|
| 99 | count($ec_lists['add_pages']) == 0 |
---|
| 100 | ) { |
---|
| 101 | $_POST['ec_act1'] = 'modify_entry_submit'; |
---|
| 102 | $_POST['ec_input_action'] = 'refused'; |
---|
| 103 | } |
---|
| 104 | if ( |
---|
[4058] | 105 | $_POST['ec_act1'] == 'duplicate_entry_ask' or |
---|
[4157] | 106 | $_POST['ec_act1'] == 'create_ask' |
---|
| 107 | ) |
---|
| 108 | $page['tab'] = 'autolog_new'; |
---|
| 109 | elseif ( |
---|
[4058] | 110 | $_POST['ec_act1'] == 'disable' or |
---|
| 111 | $_POST['ec_act1'] == 'modify_entry_ask' |
---|
[4019] | 112 | ) |
---|
[4157] | 113 | $page['tab'] = 'autolog_modif'; |
---|
[4026] | 114 | elseif ($_POST['ec_act1'] == 'create') |
---|
[4218] | 115 | $page['tab'] = (ec_create_modify_entry_OK()) ? |
---|
| 116 | 'autolog_entries' : 'autolog_new'; |
---|
| 117 | elseif ( |
---|
| 118 | isset($_POST['ec_entry_sel']) and |
---|
| 119 | is_numeric($_POST['ec_entry_sel']) |
---|
| 120 | ) { |
---|
[4219] | 121 | if ($_POST['ec_act1'] == 'duplicate_entry_submit') $page['tab'] = |
---|
| 122 | (ec_create_modify_entry_OK()) ? 'autolog_entries' : 'autolog_new'; |
---|
| 123 | elseif ($_POST['ec_act1'] == 'modify_entry_submit') $page['tab'] = |
---|
| 124 | (ec_create_modify_entry_OK()) ? 'autolog_entries' : 'autolog_modif'; |
---|
[4115] | 125 | else { |
---|
| 126 | $page['tab'] = 'autolog_entries'; |
---|
[4218] | 127 | if ($_POST['ec_act1'] == 'delete') { |
---|
| 128 | if (isset($_POST['ec_entry_sel'])) { |
---|
| 129 | ec_delete_entry_OK($_POST['ec_entry_sel']); |
---|
| 130 | build_ec_table(); |
---|
| 131 | } |
---|
| 132 | else ec_end1('ec_entry_sel', 'ec_bad_argument1'); |
---|
| 133 | } |
---|
[4219] | 134 | else if ($_POST['ec_act1'] == 'toggle_forced') |
---|
| 135 | ec_create_modify_entry_OK(); |
---|
[4115] | 136 | } |
---|
[4058] | 137 | } |
---|
[4019] | 138 | } |
---|
[4115] | 139 | else { |
---|
| 140 | if (isset($_GET['tab'])) switch ($_GET['tab']) { |
---|
[4157] | 141 | case 'autolog_modif': |
---|
[4115] | 142 | case 'autolog_new': |
---|
| 143 | case 'duplication': |
---|
| 144 | case 'config': |
---|
[4157] | 145 | $page['tab'] = $_GET['tab']; |
---|
| 146 | break; |
---|
[4115] | 147 | } |
---|
[3999] | 148 | } |
---|
[3960] | 149 | |
---|
[4219] | 150 | $ec_exist_entries = (mysql_num_rows(pwg_query(" |
---|
| 151 | SELECT * FROM `".EVNTCATS_TABLE."` |
---|
| 152 | WHERE `code` IS NOT NULL |
---|
| 153 | ")) != 0); |
---|
| 154 | |
---|
[3960] | 155 | $tabsheet = new tabsheet(); |
---|
[4157] | 156 | if ($ec_exist_entries) { |
---|
| 157 | $tabsheet->add('autolog_entries', |
---|
| 158 | l10n('ec_tab_autoid_entries'), |
---|
| 159 | $my_base_url.'&tab=autolog_entries'); |
---|
| 160 | $tabsheet->add('autolog_modif', |
---|
| 161 | l10n('ec_tab_autoid_modif'), |
---|
| 162 | $my_base_url.'&tab=autolog_modif'); |
---|
| 163 | } |
---|
| 164 | $tabsheet->add('autolog_new', |
---|
| 165 | l10n('ec_tab_autoid_new'), |
---|
[3999] | 166 | $my_base_url.'&tab=autolog_new'); |
---|
| 167 | $tabsheet->add('duplication', |
---|
| 168 | l10n('ec_tab_duplication'), |
---|
| 169 | $my_base_url.'&tab=duplication'); |
---|
[3960] | 170 | $tabsheet->add('config', |
---|
| 171 | l10n('ec_tab_config'), |
---|
| 172 | $my_base_url.'&tab=config'); |
---|
| 173 | |
---|
| 174 | $template->assign( |
---|
| 175 | array('U_HELP' => get_root_url().'popuphelp.php?page=event_cats')); |
---|
| 176 | |
---|
[4157] | 177 | $template->assign('EVNTCATS_URLS', array( |
---|
[3960] | 178 | 'ROOT' => EVNTCATS_PATH, |
---|
| 179 | )); |
---|
| 180 | |
---|
| 181 | /****************************************************************************/ |
---|
| 182 | |
---|
[4157] | 183 | $ec_file = ($page['tab'] == 'autolog_modif') ? 'autolog_new' : $page['tab']; |
---|
[3960] | 184 | |
---|
[4157] | 185 | include(EVNTCATS_PATH.'admin/'.$ec_file.'.inc.php'); |
---|
| 186 | |
---|
[4011] | 187 | $tabsheet->select($page['tab']); |
---|
| 188 | $tabsheet->assign(); |
---|
| 189 | |
---|
[3960] | 190 | /* |
---|
| 191 | print '<pre>'; |
---|
| 192 | //print_r('ROOT_URL : '.ROOT_URL.'<br>EVNTCATS_PATH : '.EVNTCATS_PATH); |
---|
| 193 | print('ROOT_URL : '.ROOT_URL.'<br>EVNTCATS_PATH : '.EVNTCATS_PATH); |
---|
| 194 | print '</pre>'; |
---|
| 195 | */ |
---|
| 196 | |
---|
[4092] | 197 | $template->assign('ec_howto', |
---|
| 198 | ($ec_howto and (count($page['errors']) ==0 and count($page['infos']) == 0))); |
---|
[3960] | 199 | |
---|
| 200 | $template->assign('EVNTCATS_PATH',EVNTCATS_PATH); |
---|
| 201 | $template->assign('RACINE_URL',ROOT_URL); |
---|
| 202 | |
---|
[4048] | 203 | if (isset($conf['ec_debug1'])) $template->assign('ec_debug1', array( |
---|
[4219] | 204 | 'POST' => str_from_var($_POST), |
---|
| 205 | 'ec_debug' => (isset($ec_debug)) ? str_from_var($ec_debug) : '(unset)', |
---|
[4048] | 206 | 'GET' => str_from_var($_GET), |
---|
| 207 | 'page' => str_from_var($page), |
---|
[4171] | 208 | 'ec_conf' => str_from_var($ec_conf), |
---|
[4048] | 209 | 'ec_lists' => (isset($ec_lists)) ? str_from_var($ec_lists) : '(unset)', |
---|
| 210 | 'code_list' => (isset($code_list)) ? str_from_var($code_list) : '(unset)', |
---|
| 211 | )); |
---|
[3960] | 212 | |
---|
[4157] | 213 | $template->set_filenames(array( |
---|
| 214 | 'evntcats_admin_content' => dirname(__FILE__).'/template/'.$ec_file.'.tpl' |
---|
| 215 | )); |
---|
[3960] | 216 | $template->assign_var_from_handle('ADMIN_CONTENT','evntcats_admin_content'); |
---|
| 217 | ?> |
---|