mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 17:14:44 +01:00
c71c53851f
a too long account-lid caused the complete lost of run-rigths from all user and groups
98 lines
2.7 KiB
PHP
Executable File
98 lines
2.7 KiB
PHP
Executable File
<?php
|
|
/**************************************************************************\
|
|
* eGroupWare - account administration *
|
|
* http://www.egroupware.org *
|
|
* -------------------------------------------- *
|
|
* 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 *
|
|
* option) any later version. *
|
|
\**************************************************************************/
|
|
|
|
/* $Id$ */
|
|
|
|
class soaccounts
|
|
{
|
|
function soaccounts()
|
|
{
|
|
}
|
|
|
|
function add_user($userData)
|
|
{
|
|
$userData['account_expires'] = $userData['expires'];
|
|
//$userData['account_email'] = $userData['email'];
|
|
|
|
if($userData['email'] != "")
|
|
{
|
|
$userData['account_email'] = $userData['email'];
|
|
}
|
|
|
|
if (!($userData['account_id'] = $GLOBALS['egw']->accounts->create($userData)))
|
|
{
|
|
return false;
|
|
}
|
|
$apps =& CreateObject('phpgwapi.applications',$userData['account_id']);
|
|
$apps->read_installed_apps();
|
|
// Read Group Apps
|
|
if ($userData['account_groups'])
|
|
{
|
|
$apps->account_type = 'g';
|
|
reset($userData['account_groups']);
|
|
while($groups = each($userData['account_groups']))
|
|
{
|
|
$apps->account_id = $groups[0];
|
|
$old_app_groups = $apps->read_account_specific();
|
|
@reset($old_app_groups);
|
|
while($old_group_app = each($old_app_groups))
|
|
{
|
|
if (!$apps_after[$old_group_app[0]])
|
|
{
|
|
$apps_after[$old_group_app[0]] = $old_app_groups[$old_group_app[0]];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$apps->account_type = 'u';
|
|
$apps->account_id = $userData['account_id'];
|
|
$apps->data = Array(Array());
|
|
|
|
if ($userData['account_permissions'])
|
|
{
|
|
@reset($userData['account_permissions']);
|
|
while (list($app,$turned_on) = each($userData['account_permissions']))
|
|
{
|
|
if ($turned_on)
|
|
{
|
|
$apps->add($app);
|
|
if (!$apps_after[$app])
|
|
{
|
|
$apps_after[] = $app;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$apps->save_repository();
|
|
|
|
if ($userData['changepassword'])
|
|
{
|
|
$GLOBALS['egw']->acl->add_repository('preferences','changepassword',$userData['account_id'],1);
|
|
}
|
|
// Assign user to groups
|
|
if ($userData['account_groups'])
|
|
{
|
|
$c_acct_groups = count($userData['account_groups']);
|
|
for ($i=0;$i<$c_acct_groups;$i++)
|
|
{
|
|
$GLOBALS['egw']->acl->add_repository('phpgw_group',$userData['account_groups'][$i],$userData['account_id'],1);
|
|
}
|
|
}
|
|
|
|
$apps->account_apps = array(array());
|
|
$apps_after = array(array());
|
|
|
|
return $userData['account_id'];
|
|
}
|
|
}
|
|
?>
|