[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] setup ldapimport.php [Version-0_9_16-branch]
From: |
Dave Hall |
Subject: |
[Phpgroupware-cvs] setup ldapimport.php [Version-0_9_16-branch] |
Date: |
Wed, 18 Oct 2006 04:11:50 +0000 |
CVSROOT: /cvsroot/phpgroupware
Module name: setup
Branch: Version-0_9_16-branch
Changes by: Dave Hall <skwashd> 06/10/18 04:11:50
Modified files:
. : ldapimport.php
Log message:
fix ldap import, group memberships and make globals safe
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/setup/ldapimport.php?cvsroot=phpgroupware&only_with_tag=Version-0_9_16-branch&r1=1.10.2.4&r2=1.10.2.5
Patches:
Index: ldapimport.php
===================================================================
RCS file: /cvsroot/phpgroupware/setup/ldapimport.php,v
retrieving revision 1.10.2.4
retrieving revision 1.10.2.5
diff -u -b -r1.10.2.4 -r1.10.2.5
--- ldapimport.php 6 Nov 2004 16:13:46 -0000 1.10.2.4
+++ ldapimport.php 18 Oct 2006 04:11:50 -0000 1.10.2.5
@@ -9,7 +9,7 @@
* option) any later version. *
\**************************************************************************/
- /* $Id: ldapimport.php,v 1.10.2.4 2004/11/06 16:13:46 powerstat Exp $ */
+ /* $Id: ldapimport.php,v 1.10.2.5 2006/10/18 04:11:50 skwashd Exp $ */
$GLOBALS['phpgw_info'] = array();
$GLOBALS['phpgw_info']['flags'] = array(
@@ -148,6 +148,7 @@
if ($_POST['submit'])
{
+ $error = '';
if (! @count($_POST['admins']) )
{
$error = '<br />You must select at least 1 admin';
@@ -160,88 +161,7 @@
if (!$error)
{
- if(@$_POST['users'] && is_array($_POST['users']) )
- {
- foreach($users as $key => $id)
- {
- $id_exist = 0;
- $thisacctid =
$account_info[$id]['account_id'];
- $thisacctlid =
$account_info[$id]['account_lid'];
- $thisfirstname =
$account_info[$id]['account_firstname'];
- $thislastname =
$account_info[$id]['account_lastname'];
- $thispasswd =
$account_info[$id]['account_passwd'];
-
- // Do some checks before we try to
import the data.
- if (!empty($thisacctid) &&
!empty($thisacctlid) )
- {
- $accounts =
CreateObject('phpgwapi.accounts',intval($thisacctid));
- $accounts->db =
$GLOBALS['phpgw_setup']->db;
-
- // Check if the account is
already there.
- // If so, we won't try to
create it again.
- $acct_exist =
$acct->name2id($thisacctlid);
- if ($acct_exist)
- {
- $thisacctid =
$acct_exist;
- }
- $id_exist =
$accounts->exists($thisacctlid);
- // If not, create it now.
- if(!$id_exist)
- {
- $thisaccount_info =
array(
- 'account_type'
=> 'u',
- 'account_lid'
=> $thisacctlid,
-
'account_passwd' => 'x',
- /*
'account_passwd' => $thispasswd, */
-
'account_firstname' => $thisfirstname,
-
'account_lastname' => $thislastname,
-
'account_status' => 'A',
-
'account_expires' => -1
- );
-
$accounts->create($thisaccount_info);
- $thisacctid =
$acct->name2id($thisacctlid);
- }
-
- // Insert default acls for this
user.
- // Since the group has app
rights, we don't need to give users
- // these rights. Instead, we
make the user a member of the Default group
- // below.
-
$GLOBALS['phpgw']->acl->acl($thisacctid);
-
$GLOBALS['phpgw']->acl->read_repository();
-
- // Only give them admin if we
asked for them to have it.
- // This is typically an
exception to apps for run rights
- // as a group member.
- $cnt_admins =
count($_POST['admins']);
- for ($a = 0; $a < $cnt_admins;
++$a)
- {
- if ($admins[$a] ==
$thisacctlid)
- {
-
$GLOBALS['phpgw']->acl->delete('admin','run',1);
-
$GLOBALS['phpgw']->acl->add('admin','run',1);
- }
- }
-
- // Now make them a member of
the 'Default' group.
- // But, only if the current
user is not the group itself.
- if (!$defaultgroupid)
- {
- $defaultgroupid =
$accounts->name2id('Default');
- }
-
- if($defaultgroupid)
- {
-
$GLOBALS['phpgw']->acl->delete('phpgw_group',$defaultgroupid,1);
-
$GLOBALS['phpgw']->acl->add('phpgw_group',$defaultgroupid,1);
- }
-
- // Save these new acls.
-
$GLOBALS['phpgw']->acl->save_repository();
- }
- }
- }
-
- if ( @$_POST['ldapgroups'] &&
is_array($_POST['ldapgroups']) )
+ if ( isset($_POST['ldapgroups']) &&
count($_POST['ldapgroups']) )
{
foreach($ldapgroups as $key => $groupid)
{
@@ -327,8 +247,8 @@
$pref->db =
$GLOBALS['phpgw_setup']->db;
$pref->account_id = intval($tmpid);
$pref->read_repository();
- @reset($s_apps);
- while
(list($key,$app) = each($s_apps))
+
@reset($_POST['s_apps']);
+ while
(list($key,$app) = each($_POST['s_apps']))
{
$GLOBALS['phpgw']->hooks->single('add_def_pref',$app);
}
@@ -338,12 +258,13 @@
/* Now give this group some
rights */
$GLOBALS['phpgw']->acl->acl($thisacctid);
$GLOBALS['phpgw']->acl->read_repository();
- @reset($s_apps);
- while (list($key,$app) =
each($s_apps))
+ @reset($_POST['s_apps']);
+ while (list($key,$app) =
each($_POST['s_apps']))
{
$GLOBALS['phpgw']->acl->delete($app,'run',1);
$GLOBALS['phpgw']->acl->add($app,'run',1);
}
+
$acl->add('preferences','changepassword', 1);
$GLOBALS['phpgw']->acl->save_repository();
$defaultgroupid = $thisacctid;
}
@@ -368,7 +289,8 @@
{
$groups->delete($defaultgroupid);
}
- $thisgroup_info = array(
+ $thisgroup_info = array
+ (
'account_type' => 'g',
'account_lid' => 'Default',
'account_passwd' => $passwd,
@@ -385,19 +307,100 @@
$acl->db = $GLOBALS['phpgw_setup']->db;
$acl->account_id = intval($defaultgroupid);
$acl->read_repository();
- @reset($s_apps);
- while (list($key,$app) = each($s_apps))
+ foreach ( $_POST['s_apps'] as $app )
{
$acl->delete($app,'run',1);
$acl->add($app,'run',1);
}
+ $acl->add('preferences','changepassword', 1);
$acl->save_repository();
} //end default group creation
}
+
+ if ( isset($_POST['users']) && is_array($_POST['users']) )
+ {
+ foreach($_POST['users'] as $key => $id)
+ {
+ $id_exist = 0;
+ $thisacctid =
$account_info[$id]['account_id'];
+ $thisacctlid =
$account_info[$id]['account_lid'];
+ $thisfirstname =
$account_info[$id]['account_firstname'];
+ $thislastname =
$account_info[$id]['account_lastname'];
+ $thispasswd =
$account_info[$id]['account_passwd'];
+
+ // Do some checks before we try to import the
data.
+ if (!empty($thisacctid) && !empty($thisacctlid)
)
+ {
+ $accounts =
CreateObject('phpgwapi.accounts',intval($thisacctid));
+ $accounts->db =
$GLOBALS['phpgw_setup']->db;
+
+ // Check if the account is already
there.
+ // If so, we won't try to create it
again.
+ $acct_exist =
$acct->name2id($thisacctlid);
+ if ($acct_exist)
+ {
+ $thisacctid = $acct_exist;
+ }
+ $id_exist =
$accounts->exists($thisacctlid);
+ // If not, create it now.
+ if(!$id_exist)
+ {
+ $thisaccount_info = array(
+ 'account_type' =>
'u',
+ 'account_lid' =>
$thisacctlid,
+ 'account_passwd' =>
'x',
+ /* 'account_passwd' =>
$thispasswd, */
+ 'account_firstname' =>
$thisfirstname,
+ 'account_lastname' =>
$thislastname,
+ 'account_status' =>
'A',
+ 'account_expires' =>
-1
+ );
+
$accounts->create($thisaccount_info);
+ $thisacctid =
$acct->name2id($thisacctlid);
+ }
+
+ // Insert default acls for this user.
+ // Since the group has app rights, we
don't need to give users
+ // these rights. Instead, we make the
user a member of the Default group
+ // below.
+
$GLOBALS['phpgw']->acl->acl($thisacctid);
+
$GLOBALS['phpgw']->acl->read_repository();
+
+ // Only give them admin if we asked for
them to have it.
+ // This is typically an exception to
apps for run rights
+ // as a group member.
+ $cnt_admins = count($_POST['admins']);
+ for ($a = 0; $a < $cnt_admins; ++$a)
+ {
+ if ($admins[$a] == $thisacctlid)
+ {
+
$GLOBALS['phpgw']->acl->delete('admin','run',1);
+
$GLOBALS['phpgw']->acl->add('admin','run',1);
+ }
+ }
+
+ // Now make them a member of the
'Default' group.
+ // But, only if the current user is not
the group itself.
+ if (!$defaultgroupid)
+ {
+ $defaultgroupid =
$accounts->name2id('Default');
+ }
+
+ if($defaultgroupid)
+ {
+
$GLOBALS['phpgw']->acl->delete('phpgw_group',$defaultgroupid,1);
+
$GLOBALS['phpgw']->acl->add('phpgw_group',$defaultgroupid,1);
+ }
+
+ // Save these new acls.
+
$GLOBALS['phpgw']->acl->save_repository();
+ }
+ }
+ }
$setup_complete = True;
}
- $GLOBALS['phpgw_setup']->html->show_header('LDAP
Import','','config',$ConfigDomain);
+ $GLOBALS['phpgw_setup']->html->show_header('LDAP
Import','','config',$_COOKIE['ConfigDomain']);
if ($error)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] setup ldapimport.php [Version-0_9_16-branch],
Dave Hall <=