[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] phpgwapi/inc class.contact_central.inc.php, 1.1.2.5,
From: |
Dave Hall <address@hidden> |
Subject: |
[Phpgroupware-cvs] phpgwapi/inc class.contact_central.inc.php, 1.1.2.5, 1.1.2.6 class.contact_org.inc.php, 1.1.2.5, 1.1.2.6 class.contact_org_person.inc.php, 1.1.2.6, 1.1.2.7 class.contact_person.inc.php, 1.1.2.8, 1.1.2.9 class.contacts_sql.inc.php, 1.17.2.2.2.22, 1.17.2.2.2.23 class.sql_builder.inc.php, 1.1.2.12, 1.1.2.13 |
Date: |
Thu, 16 Oct 2003 06:31:31 +0000 |
Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv32474
Modified Files:
Tag: Version-0_9_16-branch
class.contact_central.inc.php class.contact_org.inc.php
class.contact_org_person.inc.php class.contact_person.inc.php
class.contacts_sql.inc.php class.sql_builder.inc.php
Log Message:
fix for 5951 from eald
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.22
retrieving revision 1.17.2.2.2.23
diff -C2 -d -r1.17.2.2.2.22 -r1.17.2.2.2.23
*** class.contacts_sql.inc.php 14 Oct 2003 10:36:34 -0000 1.17.2.2.2.22
--- class.contacts_sql.inc.php 16 Oct 2003 06:31:29 -0000 1.17.2.2.2.23
***************
*** 266,270 ****
'count_contacts' =>
array('phpgwapi.contact_central', '0'),
'sel_cat_id' =>
array('phpgwapi.contact_central', '0'),
!
'org_id' =>
array('phpgwapi.contact_org', '1'),
'org_name' =>
array('phpgwapi.contact_org', '1'),
--- 266,272 ----
'count_contacts' =>
array('phpgwapi.contact_central', '0'),
'sel_cat_id' =>
array('phpgwapi.contact_central', '0'),
! 'organizations_contact'=>
array('phpgwapi.contact_central', '0'),
! 'people_contact' =>
array('phpgwapi.contact_central', '0'),
!
'org_id' =>
array('phpgwapi.contact_org', '1'),
'org_name' =>
array('phpgwapi.contact_org', '1'),
***************
*** 277,281 ****
'name' =>
array('phpgwapi.contact_org', '1'),
'count_orgs' =>
array('phpgwapi.contact_org', '1'),
! 'organizations' =>
array('phpgwapi.contact_org', '1', array('organizations_person',
'organizations_org_person')),
'people_org' =>
array('phpgwapi.contact_org', '1', '', 3),
--- 279,284 ----
'name' =>
array('phpgwapi.contact_org', '1'),
'count_orgs' =>
array('phpgwapi.contact_org', '1'),
! 'organizations' =>
array('phpgwapi.contact_org', '1', array('organizations_person',
'organizations_org_person', 'organizations_contact')),
! 'orgs_local' =>
array('phpgwapi.contact_org', '1'),
'people_org' =>
array('phpgwapi.contact_org', '1', '', 3),
***************
*** 301,305 ****
'account_id' =>
array('phpgwapi.contact_person', '1'),
'count_persons' =>
array('phpgwapi.contact_person', '1'),
! 'people' =>
array('phpgwapi.contact_person', '1', array('people_org', 'people_org_person')),
'organizations_person' =>
array('phpgwapi.contact_person', '1', '', 3),
--- 304,309 ----
'account_id' =>
array('phpgwapi.contact_person', '1'),
'count_persons' =>
array('phpgwapi.contact_person', '1'),
! 'people' =>
array('phpgwapi.contact_person', '1', array('people_org', 'people_org_person',
'people_contact')),
! 'people_local' =>
array('phpgwapi.contact_person', '1'),
'organizations_person' =>
array('phpgwapi.contact_person', '1', '', 3),
***************
*** 536,539 ****
--- 540,550 ----
$this->save_sessiondata();
}
+
+ if ($GLOBALS['phpgw_info']['server']['ldap_host'])
+ {
+ $this->LDAPSyncEnabled = true;
+ $this->LDAPResource =
ldap_connect($GLOBALS['phpgw_info']['server']['ldap_host']);
+
ldap_bind($this->LDAPResource,$GLOBALS['phpgw_info']['server']['ldap_root_dn'],
$GLOBALS['phpgw_info']['server']['ldap_root_pw']);
+ }
}
***************
*** 1033,1041 ****
$data = array('my_org_id',
'my_addr_id',
! 'my_preferred');
$this->request($data);
$this->criteria(array('my_person_id' => $person_id));
! $this->criteria($criteria);
return $this->get_query($action, __LINE__, __FILE__);
}
--- 1044,1057 ----
$data = array('my_org_id',
'my_addr_id',
! 'my_preferred',
! 'org_name',
! 'people');
$this->request($data);
$this->criteria(array('my_person_id' => $person_id));
! if (!empty($criteria))
! {
! $this->criteria($criteria);
! }
return $this->get_query($action, __LINE__, __FILE__);
}
***************
*** 1118,1121 ****
--- 1134,1138 ----
'cat_id',
'org_name');
+ $this->request($data);
$this->criteria(array('contact_id' => $contact_id));
return $this->get_query($action, __LINE__, __FILE__);
***************
*** 1840,1843 ****
--- 1857,1861 ----
$execute =
$this->_add($principal,'person','person_id',$cid, $action);
$this->unlock_table();
+ $this->finalize_add($cid);
return $execute;
}
***************
*** 2030,2033 ****
--- 2048,2057 ----
}
$this->transaction_end();
+
+ if ($type == 'person')
+ {
+ $this->finalize_delete($cid);
+ }
+
}
***************
*** 2579,2583 ****
function get_orgs_by_person($person_id)
{
! return $this->get_organizations_by_person($person_id,
array('my_org_id','org_name'));
}
--- 2603,2607 ----
function get_orgs_by_person($person_id)
{
! return $this->get_organizations_by_person($person_id);
}
***************
*** 3058,3061 ****
--- 3082,3277 ----
{
return $GLOBALS['phpgw_info']['user']['account_id'];
+ }
+
+ function finalize_add($id)
+ {
+ $this->finalize_edit($id);
+ }
+
+ function finalize_edit($id)
+ {
+ if ($this->LDAPSyncEnabled)
+ {
+ $this->LDAPSync($id);
+ }
+ }
+
+ function finalize_delete($id)
+ {
+ if ($this->LDAPSyncEnabled)
+ {
+ $this->LDAPSyncDelete($id);
+ }
+ }
+
+ function LDAPSyncDelete($id)
+ {
+ $result = ldap_search($this->LDAPResource,
$GLOBALS['phpgw_info']['server']['ldap_context'], 'contactID='.$id,
array('dn'));
+ $count = ldap_get_entries($this->LDAPResource, $result);
+ if ((int)$count['count'] > 0)
+ {
+
ldap_delete($this->LDAPResource,$count[0]['dn']);
+ }
+ }
+
+ function LDAPSync($id)
+ {
+ $this->LDAPSyncDelete($id);
+
+ $person = $this->get_persons(array('person_id',
+
'per_first_name',
+
'per_last_name',
+
//'fn', //'CONCAT( IFNULL( CONCAT(first_name," "),
""),last_name)'
+
'per_initials',
+
'per_title',
+
'per_department',
+
'per_pubkey'
+
),
+
'','','','','',
+
array('contact_id', $id, 'equal')
+
);
+
+ $attributes = array();
+ $attributes['objectclass'][] = 'inetorgperson';
+ $attributes['objectclass'][] = 'phpgwcontact';
+
+ $attributes['sn'][] =
utf8_encode($person[0]['per_last_name']);
+ $attributes['contactID'][] =
utf8_encode($person[0]['person_id']);
+
+ $attributes['cn'][] =
utf8_encode($person[0]['per_last_name']);
+ //$attributes['displayname'][] =
utf8_encode($person[0]['fn']);
+
+ $dn =
'cn='.$attributes['sn'][0].':'.time().','.$GLOBALS['phpgw_info']['server']['ldap_context'];
+
+ if ($person[0]['per_first_name'])
+ {
+ $attributes['givenname'][] =
utf8_encode($person[0]['per_first_name']);
+ }
+
+ if ($person[0]['per_initials'])
+ {
+ $attributes['initials'][] =
utf8_encode($person[0]['per_initials']);
+ }
+
+ if ($person[0]['per_title'])
+ {
+ $attributes['title'][] =
utf8_encode($person[0]['per_title']);
+ }
+
+ if ($person[0]['per_department'])
+ {
+ $attributes['ou'][] =
utf8_encode($person[0]['per_department']);
+ }
+
+ if ($person[0]['per_pubkey'])
+ {
+ $attributes['userPKCS12'][] =
utf8_encode($person[0]['per_pubkey']);
+ }
+
+ $address = $this->get_addr_contact_data($id,
array('addr_pref_val'=>'Y'));
+
+ for ($i = 0; $i < count ($address); $i++)
+ {
+ if ($address[$i]['addr_contact_id'] == $id &&
$address[$i]['addr_preferred'] == 'Y')
+ {
+ if ($address[$i]['addr_add1'])
+ {
+ $attributes['postaladdress'][]
= utf8_encode($address[$i]['addr_add1']);
+ }
+
+ if ($address[$i]['addr_add2'])
+ {
+ $attributes['postaladdress'][]
= utf8_encode($address[$i]['addr_add2']);
+ }
+
+ if ($address[$i]['addr_city'])
+ {
+ $attributes['l'][] =
utf8_encode($address[$i]['addr_city']);
+ }
+
+ if ($address[$i]['addr_state'])
+ {
+ $attributes['st'][] =
utf8_encode($address[$i]['addr_state']);
+ }
+
+ if ($address[$i]['addr_postal_code'])
+ {
+ $attributes['postalcode'][] =
utf8_encode($address[$i]['addr_postal_code']);
+ }
+
+ if ($address[$i]['addr_country'])
+ {
+ $attributes['c'][] =
utf8_encode($address[$i]['addr_country']);
+ if (!in_array('country',
$attributes['objectclass']))
+ {
+
$attributes['objectclass'][] = 'country';
+ }
+ }
+ }
+ }
+
+ $db2LDAP_map['home email'] = 'mail';
+ $db2LDAP_map['work email'] = 'mail';
+ $db2LDAP_map['home phone'] = 'homePhone';
+ $db2LDAP_map['work phone'] = 'telephoneNumber';
+ $db2LDAP_map['pager'] = 'pager';
+ $db2LDAP_map['isdn'] =
'internationaliSDNNumber';
+ $db2LDAP_map['home fax'] =
'facsimileTelephoneNumber';
+ $db2LDAP_map['work fax'] =
'facsimileTelephoneNumber';
+ $db2LDAP_map['mobile (cell) phone'] = 'mobile';
+ $db2LDAP_map['car phone'] = 'telephoneNumber';
+ $db2LDAP_map['website'] = 'labeledURI';
+
+
+ $comms = $this->get_comm_contact_data($id, '');
+ for ($i=0; $i < count($comms); $i++)
+ {
+ $key =
$db2LDAP_map[$comms[$i]['comm_description']];
+ if ($comms[$i]['comm_data'] && $key)
+ {
+ if ($comms[$i]['comm_preferred'] == 'Y'
&& count($attributes[$key]) > 0)
+ {
+
array_unshift($attributes[$key], utf8_encode($comms[$i]['comm_data']));
+ }
+ else
+ {
+ $attributes[$key][] =
utf8_encode($comms[$i]['comm_data']);
+ }
+ }
+ }
+
+ $orgs = $this->get_organizations_by_person($id);
+
+ /* Workaround */
+ for ($i=0; $i < count($orgs); $i++)
+ {
+ $orgName = $this->get_orgs(array('org_name'),
'', '', '', '', '', sql_criteria::_equal('org_id', $orgs[$i]['my_org_id']));
+ $orgName = $orgName[0]['org_name'];
+ $orgs[$i]['org_name'] = $orgName;
+ }
+ /* Workaround End */
+
+ for ($i=0; $i < count($orgs); $i++)
+ {
+ if ($orgs[$i]['org_name'])
+ {
+ if ($orgs[$i]['my_preferred'] == 'Y' &&
count($attributes['o']) > 0)
+ {
+ array_unshift($attributes['o'],
utf8_encode($orgs[$i]['org_name']));
+ }
+ else
+ {
+ $attributes['o'][] =
utf8_encode($orgs[$i]['org_name']);
+ }
+ }
+ }
+
+ //echo "<pre>";
+ //print_r($attributes);
+ //echo "</pre>";
+
+ ldap_add($this->LDAPResource, $dn, $attributes);
+ //ldap_close($this->LDAPResource);
+ //die('debug');
}
}
Index: class.contact_central.inc.php
===================================================================
RCS file:
/cvsroot/phpgroupware/phpgwapi/inc/Attic/class.contact_central.inc.php,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** class.contact_central.inc.php 14 Oct 2003 10:36:34 -0000 1.1.2.5
--- class.contact_central.inc.php 16 Oct 2003 06:31:29 -0000 1.1.2.6
***************
*** 52,56 ****
'sort' => '',
'field' =>
'cat_id'),
! 'count_contacts'=> array('select' => '',
'criteria' => '',
'insert' => '',
--- 52,56 ----
'sort' => '',
'field' =>
'cat_id'),
! 'count_contacts'=> array('select' => '',
'criteria' => '',
'insert' => '',
***************
*** 58,62 ****
'delete' => '',
'sort' => '',
! 'field' => ''));
--- 58,64 ----
'delete' => '',
'sort' => '',
! 'field' => ''),
! 'people_contact'=> array('select' =>
'unlink_org'),
! 'organizations_contact' => array('select' =>
'unlink_org'));
***************
*** 84,87 ****
--- 86,99 ----
// $this->set_ilinks('owner',
'phpgwapi.contact_accounts','account_id');
//$this->set_ilinks('cat_id',
'contact_categories','key_cat_id');
+ }
+
+ function unlink_org()
+ {
+ unset($this->elink['phpgwapi.contact_org']);
+ }
+
+ function unlink_person()
+ {
+ unset($this->elink['phpgwapi.contact_person']);
}
Index: class.contact_org_person.inc.php
===================================================================
RCS file:
/cvsroot/phpgroupware/phpgwapi/inc/Attic/class.contact_org_person.inc.php,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -C2 -d -r1.1.2.6 -r1.1.2.7
*** class.contact_org_person.inc.php 9 Oct 2003 00:25:20 -0000 1.1.2.6
--- class.contact_org_person.inc.php 16 Oct 2003 06:31:29 -0000 1.1.2.7
***************
*** 67,70 ****
--- 67,72 ----
$this->add_criteria($criteria);
}
+ $this->set_elinks('my_org_id',
'phpgwapi.contact_org','org_id');
+ $this->set_elinks('my_person_id',
'phpgwapi.contact_person','person_id');
}
***************
*** 72,76 ****
function relink_person()
{
! $this->set_elinks('my_org_id',
'phpgwapi.contact_org','org_id');
$this->set_ilinks('my_person_id',
'phpgwapi.contact_person','person_id', PHPGW_SQL_LAZY_KEY);
}
--- 74,78 ----
function relink_person()
{
! unset($thsi->elink['phpgwapi.contact_person']);
$this->set_ilinks('my_person_id',
'phpgwapi.contact_person','person_id', PHPGW_SQL_LAZY_KEY);
}
***************
*** 79,83 ****
function relink_org()
{
! $this->set_elinks('my_person_id',
'phpgwapi.contact_person','person_id');
$this->set_ilinks('my_org_id',
'phpgwapi.contact_org','org_id', PHPGW_SQL_LAZY_KEY);
}
--- 81,85 ----
function relink_org()
{
! unset($thsi->elink['phpgwapi.contact_org']);
$this->set_ilinks('my_org_id',
'phpgwapi.contact_org','org_id', PHPGW_SQL_LAZY_KEY);
}
***************
*** 88,91 ****
--- 90,94 ----
$new_criteria = sql_criteria::equal($field,
$element['value']);
$this->_add_criteria($new_criteria);
+ $this->relink_person();
}
***************
*** 95,98 ****
--- 98,102 ----
$new_criteria = sql_criteria::equal($field,
$element['value']);
$this->_add_criteria($new_criteria);
+ $this->relink_org();
}
Index: class.contact_person.inc.php
===================================================================
RCS file:
/cvsroot/phpgroupware/phpgwapi/inc/Attic/class.contact_person.inc.php,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -C2 -d -r1.1.2.8 -r1.1.2.9
*** class.contact_person.inc.php 14 Oct 2003 06:24:57 -0000 1.1.2.8
--- class.contact_person.inc.php 16 Oct 2003 06:31:29 -0000 1.1.2.9
***************
*** 257,261 ****
'field'
=> 'person_id'),
'organizations_person' => array('select'
=> 'unlink_person'),
! 'people' => array('select'
=> 'relink_org_person'));
function contact_person ($ali = '', $field = '', $criteria =
'')
--- 257,262 ----
'field'
=> 'person_id'),
'organizations_person' => array('select'
=> 'unlink_person'),
! 'people' => array('select'
=> 'relink_org_person'),
! 'people_local' => array('select'
=> 'relink_org_person'));
function contact_person ($ali = '', $field = '', $criteria =
'')
***************
*** 275,278 ****
--- 276,292 ----
}
+ // When we want organizations
+ function unlink_person()
+ {
+ unset($this->ilink['phpgwapi.contact_central']);
+ }
+
+ // When we want people
+ function relink_org_person()
+ {
+ unset($this->ilink['phpgwapi.contact_org_person']);
+ $this->set_elinks('person_id',
'phpgwapi.contact_org_person','my_person_id');
+ }
+
function criteria_person_id($element)
{
***************
*** 293,308 ****
}
- // When we want organizations
- function unlink_person()
- {
- unset($this->ilink['phpgwapi.contact_central']);
- }
-
- // When we want people
- function relink_org_person()
- {
- unset($this->ilink['phpgwapi.contact_org_person']);
- $this->set_elinks('person_id',
'phpgwapi.contact_org_person','my_person_id');
- }
}
?>
--- 307,310 ----
Index: class.sql_builder.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/Attic/class.sql_builder.inc.php,v
retrieving revision 1.1.2.12
retrieving revision 1.1.2.13
diff -C2 -d -r1.1.2.12 -r1.1.2.13
*** class.sql_builder.inc.php 14 Oct 2003 10:36:34 -0000 1.1.2.12
--- class.sql_builder.inc.php 16 Oct 2003 06:31:29 -0000 1.1.2.13
***************
*** 1196,1200 ****
// ($myfoo == 'add_path')) xor
// ($myfoo == ''))
! // if ($myfoo != 'get_join')
// {
return;
--- 1196,1200 ----
// ($myfoo == 'add_path')) xor
// ($myfoo == ''))
! // if ($myfoo != 'get_sql')
// {
return;
Index: class.contact_org.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/Attic/class.contact_org.inc.php,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** class.contact_org.inc.php 9 Oct 2003 00:25:20 -0000 1.1.2.5
--- class.contact_org.inc.php 16 Oct 2003 06:31:29 -0000 1.1.2.6
***************
*** 84,88 ****
'field' => ''),
'people_org' => array('select' =>
'unlink_org'),
! 'organizations'=> array('select' =>
'relink_org_person'));
function contact_org ($ali = '', $field = '', $criteria =
'')
--- 84,89 ----
'field' => ''),
'people_org' => array('select' =>
'unlink_org'),
! 'organizations'=> array('select' =>
'relink_org_person'),
! 'orgs_local' => array('select' =>
'relink_org_person'));
function contact_org ($ali = '', $field = '', $criteria =
'')
***************
*** 101,104 ****
--- 102,118 ----
}
+ // From people_org, when we want people
+ function unlink_org()
+ {
+ unset($this->ilink['phpgwapi.contact_central']);
+ }
+
+ // Run when ask organizations
+ function relink_org_person()
+ {
+ unset($this->ilink['phpgwapi.contact_org_person']);
+ $this->set_elinks('org_id',
'phpgwapi.contact_org_person', 'my_org_id');
+ }
+
function criteria_org_id($element)
{
***************
*** 119,134 ****
}
- // From people_org, when we want people
- function unlink_org()
- {
- unset($this->ilink['phpgwapi.contact_central']);
- }
-
- // Run when ask organizations
- function relink_org_person()
- {
- unset($this->ilink['phpgwapi.contact_org_person']);
- $this->set_elinks('org_id',
'phpgwapi.contact_org_person', 'my_org_id');
- }
}
?>
--- 133,136 ----
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] phpgwapi/inc class.contact_central.inc.php, 1.1.2.5, 1.1.2.6 class.contact_org.inc.php, 1.1.2.5, 1.1.2.6 class.contact_org_person.inc.php, 1.1.2.6, 1.1.2.7 class.contact_person.inc.php, 1.1.2.8, 1.1.2.9 class.contacts_sql.inc.php, 1.17.2.2.2.22, 1.17.2.2.2.23 class.sql_builder.inc.php, 1.1.2.12, 1.1.2.13,
Dave Hall <address@hidden> <=