Changeset 4239 for extensions/event_cats
- Timestamp:
- Nov 10, 2009, 4:04:07 PM (14 years ago)
- Location:
- extensions/event_cats
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/event_cats/admin/evntcats_admin.php
r4219 r4239 38 38 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 39 39 40 global $template, $conf, $lang, $ test1, $prefixeTable, $ec_conf, $page, $ec_debug,40 global $template, $conf, $lang, $prefixeTable, $ec_conf, $page, $ec_debug, 41 41 $ec_lists, // array of following arrays : 42 42 // $ec_lists['ec_table'] : … … 68 68 EVNTCATS_PATH.'admin/evntcats_theme.css">' 69 69 ); 70 $ec_debug = array();70 if (!isset($ec_debug)) $ec_debug = array(); 71 71 72 72 if ( … … 75 75 ) change_ec_conf('auto_code_dg_nb', $_POST['ec_in_up_auto_code_length']); 76 76 77 $ec_howto = (read_ec_conf('howto') == '0'); 78 if ($ec_howto) change_ec_conf('howto', '1'); 77 if ($ec_howto = (read_ec_conf('howto') == '0')) change_ec_conf('howto', '1'); 79 78 80 79 build_ec_lists(); // in evntcats_main_funcs.php -
extensions/event_cats/include/ec_conf.inc.php
r4233 r4239 23 23 // +-----------------------------------------------------------------------+ 24 24 25 /***************************************************************************** 26 Parameters ($ec_conf) : 27 _ plugin activated ($ec_conf[0] <=> read_ec_conf('activated')) yes/no ; 28 _ duplication allowance ($ec_conf[1] <=> read_ec_conf('dup_allow')) : 29 0 : no account ; 30 1 : all accounts ; 31 2 : no account but those specified ; \ 32 3 : all accounts but those specified ; | could be different finally 33 _ the number of digits when creating a new code automatically 34 ($ec_conf[2] <=> read_ec_conf('auto_code_dg_nb')) ; 35 _ the way the "register" link is displayed, together with the original $lang 36 value for this label ( $ec_conf[3] <=> read_ec_conf('') ) ; 37 _ whether the "how to" banner has already been displayed or not 38 ($ec_conf[4] <=> read_ec_conf('howto')) ; 39 _ what to do in case an unknown code is used with "autolog" parameter 40 ($ec_conf[5] <=> read_ec_conf('unknown_code')) : 41 0 : nothing ("goto" home page, index.php (not logged in of course)) ; 42 1 : redirected to "access denied" page ; 43 2 : redirected to an Additional Page precised below. 44 _ the id of the Additional Page which must be used in case of usage of an 45 unknow code ($ec_conf[6] <=> read_ec_conf('unknown_code_ap_id')). 46 *****************************************************************************/ 25 global $ec_conf, $page, $ec_conf_index; 47 26 48 global $ec_conf, $page; 27 // $ec_conf initalization 49 28 50 // $ec_conf initalization / check 51 if ($t = mysql_fetch_row(pwg_query(" 52 SELECT `value` 53 FROM `".CONFIG_TABLE."` 54 WHERE `param` = 'event_cats'; 55 "))) $ec_conf = explode(',' , $t[0]); 56 else { 57 $ec_conf = explode(',' , '0,1,10,0,0,0,0'); 58 if (!change_ec_conf('activated', 0)) 59 $page['errors'][] = 'Error updating $ec_conf'; 29 $ec_conf_default = array( // PLUGIN CONFIGURATION ($ec_conf) : 30 // --------------------------------- 31 'activated' // plugin activated 32 => '0', // 33 // 34 'dup_allow' // duplication allowance : 35 => '0', // 0 : no account ; 36 // 1 : all accounts ; 37 // 2 : specified by group and user ids ; 38 // 39 'auto_code_dg_nb' // number of digits when creating a new code 40 => '10', // automatically 41 // 42 'reg_display' // the way the "register" link is displayed, 43 => '0', // together with the original $lang value for this 44 // label 45 // 46 'howto' // whether the small aknowledgement message has 47 => '0', // already been displayed 48 // 49 'unknown_code' // what to do in case an unknown code is used with 50 => '1', // "autolog" parameter : 51 // 0 : nothing (display home page, index.php (not 52 // logged in of course)) ; 53 // 1 : display "access denied" page ; 54 // 2 : display an Additional Page precised below. 55 // 56 'unknown_code_ap_id' // the id of the Additional Page which must be used 57 => '0', // in case of usage of an unknow code. 58 ); 59 60 $ec_conf_index = array_flip(array_keys($ec_conf_default)); 61 62 $t = array(); $u = '0'; $v = false; 63 if ($v = ( 64 ($t = mysql_fetch_row(pwg_query(" 65 SELECT `value` 66 FROM `".CONFIG_TABLE."` 67 WHERE `param` = 'event_cats'; 68 "))) !== false) 69 ) { 70 $v = (count($ec_conf = explode(',', $t[0])) == count($ec_conf_index)); 71 $u = $ec_conf[0]; 60 72 } 73 // $v is false 74 // _ if the entry in the table doesn't exist ; 75 // _ if the entry in the table exists, but its number of parameters is 76 // different than the number of default parameters. 77 // $u is '0' if the plugin has not yet been activated, '1' if it has been. 78 if (!$v) { 79 $ec_conf = array_values($ec_conf_default); 80 change_ec_conf('activated', $u); 81 } 82 // now : 83 // _ the number of parameters is the same in the DB as the number of 84 // default parameters ; 85 // _ the parameters have the default values if needed ; 86 // _ the plugin shows it is active if it is the case. 87 unset($t, $u, $v); 61 88 62 89 /* … … 72 99 */ 73 100 function change_ec_conf($c, $v) { 74 global $ec_conf, $page; 75 switch ($c) { 76 case 'activated': 77 $ec_conf[0] = $v; 78 break; 79 case 'dup_allow': 80 $ec_conf[1] = $v; 81 break; 82 case 'auto_code_dg_nb': 83 $ec_conf[2] = $v; 84 break; 85 case 'reg_display': 86 $ec_conf[3] = $v; 87 break; 88 case 'howto': 89 $ec_conf[4] = $v; 90 break; 91 case 'unknown_code': 92 $ec_conf[5] = $v; 93 break; 94 case 'unknown_code_ap_id': 95 $ec_conf[6] = $v; 96 break; 97 default: 98 $page['errors'][] = 'Bad change_ec_conf argument'; 101 global $ec_conf, $page, $ec_conf_index; 102 if (array_key_exists($c, $ec_conf_index)) { 103 $ec_conf[$ec_conf_index[$c]] = $v; 104 return (pwg_query(" 105 UPDATE `".CONFIG_TABLE."` 106 SET `value` = \"".implode(',', $ec_conf)."\" 107 WHERE `param` = 'event_cats'; 108 ") !== false); 109 } 110 else { 111 $page['errors'][] = 'Bad change_ec_conf argument'; 99 112 return false; 100 113 } 101 return (pwg_query("102 UPDATE `".CONFIG_TABLE."`103 SET `value` = \"".implode(',', $ec_conf)."\"104 WHERE `param` = 'event_cats';105 ") !== false);106 114 } 107 115 … … 116 124 */ 117 125 function read_ec_conf($c) { 118 global $ec_conf, $page; 119 switch ($c) { 120 case 'activated' : return $ec_conf[0]; 121 case 'dup_allow' : return $ec_conf[1]; 122 case 'auto_code_dg_nb' : return $ec_conf[2]; 123 case 'reg_display' : return $ec_conf[3]; 124 case 'howto' : return $ec_conf[4]; 125 case 'unknown_code' : return $ec_conf[5]; 126 case 'unknown_code_ap_id': return $ec_conf[6]; 127 default: 128 $page['errors'][] = 'Bad read_ec_conf argument'; 126 global $ec_conf, $page, $ec_conf_index; 127 if (array_key_exists($c, $ec_conf_index)) 128 return $ec_conf[$ec_conf_index[$c]]; 129 else { 130 $page['errors'][] = 'Bad read_ec_conf argument'; 129 131 return false; 130 132 } -
extensions/event_cats/include/evntcats_main_funcs.inc.php
r4219 r4239 32 32 // +-----------------------------------------------------------------------+ 33 33 34 global $conf;35 36 34 include_once(EVNTCATS_PATH.'include/ec_conf.inc.php'); 37 35 … … 111 109 $to_correct = array(); 112 110 111 /* 113 112 // $to_correct is needed cause following code would not work everywhere : 114 /*115 113 foreach ($table as $value) { 116 114 if ($value == $value_to_check and $value == $problem) { … … 196 194 */ 197 195 function build_ec_table() { 198 global $ec_lists, $ conf, $ec_ap_ok;196 global $ec_lists, $ec_ap_ok; 199 197 200 198 $ec_lists['ec_table'] = array(); -
extensions/event_cats/main.inc.php
r4233 r4239 38 38 //ini_set('display_errors', true); 39 39 40 global 41 $conf, $prefixeTable, 40 global $conf, $prefixeTable, $ec_lists, $ec_debug, 42 41 $ec_ap_ok; // whether Additional Pages is installed and activated 43 42 … … 49 48 $ec_ap_ok = defined('AP_DIR'); 50 49 51 if (!isset($ec_lists)) { 52 $ec_lists = array(); 53 } 50 if (!isset($ec_lists)) $ec_lists = array(); 54 51 55 52 include_once(EVNTCATS_PATH.'include/evntcats_main_funcs.inc.php'); -
extensions/event_cats/maintain.inc.php
r4092 r4239 37 37 38 38 function plugin_uninstall() { 39 40 39 global $prefixeTable, $ec_conf; 41 40 … … 46 45 47 46 function plugin_install() { 48 49 47 global $prefixeTable; 50 48 … … 133 131 134 132 */ 135 pwg_query( '136 INSERT INTO '.CONFIG_TABLE.' (param,value,comment)137 VALUES ("event_cats","0,1,0,0","Paramètres du plugin Event Cats");138 ');139 change_ec_conf('activated', 0);133 pwg_query(" 134 INSERT INTO `".CONFIG_TABLE."` (`param`,`value`,`comment`) 135 VALUES ('event_cats','0','Paramètres du plugin Event Cats'); 136 "); 137 change_ec_conf('activated', '0'); 140 138 return $q; 141 139 } 142 140 143 141 function plugin_activate() { 144 change_ec_conf('activated', 1);142 change_ec_conf('activated', '1'); 145 143 } 146 144 147 145 function plugin_deactivate() { 148 change_ec_conf('activated', 0);146 change_ec_conf('activated', '0'); 149 147 } 150 148
Note: See TracChangeset
for help on using the changeset viewer.