diff --git a/phpgwapi/inc/class.contacts.inc.php b/phpgwapi/inc/class.contacts.inc.php index 5371f0dd86..5f4bf73979 100644 --- a/phpgwapi/inc/class.contacts.inc.php +++ b/phpgwapi/inc/class.contacts.inc.php @@ -6,9 +6,9 @@ * and Bettina Gille * * View and manipulate contact records * * Copyright (C) 2001, 2002 Joseph Engo, Miles Lott, Bettina Gille * - * -------------------------------------------------------------------------* + * ------------------------------------------------------------------------ * * This library is part of the eGroupWare API * - * http://www.egroupware.org * + * http://www.egroupware.org * * ------------------------------------------------------------------------ * * This library is free software; you can redistribute it and/or modify it * * under the terms of the GNU Lesser General Public License as published by * @@ -24,11 +24,11 @@ \**************************************************************************/ /* $Id$ */ - if (!isset($GLOBALS['phpgw_info']['server']['contact_repository'])) + if (!isset($GLOBALS['egw_info']['server']['contact_repository'])) { - $GLOBALS['phpgw_info']['server']['contact_repository'] = 'sql'; + $GLOBALS['egw_info']['server']['contact_repository'] = 'sql'; } - require_once(PHPGW_API_INC . '/class.contacts_'.$GLOBALS['phpgw_info']['server']['contact_repository'] . '.inc.php'); + require_once(EGW_API_INC . '/class.contacts_'.$GLOBALS['egw_info']['server']['contact_repository'] . '.inc.php'); class contacts extends contacts_ { @@ -111,13 +111,13 @@ $fields[$fieldValue]=$fieldValue; } } - + // transform criteria from phpgw to egw structure if(is_array($_criteria)) { foreach($_criteria as $criteriaKey => $criteriaValue) { - if($GLOBALS['phpgw_info']['server']['contact_repository'] == 'ldap') + if($GLOBALS['egw_info']['server']['contact_repository'] == 'ldap') { switch($criteriaKey) { @@ -144,7 +144,7 @@ } } $entries = $this->read($start,$limit,$fields,$criteria,'',$sort,$orderby); - + // transform entries from egw to phpgw structure if(is_array($entries)) { @@ -325,7 +325,7 @@ function formatted_address($id, $business = True, $afont = '', $asize = '2') { - $t = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('addressbook')); + $t = CreateObject('phpgwapi.Template',$GLOBALS['egw']->common->get_tpl_dir('addressbook')); $s = CreateObject('phpgwapi.sbox'); $fields = array( @@ -349,7 +349,7 @@ list($address) = $this->read_single_entry($id,$fields); foreach($address as $k => $val) { - $address[$k] = $GLOBALS['phpgw']->strip_html($val); + $address[$k] = $GLOBALS['egw']->strip_html($val); } if ($address['title']) @@ -386,7 +386,7 @@ if (! $country) { - $country = $GLOBALS['phpgw_info']['user']['preferences']['common']['country']; + $country = $GLOBALS['egw_info']['user']['preferences']['common']['country']; } if (file_exists(PHPGW_SERVER_ROOT . SEP . 'addressbook' . SEP . 'templates' . SEP .'default' . SEP . 'format_' . strtolower($country) . '.tpl')) @@ -400,7 +400,7 @@ if (!$afont) { - $afont = $GLOBALS['phpgw_info']['theme']['font']; + $afont = $GLOBALS['egw_info']['theme']['font']; } $a .= $t->set_var('font',$afont); @@ -412,7 +412,7 @@ $a .= $t->set_var('zip',$zip); $a .= $t->set_var('state',$state); - if ($country != $GLOBALS['phpgw_info']['user']['preferences']['common']['country']) + if ($country != $GLOBALS['egw_info']['user']['preferences']['common']['country']) { $countryname = $s->get_full_name($country); $a .= $t->set_var('country',lang($countryname)); @@ -424,7 +424,7 @@ function formatted_address_full($id, $business = True, $afont = '', $asize = '2') { - $t = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('addressbook')); + $t = CreateObject('phpgwapi.Template',$GLOBALS['egw']->common->get_tpl_dir('addressbook')); $s = CreateObject('phpgwapi.sbox'); $fields = array( @@ -454,7 +454,7 @@ list($address) = $this->read_single_entry($id,$fields); foreach($address as $k => $val) { - $address[$k] = $GLOBALS['phpgw']->strip_html($val); + $address[$k] = $GLOBALS['egw']->strip_html($val); } if($address['title']) @@ -495,7 +495,7 @@ if(!$country) { - $country = $GLOBALS['phpgw_info']['user']['preferences']['common']['country']; + $country = $GLOBALS['egw_info']['user']['preferences']['common']['country']; } if(file_exists(PHPGW_SERVER_ROOT . SEP . 'addressbook' . SEP . 'templates' . SEP .'default' . SEP . 'full_format_' . strtolower($country) . '.tpl')) @@ -509,7 +509,7 @@ if(!$afont) { - $afont = $GLOBALS['phpgw_info']['theme']['font']; + $afont = $GLOBALS['egw_info']['theme']['font']; } $a .= $t->set_var('font',$afont); @@ -529,7 +529,7 @@ $a .= $t->set_var('fax',$address['tel_fax']); $a .= $t->set_var('url',$address['url']); - if($country != $GLOBALS['phpgw_info']['user']['preferences']['common']['country']) + if($country != $GLOBALS['egw_info']['user']['preferences']['common']['country']) { $countryname = $s->get_full_name($country); $a .= $t->set_var('country',lang($countryname)); @@ -541,7 +541,7 @@ function formatted_address_line($id, $business = True, $afont = '', $asize = '2') { - $t = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('addressbook')); + $t = CreateObject('phpgwapi.Template',$GLOBALS['egw']->common->get_tpl_dir('addressbook')); $s = CreateObject('phpgwapi.sbox'); $fields = array( @@ -564,7 +564,7 @@ list($address) = $this->read_single_entry($id,$fields); foreach($address as $k => $val) { - $address[$k] = $GLOBALS['phpgw']->strip_html($val); + $address[$k] = $GLOBALS['egw']->strip_html($val); } if($address['title']) @@ -601,7 +601,7 @@ if(!$country) { - $country = $GLOBALS['phpgw_info']['user']['preferences']['common']['country']; + $country = $GLOBALS['egw_info']['user']['preferences']['common']['country']; } if(file_exists(PHPGW_SERVER_ROOT . SEP . 'addressbook' . SEP . 'templates' . SEP .'default' . SEP . 'line_format_' . strtolower($country) . '.tpl')) @@ -615,7 +615,7 @@ if(!$afont) { - $afont = $GLOBALS['phpgw_info']['theme']['font']; + $afont = $GLOBALS['egw_info']['theme']['font']; } $a .= $t->set_var('font',$afont); @@ -626,7 +626,7 @@ $a .= $t->set_var('zip',$zip); $a .= $t->set_var('state',$state); - if($country != $GLOBALS['phpgw_info']['user']['preferences']['common']['country']) + if($country != $GLOBALS['egw_info']['user']['preferences']['common']['country']) { $countryname = $s->get_full_name($country); $a .= $t->set_var('country',' ° ' . lang($countryname)); diff --git a/phpgwapi/inc/class.contacts_ldap.inc.php b/phpgwapi/inc/class.contacts_ldap.inc.php index 8736899a8e..8e9524ec31 100644 --- a/phpgwapi/inc/class.contacts_ldap.inc.php +++ b/phpgwapi/inc/class.contacts_ldap.inc.php @@ -144,14 +144,14 @@ function contacts_() { - $this->db = $GLOBALS['phpgw']->db; - $this->ldap = $GLOBALS['phpgw']->common->ldapConnect( - $GLOBALS['phpgw_info']['server']['ldap_contact_host'], - $GLOBALS['phpgw_info']['server']['ldap_contact_dn'], - $GLOBALS['phpgw_info']['server']['ldap_contact_pw'] + $this->db = clone($GLOBALS['egw']->db); + $this->ldap = $GLOBALS['egw']->common->ldapConnect( + $GLOBALS['egw_info']['server']['ldap_contact_host'], + $GLOBALS['egw_info']['server']['ldap_contact_dn'], + $GLOBALS['egw_info']['server']['ldap_contact_pw'] ); - $this->account_id = $GLOBALS['phpgw_info']['user']['account_id']; - $this->grants = $GLOBALS['phpgw']->acl->get_grants('addressbook'); + $this->account_id = $GLOBALS['egw_info']['user']['account_id']; + $this->grants = $GLOBALS['egw']->acl->get_grants('addressbook'); /* Used to flag an address as being: domestic OR international(default) @@ -185,7 +185,7 @@ } } - $sri = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_contact_context'], 'uidnumber=' . (int)$id); + $sri = ldap_search($this->ldap, $GLOBALS['egw_info']['server']['ldap_contact_context'], 'uidnumber=' . (int)$id); $ldap_fields = ldap_get_entries($this->ldap, $sri); $return_fields[0]['id'] = $ldap_fields[0]['uidnumber'][0]; @@ -199,7 +199,7 @@ { foreach($stock_fieldnames as $name => $value) { - $return_fields[0][$name] = $GLOBALS['phpgw']->translation->convert(($ldap_fields[0][$value][0]),'utf-8'); + $return_fields[0][$name] = $GLOBALS['egw']->translation->convert(($ldap_fields[0][$value][0]),'utf-8'); } } @@ -262,7 +262,7 @@ $id = 1; } - $sri = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_contact_context'], 'uidnumber=' . (int)$id); + $sri = ldap_search($this->ldap, $GLOBALS['egw_info']['server']['ldap_contact_context'], 'uidnumber=' . (int)$id); $ldap_fields = ldap_get_entries($this->ldap, $sri); $return_fields[0]['id'] = $ldap_fields[0]['uidnumber'][0]; @@ -277,7 +277,7 @@ { foreach($stock_fieldnames as $name => $value) { - $return_fields[0][$name] = $GLOBALS['phpgw']->translation->convert(($ldap_fields[0][$value][0]),'utf-8'); + $return_fields[0][$name] = $GLOBALS['egw']->translation->convert(($ldap_fields[0][$value][0]),'utf-8'); } } @@ -427,7 +427,7 @@ if(is_array($query)) { // must be fixed somehow Milosch???? - $myfilter = $this->makefilter($filterfields,$GLOBALS['phpgw']->common->ldap_addslashes($query),'',$DEBUG); + $myfilter = $this->makefilter($filterfields,$GLOBALS['egw']->common->ldap_addslashes($query),'',$DEBUG); } else { @@ -440,16 +440,16 @@ 'org_name' => 'o', 'org_unit' => 'ou' ); - $myfilter = $this->makefilter($filterfields,$search_filter,$GLOBALS['phpgw']->common->ldap_addslashes($query),$DEBUG); + $myfilter = $this->makefilter($filterfields,$search_filter,$GLOBALS['egw']->common->ldap_addslashes($query),$DEBUG); } } else { $myfilter = $this->makefilter($filterfields,'','',$DEBUG); } - $myfilter = $GLOBALS['phpgw']->translation->convert($myfilter,$GLOBALS['phpgw']->translation->system_charset,'utf-8'); + $myfilter = $GLOBALS['egw']->translation->convert($myfilter,$GLOBALS['egw']->translation->system_charset,'utf-8'); - $sri = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_contact_context'], $myfilter); + $sri = ldap_search($this->ldap, $GLOBALS['egw_info']['server']['ldap_contact_context'], $myfilter); $ldap_fields = ldap_get_entries($this->ldap, $sri); /* _debug_array($ldap_fields);exit; */ @@ -511,7 +511,7 @@ { foreach($stock_fieldnames as $f_name => $f_value) { - $return_fields[$j][$f_name] = $GLOBALS['phpgw']->translation->convert(($ldap_fields[$i][$f_value][0]),'utf-8'); + $return_fields[$j][$f_name] = $GLOBALS['egw']->translation->convert(($ldap_fields[$i][$f_value][0]),'utf-8'); } } $this->db->query("SELECT contact_name,contact_value FROM $this->ext_table WHERE contact_id='" @@ -609,11 +609,11 @@ /* exact value (filtering based on tid, etc...) */ if($name == 'phpgwcontactcatid') { - if (!is_object($GLOBALS['phpgw']->categories)) + if (!is_object($GLOBALS['egw']->categories)) { - $GLOBALS['phpgw']->categories = CreateObject('phpgwapi.categories'); + $GLOBALS['egw']->categories = CreateObject('phpgwapi.categories'); } - $cats = $GLOBALS['phpgw']->categories->return_all_children((int)$value); + $cats = $GLOBALS['egw']->categories->return_all_children((int)$value); $aquery .= '(|'; foreach($cats as $cat) @@ -658,7 +658,7 @@ echo '
AND query: "' . $aquery . '"'; echo '
OR query: "' . $oquery . '"'; echo '
Full query: "' . $fquery . '"'; - echo '
Will search in "' . $GLOBALS['phpgw_info']['server']['ldap_contact_context'] . '"'; + echo '
Will search in "' . $GLOBALS['egw_info']['server']['ldap_contact_context'] . '"'; } // echo $fquery; @@ -680,7 +680,7 @@ $fields['tid'] = 'n'; } - if(!$GLOBALS['phpgw_info']['server']['ldap_contact_context']) + if(!$GLOBALS['egw_info']['server']['ldap_contact_context']) { return False; } @@ -688,16 +688,16 @@ list($stock_fields,$stock_fieldnames,$extra_fields) = $this->split_stock_and_extras($fields); $free = 0; - $this->nextid = $GLOBALS['phpgw']->common->last_id('contacts'); + $this->nextid = $GLOBALS['egw']->common->last_id('contacts'); /* Loop until we find a free id */ while(!$free) { $ldap_fields = ''; - $sri = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_contact_context'], 'uidnumber='.$this->nextid); + $sri = ldap_search($this->ldap, $GLOBALS['egw_info']['server']['ldap_contact_context'], 'uidnumber='.$this->nextid); $ldap_fields = ldap_get_entries($this->ldap, $sri); if($ldap_fields[0]['dn'][0]) { - $this->nextid = $GLOBALS['phpgw']->common->next_id('contacts'); + $this->nextid = $GLOBALS['egw']->common->next_id('contacts'); } else { @@ -712,7 +712,7 @@ { if($stock_fields[$name] != '') { - $ldap_fields[$value] = $GLOBALS['phpgw']->translation->convert($stock_fields[$name],$GLOBALS['phpgw']->translation->system_charset,'utf-8'); + $ldap_fields[$value] = $GLOBALS['egw']->translation->convert($stock_fields[$name],$GLOBALS['egw']->translation->system_charset,'utf-8'); } } } @@ -720,7 +720,7 @@ $time = gettimeofday(); $ldap_fields['uid'] = time().$time['usec'].':'.$ldap_fields['givenname']; - $dn = 'uid=' . $ldap_fields['uid'].',' . $GLOBALS['phpgw_info']['server']['ldap_contact_context']; + $dn = 'uid=' . $ldap_fields['uid'].',' . $GLOBALS['egw_info']['server']['ldap_contact_context']; $ldap_fields['phpgwcontacttypeid'] = $fields['tid']; $ldap_fields['phpgwcontactowner'] = $owner; if(!isset($fields['access'])) @@ -734,7 +734,7 @@ $ldap_fields['objectclass'][0] = 'organizationalPerson'; $ldap_fields['objectclass'][1] = 'inetOrgPerson'; $ldap_fields['objectclass'][2] = 'phpgwContact'; - //$ldap_fields['last_mod'] = $GLOBALS['phpgw']->datetime->gmtnow; + //$ldap_fields['last_mod'] = $GLOBALS['egw']->datetime->gmtnow; $err = $this->validate($ldap_fields); if(@is_array($err) && @isset($err[0])) @@ -847,13 +847,13 @@ } $nonfields = $this->non_contact_fields; - if(!$GLOBALS['phpgw_info']['server']['ldap_contact_context']) + if(!$GLOBALS['egw_info']['server']['ldap_contact_context']) { return False; } /* First make sure that id number exists */ - $sri = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_contact_context'], 'uidnumber=' . (int)$id); + $sri = ldap_search($this->ldap, $GLOBALS['egw_info']['server']['ldap_contact_context'], 'uidnumber=' . (int)$id); $ldap_fields = ldap_get_entries($this->ldap, $sri); if($ldap_fields[0]['dn']) @@ -960,12 +960,12 @@ if($ldap_fields[0][$fvalue] && $stock_fields[$fname] && $ldap_fields[0][$fvalue][0] != $stock_fields[$fname] ) { //echo "
".$fname." => ".$fvalue." was there"; - $err = ldap_modify($this->ldap,$dn,array($fvalue => $GLOBALS['phpgw']->translation->convert($stock_fields[$fname],$GLOBALS['phpgw']->translation->system_charset,'utf-8'))); + $err = ldap_modify($this->ldap,$dn,array($fvalue => $GLOBALS['egw']->translation->convert($stock_fields[$fname],$GLOBALS['egw']->translation->system_charset,'utf-8'))); } elseif(!$ldap_fields[0][$fvalue] && $stock_fields[$fname]) { //echo "
".$fname." not there - '".$fvalue."'"; - $err = ldap_mod_add($this->ldap,$dn,array($fvalue => $GLOBALS['phpgw']->translation->convert($stock_fields[$fname],$GLOBALS['phpgw']->translation->system_charset,'utf-8'))); + $err = ldap_mod_add($this->ldap,$dn,array($fvalue => $GLOBALS['egw']->translation->convert($stock_fields[$fname],$GLOBALS['egw']->translation->system_charset,'utf-8'))); } elseif($ldap_fields[0][$fvalue] && !$stock_fields[$fname]) { @@ -981,7 +981,7 @@ } } - //something here to update the last_mod from $GLOBALS['phpgw']->datetime->gmtnow + //something here to update the last_mod from $GLOBALS['egw']->datetime->gmtnow foreach($extra_fields as $x_name => $x_value) { @@ -1018,7 +1018,7 @@ return False; } - $sri = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_contact_context'], 'phpgwcontactowner='.$old_owner); + $sri = ldap_search($this->ldap, $GLOBALS['egw_info']['server']['ldap_contact_context'], 'phpgwcontactowner='.$old_owner); $ldap_fields = ldap_get_entries($this->ldap, $sri); $entry = ''; @@ -1034,12 +1034,12 @@ /* This is where the real work of delete() is done, shared class file contains calling function */ function delete_($id) { - if(!$GLOBALS['phpgw_info']['server']['ldap_contact_context']) + if(!$GLOBALS['egw_info']['server']['ldap_contact_context']) { return False; } - $sri = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_contact_context'], 'uidnumber='.$id); + $sri = ldap_search($this->ldap, $GLOBALS['egw_info']['server']['ldap_contact_context'], 'uidnumber='.$id); $ldap_fields = ldap_get_entries($this->ldap, $sri); if($ldap_fields[0]['dn']) @@ -1058,14 +1058,14 @@ // This is for the admin script deleteaccount.php function delete_all($owner=0) { - if(!$GLOBALS['phpgw_info']['server']['ldap_contact_context']) + if(!$GLOBALS['egw_info']['server']['ldap_contact_context']) { return False; } if($owner) { - $sri = ldap_search($this->ldap, $GLOBALS['phpgw_info']['server']['ldap_contact_context'], 'phpgwcontactowner='.$owner); + $sri = ldap_search($this->ldap, $GLOBALS['egw_info']['server']['ldap_contact_context'], 'phpgwcontactowner='.$owner); $ldap_fields = ldap_get_entries($this->ldap, $sri); $entry = ''; diff --git a/phpgwapi/inc/class.contacts_sql.inc.php b/phpgwapi/inc/class.contacts_sql.inc.php index 5d2a6d6a89..8b21a1afaf 100644 --- a/phpgwapi/inc/class.contacts_sql.inc.php +++ b/phpgwapi/inc/class.contacts_sql.inc.php @@ -22,10 +22,10 @@ * along with this library; if not, write to the Free Software Foundation, * * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * \**************************************************************************/ - + /** - * This class provides a contact database scheme. - * It attempts to be based on the vcard 2.1 standard, with mods as needed + * This class provides a contact database scheme. + * It attempts to be based on the vcard 2.1 standard, with mods as needed * to make for more reasonable sql storage. * Note that changes here must also work in the LDAP version. * Syntax: CreateObject('phpgwapi.contacts'); @@ -35,10 +35,10 @@ * @class contacts_ * @abstract Contact Management System * @author jengo/Milosch - * @version $Revision$ + * @version $Revision$ * @license LGPL */ - + /* $Id$ */ class contacts_ @@ -147,15 +147,14 @@ function contacts_($useacl=True) { -// $this->db = $GLOBALS['phpgw']->db; - copyobj($GLOBALS['phpgw']->db,$this->db); + $this->db = clone($GLOBALS['egw']->db); $this->db->set_app('phpgwapi'); if($useacl) { - $this->grants = $GLOBALS['phpgw']->acl->get_grants('addressbook'); + $this->grants = $GLOBALS['egw']->acl->get_grants('addressbook'); } - $this->account_id = $GLOBALS['phpgw_info']['user']['account_id']; + $this->account_id = $GLOBALS['egw_info']['user']['account_id']; /* Used to flag an address as being: domestic AND/OR international(default) @@ -301,11 +300,11 @@ if (!(int)$value) continue; // nothing to filter //$filterlist[] = "(" . $name . " LIKE '%," . (int)$value . ",%' OR " . $name."='".(int)$value."')"; - if (!is_object($GLOBALS['phpgw']->categories)) + if (!is_object($GLOBALS['egw']->categories)) { - $GLOBALS['phpgw']->categories = CreateObject('phpgwapi.categories'); + $GLOBALS['egw']->categories = CreateObject('phpgwapi.categories'); } - $cats = $GLOBALS['phpgw']->categories->return_all_children((int)$value); + $cats = $GLOBALS['egw']->categories->return_all_children((int)$value); $cat_filter = "(cat_id IN ('".implode("','",$cats)."')"; foreach($cats as $cat) { @@ -602,7 +601,7 @@ //this is added here so it is never tainted $this->stock_contact_fields['last_mod'] = 'last_mod'; - $stock_fields['last_mod'] = $GLOBALS['phpgw']->datetime->gmtnow; + $stock_fields['last_mod'] = $GLOBALS['egw']->datetime->gmtnow; $data = array( 'owner' => $owner, @@ -685,7 +684,7 @@ if (count($stock_fields)) { - $stock_fields['last_mod'] = $GLOBALS['phpgw']->datetime->gmtnow; + $stock_fields['last_mod'] = $GLOBALS['egw']->datetime->gmtnow; $this->db->update($this->std_table,$stock_fields,array('id'=>$id),__LINE__,__FILE__); } if (is_array($extra_fields))