From 182fb00f8f7873d220ab8502a31357f9245fbf8f Mon Sep 17 00:00:00 2001 From: rub Date: Tue, 5 Jun 2007 22:01:15 +0000 Subject: Resolved issue 0000697: with generic user a author name is necessary to comment picture. + Change way to determinate if user is a guest (use functions like is_admin) git-svn-id: http://piwigo.org/svn/trunk@2029 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_user.inc.php | 54 +++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 14 deletions(-) (limited to 'include/functions_user.inc.php') diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index 5ed6c169f..d9e63c437 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -146,8 +146,6 @@ function build_user( $user_id, $use_cache ) global $conf; $user['id'] = $user_id; $user = array_merge( $user, getuserdata($user_id, $use_cache) ); - $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']; @@ -1015,11 +1013,11 @@ function log_user($user_id, $remember_me) { $cookie = array('id' => (int)$user_id, 'key' => $key); setcookie($conf['remember_me_name'], - serialize($cookie), - time()+$conf['remember_me_length'], - cookie_path() - ); - } + serialize($cookie), + time()+$conf['remember_me_length'], + cookie_path() + ); + } } else { // make sure we clean any remember me ... @@ -1090,13 +1088,12 @@ SELECT '.$conf['user_fields']['id'].' AS id, } /* - * Return access_type definition of uuser - * Test does with user status - * @return bool + * Return user status used in this library + * @return string */ -function get_access_type_status($user_status='') +function get_user_status($user_status) { - global $user, $conf; + global $user; if (empty($user_status)) { @@ -1110,8 +1107,19 @@ function get_access_type_status($user_status='') $user_status = ''; } } + return $user_status; +} + +/* + * Return access_type definition of uuser + * Test does with user status + * @return bool +*/ +function get_access_type_status($user_status='') +{ + global $conf; - switch ($user_status) + switch (get_user_status($user_status)) { case 'guest': { @@ -1173,7 +1181,25 @@ function check_status($access_type, $user_status = '') } /* - * Return if user is an administrator + * Return if user is only a guest + * @return bool +*/ + function is_a_guest($user_status = '') +{ + return get_user_status($user_status) == 'guest'; +} + +/* + * Return if user is, at least, a classic user + * @return bool +*/ + function is_classic_user($user_status = '') +{ + return is_autorize_status(ACCESS_CLASSIC, $user_status); +} + +/* + * Return if user is, at least, an administrator * @return bool */ function is_admin($user_status = '') -- cgit v1.2.3