aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/common.inc.php3
-rw-r--r--include/config_default.inc.php4
-rw-r--r--include/functions.inc.php2
-rw-r--r--include/functions_comment.inc.php5
-rw-r--r--include/functions_html.inc.php2
-rw-r--r--include/functions_user.inc.php54
-rw-r--r--include/menubar.inc.php4
-rw-r--r--include/page_tail.php5
-rw-r--r--include/picture_comment.inc.php17
-rw-r--r--include/ws_functions.inc.php8
10 files changed, 65 insertions, 39 deletions
diff --git a/include/common.inc.php b/include/common.inc.php
index 8c7c9d85d..847a52b87 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -4,7 +4,6 @@
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
-// | branch : BSF (Best So Far)
// | file : $Id$
// | last update : $Date$
// | last modifier : $Author$
@@ -165,7 +164,7 @@ trigger_action('loading_lang');
// only now we can set the localized username of the guest user (and not in
// include/user.inc.php)
-if ($user['is_the_guest'])
+if (is_a_guest())
{
$user['username'] = $lang['guest'];
}
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index 0ac388e33..a12770ef2 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -173,7 +173,7 @@ $conf['show_version'] = true;
// $conf['links'] = array(
// 'http://phpwebgallery.net' => array('label' => 'PWG website', 'new_window' => false, 'eval_visible' => 'return true;'),
// 'http://forum.phpwebgallery.net' => array('label' => 'For ADMIN', 'new_window' => true, 'eval_visible' => 'return is_admin();'),
-// 'http://phpwebgallery.net/doc' => array('label' => 'For Guest', 'new_window' => true, 'eval_visible' => 'return $user[\'is_the_guest\'];'),
+// 'http://phpwebgallery.net/doc' => array('label' => 'For Guest', 'new_window' => true, 'eval_visible' => 'return is_a_guest();'),
// 'http://download.gna.org/phpwebgallery/' =>
// array('label' => 'PopUp', 'new_window' => true,
// 'nw_name' => 'PopUp', 'nw_features' => 'width=800,height=450,location=no,status=no,toolbar=no,scrollbars=no,menubar=no'),
@@ -213,7 +213,7 @@ $conf['links'] = array();
// '' condition is equivalent to 'return true;'
// $conf['random_index_redirect'] = array(
// PHPWG_ROOT_PATH.'index.php?/best_rated' => 'return true;',
-// PHPWG_ROOT_PATH.'index.php?/recent_pics' => 'return $user[\'is_the_guest\'];',
+// PHPWG_ROOT_PATH.'index.php?/recent_pics' => 'return is_a_guest();',
// PHPWG_ROOT_PATH.'random.php' => '',
// PHPWG_ROOT_PATH.'index.php?/categories' => '',
// );
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 81c5f6009..6488bec6b 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -423,7 +423,7 @@ function pwg_log($image_id = null, $image_type = null)
{
$do_log = false;
}
- if ($user['is_the_guest'] and !$conf['history_guest'])
+ if (is_a_guest() and !$conf['history_guest'])
{
$do_log = false;
}
diff --git a/include/functions_comment.inc.php b/include/functions_comment.inc.php
index 15a72d2f6..3a8139a9c 100644
--- a/include/functions_comment.inc.php
+++ b/include/functions_comment.inc.php
@@ -58,7 +58,7 @@ function user_comment_check($action, $comment)
return $action;
// we do here only BASIC spam check (plugins can do more)
- if ( !$user['is_the_guest'] )
+ if ( !is_a_guest() )
return $action;
$link_count = preg_match_all( '/https?:\/\//',
@@ -118,7 +118,8 @@ function insert_user_comment( &$comm, $key, &$infos )
$comment_action='moderate'; //one of validate, moderate, reject
}
- if ( $user['is_the_guest'] )
+ // display author field if the user status is guest or generic
+ if (!is_classic_user())
{
if ( empty($comm['author']) )
{
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php
index db6d12710..af74d0f69 100644
--- a/include/functions_html.inc.php
+++ b/include/functions_html.inc.php
@@ -574,7 +574,7 @@ function access_denied()
get_root_url().'identification.php?redirect='
.urlencode(urlencode($_SERVER['REQUEST_URI']));
- if ( isset($user['is_the_guest']) and !$user['is_the_guest'] )
+ if ( isset($user) and !is_a_guest() )
{
echo '<div style="text-align:center;">'.$lang['access_forbiden'].'<br />';
echo '<a href="'.get_root_url().'identification.php">'.$lang['identification'].'</a>&nbsp;';
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 = '')
diff --git a/include/menubar.inc.php b/include/menubar.inc.php
index aa3f490ca..56a597e2d 100644
--- a/include/menubar.inc.php
+++ b/include/menubar.inc.php
@@ -163,7 +163,7 @@ if ('tags' == $page['section'])
}
//---------------------------------------------------------- special categories
// favorites categories
-if ( !$user['is_the_guest'] )
+if ( !is_a_guest() )
{
$template->assign_block_vars('username', array());
@@ -242,7 +242,7 @@ $template->assign_block_vars(
);
//--------------------------------------------------------------------- summary
-if ($user['is_the_guest'])
+if (is_a_guest())
{
$template->assign_block_vars('login', array());
diff --git a/include/page_tail.php b/include/page_tail.php
index 2a03cbd86..0fda300d5 100644
--- a/include/page_tail.php
+++ b/include/page_tail.php
@@ -4,8 +4,7 @@
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
-// | branch : BSF (Best So Far)
-// | file : $RCSfile$
+// | file : $Id$
// | last update : $Date$
// | last modifier : $Author$
// | revision : $Revision$
@@ -38,7 +37,7 @@ $template->assign_vars(
//--------------------------------------------------------------------- contact
-if (!$user['is_the_guest'])
+if (!is_a_guest())
{
$template->assign_block_vars(
'contact',
diff --git a/include/picture_comment.inc.php b/include/picture_comment.inc.php
index c84f2a629..cab49ffcf 100644
--- a/include/picture_comment.inc.php
+++ b/include/picture_comment.inc.php
@@ -43,7 +43,7 @@ foreach ($related_categories as $category)
if ( $page['show_comments'] and isset( $_POST['content'] ) )
{
- if ( $user['is_the_guest'] and !$conf['comments_forall'] )
+ if ( is_a_guest() and !$conf['comments_forall'] )
{
die ('Session expired');
}
@@ -61,9 +61,9 @@ if ( $page['show_comments'] and isset( $_POST['content'] ) )
switch ($comment_action)
{
case 'moderate':
- array_push( $infos, $lang['comment_to_validate'] );
+ array_push( $infos, l10n('comment_to_validate') );
case 'validate':
- array_push( $infos, $lang['comment_added']);
+ array_push( $infos, l10n('comment_added'));
break;
case 'reject':
set_status_header(403);
@@ -137,7 +137,7 @@ SELECT id,author,date,image_id,content
'comments.comment',
array(
'COMMENT_AUTHOR' => empty($row['author'])
- ? $lang['guest']
+ ? l10n('guest')
: $row['author'],
'COMMENT_DATE' => format_date(
@@ -168,8 +168,8 @@ SELECT id,author,date,image_id,content
}
}
- if (!$user['is_the_guest']
- or ($user['is_the_guest'] and $conf['comments_forall']))
+ if (!is_a_guest()
+ or (is_a_guest() and $conf['comments_forall']))
{
include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
$key = get_comment_post_key($page['image_id']);
@@ -183,8 +183,9 @@ SELECT id,author,date,image_id,content
'KEY' => $key,
'CONTENT' => $content
));
- // display author field if the user is not logged in
- if ($user['is_the_guest'])
+
+ // display author field if the user status is guest or generic
+ if (!is_classic_user())
{
$template->assign_block_vars(
'comments.add_comment.author_field', array()
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index 43a50b093..151296de0 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -702,8 +702,8 @@ SELECT id, date, author, content
$comment_post_data = null;
if ($is_commentable and
- (!$user['is_the_guest']
- or ($user['is_the_guest'] and $conf['comments_forall'] )
+ (!is_a_guest()
+ or (is_a_guest() and $conf['comments_forall'] )
)
)
{
@@ -884,7 +884,7 @@ function ws_session_login($params, &$service)
function ws_session_logout($params, &$service)
{
global $user, $conf;
- if (!$user['is_the_guest'])
+ if (!is_a_guest())
{
$_SESSION = array();
session_unset();
@@ -902,7 +902,7 @@ function ws_session_getStatus($params, &$service)
{
global $user, $lang_info;
$res = array();
- $res['username'] = $user['is_the_guest'] ? 'guest' : $user['username'];
+ $res['username'] = is_a_guest() ? 'guest' : $user['username'];
foreach ( array('status', 'template', 'theme', 'language') as $k )
{
$res[$k] = $user[$k];