diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/config_default.inc.php | 5 | ||||
-rw-r--r-- | include/constants.php | 1 | ||||
-rw-r--r-- | include/functions.inc.php | 2 | ||||
-rw-r--r-- | include/functions_mail.inc.php | 18 | ||||
-rw-r--r-- | include/functions_user.inc.php | 230 |
5 files changed, 183 insertions, 73 deletions
diff --git a/include/config_default.inc.php b/include/config_default.inc.php index 88eb54856..cc949f7b2 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -136,9 +136,6 @@ $conf['newcat_default_visible'] = true; // automatically create private. $conf['newcat_default_status'] = 'public'; -// newuser_default_enabled_high : at creation, must a user with enabled_high or not -$conf['newuser_default_enabled_high'] = true; - // level_separator : character string used for separating a category level // to the sub level. Suggestions : ' / ', ' » ', ' → ', ' - ', // ' >' @@ -463,6 +460,8 @@ $conf['pass_convert'] = create_function('$s', 'return md5($s);'); // guest_id : id of the anonymous user $conf['guest_id'] = 2; +// default_user_id : id of user used for default value +$conf['default_user_id'] = $conf['guest_id']; // webmaster_id : webmaster'id. $conf['webmaster_id'] = 1; diff --git a/include/constants.php b/include/constants.php index f442bac99..b7a0d9929 100644 --- a/include/constants.php +++ b/include/constants.php @@ -29,6 +29,7 @@ define('PHPWG_VERSION', 'Alligator'); define('PHPWG_DOMAIN', 'phpwebgallery.net'); define('PHPWG_URL', 'http://www.'.PHPWG_DOMAIN); define('PHPWG_DEFAULT_LANGUAGE', 'en_UK.iso-8859-1'); +define('PHPWG_DEFAULT_TEMPLATE', 'yoga/clear'); // Error codes define('GENERAL_MESSAGE', 200); diff --git a/include/functions.inc.php b/include/functions.inc.php index b69c88a71..69174ea4d 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -644,7 +644,7 @@ function redirect_html( $url , $msg = '', $refresh_time = 0) include_once(get_language_filepath('common.lang.php')); trigger_action('loading_lang'); @include_once(get_language_filepath('local.lang.php')); - list($tmpl, $thm) = explode('/', $conf['default_template']); + list($tmpl, $thm) = explode('/', get_default_template()); $template = new Template(PHPWG_ROOT_PATH.'template/'.$tmpl, $thm); } else diff --git a/include/functions_mail.inc.php b/include/functions_mail.inc.php index 5f10d2f0a..d7314fb82 100644 --- a/include/functions_mail.inc.php +++ b/include/functions_mail.inc.php @@ -93,12 +93,12 @@ function format_email($name, $email) /**
* Returns an completed array template/theme
- * completed with $conf['default_template']
+ * completed with get_default_template()
*
* @params:
* - args: incompleted array of template/theme
- * o template: template to use [default $conf['default_template']]
- * o theme: template to use [default $conf['default_template']]
+ * o template: template to use [default get_default_template()]
+ * o theme: template to use [default get_default_template()]
*/
function get_array_template_theme($args = array())
{
@@ -108,7 +108,7 @@ function get_array_template_theme($args = array()) if (empty($args['template']) or empty($args['theme']))
{
- list($res['template'], $res['theme']) = explode('/', $conf['default_template']);
+ list($res['template'], $res['theme']) = explode('/', get_default_template());
}
if (!empty($args['template']))
@@ -130,8 +130,8 @@ function get_array_template_theme($args = array()) * @params:
* - email_format: mail format
* - args: function params of mail function:
- * o template: template to use [default $conf['default_template']]
- * o theme: template to use [default $conf['default_template']]
+ * o template: template to use [default get_default_template()]
+ * o theme: template to use [default get_default_template()]
*/
function get_mail_template($email_format, $args = array())
{
@@ -298,7 +298,7 @@ order by get_l10n_args('Browser: %s', $_SERVER['HTTP_USER_AGENT'])
);
- switch_lang_to($conf['default_language']); + switch_lang_to(get_default_language()); $return = pwg_mail ( @@ -451,8 +451,8 @@ WHERE * o content: content of mail [default value ''] * o content_format: format of mail content [default value 'text/plain'] * o email_format: global mail format [default value $conf_mail['default_email_format']]
- * o template: template to use [default $conf['default_template']]
- * o theme: template to use [default $conf['default_template']] + * o template: template to use [default get_default_template()]
+ * o theme: template to use [default get_default_template()] * * @return boolean (Ok or not) */
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index c3608eee3..635055f1a 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -147,25 +147,9 @@ function build_user( $user_id, $use_cache ) global $conf; $user['id'] = $user_id; $user = array_merge( $user, getuserdata($user_id, $use_cache) ); - if ( $user['id'] == $conf['guest_id']) - { - $user['is_the_guest']=true; - $user['template'] = $conf['default_template']; - $user['nb_image_line'] = $conf['nb_image_line']; - $user['nb_line_page'] = $conf['nb_line_page']; - $user['language'] = $conf['default_language']; - $user['maxwidth'] = $conf['default_maxwidth']; - $user['maxheight'] = $conf['default_maxheight']; - $user['recent_period'] = $conf['recent_period']; - $user['expand'] = $conf['auto_expand']; - $user['show_nb_comments'] = $conf['show_nb_comments']; - $user['show_nb_hits'] = $conf['show_nb_hits']; - $user['enabled_high'] = $conf['newuser_default_enabled_high']; - } - else - { - $user['is_the_guest']=false; - } + $user['is_the_guest'] = ($user['id'] == $conf['guest_id']); + $user['is_the_default'] = ($user['id'] == $conf['default_user_id']); + // calculation of the number of picture to display per page $user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page']; @@ -726,51 +710,150 @@ SELECT COUNT(*) } } +/* + * Returns a array with default user value + * + * @param convert_str allows to convert string value if necessary + */ +function get_default_user_info($convert_str = true) +{ + global $page, $conf; + + if (!isset($page['cache_default_user'])) + { + $query = 'select * from '.USER_INFOS_TABLE. + ' where user_id = '.$conf['default_user_id'].';'; + + $result = pwg_query($query); + $page['cache_default_user'] = mysql_fetch_assoc($result); + } + + if (is_array($page['cache_default_user']) and $convert_str) + { + $default_user = array(); + foreach ($page['cache_default_user'] as $name => $value) + { + // If the field is true or false, the variable is transformed into a + // boolean value. + if ($value == 'true' or $value == 'false') + { + $default_user[$name] = get_boolean($value); + } + else + { + $default_user[$name] = $value; + } + } + return $default_user; + } + else + { + return $page['cache_default_user']; + } +} + +/* + * Returns a default user value + * + * @param value_name: name of value + * @param sos_value: value used if don't exist value + */ +function get_default_user_value($value_name, $sos_value) +{ + $default_user = get_default_user_info(true); + if ($default_user === false or !isset($default_user[$value_name])) + { + return $sos_value; + } + else + { + return $default_user[$value_name]; + } +} + +/* + * Returns the default template value + * + */ +function get_default_template() +{ + return get_default_user_value('template', PHPWG_DEFAULT_TEMPLATE); +} + +/* + * Returns the default language value + * + */ +function get_default_language() +{ + return get_default_user_value('language', PHPWG_DEFAULT_LANGUAGE); +} + /** * add user informations based on default values * - * @param int user_id + * @param int user_id / array of user_if */ -function create_user_infos($user_id) +function create_user_infos($arg_id) { global $conf; - list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); - - if ($user_id == $conf['webmaster_id']) + if (is_array($arg_id)) { - $status = 'webmaster'; + $user_ids = $arg_id; } - else if ($user_id == $conf['guest_id']) + else { - $status = 'guest'; + $user_ids = array(); + if (is_integer($arg_id)) + { + $user_ids[] = $arg_id; + } } - else + + if (!empty($user_ids)) { - $status = 'normal'; - } - - $insert = - array( - 'user_id' => $user_id, - 'status' => $status, - 'template' => $conf['default_template'], - 'nb_image_line' => $conf['nb_image_line'], - 'nb_line_page' => $conf['nb_line_page'], - 'language' => $conf['default_language'], - 'recent_period' => $conf['recent_period'], - 'expand' => boolean_to_string($conf['auto_expand']), - 'show_nb_comments' => boolean_to_string($conf['show_nb_comments']), - 'show_nb_hits' => boolean_to_string($conf['show_nb_hits']), - 'maxwidth' => $conf['default_maxwidth'], - 'maxheight' => $conf['default_maxheight'], - 'registration_date' => $dbnow, - 'enabled_high' => - boolean_to_string($conf['newuser_default_enabled_high']), - ); + $inserts = array(); + list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); - include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); - mass_inserts(USER_INFOS_TABLE, array_keys($insert), array($insert)); + $default_user = get_default_user_info(false); + if ($default_user === false) + { + // Default on structure are used + $default_user = array(); + } + + + foreach ($user_ids as $user_id) + { + if ($user_id == $conf['webmaster_id']) + { + $status = 'webmaster'; + } + else if (($user_id == $conf['guest_id']) or + ($user_id == $conf['default_user_id'])) + { + $status = 'guest'; + } + else + { + $status = 'normal'; + } + + $insert = + array( + 'user_id' => $user_id, + 'status' => $status, + 'registration_date' => $dbnow + ); + + array_push($inserts, $insert); + } + + include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); + mass_inserts(USER_INFOS_TABLE, array_keys($inserts[0]), $inserts); + + } } /** @@ -823,20 +906,47 @@ function get_language_filepath($filename, $dirname = '', $language = '') } $dirname .= 'language'.'/'; - $directories = array(); - if ( !empty($language) ) - { - $directories[] = $dirname.$language; - } + $dir_methods = array(); + if (!empty($language)) { - $directories[] = $dirname.$user['language']; + $dir_methods[] = 1; } - $directories[] = $dirname.$conf['default_language']; - $directories[] = $dirname.PHPWG_DEFAULT_LANGUAGE; - foreach ($directories as $directory) + $dir_methods[] = 2; + $dir_methods[] = 3; + $dir_methods[] = 4; + + foreach ($dir_methods as $dir_method) { + switch ($dir_method) + { + case '1': + { + $directory = $dirname.$language; + break; + } + case '2': + { + $directory = $dirname.$user['language']; + break; + } + case '3': + { + $directory = $dirname.get_default_language(); + break; + } + case '4': + default: + { + $directory = $dirname.PHPWG_DEFAULT_LANGUAGE; + break; + } + { + $directory = '.'; + } + } + $filepath = $directory.'/'.$filename; if (file_exists($filepath)) |