aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrub <rub@piwigo.org>2006-10-30 23:34:31 +0000
committerrub <rub@piwigo.org>2006-10-30 23:34:31 +0000
commit9c3e182268ed2bc5df5f31cf4045b217f7ad8791 (patch)
treec09a2b977ba3bfde8f32d2e38c07ad237ac29013 /include
parenta0e981198d4602c7634407780379c19d58b92e15 (diff)
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
Diffstat (limited to '')
-rw-r--r--include/config_default.inc.php3
-rw-r--r--include/functions_user.inc.php31
2 files changed, 21 insertions, 13 deletions
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);
}
}