aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/group_list.php34
-rw-r--r--include/config_default.inc.php3
-rw-r--r--include/functions_user.inc.php31
-rw-r--r--install/db/33-database.php55
-rw-r--r--install/phpwebgallery_structure.sql1
-rw-r--r--language/en_UK.iso-8859-1/admin.lang.php3
-rw-r--r--language/fr_FR.iso-8859-1/admin.lang.php3
-rw-r--r--template/yoga/admin/group_list.tpl3
-rw-r--r--template/yoga/icon/toggle_is_default_group.pngbin0 -> 571 bytes
9 files changed, 117 insertions, 16 deletions
diff --git a/admin/group_list.php b/admin/group_list.php
index 0386757dd..69edcb02a 100644
--- a/admin/group_list.php
+++ b/admin/group_list.php
@@ -123,6 +123,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']
)
);
}
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index a27b604e6..b70b24e21 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -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 |
// +-----------------------------------------------------------------------+
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index a599539e8..3cdae176e 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -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);
}
}
diff --git a/install/db/33-database.php b/install/db/33-database.php
new file mode 100644
index 000000000..c4d692f5b
--- /dev/null
+++ b/install/db/33-database.php
@@ -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"
+;
+
+?>
diff --git a/install/phpwebgallery_structure.sql b/install/phpwebgallery_structure.sql
index cf7c55b39..6e3fbd8f9 100644
--- a/install/phpwebgallery_structure.sql
+++ b/install/phpwebgallery_structure.sql
@@ -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;
diff --git a/language/en_UK.iso-8859-1/admin.lang.php b/language/en_UK.iso-8859-1/admin.lang.php
index adf98646d..0c94b62e1 100644
--- a/language/en_UK.iso-8859-1/admin.lang.php
+++ b/language/en_UK.iso-8859-1/admin.lang.php
@@ -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';
?> \ No newline at end of file
diff --git a/language/fr_FR.iso-8859-1/admin.lang.php b/language/fr_FR.iso-8859-1/admin.lang.php
index 0dfb32044..c6662ff3b 100644
--- a/language/fr_FR.iso-8859-1/admin.lang.php
+++ b/language/fr_FR.iso-8859-1/admin.lang.php
@@ -242,6 +242,7 @@ $lang['general'] = 'Général';
$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\'';
?> \ No newline at end of file
diff --git a/template/yoga/admin/group_list.tpl b/template/yoga/admin/group_list.tpl
index 6c370a96b..0424456e5 100644
--- a/template/yoga/admin/group_list.tpl
+++ b/template/yoga/admin/group_list.tpl
@@ -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 -->
diff --git a/template/yoga/icon/toggle_is_default_group.png b/template/yoga/icon/toggle_is_default_group.png
new file mode 100644
index 000000000..9eaa3c601
--- /dev/null
+++ b/template/yoga/icon/toggle_is_default_group.png
Binary files differ