diff -aburN --exclude CVS* phpgw-orig/admin/inc/class.boaccounts.inc.php phpgw-mod/admin/inc/class.boaccounts.inc.php --- phpgw-orig/admin/inc/class.boaccounts.inc.php Tue Aug 6 03:14:17 2002 +++ phpgw-mod/admin/inc/class.boaccounts.inc.php Sat Dec 7 11:29:06 2002 @@ -203,7 +203,8 @@ 'account_id' => ($GLOBALS['HTTP_POST_VARS']['account_id']?intval($GLOBALS['HTTP_POST_VARS']['account_id']):0), 'account_name' => ($GLOBALS['HTTP_POST_VARS']['account_name']?$GLOBALS['HTTP_POST_VARS']['account_name']:''), 'account_user' => $account_user, - 'account_apps' => $account_apps + 'account_apps' => $account_apps, + 'account_type' => $GLOBALS['HTTP_POST_VARS']['account_type'] ); $this->validate_group($group_info); @@ -221,8 +222,8 @@ ) ); - $group = CreateObject('phpgwapi.accounts',$group_info['account_id'],'g'); - $group->acct_type = 'g'; + $group = CreateObject('phpgwapi.accounts',$group_info['account_id'],$group_info['account_type']); + $group->acct_type = $group_info['account_type']; $account_info = array( 'account_type' => 'g', 'account_lid' => $group_info['account_name'], @@ -230,7 +231,8 @@ 'account_firstname' => $group_info['account_name'], 'account_lastname' => 'Group', 'account_status' => 'A', - 'account_expires' => -1 + 'account_expires' => -1, + 'account_type' => $group_info['account_type'] // 'account_file_space' => $account_file_space_number . "-" . $account_file_space_type, ); $group->create($account_info); @@ -380,7 +382,8 @@ 'account_id' => ($GLOBALS['HTTP_POST_VARS']['account_id']?intval($GLOBALS['HTTP_POST_VARS']['account_id']):0), 'account_name' => ($GLOBALS['HTTP_POST_VARS']['account_name']?$GLOBALS['HTTP_POST_VARS']['account_name']:''), 'account_user' => $account_user, - 'account_apps' => $account_apps + 'account_apps' => $account_apps, + 'account_type' => $GLOBALS['HTTP_POST_VARS']['account_type'] ); $this->validate_group($group_info); @@ -399,7 +402,7 @@ ) ); - $group = CreateObject('phpgwapi.accounts',$group_info['account_id'],'g'); + $group = CreateObject('phpgwapi.accounts',$group_info['account_id'],$group_info['account_type']); $old_group_info = $group->read_repository(); // Set group apps @@ -511,7 +514,11 @@ $group->data['file_space'] = $GLOBALS['HTTP_POST_VARS']['account_file_space_number'] . "-" . $GLOBALS['HTTP_POST_VARS']['account_file_space_type']; $group->save_repository(); */ - + if($group->data['account_type']<>$group_info['account_type']) + { + $group->data['account_type']=$group_info['account_type']; + $group->save_repository(); + } $GLOBALS['phpgw']->db->unlock(); ExecMethod('admin.uiaccounts.list_groups'); @@ -545,7 +552,8 @@ 'account_expires_month' => $GLOBALS['HTTP_POST_VARS']['account_expires_month'], 'account_expires_day' => $GLOBALS['HTTP_POST_VARS']['account_expires_day'], 'account_expires_year' => $GLOBALS['HTTP_POST_VARS']['account_expires_year'], - 'account_expires_never' => $GLOBALS['HTTP_POST_VARS']['never_expires'] + 'account_expires_never' => $GLOBALS['HTTP_POST_VARS']['never_expires'], + 'account_type' => 'u' /* 'file_space' => $GLOBALS['HTTP_POST_VARS']['account_file_space_number'] . "-" . $GLOBALS['HTTP_POST_VARS']['account_file_space_type'] */ ); @@ -609,7 +617,7 @@ { $errors = Array(); - $group = CreateObject('phpgwapi.accounts',$group_info['account_id'],'g'); + $group = CreateObject('phpgwapi.accounts',$group_info['account_id'],$group_info['account_type']); $group->read_repository(); if(!$group_info['account_name']) @@ -766,7 +774,7 @@ $apps->save_repository(); $account = CreateObject('phpgwapi.accounts',$_userData['account_id'],'u'); - $allGroups = $account->get_list('groups'); + $allGroups = $account->get_list('acls'); if ($_userData['account_groups']) { diff -aburN --exclude CVS* phpgw-orig/admin/inc/class.uiaccounts.inc.php phpgw-mod/admin/inc/class.uiaccounts.inc.php --- phpgw-orig/admin/inc/class.uiaccounts.inc.php Sat Dec 7 00:08:23 2002 +++ phpgw-mod/admin/inc/class.uiaccounts.inc.php Sat Dec 7 11:33:48 2002 @@ -69,15 +69,17 @@ $p->set_block('groups','list','list'); $p->set_block('groups','row','row'); $p->set_block('groups','row_empty','row_empty'); + $order='account_type,'; + $sort='account_firstname'; if ($GLOBALS['phpgw']->acl->check('group_access',2,'admin')) { - $account_info = $GLOBALS['phpgw']->accounts->get_list('groups',$start,$sort, $order, $query, $total); + $account_info = $GLOBALS['phpgw']->accounts->get_list('acls',$start,$sort, $order, $query, $total); $total = $GLOBALS['phpgw']->accounts->total; } else { - $account_info = $GLOBALS['phpgw']->accounts->get_list('groups',$start,$sort, $order, $query, $total); + $account_info = $GLOBALS['phpgw']->accounts->get_list('acls',$start,$sort, $order, $query, $total); $total = $GLOBALS['phpgw']->accounts->total; } @@ -121,7 +123,7 @@ $tr_color = $this->nextmatchs->alternate_row_color($tr_color); $var = Array( 'tr_color' => $tr_color, - 'group_name' => (!$account['account_lid']?'&nbsp;':$account['account_lid']), + 'group_name' => (!$account['account_lid']?'&nbsp;':$account['account_lid']." ".(strtolower($account['account_type'])=='a'?'('.lang('acl group').')':'('.lang('membership group').')')), 'delete_link' => $this->row_action('delete','group',$account['account_id']) ); $p->set_var($var); @@ -315,7 +317,8 @@ 'account_id' => $GLOBALS['HTTP_GET_VARS']['account_id'], 'account_name' => '', 'account_user' => Array(), - 'account_apps' => Array() + 'account_apps' => Array(), + 'account_type' => 'g' ); $this->create_edit_group($group_info); } @@ -477,7 +480,8 @@ 'account_id' => intval($GLOBALS['HTTP_GET_VARS']['account_id']), 'account_name' => $GLOBALS['phpgw']->accounts->id2name($GLOBALS['HTTP_GET_VARS']['account_id']), 'account_user' => $this->bo->load_group_users($GLOBALS['HTTP_GET_VARS']['account_id']), - 'account_apps' => $this->bo->load_group_apps($GLOBALS['HTTP_GET_VARS']['account_id']) + 'account_apps' => $this->bo->load_group_apps($GLOBALS['HTTP_GET_VARS']['account_id']), + 'account_type' => $GLOBALS['phpgw']->accounts->get_type($GLOBALS['HTTP_GET_VARS']['account_id']) ); $this->create_edit_group($group_info); @@ -601,7 +605,7 @@ } // Find out which groups they are members of - $usergroups = $account->membership(intval($GLOBALS['HTTP_GET_VARS']['account_id'])); + $usergroups = $account->membership(intval($GLOBALS['HTTP_GET_VARS']['account_id']),true); if (gettype($usergroups) != 'array') { $var['groups_select'] = lang('None'); @@ -740,6 +744,10 @@ $account_list = $accounts->get_list('accounts'); $account_num = count($account_list); + if(strtolower($group_info[account_type])=='a') + $type_list='<select name="account_type"><option value="a" selected>'.lang('acl group').'</option><option value="g">'.lang('membership group').'</option></select>'; + else + $type_list='<select name="account_type"><option value="a">'.lang('acl group').'</option><option value="g" selected>'.lang('membership group').'</option></select>'; $user_list = ''; while (list($key,$entry) = each($account_list)) { @@ -756,12 +764,14 @@ 'form_action' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.boaccounts.'.($group_info['account_id']?'edit':'add').'_group'), 'hidden_vars' => '<input type="hidden" name="account_id" value="' . $group_info['account_id'] . '">', 'lang_group_name' => lang('group name'), + 'lang_group_type' => lang('group type'), 'group_name_value' => $group_info['account_name'], 'lang_include_user' => lang('Select users for inclusion'), 'error' => (!$_errors?'':'<center>'.$GLOBALS['phpgw']->common->error_list($_errors).'</center>'), 'select_size' => ($account_num < 5?$account_num:5), 'user_list' => $user_list, - 'lang_permissions' => lang('Permissions this group has') + 'lang_permissions' => lang('Permissions this group has'), + 'type_list' => $type_list ); $p->set_var($var); @@ -870,7 +880,7 @@ } $account = CreateObject('phpgwapi.accounts'); - $allGroups = $account->get_list('groups'); + $allGroups = $account->get_list('acls'); } elseif(is_string($_userData) && $_userData=='') { @@ -878,7 +888,7 @@ { $account = CreateObject('phpgwapi.accounts',intval($_account_id),'u'); $userData = $account->read_repository(); - $userGroups = $account->membership($_account_id); + $userGroups = $account->membership($_account_id,true); } else { @@ -887,7 +897,7 @@ $userData['status'] = 'A'; $userGroups = Array(); } - $allGroups = $account->get_list('groups'); + $allGroups = $account->get_list('acls'); if ($userData['expires'] == -1) { @@ -1059,7 +1069,7 @@ $part1 = sprintf('<td></td><td><input type="checkbox" name="account_permissions[]" value="True"></td>', lang($perm_display[$i]['translatedName']), $perm_display[$i]['appName'], - ($userData['account_permissions'][$perm_display[$i]['appName']] || $db_perms[$perm_display[$i]['appName']]?' checked':'')); + ($_account_id!==0 && ($userData['account_permissions'][$perm_display[$i]['appName']] || $db_perms[$perm_display[$i]['appName']])?' checked':'')); } $i++; @@ -1069,7 +1079,7 @@ $part2 = sprintf('<td></td><td><input type="checkbox" name="account_permissions[]" value="True"></td>', lang($perm_display[$i]['translatedName']), $perm_display[$i]['appName'], - ($userData['account_permissions'][$perm_display[$i]['appName']] || $db_perms[$perm_display[$i]['appName']]?' checked':'')); + ($_account_id!==0 && ($userData['account_permissions'][$perm_display[$i]['appName']] || $db_perms[$perm_display[$i]['appName']])?' checked':'')); } else { diff -aburN --exclude CVS* phpgw-orig/admin/templates/default/group_form.tpl phpgw-mod/admin/templates/default/group_form.tpl --- phpgw-orig/admin/templates/default/group_form.tpl Thu Jan 10 13:18:43 2002 +++ phpgw-mod/admin/templates/default/group_form.tpl Sat Dec 7 11:34:58 2002 @@ -9,6 +9,10 @@ <form action="{form_action}" method="POST"> {hidden_vars} <tr> + <td>{lang_group_type}</td> + <td>{type_list}</td> + </tr> + <tr> <td>{lang_group_name}</td> <td><input name="account_name" value="{group_name_value}"></td> </tr> diff -aburN --exclude CVS* phpgw-orig/phpgwapi/inc/class.accounts_shared.inc.php phpgw-mod/phpgwapi/inc/class.accounts_shared.inc.php --- phpgw-orig/phpgwapi/inc/class.accounts_shared.inc.php Tue Dec 25 04:22:31 2001 +++ phpgw-mod/phpgwapi/inc/class.accounts_shared.inc.php Sat Dec 7 11:41:10 2002 @@ -135,7 +135,7 @@ return $this->data; } - function membership($accountid = '') + function membership($accountid = '',$acls=false) { $account_id = get_account_id($accountid); @@ -152,6 +152,7 @@ for ($idx=0; $idx<count($security_equals); $idx++) { $groups = intval($security_equals[$idx]); + if($acls || $this->get_type($groups)=='g') $this->memberships[] = Array('account_id' => $groups, 'account_name' => $this->id2name($groups)); } @@ -181,6 +182,97 @@ return $this->members; } + function allMembers($account_id='',$refresh=true) + { + if($refresh || count($this->memberships)==0) + $this->memberlids($account_id,false,$refresh); + $this->members=Array(); + reset($this->memberships); + while(list(,$findMe)=each($this->memberships)) + { + $accountid=$findMe['account_id']; + settype($accountid,"integer"); + $this->member($accountid); + } + return $this->removeDupes(); + } + + function removeDupes() + { + $members=&$this->members; + $count=count($members); + $incomplete=$count>1; + while($incomplete) + { + $restart=false; + $incomplete=false; + $count=count($members); + reset($members); + for($i=0;$restart==false && $i<$count-1;$i++) + { + for($j=$i+1;$restart==false && $j<$count;$j++) + { + if($members[$i]['account_id']==$members[$j]['account_id']) + { + $incomplete=true; + array_splice($members,$j,1); + $restart=true; + } + } + } + } + return $this->members; + } + + function memberlids($account_id='',$acls=false,$refresh=true) + { + if($refresh || count($this->memberships)==0) + $this->membership($account_id); + $groups = $this->get_list('groups'); + $count=count($this->memberships); + for($i=0;$i<$count;$i++) + { + $membership =& $this->memberships[$i]; + + $done=false; + + reset($groups); + while($done==false && list(,$group)=each($groups)) + { + if($group['account_id']==$membership['account_id']) + { + $membership=$group; + $done=true; + } + } + } + return $this->memberships; + } + + function memberusers($account_id='',$refresh=true) + { + $this->allMembers($account_id,$refresh); + $members=&$this->members; + $count=count($members); + $users=$this->get_list('accounts'); + for($i=0;$i<$count;$i++) + { + $done=false; + reset($users); + while($done==false && list(,$user)=each($users)) + { + $member=&$members[$i]; + if($member['account_id']==$user['account_id']) + { + $member=$user; + $done=true; + } + } + } + return $this->members; + } + + /*! @function get_nextid @abstract Using the common functions next_id and last_id, find the next available account_id @@ -194,6 +286,10 @@ if ($account_type == 'g') { $type = 'groups'; + } + elseif($account_type=='a') + { + $type = 'acls'; } else { diff -aburN --exclude CVS* phpgw-orig/phpgwapi/inc/class.accounts_sql.inc.php phpgw-mod/phpgwapi/inc/class.accounts_sql.inc.php --- phpgw-orig/phpgwapi/inc/class.accounts_sql.inc.php Sat Dec 7 00:08:46 2002 +++ phpgw-mod/phpgwapi/inc/class.accounts_sql.inc.php Sat Dec 7 11:46:20 2002 @@ -53,6 +53,7 @@ $this->data['userid'] = $this->db->f('account_lid'); $this->data['account_id'] = $this->db->f('account_id'); $this->data['account_lid'] = $this->db->f('account_lid'); + $this->data['account_type'] = $this->db->f('account_type'); $this->data['firstname'] = $this->db->f('account_firstname'); $this->data['lastname'] = $this->db->f('account_lastname'); $this->data['fullname'] = $this->db->f('account_firstname') . ' ' . $this->db->f('account_lastname'); @@ -74,6 +75,7 @@ $this->db->query("UPDATE phpgw_accounts SET account_firstname='" . $this->data['firstname'] . "', account_lastname='" . $this->data['lastname'] . "', account_status='" . $this->data['status'] . "', account_expires=" . $this->data['expires'] + . ", account_type='" . $this->data['account_type'] . "'" . ($this->data['account_lid']?", account_lid='".$this->data['account_lid']."'":'') . " WHERE account_id='" . $this->account_id . "'",__LINE__,__FILE__); } @@ -112,6 +114,9 @@ break; case 'groups': $whereclause = "WHERE account_type = 'g'"; + break; + case 'acls': + $whereclause = "WHERE account_type in ('g','a')"; break; default: $whereclause = ''; diff -aburN --exclude CVS* phpgw-orig/phpgwapi/inc/class.acl.inc.php phpgw-mod/phpgwapi/inc/class.acl.inc.php --- phpgw-orig/phpgwapi/inc/class.acl.inc.php Mon Dec 10 20:14:43 2001 +++ phpgw-mod/phpgwapi/inc/class.acl.inc.php Sat Dec 7 11:47:16 2002 @@ -589,7 +589,7 @@ $cache_accountid[$accountid] = $account_id; } $db2 = $this->db; - $memberships = $GLOBALS['phpgw']->accounts->membership($account_id); + $memberships = $GLOBALS['phpgw']->accounts->membership($account_id,true); $sql = "select acl_appname, acl_rights from phpgw_acl where acl_location = 'run' and " . 'acl_account in '; $security = '('.$account_id; @@ -639,7 +639,7 @@ . "acl_location in "; $security = "('". $this->account_id ."'"; $myaccounts = CreateObject('phpgwapi.accounts'); - $my_memberships = $myaccounts->membership($this->account_id); + $my_memberships = $myaccounts->membership($this->account_id,true); unset($myaccounts); @reset($my_memberships); while($my_memberships && list($key,$group) = each($my_memberships)) diff -aburN --exclude CVS* phpgw-orig/preferences/inc/class.uiaclprefs.inc.php phpgw-mod/preferences/inc/class.uiaclprefs.inc.php --- phpgw-orig/preferences/inc/class.uiaclprefs.inc.php Sat Dec 7 00:08:48 2002 +++ phpgw-mod/preferences/inc/class.uiaclprefs.inc.php Sat Dec 7 11:55:36 2002 @@ -86,8 +86,9 @@ } $acct = CreateObject('phpgwapi.accounts',$owner); - $groups = $acct->get_list('groups'); - $users = $acct->get_list('accounts'); + $acct->memberusers(); + $groups = $acct->memberships; + $users = $acct->members; $owner_name = $acct->id2name($owner); // get owner name for title if($is_group = $acct->get_type($owner) == 'g') {