[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] phpgwapi/inc class.accounts_ldap.inc.php, 1.101.2.13.
From: |
Alejandro Borges (lex) <address@hidden> |
Subject: |
[Phpgroupware-cvs] phpgwapi/inc class.accounts_ldap.inc.php, 1.101.2.13.2.7, 1.101.2.13.2.8 class.accounts_shared.inc.php, 1.48.2.2.2.20, 1.48.2.2.2.21 class.accounts_sql.inc.php, 1.80.2.8.2.17, 1.80.2.8.2.18 class.contacts_sql.inc.php, 1.17.2.2.2.34, 1.17.2.2.2.35 |
Date: |
Fri, 31 Oct 2003 01:23:30 +0000 |
Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv18540/phpgwapi/inc
Modified Files:
Tag: Version-0_9_16-branch
class.accounts_ldap.inc.php class.accounts_shared.inc.php
class.accounts_sql.inc.php class.contacts_sql.inc.php
Log Message:
Further work to make contacts <-> ldap work with all upgrade paths
Index: class.contacts_sql.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.contacts_sql.inc.php,v
retrieving revision 1.17.2.2.2.34
retrieving revision 1.17.2.2.2.35
diff -C2 -d -r1.17.2.2.2.34 -r1.17.2.2.2.35
*** class.contacts_sql.inc.php 30 Oct 2003 02:47:53 -0000 1.17.2.2.2.34
--- class.contacts_sql.inc.php 31 Oct 2003 01:23:28 -0000 1.17.2.2.2.35
***************
*** 1844,1848 ****
* @param array $principal Principal information for contact,
its depends on $type, but is according which each definition
* @param integer $action PHPGW_SQL_RETURN_SQL |
PHPGW_SQL_RUN_SQL depending what we want
! */
function edit_contact($cid, $principal,
$action=PHPGW_SQL_RETURN_SQL)
{
--- 1844,1848 ----
* @param array $principal Principal information for contact,
its depends on $type, but is according which each definition
* @param integer $action PHPGW_SQL_RETURN_SQL |
PHPGW_SQL_RUN_SQL depending what we want
! */
function edit_contact($cid, $principal,
$action=PHPGW_SQL_RETURN_SQL)
{
***************
*** 2328,2344 ****
* @param string $type Contact type
*/
! function delete($cid, $type='', $action=PHPGW_SQL_RUN_SQL)
{
! $type_id = ($type)? $type :
$this->get_type_contact($cid);
! if ($this->search_contact_type_id($type_id) ==
$this->_contact_person)
! {
! $type = 'person';
! }
! else
! {
! $type = 'org';
! }
!
! //$type = ($this->search_contact_type_id($type) ==
$this->_contact_person)? 'person' : 'org';
if(empty($entity_keys))
--- 2328,2335 ----
* @param string $type Contact type
*/
! function delete($cid, $contact_type='', $transaction=True)
{
! $type = ($contact_type)? $contact_type :
$this->search_contact_type_id($this->get_type_contact($cid));
! $type = ($type == $this->_contact_person) ? 'person' :
'org';
if(empty($entity_keys))
***************
*** 2354,2365 ****
'comm_contact_id');
}
! $this->transaction_begin();
foreach ($entity_keys as $key)
{
! $this->_delete(sql_criteria::_equal($key,
$cid), $action);
}
- $this->transaction_end();
! if ($type == 'person')
{
$this->finalize_delete($cid);
--- 2345,2362 ----
'comm_contact_id');
}
! if($transaction)
! {
! $this->transaction_begin();
! }
foreach ($entity_keys as $key)
{
! $this->_delete(sql_criteria::_equal($key,
$cid), PHPGW_SQL_RUN_SQL);
! }
! if($transaction)
! {
! $this->transaction_end();
}
! if ($contact_type == $this->_contact_person)
{
$this->finalize_delete($cid);
***************
*** 2375,2381 ****
* @param integer $action PHPGW_SQL_RETURN_SQL |
PHPGW_SQL_RUN_SQL
*/
! function delete_contact($cid, $type='',
$action=PHPGW_SQL_RUN_SQL)
{
! $type = ($type)? $type : $this->get_type_contact($cid);
if ($action == PHPGW_SQL_RUN_SQL)
{
--- 2372,2379 ----
* @param integer $action PHPGW_SQL_RETURN_SQL |
PHPGW_SQL_RUN_SQL
*/
! function delete_contact($cid, $contact_type='',
$action=PHPGW_SQL_RUN_SQL)
{
! $type = ($contact_type)? $contact_type :
$this->search_contact_type_id($this->get_type_contact($cid));
! $type = ($type == $this->_contact_person) ? 'person' :
'org';
if ($action == PHPGW_SQL_RUN_SQL)
{
***************
*** 3137,3145 ****
* @return integer Id of the new contact
*/
! function copy_contact($contact_id, $type='')
{
! $type = ($type)? $type :
$this->get_type_contact($contact_id);
! $copy_type = $this->search_contact_type_id($type);
!
$get_data_type= 'get_principal_' . $copy_type . '_data';
--- 3135,3143 ----
* @return integer Id of the new contact
*/
! function copy_contact($contact_id, $contact_type='')
{
! $type = ($contact_type)? $contact_type :
$this->search_contact_type_id($this->get_type_contact($cid));
! $copy_type = ($type == $this->_contact_person) ?
'person' : 'org';
!
$get_data_type= 'get_principal_' . $copy_type . '_data';
***************
*** 3432,3436 ****
function LDAPSyncDelete($id)
{
! $result = ldap_search($this->LDAPResource,
$GLOBALS['phpgw_info']['server']['ldap_contact_context'], 'contactID='.$id,
array('dn'));
$count = ldap_get_entries($this->LDAPResource, $result);
if ((int)$count['count'] > 0)
--- 3430,3434 ----
function LDAPSyncDelete($id)
{
! $result = ldap_search($this->LDAPResource,
$GLOBALS['phpgw_info']['server']['ldap_contact_context'],
'employeeNumber='.$id, array('dn'));
$count = ldap_get_entries($this->LDAPResource, $result);
if ((int)$count['count'] > 0)
***************
*** 3447,3451 ****
$time = gettimeofday();
! $uid =
time().$time['usec'].':'.$person[0]['per_full_name'];
$dn = 'uid=' . $uid.',' .
$GLOBALS['phpgw_info']['server']['ldap_contact_context'];
--- 3445,3450 ----
$time = gettimeofday();
! //$uid =
time().$time['usec'].':'.$person[0]['per_full_name'];
! $uid =
$person[0]['contact_id'].':'.$person[0]['per_full_name'];
$dn = 'uid=' . $uid.',' .
$GLOBALS['phpgw_info']['server']['ldap_contact_context'];
Index: class.accounts_ldap.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.accounts_ldap.inc.php,v
retrieving revision 1.101.2.13.2.7
retrieving revision 1.101.2.13.2.8
diff -C2 -d -r1.101.2.13.2.7 -r1.101.2.13.2.8
*** class.accounts_ldap.inc.php 30 Oct 2003 02:47:53 -0000 1.101.2.13.2.7
--- class.accounts_ldap.inc.php 31 Oct 2003 01:23:27 -0000 1.101.2.13.2.8
***************
*** 110,113 ****
--- 110,117 ----
{
$entry['cn'] =
utf8_encode(sprintf("%s %s", $this->data['firstname'],
$this->data['lastname']));
+ if($this->data['person_id'])
+ {
+ $entry['phpgwpersonid'] =
$this->data['person_id'];
+ }
}
else
***************
*** 223,226 ****
--- 227,234 ----
$entry['loginshell'] =
$this->data['loginshell'];
}
+ if($this->data['person_id'])
+ {
+ $entry['phpgwpersonid']
= $this->data['person_id'];
+ }
}
/* print_r($entry); exit;*/
***************
*** 261,264 ****
--- 269,273 ----
if (!$allValues[0][$key][0])
{
+ print_r($tmpentry);
/* attribute was not in
LDAP, add it */
ldap_mod_add($this->ds,
$allValues[0]['dn'], $tmpentry);
***************
*** 530,534 ****
* @param integer $person_id The person_id to search
*/
! function search_person($person_id)
{
static $person_list;
--- 539,543 ----
* @param integer $person_id The person_id to search
*/
! function search_person($person_id)
{
static $person_list;
***************
*** 743,746 ****
--- 752,756 ----
$tmpentry['phpgwaccounttype'] =
$account_info['account_type'];
$tmpentry['phpgwaccountexpires'] =
$account_info['account_expires'];
+ $tmpentry['phpgwpersonid'] =
$account_info['person_id'];
}
ldap_modify($this->ds, $allValues[0]['dn'],
$tmpentry);
***************
*** 941,944 ****
--- 951,984 ----
return $allValues[0]['dn'];
+ }
+
+ function get_account_with_contact()
+ {
+ $sri = ldap_search($this->ds, $this->user_context,
"(&(phpgwaccounttype=u)(phpgwpersonid=*))", array('uidnumber',
'phpgwpersonid'));
+ $allValues = ldap_get_entries($this->ds, $sri);
+ if(is_array($allValues))
+ {
+ foreach($allValues as $value)
+ {
+ $accounts[$value['uidnumber'][0]] =
$value['phpgwpersonid'][0];
+ }
+ }
+
+ return $accounts;
+ }
+
+ function get_account_without_contact()
+ {
+ $sri = ldap_search($this->ds, $this->user_context,
"(&(phpgwaccounttype=u)(!(phpgwpersonid=*)))", array('uidnumber'));
+ $allValues = ldap_get_entries($this->ds, $sri);
+ if(is_array($allValues))
+ {
+ foreach($allValues as $value)
+ {
+ $accounts[] = $value['uidnumber'][0];
+ }
+ }
+
+ return $accounts;
}
}
Index: class.accounts_shared.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.accounts_shared.inc.php,v
retrieving revision 1.48.2.2.2.20
retrieving revision 1.48.2.2.2.21
diff -C2 -d -r1.48.2.2.2.20 -r1.48.2.2.2.21
*** class.accounts_shared.inc.php 28 Oct 2003 13:45:00 -0000
1.48.2.2.2.20
--- class.accounts_shared.inc.php 31 Oct 2003 01:23:28 -0000
1.48.2.2.2.21
***************
*** 130,133 ****
--- 130,158 ----
}
+ function sync_accounts_contacts()
+ {
+ $accounts = $this->get_account_without_contact();
+ if(is_array($accounts))
+ {
+ $contacts = CreateObject('phpgwapi.contacts');
+
+ foreach($accounts as $account)
+ {
+
//$this->get_account_name($account,$lid,$fname,$lname);
+ $this->account_id = $account;
+ $user_account =
$this->read_repository();
+ $principal = array('per_prefix' =>
$user_account['account_lid'],
+ 'per_first_name' =>
$user_account['firstname'],
+ 'per_last_name' =>
$user_account['lastname'],
+ 'access' =>
'public',
+ 'owner' =>
$GLOBALS['phpgw_info']['server']['addressmaster']);
+ $contact_type =
$contacts->search_contact_type('Persons');
+ $user_account['person_id'] =
$contacts->add_contact($contact_type, $principal);
+ $this->update_data($user_account);
+ $this->save_repository();
+ }
+ }
+ }
+
function is_expired()
{
Index: class.accounts_sql.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.accounts_sql.inc.php,v
retrieving revision 1.80.2.8.2.17
retrieving revision 1.80.2.8.2.18
diff -C2 -d -r1.80.2.8.2.17 -r1.80.2.8.2.18
*** class.accounts_sql.inc.php 28 Oct 2003 06:46:18 -0000 1.80.2.8.2.17
--- class.accounts_sql.inc.php 31 Oct 2003 01:23:28 -0000 1.80.2.8.2.18
***************
*** 506,509 ****
--- 506,532 ----
return $data;
}
+
+ function get_account_with_contact()
+ {
+ $sql = 'SELECT account_id, person_id from
phpgw_accounts where person_id is not null;';
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ $accounts[$this->db->f('account_id')] =
$this->db->f('person_id');
+ }
+ return $accounts;
+ }
+
+ function get_account_without_contact()
+ {
+ {
+ $sql = 'SELECT account_id from phpgw_accounts where
person_id is null;';
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ $accounts[] = $this->db->f('account_id');
+ }
+ return $accounts;
+ }
}
/*!
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] phpgwapi/inc class.accounts_ldap.inc.php, 1.101.2.13.2.7, 1.101.2.13.2.8 class.accounts_shared.inc.php, 1.48.2.2.2.20, 1.48.2.2.2.21 class.accounts_sql.inc.php, 1.80.2.8.2.17, 1.80.2.8.2.18 class.contacts_sql.inc.php, 1.17.2.2.2.34, 1.17.2.2.2.35,
Alejandro Borges (lex) <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] setup setup_demo.php,1.30.2.11,1.30.2.12
- Next by Date:
[Phpgroupware-cvs] admin/inc class.uiaccounts.inc.php, 1.23.2.9.2.24, 1.23.2.9.2.25 hook_admin.inc.php, 1.26.2.1.2.7, 1.26.2.1.2.8
- Previous by thread:
[Phpgroupware-cvs] setup setup_demo.php,1.30.2.11,1.30.2.12
- Next by thread:
[Phpgroupware-cvs] admin/inc class.uiaccounts.inc.php, 1.23.2.9.2.24, 1.23.2.9.2.25 hook_admin.inc.php, 1.26.2.1.2.7, 1.26.2.1.2.8
- Index(es):