Ignore:
Timestamp:
Oct 31, 2006, 12:34:31 AM (18 years ago)
Author:
rub
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_user.inc.php

    r1582 r1583  
    9494    mass_inserts(USERS_TABLE, array_keys($insert), array($insert));
    9595
    96   // Assign by default one group
    97   if(isset($conf['default_group_id']))
     96  // Assign by default groups
    9897  {
    9998    $query = '
    100 select count(*) from '.GROUPS_TABLE.' where id = '.$conf['default_group_id'].';';
    101     list($exist_group) = mysql_fetch_array(pwg_query($query));
    102 
    103     if ($exist_group == 1)
    104     {
    105       $insert =
    106         array(
     99SELECT id
     100  FROM '.GROUPS_TABLE.'
     101  WHERE is_default = \''.boolean_to_string(true).'\'
     102  ORDER BY id ASC
     103;';
     104    $result = pwg_query($query);
     105
     106    $inserts = array();
     107    while ($row = mysql_fetch_array($result))
     108    {
     109      array_push
     110      (
     111        $inserts,
     112        array
     113        (
    107114          'user_id' => $next_id,
    108           'group_id' => $conf['default_group_id']
    109           );
    110 
     115          'group_id' => $row['id']
     116        )
     117      );
     118    }
     119
     120    if (count($inserts) != 0)
     121    {
    111122      include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    112       mass_inserts(USER_GROUP_TABLE, array_keys($insert), array($insert));
     123      mass_inserts(USER_GROUP_TABLE, array('user_id', 'group_id'), $inserts);
    113124    }
    114125  }
Note: See TracChangeset for help on using the changeset viewer.