[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] setup/ldapimport.php, 1.10.2.3
From: |
nomail |
Subject: |
[Phpgroupware-cvs] setup/ldapimport.php, 1.10.2.3 |
Date: |
Mon, 7 Jun 2004 16:26:37 +0200 |
Update of /setup
Modified Files:
Branch: Version-0_9_16-branch
ldapimport.php
date: 2004/06/07 14:26:37; author: skwashd; state: Exp; lines: +60 -58
Log Message:
fix import
=====================================================================
Index: setup/ldapimport.php
diff -u setup/ldapimport.php:1.10.2.2 setup/ldapimport.php:1.10.2.3
--- setup/ldapimport.php:1.10.2.2 Fri Jan 9 01:32:58 2004
+++ setup/ldapimport.php Mon Jun 7 14:26:37 2004
@@ -11,8 +11,8 @@
/* $Id$ */
- $phpgw_info = array();
- $phpgw_info["flags"] = array(
+ $GLOBALS['phpgw_info'] = array();
+ $GLOBALS['phpgw_info']['flags'] = array(
'noheader' => True,
'nonavbar' => True,
'currentapp' => 'home',
@@ -34,13 +34,19 @@
var $accounts;
var $applications;
var $db;
+ var $hooks;
+ var $acl;
}
- $phpgw = new phpgw;
- $phpgw->common = CreateObject('phpgwapi.common');
+ $GLOBALS['phpgw'] = new phpgw;
+ $GLOBALS['phpgw']->common = CreateObject('phpgwapi.common');
- $common = $phpgw->common;
+ $common = $GLOBALS['phpgw']->common;
$GLOBALS['phpgw_setup']->loaddb();
- $phpgw->db = $GLOBALS['phpgw_setup']->db;
+ $GLOBALS['phpgw']->db = $GLOBALS['phpgw_setup']->db;
+ $GLOBALS['phpgw']->hooks = createObject('phpgwapi.hooks');
+
+ $GLOBALS['phpgw']->acl = createObject('phpgwapi.acl');
+ $GLOBALS['phpgw']->acl->db = $GLOBALS['phpgw_setup']->db;
$tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
$setup_tpl = CreateObject('setup.Template',$tpl_root);
@@ -51,25 +57,25 @@
'T_alert_msg' => 'msg_alert_msg.tpl'
));
- $phpgw_info['server']['auth_type'] = 'ldap';
+ $GLOBALS['phpgw_info']['server']['auth_type'] = 'ldap';
- $phpgw->applications = CreateObject('phpgwapi.applications');
- $applications = $phpgw->applications;
+ $GLOBALS['phpgw']->applications = CreateObject('phpgwapi.applications');
+ $applications = $GLOBALS['phpgw']->applications;
$GLOBALS['phpgw_setup']->db->query("SELECT config_name,config_value
FROM phpgw_config WHERE config_name LIKE 'ldap%' OR
config_name='account_repository'",__LINE__,__FILE__);
while ($GLOBALS['phpgw_setup']->db->next_record())
{
$config[$GLOBALS['phpgw_setup']->db->f('config_name')] =
$GLOBALS['phpgw_setup']->db->f('config_value');
}
- $phpgw_info['server']['ldap_host'] = $config['ldap_host'];
- $phpgw_info['server']['ldap_context'] = $config['ldap_context'];
- $phpgw_info['server']['ldap_group_context'] =
$config['ldap_group_context'];
- $phpgw_info['server']['ldap_root_dn'] = $config['ldap_root_dn'];
- $phpgw_info['server']['ldap_root_pw'] = $config['ldap_root_pw'];
- $phpgw_info['server']['account_repository'] =
$config['account_repository'];
+ $GLOBALS['phpgw_info']['server']['ldap_host'] =
$config['ldap_host'];
+ $GLOBALS['phpgw_info']['server']['ldap_context'] =
$config['ldap_context'];
+ $GLOBALS['phpgw_info']['server']['ldap_group_context'] =
$config['ldap_group_context'];
+ $GLOBALS['phpgw_info']['server']['ldap_root_dn'] =
$config['ldap_root_dn'];
+ $GLOBALS['phpgw_info']['server']['ldap_root_pw'] =
$config['ldap_root_pw'];
+ $GLOBALS['phpgw_info']['server']['account_repository'] =
$config['account_repository'];
- $phpgw->accounts = CreateObject('phpgwapi.accounts');
- $acct = $phpgw->accounts;
+ $GLOBALS['phpgw']->accounts = CreateObject('phpgwapi.accounts');
+ $acct = $GLOBALS['phpgw']->accounts;
// First, see if we can connect to the LDAP server, if not send `em
back to config.php with an
// error message.
@@ -92,7 +98,7 @@
for ($i=0; $i<$info['count']; $i++)
{
- if (!
$phpgw_info['server']['global_denied_users'][$info[$i]['uid'][0]])
+ if (!
$GLOBALS['phpgw_info']['server']['global_denied_users'][$info[$i]['uid'][0]])
{
$tmp = $info[$i]['uidnumber'][0];
$account_info[$tmp]['account_id'] =
$info[$i]['uidnumber'][0];
@@ -103,7 +109,7 @@
}
}
- if ($phpgw_info['server']['ldap_group_context'])
+ if ($GLOBALS['phpgw_info']['server']['ldap_group_context'])
{
$srg =
ldap_search($ldap,$config['ldap_group_context'],'(|(cn=*))',array('gidnumber','cn','memberuid'));
$info = ldap_get_entries($ldap, $srg);
@@ -111,7 +117,7 @@
for ($i=0; $i<$info['count']; $i++)
{
- if (!
$phpgw_info['server']['global_denied_groups'][$info[$i]['cn'][0]] &&
+ if (!
$GLOBALS['phpgw_info']['server']['global_denied_groups'][$info[$i]['cn'][0]] &&
! $account_info[$i][$info[$i]['cn'][0]])
{
$tmp = $info[$i]['gidnumber'][0];
@@ -134,29 +140,29 @@
$apps[$GLOBALS['phpgw_setup']->db->f('app_name')] =
lang($GLOBALS['phpgw_setup']->db->f('app_name'));
}
- if ($cancel)
+ if ($_POST['cancel'])
{
Header("Location: ldap.php");
exit;
}
- if ($submit)
+ if ($_POST['submit'])
{
- if (!count($admins))
+ if (! @count($_POST['admins']) )
{
$error = '<br>You must select at least 1 admin';
}
- if (!count($s_apps))
+ if (! @count($_POST['s_apps']) )
{
$error .= '<br>You must select at least 1 application';
}
if (!$error)
{
- if($users)
+ if(@$_POST['users'] && is_array($_POST['users']) )
{
- while (list($key,$id) = each($users))
+ foreach($users as $key => $id)
{
$id_exist = 0;
$thisacctid =
$account_info[$id]['account_id'];
@@ -166,7 +172,7 @@
$thispasswd =
$account_info[$id]['account_passwd'];
// Do some checks before we try to
import the data.
- if (!empty($thisacctid) &&
!empty($thisacctlid))
+ if (!empty($thisacctid) &&
!empty($thisacctlid) )
{
$accounts =
CreateObject('phpgwapi.accounts',intval($thisacctid));
$accounts->db =
$GLOBALS['phpgw_setup']->db;
@@ -200,19 +206,19 @@
// 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.
- $acl =
CreateObject('phpgwapi.acl',intval($thisacctid));
- $acl->db =
$GLOBALS['phpgw_setup']->db;
- $acl->read_repository();
+
$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.
- for
($a=0;$a<count($admins);$a++)
+ $cnt_admins =
count($_POST['admins']);
+ for ($a = 0; $a < $cnt_admins;
++$a)
{
if ($admins[$a] ==
$thisacctlid)
{
-
$acl->delete('admin','run',1);
-
$acl->add('admin','run',1);
+
$GLOBALS['phpgw']->acl->delete('admin','run',1);
+
$GLOBALS['phpgw']->acl->add('admin','run',1);
}
}
@@ -222,21 +228,22 @@
{
$defaultgroupid =
$accounts->name2id('Default');
}
+
if($defaultgroupid)
{
-
$acl->delete('phpgw_group',$defaultgroupid,1);
-
$acl->add('phpgw_group',$defaultgroupid,1);
+
$GLOBALS['phpgw']->acl->delete('phpgw_group',$defaultgroupid,1);
+
$GLOBALS['phpgw']->acl->add('phpgw_group',$defaultgroupid,1);
}
// Save these new acls.
- $acl->save_repository();
+
$GLOBALS['phpgw']->acl->save_repository();
}
}
}
- if ($ldapgroups)
+ if ( @$_POST['ldapgroups'] &&
is_array($_POST['ldapgroups']) )
{
- while (list($key,$groupid) = each($ldapgroups))
+ foreach($ldapgroups as $key => $groupid)
{
$id_exist = 0;
$thisacctid =
$group_info[$groupid]['account_id'];
@@ -277,7 +284,7 @@
}
// Now make them a member of
this group in phpgw.
- while (list($key,$members) =
each($thismembers))
+ while (list($key,$members) =
@each($thismembers))
{
if ($key == 'count')
{
@@ -301,19 +308,17 @@
*/
if($tmpid)
{
- $acl =
CreateObject('phpgwapi.acl',$tmpid);
- $acl->db =
$GLOBALS['phpgw_setup']->db;
-
$acl->account_id = intval($tmpid);
-
$acl->read_repository();
+
$GLOBALS['phpgw']->acl->acl($tmpid);
+
$GLOBALS['phpgw']->acl->read_repository();
-
$acl->delete('phpgw_group',$thisacctid,1);
-
$acl->add('phpgw_group',$thisacctid,1);
+
$GLOBALS['phpgw']->acl->delete('phpgw_group',$thisacctid,1);
+
$GLOBALS['phpgw']->acl->add('phpgw_group',$thisacctid,1);
/* Now add the
acl to let them change their password */
-
$acl->delete('preferences','changepassword',1);
-
$acl->add('preferences','changepassword',1);
+
$GLOBALS['phpgw']->acl->delete('preferences','changepassword',1);
+
$GLOBALS['phpgw']->acl->add('preferences','changepassword',1);
-
$acl->save_repository();
+
$GLOBALS['phpgw']->acl->save_repository();
/* Add prefs
for selected apps here, since they are per-user.
App
access is added below.
@@ -325,24 +330,21 @@
@reset($s_apps);
while
(list($key,$app) = each($s_apps))
{
-
$phpgw->hooks->single('add_def_pref',$app);
+
$GLOBALS['phpgw']->hooks->single('add_def_pref',$app);
}
$pref->save_repository();
}
}
/* Now give this group some
rights */
-
$phpgw_info['user']['account_id'] = $thisacctid;
- $acl =
CreateObject('phpgwapi.acl');
- $acl->db =
$GLOBALS['phpgw_setup']->db;
- $acl->account_id =
intval($thisacctid);
- $acl->read_repository();
+
$GLOBALS['phpgw']->acl->acl($thisacctid);
+
$GLOBALS['phpgw']->acl->read_repository();
@reset($s_apps);
while (list($key,$app) =
each($s_apps))
{
-
$acl->delete($app,'run',1);
- $acl->add($app,'run',1);
+
$GLOBALS['phpgw']->acl->delete($app,'run',1);
+
$GLOBALS['phpgw']->acl->add($app,'run',1);
}
- $acl->save_repository();
+
$GLOBALS['phpgw']->acl->save_repository();
$defaultgroupid = $thisacctid;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] setup/ldapimport.php, 1.10.2.3,
nomail <=