phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] setup/ldapexport.php, 1.7


From: nomail
Subject: [Phpgroupware-cvs] setup/ldapexport.php, 1.7
Date: Thu, 30 Dec 2004 09:43:15 +0100

Update of /setup
Modified Files:
        Branch: 
          ldapexport.php

date: 2004/12/30 08:43:15;  author: skwashd;  state: Exp;  lines: +55 -51

Log Message:
adding missing files to new HEAD
=====================================================================
Index: setup/ldapexport.php
diff -u setup/ldapexport.php:1.6 setup/ldapexport.php:1.7
--- setup/ldapexport.php:1.6    Sun Aug 11 23:54:57 2002
+++ setup/ldapexport.php        Thu Dec 30 08:43:15 2004
@@ -28,6 +28,9 @@
        }
        // Does not return unless user is authorized
 
+       //This stops timeout problems for larger conversions
+       @set_time_limit(0);
+
        class phpgw
        {
                var $common;
@@ -54,17 +57,8 @@
        $GLOBALS['phpgw_setup']->db->query("SELECT config_name,config_value 
FROM phpgw_config WHERE config_name LIKE 'ldap%'",__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'][$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']['ldap_account_home']  = 
$config['ldap_account_home'];
-       $phpgw_info['server']['ldap_account_shell'] = 
$config['ldap_account_shell'];
-       $phpgw_info['server']['ldap_extra_attributes'] = 
$config['ldap_extra_attributes'];
-
        $phpgw_info['server']['account_repository'] = 'ldap';
 
        $phpgw->accounts     = CreateObject('phpgwapi.accounts');
@@ -118,24 +112,18 @@
                $group_info[$i]['account_expires']   = 
$GLOBALS['phpgw_setup']->db->f('account_expires');
        }
 
-       while(list($key,$data) = @each($group_info))
-       {
-               $tmp = $data['account_id'][0];
-               $newgroup[$tmp] = $data;
-       }
-       $group_info = $newgroup;
-
-       if($cancel)
+       if($_POST['cancel'])
        {
                Header('Location: ldap.php');
                exit;
        }
 
-       if($submit)
+       if($_POST['submit'])
        {
-               if($ldapgroups)
+               if($_POST['ldapgroups'] && is_array($_POST['ldapgroups']))
                {
-                       while(list($key,$groupid) = each($ldapgroups))
+
+                       foreach($_POST['ldapgroups'] as $key => $groupid)
                        {
                                $id_exist = 0;
                                $thisacctid    = 
$group_info[$groupid]['account_id'];
@@ -152,39 +140,47 @@
 
                                        // Check if the account is already 
there.
                                        // If so, we won't try to create it 
again.
-                                       $acct_exist = 
$acct->name2id($thisacctlid);
+                                       $acct_exist = 
$acct->groupName2id($thisacctlid);
                                        if($acct_exist)
                                        {
                                                $thisacctid = $acct_exist;
                                        }
-                                       $id_exist = 
$groups->exists(intval($thisacctid));
+                                       $id_exist = 
$groups->group_exists(intval($thisacctid));
                                        
+                                       /*
                                        echo '<br>accountid: ' . $thisacctid;
                                        echo '<br>accountlid: ' . $thisacctlid;
                                        echo '<br>exists: ' . $id_exist;
+                                       */
                                        
                                        /* If not, create it now. */
                                        if(!$id_exist)
                                        {
-                                               $thisaccount_info = array(
-                                                       'account_type'      => 
'g',
-                                                       'account_id'        => 
$thisacctid,
-                                                       'account_lid'       => 
$thisacctlid,
-                                                       'account_passwd'    => 
'x',
-                                                       'account_firstname' => 
$thisfirstname,
-                                                       'account_lastname'  => 
$thislastname,
-                                                       'account_status'    => 
'A',
-                                                       'account_expires'   => 
-1
+                                               echo "<br />\nAdding Group:  
$thisacctlid (gid: $thisacctid)";
+                                               $groups->create(
+                                                       array(
+                                                               'account_type'  
    => 'g',
+                                                               'account_id'    
    => $thisacctid,
+                                                               'account_lid'   
    => $thisacctlid,
+                                                               
'account_passwd'    => 'x',
+                                                               
'account_firstname' => $thisfirstname,
+                                                               
'account_lastname'  => $thislastname,
+                                                               
'account_status'    => 'A',
+                                                               
'account_expires'   => -1
+                                                       )
                                                );
-                                               
$groups->create($thisaccount_info);
+                                       }
+                                       else
+                                       {
+                                               echo "<br />\nSkipping Group: 
$thisacctlid (gid: $thisacctlid) - Exists";
                                        }
                                }
                        }
                }
 
-               if($users)
+               if($_POST['users'] && is_array($_POST['users']))
                {
-                       while(list($key,$accountid) = each($users))
+                       foreach($_POST['users'] as $key => $accountid)
                        {
                                $id_exist = 0; $acct_exist = 0;
                                $thisacctid    = 
$account_info[$accountid]['account_id'];
@@ -205,24 +201,32 @@
                                        {
                                                $thisacctid = $acct_exist;
                                        }
+                                       /* create_account handles existing 
accounts
                                        $id_exist = 
$accounts->exists(intval($thisacctid));
+                                       */
                                        // If not, create it now.
                                        if(!$id_exist)
                                        {
-                                               echo '<br>Adding' . $thisacctid;
-                                               $thisaccount_info = array(
-                                                       'account_type'      => 
'u',
-                                                       'account_id'        => 
$thisacctid,
-                                                       'account_lid'       => 
$thisacctlid,
-                                                       'account_passwd'    => 
'x',
-                                                       'account_firstname' => 
$thisfirstname,
-                                                       'account_lastname'  => 
$thislastname,
-                                                       'account_status'    => 
'A',
-                                                       'account_expires'   => 
-1,
-                                                       'homedirectory'     => 
$config['ldap_account_home'] . '/' . $thisacctlid,
-                                                       'loginshell'        => 
$config['ldap_account_shell']
+                                               echo "<br />\nAdding User: 
$thisacctlid (uid: $thisacctid)";
+                                               $accounts->create(
+                                                               array(
+                                                                       
'account_type'      => 'u',
+                                                                       
'account_id'        => $thisacctid,
+                                                                       
'account_lid'       => $thisacctlid,
+                                                                       
'account_passwd'    => 'x',
+                                                                       
'account_firstname' => $thisfirstname,
+                                                                       
'account_lastname'  => $thislastname,
+                                                                       
'account_status'    => 'A',
+                                                                       
'account_expires'   => -1,
+                                                                       
'homedirectory'     => $config['ldap_account_home'] 
+                                                                               
                . '/' . $thisacctlid,
+                                                                       
'loginshell'        => $config['ldap_account_shell']
+                                                               )
                                                );
-                                               
$accounts->create($thisaccount_info);
+                                       }
+                                       else
+                                       {
+                                               echo "<br />\nSkipping User: 
$thisacctlid (uid: $thisacctid) - Exists";
                                        }
                                }
                        }
@@ -240,8 +244,8 @@
 
        if($setup_complete)
        {
-               echo lang('<br><center>Export has been completed!  You will 
need to set the user passwords manually.</center>');
-               echo lang('<br><center>Click <a href="index.php">here</a> to 
return to setup </center>');
+               echo '<br><center>'.lang('Export has been completed!  You will 
need to set the user passwords manually.').'</center>';
+               echo '<br><center>'.lang('Click <a href="index.php">here</a> to 
return to setup.').'</center>';
                $GLOBALS['phpgw_setup']->html->show_footer();
                exit;
        }




reply via email to

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