aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrub <rub@piwigo.org>2007-06-05 22:01:15 +0000
committerrub <rub@piwigo.org>2007-06-05 22:01:15 +0000
commit182fb00f8f7873d220ab8502a31357f9245fbf8f (patch)
treef9e2a44bfc3d93bea8d2e804286a56c88e69ae98
parenta42b553c48acfea369579186a6ca6ea2cdb3ca62 (diff)
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
Diffstat (limited to '')
-rw-r--r--feed.php2
-rw-r--r--identification.php2
-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
-rw-r--r--notification.php3
-rw-r--r--picture.php2
-rw-r--r--profile.php4
-rw-r--r--ws.php2
16 files changed, 72 insertions, 47 deletions
diff --git a/feed.php b/feed.php
index 1c215592a..7bf3f4f53 100644
--- a/feed.php
+++ b/feed.php
@@ -91,7 +91,7 @@ SELECT user_id,
else
{
$image_only = true;
- if (!$user['is_the_guest'])
+ if (!is_a_guest())
{// auto session was created - so switch to guest
$user = build_user( $conf['guest_id'], true );
}
diff --git a/identification.php b/identification.php
index ac546a642..434cc06c3 100644
--- a/identification.php
+++ b/identification.php
@@ -40,7 +40,7 @@ $redirect_to = '';
if ( !empty($_GET['redirect']) )
{
$redirect_to = urldecode($_GET['redirect']);
- if ( $user['is_the_guest'] )
+ if ( is_a_guest() )
{
array_push($errors, l10n('access_forbiden'));
}
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];
diff --git a/notification.php b/notification.php
index 4154501c9..7bbe66cc1 100644
--- a/notification.php
+++ b/notification.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$
@@ -53,7 +52,7 @@ pwg_query($query);
$feed_url=PHPWG_ROOT_PATH.'feed.php';
-if ($user['is_the_guest'])
+if (is_a_guest())
{
$feed_image_only_url=$feed_url;
$feed_url .= '?feed='.$page['feed'];
diff --git a/picture.php b/picture.php
index 216355be4..cc43eab95 100644
--- a/picture.php
+++ b/picture.php
@@ -578,7 +578,7 @@ if (is_admin())
}
// favorite manipulation
-if (!$user['is_the_guest'])
+if (!is_a_guest())
{
// verify if the picture is already in the favorite of the user
$query = '
diff --git a/profile.php b/profile.php
index 127ba3cc8..922f4c6d1 100644
--- a/profile.php
+++ b/profile.php
@@ -206,7 +206,7 @@ function save_profile_from_post(&$userdata, &$errors)
function load_profile_in_template($url_action, $url_redirect, $userdata)
{
- global $template;
+ global $template, $conf;
$template->set_filename('profile_content', 'profile_content.tpl');
@@ -293,7 +293,7 @@ function load_profile_in_template($url_action, $url_redirect, $userdata)
));
}
- if (!($userdata['is_the_guest'] or $userdata['is_the_default']))
+ if (!(in_array($userdata['id'], array($conf['guest_id'], $conf['default_user_id']))))
{
$template->assign_block_vars('not_special_user', array());
if ( !defined('IN_ADMIN') )
diff --git a/ws.php b/ws.php
index 124e531f0..2d8a4a35a 100644
--- a/ws.php
+++ b/ws.php
@@ -80,7 +80,7 @@ function ws_addDefaultMethods( $arr )
$service->addMethod('pwg.images.addComment', 'ws_images_addComment',
array(
'image_id' => array(),
- 'author' => array( 'default' => $user['is_the_guest']? 'guest':$user['username']),
+ 'author' => array( 'default' => is_a_guest()? 'guest':$user['username']),
'content' => array(),
'key' => array(),
),