Skip to content

Commit

Permalink
Issue 578
Browse files Browse the repository at this point in the history
User guest must be real user

Step 1: guest is a real user

On next commit, I finish installation and use of guest of user list and group

git-svn-id: http://piwigo.org/svn/trunk@1926 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rub committed Mar 28, 2007
1 parent b86d4ac commit 7c43a3c
Show file tree
Hide file tree
Showing 20 changed files with 581 additions and 601 deletions.
130 changes: 29 additions & 101 deletions admin/configuration.php
Expand Up @@ -73,6 +73,7 @@
if (isset($_POST['submit']) and !is_adviser())
{
$int_pattern = '/^\d+$/';

switch ($page['section'])
{
case 'main' :
Expand Down Expand Up @@ -113,28 +114,7 @@
}
case 'default' :
{
// periods must be integer values, they represents number of days
if (!preg_match($int_pattern, $_POST['recent_period'])
or $_POST['recent_period'] <= 0)
{
array_push($page['errors'], $lang['periods_error']);
}
// maxwidth
if (isset($_POST['default_maxwidth'])
and !empty($_POST['default_maxwidth'])
and (!preg_match($int_pattern, $_POST['default_maxwidth'])
or $_POST['default_maxwidth'] < 50))
{
array_push($page['errors'], $lang['maxwidth_error']);
}
// maxheight
if (isset($_POST['default_maxheight'])
and !empty($_POST['default_maxheight'])
and (!preg_match($int_pattern, $_POST['default_maxheight'])
or $_POST['default_maxheight'] < 50))
{
array_push($page['errors'], $lang['maxheight_error']);
}
// Never go here
break;
}
}
Expand All @@ -160,8 +140,8 @@

$query = '
UPDATE '.CONFIG_TABLE.'
SET value = \''. str_replace("\'", "''", $value).'\'
WHERE param = \''.$row['param'].'\'
SET value = \''. str_replace("\'", "''", $value).'\'
WHERE param = \''.$row['param'].'\'
;';
pwg_query($query);
}
Expand Down Expand Up @@ -223,6 +203,8 @@

$html_check='checked="checked"';

$include_submit_buttons = true;

switch ($page['section'])
{
case 'main' :
Expand Down Expand Up @@ -288,91 +270,37 @@
}
case 'default' :
{
$show_yes = ($conf['show_nb_comments']==true)?'checked="checked"':'';
$show_no = ($conf['show_nb_comments']==false)?'checked="checked"':'';
$hits_yes = ($conf['show_nb_hits']==true)?'checked="checked"':'';
$hits_no = ($conf['show_nb_hits']==false)?'checked="checked"':'';
$expand_yes = ($conf['auto_expand']==true)?'checked="checked"':'';
$expand_no = ($conf['auto_expand']==false)?'checked="checked"':'';
$edit_user = build_user($conf['default_user_id'], false);
include_once(PHPWG_ROOT_PATH.'profile.php');

$template->assign_block_vars(
'default',
array(
'NB_IMAGE_LINE'=>$conf['nb_image_line'],
'NB_ROW_PAGE'=>$conf['nb_line_page'],
'CONF_RECENT'=>$conf['recent_period'],
'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'],
'MAXWIDTH'=>$conf['default_maxwidth'],
'MAXHEIGHT'=>$conf['default_maxheight'],
'EXPAND_YES'=>$expand_yes,
'EXPAND_NO'=>$expand_no,
'SHOW_COMMENTS_YES'=>$show_yes,
'SHOW_COMMENTS_NO'=>$show_no,
'SHOW_HITS_YES'=>$hits_yes,
'SHOW_HITS_NO'=>$hits_no,
));

$blockname = 'default.language_option';

foreach (get_languages() as $language_code => $language_name)
$errors = array();
if ( !is_adviser() )
{
if (isset($_POST['submit']))
if (save_profile_from_post($edit_user, $errors))
{
$selected =
$_POST['default_language'] == $language_code
? 'selected="selected"' : '';
// Reload user
$edit_user = build_user($conf['default_user_id'], false);
array_push($page['infos'], $lang['conf_confirmation']);
}
else if ($conf['default_language'] == $language_code)
{
$selected = 'selected="selected"';
}
else
{
$selected = '';
}

$template->assign_block_vars(
$blockname,
array(
'VALUE'=> $language_code,
'CONTENT' => $language_name,
'SELECTED' => $selected
));
}

$blockname = 'default.template_option';

foreach (get_pwg_themes() as $pwg_template)
{
if (isset($_POST['submit']))
{
$selected =
$_POST['default_template'] == $pwg_template
? 'selected="selected"' : '';
}
else if ($conf['default_template'] == $pwg_template)
{
$selected = 'selected="selected"';
}
else
{
$selected = '';
}

$template->assign_block_vars(
$blockname,
array(
'VALUE'=> $pwg_template,
'CONTENT' => $pwg_template,
'SELECTED' => $selected
)
);
}


$page['errors'] = array_merge($page['errors'], $errors);

load_profile_in_template(
$action,
'',
$edit_user
);
$template->assign_block_vars('default', array());
$include_submit_buttons = false;
break;
}
}

if ($include_submit_buttons)
{
$template->assign_block_vars('include_submit_buttons', array());
}

//----------------------------------------------------------- sending html code
$template->assign_var_from_handle('ADMIN_CONTENT', 'config');
?>
31 changes: 1 addition & 30 deletions admin/include/functions.php
Expand Up @@ -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$
Expand Down Expand Up @@ -1142,35 +1141,7 @@ function sync_users()

if (count($to_create) > 0)
{
$inserts = array();

list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));

foreach ($to_create as $user_id)
{
$insert = array();
$insert['user_id'] = $user_id;
$insert['status'] = 'normal';
$insert['template'] = $conf['default_template'];
$insert['nb_image_line'] = $conf['nb_image_line'];
$insert['nb_line_page'] = $conf['nb_line_page'];
$insert['language'] = $conf['default_language'];
$insert['recent_period'] = $conf['recent_period'];
$insert['expand'] = boolean_to_string($conf['auto_expand']);
$insert['show_nb_comments'] =
boolean_to_string($conf['show_nb_comments']);
$insert['show_nb_hits'] =
boolean_to_string($conf['show_nb_hits']);
$insert['maxwidth'] = $conf['default_maxwidth'];
$insert['maxheight'] = $conf['default_maxheight'];
$insert['registration_date'] = $dbnow;

array_push($inserts, $insert);
}

mass_inserts(USER_INFOS_TABLE,
array_keys($inserts[0]),
$inserts);
create_user_infos($to_create);
}

// users present in user related tables must be present in the base user
Expand Down
4 changes: 2 additions & 2 deletions admin/profile.php
Expand Up @@ -35,15 +35,15 @@
$errors = array();
if ( !is_adviser() )
{
save_profile_from_post( $edit_user, $errors);
save_profile_from_post($edit_user, $errors);
}

load_profile_in_template(
get_root_url().'admin.php?page=profile&amp;user_id='.$edit_user['id'],
get_root_url().'admin.php?page=user_list',
$edit_user
);
$page['errors'] = array_merge($page['errors'], $errors );
$page['errors'] = array_merge($page['errors'], $errors);

$template->set_filename('profile', 'admin/profile.tpl');
$template->assign_var_from_handle('ADMIN_CONTENT', 'profile');
Expand Down
31 changes: 9 additions & 22 deletions admin/user_list.php
Expand Up @@ -4,8 +4,7 @@
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
// | file : $RCSfile$
// | file : $Id$
// | last update : $Date$
// | last modifier : $Author$
// | revision : $Revision$
Expand Down Expand Up @@ -547,19 +546,6 @@ function get_filtered_user_list()
));
}

// ---
// $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'];
// ---

if (isset($_POST['pref_submit']))
{
// echo '<pre>'; print_r($_POST); echo '</pre>';
Expand Down Expand Up @@ -588,13 +574,14 @@ function get_filtered_user_list()
}
else
{
$default_user = get_default_user_info(true);
$template->assign_vars(
array(
'NB_IMAGE_LINE' => $conf['nb_image_line'],
'NB_LINE_PAGE' => $conf['nb_line_page'],
'MAXWIDTH' => @$conf['default_maxwidth'],
'MAXHEIGHT' => @$conf['default_maxheight'],
'RECENT_PERIOD' => $conf['recent_period'],
'NB_IMAGE_LINE' => $default_user['nb_image_line'],
'NB_LINE_PAGE' => $default_user['nb_line_page'],
'MAXWIDTH' => $default_user['maxwidth'],
'MAXHEIGHT' => $default_user['maxheight'],
'RECENT_PERIOD' => $default_user['recent_period'],
));
}

Expand All @@ -606,7 +593,7 @@ function get_filtered_user_list()
{
$selected = $_POST['template']==$pwg_template ? 'selected="selected"' : '';
}
else if ($conf['default_template'] == $pwg_template)
else if (get_default_template() == $pwg_template)
{
$selected = 'selected="selected"';
}
Expand All @@ -632,7 +619,7 @@ function get_filtered_user_list()
{
$selected = $_POST['language']==$language_code ? 'selected="selected"':'';
}
else if ($conf['default_language'] == $language_code)
else if (get_default_language() == $language_code)
{
$selected = 'selected="selected"';
}
Expand Down
5 changes: 2 additions & 3 deletions include/config_default.inc.php
Expand Up @@ -136,9 +136,6 @@
// 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 : ' / ', ' &raquo; ', ' &rarr; ', ' - ',
// ' &gt;'
Expand Down Expand Up @@ -463,6 +460,8 @@

// 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;
Expand Down
1 change: 1 addition & 0 deletions include/constants.php
Expand Up @@ -29,6 +29,7 @@
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);
Expand Down
2 changes: 1 addition & 1 deletion include/functions.inc.php
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions include/functions_mail.inc.php
Expand Up @@ -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())
{
Expand All @@ -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']))
Expand All @@ -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())
{
Expand Down Expand Up @@ -298,7 +298,7 @@ function pwg_mail_notification_admins($keyargs_subject, $keyargs_content)
get_l10n_args('Browser: %s', $_SERVER['HTTP_USER_AGENT'])
);

switch_lang_to($conf['default_language']);
switch_lang_to(get_default_language());

$return = pwg_mail
(
Expand Down Expand Up @@ -451,8 +451,8 @@ function pwg_mail_group(
* 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)
*/
Expand Down

0 comments on commit 7c43a3c

Please sign in to comment.