From bbbd26dc4beca887b953180d7a6ee05b17717dbd Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Sun, 22 Feb 2004 15:18:36 +0000 Subject: [PATCH] Add initial framework for alternate contact types (not enabled), cleanup formatting --- addressbook/inc/class.boXport.inc.php | 4 + addressbook/inc/class.boaddressbook.inc.php | 148 +++++++++++--------- addressbook/inc/class.pdb.inc.php | 22 +-- addressbook/inc/class.uiXport.inc.php | 12 +- addressbook/inc/class.uiaddressbook.inc.php | 50 +++++-- addressbook/inc/class.uifields.inc.php | 2 +- addressbook/templates/default/index.tpl | 4 + 7 files changed, 144 insertions(+), 98 deletions(-) diff --git a/addressbook/inc/class.boXport.inc.php b/addressbook/inc/class.boXport.inc.php index 630c2a9e8f..07f4e0ad45 100644 --- a/addressbook/inc/class.boXport.inc.php +++ b/addressbook/inc/class.boXport.inc.php @@ -136,6 +136,10 @@ if($tsvfile['type'] == 'application/zip') { + if(!@function_exists('zip_open')) + { + return False; + } $fp = $this->unzip($tsvfile['tmp_name'],$contacts->type); } else diff --git a/addressbook/inc/class.boaddressbook.inc.php b/addressbook/inc/class.boaddressbook.inc.php index f58a9f2ab4..a329d6ff20 100644 --- a/addressbook/inc/class.boaddressbook.inc.php +++ b/addressbook/inc/class.boaddressbook.inc.php @@ -82,15 +82,15 @@ $this->use_session = True; } /* _debug_array($_POST); */ - /* Might change this to '' at the end---> */ $_start = get_var('start',array('POST','GET')); $_query = get_var('query',array('POST','GET'),'_UNSET_'); $_cquery = get_var('cquery', array('GET','POST'),'_UNSET_'); $_sort = get_var('sort',array('POST','GET')); $_order = get_var('order',array('POST','GET')); $_filter = get_var('filter',array('POST','GET')); - $_cat_id = get_var('cat_id',array('POST','GET')); +// $_cat_id = get_var('cat_id',array('POST','GET')); $_fcat_id = get_var('fcat_id',array('POST','GET')); + $_typeid = get_var('typeid',array('POST','GET'),'_UNSET_'); if(!empty($_start) || ($_start == '0') || ($_start == 0)) { @@ -111,6 +111,15 @@ $this->cquery = $_cquery; } + if($_typeid != '_UNSET_') + { + $this->typeid = $_typeid; + } + if(!@in_array($this->typeid,array('n','c'))) + { + $this->typeid = 'n'; + } + if(isset($_POST['fcat_id']) || isset($_POST['fcat_id'])) { $this->cat_id = $_fcat_id; @@ -120,6 +129,17 @@ $this->cat_id = -1; } + /* + if(isset($_POST['typeid']) || isset($_POST['typeid'])) + { + $this->typeid = $typeid; + } + else + { + $this->typeid = 'n'; + } + */ + if(isset($_sort) && !empty($_sort)) { if($this->debug) { echo '
overriding $sort: "' . $this->sort . '" now "' . $_sort . '"'; } @@ -139,11 +159,6 @@ } if($this->debug) { $this->_debug_sqsof(); } - - $this->xmlrpc_methods[] = array( - 'name' => 'read_entries', - 'description' => 'Get list of addressbook items' - ); } function _debug_sqsof() @@ -156,69 +171,13 @@ 'sort' => $this->sort, 'order' => $this->order, 'filter' => $this->filter, - 'cat_id' => $this->cat_id + 'cat_id' => $this->cat_id, + 'typeid' => $this->typeid ); echo '
BO:'; _debug_array($data); } - function list_methods($_type='xmlrpc') - { - /* - This handles introspection or discovery by the logged in client, - in which case the input might be an array. The server always calls - this function to fill the server dispatch map using a string. - */ - if(is_array($_type)) - { - $_type = $_type['type'] ? $_type['type'] : $_type[0]; - } - switch($_type) - { - case 'xmlrpc': - $xml_functions = array( - 'read' => array( - 'function' => 'read_entry', - 'signature' => array(array(xmlrpcStruct,xmlrpcStruct)), - 'docstring' => lang('Read a single entry by passing the id and fieldlist.') - ), - 'add' => array( - 'function' => 'add_entry', - 'signature' => array(array(xmlrpcStruct,xmlrpcStruct)), - 'docstring' => lang('Add a single entry by passing the fields.') - ), - 'save' => array( - 'function' => 'update_entry', - 'signature' => array(array(xmlrpcStruct,xmlrpcStruct)), - 'docstring' => lang('Update a single entry by passing the fields.') - ), - 'delete' => array( - 'function' => 'delete_entry', - 'signature' => array(array(xmlrpcInt,xmlrpcInt)), - 'docstring' => lang('Delete a single entry by passing the id.') - ), - 'read_list' => array( - 'function' => 'read_entries', - 'signature' => array(array(xmlrpcStruct,xmlrpcStruct)), - 'docstring' => lang('Read a list of entries.') - ), - 'list_methods' => array( - 'function' => 'list_methods', - 'signature' => array(array(xmlrpcStruct,xmlrpcString)), - 'docstring' => lang('Read this list of methods.') - ) - ); - return $xml_functions; - break; - case 'soap': - return $this->soap_functions; - break; - default: - return array(); - break; - } - } - function save_sessiondata($data) { if($this->use_session) @@ -241,6 +200,7 @@ $this->order = $data['order']; $this->filter = $data['filter']; $this->cat_id = $data['cat_id']; + $this->typeid = $data['typeid']; if($this->debug) { echo '
read_sessiondata();'; $this->_debug_sqsof(); } } @@ -465,5 +425,63 @@ $GLOBALS['phpgw']->preferences->save_repository(True); } + + function list_methods($_type='xmlrpc') + { + /* + This handles introspection or discovery by the logged in client, + in which case the input might be an array. The server always calls + this function to fill the server dispatch map using a string. + */ + if(is_array($_type)) + { + $_type = $_type['type'] ? $_type['type'] : $_type[0]; + } + switch($_type) + { + case 'xmlrpc': + $xml_functions = array( + 'read' => array( + 'function' => 'read_entry', + 'signature' => array(array(xmlrpcStruct,xmlrpcStruct)), + 'docstring' => lang('Read a single entry by passing the id and fieldlist.') + ), + 'add' => array( + 'function' => 'add_entry', + 'signature' => array(array(xmlrpcStruct,xmlrpcStruct)), + 'docstring' => lang('Add a single entry by passing the fields.') + ), + 'save' => array( + 'function' => 'update_entry', + 'signature' => array(array(xmlrpcStruct,xmlrpcStruct)), + 'docstring' => lang('Update a single entry by passing the fields.') + ), + 'delete' => array( + 'function' => 'delete_entry', + 'signature' => array(array(xmlrpcInt,xmlrpcInt)), + 'docstring' => lang('Delete a single entry by passing the id.') + ), + 'read_list' => array( + 'function' => 'read_entries', + 'signature' => array(array(xmlrpcStruct,xmlrpcStruct)), + 'docstring' => lang('Read a list of entries.') + ), + 'list_methods' => array( + 'function' => 'list_methods', + 'signature' => array(array(xmlrpcStruct,xmlrpcString)), + 'docstring' => lang('Read this list of methods.') + ) + ); + return $xml_functions; + break; + case 'soap': + return $this->soap_functions; + break; + default: + return array(); + break; + } + } + } ?> diff --git a/addressbook/inc/class.pdb.inc.php b/addressbook/inc/class.pdb.inc.php index 7443fd2bb3..8b125c1133 100644 --- a/addressbook/inc/class.pdb.inc.php +++ b/addressbook/inc/class.pdb.inc.php @@ -3,12 +3,12 @@ * eGroupWare API - Palm Database Access * * This file written by Miles Lott * * Access to palm OS database structures (?) * - * -------------------------------------------------------------------------* + * ------------------------------------------------------------------------ * * Portions of code from ToPTIP * * Copyright (C) 2000-2001 Pierre Dittgen * * This file is a translation of the txt2pdbdoc tool * * written in C Paul J. Lucas (plj@best.com) * - * -------------------------------------------------------------------------* + * ------------------------------------------------------------------------ * * This library may be part of the eGroupWare API * * ------------------------------------------------------------------------ * * This library is free software; you can redistribute it and/or modify it * @@ -45,7 +45,7 @@ */ function int2($value) { - return sprintf("%c%c", $value / 256, $value % 256); + return sprintf("%c%c", $value / 256, $value % 256); } /** @@ -53,7 +53,7 @@ */ function int4($value) { - for ($i=0; $i<4; $i++) + for($i=0; $i<4; $i++) { $b[$i] = $value % 256; $value = (int)(($value - $b[$i]) / 256); @@ -69,14 +69,14 @@ { // ============ File header ========================================= // Title of the document, it's limited to 31 characters - if (strlen($title) > 31) + if(strlen($title) > 31) { $title = substr($title, 0, 31); } fwrite($fd, $title); // Completion with null '\0' characters - for ($i=0; $i<32-strlen($title); $i++) + for($i=0; $i<32-strlen($title); $i++) { fwrite($fd, sprintf("%c", 0), 1); } @@ -107,7 +107,7 @@ $full_tr = (int)($content_length / $this->record_size); $notfull_tr = $content_length % $this->record_size; $num_records = $full_tr; - if ($notfull_tr != 0) + if($notfull_tr != 0) { $num_records++; } @@ -124,7 +124,7 @@ fwrite($fd, $this->int4($index++)); $val = 110 + ($num_offsets - 2) * 8; - while (--$num_offsets != 0) + while(--$num_offsets != 0) { fwrite($fd, $this->int4($val)); $val += 4096; @@ -171,7 +171,7 @@ $title = fread(31,$fd); // Completion with null '\0' characters - for ($i=0; $i<32-strlen($title); $i++) + for($i=0; $i<32-strlen($title); $i++) { fwrite($fd, sprintf("%c", 0), 1); } @@ -202,7 +202,7 @@ $full_tr = (int)($content_length / $this->record_size); $notfull_tr = $content_length % $this->record_size; $num_records = $full_tr; - if ($notfull_tr != 0) + if($notfull_tr != 0) { $num_records++; } @@ -219,7 +219,7 @@ fwrite($fd, $this->int4($index++)); $val = 110 + ($num_offsets - 2) * 8; - while (--$num_offsets != 0) + while(--$num_offsets != 0) { fwrite($fd, $this->int4($val)); $val += 4096; diff --git a/addressbook/inc/class.uiXport.inc.php b/addressbook/inc/class.uiXport.inc.php index fbf2dd4c1c..b1003151af 100644 --- a/addressbook/inc/class.uiXport.inc.php +++ b/addressbook/inc/class.uiXport.inc.php @@ -157,7 +157,7 @@ $i=0; $myfilearray = ''; while($file = readdir($dir_handle)) { - if((substr($file, 0, 1) != '.') && is_file(PHPGW_APP_INC . SEP . 'import' . SEP . $file) ) + if((substr($file, 0, 1) != '.') && is_file(PHPGW_APP_INC . SEP . 'import' . SEP . $file)) { $myfilearray[$i] = $file; $i++; @@ -191,14 +191,12 @@ $this->template->set_var('query',$this->query); $this->template->set_var('cat_id',$this->cat_id); $this->template->set_var('lang_import_instructions',lang('import_instructions')); + $this->template->set_var('zip_note',''); if(extension_loaded('zip')) { $this->template->set_var('zip_note',lang('zip_note')); } - else - { - $this->template->set_var('zip_note',''); - } + $this->template->set_var('lang_exported_file',lang('enter the path to the exported file here')); $this->template->set_var('lang_conv_type',lang('select the type of conversion')); $this->template->set_var('lang_mark_priv',lang('Mark records as private')); @@ -232,7 +230,7 @@ $buffer = $this->bo->export($conv_type,$cat_id); - if(($download == 'on') || ($conv_type == 'Palm_PDB') ) + if(($download == 'on') || ($conv_type == 'Palm_PDB')) { // filename, default application/octet-stream, length of file, default nocache True $this->browser->content_header($tsvfilename,'application/x-octet-stream',strlen($buffer)); @@ -262,7 +260,7 @@ $i=0; $myfilearray = ''; while($file = readdir($dir_handle)) { - if((substr($file, 0, 1) != '.') && is_file(PHPGW_APP_INC . SEP . 'export' . SEP . $file) ) + if((substr($file, 0, 1) != '.') && is_file(PHPGW_APP_INC . SEP . 'export' . SEP . $file)) { $myfilearray[$i] = $file; $i++; diff --git a/addressbook/inc/class.uiaddressbook.inc.php b/addressbook/inc/class.uiaddressbook.inc.php index c9dae9e889..161484a33e 100644 --- a/addressbook/inc/class.uiaddressbook.inc.php +++ b/addressbook/inc/class.uiaddressbook.inc.php @@ -48,6 +48,15 @@ 'address3' => 'address3' ); + var $contact_types = array( + 'n' => 'People', + 'c' => 'Companies' + ); + var $contact_type = array( + 'n' => 'Person', + 'c' => 'Company' + ); + function uiaddressbook() { $GLOBALS['phpgw']->country = CreateObject('phpgwapi.country'); @@ -65,14 +74,15 @@ function _set_sessiondata() { - $this->start = $this->bo->start; - $this->limit = $this->bo->limit; - $this->query = $this->bo->query; - $this->cquery = $this->bo->cquery; - $this->sort = $this->bo->sort; - $this->order = $this->bo->order; - $this->filter = $this->bo->filter; - $this->cat_id = $this->bo->cat_id; + $this->start = $this->bo->start; + $this->limit = $this->bo->limit; + $this->query = $this->bo->query; + $this->cquery = $this->bo->cquery; + $this->sort = $this->bo->sort; + $this->order = $this->bo->order; + $this->filter = $this->bo->filter; + $this->cat_id = $this->bo->cat_id; + $this->typeid = $this->bo->typeid; if($this->debug) { $this->_debug_sqsof(); } } @@ -86,7 +96,8 @@ 'sort' => $this->sort, 'order' => $this->order, 'filter' => $this->filter, - 'cat_id' => $this->cat_id + 'cat_id' => $this->cat_id, + 'typeid' => $this->typeid ); echo '
UI:'; _debug_array($data); @@ -103,7 +114,8 @@ 'sort' => $this->sort, 'order' => $this->order, 'filter' => $this->filter, - 'cat_id' => $this->cat_id + 'cat_id' => $this->cat_id, + 'typeid' => $this->typeid ); $this->bo->save_sessiondata($data); } @@ -120,7 +132,7 @@ { $select .= ''."\n"; } -// while(list($key,$val) = each($list)) + settype($list,'array'); foreach($list as $key => $val) { $select .= '