phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] admin/inc/class.boaccounts.inc.php, 1.38


From: nomail
Subject: [Phpgroupware-cvs] admin/inc/class.boaccounts.inc.php, 1.38
Date: Thu, 30 Dec 2004 08:38:14 +0100

Update of /admin/inc
Modified Files:
        Branch: 
          class.boaccounts.inc.php

date: 2004/12/30 07:38:14;  author: skwashd;  state: Exp;  lines: +656 -348

Log Message:
new HEAD admin - sans GIFs
=====================================================================
Index: admin/inc/class.boaccounts.inc.php
diff -u admin/inc/class.boaccounts.inc.php:1.37 
admin/inc/class.boaccounts.inc.php:1.38
--- admin/inc/class.boaccounts.inc.php:1.37     Fri Jul 30 12:21:31 2004
+++ admin/inc/class.boaccounts.inc.php  Thu Dec 30 07:38:14 2004
@@ -1,9 +1,8 @@
 <?php
        
/**************************************************************************\
-       * phpGroupWare - Account Administration                                 
   *
+       * phpGroupWare - account administration                                 
   *
        * http://www.phpgroupware.org                                           
   *
-       * Written by coreteam <address@hidden>                    *
-       * -----------------------------------------------------                 
   *
+       * --------------------------------------------                          
   *
        *  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; either version 2 of the License, or (at 
your  *
@@ -14,24 +13,22 @@
        class boaccounts
        {
                var $so;
-               var $public_functions = array
-               (
-                       'add_group'          => true,
-                       'delete_group'       => true,
-                       'delete_user'        => true,
-                       'edit_group'         => true,
-                       'save_user'          => true,
-                       'set_group_managers' => true
+               var $public_functions = array(
+                       'add_group'    => True,
+                       'add_user'     => True,
+                       'delete_group' => True,
+                       'delete_user'  => True,
+                       'edit_group'   => True,
+                       'edit_user'    => True,
+                       'set_group_managers'    => True
                );
 
                var $xml_functions = array();
 
-               var $soap_functions = array
-               (
-                       'add_user'      => array
-                       (
-                               'in'    => array('int','struct'),
-                               'out'   => array()
+               var $soap_functions = array(
+                       'add_user' => array(
+                               'in'  => array('int', 'struct'),
+                               'out' => array()
                        )
                );
 
@@ -77,285 +74,621 @@
                        }
                }
 
-               function check_rights($action, $access = 'group_access')
+               function delete_group()
                {
-                       switch($action)
+                       if (address@hidden($_POST['account_id']) || 
address@hidden'account_id'] || 
$GLOBALS['phpgw']->acl->check('group_access',32,'admin'))
                        {
-                               case 'view':    $right = '8'; break;
-                               case 'add':             $right = '4'; break;
-                               case 'edit':    $right = '16'; break;
-                               case 'delete':  $right = '32'; break;
-                               case 'search':  $right = '2'; break;
+                               ExecMethod('admin.uiaccounts.list_groups');
+                               return False;
+                       }
+                       
+                       $account_id = intval($_POST['account_id']);
+
+                       $GLOBALS['phpgw']->db->lock(
+                               Array(
+                                       'phpgw_accounts',
+                                       'phpgw_acl'
+                               )
+                       );
+                               
+                       $old_group_list = 
$GLOBALS['phpgw']->acl->get_ids_for_location($account_id,1,'phpgw_group');
+
+                       @reset($old_group_list);
+                       while($old_group_list && $id = each($old_group_list))
+                       {
+                               
$GLOBALS['phpgw']->acl->delete_repository('phpgw_group',$account_id,intval($id[1]));
+                               
$GLOBALS['phpgw']->session->delete_cache(intval($id[1]));
                        }
 
-                       if 
(!$GLOBALS['phpgw']->acl->check($access,$right,'admin'))
+                       
$GLOBALS['phpgw']->acl->delete_repository('%%','run',$account_id);
+
+                       if (! 
@rmdir($GLOBALS['phpgw_info']['server']['files_dir'].SEP.'groups'.SEP.$GLOBALS['phpgw']->accounts->id2name($account_id)))
                        {
-                               return True;
+                               $cd = 38;
                        }
-                       return False;
+                       else
+                       {
+                               $cd = 32;
+                       }
+
+                       $GLOBALS['phpgw']->accounts->delete($account_id);
+
+                       $GLOBALS['phpgw']->db->unlock();
+
+                       Header('Location: 
'.$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'));
+                       $GLOBALS['phpgw']->common->phpgw_exit();
                }
 
-               function edit_group($values)
+               function delete_user()
                {
-                       if 
($GLOBALS['phpgw']->acl->check('group_access',16,'admin'))
+                       if (isset($_POST['cancel']) || 
$GLOBALS['phpgw']->acl->check('account_access',32,'admin'))
                        {
-                               $error[] = lang('no permission to create 
groups');
+                               ExecMethod('admin.uiaccounts.list_users');
+                               return False;
                        }
+                       elseif($_POST['delete_account'])
+                       {
+                               $accountid = $_POST['account_id'];
+                               settype($account_id,'integer');
+                               $account_id = get_account_id($accountid);
+
+                               //jarg-SOG S
+                               $personid = $_POST['person_id'];
+                               settype($person_id,'integer');
+                               $person_id = $personid;
+                               //End
+
+                               // make this information also in hook available
+                               $lid = 
$GLOBALS['phpgw']->accounts->id2name($account_id);
+                               $GLOBALS['hook_values']['account_id'] = 
$account_id;
+                               $GLOBALS['hook_values']['account_lid'] = $lid;
+
+                               $db = $GLOBALS['phpgw']->db;
+                               $db->query('SELECT app_name,app_order FROM 
phpgw_applications WHERE app_enabled!=0 ORDER BY app_order',__LINE__,__FILE__);
+                               if($db->num_rows())
+                               {
+                                       while($db->next_record())
+                                       {
+                                               $appname = $db->f('app_name');
 
-                       $old_group = CreateObject('phpgwapi.accounts', 
$values['account_id'], 'g');
-                       $old_group->read_repository();                  
-                       $old_group->member($old_group->get_id());
-                       
-                       $new_group = CreateObject('phpgwapi.accounts', 
$values['account_id'], 'g');
-                       $new_group->read_repository();
-                       $new_group->set_lid($values['account_name']);
+                                               if($appname <> 'admin')
+                                               {
+                                                       
$GLOBALS['phpgw']->hooks->single('deleteaccount', $appname);
+                                               }
+                                       }
+                               }
+
+
+                               
$GLOBALS['phpgw']->hooks->single('deleteaccount','preferences');
+                               
$GLOBALS['phpgw']->hooks->single('deleteaccount','admin');
 
-                       $GLOBALS['phpgw']->db->lock(array('phpgw_accounts',
-                                                         'phpgw_preferences',
-                                                         'phpgw_config',
-                                                         'phpgw_applications',
-                                                         'phpgw_hooks',
-                                                         'phpgw_sessions',
-                                                         'phpgw_acl',
-                                                         'phpgw_app_sessions'
-                                                        ));
+                               
//$GLOBALS['phpgw']->hooks->process('deleteaccount');
 
-                       if(!$values['account_id']) // add new group
+                               $basedir = 
$GLOBALS['phpgw_info']['server']['files_dir'] . SEP . 'users' . SEP;
+
+                               if (! @rmdir($basedir . $lid))
+                               {
+                                       $cd = 34;
+                               }
+                               else
+                               {
+                                       $cd = 29;
+                               }
+
+                               ExecMethod('admin.uiaccounts.list_users');
+                               return False;
+                       }
+               }
+
+               function add_group()
+               {
+                       if 
($GLOBALS['phpgw']->acl->check('group_access',4,'admin'))
                        {
-                               $new_group_values = array('type'        => 'g',
-                                                         'account_lid' => 
$values['account_name'],
-                                                         'passwd'      => '',
-                                                         'firstname'   => 
$values['account_name'],
-                                                         'lastname'    => 
'Group',
-                                                         'status'      => 'A',
-                                                         'expires'     => -1
-                                                        );
-                               $new_group->create($new_group_values, false);
+                               ExecMethod('admin.uiaccounts.list_groups');
+                               return False;
                        }
-                       else //edit group
+
+                       $temp_users = 
($_POST['account_user']?$_POST['account_user']:Array());
+                       $account_user = Array();
+                       @reset($temp_users);
+                       while(list($key,$user_id) = each($temp_users))
                        {
-                               $new_group->save_repository();
+                               $account_user[$user_id] = ' selected';
                        }
-                       $GLOBALS['phpgw']->db->unlock();                        
        
+                       @reset($account_user);
 
-                       // get all new applications for this group
-                       $apps = CreateObject('phpgwapi.applications', 
$values['account_id']);
-                       $old_apps = array_keys($apps->read());
-                       foreach($values['account_apps'] as $key => $value)
+                       $group_permissions = 
($_POST['account_apps']?$_POST['account_apps']:Array());
+                       $account_apps = Array();
+                       @reset($group_permissions);
+                       while(list($key,$value) = each($group_permissions))
                        {
-                               if(!in_array($key, $old_apps))
+                               if($value)
                                {
-                                       $new_apps[] = $key;
+                                       $account_apps[$key] = True;
                                }
                        }
+                       @reset($account_apps);
 
-                       // set group applications
-                       $this->set_module_permissions($new_group->get_id(), 
$values['account_apps']);
+                       $group_info = Array(
+                               'account_id'   => 
($_POST['account_id']?intval($_POST['account_id']):0),
+                               'account_name' => 
($_POST['account_name']?$_POST['account_name']:''),
+                               'account_user' => $account_user,
+                               'account_apps' => $account_apps
+                       );
 
-                       // members handling
-                       // Add new members to group
-                       $acl = CreateObject('phpgwapi.acl', 
$values['account_id']);
-                       $old_group_list = $old_group->get_members();
-                       for($i = 0; $i < count($values['account_user']); $i++)
+                       $this->validate_group($group_info);
+
+                       $GLOBALS['phpgw']->db->lock(
+                               Array(
+                                       'phpgw_accounts',
+                                       'phpgw_nextid',
+                                       'phpgw_preferences',
+                                       'phpgw_sessions',
+                                       'phpgw_acl',
+                                       'phpgw_applications',
+                                       'phpgw_app_sessions',
+                                       'phpgw_hooks',
+                                       'phpgw_lang'
+                               )
+                       );
+
+                       $group = 
CreateObject('phpgwapi.accounts',$group_info['account_id'],'g');
+                       $group->acct_type = 'g';
+                       $account_info = array(
+                               'account_type'      => 'g',
+                               'account_lid'       => 
$group_info['account_name'],
+                               'account_passwd'    => '',
+                               'account_firstname' => 
$group_info['account_name'],
+                               'account_lastname'  => 'Group',
+                               'account_status'    => 'A',
+                               'account_expires'   => -1
+//                             'account_file_space' => 
$account_file_space_number . "-" . $account_file_space_type,
+                       );
+                       $group->create($account_info);
+                       $group_info['account_id'] = 
$GLOBALS['phpgw']->accounts->name2id($group_info['account_name']);
+
+                       $apps = 
CreateObject('phpgwapi.applications',$group_info['account_id']);
+                       $apps->update_data(Array());
+                       reset($group_info['account_apps']);
+                       while(list($app,$value) = 
each($group_info['account_apps']))
+                       {
+                               $apps->add($app);
+                               $new_apps[] = $app;
+                       }
+                       $apps->save_repository();
+
+                       $acl = 
CreateObject('phpgwapi.acl',$group_info['account_id']);
+                       $acl->read_repository();
+
+                       @reset($group_info['account_user']);
+                       while(list($user_id,$dummy) = 
each($group_info['account_user']))
                        {
-                               $is_new = true;
-                               for($j = 0; $j < count($old_group_list); $j++)
+                               if(!$dummy)
                                {
-                                       if($values['account_user'][$i] == 
$old_group_list[$j])
-                                       {
-                                               unset($old_group_list[$j]);
-                                               $is_new = false;
-                                               break;
-                                       }
+                                       continue;
                                }
-                               if($is_new)
+                               
$acl->add_repository('phpgw_group',$group_info['account_id'],$user_id,1);
+                               $group->add_account2Group($user_id, 
$group_info['account_id']);
+
+                               $docommit = False;
+                               $GLOBALS['pref'] = 
CreateObject('phpgwapi.preferences',$user_id);
+                               $t = $GLOBALS['pref']->read_repository();
+                               @reset($new_apps);
+                               while(is_array($new_apps) && 
list($app_key,$app_name) = each($new_apps))
                                {
-                                       $acl->add_repository('phpgw_group', 
$new_group->get_id(), $values['account_user'][$i], 1);
-                                       
$this->refresh_session_data($values['account_user'][$i]);
-                                       
-                                       // The following sets any default 
preferences needed for new applications..
-                                       // This is smart enough to know if 
previous preferences were selected, use them.
-                                       $docommit = false;
-                                       if(count($new_apps))
+                                       if 
(!$t[($app_name=='admin'?'common':$app_name)])
                                        {
-                                               $GLOBALS['pref'] = 
CreateObject('phpgwapi.preferences', $values['account_user'][$i]);
-                                               $t = 
$GLOBALS['pref']->read_repository();
-                                               while(list($app_key,$app_name) 
= each($new_apps))
-                                               for($j = 0; $j < 
count($new_apps); $j++)
-                                               {
-                                                       if($new_apps[$i] == 
'admin') //another workaround :-(
-                                                       {
-                                                               $new_apps[$i] 
== 'common';
-                                                       }
-                                                       
-                                                       if (!$t[$new_apps[$i]])
-                                                       {
-                                                               
$GLOBALS['phpgw']->hooks->single('add_def_pref', $new_apps[$i]);
-                                                               $docommit = 
true;
-                                                       }
-                                               }
-                                       }
-                                       if ($docommit)
-                                       {
-                                               
$GLOBALS['pref']->save_repository();
+                                               
$GLOBALS['phpgw']->hooks->single('add_def_pref', $app_name);
+                                               $docommit = True;
                                        }
                                }
+                               if ($docommit)
+                               {
+                                       $GLOBALS['pref']->save_repository();
+                               }
                        }
-                       // Remove members from group
-                       foreach($old_group_list as $key => $value)
+
+                       $acl->save_repository();
+
+                       $basedir = 
$GLOBALS['phpgw_info']['server']['files_dir'] . SEP . 'groups' . SEP;
+                       $cd = 31;
+                       umask(000);
+                       if (! @mkdir ($basedir . $group_info['account_name'], 
0707))
                        {
-                               
$acl->delete_repository('phpgw_group',$new_group->get_id(), $value);
-                               
$this->refresh_session_data($values['account_user'][$i]);
+                               $cd = 37;
                        }
 
-                       // Things that have to change because of new group name
-                       if($old_group->get_lid() != $new_group->get_lid())
+                       $GLOBALS['phpgw']->db->unlock();
+
+                       ExecMethod('admin.uiaccounts.list_groups');
+                       return False;
+               }
+
+               function add_user()
+               {
+                       if 
($GLOBALS['phpgw']->acl->check('account_access',4,'admin'))
                        {
-                               $basedir = 
$GLOBALS['phpgw_info']['server']['files_dir'] . SEP . 'groups' . SEP;
-                               @rename($basedir . $old_group->get_lid(), 
$basedir . $new_group->get_lid());
+                               ExecMethod('admin.uiaccounts.list_users');
+                               return False;
+                       }
+
+                       if ($_POST['submit'])
+                       {
+                               $userData = array(
+                                       'account_type'          => 'u',
+                                       'account_lid'           => 
$_POST['account_lid'],
+                                       'account_firstname'     => 
$_POST['account_firstname'],
+                                       'account_lastname'      => 
$_POST['account_lastname'],
+                                       'account_passwd'        => 
$_POST['account_passwd'],
+                                       'status'                => 
($_POST['account_status'] ? 'A' : ''),
+                                       'account_status'        => 
($_POST['account_status'] ? 'A' : ''),
+                                       'old_loginid'           => 
($_GET['old_loginid']?rawurldecode($_GET['old_loginid']):''),
+                                       'account_id'            => 
($_GET['account_id']?$_GET['account_id']:0),
+                                       'account_passwd_2'      => 
$_POST['account_passwd_2'],
+                                       'account_groups'        => 
$_POST['account_groups'],
+                                       'anonymous'             => 
$_POST['anonymous'],
+                                       'changepassword'        => 
$_POST['changepassword'],
+                                       'account_permissions'   => 
$_POST['account_permissions'],
+                                       'homedirectory'         => 
$_POST['homedirectory'],
+                                       'loginshell'            => 
$_POST['loginshell'],
+                                       'account_expires_month' => 
$_POST['account_expires_month'],
+                                       'account_expires_day'   => 
$_POST['account_expires_day'],
+                                       'account_expires_year'  => 
$_POST['account_expires_year'],
+                                       'account_expires_never' => 
$_POST['never_expires'],
+                                       //jarg-SOG S
+                                       'domain'                                
=> $_POST['domain'],
+                                       'add_addbook'                   => 
$_POST['add_addbook'],
+                                       'quota'                                 
=> $_POST['quota']
+                                       //End
+                                       /* 'file_space' => 
$_POST['account_file_space_number'] . "-" . $_POST['account_file_space_type'] */
+                               );
+                               if (!$errors = $this->validate_user($userData))
+                               {
+                                       $userData['person_id'] = 
$GLOBALS['phpgw']->accounts->save_contact_for_account($userData);
+                                       $account_id = 
$this->_add_user($userData);
+
+                                       $ui = createobject('admin.uiaccounts');
+                                       
$ui->create_edit_user($account_id,$userData);
+                                       return False;
+                               }
+                               else
+                               {
+                                       $ui = createobject('admin.uiaccounts');
+                                       
$ui->create_edit_user($userData['account_id'],$userData,$errors);
+                               }
+                       }
+                       else
+                       {
+                               ExecMethod('admin.uiaccounts.list_users');
+                               return False;
                        }
                }
 
                /**
-               * Saves a new user (account) or update an existing one
+               * This function was created for others apps can call with 
parameters
                *
-               * @param array $values Account details
-               * @return null No return value
+               * @param Array $userData Array with all account data. If you 
want to send data for contact
+               * you can set an array $userData['extra_contact'] with all 
data, see add_contact in contact api
+               * for more info about the format of this array
                */
-               function save_user($values)
+               function _add_user($userData)
                {
-                       if (is_array($values))
+                       $account_id = $this->so->add_user($userData);
+                       if ($userData['anonymous'])
+                       {
+                               
$GLOBALS['phpgw']->acl->add_repository('phpgwapi','anonymous',$account_id,1);
+                       }
+                       else
                        {
-                               if($values['expires_never'])
+                               
$GLOBALS['phpgw']->acl->delete_repository('phpgwapi','anonymous',$account_id);
+                       }
+                       // make this information for the hooks available
+                       $GLOBALS['hook_values']['account_lid'] = 
$userData['account_lid'];
+                       $GLOBALS['hook_values']['account_id'] = $account_id;
+                       $GLOBALS['hook_values']['new_passwd'] = 
$userData['account_passwd'];
+                       $GLOBALS['hook_values']['account_firstname'] = 
$userData['account_firstname'];
+                       $GLOBALS['hook_values']['account_lastname'] = 
$userData['account_lastname'];
+                       $GLOBALS['phpgw']->hooks->process('addaccount');
+                       return $account_id;
+               }
+               
+               function edit_group()
+               {
+                       if 
($GLOBALS['phpgw']->acl->check('group_access',16,'admin'))
+                       {
+                               ExecMethod('admin.uiaccounts.list_groups');
+                               return False;
+                       }
+
+                       $temp_users = 
($_POST['account_user']?$_POST['account_user']:Array());
+                       $account_user = Array();
+                       @reset($temp_users);
+                       while($temp_users && list($key,$user_id) = 
each($temp_users))
+                       {
+                               $account_user[$user_id] = ' selected';
+                       }
+                       @reset($account_user);
+
+                       $group_permissions = 
($_POST['account_apps']?$_POST['account_apps']:Array());
+                       $account_apps = Array();
+                       @reset($group_permissions);
+                       while(list($key,$value) = each($group_permissions))
+                       {
+                               if($value)
                                {
-                                       $values['expires'] = 
$values['account_expires'] = -1;
+                                       $account_apps[$key] = True;
                                }
-                               else
+                       }
+                       @reset($account_apps);
+
+                       $group_info = Array(
+                               'account_id'   => 
($_POST['account_id']?intval($_POST['account_id']):0),
+                               'account_name' => 
($_POST['account_name']?$_POST['account_name']:''),
+                               'account_user' => $account_user,
+                               'account_apps' => $account_apps
+                       );
+
+                       $this->validate_group($group_info);
+
+                       // Lock tables
+                       $GLOBALS['phpgw']->db->lock(
+                               Array(
+                                       'phpgw_accounts',
+                                       'phpgw_preferences',
+                                       'phpgw_config',
+                                       'phpgw_applications',
+                                       'phpgw_hooks',
+                                       'phpgw_sessions',
+                                       'phpgw_acl',
+                                       'phpgw_app_sessions',
+                                       'phpgw_lang'
+                               )
+                       );
+
+                       $group = 
CreateObject('phpgwapi.accounts',$group_info['account_id'],'g');
+                       $old_group_info = $group->read_repository();
+
+                       // Set group apps
+                       $apps = 
CreateObject('phpgwapi.applications',$group_info['account_id']);
+                       $apps_before = $apps->read_account_specific();
+                       $apps->update_data(Array());
+                       $new_apps = Array();
+                       if(count($group_info['account_apps']))
+                       {
+                               reset($group_info['account_apps']);
+                               while(list($app,$value) = 
each($group_info['account_apps']))
                                {
-                                       $values['expires'] = 
$values['account_expires'] = 
mktime(2,0,0,$values['account_expires_month'],$values['account_expires_day'],$values['account_expires_year']);
+                                       $apps->add($app);
+                                       if(address@hidden || @$apps_before == 
False)
+                                       {
+                                               $new_apps[] = $app;
+                                       }
                                }
+                       }
+                       $apps->save_repository();
 
-                               $userData = array
-                               (
-                                       'type'                  => 'u',
-                                       'account_lid'           => 
$values['account_lid'],
-                                       'firstname'             => 
$values['account_firstname'],
-                                       'lastname'              => 
$values['account_lastname'],
-                                       'passwd'                => 
$values['account_passwd'],
-                                       'status'                => 
($values['account_status'] ? 'A' : ''),
-                                       'old_loginid'           => 
($values['old_loginid']?rawurldecode($GLOBALS['HTTP_GET_VARS']['old_loginid']):''),
-                                       'account_id'            => 
$values['account_id'],
-                                       'account_passwd_2'      => 
$values['account_passwd_2'],
-                                       'groups'                => 
$values['account_groups'],
-                                       'account_permissions'   => 
$values['account_permissions'],
-                                       'homedirectory'         => 
$values['homedirectory'],
-                                       'loginshell'            => 
$values['loginshell'],
-                                       'account_expires_month' => 
$values['account_expires_month'],
-                                       'account_expires_day'   => 
$values['account_expires_day'],
-                                       'account_expires_year'  => 
$values['account_expires_year'],
-                                       'account_expires_never' => 
$values['expires'],
-                                       'expires'                     => 
$values['expires'],
-                                       /* 'file_space' => 
$GLOBALS['HTTP_POST_VARS']['account_file_space_number'] . "-" . 
$GLOBALS['HTTP_POST_VARS']['account_file_space_type'] */
-                               );
+                       // Set new account_lid, if needed
+                       if($group_info['account_name'] && 
$old_group_info['account_lid'] <> $group_info['account_name'])
+                       {
+                               $group->data['account_lid'] = 
$group_info['account_name'];
 
-                               if ($values['account_id']) //user exists
+                               $basedir = 
$GLOBALS['phpgw_info']['server']['files_dir'] . SEP . 'groups' . SEP;
+                               if (! @rename($basedir . 
$old_group_info['account_lid'], $basedir . $group_info['account_name']))
+                               {
+                                       $cd = 39;
+                               }
+                               else
                                {
-                                       $userData['account_id'] = 
$values['account_id'];
-                                       $this->so->update_user($userData);
+                                       $cd = 33;
+                               }
+                       }
+                       else
+                       {
+                               $cd = 33;
+                       }
 
-                                       if ($userData['passwd'])
+                       // Set group acl
+                       $acl = 
CreateObject('phpgwapi.acl',$group_info['account_id']);
+                       $old_group_list = 
$acl->get_ids_for_location($group_info['account_id'],1,'phpgw_group');
+                       if ($old_group_list)
+                       {
+                               @reset($old_group_list);
+                               while(list($key,$user_id) = 
each($old_group_list))
+                               {
+                                       
$acl->delete_repository('phpgw_group',$group_info['account_id'],$user_id);
+                                       
if(!$group_info['account_user'][$user_id])
                                        {
-                                               $auth = 
CreateObject('phpgwapi.auth');
-                                               
$auth->change_password($old_passwd,$userData['passwd'],$userData['account_id']);
-                                               
$GLOBALS['hook_values']['account_id'] = $userData['account_id'];
-                                               
$GLOBALS['hook_values']['old_passwd'] = $old_passwd;
-                                               
$GLOBALS['hook_values']['new_passwd'] = $userData['account_passwd'];
-                                               
$GLOBALS['phpgw']->hooks->process('changepassword');
+                                               // If the user is logged in, it 
will force a refresh of the session_info
+                                               
$GLOBALS['phpgw']->db->query("update phpgw_sessions set session_action='' "
+                                                       ."where session_lid='" 
. $GLOBALS['phpgw']->accounts->id2name($user_id)
+                                                       . '@' . 
$GLOBALS['phpgw_info']['user']['domain'] . "'",__LINE__,__FILE__);
+                                               
$GLOBALS['phpgw']->session->delete_cache($user_id);
                                        }
+                               }
+                       }
+
+                       @reset($group_info['account_user']);
+                       while(list($user_id,$dummy) = 
each($group_info['account_user']))
+                       {
+                               if(!$dummy)
+                               {
+                                       continue;
+                               }
+                               
$acl->add_repository('phpgw_group',$group_info['account_id'],$user_id,1);
+
+                               // If the user is logged in, it will force a 
refresh of the session_info
+                               $GLOBALS['phpgw']->db->query("update 
phpgw_sessions set session_action='' "
+                                       ."where session_lid='" . 
$GLOBALS['phpgw']->accounts->id2name($user_id)
+                                       . '@' . 
$GLOBALS['phpgw_info']['user']['domain'] . "'",__LINE__,__FILE__);
                                        
-                                       
$GLOBALS['phpgw']->session->delete_cache(intval($userData['id']));
-                                       /* check if would create a menu
+                               
$GLOBALS['phpgw']->session->delete_cache($user_id);
+
+                               // The following sets any default preferences 
needed for new applications..
+                               // This is smart enough to know if previous 
preferences were selected, use them.
+                               $docommit = False;
+                               if($new_apps)
+                               {
+                                       $GLOBALS['pref'] = 
CreateObject('phpgwapi.preferences',$user_id);
+                                       $t = 
$GLOBALS['pref']->read_repository();
+                                       @reset($new_apps);
+                                       while(list($app_key,$app_name) = 
each($new_apps))
+                                       {
+                                               if 
(!$t[($app_name=='admin'?'common':$app_name)])
+                                               {
+                                                       
$GLOBALS['phpgw']->hooks->single('add_def_pref', $app_name);
+                                                       $docommit = True;
+                                               }
+                                       }
+                               }
+                               if ($docommit)
+                               {
+                                       $GLOBALS['pref']->save_repository();
+                               }
+                       }
+                       $group->save_repository();
+
+               /*
+                       // Update any other options here, since the above 
save_repository () depends
+                       // on a group having users
+                       $group->data['file_space'] = 
$_POST['account_file_space_number'] . "-" . $_POST['account_file_space_type'];
+                       $group->save_repository();
+               */
+
+                       $GLOBALS['phpgw']->db->unlock();
+
+                       ExecMethod('admin.uiaccounts.list_groups');
+                       return False;
+               }
+
+               function edit_user()
+               {
+                       if 
($GLOBALS['phpgw']->acl->check('account_access',16,'admin'))
+                       {
+                               ExecMethod('admin.uiaccounts.list_users');
+                               return False;
+                       }
+
+                       if ($_POST['submit'])
+                       {
+                               $userData = array(
+                                       'account_lid'           => 
$_POST['account_lid'],
+                                       'account_firstname'     => 
$_POST['account_firstname'],
+                                       'account_lastname'      => 
$_POST['account_lastname'],
+                                       'account_passwd'        => 
$_POST['account_passwd'],
+                                       'status'                => 
($_POST['account_status'] ? 'A' : 'I'),
+                                       'account_status'        => 
($_POST['account_status'] ? 'A' : 'I'),
+                                       'old_loginid'           => 
($_GET['old_loginid']?rawurldecode($_GET['old_loginid']):''),
+                                       'account_id'            => 
($_GET['account_id']?$_GET['account_id']:0),
+                                       'account_passwd_2'      => 
$_POST['account_passwd_2'],
+                                       'account_groups'        => 
$_POST['account_groups'],
+                                       'anonymous'             => 
$_POST['anonymous'],
+                                       'changepassword'        => 
$_POST['changepassword'],
+                                       'account_permissions'   => 
$_POST['account_permissions'],
+                                       'homedirectory'         => 
$_POST['homedirectory'],
+                                       'loginshell'            => 
$_POST['loginshell'],
+                                       'account_expires_month' => 
$_POST['account_expires_month'],
+                                       'account_expires_day'   => 
$_POST['account_expires_day'],
+                                       'account_expires_year'  => 
$_POST['account_expires_year'],
+                                       'account_expires_never' => 
$_POST['never_expires'],
+                                       //jarg-SOG S
+                               //      'domain'                                
=> $_POST['domain'],
+                                       'add_addbook'                   => 
$_POST['add_addbook'],
+                                       'person_id'                             
=> $_POST['person_id'],
+                                       'quota'                                 
=> $_POST['quota']
+                                       //End
+                                       /* 'file_space' => 
$_POST['account_file_space_number'] . "-" . $_POST['account_file_space_type'] */
+                               );
+                               if (!$errors = $this->validate_user($userData))
+                               {
+                                       $this->save_user($userData);
+                                       $GLOBALS['hook_values']['account_id'] = 
$userData['account_id'];
+                                       $GLOBALS['hook_values']['account_lid'] 
= $userData['account_lid'];
+                                       
$GLOBALS['hook_values']['account_firstname'] = $userData['account_firstname'];
+                                       
$GLOBALS['hook_values']['account_lastname'] = $userData['account_lastname'];
+                                       $GLOBALS['hook_values']['person_id'] = 
$userData['person_id'];
+                                       
$GLOBALS['phpgw']->hooks->process('editaccount');
+
+                                       // check if would create a menu
                                        // if we do, we can't return to the 
users list, because
                                        // there are also some other plugins
                                        if 
(!ExecMethod('admin.uimenuclass.createHTMLCode','edit_user'))
                                        {
-                                       }*/
+                                               
ExecMethod('admin.uiaccounts.list_users');
+                                               return False;
+                                       }
+                                       else
+                                       {
+                                               
ExecMethod('admin.uiaccounts.edit_user',$_GET['account_id']);
+                                               return False;
+                                       }
                                }
-                               else //new user
+                               else
                                {
-                                       $userData['account_id'] = 
$this->so->add_user($userData);
-                                       $GLOBALS['hook_values']['account_lid'] 
= $userData['account_lid'];
-                                       $GLOBALS['hook_values']['account_id']   
 = $userData['account_id'];
-                                       $GLOBALS['hook_values']['new_passwd']   
 = $userData['passwd'];
-                                       
$GLOBALS['phpgw']->hooks->process('addaccount');
+                                       $ui = createobject('admin.uiaccounts');
+                                       
$ui->create_edit_user($userData['account_id'],$userData,$errors);
                                }
-                               
$this->set_module_permissions($userData['account_id'], 
$userData['account_permissions']);
-                               
$this->set_groups2account($userData['account_id'], $userData['groups']);        
                
                        }
                }
 
                function set_group_managers()
                {
-                       
if($GLOBALS['phpgw']->acl->check('group_access',16,'admin') || 
$GLOBALS['HTTP_POST_VARS']['cancel'])
+                       
if($GLOBALS['phpgw']->acl->check('group_access',16,'admin') || $_POST['cancel'])
                        {
                                
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'));
-                               $GLOBALS['phpgw_info']['flags']['nodisplay'] = 
True;
-                               exit;
+                               $GLOBALS['phpgw']->common->phpgw_exit();
                        }
-                       elseif($GLOBALS['HTTP_POST_VARS']['submit'])
+                       elseif($_POST['submit'])
                        {
-                               $acl = 
CreateObject('phpgwapi.acl',intval($GLOBALS['HTTP_POST_VARS']['account_id']));
-                               
-                               $users = 
$GLOBALS['phpgw']->accounts->member($GLOBALS['HTTP_POST_VARS']['account_id']);
+                               $acl = 
CreateObject('phpgwapi.acl',intval($_POST['account_id']));
+
+                               $users = 
$GLOBALS['phpgw']->accounts->member($_POST['account_id']);
                                @reset($users);
                                while($managers && list($key,$user) = 
each($users))
                                {
-                                       
$acl->add_repository('phpgw_group',intval($GLOBALS['HTTP_POST_VARS']['account_id']),$user['account_id'],1);
+                                       
$acl->add_repository('phpgw_group',intval($_POST['account_id']),$user['account_id'],1);
                                }
-                               $managers = 
$GLOBALS['HTTP_POST_VARS']['managers'];
+                               $managers = $_POST['managers'];
                                @reset($managers);
                                while($managers && list($key,$manager) = 
each($managers))
                                {
-                                       
$acl->add_repository('phpgw_group',intval($GLOBALS['HTTP_POST_VARS']['account_id']),$manager,(1
 + PHPGW_ACL_GROUP_MANAGERS));
+                                       
$acl->add_repository('phpgw_group',intval($_POST['account_id']),$manager,(1 + 
PHPGW_ACL_GROUP_MANAGERS));
                                }
                        }
                        
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiaccounts.list_groups'));
-                       $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
-                       exit;
+                       $GLOBALS['phpgw']->common->phpgw_exit();
                }
 
-               function validate_group($values)
+               function validate_group($group_info)
                {
-                       $group = 
CreateObject('phpgwapi.accounts',$values['account_id'],'g');
+                       $errors = Array();
+                       
+                       $group = 
CreateObject('phpgwapi.accounts',$group_info['account_id'],'g');
                        $group->read_repository();
 
-                       if (!$values['account_id'] && 
$GLOBALS['phpgw']->acl->check('group_access',4,'admin'))
-                       {
-                               $error[] = lang('no permission to add groups');
-                       }
-
-                       if(!$values['account_name'])
+                       if(!$group_info['account_name'])
                        {
-                               $error[] = lang('You must enter a group name.');
+                               $errors[] = lang('You must enter a group 
name.');
                        }
 
-                       if($values['account_name'] != 
$group->id2name($values['account_id']))
+                       if($group_info['account_name'] != 
$group->id2name($group_info['account_id']))
                        {
-                               if ($group->exists($values['account_name']))
+                               if ($group->exists($group_info['account_name']))
                                {
-                                       $error[] = lang('Sorry, that group name 
has already been taken.');
+                                       $errors[] = lang('Sorry, that group 
name has already been taken.');
                                }
                        }
 
                /*
                        if (preg_match ("/\D/", $account_file_space_number))
                        {
-                               $error[] = lang ('File space must be an 
integer');
+                               $errors[] = lang ('File space must be an 
integer');
                        }
                */
-                       if(is_array($error))
+                       if(count($errors))
                        {
-                               return $error;
+                               $ui = createobject('admin.uiaccounts');
+                               $ui->create_edit_group($group_info,$errors);
+                               $GLOBALS['phpgw']->common->phpgw_exit();
                        }
                }
 
@@ -363,70 +696,77 @@
                 returns FALSE if the data are correct
                 otherwise the error array
                */
-               function validate_user($values)
+               function validate_user(&$_userData)
                {
-                       if (!$values['account_id'] && 
$GLOBALS['phpgw']->acl->check('account_access',4,'admin'))
-                       {
-                               $error[] = lang('no permission to add users');
-                       }
+                       $totalerrors = 0;
 
                        /*
-                       if 
($GLOBALS['phpgw_info']['server']['account_repository'] == 'ldap' && ! 
$values['allow_long_loginids'])
+                       if 
($GLOBALS['phpgw_info']['server']['account_repository'] == 'ldap' && ! 
$allow_long_loginids)
                        {
-                               if (strlen($values['account_lid']) > 8) 
+                               if (strlen($_userData['account_lid']) > 8) 
                                {
-                                       $error[] = lang('The loginid can not be 
more then 8 characters');
+                                       $error[$totalerrors] = lang('The 
loginid can not be more then 8 characters');
+                                       $totalerrors++;
                                }
                        }
                        */
 
-                       if (!$values['account_lid'])
+                       if (!$_userData['account_lid'])
                        {
-                               $error[] = lang('You must enter a loginid');
+                               $error[$totalerrors] = lang('You must enter a 
loginid');
+                               $totalerrors++;
                        }
 
-                       if ($values['old_loginid'] != $values['account_lid']) 
+                       if ($_userData['old_loginid'] != 
$_userData['account_lid']) 
                        {
-                               if 
($GLOBALS['phpgw']->accounts->exists($values['account_lid']))
+                               if 
($GLOBALS['phpgw']->accounts->exists($_userData['account_lid']))
                                {
-                                       $error[] = lang('That loginid has 
already been taken');
+                                       $error[$totalerrors] = lang('That 
loginid has already been taken');
+                                       $totalerrors++;
                                }
                        }
 
-                       if ($values['account_passwd'] || 
$values['account_passwd_2']) 
+                       if ($_userData['account_passwd'] || 
$_userData['account_passwd_2']) 
                        {
-                               if ($values['account_passwd'] != 
$values['account_passwd_2']) 
+                               if ($_userData['account_passwd'] != 
$_userData['account_passwd_2']) 
                                {
-                                       $error[] = lang('The two passwords are 
not the same');
-                               }
-
-                       /*      $temp_msgbox_data = 
$GLOBALS['phpgw_info']['flags']['msgbox_data'];
-                               
unset($GLOBALS['phpgw_info']['flags']['msgbox_data']);
-                               
if(!sanitize($_userData['account_passwd'],'password'))
-                               {
-                                       
reset($GLOBALS['phpgw_info']['flags']['msgbox_data']);
-                                       while(list($key) = 
each($GLOBALS['phpgw_info']['flags']['msgbox_data']))
-                                       {
-                                               $error[$totalerrors] = 
lang($key);
-                                               $totalerrors++;
-                                       }
+                                       $error[$totalerrors] = lang('The two 
passwords are not the same');
+                                       $totalerrors++;
                                }
-                               $GLOBALS['phpgw_info']['flags']['msgbox_data'] 
= $temp_msgbox_data;
-                               unset($temp_msgbox_data); */
                        }
 
-                       if (!count($values['account_permissions']) && 
!count($values['account_groups'])) 
+                       if (!count($_userData['account_permissions']) && 
!count($_userData['account_groups'])) 
                        {
-                               $error[] = lang('You must add at least 1 
permission or group to this account');
+                               $error[$totalerrors] = lang('You must add at 
least 1 permission or group to this account');
+                               $totalerrors++;
                        }
 
-                       if ($values['account_expires_month'] || 
$values['account_expires_day'] || $values['account_expires_year'] || 
$values['account_expires_never'])
+                       if ($_userData['account_expires_month'] || 
$_userData['account_expires_day'] || $_userData['account_expires_year'] || 
$_userData['account_expires_never'])
                        {
-                               if (! 
checkdate($values['account_expires_month'],$values['account_expires_day'],$values['account_expires_year']))
+                               if($_userData['account_expires_never'])
                                {
-                                       $error[] = lang('You have entered an 
invalid expiration date');
+                                       $_userData['expires'] = -1;
+                                       $_userData['account_expires'] = 
$_userData['expires'];
+                               }
+                               else
+                               {
+                                       if (! 
checkdate($_userData['account_expires_month'],$_userData['account_expires_day'],$_userData['account_expires_year']))
+                                       {
+                                               $error[$totalerrors] = 
lang('You have entered an invalid expiration date');
+                                               $totalerrors++;
+                                       }
+                                       else
+                                       {
+                                               $_userData['expires'] = 
mktime(2,0,0,$_userData['account_expires_month'],$_userData['account_expires_day'],$_userData['account_expires_year']);
+                                               $_userData['account_expires'] = 
$_userData['expires'];
+                                       }
                                }
                        }
+                       else
+                       {
+                               $_userData['expires'] = -1;
+                               $_userData['account_expires'] = 
$_userData['expires'];
+                       }
 
                /*
                        $check_account_file_space = explode ('-', 
$_userData['file_space']);
@@ -437,89 +777,108 @@
                        }
                */
 
-                       if (is_array($error))
+                       /* check that addressmaster record exist */
+//                     if 
(!$GLOBALS['phpgw']->accounts->exists('addressmaster') && 
$_userData['account_lid'] != 'addressmaster')
+//                     {
+//                             $error[$totalerrors] = lang('You have not the 
addressmaster record');
+//                             $totalerrors++;
+//                     }
+                       
+                       
+                       if ($totalerrors == 0)
+                       {
+                               return FALSE;
+                       }
+                       else
                        {
                                return $error;
                        }
                }
 
-
-               function delete_group($account_id)
+               /* stores the userdata */
+               function save_user($_userData)
                {
-                       if 
($GLOBALS['phpgw']->acl->check('group_access',32,'admin'))
+                       $account = 
CreateObject('phpgwapi.accounts',$_userData['account_id'],'u');
+                       //This is a temporary patch for the case of corrupted 
LDAP tree :) (Caeies)
+                       if ( empty($_userData['person_id']) )
                        {
-                               return False;
+                               $_userData['person_id'] = 
$account->data['person_id'] ? $account->data['person_id'] : 
$GLOBALS['phpgw']->accounts->save_contact_for_account($_userData);
                        }
-
-                       $GLOBALS['phpgw']->db->lock(array
-                               (
-                                       'phpgw_accounts',
-                                       'phpgw_acl',
-                                       'phpgw_sessions' // should be in direct 
in the session class!?
-                               )
-                       );
-
-                       $old_group_list = 
$GLOBALS['phpgw']->acl->get_ids_for_location($account_id,1,'phpgw_group');
-
-                       @reset($old_group_list);
-                       while($old_group_list && $id = each($old_group_list))
+                       $account->update_data($_userData);
+                       $account->save_repository();
+                       if ($_userData['account_passwd'])
                        {
-                               
$GLOBALS['phpgw']->acl->delete_repository('phpgw_group',$account_id,intval($id[1]));
-                               
$GLOBALS['phpgw']->session->delete_cache(intval($id[1]));
+                               $auth = CreateObject('phpgwapi.auth');
+                               $auth->change_password($old_passwd, 
$_userData['account_passwd'], $_userData['account_id']);
+                               $GLOBALS['hook_values']['account_id'] = 
$_userData['account_id'];
+                               $GLOBALS['hook_values']['old_passwd'] = 
$old_passwd;
+                               $GLOBALS['hook_values']['new_passwd'] = 
$_userData['account_passwd'];
+                               
$GLOBALS['phpgw']->hooks->process('changepassword');
                        }
 
-                       
$GLOBALS['phpgw']->acl->delete_repository('%%','run',$account_id);
-
-                       
@rmdir($GLOBALS['phpgw_info']['server']['files_dir'].SEP.'groups'.SEP.$GLOBALS['phpgw']->accounts->id2name($account_id));
-
-                       $GLOBALS['phpgw']->accounts->delete($account_id);
-                       $GLOBALS['phpgw']->db->unlock();
-               }
+                       $apps = 
CreateObject('phpgwapi.applications',array(intval($_userData['account_id']),'u'));
 
-               function delete_user($id, $newowner)
-               {
-                       
if($GLOBALS['phpgw']->acl->check('account_access',32,'admin'))
+                       $apps->account_id = $_userData['account_id'];
+                       if ($_userData['account_permissions'])
                        {
-                               ExecMethod('admin.uiaccounts.list_users');
-                               return False;
+                               while($app = 
each($_userData['account_permissions']))
+                               {
+                                       if($app[1])
+                                       {
+                                               $apps->add($app[0]);
+                                       }
+                               }
                        }
-                       
-                       $account_id = get_account_id( (int) $id );
-                       $GLOBALS['hook_values']['account_id'] = $account_id;
+                       $apps->save_repository();
+
+                       $account = 
CreateObject('phpgwapi.accounts',$_userData['account_id'],'u');
+                       $allGroups = $account->get_list('groups');
 
-                       $db = $GLOBALS['phpgw']->db;
-                       $db->query('SELECT app_name,app_order FROM 
phpgw_applications WHERE app_enabled!=0 ORDER BY app_order',__LINE__,__FILE__);
-                       if($db->num_rows())
+                       if ($_userData['account_groups'])
                        {
-                               while($db->next_record())
+                               reset($_userData['account_groups']);
+                               while (list($key,$value) = 
each($_userData['account_groups']))
                                {
-                                       $appname = $db->f('app_name');
-
-                                       if($appname != 'admin' && $appname != 
'preferences')
-                                       {
-                                               
$GLOBALS['phpgw']->hooks->single('deleteaccount', $appname);
-                                       }
+                                       $newGroups[$value] = $value;
                                }
                        }
 
-                       
$GLOBALS['phpgw']->hooks->single('deleteaccount','preferences');
-                       
$GLOBALS['phpgw']->hooks->single('deleteaccount','admin');
+                       $acl = 
CreateObject('phpgwapi.acl',$_userData['account_id']);
 
-                       $GLOBALS['phpgw']->hooks->process('deleteaccount');
+                       reset($allGroups);
+                       while (list($key,$groupData) = each($allGroups))
+                       {
+                               /* print "$key,". $groupData['account_id'] 
."<br>";*/
+                               /* print "$key,". 
$_userData['account_groups'][1] ."<br>"; */
 
-                       //<??[+_+]??
-                       $basedir = 
$GLOBALS['phpgw_info']['server']['files_dir'] . SEP . 'users' . SEP;
-                       $lid = 
$GLOBALS['phpgw']->accounts->id2name($account_id);
-                       if (! @rmdir($basedir . $lid))
+                               if ($newGroups[$groupData['account_id']])
+                               {
+                                       
$acl->add_repository('phpgw_group',$groupData['account_id'],$_userData['account_id'],1);
+                                       
$GLOBALS['phpgw']->accounts->add_account2Group($_userData['account_id'], 
$groupData['account_id']);
+                               }
+                               else
+                               {
+                                       
$acl->delete_repository('phpgw_group',$groupData['account_id'],$_userData['account_id']);
+                                       
$GLOBALS['phpgw']->accounts->delete_account4Group($_userData['account_id'], 
$groupData['account_id']);
+                               }
+                       }
+                       if ($_userData['anonymous'])
                        {
-                               $cd = 34;
+                               
$acl->add_repository('phpgwapi','anonymous',$_userData['account_id'],1);
                        }
                        else
                        {
-                               $cd = 29;
+                               
$acl->delete_repository('phpgwapi','anonymous',$_userData['account_id']);
                        }
-                       //<??[+_+]??
-                       return $this->so->delete_user($account_id);
+                       if ($_userData['changepassword'])
+                       {
+                               
$GLOBALS['phpgw']->acl->add_repository('preferences','changepassword',$_userData['account_id'],1);
+                       }
+                       else
+                       {
+                               
$GLOBALS['phpgw']->acl->delete_repository('preferences','changepassword',$_userData['account_id']);
+                       }
+                       
$GLOBALS['phpgw']->session->delete_cache(intval($_userData['account_id']));
                }
 
                function load_group_users($account_id)
@@ -564,21 +923,19 @@
 
                function load_group_apps($account_id)
                {
-                       $account_apps = array();
-                       if($account_id)
+                       $apps = 
CreateObject('phpgwapi.applications',intval($account_id));
+                       $app_list = $apps->read_account_specific();
+                       $account_apps = Array();
+                       while(list($key,$app) = each($app_list))
                        {
-                               $apps = 
CreateObject('phpgwapi.applications',intval($account_id));
-                               $app_list = $apps->read_account_specific();
-
-                               while(list($key,$app) = each($app_list))
-                               {
-                                       $account_apps[$app['name']] = True;
-                               }
-                               @reset($account_apps);
+                               $account_apps[$app['name']] = True;
                        }
+                       @reset($account_apps);
                        return $account_apps;
                }
 
+               // xmlrpc functions
+
                function rpc_add_user($data)
                {
                        exit;
@@ -593,59 +950,10 @@
                        }
                        return $result;
                }
-               
-               function set_module_permissions($id, $modules)
-               {
-                       if($id)
-                       {
-                               $apps = CreateObject('phpgwapi.applications', 
intval($id));
-                               while($app = each($modules)) 
-                               {
-                                       if($app[1])
-                                       {
-                                               $apps->add($app[0]);
-                                       }
-                               }
-                               $apps->save_repository();
-                       }
-               }
-               
-               function set_groups2account($id, $groups)
-               {
-                       $account = CreateObject('phpgwapi.accounts', $id, 'u');
-                       $allGroups = $account->get_list('groups');
-                       if ($groups)
-                       {
-                               while (list($key,$value) = each($groups))
-                               {
-                                       $newGroups[$value] = $value;
-                               }
-                       }
 
-                       $acl = CreateObject('phpgwapi.acl',$id);
-                       while (list($key,$groupData) = each($allGroups)) 
-                       {
-                               if (in_array($groupData['account_id'], 
$groups)) 
-                               {
-                                       
$acl->add_repository('phpgw_group',$groupData['account_id'], $id, 1);
-                               }
-                               else
-                               {
-                                       
$acl->delete_repository('phpgw_group',$groupData['account_id'],$id);
-                               }
-                       }
-               }
-       
-               function refresh_session_data($id)
+               function get_addressmaster_ids()
                {
-                       // If the user is logged in, it will force a refresh of 
the session_info
-                       
-                       // This can't work - just imaging session data in php4
-                       // $GLOBALS['phpgw']->db->query("update phpgw_sessions 
set session_action='' "
-                       // ."where session_lid='" . 
$GLOBALS['phpgw']->accounts->id2name($id)
-                       // . '@' . $GLOBALS['phpgw_info']['user']['domain'] . 
"'",__LINE__,__FILE__);
-                       
-                       $GLOBALS['phpgw']->session->delete_cache($id);
+                       return 
$GLOBALS['phpgw']->acl->get_ids_for_location('addressmaster',7,'addressbook');
                }
        }
 ?>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]