Skip to content

Commit

Permalink
Step 7 improvement issue 0000301:
Browse files Browse the repository at this point in the history
  o can attribute status <= current user
  o define mode adviser 
    => buttons disabled (gray on IE, not on FF)
    => truncated actions
    => display info mode adviser

git-svn-id: http://piwigo.org/svn/trunk@1085 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rub committed Mar 16, 2006
1 parent 5980db2 commit 9b52176
Show file tree
Hide file tree
Showing 34 changed files with 225 additions and 88 deletions.
36 changes: 26 additions & 10 deletions admin/maintenance.php
Expand Up @@ -98,16 +98,32 @@

$start_url = PHPWG_ROOT_PATH.'admin.php?page=maintenance&amp;action=';

$template->assign_vars(
array(
'U_MAINT_CATEGORIES' => $start_url.'categories',
'U_MAINT_IMAGES' => $start_url.'images',
'U_MAINT_HISTORY' => $start_url.'history',
'U_MAINT_SESSIONS' => $start_url.'sessions',
'U_MAINT_FEEDS' => $start_url.'feeds',
'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=maintenance',
)
);
if (!is_adviser())
{
$template->assign_vars(
array(
'U_MAINT_CATEGORIES' => $start_url.'categories',
'U_MAINT_IMAGES' => $start_url.'images',
'U_MAINT_HISTORY' => $start_url.'history',
'U_MAINT_SESSIONS' => $start_url.'sessions',
'U_MAINT_FEEDS' => $start_url.'feeds',
'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=maintenance',
)
);
}
else
{
$template->assign_vars(
array(
'U_MAINT_CATEGORIES' => $start_url,
'U_MAINT_IMAGES' => $start_url,
'U_MAINT_HISTORY' => $start_url,
'U_MAINT_SESSIONS' => $start_url,
'U_MAINT_FEEDS' => $start_url,
'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=maintenance',
)
);
}

// +-----------------------------------------------------------------------+
// | sending html code |
Expand Down
2 changes: 1 addition & 1 deletion admin/picture_modify.php
Expand Up @@ -41,7 +41,7 @@
// | synchronize metadata |
// +-----------------------------------------------------------------------+

if (isset($_GET['sync_metadata']))
if (isset($_GET['sync_metadata']) and !is_adviser())
{
$query = '
SELECT path
Expand Down
47 changes: 29 additions & 18 deletions admin/user_list.php
Expand Up @@ -97,6 +97,7 @@ function get_filtered_user_list()
u.'.$conf['user_fields']['username'].' AS username,
u.'.$conf['user_fields']['email'].' AS email,
ui.status,
ui.adviser,
ui.enabled_high
FROM '.USERS_TABLE.' AS u
INNER JOIN '.USER_INFOS_TABLE.' AS ui
Expand Down Expand Up @@ -337,9 +338,9 @@ function get_filtered_user_list()
$formfields =
array('nb_image_line', 'nb_line_page', 'template', 'language',
'recent_period', 'maxwidth', 'expand', 'show_nb_comments',
'maxheight', 'status', 'enabled_high');
'maxheight', 'status', 'adviser', 'enabled_high');

$true_false_fields = array('expand', 'show_nb_comments', 'enabled_high');
$true_false_fields = array('expand', 'show_nb_comments', 'adviser', 'enabled_high');

foreach ($formfields as $formfield)
{
Expand Down Expand Up @@ -380,20 +381,22 @@ function get_filtered_user_list()
$data[$dbfield] = $_POST[$dbfield];
}
}

// Webmaster status must not be changed
if ($conf['webmaster_id'] == $user_id and isset($data['status']))
{
$data['status'] = 'webmaster';
}


// Webmaster and guest adviser must not be changed
if ((($conf['webmaster_id'] == $user_id) or ($conf['guest_id'] == $user_id)) and isset($data['adviser']))
{
$data['adviser'] = 'false';
}

array_push($datas, $data);
}

// echo '<pre>';
// print_r($datas);
// echo '</pre>';

mass_updates(USER_INFOS_TABLE, $dbfields, $datas);
}

Expand Down Expand Up @@ -572,6 +575,8 @@ function get_filtered_user_list()
// echo '<pre>'; print_r($_POST); echo '</pre>';
$template->assign_vars(
array(
'ADVISER_YES' => 'true' == $_POST['adviser'] ? 'checked="checked"' : '',
'ADVISER_NO' => 'false' == $_POST['adviser'] ? 'checked="checked"' : '',
'NB_IMAGE_LINE' => $_POST['nb_image_line'],
'NB_LINE_PAGE' => $_POST['nb_line_page'],
'MAXWIDTH' => $_POST['maxwidth'],
Expand All @@ -582,7 +587,9 @@ function get_filtered_user_list()
'SHOW_NB_COMMENTS_YES' =>
'true' == $_POST['show_nb_comments'] ? 'checked="checked"' : '',
'SHOW_NB_COMMENTS_NO' =>
'false' == $_POST['show_nb_comments'] ? 'checked="checked"' : ''
'false' == $_POST['show_nb_comments'] ? 'checked="checked"' : '',
'ENABLED_HIGH_YES' => 'true' == $_POST['enabled_high'] ? 'checked="checked"' : '',
'ENABLED_HIGH_NO' => 'false' == $_POST['enabled_high'] ? 'checked="checked"' : '',
));
}
else
Expand Down Expand Up @@ -665,14 +672,18 @@ function get_filtered_user_list()
{
$selected = '';
}

$template->assign_block_vars(
$blockname,
array(
'VALUE' => $status,
'CONTENT' => $lang['user_status_'.$status],
'SELECTED' => $selected
));

// Only status <= can be assign
if (is_autorize_status(get_access_type_status($status)))
{
$template->assign_block_vars(
$blockname,
array(
'VALUE' => $status,
'CONTENT' => $lang['user_status_'.$status],
'SELECTED' => $selected
));
}
}

// associate
Expand Down Expand Up @@ -800,7 +811,7 @@ function get_filtered_user_list()
'U_MOD' => $profile_url.$local_user['id'],
'U_PERM' => $perm_url.$local_user['id'],
'USERNAME' => $local_user['username'],
'STATUS' => $lang['user_status_'.$local_user['status']],
'STATUS' => $lang['user_status_'.$local_user['status']].(($local_user['adviser'] == 'true') ? ' ['.$lang['adviser'].']' : ''),
'EMAIL' => isset($local_user['email']) ? $local_user['email'] : '',
'GROUPS' => $groups_string,
'PROPERTIES' => (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true')) ? $lang['is_high_enabled'] : $lang['is_high_disabled']
Expand Down
12 changes: 12 additions & 0 deletions include/common.inc.php
Expand Up @@ -232,6 +232,18 @@
.'/themeconf.inc.php'
);

if (is_adviser())
{
echo '
<div class="titrePage">
<h2>
<div style="text-align:center;">'.$lang['adviser_mode_enabled'].'
</div>
</h2>
</div>
';
}

// template instance
$template = new Template(PHPWG_ROOT_PATH.'template/'.$user['template']);
?>
31 changes: 26 additions & 5 deletions include/functions_user.inc.php
Expand Up @@ -548,11 +548,11 @@ function log_user($user_id, $remember_me)
}

/*
* Return if current user have access to access_type definition
* Return access_type definition of uuser
* Test does with user status
* @return bool
*/
function is_autorize_status($access_type, $user_status = '')
function get_access_type_status($user_status = '')
{
global $user;

Expand Down Expand Up @@ -587,11 +587,21 @@ function is_autorize_status($access_type, $user_status = '')
}
}

return ($access_type_status >= $access_type);
return $access_type_status;
}

/*
* Return if user have access to access_type definition
* Test does with user status
* @return bool
*/
function is_autorize_status($access_type, $user_status = '')
{
return (get_access_type_status($user_status) >= $access_type);
}

/*
* Check if current user have access to access_type definition
* Check if user have access to access_type definition
* Stop action if there are not access
* Test does with user status
* @return none
Expand All @@ -609,12 +619,23 @@ function check_status($access_type, $user_status = '')
}

/*
* Return if current user is an administrator
* Return if user is an administrator
* @return bool
*/
function is_admin($user_status = '')
{
return is_autorize_status(ACCESS_ADMINISTRATOR, $user_status);
}

/*
* Return if current user is an adviser
* @return bool
*/
function is_adviser()
{
global $user;

return ($user['adviser'] == 'true');
}

?>
5 changes: 3 additions & 2 deletions include/page_header.php
Expand Up @@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
// | file : $RCSfile$
Expand Down Expand Up @@ -52,7 +52,8 @@
'LANG'=>$lang_info['code'],
'DIR'=>$lang_info['direction'],

'T_STYLE' => $css
'T_STYLE' => $css,
'TAG_INPUT_ENABLED' => ((is_adviser()) ? 'disabled' : '')
));

// refresh
Expand Down
54 changes: 54 additions & 0 deletions install/db/16-database.php
@@ -0,0 +1,54 @@
<?php
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | 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$
// | last update : $Date: 2005-09-21 00:04:57 +0200 (mer, 21 sep 2005) $
// | last modifier : $Author: plg $
// | revision : $Revision: 870 $
// +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation |
// | |
// | This program is distributed in the hope that it will be useful, but |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA. |
// +-----------------------------------------------------------------------+

if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}

$upgrade_description = 'Update database from adviser functionnality';

include_once(PHPWG_ROOT_PATH.'include/constants.php');

// +-----------------------------------------------------------------------+
// | Upgrade content |
// +-----------------------------------------------------------------------+

echo "Alter table ".USER_INFOS_TABLE. ' add field adviser';
$query = "
alter table ".USER_INFOS_TABLE."
add column `adviser` enum('true','false') NOT NULL default 'false' after `status`
;";
pwg_query($query);

echo
"\n"
.'"'.$upgrade_description.'"'.' ended'
."\n"
;

?>
1 change: 1 addition & 0 deletions install/phpwebgallery_structure.sql
Expand Up @@ -297,6 +297,7 @@ CREATE TABLE `phpwebgallery_user_infos` (
`nb_image_line` tinyint(1) unsigned NOT NULL default '5',
`nb_line_page` tinyint(3) unsigned NOT NULL default '3',
`status` enum('webmaster', 'admin', 'normal', 'generic', 'guest') NOT NULL default 'guest',
`adviser` enum('true','false') NOT NULL default 'false',
`language` varchar(50) NOT NULL default 'english',
`maxwidth` smallint(6) default NULL,
`maxheight` smallint(6) default NULL,
Expand Down
1 change: 1 addition & 0 deletions language/en_UK.iso-8859-1/admin.lang.php
Expand Up @@ -166,6 +166,7 @@
$lang['is_high_enabled'] = 'High definition';
$lang['is_high_disabled'] = '';
$lang['enabled_high'] = 'High definition enabled';
$lang['adviser'] = 'Adviser';
$lang['add keywords'] = 'add keywords';
$lang['associate to category'] = 'associate to category';
$lang['associate to group'] = 'associate to group';
Expand Down
1 change: 1 addition & 0 deletions language/en_UK.iso-8859-1/common.lang.php
Expand Up @@ -331,4 +331,5 @@
$lang['useful when password forgotten'] = 'useful when password forgotten';
$lang['w_month'] = 'Month';
$lang['yes'] = 'Yes';
$lang['adviser_mode_enabled'] = 'Adviser mode enabled';
?>
4 changes: 3 additions & 1 deletion language/en_UK.iso-8859-1/help/user_list.html
Expand Up @@ -21,7 +21,9 @@ <h3>Users list</h3>
<li>delete users (require a confirmation checkbox)</li>

<li>change status</li>


<li>set user like an adviser</li>

<li>associate or dissociate from groups</li>

<li>modify display properties</li>
Expand Down
1 change: 1 addition & 0 deletions language/fr_FR.iso-8859-1/admin.lang.php
Expand Up @@ -166,6 +166,7 @@
$lang['is_high_enabled'] = 'Haute définition';
$lang['is_high_disabled'] = '';
$lang['enabled_high'] = 'Haute définition actif';
$lang['adviser'] = 'Conseiller';
$lang['add keywords'] = 'ajouter des mots-clef';
$lang['associate to category'] = 'associer à la catégorie';
$lang['associate to group'] = 'associer au groupe';
Expand Down
1 change: 1 addition & 0 deletions language/fr_FR.iso-8859-1/common.lang.php
Expand Up @@ -331,4 +331,5 @@
$lang['useful when password forgotten'] = 'utile en cas d\'oubli de mot de passe';
$lang['w_month'] = 'Mois';
$lang['yes'] = 'Oui';
$lang['adviser_mode_enabled'] = 'Mode conseiller actif';
?>
2 changes: 2 additions & 0 deletions language/fr_FR.iso-8859-1/help/user_list.html
Expand Up @@ -23,6 +23,8 @@ <h3>Liste des utilisateurs</h3>

<li>changer le status</li>

<li>définir l'utilisateur comme un conseiller</li>

<li>associer ou dissocier des groupes</li>

<li>modifier les propriétés d'affichage</li>
Expand Down
7 changes: 5 additions & 2 deletions picture.php
Expand Up @@ -169,7 +169,7 @@
}
case 'set_as_representative' :
{
if (is_admin() and isset($page['category']))
if (is_admin() and isset($page['category']) and !is_adviser())
{
$query = '
UPDATE '.CATEGORIES_TABLE.'
Expand All @@ -189,7 +189,10 @@
}
case 'add_to_caddie' :
{
fill_caddie(array($page['image_id']));
if (!is_adviser())
{
fill_caddie(array($page['image_id']));
}
redirect($url_self);
break;
}
Expand Down

0 comments on commit 9b52176

Please sign in to comment.