'0', // // 'dup_allow' // duplication allowance : => '0', // 0 : no account ; // 1 : all accounts ; // 2 : specified by group and user ids ; // 'auto_code_dg_nb' // number of digits when creating a new code => '10', // automatically // 'duplic_gen' // whether Generic accounts allow to be duplicated => '0', // // 'duplic_type' // the kind of account type (Contacts, Friends, => '0', // Family) allowed to duplicate account // 'howto' // whether the small aknowledgement message has => '0', // already been displayed // 'unknown_code' // what to do in case an unknown code is used with => '1', // "autolog" parameter : // 0 : nothing (display home page, index.php (not // logged in of course)) ; // 1 : display "access denied" page ; // 2 : display an Additional Page precised below. // 'unknown_code_ap_id' // the id of the Additional Page which must be used => '0', // in case of usage of an unknow code. ); $ec_conf_index = array_flip(array_keys($ec_conf_default)); $t = array(); $u = '0'; $v = false; if ($v = ( ($t = mysql_fetch_row(pwg_query(" SELECT `value` FROM `".CONFIG_TABLE."` WHERE `param` = 'event_cats'; "))) !== false) ) { $v = (count($ec_conf = explode(',', $t[0])) == count($ec_conf_index)); $u = $ec_conf[0]; } // $v is false // _ if the entry in the table doesn't exist ; // _ if the entry in the table exists, but its number of parameters is // different than the number of default parameters. // $u is '0' if the plugin has not yet been activated, '1' if it has been. if (!$v) { $ec_conf = array_values($ec_conf_default); change_ec_conf('activated', $u); // writes in the DB } // now : // _ the number of parameters is the same in the DB as the number of // default parameters ; // _ the parameters have the default values if needed ; // _ the plugin shows it is active if it is the case. unset($t, $u, $v); /* * change_ec_conf($c, $v) * updates Event Cats configuration values in the database as well as in * $ec_conf. * * @param * $c : conf value to update ; * $v : value to give to $ec_conf[$c]. * @return * true or false whether the change was OK or not */ function change_ec_conf($c, $v) { global $ec_conf, $page, $ec_conf_index; if (array_key_exists($c, $ec_conf_index)) { $ec_conf[$ec_conf_index[$c]] = $v; return (pwg_query(" UPDATE `".CONFIG_TABLE."` SET `value` = \"".implode(',', $ec_conf)."\" WHERE `param` = 'event_cats'; ") !== false); } else { $page['errors'][] = 'Bad change_ec_conf argument'; return false; } } /* * read_ec_conf($c) * returns the value in $ec_conf using string keys. * * @param * $c : conf value to update ; * @return * $ec_conf value */ function read_ec_conf($c) { global $ec_conf, $page, $ec_conf_index; if (array_key_exists($c, $ec_conf_index)) return $ec_conf[$ec_conf_index[$c]]; else { $page['errors'][] = 'Bad read_ec_conf argument'; return false; } } ?>