mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-03-28 17:42:57 +01:00
Resolved Issue ID 0000526:
o Add default group to new user Allow to have n default groups. Property are save on table #_group and can be modified on administration group screen. git-svn-id: http://piwigo.org/svn/trunk@1583 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -122,6 +122,33 @@ INSERT INTO '.GROUPS_TABLE.'
|
||||
}
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | toggle is default group property |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
if (isset($_GET['toggle_is_default']) and is_numeric($_GET['toggle_is_default']))
|
||||
{
|
||||
$query = '
|
||||
SELECT name, is_default
|
||||
FROM '.GROUPS_TABLE.'
|
||||
WHERE id = '.$_GET['toggle_is_default'].'
|
||||
;';
|
||||
list($groupname, $is_default) = mysql_fetch_row(pwg_query($query));
|
||||
|
||||
// update of the group
|
||||
$query = '
|
||||
UPDATE '.GROUPS_TABLE.'
|
||||
SET is_default = \''.boolean_to_string(!get_boolean($is_default)).'\'
|
||||
WHERE id = '.$_GET['toggle_is_default'].'
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
array_push(
|
||||
$page['infos'],
|
||||
sprintf(l10n('group "%s" updated'), $groupname)
|
||||
);
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | template init |
|
||||
// +-----------------------------------------------------------------------+
|
||||
@@ -139,7 +166,7 @@ $template->assign_vars(
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
$query = '
|
||||
SELECT id, name
|
||||
SELECT id, name, is_default
|
||||
FROM '.GROUPS_TABLE.'
|
||||
ORDER BY id ASC
|
||||
;';
|
||||
@@ -149,6 +176,7 @@ $admin_url = PHPWG_ROOT_PATH.'admin.php?page=';
|
||||
$perm_url = $admin_url.'group_perm&group_id=';
|
||||
$del_url = $admin_url.'group_list&delete=';
|
||||
$members_url = $admin_url.'user_list&group=';
|
||||
$toggle_is_default_url = $admin_url.'group_list&toggle_is_default=';
|
||||
|
||||
$num = 0;
|
||||
while ($row = mysql_fetch_array($result))
|
||||
@@ -165,10 +193,12 @@ SELECT COUNT(*)
|
||||
array(
|
||||
'CLASS' => ($num++ % 2 == 1) ? 'row2' : 'row1',
|
||||
'NAME' => $row['name'],
|
||||
'IS_DEFAULT' => (get_boolean($row['is_default']) ? ' ['.l10n('is_default_group').']' : ''),
|
||||
'MEMBERS' => sprintf(l10n('%d members'), $counter),
|
||||
'U_MEMBERS' => $members_url.$row['id'],
|
||||
'U_DELETE' => $del_url.$row['id'],
|
||||
'U_PERM' => $perm_url.$row['id']
|
||||
'U_PERM' => $perm_url.$row['id'],
|
||||
'U_ISDEFAULT' => $toggle_is_default_url.$row['id']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -222,9 +222,6 @@ $conf['check_upgrade_feed'] = true;
|
||||
// rate_items: available rates for a picture
|
||||
$conf['rate_items'] = array(0,1,2,3,4,5);
|
||||
|
||||
// Dafault groups to assign to new user
|
||||
$conf['default_group_id'] = -1;
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | metadata |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
@@ -93,23 +93,34 @@ SELECT MAX('.$conf['user_fields']['id'].') + 1
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
mass_inserts(USERS_TABLE, array_keys($insert), array($insert));
|
||||
|
||||
// Assign by default one group
|
||||
if(isset($conf['default_group_id']))
|
||||
// Assign by default groups
|
||||
{
|
||||
$query = '
|
||||
select count(*) from '.GROUPS_TABLE.' where id = '.$conf['default_group_id'].';';
|
||||
list($exist_group) = mysql_fetch_array(pwg_query($query));
|
||||
SELECT id
|
||||
FROM '.GROUPS_TABLE.'
|
||||
WHERE is_default = \''.boolean_to_string(true).'\'
|
||||
ORDER BY id ASC
|
||||
;';
|
||||
$result = pwg_query($query);
|
||||
|
||||
if ($exist_group == 1)
|
||||
$inserts = array();
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
$insert =
|
||||
array(
|
||||
array_push
|
||||
(
|
||||
$inserts,
|
||||
array
|
||||
(
|
||||
'user_id' => $next_id,
|
||||
'group_id' => $conf['default_group_id']
|
||||
);
|
||||
'group_id' => $row['id']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (count($inserts) != 0)
|
||||
{
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
mass_inserts(USER_GROUP_TABLE, array_keys($insert), array($insert));
|
||||
mass_inserts(USER_GROUP_TABLE, array('user_id', 'group_id'), $inserts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
55
install/db/33-database.php
Normal file
55
install/db/33-database.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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 = 'Add column #group.is_default';
|
||||
|
||||
include_once(PHPWG_ROOT_PATH.'include/constants.php');
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Upgrade content |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
echo "Add column is_default on ".GROUPS_TABLE;
|
||||
$query = '
|
||||
alter table '.GROUPS_TABLE.' add column
|
||||
`is_default` enum(\'true\',\'false\') NOT NULL default \'false\'
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
|
||||
echo
|
||||
"\n"
|
||||
.'"'.$upgrade_description.'"'.' ended'
|
||||
."\n"
|
||||
;
|
||||
|
||||
?>
|
||||
@@ -102,6 +102,7 @@ DROP TABLE IF EXISTS `phpwebgallery_groups`;
|
||||
CREATE TABLE `phpwebgallery_groups` (
|
||||
`id` smallint(5) unsigned NOT NULL auto_increment,
|
||||
`name` varchar(255) NOT NULL default '',
|
||||
`is_default` enum('true','false') NOT NULL default 'false',
|
||||
PRIMARY KEY (`id`)
|
||||
) TYPE=MyISAM;
|
||||
|
||||
|
||||
@@ -242,6 +242,7 @@ $lang['general'] = 'General';
|
||||
$lang['global mode'] = 'global mode';
|
||||
$lang['group "%s" added'] = 'group "%s" added';
|
||||
$lang['group "%s" deleted'] = 'group "%s" deleted';
|
||||
$lang['group "%s" updated'] = 'group "%s" updated';
|
||||
$lang['group'] = 'group';
|
||||
$lang['group_add_error1'] = 'The name of a group must not contain " or \' or be empty.';
|
||||
$lang['group_add_error2'] = 'This name is already used by another group.';
|
||||
@@ -486,4 +487,6 @@ $lang['users'] = 'Users';
|
||||
$lang['visitors'] = 'Visitors';
|
||||
$lang['w_day'] = 'Day';
|
||||
$lang['waiting'] = 'Waiting';
|
||||
$lang['is_default_group'] = 'default';
|
||||
$lang['toggle_is_default_group'] = 'Toggle \'default group\' property';
|
||||
?>
|
||||
@@ -242,6 +242,7 @@ $lang['general'] = 'G
|
||||
$lang['global mode'] = 'mode global';
|
||||
$lang['group "%s" added'] = 'groupe "%s" ajouté';
|
||||
$lang['group "%s" deleted'] = 'groupe "%s" supprimé';
|
||||
$lang['group "%s" updated'] = 'groupe "%s" mis à jour';
|
||||
$lang['group'] = 'groupe';
|
||||
$lang['group_add_error1'] = 'Le nom du groupe ne doit pas contenir " or \' et ne doit pas être vide.';
|
||||
$lang['group_add_error2'] = 'Ce nom est déjà utilisé par un autre groupe.';
|
||||
@@ -486,4 +487,6 @@ $lang['users'] = 'Utilisateurs';
|
||||
$lang['visitors'] = 'Visiteurs';
|
||||
$lang['w_day'] = 'Jour';
|
||||
$lang['waiting'] = 'En attente';
|
||||
$lang['is_default_group'] = 'par défaut';
|
||||
$lang['toggle_is_default_group'] = 'Inverser la propriété \'groupe par défaut\'';
|
||||
?>
|
||||
@@ -24,11 +24,12 @@
|
||||
</tr>
|
||||
<!-- BEGIN group -->
|
||||
<tr class="{group.CLASS}">
|
||||
<td>{group.NAME}</td>
|
||||
<td>{group.NAME}<i><small>{group.IS_DEFAULT}</small></i></td>
|
||||
<td><a href="{group.U_MEMBERS}">{group.MEMBERS}</a></td>
|
||||
<td style="text-align:center;">
|
||||
<a href="{group.U_PERM}"><img src="{themeconf:icon_dir}/permissions.png" class="button" style="border:none" alt="permissions" title="{lang:permissions}" /></a>
|
||||
<a href="{group.U_DELETE}" onclick="return confirm('{lang:Are you sure?}');"><img src="{themeconf:icon_dir}/delete.png" class="button" style="border:none" alt="delete" title="{lang:delete}" {TAG_INPUT_ENABLED}/></a>
|
||||
<a href="{group.U_ISDEFAULT}" onclick="return confirm('{lang:Are you sure?}');"><img src="{themeconf:icon_dir}/toggle_is_default_group.png" class="button" style="border:none" alt="toggle_is_default_group" title="{lang:toggle_is_default_group}" {TAG_INPUT_ENABLED}/></a>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- END group -->
|
||||
|
||||
BIN
template/yoga/icon/toggle_is_default_group.png
Normal file
BIN
template/yoga/icon/toggle_is_default_group.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 571 B |
Reference in New Issue
Block a user