Only in phpgw008: CVS Only in phpgw008: README.NOW-IMPORTANT Only in phpgw008: about.php Only in phpgw008/addressbook: CVS Only in phpgw008/addressbook: admin.php Only in phpgw008/addressbook: csv_import.php Only in phpgw008/addressbook: help Only in phpgw008/addressbook/inc: CVS Only in phpgw008/addressbook/inc: arr.php Only in phpgw008/addressbook/inc: class.addressbook_importer.inc.php Only in phpgw008/addressbook/inc: class.boXport.inc.php Only in phpgw008/addressbook/inc: class.boaddressbook.inc.php Only in phpgw008/addressbook/inc: class.boaddressbook_prefs.inc.php Only in phpgw008/addressbook/inc: class.bocatalog_contact_addr_type.inc.php Only in phpgw008/addressbook/inc: class.bocatalog_contact_comm_descr.inc.php Only in phpgw008/addressbook/inc: class.bocatalog_contact_comm_type.inc.php Only in phpgw008/addressbook/inc: class.bocatalog_contact_note_type.inc.php Only in phpgw008/addressbook/inc: class.catalog_manager.inc.php diff -i -u -r -d phpgw008/addressbook/inc/class.ipc_addressbook.inc.php sync_modul/addressbook/inc/class.ipc_addressbook.inc.php --- phpgw008/addressbook/inc/class.ipc_addressbook.inc.php Mon Jan 3 06:56:06 2005 +++ sync_modul/addressbook/inc/class.ipc_addressbook.inc.php Mon Nov 28 16:52:46 2005 @@ -1,175 +1,371 @@ - * @copyright Copyright (C) 2003 Free Software Foundation http://www.fsf.org/ - * @license http://www.fsf.org/licenses/gpl.html GNU General Public License - * @package phpgwapi - * @subpackage ipc - * @version $Id: class.ipc_addressbook.inc.php,v 1.1.2.2 2004/11/06 16:13:43 powerstat Exp $ + * @author Dirk Schaller + * @copyright Copyright (C) 2003-2004, Free Software Foundation, Inc. http://www.fsf.org/ + * @license http://www.fsf.org/licenses/gpl.html GNU General Public License + * @package phpgwapi + * @subpackage ipc + * @version $Id: class.ipc_addressbook.inc.php,v 1.1.2.1.52.21 2005/07/19 09:29:59 mlinke Exp $ */ - /** * Fassade of the adressbook application. - * - * @package notes + * @package addressbook */ class ipc_addressbook extends ipc_ { /** - * @var object $contacts phpgwapi contacts object - * @access private + * @var object $contacts phpgwapi contacts object + * @access private */ var $contacts; /** - * @var object $vcard import/export vcard object - * @access private + * @var object $vcard import/export vcard object + * @access private */ var $vcard; - + + /** + * @var object $s4j import/export sync4j client data object + * @access private + */ + var $s4j; + + /** + * @var object $validator object of validator class for check email syntax + * @access private + */ + var $validator; + /** * Constructor - * - * @access public */ function ipc_addressbook() { - $this->contacts = CreateObject('phpgwapi.contacts'); - $this->vcard = CreateObject('phpgwapi.vcard'); + $this->contacts = CreateObject('phpgwapi.contacts'); + $this->vcard = CreateObject('phpgwapi.vcard'); + $this->s4j = CreateObject('phpgwapi.s4j'); + $this->validator = CreateObject('phpgwapi.validator'); } - + /** * Add data in a certain mime type format to the application. - * - * @access public - * @param mixed $data data for adding to the application, the datatype depends on the mime type - * @param string $type specifies the mime type of the passed data - * @return integer id of the added data + * @param mixed $data data for adding to the application, the datatype depends on the mime type + * @param string $type specifies the mime type of the passed data + * @param string $version specifies the mime type version of the passed data (still no need for this because the version would be recognized automaticly) + * @param string $timestamp the timestamp is used to set in db instead of current time + * @return integer id of the added data */ - function addData($data, $type) + function addData($data, $type, $version='', $timestamp=null) { + $fields = array(); + // 1: mapping the mime type to application data - if($type != 'text/x-vcard') + $convertTypeIn = $type; + $convertVersionIn = $version; + $convertTypeOut = 'x-phpgroupware/addressbook-appl-data-array'; + $convertVersionOut = ''; + + $fields = $this->convertData($data, $convertTypeIn, $convertVersionIn, $convertTypeOut, $convertVersionOut); + if(count($fields) == 0) return false; - $data = ereg_replace("\n\n", "\r\n", $data); - $data_lines = explode("\r\n", $data); - - $buffer = array(); - $temp_line = ''; + if(!isset($fields['owner']) || !$fields['owner']) + $fields['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; - while(list(, $line) = each($data_lines)) + if(!isset($fields['access'])) + $fields['access'] = 'private'; + + if($timestamp != null) { - $line = trim($line); - if(substr($line, -1) == '=') + error_log("setting timestamp to submitted: $timestamp"); + $fields['createon'] = $timestamp; + $fields['modon'] = $timestamp; + } + else + { + error_log("setting timestamp to: 0"); + $fields['createon'] = 0; + $fields['modon'] = 0; + } + //_debug_array($fields); + //$ln_list = $this->contacts->search(array('per_last_name'), $fields['last_name']); + //_debug_array($ln_list); + + $owner = $GLOBALS['phpgw_info']['user']['account_id']; + $sql = 'SELECT DISTINCT c.contact_id AS contact_id '; + $sql .= 'FROM phpgw_contact c '; + $sql .= 'JOIN phpgw_contact_addr ca ON (c.contact_id=ca.contact_id) '; + $sql .= 'JOIN phpgw_contact_person cp ON (c.contact_id=cp.person_id) '; + $sql .= 'JOIN phpgw_contact_org_person cop ON (cp.person_id=cop.person_id) '; + $sql .= 'JOIN phpgw_contact_org co ON (cop.org_id=co.org_id) '; + $sql .= 'WHERE '; + $sql .= ' (c.owner = '.$owner.')'; + $sql .= ' AND (cp.last_name = "'.$fields['last_name'].'")'; + + if(isset($fields['first_name'])) + $sql .= ' AND (cp.first_name = "'.$fields['first_name'].'")'; + else + $sql .= ' AND (cp.first_name = "")'; + + if(isset($fields['title'])) + $sql .= ' AND (cp.title = "'.$fields['title'].'")'; + else + $sql .= ' AND (cp.title = "")'; + + // other not person depended fields + + if(isset($fields['preferred_org'])) + $sql .= ' AND (co.name = "'.$fields['preferred_org'].'")'; + + if(isset($fields['locations']['work'])) + { + $sql .= ' AND (ca.postal_code = "'.$fields['locations']['work']['postal_code'].'")'; + $sql .= ' AND (ca.country = "'.$fields['locations']['work']['country'].'")'; + } + + $contacts = $this->contacts->db->query($sql,__LINE__,__FILE__); + $idList = array(); + while ($this->contacts->db->next_record()) + { + $cid = $this->contacts->db->Record['contact_id']; + if($this->contacts->check_read($cid, $owner)) { - // '=' at end-of-line --line to be continued with next line - $temp_line .= substr($line, 0, -1); - continue; + $idList[] = $cid; } - else + } + + if(count($idList) == 1) + { + error_log('found unique data'); + return $idList[0]; + } + elseif(count($idList) > 1) + { + error_log('data not unique
'); + _debug_array($fields); + _debug_array($idList); + + error_log('check references in projects
'); + // get references projects customer to contact + $sql = 'SELECT DISTINCT customer '; + $sql .= 'FROM phpgw_p_projects p '; + $sql .= 'JOIN phpgw_contact c ON (c.contact_id=p.customer) '; + $sql .= 'WHERE'; + $sql .= ' (c.owner = '.$owner.') AND '; + $sql .= ' (p.customer IN ('.implode(',', $idList).'))'; + + $contacts = $this->contacts->db->query($sql,__LINE__,__FILE__); + $idListProjects = array(); + while ($this->contacts->db->next_record()) { - $line = $temp_line . $line; - $temp_line = ''; // important for next line which ends with = + $cid = $this->contacts->db->Record['contact_id']; + if($this->contacts->check_read($cid, $owner)) + { + $idListProjects[] = $cid; + } } - if (strstr($line, 'BEGIN:VCARD')) + if(count($idListProjects) == 0) { - // added for p800 vcards: problem if vcard starts with "no references found
'); + for($i=1; $iremoveData($idList[$i]); + } + + error_log('use id: '.$idList[0].' and other data removed
'); + return $idList[0]; } + else + { + error_log('references found (id: '.$idListProjects[0].')
'); - $buffer += $this->vcard->parse_vcard_line($line); - } + for($i=0; $iremoveData($idList[$i]); + } - $fields = $this->vcard->in($buffer); - $fields['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; - $fields['access'] = 'private'; + error_log('use id: '.$idListProjects[0].' and other data removed
'); + return $idList[0]; + } + } + // 2. Add data to application + error_log('add new data'); $id = $this->contacts->contact_import($fields); + error_log('new id: '.$id); return $id; } - - /** - * Convert data from a mime type to another. - * - * @access public - * @param mixed $data data for converting, the datatype depends on the input mime type - * @param string $typeIn specifies the input mime type of the passed data - * @param string $typeOut specifies the output mime type of the passed data - * @return mixed converted data from application, the datatype depends on the passed output mime type - */ - function convertData($data, $typeIn, $typeOut) - { - return false; - } - - /** * Get data from the application in a certain mime type format. - * - * @param integer $id id of data to get from the application - * @param string $type specifies the mime type of the returned data - * @return mixed data from application, the datatype depends on the passed mime type, false if no data exists for the passed id + * @param integer $id id of data to get from the application + * @param string $type specifies the mime type of the returned data + * @param string $version specifies the mime type version of the returned data + * @return mixed data from application, the datatype depends on the passed mime type, false if no data exists for the passed id */ - function getData($id, $type) + function getData($id, $type, $version='') { - if($type != 'text/x-vcard') + if($type == 'x-phpgroupware/addressbook-view-url') { - return false; + $link_data['menuaction'] = 'addressbook.uiaddressbook.view_contact'; + $link_data['ab_id'] = $id; + return $GLOBALS['phpgw']->link('/index.php',$link_data); } - if(!$this->contacts->check_read($id)) + if($type != 'x-phpgroupware/search-index-data-item') { + $owner = $GLOBALS['phpgw_info']['user']['account_id']; + // First, make sure they have permission to this entry + if(!$this->contacts->check_read($id, $owner)) + { + return false; + } + unset($owner); + } + + $contact_type = $this->contacts->search_contact_type_id($this->contacts->get_type_contact($id)); + + $fields['type'] = $contact_type; + $fields['id'] = $id; + $fields['adr_one_type'] = 'WORK'; + $fields['adr_two_type'] = 'HOME'; + $fields['email_type'] = 'INTERNET'; + $fields['email_home_type'] = 'INTERNET'; + + if($contact_type == $this->contacts->get_person_name()) + { // person + $fieldlist = $this->contacts->person_complete_data($id); + + +###error_log('getData---fields: '.serialize($fieldlist)); + $fields['owner'] = $fieldlist['owner']; + $fields['access'] = ($fieldlist['access']?$fieldlist['access']:'private'); + $fields['createon'] = $fieldlist['createon']; + $fields['modon'] = $fieldlist['modon']; + + $fields['first_name'] = $fieldlist['first_name']; + $fields['last_name'] = $fieldlist['last_name']; + $fields['middle_name'] = $fieldlist['middle_name']; + + // bug in get_person_name: fullname has two spaces, build fullname again: + $fieldlist['full_name'] = $fieldlist['first_name']; + if($fieldlist['full_name'] != '') + $fieldlist['full_name'] .= ($fields['middle_name'] != '') ? ' '.$fields['middle_name'] : ''; + else + $fieldlist['full_name'] .= ($fields['middle_name'] != '') ? $fields['middle_name'] : ''; + if($fieldlist['full_name'] != '') + $fieldlist['full_name'] .= ($fields['last_name'] != '') ? ' '.$fields['last_name'] : ''; + else + $fieldlist['full_name'] .= ($fields['last_name'] != '') ? $fields['last_name'] : ''; + $fields['full_name'] = $fieldlist['full_name']; + + $fields['prefix'] = $fieldlist['prefix']; + $fields['suffix'] = $fieldlist['suffix']; + $fields['sound'] = $fieldlist['sound']; + $fields['birthday'] = preg_replace('/-/', '', $fieldlist['birthday']); + //$fields['note'] = $fieldlist['']; + //$fields['tz'] = $fieldlist['locations'][$type_work]['']; + //$fields['geo'] = $fieldlist['']; + $fields['pubkey'] = $fieldlist['pubkey']; + $fields['org_name'] = $fieldlist['org_name']; + $fields['org_unit'] = $fieldlist['department']; + $fields['title'] = $fieldlist['title']; + //$fields['tel_prefer'] = $fieldlist['']; + + $cats = $this->contacts->get_cats_by_person($id); + if(is_array($cats)) + $fields['cat_id'] = implode(",", $cats); + else + $fields['cat_id'] = false; + } + elseif($contact_type == $this->contacts->get_org_name()) + { // organization + $fieldlist = array(); + + $data = array('contact_id','owner','access','cat_id','org_name','org_creaton','org_modon'); + $org_data = $this->contacts->get_orgs($data, null, null, null, 'ASC', array('contact_id' => $id), null); + + if(!isset($org_data[0])) + { + return false; + } + + $fields['owner'] = $org_data[0]['owner']; + $fields['access'] = $org_data[0]['access']?$org_data[0]['access']:''; + $fields['createon'] = $org_data[0]['org_creaton']?$org_data[0]['org_creaton']:''; + $fields['modon'] = $org_data[0]['org_modon']?$org_data[0]['org_modon']:''; + $fields['org_name'] = $org_data[0]['org_name']; + $fields['cat_id'] = $org_data[0]['cat_id']?$org_data[0]['cat_id']:''; + + $loclist = $this->contacts->get_addr_contact_data($id); + if(is_array($loclist)) + { + $fieldlist['locations'] = array(); + #while(list($no_use, $loc) = each($loclist)) + foreach( $loclist as $loc) + { + $addr_id = $loc['key_addr_id']; + $fieldlist['locations'][$addr_id] = array( + 'type' => $loc['addr_description'], + 'add1' => $loc['addr_add1'], + 'add2' => $loc['addr_add2'], + 'city' => $loc['addr_city'], + 'state' => $loc['addr_state'], + 'postal_code' => $loc['addr_postal_code'], + 'country' => $loc['addr_country'] + ); + } + } + + $commlist = $this->contacts->get_comm_contact_data($id); + if(is_array($commlist)) + { + $fieldlist['comm_media'] = array(); + #while(list($no_use, $comm) = each($commlist)) + foreach($commlist as $comm ) + { + $comm_type = $comm['comm_description']; + $fieldlist['comm_media'][$comm_type] = $comm['comm_data']; + } + } + + $cats = $this->contacts->get_cats_by_org($id); + #while(list($no_use, $cat_id) = each($cats)) + foreach( $cats as $cat_id ) + { + if($cat_id) + $cat_id_list[] = $cat_id; + } + $cats = $cat_id_list; + if(is_array($cats)) + $fields['cat_id'] = implode(",", $cats); + else + $fields['cat_id'] = false; + } + else + { // no person and no no org return false; } - // First, make sure they have permission to this entry - $fieldlist = $this->contacts->person_complete_data($id); $type_work = $this->contacts->search_location_type('work'); $type_home = $this->contacts->search_location_type('home'); - /* - $fields['full_name'] = $fieldlist['full_name']; - bug: $fieldlist['full_name'] contains two spaces between first and last name, when middle name is empty - workaround: calculate the fullname like shown below - */ - $fields['first_name'] = $fieldlist['first_name']; - $fields['last_name'] = $fieldlist['last_name']; - $fields['middle_name'] = $fieldlist['middle_name']; - - $fields['full_name'] = $fields['first_name'] . ' '; - $fields['full_name'] .= ($fields['middle_name'] != '') ? $fields['middle_name'] . ' ' : ''; - $fields['full_name'] .= $fields['last_name']; - - $fields['prefix'] = $fieldlist['prefix']; - $fields['suffix'] = $fieldlist['suffix']; - $fields['sound'] = $fieldlist['sound']; - $fields['birthday'] = $fieldlist['birthday']; - //$fields['note'] = $fieldlist['']; - //$fields['tz'] = $fieldlist['locations'][$type_work]['']; - //$fields['geo'] = $fieldlist['']; - $fields['pubkey'] = $fieldlist['pubkey']; - $fields['org_name'] = $fieldlist['org_name']; - $fields['org_unit'] = $fieldlist['department']; - $fields['title'] = $fieldlist['title']; - $fields['adr_one_type'] = 'WORK'; - $fields['adr_two_type'] = 'HOME'; - //$fields['tel_prefer'] = $fieldlist['']; - $fields['email_type'] = 'INTERNET'; - $fields['email_home_type'] = 'INTERNET'; // locations contains a list of loc_id and its date if (isset($fieldlist['locations']) && is_array($fieldlist['locations'])) { // locations[loc_id][type] is work or home // loc_id is not interested here, but the type is important! - while ( list($loc_id, $loc_data) = each($fieldlist['locations']) ) + #while ( list($loc_id, $loc_data) = each($fieldlist['locations']) ) + foreach ($fieldlist['locations'] as $loc_id => $loc_data ) { $loc_type_id = $this->contacts->search_location_type($loc_data['type']); switch($loc_type_id) @@ -182,7 +378,6 @@ break; default: continue; - break; } $fields[$adr.'street'] = $loc_data['add1']; $fields[$adr.'ext'] = $loc_data['add2']; @@ -193,58 +388,71 @@ } } - $fields['tel_work'] = $fieldlist['comm_media']['work phone']; - $fields['tel_home'] = $fieldlist['comm_media']['home phone']; - $fields['tel_voice'] = $fieldlist['comm_media']['voice phone']; - $fields['tel_work_fax'] = $fieldlist['comm_media']['work fax']; - $fields['tel_home_fax'] = $fieldlist['comm_media']['home fax']; - $fields['tel_msg'] = $fieldlist['comm_media']['msg phone']; - $fields['tel_cell'] = $fieldlist['comm_media']['mobile (cell) phone']; - $fields['tel_pager'] = $fieldlist['comm_media']['pager']; - $fields['tel_bbs'] = $fieldlist['comm_media']['bbs']; - $fields['tel_modem'] = $fieldlist['comm_media']['modem']; - $fields['tel_car'] = $fieldlist['comm_media']['car phone']; - $fields['tel_isdn'] = $fieldlist['comm_media']['isdn']; - $fields['tel_video'] = $fieldlist['comm_media']['video']; - $fields['email'] = $fieldlist['comm_media']['work email']; - $fields['email_home'] = $fieldlist['comm_media']['home email']; - $fields['url'] = $fieldlist['comm_media']['website']; - - $email = $fields['email']; - $emailtype = $fields['email_type']; - if (!$emailtype) - { - $fields['email_type'] = 'INTERNET'; - } - $hemail = $fields['email_home']; - $hemailtype = $fields['email_home_type']; - if (!$hemailtype) + if (isset($fieldlist['comm_media']) && is_array($fieldlist['comm_media'])) { - $fields['email_home_type'] = 'INTERNET'; - } + $fields['tel_work'] = $fieldlist['comm_media']['work phone']; + $fields['tel_home'] = $fieldlist['comm_media']['home phone']; + $fields['tel_voice'] = $fieldlist['comm_media']['voice phone']; + $fields['tel_work_fax'] = $fieldlist['comm_media']['work fax']; + $fields['tel_home_fax'] = $fieldlist['comm_media']['home fax']; + $fields['tel_msg'] = $fieldlist['comm_media']['msg phone']; + $fields['tel_cell'] = $fieldlist['comm_media']['mobile (cell) phone']; + $fields['tel_pager'] = $fieldlist['comm_media']['pager']; + $fields['tel_bbs'] = $fieldlist['comm_media']['bbs']; + $fields['tel_modem'] = $fieldlist['comm_media']['modem']; + $fields['tel_car'] = $fieldlist['comm_media']['car phone']; + $fields['tel_isdn'] = $fieldlist['comm_media']['isdn']; + $fields['tel_video'] = $fieldlist['comm_media']['video']; + $fields['email'] = $fieldlist['comm_media']['work email']; + $fields['email_home'] = $fieldlist['comm_media']['home email']; + $fields['url'] = $fieldlist['comm_media']['website']; - // set translation variable - $myexport = $this->vcard->export; - // check that each $fields exists in the export array and - // set a new array to equal the translation and original value - while( list($name,$value) = each($fields) ) - { - if ($myexport[$name] && ($value != "") ) + $email = $fields['email']; + $emailtype = $fields['email_type']; + if (!$emailtype) { - //echo '
'.$name."=".$fields[$name]."\n"; - $buffer[$myexport[$name]] = $value; + $fields['email_type'] = 'INTERNET'; + } + $hemail = $fields['email_home']; + $hemailtype = $fields['email_home_type']; + if (!$hemailtype) + { + $fields['email_home_type'] = 'INTERNET'; } } - // create a vcard from this translated array - $data = $this->vcard->out($buffer); + // fields are 'x-phpgroupware/addressbook-appl-data-array' + $convertTypeIn = 'x-phpgroupware/addressbook-appl-data-array'; + $convertVersionIn = ''; + $convertTypeOut = $type; + $convertVersionOut = $version; - if ($data == false) +error_log('getData-----fields: '.serialize($fields)); +error_log('getData-----$convertTypeIn:'.$convertTypeIn); +error_log('getData-----$convertVersionIn:'.$convertVersionIn); +error_log('getData-----$convertTypeOut:'.$convertTypeOut); +error_log('getData-----$convertVersionOut:'.$convertVersionOut); + + + + + if($convertTypeOut == 'x-phpgroupware/addressbook-show-data-array') { - return false; + // workaround + $tmp_type = 'text/x-vcard'; + $tmp_version = '3.0'; + $tmp_data = $this->convertData($fields, $convertTypeIn, $convertVersionIn, $tmp_type, $tmp_version); + // convert fields to mime type format + return $this->convertData($tmp_data, $tmp_type, $tmp_version, $convertTypeOut, $convertVersionOut); + } + else + { + // convert fields to mime type format + $my_tmp = $this->convertData($fields, $convertTypeIn, $convertVersionIn, $convertTypeOut, $convertVersionOut); + error_log('getData------converted: '. $my_tmp); + # return $this->convertData($fields, $convertTypeIn, $convertVersionIn, $convertTypeOut, $convertVersionOut); + return $my_tmp; } - - return $data; } @@ -252,49 +460,105 @@ * Return a list with the available id's in the application. * The optional lastmod parameter allows a limitations of the data id list. * The list contains all the id's of the modified data since the passed lastmod timestamp. - * - * @param integer $lastmod last modification time, default is -1 and means return all data id's - * @return array list of data id's + * @param integer $lastmod last modification time, default is -1 and means return all data id's. + * @param string $restriction restrict the result for a special use of the id list. The possible restrictions are 'syncable' or 'searchable'. When using 'syncable' only person ids will be returned in the result. 'searchable' returns all ids for both persons and orgs without check the owner. Otherwise no restriction will be used and the result contains all ids for both persons and orgs from the owner. + * @return array list of data id's */ - function getIdList($lastmod=-1) + function getIdList($lastmod=-1, $restriction='') { + $restriction = 'searchable'; $idList = array(); $lastmod = intval($lastmod); - + $owner = $GLOBALS['phpgw_info']['user']['account_id']; + //$this->contacts->read(null, false, null, null, null, null, null, $lastmod); - // read_contacts doesnt allow lastmod time -workaround: - $owner = intval($GLOBALS['phpgw_info']['user']['account_id']); + // read_contacts doesnt allow lastmod time -> workaround: - if($lastmod >= 0) + if($lastmod > 0) { - $sql = 'SELECT DISTINCT c.contact_id AS contact_id '. - 'FROM phpgw_contact c '. - 'LEFT JOIN phpgw_contact_addr ca ON (c.contact_id=ca.contact_id) '. - 'LEFT JOIN phpgw_contact_comm cc ON (c.contact_id=cc.contact_id) '. - 'LEFT JOIN phpgw_contact_note cn ON (c.contact_id=cn.contact_id) '. - 'LEFT JOIN phpgw_contact_person cp ON (c.contact_id=cp.person_id) '. - 'WHERE '. - ' (c.owner = '.$owner.')'. - ' AND'. - ' ('. - ' (ca.modified_on '.$lastmod.') OR '. - ' (cc.modified_on '.$lastmod.') OR '. - ' (cn.modified_on '.$lastmod.') OR '. - ' (cp.modified_on '.$lastmod.') '. - ' ) '. - 'ORDER BY c.contact_id'; +## by tb --> we also need the owner of the contact (see end of function) +# $sql = 'SELECT DISTINCT c.contact_id AS contact_id '; + $sql = 'SELECT DISTINCT c.contact_id AS contact_id, c.owner AS contact_owner '; +## by tb --> + $sql .= 'FROM phpgw_contact c '; + $sql .= 'LEFT JOIN phpgw_contact_addr ca ON (c.contact_id=ca.contact_id) '; + $sql .= 'LEFT JOIN phpgw_contact_comm cc ON (c.contact_id=cc.contact_id) '; + $sql .= 'LEFT JOIN phpgw_contact_note cn ON (c.contact_id=cn.contact_id) '; + if($restriction == 'syncable') + { // only persons - no organizations + $sql .= 'JOIN phpgw_contact_person cp ON (c.contact_id=cp.person_id) '; + } + else + { // persons and organizations + $sql .= 'LEFT JOIN phpgw_contact_person cp ON (c.contact_id=cp.person_id) '; + $sql .= 'LEFT JOIN phpgw_contact_org co ON (c.contact_id=co.org_id) '; + } + $sql .= 'WHERE '; + if($restriction == 'searchable') + { // all data + $sql .= ' (c.owner > 0)'; + } + else + { // only owners data + $sql .= ' (c.owner = '.$owner.')'; + } + $sql .= ' AND'; + $sql .= ' ('; + $sql .= ' (ca.modified_on > '.$lastmod.') OR '; + $sql .= ' (cc.modified_on > '.$lastmod.') OR '; + $sql .= ' (cn.modified_on > '.$lastmod.') OR '; + + if($restriction == 'syncable') + { // only persons - no organizations + $sql .= ' (cp.modified_on > '.$lastmod.') '; + } + else + { // persons and organizations + $sql .= ' (cp.modified_on > '.$lastmod.') OR '; + $sql .= ' (co.modified_on > '.$lastmod.') '; + } + + $sql .= ' ) '; + $sql .= 'ORDER BY c.contact_id'; } else { - $sql = 'SELECT DISTINCT contact_id '. - 'FROM phpgw_contact '. - 'WHERE owner = '.$owner.' '. - 'ORDER BY contact_id'; +## by tb --> we also need the owner of the contact (see end of function) +# $sql = 'SELECT DISTINCT c.contact_id AS contact_id '; + $sql = 'SELECT DISTINCT c.contact_id AS contact_id, c.owner AS contact_owner '; +## by tb --> + $sql .= 'FROM phpgw_contact c '; + + if($restriction == 'syncable') + { // only persons - no organizations + $sql .= 'JOIN phpgw_contact_person cp ON (c.contact_id=cp.person_id) '; + } + + if($restriction == 'searchable') + { // all data + $sql .= 'WHERE c.owner > 0 '; + } + else + { // only owners data + $sql .= 'WHERE c.owner = '.$owner.' '; + } + + $sql .= 'ORDER BY c.contact_id'; } $contacts = $this->contacts->db->query($sql,__LINE__,__FILE__); while ($this->contacts->db->next_record()) { - $idList[] = $this->contacts->db->Record['contact_id']; + $cid = $this->contacts->db->Record['contact_id']; +## by tb --> this function needs the owner of the contact, NOT the one who wants to have access !!!!! +## and fetches it if not given !!!! +## here: use owner-id from above query for performance reasons + $cowner = $this->contacts->db->Record['contact_owner']; +# if($this->contacts->check_read($cid, $owner)) + if($this->contacts->check_read($cid, $cowner)) +## by tb --> + { + $idList[] = $cid; + } } return $idList; @@ -303,43 +567,279 @@ /** * Remove data of the passed id. - * - * @param integer $id id of data to remove from the application - * @return boolean true if the data is removed, otherwise false + * @param integer $id id of data to remove from the application + * @return boolean true if the data is removed, otherwise false */ function removeData($id) { - return $this->contacts->delete_contact($id); + $owner = $GLOBALS['phpgw_info']['user']['account_id']; + + if(!$this->contacts->check_delete($id, $owner)) + { + return false; + } + else + { + $this->contacts->delete($id); + + //$this->contacts->delete($id); + //provides no useable return value -> workaround: check for db error + if($GLOBALS['phpgw']->db->Error) + return false; + else + return true; + } } /** * Replace the existing data of the passed id with the passed data in a certain mime type format. - * - * @param integer $id id of data to replace - * @param mixed $data the new data, the datatype depends on the passed mime type - * @param string $type specifies the mime type of the passed data - * @return boolean true if the data is replaced, otherwise false + * @param integer $id id of data to replace + * @param mixed $data the new data, the datatype depends on the passed mime type + * @param string $type specifies the mime type of the passed data + * @param string $version specifies the mime type version of the passed data (still no need for this because the version would be recognized automaticly) + * @param string $timestamp the timestamp is used to set in db instead of current time + * @return boolean true if the data is replaced, otherwise false */ - function replaceData($id, $data, $type) + function replaceData($id, $data, $type, $version='', $timestamp=null) { - if($type != 'text/x-vcard') + $owner = $GLOBALS['phpgw_info']['user']['account_id']; + if(!$this->contacts->check_edit($id, $owner)) { return false; } - + + // 1: mapping the mime type to application data + $convertTypeIn = $type; + $convertVersionIn = $version; + $convertTypeOut = 'x-phpgroupware/addressbook-appl-data-array'; + $convertVersionOut = ''; + + $fields = $this->convertData($data, $convertTypeIn, $convertVersionIn, $convertTypeOut, $convertVersionOut); + + if(!$fields || count($fields) == 0) + return false; + + if(!isset($fields['owner']) || !$fields['owner']) + $fields['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; + + if(!isset($fields['access'])) + $fields['access'] = 'private'; + + if(!isset($fields['contact_id'])) + $fields['contact_id'] = $id; + + if($timestamp != null) + { + $fields['modon'] = $timestamp; + } + else + { + $fields['modon'] = time(); + } + + // 2. Replace data to application + return $this->contacts->contact_import($fields, '', true); + } + + + /** + * Checks if data for the passed id exists. + * @param integer $id id to check + * @return boolean true if the data with id exist, otherwise false + */ + function existData($id) + { if(!$this->contacts->check_read($id)) { return false; } + else + { + return true; + } + } - $data = ereg_replace("\n\n", "\r\n", $data); + /** + * contact_id == ID of the data row + * account_id == ID of the user who needs access + * owner_id == ID of the creator of the data + */ + function checkPermission($contact_id , $account_login) + { + + $account_id = $GLOBALS['phpgw']->accounts->name2id($account_login); + if ($account_id != false){ // checks whether account_login exist or not + if(!$this->contacts->check_access($contact_id, $account_id)) + { + return false; + } + else + { + return true; + } + } + return -1; + } + + /** + * Convert the given data from a mime type into another. + * @param mixed $data data for converting + * @param string $typeIn specifies the mime type of the passed data + * @param string $versionIn specifies the mime type version of the passed data + * @param string $typeOut specifies the mime type of the returned data + * @param string $versionOut specifies the mime type version of the returned data + * @return mixed data from application, the datatype depends on the passed typeOut and versionOut parameters + */ + function convertData($data, $typeIn, $versionIn, $typeOut, $versionOut) + { + // data import: if data typeIn != x-phpgroupware/addressbook-appl-data-array + // convert given data into x-phpgroupware/addressbook-appl-data-array + switch($typeIn) + { + case 'text/x-vcard': + case 'text/vcard': + $appl_data_array = $this->_import_vcard($data); + break; + case 'text/x-s4j-sifc': + $appl_data_array = $this->_import_sync4j_xmlcontact($data); + break; + case 'x-phpgroupware/addressbook-ldap': + $appl_data_array = $this->_import_ldap_array($data); + break; + case 'x-phpgroupware/addressbook-data-array': + $appl_data_array = $this->_import_data_array($data); + break; + case 'x-phpgroupware/addressbook-serialized-appl-data-array': + $appl_data_array = unserialize(base64_decode(trim($data))); + break; + case 'x-phpgroupware/addressbook-appl-data-array': + // no import convert + $appl_data_array = $data; + break; + default: + return false; + } + + +error_log('convertData-------$appl_data_array: '.serialize($appl_data_array) ); + if(!$appl_data_array) + return false; + + // data export: if data typeOut != x-phpgroupware/addressbook-appl-data-array + // convert data into typeOut + switch($typeOut) + { + case 'text/x-vcard': + case 'text/vcard': + $ret_data = $this->_export_vcard($appl_data_array, $versionOut); + break; + case 'text/x-s4j-sifc': + error_log('convertData-------text/x-s4j-sifc: '. $versionOut); + + $ret_data = $this->_export_sync4j_xmlcontact($appl_data_array, $versionOut); + break; + case 'text/xml': + $ret_data = $this->_export_xml($appl_data_array, $versionOut); + break; + case 'x-phpgroupware/search-index-data-item': + $ret_data = $this->_export_index_data_item($appl_data_array, $versionOut); + break; + case 'x-phpgroupware/addressbook-show-data-array': + $ret_data = $this->_export_show_data_array($appl_data_array, $versionOut); + break; + case 'x-phpgroupware/addressbook-serialized-appl-data-array': + $ret_data = base64_encode(serialize($data)); + break; + case 'x-phpgroupware/addressbook-appl-data-array': + // no export convert + $ret_data = $appl_data_array; + break; + default: + return false; + } + error_log('convertData-------retData: '.$ret_data ); + return $ret_data; + } + + + // below are some private helper methods + + // ########################## + // ##### IMPORT METHODS ##### + // ########################## + + /** + * Convert the extern data array structure into intern application array + * @access private + * @param array $fields extern data array + * @return string xml + */ + function _import_data_array($fields) + { + if(!is_array($fields)) + return false; + + $appl_data_array = array(); + + $data = array(); + $comm = array(); + $loc = array(); + + #while(list($field_name, $field_data) = each($fields)) + foreach ($fields as $field_name => $field_data) + { + if(strpos($field_name, 'comm_') === 0) + { + $field_name = str_replace('comm_', '', $field_name); + $comm[$field_name] = html_entity_decode($field_data); + } + elseif(strpos($field_name, 'loc_') === 0) + { + $field_name = str_replace('loc_', '', $field_name); + $field_name = explode('_', $field_name, 2); + + if(count($field_name) == 2) + { + $loc_type = $field_name[0]; + $loc_name = $field_name[1]; + + if(!isset($loc[$loc_type])) + { + $loc[$loc_type] = array('type' => $loc_type); + } + + $loc[$loc_type] += array($loc_name => html_entity_decode($field_data)); + } + } + else + { + $data[$field_name] = html_entity_decode($field_data); + } + } + + $appl_data_array = $data; + $appl_data_array['comm_media'] = $comm; + $appl_data_array['locations'] = $loc; + return $appl_data_array; + } + + /** + * Convert the passed vcard into the internal array structure + * @access private + * @param string $data vcard data string + * @return array internal fields + */ + function _import_vcard($data) + { + $data = ereg_replace("\n\n", "\r\n", $data); // xml-rpc bug: \r\n -> \n\n $data_lines = explode("\r\n", $data); - + $buffer = array(); $temp_line = ''; - while(list(, $line) = each($data_lines)) + #while(list(, $line) = each($data_lines)) + foreach ($data_lines as $line) { $line = trim($line); if(substr($line, -1) == '=') @@ -363,32 +863,639 @@ $buffer += $this->vcard->parse_vcard_line($line); } - $fields = $this->vcard->in($buffer); - $fields['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; - $fields['access'] = 'private'; - $fields['contact_id'] = $id; + if(count($buffer) == 0) + return array(); + else + return $this->vcard->in($buffer); + } - return $this->contacts->contact_import($fields, '', true); + /** + * Convert the passed ldap array into the internal array structure + * @access private + * @param string $data vcard data string + * @return array list of arrays with internal fields + */ + function _import_ldap_array($data) + { + $fields = array(); + + if(!is_array($data) || !isset($data['count'])) + return $fields; + + for($a=0;$a<$data['count'];++$a) + { + $attribute = strtolower($data[$a]); + switch($attribute) + { + case 'objectclass': + break; + case 'rdn': + break; + case 'cn': // common name + if(isset($data[$attribute][0]) && !(isset($fields['first_name']) || isset($fields['last_name']))) + { + $fields['full_name'] = utf8_decode($data[$attribute][0]); + $names = explode(' ', $fields['full_name'], 3); + switch(count($names)) + { + case 2: + $fields['first_name'] = $names[0]; + $fields['last_name'] = $names[1]; + break; + case 3: + $fields['first_name'] = $names[0]; + $fields['middle_name'] = $names[1]; + $fields['last_name'] = $names[2]; + break; + } + } + break; + case 'sn': // last name + case 'surname': + if(isset($data[$attribute][0])) + $fields['last_name'] = utf8_decode($data[$attribute][0]); + break; + case 'givenname': // first name + if(isset($data[$attribute][0])) + $fields['first_name'] = utf8_decode($data[$attribute][0]); + break; + case 'initials': + if(isset($data[$attribute][0]) && !isset($fields['initials'])) + $fields['initials'] = utf8_decode($data[$attribute][0]); + break; + case 'title': + case 'personaltitle': + if(isset($data[$attribute][0])) + $fields['title'] = utf8_decode($data[$attribute][0]); + break; + case 'distinguishedname': + if(isset($data[$attribute][0])) + { + $add_parts = explode(',', utf8_decode($data[$attribute][0])); + for($k=0;$k department + if($value && !isset($fields['department'])) + $fields['department'] = $value; + break; + case 'o': // org -> preferred_org + if($value && !isset($fields['preferred_org'])) + $fields['preferred_org'] = $value; + break; + case 'c': // country + break; + } + } + } + break; + case 'department': + if(isset($data[$attribute][0])) + $fields['department'] = utf8_decode($data[$attribute][0]); + break; + + // location + case 'postaladdress': + if(isset($data[$attribute][0])) + $fields['locations']['work']['add1'] = utf8_decode($data[$attribute][0]); + if(isset($data[$attribute][1])) + $fields['locations']['home']['add1'] = utf8_decode($data[$attribute][1]); + break; + case 'postofficebox': + if(isset($data[$attribute][0])) + $fields['locations']['work']['add2'] = utf8_decode($data[$attribute][0]); + if(isset($data[$attribute][1])) + $fields['locations']['home']['add2'] = utf8_decode($data[$attribute][1]); + break; + case 'postalcode': + if(isset($data[$attribute][0])) + $fields['locations']['work']['postal_code'] = utf8_decode($data[$attribute][0]); + if(isset($data[$attribute][1])) + $fields['locations']['home']['postal_code'] = utf8_decode($data[$attribute][1]); + break; + case 'l': // Locality -> city + case 'locality': + if(isset($data[$attribute][0])) + $fields['locations']['work']['city'] = utf8_decode($data[$attribute][0]); + if(isset($data[$attribute][1])) + $fields['locations']['home']['city'] = utf8_decode($data[$attribute][1]); + break; + case 'countryname': + if(isset($data[$attribute][0])) + $fields['locations']['work']['country'] = utf8_decode($data[$attribute][0]); + if(isset($data[$attribute][1])) + $fields['locations']['home']['country'] = utf8_decode($data[$attribute][1]); + break; + case 'textencodedoraddress': + if(isset($data[$attribute][0])) + { + $add_parts = explode(';', utf8_decode($data[$attribute][0])); + for($k=0;$k last name + if($value && !isset($fields['last_name'])) + $fields['last_name'] = $value; + break; + case 'g': // given name -> first name + if($value && !isset($fields['first_name'])) + $fields['first_name'] = $value; + break; + case 'i': // initials + if($value && !isset($fields['initials'])) + $fields['initials'] = $value; + break; + } + } + } + break; + + // comm_media + case 'facsimiletelephonenumber': + case 'homephone': + case 'telephonenumber': + case 'mail': + case 'rfc822mailbox': + case 'othermailbox': + for($k=0;$k<$data[$attribute]['count'];++$k) + { + if(!isset($data[$attribute][$k])) + { + break; + } + else + { + $is_found = false; + $is_saved = false; + $continue_next = false; + $value = $data[$attribute][$k]; + + switch($attribute) + { + case 'facsimiletelephonenumber': + $fill_map = array('work fax', 'home fax'); + $save_other = true; + break; + case 'homephone': + $fill_map = array('home phone', 'voice phone', 'car phone', 'msg phone', 'work phone'); + $save_other = true; + break; + case 'telephonenumber': + $fill_map = array('work phone', 'voice phone', 'car phone', 'msg phone', 'home phone'); + $save_other = true; + break; + case 'mail': + case 'rfc822mailbox': + case 'othermailbox': + $fill_map = array('work email', 'home email'); + $save_other = true; + if(!$this->validator->is_email($value)) + { + $continue_next = true; + } + break; + default: + $continue_next = true; + break; + } + + if($continue_next == true) + { // continue with next $k in for + continue; + } + + foreach($fill_map as $fill) + { + if(isset($fields['comm_media'][$fill])) + { + if($value == $fields['comm_media'][$fill]) + { + $is_found = true; + break; + } + } + } + + if(!$is_found) + { // value was not found in fields -> save it + foreach($fill_map as $fill) + { + // search the first not set fill field + if(!isset($fields['comm_media'][$fill])) + { // save value in fields + $fields['comm_media'][$fill] = $value; + $is_saved = true; + break; + } + } + + if(!$is_saved) + { // save as other field + $fields[$attribute] = $value; + } + } + } + } + break; + case 'mobile': + if(isset($data[$attribute][0])) + $fields['comm_media']['mobile (cell) phone'] = $data[$attribute][0]; + break; + case 'internationalisdnnumber': + if(isset($data[$attribute][0])) + $fields['comm_media']['isdn'] = $data[$attribute][0]; + break; + case 'pager': + if(isset($data[$attribute][0])) + $fields['comm_media']['pager'] = $data[$attribute][0]; + break; + case 'homepage': + case 'url': + if(isset($data[$attribute][0])) + $fields['comm_media']['website'] = utf8_decode($data[$attribute][0]); + break; + + // other + default: + // save any other ldap info as other fields + //if(isset($data[$attribute][0])) + // $fields[$attribute] = utf8_decode($data[$attribute][0]); + break; + } + } + + if(isset($fields['locations'])) + { + if(isset($fields['locations']['work'])) + $fields['locations']['work']['type'] = 'work'; + if(isset($fields['locations']['home'])) + $fields['locations']['home']['type'] = 'home'; + } + + return $fields; } + /** + * Convert the passed sync4j client xml-contact into the internal array structure + * @access private + * @param string $data xml contact data string + * @return array list of arrays with internal fields + */ + function _import_sync4j_xmlcontact($data) + { + return $this->s4j->contact2addressbook(base64_decode($data)); + } + + // ########################## + // ##### EXPORT METHODS ##### + // ########################## /** - * Checks if data for the passed id exists. - * - * @param integer $id id to check - * @return boolean true if the data with id exist, otherwise false + * Convert the internal array structure into a vcard string + * @access private + * @param array $fields data array + * @param string $version specifies the exported vcard version + * @return string vcard */ - function existData($id) + function _export_vcard($fields, $version) { - if(!$this->contacts->check_read($id)) + $vcardString = ''; + $buffer = array(); + + if(count($fields) == 0) + return $vcardString; + + // set translation variable + $myexport = $this->vcard->export; + // check that each $fields exists in the export array and + // set a new array to equal the translation and original value + while( list($name,$value) = each($fields) ) { + if (@$myexport[$name] && ($value != "") ) + { + //echo '
'.$name."=".$fields[$name]."\n"; + $buffer[$myexport[$name]] = $value; + } + } + + // create a vcard from this translated array + if($version == '3.0') + $vcardString = $this->vcard->out_version_30($buffer); + else + $vcardString = $this->vcard->out($buffer); + + return $vcardString; + } + + /** + * Convert the internal array structure into a sync4j client xml contact string + * @access private + * @param array $fields data array + * @param string $version specifies the exported s4j xml version + * @return string s4j xml contact string + */ + function _export_sync4j_xmlcontact($fields, $version) + { + return base64_encode($this->s4j->addressbook2contact($fields)); + } + + + /** + * Convert the internal application array structure into extern showable data array with translation and input field name data included + * @access private + * @param array $fields application data array + * @param string $version version of export array + * @return string xml + */ + function _export_show_data_array($fields, $version='1.0') + { + if(!is_array($fields)) return false; + + $show_data_array = array(); + $bo =& CreateObject('addressbook.boaddressbook'); + + if(isset($fields['comm_media']) && is_array($fields['comm_media'])) + { + $comms = $fields['comm_media']; + unset($fields['comm_media']); } else { - return true; + $comms = array(); + } + + if(isset($fields['locations']) && is_array($fields['locations'])) + { + $locations = $fields['locations']; + unset($fields['locations']); + } + else + { + $locations = array(); + } + + $field_data = array(); + if(isset($fields['org_name'])) + { + $field_data[] = array('tf' => 'org_name', 'if' => 'org_name', 'vf' => $fields['org_name']); } + else + { + $fields['first_name'] = isset($fields['first_name']) ? $fields['first_name'] : ''; + $fields['last_name'] = isset($fields['last_name']) ? $fields['last_name'] : ''; + $fields['middle_name'] = isset($fields['middle_name']) ? $fields['middle_name'] : ''; + $fields['suffix'] = isset($fields['suffix']) ? $fields['suffix'] : ''; + $fields['prefix'] = isset($fields['prefix']) ? $fields['prefix'] : ''; + $fields['birthday'] = isset($fields['birthday']) ? $fields['birthday'] : ''; + $fields['pubkey'] = isset($fields['pubkey']) ? $fields['pubkey'] : ''; + $fields['title'] = isset($fields['title']) ? $fields['title'] : ''; + $fields['initials'] = isset($fields['initials']) ? $fields['initials'] : ''; + $fields['sound'] = isset($fields['sound']) ? $fields['sound'] : ''; + $fields['preferred_org'] = isset($fields['preferred_org']) ? $fields['preferred_org'] : ''; + $fields['department'] = isset($fields['department']) ? $fields['department'] : ''; + + $field_data[] = array('tf' => 'per_first_name', 'if' => 'first_name', 'vf' => $fields['first_name']); + $field_data[] = array('tf' => 'per_last_name', 'if' => 'last_name', 'vf' => $fields['last_name']); + $field_data[] = array('tf' => 'per_middle_name', 'if' => 'middle_name', 'vf' => $fields['middle_name']); + $field_data[] = array('tf' => 'per_suffix', 'if' => 'suffix', 'vf' => $fields['suffix']); + $field_data[] = array('tf' => 'per_prefix', 'if' => 'prefix', 'vf' => $fields['prefix']); + $field_data[] = array('tf' => 'per_birthday', 'if' => 'birthday', 'vf' => $fields['birthday']); + $field_data[] = array('tf' => 'per_pubkey', 'if' => 'pubkey', 'vf' => $fields['pubkey']); + $field_data[] = array('tf' => 'per_title', 'if' => 'title', 'vf' => $fields['title']); + $field_data[] = array('tf' => 'per_initials', 'if' => 'initials', 'vf' => $fields['initials']); + $field_data[] = array('tf' => 'per_sound', 'if' => 'sound', 'vf' => $fields['sound']); + $field_data[] = array('tf' => 'org_name', 'if' => 'preferred_org', 'vf' => $fields['preferred_org']); + $field_data[] = array('tf' => 'per_department', 'if' => 'department', 'vf' => $fields['department']); + } + + #while(list($no_use, $data) = each($field_data)) + foreach($field_data as $data) + { + $show_data_array[] = array( + 'displayName' => $bo->display_name($data['tf']), + 'displayValue' => htmlentities($data['vf']), + 'fieldName' => $data['if'] + ); + } + + #while(list($field, $data) = each($comms)) + foreach($comms as $field => $data) + { + $show_data_array[] = array( + 'displayName' => lang($field), + 'displayValue' => htmlentities($data), + 'fieldName' => 'comm_'.$field + ); + } + + $type_work = $this->contacts->search_location_type('work'); + $type_home = $this->contacts->search_location_type('home'); + #while(list($loc_id, $loc_data) = each($locations)) + foreach ($locations as $loc_id => $loc_data) + { + unset($loc_data['type']); + + #while(list($field, $data) = each($loc_data)) + foreach ($loc_data as $field => $data) + { + $show_data_array[] = array( + 'displayName' => $bo->display_name('addr_'.$field), + 'displayValue' => htmlentities($data), + 'fieldName' => 'loc_'.$loc_id.'_'.$field + ); + } + } + + return $show_data_array; + } + + + /** + * Convert the internal application array structure into a xml string + * @access private + * @param array $fields data array + * @return string xml + */ + function _export_xml($fields, $version='1.0') + { + $dom_doc = domxml_new_doc($version); + + // contact/ + $elem_contact = $dom_doc->create_element('contact'); + $node_contact = $dom_doc->append_child($elem_contact); + + #while(list($element, $value) = each($fields)) + foreach ($fields as $element => $value) + { + // contact/ + $xmlElement = $dom_doc->create_element($element); + $xmlNode = $node_contact->append_child($xmlElement); + // contact/ text string + $xmlNode->set_content($value); + } + + $xml_string = $dom_doc->dump_mem(true); + return $xml_string; } + function &_export_index_data_item($fields, $version='1.0') + { + $indexitem = CreateObject('pbsearch.IndexBaseDataItem', 'addressbook', $fields['id']); + + if($fields['type'] == 'Persons') + $indexitem->setValue('DataDisplayName', $fields['full_name']); + elseif($fields['type'] == 'Organizations') + $indexitem->setValue('DataDisplayName', $fields['org_name']); + + $indexitem->setValue('DataOwnerId', $fields['owner']); + $indexitem->setValue('DataAccess', $fields['access']); + $indexitem->setValue('DataTimeCreated', $fields['createon']); + $indexitem->setValue('DataTimeModified', $fields['modon']); + $indexitem->setValue('DataCategoryId', $fields['cat_id']); + + $data = $fields; + $indexitem->setValue('Data', $data); + + return $indexitem; + } + + function _export_html($fields) + { + $id = isset($fields['contact_id']) ? $fields['contact_id'] : ''; + $owner = isset($fields['owner']) ? $fields['owner'] : $GLOBALS['phpgw_info']['user']['account_id']; + $access = isset($fields['access']) ? $fields['access'] : ''; + + if(isset($fields['comm_media']) && is_array($fields['comm_media'])) + { + $comm_media = $fields['comm_media']; + unset($fields['comm_media']); + } + else + { + $comm_media = array(); + } + + if(isset($fields['locations']) && is_array($fields['locations'])) + { + $locations = $fields['locations']; + unset($fields['locations']); + } + else + { + $locations = array(); + } + + $contact['per_first_name'] = isset($fields['first_name']) ? $fields['first_name'] : ''; + $contact['per_last_name'] = isset($fields['last_name']) ? $fields['last_name'] : ''; + $contact['per_middle_name'] = isset($fields['middle_name']) ? $fields['middle_name'] : ''; + $contact['per_suffix'] = isset($fields['suffix']) ? $fields['suffix'] : ''; + $contact['per_prefix'] = isset($fields['prefix']) ? $fields['prefix'] : ''; + $contact['per_birthday'] = isset($fields['birthday']) ? $fields['birthday'] : ''; + $contact['per_pubkey'] = isset($fields['pubkey']) ? $fields['pubkey'] : ''; + $contact['per_title'] = isset($fields['title']) ? $fields['title'] : ''; + $contact['per_department'] = isset($fields['department']) ? $fields['department'] : ''; + $contact['per_initials'] = isset($fields['initials']) ? $fields['initials'] : ''; + $contact['per_sound'] = isset($fields['sound']) ? $fields['sound'] : ''; + $contact['per_active'] = isset($fields['active']) ? $fields['active'] : ''; + $contact['preferred_org'] = isset($fields['preferred_org']) ? $fields['preferred_org'] : ''; + $contact['preferred_address'] = isset($fields['preferred_address']) ? $fields['preferred_address'] : ''; + $contact['relations'] = isset($fields['organizations']) ? $fields['organizations'] : array(); + + $contact['org_name'] = isset($fields['org_name']) ? $fields['org_name'] : ''; + $contact['org_active'] = isset($fields['active']) ? $fields['active'] : ''; + $contact['org_parent'] = isset($fields['parent']) ? $fields['parent'] : ''; + $contact['relations'] = isset($fields['people']) ? $fields['people'] : ''; + + $bo = CreateObject('addressbook.boaddressbook'); + $template =& $GLOBALS['phpgw']->template; + $GLOBALS['phpgw']->nextmatchs = CreateObject('phpgwapi.nextmatchs'); + + $template->set_file(array('view_t' => 'view.tpl')); + $template->set_block('view_t','view_row','view_row'); + + $tr_color = $GLOBALS['phpgw_info']['theme']['row_on']; + + #while(list($field, $data) = each($contact)) + foreach ($contact as $field => $data) + { + $data = htmlentities($data); + if(!is_numeric($field) && $data!='') + { + $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); + $template->set_var('th_bg', $tr_color); + $template->set_var('display_col', $bo->display_name($field)); + $template->set_var('ref_data', $data); + $template->parse('cols', 'view_row', True); + } + } + + if(count($comm_media) > 0) + { + $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); + $template->set_var('th_bg', $tr_color); + $template->set_var('display_col', lang('communications')); + $template->set_var('ref_data', ''); + $template->parse('cols', 'view_row', True); + } + + #while(list($field, $data) = each($comm_media)) + foreach($comm_media as $field => $data) + { + $data = htmlentities($data); + if(!is_numeric($field) && $data!='') + { + $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); + $template->set_var('th_bg', $tr_color); + $template->set_var('display_col', lang($field)); + $template->set_var('ref_data', $data); + $template->parse('cols', 'view_row', True); + } + } + + #while(list($loc_type, $loc_data) = each($locations)) + foreach ($locations as $loc_type => $loc_data) + { + #while(list($field, $data) = each($loc_data)) + foreach($loc_data as $field => $data) + { + if($field == 'type') + $data = ''.htmlentities($data).''; + else + $data = htmlentities($data); + + if(!is_numeric($field) && $data!='') + { + $field = 'addr_'.$field; + $tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color); + $template->set_var('th_bg', $tr_color); + $template->set_var('display_col', $bo->display_name($field)); + $template->set_var('ref_data', $data); + $template->parse('cols', 'view_row', True); + } + } + } + + /* Following cleans up view_row, since we were only using it to fill {cols} */ + $template->set_var('view_row',''); + + echo $template->subst('cols'); + return true; + } } ?> Only in phpgw008/addressbook/inc: class.pdb.inc.php diff -i -u -r -d phpgw008/addressbook/inc/class.soaddressbook.inc.php sync_modul/addressbook/inc/class.soaddressbook.inc.php --- phpgw008/addressbook/inc/class.soaddressbook.inc.php Sat Aug 20 12:15:10 2005 +++ sync_modul/addressbook/inc/class.soaddressbook.inc.php Mon Oct 10 10:01:58 2005 @@ -17,7 +17,7 @@ * option) any later version. * \**************************************************************************/ -/* $Id: class.soaddressbook.inc.php,v 1.14.2.3.2.25 2005/08/19 19:48:43 jarg Exp $ */ +/* $Id: class.soaddressbook.inc.php,v 1.14.2.3.2.24 2004/08/21 05:53:12 jarg Exp $ */ class soaddressbook { @@ -27,7 +27,7 @@ if($useacl) { - $this->grants = $GLOBALS['phpgw']->acl->get_grants('addressbook'); + $this->grants = $GLOBALS['phpgw']->acl->get_grants('addressbook'); } if(!isset($GLOBALS['owner'])) @@ -146,7 +146,15 @@ */ function get_addr_contact_data($contact_id, $criteria='') { - return $this->contacts->get_addr_contact_data($contact_id, $criteria); +## by tb + $addr_data = $this->contacts->get_addr_contact_data($contact_id, $criteria); + + for($i=0; $icontacts->search_location_type_id($addr_data[$i]['addr_type']); + } + return $addr_data; +## END - by tb } /** @@ -262,7 +270,7 @@ { return $this->contacts->search_location_type_id($id); } - + /** * This function call to search_location_type from contact object * See the documentation in contact objet @@ -282,7 +290,7 @@ { return $this->contacts->search_note_type_id($id); } - + /** * This function call to search_note_type from contact object * See the documentation in contact objet @@ -292,7 +300,7 @@ { return $this->contacts->search_note_type($description); } - + /** * This function call to search_comm_type_id from contact object * See the documentation in contact objet @@ -302,7 +310,7 @@ { return $this->contacts->search_comm_type_id($id); } - + /** * This function call to search_comm_type from contact object * See the documentation in contact objet @@ -322,7 +330,7 @@ { return $this->contacts->search_comm_descr_id($id); } - + /** * This function call to search_comm_descr from contact object * See the documentation in contact objet @@ -342,7 +350,7 @@ { return $this->contacts->search_contact_type_id($id); } - + /** * This function call to search_contact_type from contact object * See the documentation in contact objet @@ -377,7 +385,7 @@ { $cats = ''; } - + $principal['cat_id'] = $cats; $person = array_merge($fields['tab_person_data'], $fields['tab_extra']); $orgs = $fields['edit_orgs']; @@ -410,9 +418,9 @@ if(count($orgs['insert'])>0) { - $this->contacts->add_orgs_for_person($orgs['insert'], - $orgs['preferred_org'], - $fields['preferred_address'], + $this->contacts->add_orgs_for_person($orgs['insert'], + $orgs['preferred_org'], + $fields['preferred_address'], $person_id, PHPGW_SQL_RUN_SQL); } else @@ -423,11 +431,11 @@ 'my_addr_id' => $fields['preferred_address']); $this->contacts->edit_org_person_relation($orgs['preferred_org'], $person_id, $data, PHPGW_SQL_RUN_SQL); } - + $comm_preferred = $fields['tab_comms']['preferred']; - - $this->upgrade_comms($fields['edit_comms']['insert'], - $fields['edit_comms']['delete'], + + $this->upgrade_comms($fields['edit_comms']['insert'], + $fields['edit_comms']['delete'], $fields['edit_comms']['edit'], $fields['comm_data'], $comm_preferred, $person_id); @@ -435,9 +443,9 @@ $fields['edit_others']['delete'], $fields['edit_others']['edit'], $fields['tab_others']['other_value'], $person_id); - + $this->execute_queries($queries); - + if($preferred_force_addr && $preferred_force_addr!='') { $preferred_force_addr = $this->get_preferred_location($person_id, $preferred_force_addr); @@ -464,10 +472,10 @@ $account->update_data($account_data); $account->save_repository(); } - + $this->contacts->finalize_edit($person_id); } - + function edit_org($org_id, $fields) { $principal['owner'] = $fields['owner']; @@ -488,7 +496,7 @@ { $cats = ''; } - + $principal['cat_id'] = $cats; $org = $fields['tab_org_data']; $persons = $fields['edit_persons']; @@ -500,19 +508,19 @@ { $this->contacts->delete_org_person_relation($org_id, $person_id, PHPGW_SQL_RUN_SQL); } - + $this->contacts->add_people_for_organzation($persons['insert'], $org_id, PHPGW_SQL_RUN_SQL); - $this->upgrade_comms($fields['edit_comms']['insert'], - $fields['edit_comms']['delete'], + $this->upgrade_comms($fields['edit_comms']['insert'], + $fields['edit_comms']['delete'], $fields['edit_comms']['edit'], $fields['comm_data'], '', $org_id); - + $this->upgrade_others($fields['edit_others']['insert'], $fields['edit_others']['delete'], $fields['edit_others']['edit'], $fields['tab_others']['other_value'], $org_id); - + $this->execute_queries($queries); if($preferred_force_addr && $preferred_force_addr!='') @@ -599,24 +607,23 @@ //used function add_person($fields) - { - if(!is_array($fields['tab_person_data'])) - { - $fields['tab_person_data'] = (array)$fields['tab_person_data']; - } + { + if(!is_array($fields['tab_person_data'])) + { + $fields['tab_person_data'] = (array)$fields['tab_person_data']; + } + + if(!is_array($fields['tab_extra'])) + { + $fields['tab_extra'] = (array)$fields['tab_extra']; + } + $principal = array_merge($fields['tab_person_data'], $fields['tab_extra']); - if(!is_array($fields['tab_extra'])) - { - $fields['tab_extra'] = (array)$fields['tab_extra']; - } - - $principal = array_merge($fields['tab_person_data'], $fields['tab_extra']); - if(!is_array($fields['tab_comms']['comm_data'])) { $fields['tab_comms']['comm_data']=array(); } - + foreach($fields['tab_comms']['comm_data'] as $type_descr => $data) { if($data) @@ -626,7 +633,7 @@ 'comm_preferred' => ($type_descr==$fields['tab_comms']['preferred']?'Y':'N')); } } - + if(is_array($fields['addr_data'])) { $fields['addr_data'][$fields['tab_address']['addr_preferred']]['addr_preferred']='Y'; @@ -641,7 +648,7 @@ } } $others = $fields['others_data']; - + $orgs = $fields['tab_orgs']['my_orgs']; $principal['preferred_org'] = $fields['tab_orgs']['preferred_org']; if($fields['tab_orgs']['preferred_org']) @@ -676,13 +683,13 @@ 'comm_preferred' => ($type_descr==$fields['tab_comms']['preferred']?'Y':'N')); } } - + if(is_array($fields['addr_data'])) { $fields['addr_data'][$fields['tab_address']['addr_preferred']]['addr_preferred']='Y'; $addr = $fields['addr_data']; } - + if(is_array($fields['others_data'])) { foreach($fields['others_data'] as $key => $data) @@ -691,9 +698,9 @@ } } $others = $fields['others_data']; - + $persons = $fields['tab_persons']['my_person']; - + $cats = $fields['tab_cats']['my_cats']; $type = $this->contacts->search_contact_type($this->contacts->get_org_name()); @@ -710,7 +717,7 @@ { return $this->contacts->add_others($fields, $contact_id, $action); } - + /** * This function call to add_communication_media from contact object * See the documentation in contact objet @@ -752,7 +759,7 @@ $principal['access'] = 'private'; $principal['owner'] = $GLOBALS['phpgw_info']['user']['account_id']; - + $comms[] = array('comm_descr' => $this->search_comm_descr('work email'), 'comm_data' => $email, 'comm_preferred' => 'Y'); @@ -762,7 +769,7 @@ return $c_id; } - + /*************************************************************\ * Delete contact section * @@ -780,7 +787,7 @@ /** * Delete the specified communication media. - * + * * @param integer|array $id Key of the comm media what you want */ function delete_specified_comm($id, $action=PHPGW_SQL_RETURN_SQL) @@ -790,7 +797,7 @@ /** * Delete the specified address. - * + * * @param integer|array $id Key of the address what you want */ function delete_specified_location($id, $action=PHPGW_SQL_RETURN_SQL) @@ -799,7 +806,7 @@ } /** * Delete the specified others field. - * + * * @param integer|array $id Key of the other field what you want */ function delete_specified_other($id, $action=PHPGW_SQL_RETURN_SQL) @@ -809,7 +816,7 @@ /** * Delete the specified note. - * + * * @param integer|array $id Key of the note what you want */ function delete_specified_note($id, $action=PHPGW_SQL_RETURN_SQL) @@ -840,7 +847,7 @@ { $data = array(); } - + $this->edit_comms_by_contact($contact_id, array('comm_preferred'=>'N'), PHPGW_SQL_RUN_SQL); foreach($data as $key => $value) { @@ -848,7 +855,7 @@ { $this->delete_specified_comm($value['key_comm_id'], PHPGW_SQL_RUN_SQL); } - + if(array_key_exists($value['comm_description'], $edit_comms)) { if($comm_preferred == $value['comm_description']) @@ -859,10 +866,10 @@ { $preferred = 'N'; } - - $this->edit_comms($value['key_comm_id'], + + $this->edit_comms($value['key_comm_id'], array('comm_data' => $edit_comms[$value['comm_description']], - 'comm_preferred' => $preferred), + 'comm_preferred' => $preferred), PHPGW_SQL_RUN_SQL); } } @@ -877,11 +884,11 @@ { $pref = 'N'; } - + $fields = array('comm_descr' => $this->search_comm_descr($key), 'comm_data' => $value, 'comm_preferred' => $pref); - + $this->add_communication_media($fields, $contact_id, PHPGW_SQL_RUN_SQL); } $this->unlock(); @@ -905,8 +912,8 @@ { if(array_key_exists($key, $edit_others)) { - $this->edit_other($key, - array('other_value' => $value), + $this->edit_other($key, + array('other_value' => $value), PHPGW_SQL_RUN_SQL); } } @@ -916,7 +923,7 @@ $fields['other_value'] = $data[$key]; $this->add_others($fields, $contact_id, PHPGW_SQL_RUN_SQL); } - + $this->unlock(); } @@ -996,7 +1003,7 @@ /** * Check if the contact has add permissions. - * + * * @param integer $contact_id The contact_id which you want to check * @param integer $owner_id The owner_id of the contact which you want to check */ @@ -1004,10 +1011,10 @@ { return $this->contacts->check_add($contact_id, $owner_id); } - + /** * Check if the contact has edit permissions. - * + * * @param integer $contact_id The contact_id which you want to check * @param integer $owner_id The owner_id of the contact which you want to check */ @@ -1015,10 +1022,10 @@ { return $this->contacts->check_edit($contact_id, $owner_id); } - + /** * Check if the contact has read permissions. - * + * * @param integer $contact_id The contact_id which you want to check * @param integer $owner_id The owner_id of the contact which you want to check */ @@ -1026,10 +1033,10 @@ { return $this->contacts->check_read($contact_id, $owner_id); } - + /** * Check if the contact has delete permissions. - * + * * @param integer $contact_id The contact_id which you want to check * @param integer $owner_id The owner_id of the contact which you want to check */ @@ -1048,13 +1055,13 @@ $prefs=$prefs->data['addressbook']; if($contact_type==$this->tab_main_persons) { - + return unserialize($prefs['person_columns']); } elseif($contact_type==$this->tab_main_organizations) { return unserialize($prefs['org_columns']); - } + } } } Only in phpgw008/addressbook/inc: class.socatalog_contact_addr_type.inc.php Only in phpgw008/addressbook/inc: class.socatalog_contact_comm_descr.inc.php Only in phpgw008/addressbook/inc: class.socatalog_contact_comm_type.inc.php Only in phpgw008/addressbook/inc: class.socatalog_contact_note_type.inc.php Only in phpgw008/addressbook/inc: class.uiXport.inc.php Only in phpgw008/addressbook/inc: class.uiaddressbook.inc.php Only in phpgw008/addressbook/inc: class.uiaddressbook_prefs.inc.php Only in phpgw008/addressbook/inc: class.uicatalog_contact_addr_type.inc.php Only in phpgw008/addressbook/inc: class.uicatalog_contact_comm_descr.inc.php Only in phpgw008/addressbook/inc: class.uicatalog_contact_comm_type.inc.php Only in phpgw008/addressbook/inc: class.uicatalog_contact_note_type.inc.php Only in phpgw008/addressbook/inc: class.uicategorize_contacts.inc.php Only in phpgw008/addressbook/inc: class.uifields.inc.php Only in phpgw008/addressbook/inc: class.uivcard.inc.php Only in phpgw008/addressbook/inc: class.widget_lists.inc.php Only in phpgw008/addressbook/inc: export Only in phpgw008/addressbook/inc: functions.inc.php Only in phpgw008/addressbook/inc: hook_add_def_pref.inc.php Only in phpgw008/addressbook/inc: hook_addressbook_add_def_acl.inc.php Only in phpgw008/addressbook/inc: hook_admin.inc.php Only in phpgw008/addressbook/inc: hook_config_validate.inc.php Only in phpgw008/addressbook/inc: hook_deleteaccount.inc.php Only in phpgw008/addressbook/inc: hook_home.inc.php Only in phpgw008/addressbook/inc: hook_manual.inc.php Only in phpgw008/addressbook/inc: hook_notifywindow.inc.php Only in phpgw008/addressbook/inc: hook_preferences.inc.php Only in phpgw008/addressbook/inc: hook_sidebox_menu.inc.php Only in phpgw008/addressbook/inc: import Only in phpgw008/addressbook: index.php Only in phpgw008/addressbook: setup Only in phpgw008/addressbook: templates Only in phpgw008: admin Only in phpgw008: anon_wrapper.php Only in phpgw008: bookmarks Only in phpgw008/calendar: CVS Only in phpgw008/calendar: doc Only in phpgw008/calendar: help Only in phpgw008/calendar: ical.php Only in phpgw008/calendar/inc: CVS Only in phpgw008/calendar/inc: class.boalarm.inc.php Only in phpgw008/calendar/inc: class.bocalendar.inc.php Only in phpgw008/calendar/inc: class.bocustom_fields.inc.php Only in phpgw008/calendar/inc: class.boholiday.inc.php Only in phpgw008/calendar/inc: class.boicalendar.inc.php Only in sync_modul/calendar/inc: class.boxmlcalendar.inc.php Only in phpgw008/calendar/inc: class.calendar_holiday.inc.php Only in phpgw008/calendar/inc: class.calendar_icap.inc.php Only in phpgw008/calendar/inc: class.holidaycalc.inc.php Only in phpgw008/calendar/inc: class.holidaycalc_JP.inc.php Only in phpgw008/calendar/inc: class.holidaycalc_US.inc.php Only in phpgw008/calendar/inc: class.html.inc.php Only in sync_modul/calendar/inc: class.ipc_calendar.inc.php Only in phpgw008/calendar/inc: class.socalendar.inc.php Only in phpgw008/calendar/inc: class.socalendar_.inc.php Only in phpgw008/calendar/inc: class.socalendar__.inc.php diff -i -u -r -d phpgw008/calendar/inc/class.socalendar_sql.inc.php sync_modul/calendar/inc/class.socalendar_sql.inc.php --- phpgw008/calendar/inc/class.socalendar_sql.inc.php Mon Jan 3 06:56:24 2005 +++ sync_modul/calendar/inc/class.socalendar_sql.inc.php Tue Nov 29 16:21:54 2005 @@ -24,14 +24,14 @@ class socalendar_ extends socalendar__ { var $deleted_events = Array(); - + var $cal_event; var $today = Array('raw','day','month','year','full','dow','dm','bd'); function socalendar_() { $this->socalendar__(); - + if (!is_object($GLOBALS['phpgw']->asyncservice)) { $GLOBALS['phpgw']->asyncservice = CreateObject('phpgwapi.asyncservice'); @@ -46,7 +46,7 @@ // settype($user,'integer'); $this->user = $GLOBALS['phpgw_info']['user']['account_id']; } - elseif(is_int($user)) + elseif(is_int($user)) { $this->user = $user; } @@ -83,7 +83,7 @@ { return $new_name; } - + function delete_calendar($calendar='') { $this->stream->query('SELECT cal_id FROM phpgw_cal WHERE owner='.intval($calendar),__LINE__,__FILE__); @@ -98,7 +98,7 @@ $this->stream->lock(array('phpgw_cal_user')); $this->stream->query('DELETE FROM phpgw_cal_user WHERE cal_login='.intval($calendar),__LINE__,__FILE__); $this->stream->unlock(); - + return $calendar; } @@ -180,7 +180,7 @@ } return $id; } - + /*! @function delete_alarms($cal_id) @abstract delete all alarms of a calendar-entry @@ -189,14 +189,14 @@ function delete_alarms($cal_id) { $alarms = $this->read_alarms($cal_id); - + foreach($alarms as $id => $alarm) { $this->async->cancel_timer($id); } return count($alarms); } - + /*! @function delete_alarm($id) @abstract delete one alarms identified by its id @@ -219,11 +219,11 @@ $this->stream->lock(array('phpgw_cal','phpgw_cal_user','phpgw_cal_repeats','phpgw_cal_extra'/* OLD-ALARM,'phpgw_cal_alarm'*/)); $this->stream->query('SELECT * FROM phpgw_cal WHERE cal_id='.$event_id,__LINE__,__FILE__); - + if($this->stream->num_rows() > 0) { $this->event_init(); - + $this->stream->next_record(); // Load the calendar event data from the db into $event structure // Use http://www.php.net/manual/en/function.mcal-fetch-event.php as the reference @@ -236,7 +236,7 @@ $this->add_attribute('uid',$GLOBALS['phpgw']->strip_html($this->stream->f('uid'))); $this->add_attribute('location',stripslashes($GLOBALS['phpgw']->strip_html($this->stream->f('location')))); $this->add_attribute('reference',intval($this->stream->f('reference'))); - + // This is the preferred method once everything is normalized... //$this->event->alarm = intval($this->stream->f('alarm')); // But until then, do it this way... @@ -261,7 +261,7 @@ $this->add_attribute('groups',$groups[$j],$j-1); } } - + $this->stream->query('SELECT * FROM phpgw_cal_repeats WHERE cal_id='.$event_id,__LINE__,__FILE__); if($this->stream->num_rows()) { @@ -308,7 +308,7 @@ } $this->add_attribute('recur_exception',$exceptions); } - + //Legacy Support $this->stream->query('SELECT * FROM phpgw_cal_user WHERE cal_id='.$event_id,__LINE__,__FILE__); if($this->stream->num_rows()) @@ -365,7 +365,7 @@ { $this->event = False; } - + $this->stream->unlock(); if ($this->event) @@ -388,7 +388,7 @@ } $datetime = mktime(0,0,0,$startMonth,$startDay,$startYear) - $tz_offset; - + $user_where = ' AND (phpgw_cal_user.cal_login in ('; if($owner_id) { @@ -408,6 +408,7 @@ // $user_where .= ','.implode(',',$member); $user_where .= ')) '; + if($this->debug) { echo ''."\n"; @@ -459,7 +460,7 @@ function snooze($event_id) { //Turn off an alarm for an event - //Returns true. + //Returns true. } function list_alarms($begin_year='',$begin_month='',$begin_day='',$end_year='',$end_month='',$end_day='') @@ -508,7 +509,7 @@ $this->event = $this_event; return 1; } - + /***************** Local functions for SQL based Calendar *****************/ function get_event_ids($search_repeats=False,$extra='',$search_extra=False) @@ -536,7 +537,7 @@ { echo "FULL SQL : ".$sql."
\n"; } - + $this->stream->query($sql,__LINE__,__FILE__); $retval = Array(); @@ -562,6 +563,7 @@ function save_event(&$event) { +error_log('---socal---save_called------------------------------------------------ '); $locks = Array( 'phpgw_cal', 'phpgw_cal_user', @@ -606,7 +608,18 @@ $date = $this->maketime($event['start']) - $GLOBALS['phpgw']->datetime->tz_offset; $enddate = $this->maketime($event['end']) - $GLOBALS['phpgw']->datetime->tz_offset; - $today = time() - $GLOBALS['phpgw']->datetime->tz_offset; +## by tb --> why today ?? +# $today = time() - $GLOBALS['phpgw']->datetime->tz_offset; +# wenn in ['timestamp'] etwas steht wir es in moddate geschrieben, SONST ( jetzt - offset ) + if (isset($event['timestamp'])) + { + $moddate = $this->maketime($event['timestamp']); + } + else + { + $moddate = time() - $GLOBALS['phpgw']->datetime->tz_offset; + } +## by tb --> if($event['recur_type'] != MCAL_RECUR_NONE) { @@ -620,7 +633,10 @@ $sql = 'UPDATE phpgw_cal SET ' . 'owner='.$event['owner'].', ' . 'datetime='.$date.', ' - . 'mdatetime='.$today.', ' +## by tb --> +# . 'mdatetime='.$today.', ' + . 'mdatetime='.$moddate.', ' +## by tb --> . 'edatetime='.$enddate.', ' . 'priority='.$event['priority'].', ' . "category='".$event['category']."', " @@ -632,14 +648,17 @@ . ($event['groups']?"groups='".(count($event['groups'])>1?implode(',',$event['groups']):','.$event['groups'][0].',')."', ":'') . 'reference='.$event['reference'].' ' . 'WHERE cal_id='.$event['id']; - +error_log('---socal---sql: '.$sql); $this->stream->query($sql,__LINE__,__FILE__); - +error_log('----socal---streamQuerySql'); + $this->stream->query('DELETE FROM phpgw_cal_user WHERE cal_id='.$event['id'],__LINE__,__FILE__); +error_log('----socal---streamQueryDelete'); @reset($event['participants']); while (list($key,$value) = @each($event['participants'])) { +error_log('----socal---participants'); if(intval($key) == $event['owner']) { $value = 'A'; @@ -717,6 +736,7 @@ $alarm['id'] = $this->stream->f(0); } */ +error_log('---socal---nachALARM: '.$event['id']); print_debug('Event Saved: ID #',$event['id']); $this->stream->unlock(); @@ -728,13 +748,13 @@ $this->save_alarm($event['id'],$alarm); } } - $GLOBALS['phpgw_info']['cal_new_event_id'] = $event['id']; + $GLOBALS['phpgw_info']['cal_new_event_id'] = $event['id']; return True; } function get_alarm($cal_id) { -/* OLD-ALARM +/* OLD-ALARM $this->stream->query('SELECT cal_time, cal_text FROM phpgw_cal_alarm WHERE cal_id='.$id.' AND cal_owner='.$this->user,__LINE__,__FILE__); if($this->stream->num_rows()) { @@ -771,7 +791,7 @@ TENTATIVE => 'T', ACCEPTED => 'A' ); - + $this->stream->query("UPDATE phpgw_cal_user SET cal_status='".$status_code_short[$status]."' WHERE cal_id=".$id." AND cal_login=".$owner,__LINE__,__FILE__); /* OLD-ALARM if ($status == 'R') @@ -781,7 +801,7 @@ */ return True; } - + // End of ICal style support....... function group_search($owner=0) @@ -845,7 +865,7 @@ { $wheremod = ' AND mdatetime > ' . intval($lastmod); } - + $order_by = ' ORDER BY phpgw_cal.cal_id ASC'; if($this->debug) { Only in phpgw008/calendar/inc: class.soholiday.inc.php Only in phpgw008/calendar/inc: class.uialarm.inc.php Only in phpgw008/calendar/inc: class.uicustom_fields.inc.php Only in phpgw008/calendar/inc: class.uiholiday.inc.php Only in phpgw008/calendar/inc: class.uiicalendar.inc.php Only in phpgw008/calendar/inc: events.ics Only in phpgw008/calendar/inc: hook_add_def_pref.inc.php Only in phpgw008/calendar/inc: hook_admin.inc.php Only in phpgw008/calendar/inc: hook_deleteaccount.inc.php Only in phpgw008/calendar/inc: hook_email.inc.php Only in phpgw008/calendar/inc: hook_home.inc.php Only in phpgw008/calendar/inc: hook_home_day.inc.php Only in phpgw008/calendar/inc: hook_home_month.inc.php Only in phpgw008/calendar/inc: hook_home_planner.inc.php Only in phpgw008/calendar/inc: hook_home_week.inc.php Only in phpgw008/calendar/inc: hook_home_year.inc.php Only in phpgw008/calendar/inc: hook_manual.inc.php Only in phpgw008/calendar/inc: hook_preferences.inc.php Only in phpgw008/calendar/inc: hook_settings.inc.php Only in phpgw008/calendar/inc: hook_sidebox_menu.inc.php Only in phpgw008/calendar: index.php Only in phpgw008/calendar: phpgroupware.org Only in phpgw008/calendar: preferences.php Only in phpgw008/calendar: setup Only in phpgw008/calendar: templates Only in phpgw008: chat Only in phpgw008: chora Only in phpgw008: comic Only in phpgw008: developer_tools Only in phpgw008: dj Only in phpgw008: doc Only in phpgw008: eldaptir Only in phpgw008: email Only in phpgw008: etemplate Only in phpgw008: felamimail Only in phpgw008: filemanager Only in phpgw008: folders Only in phpgw008: forum Only in phpgw008: ftp Only in phpgw008: fudforum Only in phpgw008: header.inc.php.template Only in phpgw008: headlines Only in phpgw008: home.php Only in phpgw008: hr Only in phpgw008: img Only in phpgw008: index.php Only in phpgw008: infolog Only in phpgw008: javassh Only in phpgw008: login.php Only in phpgw008: logout.php Only in phpgw008: manual Only in phpgw008: messenger Only in phpgw008: news_admin Only in phpgw008: nntp Only in phpgw008: notes Only in phpgw008: notify.php Only in phpgw008: notify_simple.php Only in phpgw008: phonelog Only in phpgw008: phpGroupWare - 0.9.16.kpf Only in phpgw008: phpbrain Only in phpgw008/phpgwapi: CVS Only in phpgw008/phpgwapi: cron Only in phpgw008/phpgwapi: doc Only in phpgw008/phpgwapi/inc: CVS Only in phpgw008/phpgwapi/inc: class.Template.inc.php Only in phpgw008/phpgwapi/inc: class.Template_experimental.inc.php Only in phpgw008/phpgwapi/inc: class.accounts.inc.php Only in phpgw008/phpgwapi/inc: class.accounts_contacts.inc.php Only in phpgw008/phpgwapi/inc: class.accounts_ldap.inc.php Only in phpgw008/phpgwapi/inc: class.accounts_sql.inc.php Only in phpgw008/phpgwapi/inc: class.acl.inc.php Only in phpgw008/phpgwapi/inc: class.applications.inc.php Only in phpgw008/phpgwapi/inc: class.arrayfunctions.inc.php Only in phpgw008/phpgwapi/inc: class.asyncservice.inc.php Only in phpgw008/phpgwapi/inc: class.auth.inc.php Only in phpgw008/phpgwapi/inc: class.auth_http.inc.php Only in phpgw008/phpgwapi/inc: class.auth_ldap.inc.php Only in phpgw008/phpgwapi/inc: class.auth_mail.inc.php Only in phpgw008/phpgwapi/inc: class.auth_nis.inc.php Only in phpgw008/phpgwapi/inc: class.auth_sql.inc.php Only in phpgw008/phpgwapi/inc: class.auth_sqlssl.inc.php Only in phpgw008/phpgwapi/inc: class.bojsaddressbook.inc.php Only in phpgw008/phpgwapi/inc: class.browser.inc.php Only in phpgw008/phpgwapi/inc: class.clientsniffer.inc.php Only in phpgw008/phpgwapi/inc: class.common.inc.php Only in phpgw008/phpgwapi/inc: class.config.inc.php Only in phpgw008/phpgwapi/inc: class.contact_accounts.inc.php Only in phpgw008/phpgwapi/inc: class.contact_addr.inc.php Only in phpgw008/phpgwapi/inc: class.contact_addr_type.inc.php Only in phpgw008/phpgwapi/inc: class.contact_categories.inc.php Only in phpgw008/phpgwapi/inc: class.contact_central.inc.php Only in phpgw008/phpgwapi/inc: class.contact_comm.inc.php Only in phpgw008/phpgwapi/inc: class.contact_comm_descr.inc.php Only in phpgw008/phpgwapi/inc: class.contact_comm_type.inc.php Only in phpgw008/phpgwapi/inc: class.contact_note.inc.php Only in phpgw008/phpgwapi/inc: class.contact_note_type.inc.php Only in phpgw008/phpgwapi/inc: class.contact_org.inc.php Only in phpgw008/phpgwapi/inc: class.contact_org_person.inc.php Only in phpgw008/phpgwapi/inc: class.contact_others.inc.php Only in phpgw008/phpgwapi/inc: class.contact_person.inc.php Only in phpgw008/phpgwapi/inc: class.contact_types.inc.php Only in phpgw008/phpgwapi/inc: class.contacts.inc.php Only in phpgw008/phpgwapi/inc: class.contacts_ldap.inc.php Only in phpgw008/phpgwapi/inc: class.contacts_shared.inc.php Only in phpgw008/phpgwapi/inc: class.country.inc.php Only in phpgw008/phpgwapi/inc: class.crypto.inc.php Only in phpgw008/phpgwapi/inc: class.data_cleaner.inc.php Only in phpgw008/phpgwapi/inc: class.datetime.inc.php Only in phpgw008/phpgwapi/inc: class.db.inc.php Only in phpgw008/phpgwapi/inc: class.db_msql.inc.php Only in phpgw008/phpgwapi/inc: class.db_mssql.inc.php Only in phpgw008/phpgwapi/inc: class.db_mysql.inc.php Only in phpgw008/phpgwapi/inc: class.db_odbc.inc.php Only in phpgw008/phpgwapi/inc: class.db_oracle.inc.php Only in phpgw008/phpgwapi/inc: class.db_pgsql.inc.php Only in phpgw008/phpgwapi/inc: class.db_sapdb.inc.php Only in phpgw008/phpgwapi/inc: class.db_sybase.inc.php Only in phpgw008/phpgwapi/inc: class.error.inc.php Only in phpgw008/phpgwapi/inc: class.errorlog.inc.php Only in phpgw008/phpgwapi/inc: class.graphics.inc.php Only in phpgw008/phpgwapi/inc: class.historylog.inc.php Only in phpgw008/phpgwapi/inc: class.hooks.inc.php Only in phpgw008/phpgwapi/inc: class.http.inc.php Only in phpgw008/phpgwapi/inc: class.http_dav_client.inc.php Only in phpgw008/phpgwapi/inc: class.interserver.inc.php diff -i -u -r -d phpgw008/phpgwapi/inc/class.ipc_.inc.php sync_modul/phpgwapi/inc/class.ipc_.inc.php --- phpgw008/phpgwapi/inc/class.ipc_.inc.php Tue Mar 2 23:59:24 2004 +++ sync_modul/phpgwapi/inc/class.ipc_.inc.php Sat Oct 1 15:31:30 2005 @@ -6,7 +6,7 @@ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License * @package phpgwapi * @subpackage communication - * @version $Id: class.ipc_.inc.php,v 1.2.2.2 2004/02/27 23:02:05 ceb Exp $ + * @version $Id: class.ipc_.inc.php,v 1.2.2.2.52.6 2004/12/01 10:29:42 dschaller Exp $ */ @@ -19,107 +19,243 @@ class ipc_ { /** + * Only if set true, the sync-engine will dispatch + * refsync-events to this ipc. + * @access package-private + */ + var $isRefSyncable = false; + + /** + * device id + * @access package-private + */ + var $deviceId = -1; + + /** + * snyc object + * @access package-private + */ + var $ipc_sync = null; + + /** + * debug level + * @access package-private + */ + var $debugLevel = 2; + + /** * Constructor - * * @abstract - * @access public */ function ipc_() { die('call abstract method: '.__class__.'::'.__function__); } + /** * Add data in a certain mime type format to the application. - * * @abstract - * @param mixed $data data for adding to the application, the datatype depends on the mime type - * @param string $type specifies the mime type of the passed data - * @return integer id of the added data + * @param mixed $data data for adding to the application, the datatype depends on the mime type + * @param string $type specifies the mime type of the passed data + * @param string $version specifies the mime type version of the passed data + * @return integer id of the added data */ - function addData($data, $type) + function addData($data, $type, $version='') { die('call abstract method: '.__class__.'::'.__function__); } - /** - * Convert data from a mime type to another. - * - * @abstract - * @access public - * @param mixed $data data for converting, the datatype depends on the input mime type - * @param string $typeIn specifies the input mime type of the passed data - * @param string $typeOut specifies the output mime type of the passed data - * @return mixed converted data from application, the datatype depends on the passed output mime type - */ - function convertData($data, $typeIn, $typeOut) - { - die('call abstract method: '.__class__.'::'.__function__); - } /** * Checks if data for the passed id exists. - * * @abstract - * @param integer $id id to check - * @return boolean true if the data with id exist, otherwise false + * @param integer $id id to check + * @param string $type specifies the mime type of the data to check + * @return boolean true if the data with id exist, otherwise false */ - function existData($id) + function existData($id, $type='') { die('call abstract method: '.__class__.'::'.__function__); } + /** * Get data from the application in a certain mime type format. - * * @abstract - * @param integer $id id of data to get from the application - * @param string $type specifies the mime type of the returned data - * @return mixed data from application, the datatype depends on the passed mime type, false if no data exists for the passed id + * @param integer $id id of data to get from the application + * @param string $type specifies the mime type of the returned data + * @param string $version specifies the mime type version of the returned data + * @return mixed data from application, the datatype depends on the passed mime type, false if no data exists for the passed id */ - function getData($id, $type) + function getData($id, $type, $version='') { die('call abstract method: '.__class__.'::'.__function__); } + /** * Return a list with the available id's in the application. * The optional lastmod parameter allows a limitations of the data id list. * The list contains all the id's of the modified data since the passed lastmod timestamp. - * * @abstract - * @param integer $lastmod last modification time, default is -1 and means return all data id's - * @return array list of data id's + * @param integer $lastmod last modification time, default is -1 and means return all data id's + * @param string $restriction restrict the result for a special use of the id list. The possible restrictions are 'syncable' or 'searchable'. When using 'syncable' only person ids will be returned in the result. 'searchable' returns all ids for both persons and orgs without check the owner. Otherwise no restriction will be used and the result contains all ids for both persons and orgs from the owner. + * @return array list of data id's */ - function getIdList($time=-1) + function getIdList($lastmod=-1, $restriction='') { die('call abstract method: '.__class__.'::'.__function__); } + /** * Remove data of the passed id. - * * @abstract - * @param integer $id id of data to remove from the application - * @return boolean true if the data is removed, otherwise false + * @param integer $id id of data to remove from the application + * @return boolean true if the data is removed, otherwise false */ function removeData($id) { die('call abstract method: '.__class__.'::'.__function__); } + /** * Replace the existing data of the passed id with the passed data in a certain mime type format. - * * @abstract - * @param integer $id id of data to replace - * @param mixed $data the new data, the datatype depends on the passed mime type - * @param string $type specifies the mime type of the passed data - * @return boolean true if the data is replaced, otherwise false + * @param integer $id id of data to replace + * @param mixed $data the new data, the datatype depends on the passed mime type + * @param string $type specifies the mime type of the passed data + * @param string $version specifies the mime type version of the passed data (still not supported) + * @return boolean true if the data is replaced, otherwise false */ - function replaceData($id, $data, $type) + function replaceData($id, $data, $type, $version='') { die('call abstract method: '.__class__.'::'.__function__); } + + function debugLog($string, $level = 0) + { + if($level <= $this->debugLevel) + { + error_log($string); + } + } + + + /** + * Called from sync-ipc before every operation the may + * need a refsync-resolve (i.e. get, add, replace). + * + * @param $deviceid the current deviceid for obtaining the + * needed channelid's + */ + function setCurrentDeviceID($deviceid, $ipc_sync) + { + $this->deviceId = $deviceid; + $this->ipc_sync = $ipc_sync; + if(!$this->ipc_sync) + { + die('###'); + } + } + + /** + * If a mapping is created inside the sync-module which luid is equal + * to a former stored delay-resolve-entry-fkluid and the deviceid as + * long as the selfsource are equal, the sync-module calls this method + * on the corresponding ipc-implementation to let the module now resolve + * the entry. + * + * @param $deviceid the deviceid as given through ipc#setCurrentDeviceID + * @param $reqsourceuri the source-uri of this ipc-implementation + * @param $id the (gu)id of the record, which needed further resolvement + * @param $fkluid the luid, former not be resolved + * @param $fkguid the guid, now be resolved + * @param $fksourceuri the source-uri of the luid, former not be resolved + * @param $tag an identifier to uniquely mark this type of resolvement + * @return true, if the resolvement was successful, false otherwise (i.e. + * only on true, the delay-entry will be deleted.) + */ + function resolveMapping($deviceid, $reqsourceuri, $id, $fkluid, $fkguid, $fksourceuri, $tag) + { + $pk_serverid = $id; + $pk_sourcetype = $reqsourceuri; + + $fk_clientid = $fkluid; // old not resolved value + $fk_serverid = $fkguid; // new resolved value + + $fk_sourcetype = $fksourceuri; + + $resolve_tag = $tag; + + return $this->resolveData($pk_serverid, $pk_sourcetype, $fk_clientid, $fk_serverid, $fk_sourcetype, $resolve_tag); + } + + /** + * Provides the resolved value for the module + * could be overwrite in module + * + * @param $pk_serverid id of module data + * @param $pk_sourcetype sourcetype of pk data + * @param $fk_clientid the luid, old not resolved client foreign key id + * @param $fk_serverid the guid, now be resolved + * @param $fk_sourcetype the source-uri of the luid, former not be resolved + * @param $$resolve_tag an identifier to uniquely mark this type of resolvement + * @return true, if the resolvement was successful, false otherwise (i.e. + * only on true, the delay-entry will be deleted.) + */ + function resolveData($pk_serverid, $pk_sourcetype, $fk_clientid, $fk_serverid, $fk_sourcetype, $resolve_tag) + { + // check if data for $pk_serverid exists + if(!$this->existData($pk_serverid, $pk_sourcetype)) + { + return false; + } + + // read data for $pk_serverid + $data = $this->getData($pk_serverid, $pk_sourcetype); + if(!$data) + { + return false; + } + + // set resolved value + $data[$resolve_tag] = $fk_serverid; + + // save updated values + $this->replaceData($pk_serverid, $data, $pk_sourcetype); + + return true; + } + + function getServerId($clientId, $sourcetype) + { + if(!$this->ipc_sync) + { + die('###'); //return false; + } + + return $this->ipc_sync->getGUID($this->deviceId, $sourcetype, $clientId); + } + + function saveForResolve($pk_serverid, $pk_sourcetype, $fk_clientid, $fk_sourcetype, $resolve_tag) + { + if(!$this->ipc_sync) + { + die('###'); //return false; + } + + $this->ipc_sync->putUnresolvedMapping( + $this->deviceId, + $pk_sourcetype, $pk_serverid, + $fk_clientid, $fk_sourcetype, + $resolve_tag + ); + + return; + } + } ?> diff -i -u -r -d phpgw008/phpgwapi/inc/class.ipc_manager.inc.php sync_modul/phpgwapi/inc/class.ipc_manager.inc.php --- phpgw008/phpgwapi/inc/class.ipc_manager.inc.php Tue Mar 2 23:59:24 2004 +++ sync_modul/phpgwapi/inc/class.ipc_manager.inc.php Sat Oct 1 15:31:30 2005 @@ -6,191 +6,266 @@ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License * @package phpgwapi * @subpackage communication - * @version $Id: class.ipc_manager.inc.php,v 1.2.2.2 2004/02/27 23:02:05 ceb Exp $ + * @version $Id: class.ipc_manager.inc.php,v 1.2.2.2.52.13 2005/08/24 12:30:43 khofmann Exp $ */ /** * Abstract IPC Application class for the IPC Layer */ -include_class('ipc_'); + include_once('class.ipc_.inc.php'); /** * Manager of the IPC Layer * @package phpgwapi * @subpackage communication */ -class ipc_manager -{ - /** - * @var array $_ipcObjectList contains the created ipc application objects - * @access private - */ - var $_ipcObjectList; - - - var $xmlrpc_methods; - - /** - * constructor - */ - function ipc_manager() + class ipc_manager { - $this->_ipcObjectList = array(); - $this->xmlrpc_methods = array(); - $this->xmlrpc_methods[] = array( - 'name' => 'execIPC', - 'description' => 'Execute an ipc application methode' - ); - } + /** + * @var array $_ipcObjectList contains the created ipc application objects + * @access private + */ + var $_ipcObjectList; + + + /** + * @var array $xmlrpc_methods contains information for xmlrpc methods + * @access public + */ + var $xmlrpc_methods; + + /** + * constructor + */ + function ipc_manager() + { + $this->_ipcObjectList = array(); + $this->xmlrpc_methods = array(); + $this->xmlrpc_methods[] = array( + 'name' => 'execIPC', + 'description' => 'Execute an ipc application methode' + ); + } - /** - * Get the ipc application object - * - * @access public - * @param string $appName name of the application - * @return object ipc object of application - */ - function &getIPC($appName) - { - // check if app is available amd the acl run app right - if ($this->_checkIPCApp($appName) == false) - return false; + /** + * Get the ipc application object + * @param string $appName name of the application + * @param bool $checkRun if true check if application is running + * @return object ipc object of application + */ + function &getIPC($appName, $checkRun=true) + { + // check if app is available amd the acl run app right + if (!$this->_checkIPCApp($appName, $checkRun)) + { + return false; + } - // create ipc class name - $className = $this->_createIPCAppClassName($appName); - - // check if ipc app object exists - if (isset($this->_ipcObjectList[$className]) && is_object($this->_ipcObjectList[$className])) - { // return the existing ipc app object - return $this->_ipcObjectList[$className]; + // create ipc class name + $className = $this->_createIPCAppClassName($appName); + + // check if ipc app object exists + if (isset($this->_ipcObjectList[$className]) && is_object($this->_ipcObjectList[$className])) + { // return the existing ipc app object + if (!$this->_setApplicationEnvironment($appName)) + { + return false; + } + else + { + return $this->_ipcObjectList[$className]; + } + } + else + { + $obj = &CreateObject($className); + if (is_object($obj) == true) + { // save and return the created ipc app object + $this->_ipcObjectList[$className] =& $obj; + if(!$this->_setApplicationEnvironment($appName)) + { + return false; + } + else + { + return $this->_ipcObjectList[$className]; + } + } + else + { + return false; + } + } } - else + + + /** + * Destroy the ipc application object. + * @param string $appName name of application + * @return boolean true when object was destroyed, otherwise false + */ + function destroyIPC($appName) { - $obj =& CreateObject($className); - if (is_object($obj) == true) - { // save and return the created ipc app object - $this->_ipcObjectList[$className] =& $obj; - return $this->_ipcObjectList[$className]; + // create ipc class name + $className = $this->_createIPCAppClassName($appName); + + // check if ipc app object exists + if (isset($this->_ipcObjectList[$className])) + { // destroy the ipc app object + unset($this->_ipcObjectList[$className]); + return(!$this->_setApplicationEnvironment('phpgwapi')); } else { return false; } } - } - /** - * Destroy the ipc application object. - * - * @access public - * @param string $appName name of application - * @return boolean true when object was destroyed, otherwise false - */ - function destroyIPC($appName) - { - // create ipc class name - $className = $this->_createIPCAppClassName($appName); - - // check if ipc app object exists - if (isset($this->_ipcObjectList[$className]) == true) - { // destroy the ipc app object - unset($this->_ipcObjectList[$className]); - return true; - } - else + /** + * Executes a ipc method. + * @param string $ipcAppMethod name of the application and mathod to execute as '.' + * @param array $ipcAppMethodParams array with parameters for passing to the called method + * @return mixed result of execution + */ + function execIPC($ipcAppMethod, $ipcAppMethodParams=null) { - return false; + list($ipcApp, $ipcMethod) = explode('.', $ipcAppMethod); + $ipc = &$this->getIPC($ipcApp); + + if (is_object($ipc) == false) + { + return false; + } + if (method_exists($ipc, $ipcMethod) == false) + { + return false; + } + + $ipcParams = ''; + for($i=0; $i0) + { + $ipcParams .= ', '; + } + if(is_string($ipcAppMethodParams[$i]) == true) + { + $ipcParams .= '\''.$ipcAppMethodParams[$i].'\''; + } + else + { + if (is_array($ipcAppMethodParams[$i])) + { + $arrayconstructor = 'array('; + $firstentry = true; + foreach($ipcAppMethodParams[$i] as $key => $value) + { + if ($firstentry) + { + $firstentry = false; + } + else + { + $arrayconstructor .= ', '; + } + $arrayconstructor .= "'$key' => '$value'"; + } + $ipcParams .= $arrayconstructor . ')'; + } + else + { + $ipcParams .= $ipcAppMethodParams[$i]; + } + } + } + + $ipc_cmd = '$ret = $ipc->'.$ipcMethod.'('.$ipcParams.');'; + + // disabled next line because passwds are submittet as plaintext + //error_log("$ipc_cmd"); + + eval($ipc_cmd); + return $ret; } - } + /** + * Check if application is available and the acl run application right for the current user. + * @access private + * @param string $appName name of application + * @return boolean true if application is available and user has acl run right, otherwise false + */ + function _checkIPCApp($appName, $checkRun=true) + { + if ($appName == 'phpgwapi') + { + return true; + } - /** - * Executes a ipc method. - * - * @access public - * @param string $ipcAppMethod name of the application and mathod to execute as '.' - * @param array $ipcAppMethodParams array with parameters for passing to the called method - * @return mixed result of execution - */ - function execIPC($ipcAppMethod, $ipcAppMethodParams=null) - { - list($ipcApp, $ipcMethod) = explode('.', $ipcAppMethod); - $ipc =& $this->getIPC($ipcApp); - - if (is_object($ipc) == false) - return false; - - if (method_exists($ipc, $ipcMethod) == false) - return false; + if ($checkRun) + { + // 1: check if app is available + if (!isset($GLOBALS['phpgw']->applications->data[$appName])) + { + error_log('Application \'' . $appName . '\' is not available (check user configuration).'); + return false; + } - $ipcParams = ''; - for($i=0; $i0) - $ipcParams .= ', '; - if(is_string($ipcAppMethodParams[$i]) == true) - $ipcParams .= '\''.$ipcAppMethodParams[$i].'\''; - else { - if (is_array($ipcAppMethodParams[$i])) { - $arrayconstructor = 'array('; - $firstentry = true; - foreach($ipcAppMethodParams[$i] as $key => $value) { - if ($firstentry) - $firstentry = false; - else - $arrayconstructor .= ', '; - $arrayconstructor .= "$key => $value"; - } - $ipcParams .= $arrayconstructor . ')'; + // 2: check the acl run app right + if (!$GLOBALS['phpgw']->acl->check('run', 1, $appName)) + { + return false; } - else - $ipcParams .= $ipcAppMethodParams[$i]; } + + return true; } - $ipc_cmd = '$ret = $ipc->'.$ipcMethod.'('.$ipcParams.');'; - eval($ipc_cmd); - return $ret; - } - /** - * Check if application is available and the acl run application right for the current user. - * - * @access private - * @param string $appName name of application - * @return boolean true if application is available and user has acl run right, otherwise false - */ - function _checkIPCApp($appName) - { - // 1: check if app is available - if (isset($GLOBALS['phpgw']->applications->data[$appName]) == false) + /** + * Create the name of the ipc application class for the passed application name. + * @access private + * @param string $appName name of application + * @return string name of tne ipc application class + */ + function _createIPCAppClassName($appName) { - return false; + return $appName.'.ipc_'.$appName; } - // 2: check the acl run app right - if ($GLOBALS['phpgw']->acl->check('run', 1, $appName) == false) + /** + * Set application environment. + * @access private + * @param string $appName name of application + * @return boolean true if environment set, otherwise false + */ + function _setApplicationEnvironment($appName) { - return false; - } - - return true; - } + // current app + $GLOBALS['phpgw_info']['flags']['currentapp'] = $appName; + // app lang data + $GLOBALS['phpgw']->translation->add_app($appName); + + // app template dir + $tpl_root_dir = $GLOBALS['phpgw']->common->get_tpl_dir($appName); + if(!$tpl_root_dir) + { + return false; + } + else + { + if(is_object($GLOBALS['phpgw']->template)) + { + if(!$GLOBALS['phpgw']->template->set_root($tpl_root_dir)) + { + return false; + } + } + } - /** - * Create the name of the ipc application class for the passed application name. - * - * @access private - * @param string $appName name of application - * @return string name of tne ipc application class - */ - function _createIPCAppClassName($appName) - { - return $appName.'.ipc_'.$appName; + return true; + } } - -} ?> Only in phpgw008/phpgwapi/inc: class.javascript.inc.php Only in phpgw008/phpgwapi/inc: class.jscalendar.inc.php Only in phpgw008/phpgwapi/inc: class.listbox.inc.php Only in phpgw008/phpgwapi/inc: class.log.inc.php Only in phpgw008/phpgwapi/inc: class.log_message.inc.php Only in phpgw008/phpgwapi/inc: class.matrixview.inc.php Only in phpgw008/phpgwapi/inc: class.menutree.inc.php Only in phpgw008/phpgwapi/inc: class.mime_magic.inc.php Only in phpgw008/phpgwapi/inc: class.net_http_client.inc.php Only in phpgw008/phpgwapi/inc: class.network.inc.php Only in phpgw008/phpgwapi/inc: class.nextmatchs.inc.php Only in phpgw008/phpgwapi/inc: class.phpgw.inc.php Only in phpgw008/phpgwapi/inc: class.ping.inc.php Only in phpgw008/phpgwapi/inc: class.portalbox.inc.php Only in phpgw008/phpgwapi/inc: class.preferences.inc.php Only in phpgw008/phpgwapi/inc: class.resultbox.inc.php Only in phpgw008/phpgwapi/inc: class.rssparser.inc.php Only in sync_modul/phpgwapi/inc: class.s4j.inc.php Only in phpgw008/phpgwapi/inc: class.sbox.inc.php Only in phpgw008/phpgwapi/inc: class.sbox2.inc.php Only in phpgw008/phpgwapi/inc: class.schema_proc.inc.php Only in phpgw008/phpgwapi/inc: class.schema_proc_array.inc.php Only in phpgw008/phpgwapi/inc: class.schema_proc_mssql.inc.php Only in phpgw008/phpgwapi/inc: class.schema_proc_mysql.inc.php Only in phpgw008/phpgwapi/inc: class.schema_proc_pgsql.inc.php Only in phpgw008/phpgwapi/inc: class.schema_proc_sapdb.inc.php Only in phpgw008/phpgwapi/inc: class.send.inc.php Only in phpgw008/phpgwapi/inc: class.service.inc.php Only in phpgw008/phpgwapi/inc: class.service_contacts.inc.php Only in phpgw008/phpgwapi/inc: class.service_notes.inc.php Only in phpgw008/phpgwapi/inc: class.service_schedule.inc.php Only in phpgw008/phpgwapi/inc: class.sessions.inc.php Only in phpgw008/phpgwapi/inc: class.sessions_db.inc.php Only in phpgw008/phpgwapi/inc: class.sessions_php4.inc.php Only in phpgw008/phpgwapi/inc: class.setup.inc.php Only in phpgw008/phpgwapi/inc: class.setup_detection.inc.php Only in phpgw008/phpgwapi/inc: class.setup_html.inc.php Only in phpgw008/phpgwapi/inc: class.setup_process.inc.php Only in phpgw008/phpgwapi/inc: class.setup_translation.inc.php Only in phpgw008/phpgwapi/inc: class.soap_client.inc.php Only in phpgw008/phpgwapi/inc: class.soap_parser.inc.php Only in phpgw008/phpgwapi/inc: class.soap_server.inc.php Only in phpgw008/phpgwapi/inc: class.soapclient.inc.php Only in phpgw008/phpgwapi/inc: class.soapmsg.inc.php Only in phpgw008/phpgwapi/inc: class.soapval.inc.php Only in phpgw008/phpgwapi/inc: class.sql.inc.php Only in phpgw008/phpgwapi/inc: class.sql_builder.inc.php Only in phpgw008/phpgwapi/inc: class.sql_criteria.inc.php Only in phpgw008/phpgwapi/inc: class.sql_entity.inc.php Only in phpgw008/phpgwapi/inc: class.sql_mssql.inc.php Only in phpgw008/phpgwapi/inc: class.sql_mysql.inc.php Only in phpgw008/phpgwapi/inc: class.sql_pgsql.inc.php Only in phpgw008/phpgwapi/inc: class.sql_sapdb.inc.php Only in phpgw008/phpgwapi/inc: class.translation.inc.php Only in phpgw008/phpgwapi/inc: class.translation_sql.inc.php Only in phpgw008/phpgwapi/inc: class.uijsaddressbook.inc.php Only in phpgw008/phpgwapi/inc: class.utilities.inc.php Only in phpgw008/phpgwapi/inc: class.validator.inc.php diff -i -u -r -d phpgw008/phpgwapi/inc/class.vcard.inc.php sync_modul/phpgwapi/inc/class.vcard.inc.php --- phpgw008/phpgwapi/inc/class.vcard.inc.php Mon Jan 3 06:57:44 2005 +++ sync_modul/phpgwapi/inc/class.vcard.inc.php Sat Oct 1 15:31:30 2005 @@ -7,7 +7,7 @@ * @license http://www.fsf.org/licenses/lgpl.html GNU Lesser General Public License * @package phpgwapi * @subpackage network - * @version $Id: class.vcard.inc.php,v 1.4.4.9 2004/11/06 15:34:26 powerstat Exp $ + * @version $Id: class.vcard.inc.php,v 1.4.4.8.52.2 2005/03/30 13:21:38 aschiller Exp $ */ /** @@ -684,40 +684,316 @@ $entries .= 'FN;ENCODING=QUOTED-PRINTABLE:' . $fn . "\r\n"; } } - if ($org_name || $org_unit) + + if(isset($org_name) && ($org_name!='')) { + $org = $org_name; + if (isset($org_unit) && ($org_unit!='')) + $org .= $org_unit; $entries .= 'ORG;ENCODING=QUOTED-PRINTABLE:' . $org . "\r\n"; } + else + { + if(isset($org_unit) && ($org_unit!='')) + $entries .= 'ORG;ENCODING=QUOTED-PRINTABLE:' . $org_unit . "\r\n"; + } + - $workattr = ereg_replace('ADR;','',$workattr); - // remember the correct order of address fields! - $workaddr['POSTOFFICEBOX'] = $this->vCard_encode($workaddr['POSTOFFICEBOX'], 'QUOTED-PRINTABLE', false); - $workaddr['EXT'] = $this->vCard_encode($workaddr['EXT'], 'QUOTED-PRINTABLE', false); - $workaddr['STREET'] = $this->vCard_encode($workaddr['STREET'], 'QUOTED-PRINTABLE', false); - $workaddr['LOCALITY'] = $this->vCard_encode($workaddr['LOCALITY'], 'QUOTED-PRINTABLE', false); - $workaddr['REGION'] = $this->vCard_encode($workaddr['REGION'], 'QUOTED-PRINTABLE', false); - $workaddr['POSTALCODE'] = $this->vCard_encode($workaddr['POSTALCODE'], 'QUOTED-PRINTABLE', false); - $workaddr['COUNTRYNAME'] = $this->vCard_encode($workaddr['COUNTRYNAME'], 'QUOTED-PRINTABLE', false); - $workaddr = $workaddr['POSTOFFICEBOX'].';'.$workaddr['EXT'].';'.$workaddr['STREET'].';'.$workaddr['LOCALITY'].';'.$workaddr['REGION'].';'.$workaddr['POSTALCODE'].';'.$workaddr['COUNTRYNAME']; - $work = 'A.ADR;' . $workattr . ';ENCODING=QUOTED-PRINTABLE:' . $workaddr . "\r\n"; - $wlabel = 'LABEL;TYPE=WORK;;ENCODING=QUOTED-PRINTABLE:' . $wlabel . "\r\n"; + if(isset($workaddr) && is_array($workaddr)) + { + $workattr = ereg_replace('ADR;','',$workattr); + // remember the correct order of address fields! + $workaddr['POSTOFFICEBOX'] = $this->vCard_encode($workaddr['POSTOFFICEBOX'], 'QUOTED-PRINTABLE', false); + $workaddr['EXT'] = $this->vCard_encode($workaddr['EXT'], 'QUOTED-PRINTABLE', false); + $workaddr['STREET'] = $this->vCard_encode($workaddr['STREET'], 'QUOTED-PRINTABLE', false); + $workaddr['LOCALITY'] = $this->vCard_encode($workaddr['LOCALITY'], 'QUOTED-PRINTABLE', false); + $workaddr['REGION'] = $this->vCard_encode($workaddr['REGION'], 'QUOTED-PRINTABLE', false); + $workaddr['POSTALCODE'] = $this->vCard_encode($workaddr['POSTALCODE'], 'QUOTED-PRINTABLE', false); + $workaddr['COUNTRYNAME'] = $this->vCard_encode($workaddr['COUNTRYNAME'], 'QUOTED-PRINTABLE', false); + $workaddr = $workaddr['POSTOFFICEBOX'].';'.$workaddr['EXT'].';'.$workaddr['STREET'].';'.$workaddr['LOCALITY'].';'.$workaddr['REGION'].';'.$workaddr['POSTALCODE'].';'.$workaddr['COUNTRYNAME']; + if (strlen($workaddr) > 6) + $work = 'A.ADR;' . $workattr . ';ENCODING=QUOTED-PRINTABLE:' . $workaddr . "\r\n"; + else + $work = ''; + $wlabel = 'LABEL;TYPE=WORK;ENCODING=QUOTED-PRINTABLE:' . $wlabel . "\r\n"; + } - $homeattr = ereg_replace('ADR;','',$homeattr); - // remember the correct order of address fields! - $homeaddr['POSTOFFICEBOX'] = $this->vCard_encode($homeaddr['POSTOFFICEBOX'], 'QUOTED-PRINTABLE', false); - $homeaddr['EXT'] = $this->vCard_encode($homeaddr['EXT'], 'QUOTED-PRINTABLE', false); - $homeaddr['STREET'] = $this->vCard_encode($homeaddr['STREET'], 'QUOTED-PRINTABLE', false); - $homeaddr['LOCALITY'] = $this->vCard_encode($homeaddr['LOCALITY'], 'QUOTED-PRINTABLE', false); - $homeaddr['REGION'] = $this->vCard_encode($homeaddr['REGION'], 'QUOTED-PRINTABLE', false); - $homeaddr['POSTALCODE'] = $this->vCard_encode($homeaddr['POSTALCODE'], 'QUOTED-PRINTABLE', false); - $homeaddr['COUNTRYNAME'] = $this->vCard_encode($homeaddr['COUNTRYNAME'], 'QUOTED-PRINTABLE', false); - $homeaddr = $homeaddr['POSTOFFICEBOX'].';'.$homeaddr['EXT'].';'.$homeaddr['STREET'].';'.$homeaddr['LOCALITY'].';'.$homeaddr['REGION'].';'.$homeaddr['POSTALCODE'].';'.$homeaddr['COUNTRYNAME']; - $home = 'B.ADR;' . $homeattr . ';ENCODING=QUOTED-PRINTABLE:' . $homeaddr . "\r\n"; - $hlabel = 'LABEL;TYPE=HOME;;ENCODING=QUOTED-PRINTABLE:' . $hlabel . "\r\n"; + if(isset($homeaddr) && is_array($homeaddr)) + { + $homeattr = ereg_replace('ADR;','',$homeattr); + // remember the correct order of address fields! + $homeaddr['POSTOFFICEBOX'] = $this->vCard_encode($homeaddr['POSTOFFICEBOX'], 'QUOTED-PRINTABLE', false); + $homeaddr['EXT'] = $this->vCard_encode($homeaddr['EXT'], 'QUOTED-PRINTABLE', false); + $homeaddr['STREET'] = $this->vCard_encode($homeaddr['STREET'], 'QUOTED-PRINTABLE', false); + $homeaddr['LOCALITY'] = $this->vCard_encode($homeaddr['LOCALITY'], 'QUOTED-PRINTABLE', false); + $homeaddr['REGION'] = $this->vCard_encode($homeaddr['REGION'], 'QUOTED-PRINTABLE', false); + $homeaddr['POSTALCODE'] = $this->vCard_encode($homeaddr['POSTALCODE'], 'QUOTED-PRINTABLE', false); + $homeaddr['COUNTRYNAME'] = $this->vCard_encode($homeaddr['COUNTRYNAME'], 'QUOTED-PRINTABLE', false); + $homeaddr = $homeaddr['POSTOFFICEBOX'].';'.$homeaddr['EXT'].';'.$homeaddr['STREET'].';'.$homeaddr['LOCALITY'].';'.$homeaddr['REGION'].';'.$homeaddr['POSTALCODE'].';'.$homeaddr['COUNTRYNAME']; + if (strlen($homeaddr) > 6) + $home = 'B.ADR;' . $homeattr . ';ENCODING=QUOTED-PRINTABLE:' . $homeaddr . "\r\n"; + else + $home = ''; + $hlabel = 'LABEL;TYPE=HOME;ENCODING=QUOTED-PRINTABLE:' . $hlabel . "\r\n"; + } $entries = ereg_replace('PUBKEY','KEY',$entries); $entries .= $work . $home . $wlabel . $hlabel . 'END:VCARD' . "\r\n"; $entries .= "\r\n"; + + $buffer = $entries; + return $buffer; + } //end function + + + function out_version_30($buffer) + { + $entry = ''; + $header = 'BEGIN:VCARD' . "\r\n"; + $header .= 'VERSION:3.0' . "\r\n"; + $header .= 'X-PHPGROUPWARE-FILE-AS:phpGroupWare.org' . "\r\n"; + + $workaddr = $hoeaddr = $this->address; + + reset($this->export); + while ( list($name,$value) = each($this->export) ) + { + if (!empty($buffer[$value])) + { + $mult = explode(';',$value); + if (!$mult[1]) + { // Normal + if (strstr($buffer[$value],"\r\n") || strstr($buffer[$value],"\n") || (strtoupper($mult[0])=='FN')) + { + $buffer[$value] = $this->vCard_encode($buffer[$value], false, 'UTF-8'); + $entry .= $value . ':' . $buffer[$value] . "\r\n"; + } + else + { + $entry .= $value . ':' . $buffer[$value] . "\r\n"; + } + } + else + { + switch ($mult[0]) + { + case 'N': + switch ($mult[1]) + { + case 'PREFIX': + $prefix = ';' . $this->vCard_encode($buffer[$value], false, 'UTF-8'); + break; + case 'GIVEN': + $firstname = ';' . $this->vCard_encode($buffer[$value], false, 'UTF-8'); + break; + case 'MIDDLE': + $middle = ';' . $this->vCard_encode($buffer[$value], false, 'UTF-8'); + break; + case 'FAMILY': + $lastname = $this->vCard_encode($buffer[$value], false, 'UTF-8'); + break; + case 'SUFFIX': + $suffix = ';' . $this->vCard_encode($buffer[$value], false, 'UTF-8'); + break; + } + break; + case 'ORG': + switch ($mult[1]) + { + case 'NAME': + $org_name = $this->vCard_encode($buffer[$value], false, 'UTF-8'); + break; + case 'UNIT': + $org_unit = ';' . $this->vCard_encode($buffer[$value], false, 'UTF-8'); + break; + } + break; + case 'ADR': + switch ($mult[1]) + { + case 'TYPE': + if(isset($typei[$mult[2]])) + { + $typei[$mult[2]] .= ';'; + } + + $types = explode(';',$buffer[$value]); + if ($types[1]) + { + $typei[$mult[2]] .= strtoupper($types[0][1]); + for ($i=1; $i'; + $entry .= $mult[0] . ';' . $mult[1] . $prefi[$mult[1]] . ':' . $buffer[$value] . "\r\n"; + break; + } + break; + case 'EMAIL': + switch($mult[1]) + { + case 'TYPE': + if ($mult[2] == 'WORK') { $emailtype = ';' . $buffer[$value]; } + if ($mult[2] == 'HOME') { $hemailtype = ';' . $buffer[$value]; } + break; + case 'WORK': + //$newval = 'A.'.$value; + $newval = ''.$value; + $entry .= $newval . $emailtype . ':' . $buffer[$value] . "\r\n"; + break; + case 'HOME': + //$newval = 'B.' . $value; + $newval = '' . $value; + $entry .= $newval . $hemailtype . ':' . $buffer[$value] . "\r\n"; + break; + default: + break; + } + break; + default: + break; + } //end switch ($mult[0]) + } //end else + } //end if (!empty) + } //end while + + $entries .= $header; + + if(!$middle) + { + $middle = ';'; + } + + if(!$prefix) + { + $prefix = ';'; + } + + $n = $lastname . $firstname . $middle . $prefix . $suffix; + $entries .= 'N:' . $n . "\r\n"; + $entries .= $entry; + + if (!$buffer['FN']) + { + if ($lastname || $firstname) + { + $fn = substr($firstname,1) . ' ' . $lastname; + $entries .= 'FN:' . $fn . "\r\n"; + } + } + + if(isset($org_name) && ($org_name!='')) + { + $org = $org_name; + if (isset($org_unit) && ($org_unit!='')) + $org .= $org_unit; + $entries .= 'ORG:' . $this->vCard_encod