diff --git a/addressbook/inc/class.addressbook_bo.inc.php b/addressbook/inc/class.addressbook_bo.inc.php index eedeabce29..09666f9de9 100755 --- a/addressbook/inc/class.addressbook_bo.inc.php +++ b/addressbook/inc/class.addressbook_bo.inc.php @@ -14,6 +14,7 @@ */ use EGroupware\Api; +use EGroupware\Api\Acl; /** * Business object for addressbook @@ -126,7 +127,7 @@ class addressbook_bo extends Api\Contacts $result = self::get_pgp_keyserver($missing, $result); } //error_log(__METHOD__."(".array2string($recipients).") returning ".array2string($result)); - egw_json_response::get()->data($result); + Api\Json\Response::get()->data($result); } /** @@ -191,7 +192,7 @@ class addressbook_bo extends Api\Contacts { $contact['pubkey'] = preg_replace(self::$pgp_key_regexp, $key, $contact['pubkey']); } - if ($this->check_perms(EGW_ACL_EDIT, $contact) && $this->save($contact)) + if ($this->check_perms(Acl::EDIT, $contact) && $this->save($contact)) { ++$updated; } @@ -209,7 +210,7 @@ class addressbook_bo extends Api\Contacts $message .= "\n".lang('%1 key(s) added to public keyserver "%2".', self::set_pgp_keyserver($keys), PARSE_URL(self::KEYSERVER_ADD, PHP_URL_HOST)); - egw_json_response::get()->data($message); + Api\Json\Response::get()->data($message); } /** diff --git a/addressbook/inc/class.addressbook_contactform.inc.php b/addressbook/inc/class.addressbook_contactform.inc.php index 860af85663..dadcc422bb 100644 --- a/addressbook/inc/class.addressbook_contactform.inc.php +++ b/addressbook/inc/class.addressbook_contactform.inc.php @@ -11,6 +11,8 @@ */ use EGroupware\Api; +use EGroupware\Api\Link; +use EGroupware\Api\Vfs; /** * SiteMgr contact form for the addressbook @@ -92,9 +94,9 @@ class addressbook_contactform // the anonymous user to have run rights for addressbook AND // edit rights for the addressbook used to store the new entry, // which is clearly not wanted securitywise - Api\Vfs::$is_root = true; - egw_link::link('addressbook',$id,egw_link::VFS_APPNAME,$value,$name); - Api\Vfs::$is_root = false; + Vfs::$is_root = true; + Link::link('addressbook',$id,Link::VFS_APPNAME,$value,$name); + Vfs::$is_root = false; } } diff --git a/addressbook/inc/class.addressbook_display.inc.php b/addressbook/inc/class.addressbook_display.inc.php index f5650e91aa..145191129a 100755 --- a/addressbook/inc/class.addressbook_display.inc.php +++ b/addressbook/inc/class.addressbook_display.inc.php @@ -10,26 +10,15 @@ * @version $Id: class.addressbook_display.inc.php 24099 2008-02-18 16:29:06Z stefanbecker $ */ +use EGroupware\Api; + /** * SiteMgr Display form for the addressbook * */ class addressbook_display extends addressbook_ui { - /** - * Shows the Addressbook Entry and stores the submitted data - * - * @param array $content=null submitted eTemplate content - * @param int $addressbook=null int owner-id of addressbook to save contacts too - * @param array $fields=null field-names to show - * @param string $msg=null message to show after submitting the form - * @param string $email=null comma-separated email addresses - * @param string $tpl_name=null custom etemplate to use - * @param string $subject=null subject for email - * @return string html content - */ - // -function get_rows(&$query,&$rows,&$readonlys,$id_only=false) + function get_rows(&$query,&$rows,&$readonlys) { $query['sitemgr_display'] = ($readonlys['sitemgr_display'] ?$readonlys['sitemgr_display']:'addressbook.display'); $total = parent::get_rows($query,$rows,$readonlys); @@ -44,6 +33,18 @@ function get_rows(&$query,&$rows,&$readonlys,$id_only=false) } + /** + * Shows the Addressbook Entry and stores the submitted data + * + * @param array $content =null submitted eTemplate content + * @param int $addressbook =null int owner-id of addressbook to save contacts too + * @param array $fields =null field-names to show + * @param string $msg =null message to show after submitting the form + * @param string $email =null comma-separated email addresses + * @param string $tpl_name =null custom etemplate to use + * @param string $subject =null subject for email + * @return string html content + */ function display($content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null) { $tpl_name=($tpl_name ? $tpl_name : 'addressbook.display'); @@ -52,7 +53,7 @@ function get_rows(&$query,&$rows,&$readonlys,$id_only=false) $content = array( 'msg' => $msg ? $msg : $_GET['msg'], ); - $content['nm1'] = $GLOBALS['egw']->session->appsession(($tpl_name ? $tpl_name : 'index'),'addressbook'); + $content['nm1'] = Api\Cache::getSession('addressbook', ($tpl_name ? $tpl_name : 'index')); $readonlys['sitemgr_display']=$tpl_name; if (!is_array($content['nm1'])) { diff --git a/addressbook/inc/class.addressbook_egw_record.inc.php b/addressbook/inc/class.addressbook_egw_record.inc.php index 66d48e6b89..4a98a895b1 100644 --- a/addressbook/inc/class.addressbook_egw_record.inc.php +++ b/addressbook/inc/class.addressbook_egw_record.inc.php @@ -11,6 +11,9 @@ * @version $Id$ */ +use EGroupware\Api; +use EGroupware\Api\Framework; + /** * class addressbook_egw_record * compability layer for iface_egw_record needed for importexport @@ -44,7 +47,7 @@ class addressbook_egw_record implements importexport_iface_egw_record */ public function __construct( $_identifier='' ){ $this->identifier = $_identifier; - $this->bocontacts = new addressbook_bo(); + $this->bocontacts = new Api\Contacts(); if($_identifier) { $this->contact = $this->bocontacts->read($this->identifier); } @@ -123,7 +126,7 @@ class addressbook_egw_record implements importexport_iface_egw_record $ui->type_icon($this->owner, $this->private, $this->tid, $icon, $label); // Specific photo - return $this->jpegphoto ? egw_framework::link('/index.php',$ui->photo_src($this->identifier,$this->jpegphoto)):$icon; + return $this->jpegphoto ? Framework::link('/index.php',$ui->photo_src($this->identifier,$this->jpegphoto)):$icon; } /** * saves record into backend @@ -171,5 +174,4 @@ class addressbook_egw_record implements importexport_iface_egw_record public function __destruct() { unset ($this->bocontacts); } - -} // end of egw_addressbook_record +} diff --git a/addressbook/inc/class.addressbook_export_contacts_csv.inc.php b/addressbook/inc/class.addressbook_export_contacts_csv.inc.php index 4931da1898..c735d49275 100644 --- a/addressbook/inc/class.addressbook_export_contacts_csv.inc.php +++ b/addressbook/inc/class.addressbook_export_contacts_csv.inc.php @@ -1,6 +1,6 @@ export_limit = $export_limit; // we may not need that after all if($export_limit == 'no' && !$limit_exception) { return; @@ -57,11 +59,12 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi if ($options['selection'] == 'search') { // uicontacts selection with checkbox 'use_all' - $query = $GLOBALS['egw']->session->appsession('index','addressbook'); + $query = Api\Cache::getSession('addressbook', 'index'); $query['num_rows'] = -1; // all $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session $query['order'] = 'contact_id'; if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id']; + $readonlys = null; $this->ui->get_rows($query,$selection,$readonlys, true); // only return the ids } elseif ( $options['selection'] == 'all' ) { @@ -73,9 +76,7 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi } elseif ($options['selection'] == 'filter') { - $fields = importexport_helper_functions::get_filter_fields($_definition->application, $this); $filter = $_definition->filter; - $known_fields = $this->ui->get_fields('supported'); $query = array(); // Handle ranges @@ -125,14 +126,14 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi } $GLOBALS['egw_info']['flags']['currentapp'] = $old_app; - if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) { + if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) { $selection = array_slice($selection, 0, $export_limit); } if($options['explode_multiselects']) { - $customfields = config::get_customfields('addressbook'); + $customfields = Api\Storage\Customfields::get('addressbook'); $additional_fields = array(); - $cat_obj = new categories('', 'addressbook'); + $cat_obj = new Api\Categories('', 'addressbook'); foreach($options['explode_multiselects'] as $field => $explode) { switch($explode['explode']) { case self::MAIN_CATS: @@ -241,7 +242,7 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi } $export_object->set_mapping($options['mapping']); - + // Add in last/next event, if needed if($options['mapping']['last_date'] || $options['mapping']['next_date']) { @@ -439,7 +440,7 @@ class addressbook_export_contacts_csv implements importexport_iface_export_plugi 'type' => 'select', 'rows' => 5, 'tags' => true, - 'values' => $this->ui->get_addressbooks(EGW_ACL_READ) + 'values' => $this->ui->get_addressbooks(Acl::READ) ); } } diff --git a/addressbook/inc/class.addressbook_export_vcard.inc.php b/addressbook/inc/class.addressbook_export_vcard.inc.php index 8ae8b19865..ce3b30c17a 100644 --- a/addressbook/inc/class.addressbook_export_vcard.inc.php +++ b/addressbook/inc/class.addressbook_export_vcard.inc.php @@ -1,6 +1,6 @@ selection = array(); // Addressbook defines its own export imits - $limit_exception = bo_merge::is_export_limit_excepted(); - $export_limit = bo_merge::getExportLimit($app='addressbook'); - if (!$limit_exception) $export_object->export_limit = $export_limit; // we may not need that after all + $limit_exception = Api\Storage\Merge::is_export_limit_excepted(); + $export_limit = Api\Storage\Merge::getExportLimit($app='addressbook'); if($export_limit == 'no' && !$limit_exception) { return; } @@ -42,10 +43,11 @@ class addressbook_export_vcard implements importexport_iface_export_plugin { if ($options['selection'] == 'search') { // uicontacts selection with checkbox 'use_all' - $query = $GLOBALS['egw']->session->appsession('index','addressbook'); + $query = Api\Cache::getSession('addressbook', 'index'); $query['num_rows'] = -1; // all $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id']; + $readonlys = null; $this->uicontacts->get_rows($query,$this->selection,$readonlys, true); // only return the ids } elseif ( $options['selection'] == 'all' ) { @@ -59,7 +61,7 @@ class addressbook_export_vcard implements importexport_iface_export_plugin { } $GLOBALS['egw_info']['flags']['currentapp'] = $old_app; - if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) { + if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) { $this->selection = array_slice($this->selection, 0, $export_limit); } @@ -69,7 +71,7 @@ class addressbook_export_vcard implements importexport_iface_export_plugin { $_contact = $_contact[$_contact['id'] ? 'id' : 'contact_id']; } } - + // vCard opens & closes the resource itself, but this doesn't seem to matter $meta = stream_get_meta_data($_stream); diff --git a/addressbook/inc/class.addressbook_groupdav.inc.php b/addressbook/inc/class.addressbook_groupdav.inc.php index 7b8715ad3b..d8de480b94 100644 --- a/addressbook/inc/class.addressbook_groupdav.inc.php +++ b/addressbook/inc/class.addressbook_groupdav.inc.php @@ -12,6 +12,7 @@ */ use EGroupware\Api; +use EGroupware\Api\Acl; /** * CalDAV/CardDAV/GroupDAV access: Addressbook handler @@ -237,7 +238,7 @@ class addressbook_groupdav extends Api\CalDAV\Handler unset($requested_multiget_ids[$k]); } // sync-collection report: deleted entry need to be reported without properties - if ($contact['tid'] == addressbook_bo::DELETED_TYPE) + if ($contact['tid'] == Api\Contacts::DELETED_TYPE) { $files[] = array('path' => $path.urldecode($this->get_path($contact))); continue; @@ -311,7 +312,7 @@ class addressbook_groupdav extends Api\CalDAV\Handler } $props = array( 'getcontenttype' => Api\CalDAV::mkprop('getcontenttype', 'text/vcard'), - 'getlastmodified' => egw_time::to($list['list_modified'],'ts'), + 'getlastmodified' => Api\DateTime::to($list['list_modified'],'ts'), 'displayname' => $list['list_name'], 'getetag' => '"'.$etag.'"', ); @@ -415,7 +416,7 @@ class addressbook_groupdav extends Api\CalDAV\Handler { case 'i;unicode-casemap': default: - $comp = ' '.$GLOBALS['egw']->db->capabilities[egw_db::CAPABILITY_CASE_INSENSITIV_LIKE].' '; + $comp = ' '.$GLOBALS['egw']->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '; break; } $column = $this->filter_prop2cal[strtoupper($prop_filter)]; @@ -618,7 +619,7 @@ class addressbook_groupdav extends Api\CalDAV\Handler $is_group = $contact['##X-ADDRESSBOOKSERVER-KIND'] == 'group'; if ($oldContact && $is_group !== isset($oldContact['list_id'])) { - throw new egw_exception_assertion_failed(__METHOD__."(,'$id',$user,'$prefix') can contact into group or visa-versa!"); + throw new Api\Exception\AssertionFailed(__METHOD__."(,'$id',$user,'$prefix') can contact into group or visa-versa!"); } if (!$is_group && is_array($contact['cat_id'])) @@ -651,7 +652,7 @@ class addressbook_groupdav extends Api\CalDAV\Handler { $contact['owner'] = $user; } - // check if default addressbook is synced and not accounts, if not use (always synced) personal addressbook + // check if default addressbook is synced and not Api\Accounts, if not use (always synced) personal addressbook elseif(!$this->bo->default_addressbook || !in_array($this->bo->default_addressbook,$this->home_set_pref)) { $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; @@ -663,7 +664,7 @@ class addressbook_groupdav extends Api\CalDAV\Handler } // check if user has add rights for addressbook // done here again, as _common_get_put_delete knows nothing about default addressbooks... - if (!($this->bo->grants[$contact['owner']] & EGW_ACL_ADD)) + if (!($this->bo->grants[$contact['owner']] & Acl::ADD)) { if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'"); return '403 Forbidden'; @@ -689,7 +690,7 @@ class addressbook_groupdav extends Api\CalDAV\Handler { if (($contact = $this->bo->read_list($save_ok))) { - $contact = egw_db::strip_array_keys($contact, 'list_'); + $contact = Api\Db::strip_array_keys($contact, 'list_'); } } else @@ -835,7 +836,7 @@ class addressbook_groupdav extends Api\CalDAV\Handler * * @link http://www.mail-archive.com/calendarserver-users@lists.macosforge.org/msg01156.html * - * @param array $props =array() regular props by the groupdav handler + * @param array $props =array() regular props by the Api\CalDAV handler * @param string $displayname * @param string $base_uri =null base url of handler * @param int $user =null account_id of owner of collection @@ -1021,7 +1022,7 @@ class addressbook_groupdav extends Api\CalDAV\Handler /** * Check if user has the neccessary rights on a contact * - * @param int $acl EGW_ACL_READ, EGW_ACL_EDIT or EGW_ACL_DELETE + * @param int $acl Acl::READ, Acl::EDIT or Acl::DELETE * @param array|int $contact contact-array or id * @return boolean null if entry does not exist, false if no access, true if access permitted */ @@ -1073,7 +1074,7 @@ class addressbook_groupdav extends Api\CalDAV\Handler $this->home_set_pref[$key] = $id; } } - foreach(array_keys($this->bo->get_addressbooks(EGW_ACL_READ)) as $id) + foreach(array_keys($this->bo->get_addressbooks(Acl::READ)) as $id) { if (($id || !$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) && $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user and no accounts, if disabled in ab prefs @@ -1125,8 +1126,8 @@ class addressbook_groupdav extends Api\CalDAV\Handler if (!isset($hook_data['setup']) && in_array($hook_data['type'], array('user', 'group'))) { $user = $hook_data['account_id']; - $addressbook_bo = new addressbook_bo(); - $addressbooks += $addressbook_bo->get_addressbooks(EGW_ACL_READ, null, $user); + $addressbook_bo = new Api\Contacts(); + $addressbooks += $addressbook_bo->get_addressbooks(Acl::READ, null, $user); if ($user > 0) unset($addressbooks[$user]); // allways synced unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now } diff --git a/addressbook/inc/class.addressbook_hooks.inc.php b/addressbook/inc/class.addressbook_hooks.inc.php index 3bed6efecc..80b0dd37e1 100644 --- a/addressbook/inc/class.addressbook_hooks.inc.php +++ b/addressbook/inc/class.addressbook_hooks.inc.php @@ -1,6 +1,6 @@ egw::link('/index.php',array( + 'Addressbook list' => Egw::link('/index.php',array( 'menuaction' => 'addressbook.addressbook_ui.index', 'ajax' => 'true')), array( - 'text' => lang('Add %1',lang(egw_link::get_registry($appname, 'entry'))), + 'text' => lang('Add %1',lang(Link::get_registry($appname, 'entry'))), 'no_lang' => true, 'link' => "javascript:egw.open('','$appname','add')" ), 'Advanced search' => "javascript:egw_openWindowCentered2('". - egw::link('/index.php',array('menuaction' => 'addressbook.addressbook_ui.search'),false). + Egw::link('/index.php',array('menuaction' => 'addressbook.addressbook_ui.search'),false). "','_blank',870,480,'yes')", - 'Placeholders' => egw::link('/index.php','menuaction=api.EGroupware\\Api\\Contacts\\Merge.show_replacements') + 'Placeholders' => Egw::link('/index.php','menuaction=api.EGroupware\\Api\\Contacts\\Merge.show_replacements') ); display_sidebox($appname,lang('Addressbook menu'),$file); } @@ -65,11 +69,11 @@ class addressbook_hooks if ($GLOBALS['egw_info']['user']['apps']['admin'] && $location != 'preferences') { $file = Array( - 'Site configuration' => egw::link('/index.php',array( + 'Site configuration' => Egw::link('/index.php',array( 'menuaction' => 'admin.uiconfig.index', 'appname' => $appname, )), - 'Global Categories' => egw::link('/index.php',array( + 'Global Categories' => Egw::link('/index.php',array( 'menuaction' => 'admin.admin_categories.index', 'appname' => $appname, 'global_cats'=> True, @@ -78,7 +82,7 @@ class addressbook_hooks // custom fields are not availible in LDAP if ($GLOBALS['egw_info']['server']['contact_repository'] != 'ldap') { - $file['Custom fields'] = egw::link('/index.php',array( + $file['Custom fields'] = Egw::link('/index.php',array( 'menuaction' => 'admin.customfields.index', 'appname' => $appname, 'use_private'=> 1, @@ -97,7 +101,7 @@ class addressbook_hooks } /** - * populates $settings for the preferences + * populates $settings for the Api\Preferences * * @param array|string $hook_data * @return array @@ -118,7 +122,7 @@ class addressbook_hooks 'label' => 'Default addressbook for adding contacts', 'name' => 'add_default', 'help' => 'Which addressbook should be selected when adding a contact AND you have no add rights to the current addressbook.', - 'values' => !$hook_data['setup'] ? ExecMethod('addressbook.addressbook_ui.get_addressbooks',EGW_ACL_ADD) : array(), + 'values' => !$hook_data['setup'] ? ExecMethod('addressbook.addressbook_ui.get_addressbooks',Acl::ADD) : array(), 'xmlrpc' => True, 'admin' => False, ); @@ -159,7 +163,7 @@ class addressbook_hooks 'type' => 'select', 'label' => 'Add a customfield to link title', 'name' => 'link_title_cf', - 'values' => addressbook_bo::cf_options(), + 'values' => Api\Contacts::cf_options(), 'help' => 'Add customfield to links of addressbook, which displays in other applications. The default value is none customfield.', 'xmlrpc' => True, 'admin' => false, @@ -223,7 +227,7 @@ class addressbook_hooks 'name' => 'default_document', 'help' => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.', lang('addressbook')).' '. lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','n_fn').' '. - lang('The following document-types are supported:'). implode(',',bo_merge::get_file_extensions()), + lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()), 'run_lang' => false, 'xmlrpc' => True, 'admin' => False, @@ -235,7 +239,7 @@ class addressbook_hooks 'name' => 'document_dir', 'help' => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the data inserted.',lang('addressbook')).' '. lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','n_fn').' '. - lang('The following document-types are supported:'). implode(',',bo_merge::get_file_extensions()), + lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()), 'run_lang' => false, 'xmlrpc' => True, 'admin' => False, @@ -301,7 +305,7 @@ class addressbook_hooks 'type' => 'select', 'label' => 'Charset for the vCard import and export', 'name' => 'vcard_charset', - 'values' => translation::get_installed_charsets(), + 'values' => Api\Translation::get_installed_charsets(), 'help' => 'Which charset should be used for the vCard import and export.', 'xmlrpc' => True, 'admin' => false, @@ -425,18 +429,18 @@ class addressbook_hooks /** * ACL rights and labels used * - * @param string|array string with location or array with parameters incl. "location", specially "owner" for selected acl owner - * @return array acl::(READ|ADD|EDIT|DELETE|PRIVAT|CUSTOM(1|2|3)) => $label pairs + * @param string|array string with location or array with parameters incl. "location", specially "owner" for selected Acl owner + * @return array Acl::(READ|ADD|EDIT|DELETE|PRIVAT|CUSTOM(1|2|3)) => $label pairs */ public static function acl_rights($params) { unset($params); // not used, but required by function signature return array( - acl::READ => 'read', - acl::EDIT => 'edit', - acl::ADD => 'add', - acl::DELETE => 'delete', + Acl::READ => 'read', + Acl::EDIT => 'edit', + Acl::ADD => 'add', + Acl::DELETE => 'delete', ); } diff --git a/addressbook/inc/class.addressbook_import_contacts_csv.inc.php b/addressbook/inc/class.addressbook_import_contacts_csv.inc.php index 721ef633e5..10ab538811 100644 --- a/addressbook/inc/class.addressbook_import_contacts_csv.inc.php +++ b/addressbook/inc/class.addressbook_import_contacts_csv.inc.php @@ -98,7 +98,7 @@ class addressbook_import_contacts_csv extends importexport_basic_import_csv { $this->errors[$import_csv->get_current_position()] = lang( 'Unable to convert "%1" to account ID. Using plugin setting (%2) for owner.', $record->owner, - common::grab_owner_name($this->user) + Api\Accounts::username($this->user) ); $record->owner = $this->user; } else { @@ -113,8 +113,8 @@ class addressbook_import_contacts_csv extends importexport_basic_import_csv { if(!array_key_exists($record->owner, $this->bocontacts->get_addressbooks())) { $this->errors[$import_csv->get_current_position()] = lang("Unable to import into %1, using %2", - common::grab_owner_name($record->owner), - common::grab_owner_name($this->user) + Api\Accounts::username($record->owner), + Api\Accounts::username($this->user) ); $record->owner = $this->user; } @@ -165,7 +165,7 @@ class addressbook_import_contacts_csv extends importexport_basic_import_csv { // Format birthday as backend requires - converter should give timestamp if($record->bday && is_numeric($record->bday)) { - $time = new egw_time($record->bday); + $time = new Api\DateTime($record->bday); $record->bday = $time->format('Y-m-d'); } @@ -323,7 +323,7 @@ class addressbook_import_contacts_csv extends importexport_basic_import_csv { return $result; } default: - throw new egw_exception('Unsupported action: '. $_action); + throw new Api\Exception('Unsupported action: '. $_action); } } @@ -415,4 +415,4 @@ class addressbook_import_contacts_csv extends importexport_basic_import_csv { public function get_results() { return $this->results; } -} // end of iface_export_plugin +} diff --git a/addressbook/inc/class.addressbook_import_vcard.inc.php b/addressbook/inc/class.addressbook_import_vcard.inc.php index b219333e36..a2552ca1b9 100644 --- a/addressbook/inc/class.addressbook_import_vcard.inc.php +++ b/addressbook/inc/class.addressbook_import_vcard.inc.php @@ -157,6 +157,7 @@ class addressbook_import_vcard implements importexport_iface_import_plugin { */ public function _vcard($_vcard, $owner) { + // ToDo: Nathan: $_definition is not defined $charset = $_definition->plugin_options['charset']; if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; $record = $this->bocontacts->vcardtoegw($_vcard,$charset); @@ -202,8 +203,12 @@ class addressbook_import_vcard implements importexport_iface_import_plugin { // Only update if there are changes $old = $this->bocontacts->read($_data['id']); // if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes. - foreach(array('adr_one_', 'adr_two_') as $c_prefix) { - if (strlen(trim($_data[$c_prefix.'countryname']))==2) $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']),$translated=true); + foreach(array('adr_one_', 'adr_two_') as $c_prefix) + { + if (strlen(trim($_data[$c_prefix.'countryname']))==2) + { + $_data[$c_prefix.'countryname'] = Api\Country::get_full_name(trim($_data[$c_prefix.'countryname']), true); + } } // Don't change a user account into a contact if($old['owner'] == 0) { @@ -270,13 +275,13 @@ class addressbook_import_vcard implements importexport_iface_import_plugin { $record_class = get_class($this->preview_records[0]); - foreach($this->preview_records as $i => $record) + foreach($this->preview_records as $record) { // Convert to human-friendly importexport_export_csv::convert($record,$record_class::$types,$_definition->application); $record = $record->get_record_array(); $row = array(); - foreach($labels as $field => $label) + foreach(array_keys($labels) as $field) { $row[$field] = $record[$field]; @@ -380,4 +385,4 @@ class addressbook_import_vcard implements importexport_iface_import_plugin { public function get_results() { return $this->results; } -} // end of iface_export_plugin +} diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index a53b915364..e59742f1f3 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -13,6 +13,12 @@ */ use EGroupware\Api; +use EGroupware\Api\Link; +use EGroupware\Api\Framework; +use EGroupware\Api\Egw; +use EGroupware\Api\Acl; +use EGroupware\Api\Vfs; +use EGroupware\Api\Etemplate; /** * General user interface object of the adressbook @@ -64,7 +70,7 @@ class addressbook_ui extends addressbook_bo /** * Instance of eTemplate class * - * @var etemplate_new + * @var Etemplate */ protected $tmpl; @@ -77,7 +83,7 @@ class addressbook_ui extends addressbook_bo { parent::__construct($contact_app); - $this->tmpl = new etemplate_new(); + $this->tmpl = new Etemplate(); $this->org_views = array( 'org_name' => lang('Organisations'), @@ -86,12 +92,12 @@ class addressbook_ui extends addressbook_bo ); // make sure the hook for export_limit is registered - if (!$GLOBALS['egw']->hooks->hook_exists('export_limit','addressbook')) $GLOBALS['egw']->hooks->register_single_app_hook('addressbook','export_limit'); + if (!Api\Hooks::exists('export_limit','addressbook')) Api\Hooks::read(true); $this->config =& $GLOBALS['egw_info']['server']; // check if a contact specific export limit is set, if yes use it also for etemplate's csv export - $this->config['export_limit'] = $this->config['contact_export_limit'] = bo_merge::getExportLimit($app='addressbook'); + $this->config['export_limit'] = $this->config['contact_export_limit'] = Api\Storage\Merge::getExportLimit($app='addressbook'); if ($this->config['copy_fields'] && ($fields = is_array($this->config['copy_fields']) ? $this->config['copy_fields'] : unserialize($this->config['copy_fields']))) @@ -114,69 +120,70 @@ class addressbook_ui extends addressbook_bo /** * List contacts of an addressbook * - * @param array $content=null submitted content - * @param string $msg=null message to show - * @param boolean $do_email=false do an email-selection popup or the regular index-page + * @param array $_content =null submitted content + * @param string $msg =null message to show + * @param boolean $do_email =false do an email-selection popup or the regular index-page */ - function index($content=null,$msg=null,$do_email=false) + function index($_content=null,$msg=null,$do_email=false) { - //echo "
uicontacts::index(".print_r($content,true).",'$msg')
\n"; - if (($re_submit = is_array($content))) + //echo "uicontacts::index(".print_r($_content,true).",'$msg')
\n"; + if (($re_submit = is_array($_content))) { - $do_email = $content['do_email']; + $do_email = $_content['do_email']; - if (isset($content['nm']['rows']['delete'])) // handle a single delete like delete with the checkboxes + if (isset($_content['nm']['rows']['delete'])) // handle a single delete like delete with the checkboxes { - list($id) = @each($content['nm']['rows']['delete']); - $content['nm']['action'] = 'delete'; - $content['nm']['selected'] = array($id); + list($id) = @each($_content['nm']['rows']['delete']); + $_content['nm']['action'] = 'delete'; + $_content['nm']['selected'] = array($id); } - if (isset($content['nm']['rows']['document'])) // handle insert in default document button like an action + if (isset($_content['nm']['rows']['document'])) // handle insert in default document button like an action { - list($id) = @each($content['nm']['rows']['document']); - $content['nm']['action'] = 'document'; - $content['nm']['selected'] = array($id); + list($id) = @each($_content['nm']['rows']['document']); + $_content['nm']['action'] = 'document'; + $_content['nm']['selected'] = array($id); } - if ($content['nm']['action'] !== '' && $content['nm']['action'] !== null) + if ($_content['nm']['action'] !== '' && $_content['nm']['action'] !== null) { - if (!count($content['nm']['selected']) && !$content['nm']['select_all'] && $content['nm']['action'] != 'delete_list') + if (!count($_content['nm']['selected']) && !$_content['nm']['select_all'] && $_content['nm']['action'] != 'delete_list') { $msg = lang('You need to select some contacts first'); } - elseif ($content['nm']['action'] == 'view_org') // org-view via context menu + elseif ($_content['nm']['action'] == 'view_org') // org-view via context menu { - $content['nm']['org_view'] = array_shift($content['nm']['selected']); + $_content['nm']['org_view'] = array_shift($_content['nm']['selected']); } else { - if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'], - $success,$failed,$action_msg,$content['do_email'] ? 'email' : 'index',$msg,$content['nm']['checkboxes'])) + $success = $failed = $action_msg = null; + if ($this->action($_content['nm']['action'],$_content['nm']['selected'],$_content['nm']['select_all'], + $success,$failed,$action_msg,$_content['do_email'] ? 'email' : 'index',$msg,$_content['nm']['checkboxes'])) { $msg .= lang('%1 contact(s) %2',$success,$action_msg); - egw_framework::message($msg); + Framework::message($msg); } elseif(is_null($msg)) { $msg .= lang('%1 contact(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); - egw_framework::message($msg,'error'); + Framework::message($msg,'error'); } $msg = ''; } } - if ($content['nm']['rows']['infolog']) + if ($_content['nm']['rows']['infolog']) { - list($org) = each($content['nm']['rows']['infolog']); + list($org) = each($_content['nm']['rows']['infolog']); return $this->infolog_org_view($org); } - if ($content['nm']['rows']['view']) // show all contacts of an organisation + if ($_content['nm']['rows']['view']) // show all contacts of an organisation { - list($org_view) = each($content['nm']['rows']['view']); + list($org_view) = each($_content['nm']['rows']['view']); } else { - $org_view = $content['nm']['org_view']; + $org_view = $_content['nm']['org_view']; } - $typeselection = $content['nm']['col_filter']['tid']; + $typeselection = $_content['nm']['col_filter']['tid']; } elseif($_GET['add_list']) { @@ -197,14 +204,14 @@ class addressbook_ui extends addressbook_bo $preserv = array( 'do_email' => $do_email, ); - $to = $content['nm']['to']; + $to = $_content['nm']['to']; $content = array(); if($msg || $_GET['msg']) { - egw_framework::message($msg ? $msg : $_GET['msg']); + Framework::message($msg ? $msg : $_GET['msg']); } - $content['nm'] = egw_session::appsession($do_email ? 'email' : 'index','addressbook'); + $content['nm'] = Api\Cache::getSession('addressbook', $do_email ? 'email' : 'index'); if (!is_array($content['nm'])) { $content['nm'] = array( @@ -257,7 +264,7 @@ class addressbook_ui extends addressbook_bo $sel_options['cat_id'] = array('' => lang('All categories'), '0' => lang('None')); // Edit and delete list actions depends on permissions - if($this->get_lists(EGW_ACL_EDIT)) + if($this->get_lists(Acl::EDIT)) { $content['nm']['placeholder_actions'][] = 'rename_list'; $content['nm']['placeholder_actions'][] = 'delete_list'; @@ -270,10 +277,10 @@ class addressbook_ui extends addressbook_bo if (isset($typeselection)) $content['nm']['col_filter']['tid'] = $typeselection; // save the tid for use in creating new addressbook entrys via UI. Current tid is to be used as type of new entrys //error_log(__METHOD__.__LINE__.' '.$content['nm']['col_filter']['tid']); - egw_cache::setSession('addressbook','active_tid',$content['nm']['col_filter']['tid']); + Api\Cache::setSession('addressbook','active_tid',$content['nm']['col_filter']['tid']); if ($this->lists_available()) { - $sel_options['filter2'] = $this->get_lists(EGW_ACL_READ,array('' => lang('No distribution list'))); + $sel_options['filter2'] = $this->get_lists(Acl::READ,array('' => lang('No distribution list'))); $sel_options['filter2']['add'] = lang('Add a new list').'...'; // put it at the end } if ($do_email) @@ -296,13 +303,13 @@ class addressbook_ui extends addressbook_bo { $content['nm']['header_left'] = 'addressbook.index.left'; } - $sel_options['filter'] = $sel_options['owner'] = $this->get_addressbooks(EGW_ACL_READ, lang('All addressbooks')); + $sel_options['filter'] = $sel_options['owner'] = $this->get_addressbooks(Acl::READ, lang('All addressbooks')); $sel_options['to'] = array( 'to' => 'To', 'cc' => 'Cc', 'bcc' => 'Bcc', ); - $sel_options['adr_one_countrycode']['-custom-'] = lang('No country selected'); + $sel_options['adr_one_countrycode']['-custom-'] = lang('No Api\Country selected'); // if there is any export limit set, pass it on to the nextmatch, to be evaluated by the export if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit']) $content['nm']['export_limit']=$this->config['contact_export_limit']; @@ -351,17 +358,16 @@ class addressbook_ui extends addressbook_bo $this->tmpl->read($do_email ? 'addressbook.email' : 'addressbook.index'); return $this->tmpl->exec($do_email ? 'addressbook.addressbook_ui.emailpopup' : 'addressbook.addressbook_ui.index', - $content,$sel_options,$readonlys,$preserv,$do_email ? 2 : 0); + $content,$sel_options,array(),$preserv,$do_email ? 2 : 0); } /** * Get actions / context menu items * - * @param string $tid_filter=null - * @param string $org_view=null - * @return array see nextmatch_widget::get_actions() + * @param string $tid_filter =null + * @return array see Etemplate\Widget\Nextmatch::get_actions() */ - public function get_actions($tid_filter=null, $org_view=null) + public function get_actions($tid_filter=null) { // Contact view $actions = array( @@ -384,7 +390,7 @@ class addressbook_ui extends addressbook_bo 'disableClass' => 'contact_organisation', 'hideOnDisabled' => true, 'url' => 'menuaction=addressbook.addressbook_ui.edit&contact_id=$id', - 'popup' => egw_link::get_registry('addressbook', 'edit_popup'), + 'popup' => Link::get_registry('addressbook', 'edit_popup'), 'group' => $group, ), 'add' => array( @@ -396,13 +402,13 @@ class addressbook_ui extends addressbook_bo 'new' => array( 'caption' => 'New', 'url' => 'menuaction=addressbook.addressbook_ui.edit', - 'popup' => egw_link::get_registry('addressbook', 'add_popup'), + 'popup' => Link::get_registry('addressbook', 'add_popup'), 'icon' => 'new', ), 'copy' => array( 'caption' => 'Copy', 'url' => 'menuaction=addressbook.addressbook_ui.edit&makecp=1&contact_id=$id', - 'popup' => egw_link::get_registry('addressbook', 'add_popup'), + 'popup' => Link::get_registry('addressbook', 'add_popup'), 'allowOnMultiple' => false, 'icon' => 'copy', ), @@ -445,7 +451,7 @@ class addressbook_ui extends addressbook_bo 'disableClass' => 'contact_contact', 'hideOnDisabled' => true, 'url' => 'menuaction=addressbook.addressbook_ui.edit&org=$id', - 'popup' => egw_link::get_registry('addressbook', 'add_popup'), + 'popup' => Link::get_registry('addressbook', 'add_popup'), ), ); @@ -455,16 +461,16 @@ class addressbook_ui extends addressbook_bo 'caption' => 'Categories', 'group' => $group, 'children' => array( - 'cat_add' => nextmatch_widget::category_action( + 'cat_add' => Etemplate\Widget\Nextmatch::category_action( 'addressbook',$group,'Add category', 'cat_add_', - true, 0,nextmatch_widget::DEFAULT_MAX_MENU_LENGTH,false + true, 0,Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH,false )+array( 'icon' => 'foldertree_nolines_plus', 'disableClass' => 'rowNoEdit', ), - 'cat_del' => nextmatch_widget::category_action( + 'cat_del' => Etemplate\Widget\Nextmatch::category_action( 'addressbook',$group,'Delete category', 'cat_del_', - true, 0,nextmatch_widget::DEFAULT_MAX_MENU_LENGTH,false + true, 0,Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH,false )+array( 'icon' => 'foldertree_nolines_minus', 'disableClass' => 'rowNoEdit', @@ -484,7 +490,7 @@ class addressbook_ui extends addressbook_bo ), 'group' => $group, ); - if (($add_lists = $this->get_lists(EGW_ACL_EDIT))) // do we have distribution lists?, and are we allowed to edit them + if (($add_lists = $this->get_lists(Acl::EDIT))) // do we have distribution lists?, and are we allowed to edit them { $actions['lists']['children'] += array( 'to_list' => array( @@ -528,11 +534,12 @@ class addressbook_ui extends addressbook_bo } } // move to AB - if (($move2addressbooks = $this->get_addressbooks(EGW_ACL_ADD))) // do we have addressbooks, we should + if (($move2addressbooks = $this->get_addressbooks(Acl::ADD))) // do we have addressbooks, we should { unset($move2addressbooks[0]); // do not offer action to move contact to an account, as we dont support that currrently foreach($move2addressbooks as $owner => $label) { + $icon = $type_label = null; $this->type_icon((int)$owner, substr($owner,-1) == 'p', 'n', $icon, $type_label); $move2addressbooks[$owner] = array( 'icon' => $icon, @@ -583,7 +590,7 @@ class addressbook_ui extends addressbook_bo 'caption' => 'Add a new Infolog', 'icon' => 'new', 'url' => 'menuaction=infolog.infolog_ui.edit&type=task&action=addressbook&action_id=$id', - 'popup' => egw_link::get_registry('infolog', 'add_popup'), + 'popup' => Link::get_registry('infolog', 'add_popup'), 'onExecute' => 'javaScript:app.addressbook.add_task', // call server for org-view only ), ), @@ -607,7 +614,7 @@ class addressbook_ui extends addressbook_bo 'calendar_add' => array( 'caption' => 'Add appointment', 'icon' => 'new', - 'popup' => egw_link::get_registry('calendar', 'add_popup'), + 'popup' => Link::get_registry('calendar', 'add_popup'), 'onExecute' => 'javaScript:app.addressbook.add_cal', ), ), @@ -676,7 +683,7 @@ class addressbook_ui extends addressbook_bo ); } // check if user is an admin or the export is not generally turned off (contact_export_limit is non-numerical, eg. no) - $exception = bo_merge::is_export_limit_excepted(); + $exception = Api\Storage\Merge::is_export_limit_excepted(); if ((isset($GLOBALS['egw_info']['user']['apps']['admin']) || $exception) || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit']) { $actions['export'] = array( @@ -693,7 +700,7 @@ class addressbook_ui extends addressbook_bo 'vcard' => array( 'caption' => 'Export as VCard', 'postSubmit' => true, // download needs post submit (not Ajax) to work - 'icon' => egw_vfs::mime_icon('text/vcard'), + 'icon' => Vfs::mime_icon('text/vcard'), ), ), 'hideOnMobile' => true @@ -727,7 +734,7 @@ class addressbook_ui extends addressbook_bo 'disableClass' => 'rowNoDelete', ); } - if ($this->grants[0] & EGW_ACL_DELETE) + if ($this->grants[0] & Acl::DELETE) { $actions['delete_account'] = array( 'caption' => 'Delete', @@ -752,7 +759,7 @@ class addressbook_ui extends addressbook_bo if (isset($actions['export']['children']['csv']) && !importexport_helper_functions::has_definitions('addressbook','export')) unset($actions['export']['children']['csv']); // Intercept open action in order to open entry into view mode instead of edit - if (html::$ua_mobile) + if (Api\Header\UserAgent::mobile()) { $actions['open']['onExecute'] = 'javaScript:app.addressbook.viewEntry'; $actions['open']['mobileViewTemplate'] = 'view'; @@ -786,15 +793,15 @@ class addressbook_ui extends addressbook_bo list(,$name) = explode(':',$part,2); if ($name) $org_name[] = $name; } - $org_name = implode(': ',$org_name); - return $org_name ? array($org => $org_name) : array(); + $name = implode(': ',$org_name); + return $name ? array($org => $name) : array(); } /** * Email address-selection popup * - * @param array $content=null submitted content - * @param string $msg=null message to show + * @param array $content =null submitted content + * @param string $msg =null message to show */ function emailpopup($content=null,$msg=null) { @@ -838,13 +845,13 @@ window.egw_LAB.wait(function() { * Return the contacts in an organisation via AJAX * * @param string|string[] $org Organisation ID - * @param mixed $query Query filters (category, etc) to use, or null to use session + * @param mixed $_query Query filters (category, etc) to use, or null to use session * @return array */ - public function ajax_organisation_contacts($org, $query = null) + public function ajax_organisation_contacts($org, $_query = null) { $org_contacts = array(); - $query = $query == null ? egw_session::appsession('index','addressbook') : $query; + $query = !$_query ? Api\Cache::getSession('addressbook', 'index') : $_query; $query['num_rows'] = -1; // all if(!is_array($query['col_filter'])) $query['col_filter'] = array(); @@ -853,13 +860,14 @@ window.egw_LAB.wait(function() { { $query['org_view'] = $org_name; $checked = array(); - $count = $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's + $readonlys = null; + $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's if($checked[0]) { $org_contacts = array_merge($org_contacts,$checked); } } - egw_json_response::get()->data(array_unique($org_contacts)); + Api\Json\Response::get()->data(array_unique($org_contacts)); } /** @@ -869,10 +877,11 @@ window.egw_LAB.wait(function() { */ function infolog_org_view($org) { - $query = egw_session::appsession('index','addressbook'); + $query = Api\Cache::getSession('addressbook', 'index'); $query['num_rows'] = -1; // all $query['org_view'] = $org; $query['searchletter'] = ''; + $checked = $readonlys = null; $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's if (count($checked) > 1) // use a nicely formatted org-name as title in infolog @@ -890,7 +899,7 @@ window.egw_LAB.wait(function() { { $org = ''; // use infolog default of link-title } - egw::redirect_link('/index.php',array( + Egw::redirect_link('/index.php',array( 'menuaction' => 'infolog.infolog_ui.index', 'action' => 'addressbook', 'action_id' => implode(',',$checked), @@ -900,13 +909,14 @@ window.egw_LAB.wait(function() { function ajax_add_whole_list($list, $email_type = 'email') { - $query = egw_session::appsession('email','addressbook'); + $query = Api\Cache::getSession('addressbook', 'email'); $query['filter2'] = (int)$list; + $success = $failed = $action_msg = $msg = null; $this->action($email_type,array(),true,$success,$failed,$action_msg,$query,$msg); - $response = egw_json_response::get(); + $response = Api\Json\Response::get(); - if ($success) $response->addScript(egw_framework::set_onload('')); + if ($success) $response->addScript(Framework::set_onload('')); // close window only if no errors AND something added if ($failed || !$success) @@ -932,23 +942,23 @@ window.egw_LAB.wait(function() { * * @param int $list_id ID of existing list, or 0 for a new one * @param string $new_name List name - * @param int $owner List owner, or empty for current user + * @param int $_owner List owner, or empty for current user * @return boolean|string */ - function ajax_set_list($list_id, $new_name, $owner = false) + function ajax_set_list($list_id, $new_name, $_owner = false) { // Set owner to current user, if not set - $owner = $owner ? $owner : $GLOBALS['egw_info']['user']['account_id']; + $owner = $_owner ? $_owner : $GLOBALS['egw_info']['user']['account_id']; // Check for valid list & permissions if(!(int)$list_id && !$this->check_list(null,EGW_ACL_ADD|EGW_ACL_EDIT,$owner)) { - egw_json_response::get()->apply('egw.message', array( lang('List creation failed, no rights!'),'error')); + Api\Json\Response::get()->apply('egw.message', array( lang('List creation failed, no rights!'),'error')); return; } - if ((int)$list_id && !$this->check_list((int)$list_id, EGW_ACL_EDIT, $owner)) + if ((int)$list_id && !$this->check_list((int)$list_id, Acl::EDIT, $owner)) { - egw_json_response::get()->apply('egw.message', array( lang('Insufficent rights to edit this list!'),'error')); + Api\Json\Response::get()->apply('egw.message', array( lang('Insufficent rights to edit this list!'),'error')); return; } @@ -963,12 +973,12 @@ window.egw_LAB.wait(function() { $new_id = $this->add_list(array('list_id' => (int)$list_id), $list['list_owner'],array(),$list); - egw_json_response::get()->apply('egw.message', array( + Api\Json\Response::get()->apply('egw.message', array( $new_id == $list_id ? lang('Distribution list renamed') : lang('List created'), 'success' )); // Success, just update selectbox to new value - egw_json_response::get()->data($new_id == $list_id ? "true" : $new_id); + Api\Json\Response::get()->data($new_id == $list_id ? "true" : $new_id); } /** @@ -990,12 +1000,13 @@ window.egw_LAB.wait(function() { if ($use_all || in_array($action,array('remove_from_list','delete_list'))) { // get the whole selection - $query = is_array($session_name) ? $session_name : egw_session::appsession($session_name,'addressbook'); + $query = is_array($session_name) ? $session_name : Api\Cache::getSession('addressbook', $session_name); if ($use_all) { @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small $query['num_rows'] = -1; // all + $readonlys = null; $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's } } @@ -1010,10 +1021,11 @@ window.egw_LAB.wait(function() { return $this->infolog_org_view($id); // uses the org-name, instead of 'selected contacts' } unset($checked[$n]); - $query = egw_session::appsession($session_name,'addressbook'); + $query = Api\Cache::getSession('addressbook', $session_name); $query['num_rows'] = -1; // all $query['org_view'] = $id; unset($query['filter2']); + $extra = $readonlys = null; $this->get_rows($query,$extra,$readonlys,true); // true = only return the id's if ($extra[0]) $org_contacts = array_merge($org_contacts,$extra); } @@ -1041,7 +1053,7 @@ window.egw_LAB.wait(function() { $action = substr($action,0,7); } // Security: stop non-admins to export more then the configured number of contacts - if (in_array($action,array('csv','vcard')) && $this->config['contact_export_limit'] && !bo_merge::is_export_limit_excepted() && + if (in_array($action,array('csv','vcard')) && $this->config['contact_export_limit'] && !Api\Storage\Merge::is_export_limit_excepted() && (!is_numeric($this->config['contact_export_limit']) || count($checked) > $this->config['contact_export_limit'])) { $action_msg = lang('exported'); @@ -1059,6 +1071,7 @@ window.egw_LAB.wait(function() { break; case 'merge': + $error_msg = null; $success = $this->merge($checked,$error_msg); $failed = count($checked) - (int)$success; $action_msg = lang('merged'); @@ -1078,7 +1091,7 @@ window.egw_LAB.wait(function() { { $msg = lang('Distribution list deleted'); unset($query['filter2']); - egw_session::appsession($session_name,'addressbook',$query); + Api\Cache::setSession('addressbook', $session_name, $query); } return false; @@ -1090,26 +1103,25 @@ window.egw_LAB.wait(function() { return false; case 'infolog_add': - egw_framework::popup(egw::link('/index.php',array( + Framework::popup(Egw::link('/index.php',array( 'menuaction' => 'infolog.infolog_ui.edit', 'type' => 'task', 'action' => 'addressbook', 'action_id' => implode(',',$checked), - )),'_blank',egw_link::get_registry('infolog', 'add_popup')); + )),'_blank',Link::get_registry('infolog', 'add_popup')); $msg = ''; // no message, as we send none in javascript too and users sees opening popup return false; case 'calendar_add': // add appointment for org-views, other views are handled directly in javascript - egw_framework::popup(egw::link('/index.php',array( + Framework::popup(Egw::link('/index.php',array( 'menuaction' => 'calendar.calendar_uiforms.edit', 'participants' => 'c'.implode(',c',$checked), - )),'_blank',egw_link::get_registry('calendar', 'add_popup')); + )),'_blank',Link::get_registry('calendar', 'add_popup')); $msg = ''; // no message, as we send none in javascript too and users sees opening popup return false; case 'calendar_view': // show calendar for org-views, although all views are handled directly in javascript - list($width,$height) = explode('x',egw_link::get_registry('calendar', 'add_popup')); - egw::redirect_link('/index.php',array( + Egw::redirect_link('/index.php',array( 'menuaction' => 'calendar.calendar_uiviews.index', 'owner' => 'c'.implode(',c',$checked), )); @@ -1120,10 +1132,10 @@ window.egw_LAB.wait(function() { { case 'cat_add': case 'cat_del': - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(EGW_ACL_EDIT,$contact))) + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::EDIT,$contact))) { $action_msg = $action == 'cat_add' ? lang('categorie added') : lang('categorie delete'); - $cat_ids = $contact['cat_id'] ? explode(',', $contact['cat_id']) : array(); //existing categories + $cat_ids = $contact['cat_id'] ? explode(',', $contact['cat_id']) : array(); //existing Api\Categories if ($action == 'cat_add') { $cat_ids[] = $cat_id; @@ -1133,10 +1145,10 @@ window.egw_LAB.wait(function() { { unset($cat_ids[$key]); } - $cat_ids = $cat_ids ? implode(',',$cat_ids) : null; - if ($cat_ids !== $contact['cat_id']) + $ids = $cat_ids ? implode(',',$cat_ids) : null; + if ($ids !== $contact['cat_id']) { - $contact['cat_id'] = $cat_ids; + $contact['cat_id'] = $ids; $Ok = $this->save($contact); } } @@ -1144,7 +1156,7 @@ window.egw_LAB.wait(function() { case 'delete': $action_msg = lang('deleted'); - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(EGW_ACL_DELETE,$contact))) + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact))) { if ($contact['owner'] || // regular contact or empty($contact['account_id']) || // accounts without account_id @@ -1156,13 +1168,13 @@ window.egw_LAB.wait(function() { // delete single account --> redirect to admin elseif (count($checked) == 1 && $contact['account_id']) { - egw::redirect_link('/index.php',array( + Egw::redirect_link('/index.php',array( 'menuaction' => 'admin.admin_account.delete', 'account_id' => $contact['account_id'], )); // this does NOT return! } - else // no mass delete of accounts + else // no mass delete of Api\Accounts { $Ok = false; } @@ -1171,7 +1183,7 @@ window.egw_LAB.wait(function() { case 'undelete': $action_msg = lang('recovered'); - if ($contact = $this->read($id)) + if (($contact = $this->read($id))) { $contact['tid'] = 'n'; $Ok = $this->save($contact); @@ -1180,9 +1192,10 @@ window.egw_LAB.wait(function() { case 'email': case 'email_home': - $action == 'email' ? $action_fallback = 'email_home' : $action_fallback = 'email'; + /* this cant work anymore, as Framework::set_onload does not longer exist + $action_fallback = $action == 'email' ? 'email_home' : 'email'; $action_msg = lang('added'); - if($contact = $this->read($id)) + if(($contact = $this->read($id))) { if(strpos($contact[$action],'@') !== false) { @@ -1199,13 +1212,13 @@ window.egw_LAB.wait(function() { if($email) { $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); - egw_framework::set_onload("addEmail('".addslashes( + Framework::set_onload("addEmail('".addslashes( $contact['n_fn'] ? $contact['n_fn'].' <'.trim($email).'>' : trim($email))."');"); //error_log(__METHOD__.__LINE__."addEmail('".addslashes( // $contact['n_fn'] ? $contact['n_fn'].' <'.trim($email).'>' : trim($email))."');"); $Ok = true; } - } + }*/ break; case 'remove_from_list': @@ -1235,16 +1248,16 @@ window.egw_LAB.wait(function() { break; default: // move to an other addressbook - if (!(int)$action || !($this->grants[(string) (int) $action] & EGW_ACL_EDIT)) // might be ADD in the future + if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT)) // might be ADD in the future { return false; } if (!$checkboxes['move_to_copy']) { $action_msg = lang('moved'); - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(EGW_ACL_DELETE,$contact))) + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact))) { - if (!$contact['owner']) // no (mass-)move of accounts + if (!$contact['owner']) // no (mass-)move of Api\Accounts { $Ok = false; } @@ -1259,7 +1272,7 @@ window.egw_LAB.wait(function() { else { $action_msg = lang('copied'); - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(EGW_ACL_READ,$contact))) + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::READ,$contact))) { if ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p')) { @@ -1270,7 +1283,7 @@ window.egw_LAB.wait(function() { $Ok = $this->save($contact); if ($Ok && is_array($links)) { - egw_link::link('addressbook', $contact['id'], $links); + Link::link('addressbook', $contact['id'], $links); } } } @@ -1301,8 +1314,8 @@ window.egw_LAB.wait(function() { function copy_contact(array &$content, $only_copy_fields=true) { $content['link_to']['to_id'] = 0; - egw_link::link('addressbook',$content['link_to']['to_id'],'addressbook',$content['id'], - lang('Copied by %1, from record #%2.',common::display_fullname('', + Link::link('addressbook',$content['link_to']['to_id'],'addressbook',$content['id'], + lang('Copied by %1, from record #%2.',Api\Accounts::format_username('', $GLOBALS['egw_info']['user']['account_firstname'],$GLOBALS['egw_info']['user']['account_lastname']), $content['id'])); // create a new contact with the content of the old @@ -1327,8 +1340,8 @@ window.egw_LAB.wait(function() { * @internal * @param array &$query * @param array &$rows returned rows/cups - * @param array &$readonlys eg. to disable buttons based on acl - * @param boolean $id_only=false if true only return (via $rows) an array of contact-ids, dont save state to session + * @param array &$readonlys eg. to disable buttons based on Acl + * @param boolean $id_only =false if true only return (via $rows) an array of contact-ids, dont save state to session * @return int total number of contacts matching the selection */ function get_rows(&$query,&$rows,&$readonlys,$id_only=false) @@ -1344,11 +1357,11 @@ window.egw_LAB.wait(function() { { unset($store_query[$key]); } - $old_state = egw_session::appsession($what,'addressbook',$store_query); + $old_state = Api\Cache::setSession('addressbook', $what, $store_query); } else { - $old_state = egw_session::appsession($what,'addressbook'); + $old_state = Api\Cache::getSession('addressbook', $what); } if (!isset($this->org_views[(string) $query['org_view']]) || strpos($query['org_view'],':') === false) // we dont have an org view, unset the according col_filters { @@ -1369,10 +1382,11 @@ window.egw_LAB.wait(function() { { $query['advanced_search'] = $old_state['advanced_search']; } + /* this cant work anymore, as Framework::set_onload no longer exists if ($do_email && etemplate::$loop) { // remove previous addEmail() calls, otherwise they will be run again - egw_framework::set_onload(preg_replace('/addEmail\([^)]+\);/','',egw_framework::set_onload()),true); - } + Framework::set_onload(preg_replace('/addEmail\([^)]+\);/','',Framework::set_onload()),true); + }*/ // Make sure old lettersearch filter doesn't stay - current letter filter will be added later foreach($query['col_filter'] as $key => $col_filter) @@ -1590,9 +1604,9 @@ window.egw_LAB.wait(function() { // do we need to read the custom fields, depends on the column is enabled and customfields exist // $query['csv_export'] allways needs to read ALL cf's - $columselection = $this->prefs['nextmatch-addressbook.'.($do_email ? 'email' : 'index').'.rows']; - $available_distib_lists=$this->get_lists(EGW_ACL_READ); - $columselection = $columselection && !$query['csv_export'] ? explode(',',$columselection) : array(); + $columsel = $this->prefs['nextmatch-addressbook.'.($do_email ? 'email' : 'index').'.rows']; + $available_distib_lists=$this->get_lists(Acl::READ); + $columselection = $columsel && !$query['csv_export'] ? explode(',',$columsel) : array(); if (!$id_only && $rows) { $show_custom_fields = (!$columselection || in_array('customfields',$columselection) || $query['csv_export']) && $this->customfields; @@ -1614,7 +1628,7 @@ window.egw_LAB.wait(function() { } if ($show_calendar && !empty($ids)) $calendar = $this->read_calendar($ids); // distributionlist memership for the entrys - //_debug_array($this->get_lists(EGW_ACL_EDIT)); + //_debug_array($this->get_lists(Acl::EDIT)); if ($show_distributionlist && $available_distib_lists) { $distributionlist = $this->read_distributionlist($ids,array_keys($available_distib_lists)); @@ -1664,7 +1678,7 @@ window.egw_LAB.wait(function() { $row['type'] = 'home'; $row['type_label'] = lang('Organisation'); - if ($query['filter'] && !($this->grants[(int)$query['filter']] & EGW_ACL_DELETE)) + if ($query['filter'] && !($this->grants[(int)$query['filter']] & Acl::DELETE)) { $row['class'] .= 'rowNoDelete '; } @@ -1676,7 +1690,7 @@ window.egw_LAB.wait(function() { $this->type_icon($row['owner'],$row['private'],$row['tid'],$row['type'],$row['type_label']); static $tel2show = array('tel_work','tel_cell','tel_home','tel_fax'); - static $prefer_marker; + static $prefer_marker = null; if (is_null($prefer_marker)) { // as et2 adds options with .text(), it can't be entities, but php knows no string literals with utf-8 @@ -1695,11 +1709,11 @@ window.egw_LAB.wait(function() { { $row['class'] .= 'rowAccount rowNoDelete '; } - elseif (!$this->check_perms(EGW_ACL_DELETE,$row) || (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge' && $query['col_filter']['tid'] == self::DELETED_TYPE)) + elseif (!$this->check_perms(Acl::DELETE,$row) || (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge' && $query['col_filter']['tid'] == self::DELETED_TYPE)) { $row['class'] .= 'rowNoDelete '; } - if (!$this->check_perms(EGW_ACL_EDIT,$row)) + if (!$this->check_perms(Acl::EDIT,$row)) { $row['class'] .= 'rowNoEdit '; } @@ -1735,7 +1749,7 @@ window.egw_LAB.wait(function() { // respect category permissions if(!empty($row['cat_id'])) { - $row['cat_id'] = $this->categories->check_list(EGW_ACL_READ,$row['cat_id']); + $row['cat_id'] = $this->categories->check_list(Acl::READ,$row['cat_id']); } } $rows['no_distribution_list'] = (bool)$query['filter2']; @@ -1754,7 +1768,7 @@ window.egw_LAB.wait(function() { $header[] = ($query['filter'] == '0' ? lang('accounts') : ($GLOBALS['egw']->accounts->get_type($query['filter']) == 'g' ? lang('Group %1',$GLOBALS['egw']->accounts->id2name($query['filter'])) : - common::grab_owner_name((int)$query['filter']). + Api\Accounts::username((int)$query['filter']). (substr($query['filter'],-1) == 'p' ? ' ('.lang('private').')' : ''))); } if ($query['org_view']) @@ -1792,7 +1806,7 @@ window.egw_LAB.wait(function() { /** * Get addressbook type icon from owner, private and tid * - * @param int $owner user- or group-id or 0 for accounts + * @param int $owner user- or group-id or 0 for Api\Accounts * @param boolean $private * @param string $tid 'n' for regular addressbook * @param string &$icon icon-name @@ -1818,12 +1832,12 @@ window.egw_LAB.wait(function() { else { $icon = 'personal'; - $label = $owner == $this->user ? lang('personal') : common::grab_owner_name($owner); + $label = $owner == $this->user ? lang('personal') : Api\Accounts::username($owner); } // show tid icon for tid!='n' AND only if one is defined - if ($tid != 'n' && common::image('addressbook',$this->content_types[$tid]['name'])) + if ($tid != 'n' && Api\Image::find('addressbook',$this->content_types[$tid]['name'])) { - $icon = common::image('addressbook',$this->content_types[$tid]['name']); + $icon = Api\Image::find('addressbook',$this->content_types[$tid]['name']); } // Legacy - from when icons could be anywhere @@ -1931,7 +1945,7 @@ window.egw_LAB.wait(function() { $content['msg'] .= ', '.$success_msg; } } - catch(egw_exception_redirect $r) + catch(Api\Exception\Redirect $r) { // catch it to continue execution and rethrow it later } @@ -1962,7 +1976,7 @@ window.egw_LAB.wait(function() { { $content['msg'] = lang('Error: the entry has been updated since you opened it for editing!').''.lang('Migration finished')."
\n"; } - common::egw_footer(); + $GLOBALS['egw']->framework->footer(); } /** @@ -2964,9 +2988,9 @@ window.egw_LAB.wait(function() { */ function admin_set_fileas() { - translation::add_app('admin'); + Api\Translation::add_app('admin'); $GLOBALS['egw_info']['flags']['app_header'] = lang('Addressbook').' - '.lang('Contact maintenance'); - common::egw_header(); + $GLOBALS['egw']->framework->header(); parse_navbar(); // check if user has admin rights AND if a valid fileas type is given (Security) @@ -2976,10 +3000,11 @@ window.egw_LAB.wait(function() { } else { - $updated = parent::set_all_fileas($_GET['type'],(boolean)$_GET['all'],$errors,true); // true = ignore acl + $errors = null; + $updated = parent::set_all_fileas($_GET['type'],(boolean)$_GET['all'],$errors,true); // true = ignore Acl echo ''.lang('%1 contacts updated (%2 errors).',$updated,$errors)."
\n"; } - common::egw_footer(); + $GLOBALS['egw']->framework->footer(); } /** @@ -2988,9 +3013,9 @@ window.egw_LAB.wait(function() { */ function admin_set_all_cleanup() { - translation::add_app('admin'); + Api\Translation::add_app('admin'); $GLOBALS['egw_info']['flags']['app_header'] = lang('Addressbook').' - '.lang('Contact maintenance'); - common::egw_header(); + $GLOBALS['egw']->framework->header(); parse_navbar(); // check if user has admin rights (Security) @@ -3000,10 +3025,11 @@ window.egw_LAB.wait(function() { } else { - $updated = parent::set_all_cleanup($errors,true); // true = ignore acl + $errors = null; + $updated = parent::set_all_cleanup($errors,true); // true = ignore Acl echo ''.lang('%1 contacts updated (%2 errors).',$updated,$errors)."
\n"; } - common::egw_footer(); + $GLOBALS['egw']->framework->footer(); } /** diff --git a/addressbook/inc/class.addressbook_vcal.inc.php b/addressbook/inc/class.addressbook_vcal.inc.php index 6d0adaa0a8..d9f6e004d1 100644 --- a/addressbook/inc/class.addressbook_vcal.inc.php +++ b/addressbook/inc/class.addressbook_vcal.inc.php @@ -13,11 +13,12 @@ */ use EGroupware\Api; +use EGroupware\Api\Link; /** * Addressbook - vCard parser */ -class addressbook_vcal extends addressbook_bo +class addressbook_vcal extends Api\Contacts { /** * product manufacturer from setSupportedFields (lowercase!) @@ -32,11 +33,11 @@ class addressbook_vcal extends addressbook_bo */ var $productName; /** - * supported fields for vCard file and groupdav import/export + * supported fields for vCard file and CardDAV import/export * * @var array */ - var $databaseFields = array( // all entries e.g. for groupdav + var $databaseFields = array( // all entries e.g. for CardDAV 'ADR;WORK' => array('','adr_one_street2','adr_one_street','adr_one_locality','adr_one_region', 'adr_one_postalcode','adr_one_countryname'), 'ADR;HOME' => array('','adr_two_street2','adr_two_street','adr_two_locality','adr_two_region', @@ -205,7 +206,7 @@ class addressbook_vcal extends addressbook_bo $vCard->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['phpgwapi']['version'].'//'. strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); - $sysCharSet = translation::charset(); + $sysCharSet = Api\Translation::charset(); // KAddressbook and Funambol4BlackBerry always requires non-ascii chars to be qprint encoded. if ($this->productName == 'kde' || @@ -280,7 +281,7 @@ class addressbook_vcal extends addressbook_bo switch ($databaseField) { case 'modified': - $value = gmdate("Y-m-d\TH:i:s\Z",egw_time::user2server($value)); + $value = gmdate("Y-m-d\TH:i:s\Z",Api\DateTime::user2server($value)); $hasdata++; break; @@ -332,7 +333,7 @@ class addressbook_vcal extends addressbook_bo case 'cat_id': if (!empty($value) && ($values = /*str_replace(',','\\,',*/$this->get_categories($value)))//) { - $values = (array) translation::convert($values, $sysCharSet, $_charset); + $values = (array) Api\Translation::convert($values, $sysCharSet, $_charset); $value = implode(',', $values); // just for the CHARSET recognition if (($size > 0) && strlen($value) > $size) { @@ -428,7 +429,7 @@ class addressbook_vcal extends addressbook_bo || in_array($vcardField,array('FN','ORG','N')) || ($size >= 0 && !$noTruncate)) { - $value = translation::convert(trim($value), $sysCharSet, $_charset); + $value = Api\Translation::convert(trim($value), $sysCharSet, $_charset); $values[] = $value; if (preg_match('/[^\x20-\x7F]/', $value)) { @@ -1030,8 +1031,8 @@ class addressbook_vcal extends addressbook_bo { if (!$file) { - $filename = count($ids) == 1 ? egw_link::title('addressbook',$ids[0]): 'egw_addressbook_'.date('Y-m-d'); - html::content_header(($filename ? $filename : 'addressbook').'.vcf','text/x-vcard'); + $filename = count($ids) == 1 ? Link::title('addressbook',$ids[0]): 'egw_addressbook_'.date('Y-m-d'); + Api\Header\Content::type(($filename ? $filename : 'addressbook').'.vcf','text/x-vcard'); } if (!($fp = fopen($file ? $file : 'php://output','w'))) { @@ -1053,7 +1054,7 @@ class addressbook_vcal extends addressbook_bo if (!$file) { - common::egw_exit(); + exit(); } return true; } @@ -1079,7 +1080,7 @@ class addressbook_vcal extends addressbook_bo { $vCard->setAttribute('X-ADDRESSBOOKSERVER-MEMBER','urn:uuid:'.$uid); } - $vCard->setAttribute('REV',egw_time::to($list['list_modified'],'Y-m-d\TH:i:s\Z')); + $vCard->setAttribute('REV',Api\DateTime::to($list['list_modified'],'Y-m-d\TH:i:s\Z')); $vCard->setAttribute('UID',$list['list_uid']); return $vCard->exportvCalendar(); diff --git a/addressbook/inc/class.addressbook_wizard_export_contacts_csv.inc.php b/addressbook/inc/class.addressbook_wizard_export_contacts_csv.inc.php index bdbf5f802e..4d453ac594 100644 --- a/addressbook/inc/class.addressbook_wizard_export_contacts_csv.inc.php +++ b/addressbook/inc/class.addressbook_wizard_export_contacts_csv.inc.php @@ -1,14 +1,16 @@ step_templates['wizard_step50'] = 'addressbook.export_explode_fields'; // Field mapping - $bocontacts = new addressbook_bo(); + $bocontacts = new Api\Contacts(); $this->export_fields = $bocontacts->contact_fields; foreach($bocontacts->customfields as $name => $data) { $this->export_fields['#'.$name] = $data['label']; @@ -51,7 +53,7 @@ class addressbook_wizard_export_contacts_csv extends importexport_wizard_basic_e } /** - * Choose how to export multi-selects (includes categories) + * Choose how to export multi-selects (includes Api\Categories) */ function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) { @@ -87,7 +89,7 @@ class addressbook_wizard_export_contacts_csv extends importexport_wizard_basic_e $content['step'] = 'wizard_step50'; unset ($preserv['button']); $field_list = $this->get_field_list($content); - + $settings = $content['explode_multiselects'] ? $content['explode_multiselects'] : $content['plugin_options']['explode_multiselects']; // Skip this step if no fields applicable @@ -97,7 +99,7 @@ class addressbook_wizard_export_contacts_csv extends importexport_wizard_basic_e $cat_options = array( addressbook_export_contacts_csv::NO_EXPLODE => lang('All in one field'), - addressbook_export_contacts_csv::MAIN_CATS => lang('Main categories in their own field'), + addressbook_export_contacts_csv::MAIN_CATS => lang('Main Api\Categories in their own field'), addressbook_export_contacts_csv::EACH_CAT => lang('Each category in its own field'), ); $multi_options = array( @@ -132,16 +134,16 @@ class addressbook_wizard_export_contacts_csv extends importexport_wizard_basic_e */ protected function get_field_list($content) { $field_list = array(); - + // Category gets special handling if(in_array('cat_id', array_keys($content['mapping']))) { $field_list['cat_id'] = $this->export_fields['cat_id']; } // Add any multi-select custom fields - $custom = config::get_customfields('addressbook'); + $custom = Api\Storage\Customfields::get('addressbook'); foreach($custom as $name => $c_field) { - if($c_field['type'] = 'select' && $c_field['rows'] > 1 && in_array('#'.$name, array_keys($content['mapping']))) { + if($c_field['type'] == 'select' && $c_field['rows'] > 1 && in_array('#'.$name, array_keys($content['mapping']))) { $field_list['#'.$name] = $c_field['label']; } } diff --git a/addressbook/inc/class.addressbook_wizard_export_vcard.inc.php b/addressbook/inc/class.addressbook_wizard_export_vcard.inc.php index 646ea00697..dd55a20407 100644 --- a/addressbook/inc/class.addressbook_wizard_export_vcard.inc.php +++ b/addressbook/inc/class.addressbook_wizard_export_vcard.inc.php @@ -9,6 +9,8 @@ * @author Nathan Gray */ +use EGroupware\Api; + /** * We need to allow choosing of charset, so we'll just use the standard one from CSV */ @@ -22,7 +24,6 @@ class addressbook_wizard_export_vcard $this->step_templates = array( 'wizard_step40' => 'addressbook.importexport_wizard_vcard_charset' ); - } /** @@ -59,14 +60,14 @@ class addressbook_wizard_export_vcard if(!$content['charset'] && $content['plugin_options']['charset']) { $content['charset'] = $content['plugin_options']['charset'] ? $content['plugin_options']['charset'] : 'user'; } - $sel_options['charset'] = $GLOBALS['egw']->translation->get_installed_charsets()+ + $sel_options['charset'] = Api\Translation::get_installed_charsets()+ array( 'user' => lang('User preference'), ); $preserv = $content; // Add in extra allowed charsets - $config = config::read('importexport'); + $config = Api\Config::read('importexport'); $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings()); if($extra_charsets) { diff --git a/addressbook/inc/class.addressbook_wizard_import_contacts_csv.inc.php b/addressbook/inc/class.addressbook_wizard_import_contacts_csv.inc.php index 771c543098..c6adc8d00c 100644 --- a/addressbook/inc/class.addressbook_wizard_import_contacts_csv.inc.php +++ b/addressbook/inc/class.addressbook_wizard_import_contacts_csv.inc.php @@ -9,6 +9,9 @@ * @version $Id: $ */ +use EGroupware\Api; +use EGroupware\Api\Acl; + class addressbook_wizard_import_contacts_csv extends importexport_wizard_basic_import_csv { @@ -25,16 +28,16 @@ class addressbook_wizard_import_contacts_csv extends importexport_wizard_basic_i ); // Field mapping - $bocontacts = new addressbook_bo(); + $bocontacts = new Api\Contacts(); $this->mapping_fields = $bocontacts->contact_fields; - $categories = new categories('','addressbook'); + $categories = new Api\Categories('','addressbook'); $cat_list = array(); foreach((array)$categories->return_sorted_array(0,False,'','','',true,0,true) as $cat) { $s = str_repeat(' ',$cat['level']) . stripslashes($cat['name']); - if (categories::is_global($cat)) + if (Api\Categories::is_global($cat)) { $s .= ' ♦'; } @@ -51,7 +54,7 @@ class addressbook_wizard_import_contacts_csv extends importexport_wizard_basic_i $this->mapping_fields['#'.$name] = $data['label']; } unset($this->mapping_fields['jpegphoto']); // can't cvs import that - + // Add in special handled fields $this->mapping_fields[lang('Special')] = addressbook_import_contacts_csv::$special_fields; @@ -77,10 +80,10 @@ class addressbook_wizard_import_contacts_csv extends importexport_wizard_basic_i } $result = parent::wizard_step50($content, $sel_options, $readonlys, $preserv); $content['msg'] .= "\n*" . lang('Contact ID cannot be changed by import'); - + return $result; } - + function wizard_step60(&$content, &$sel_options, &$readonlys, &$preserv) { if($this->debug) error_log('addressbook.importexport.addressbook_csv_import::wizard_step60->$content '.print_r($content,true)); @@ -115,8 +118,8 @@ class addressbook_wizard_import_contacts_csv extends importexport_wizard_basic_i $content['change_owner'] = $content['plugin_options']['change_owner']; } - $bocontacts = new addressbook_bo(); - $sel_options['contact_owner'] = array('personal' => lang("Importer's personal")) + $bocontacts->get_addressbooks(EGW_ACL_ADD); + $bocontacts = new Api\Contacts(); + $sel_options['contact_owner'] = array('personal' => lang("Importer's personal")) + $bocontacts->get_addressbooks(Acl::ADD); if(!in_array('owner', $content['field_mapping'])) { $content['no_owner_map'] = true; } @@ -125,6 +128,5 @@ class addressbook_wizard_import_contacts_csv extends importexport_wizard_basic_i unset ($preserv['button']); return 'addressbook.importexport_wizard_chooseowner'; } - } } diff --git a/addressbook/inc/class.addressbook_wizard_import_vcard.inc.php b/addressbook/inc/class.addressbook_wizard_import_vcard.inc.php index 8f1791f376..560f1640e3 100644 --- a/addressbook/inc/class.addressbook_wizard_import_vcard.inc.php +++ b/addressbook/inc/class.addressbook_wizard_import_vcard.inc.php @@ -10,27 +10,27 @@ * @version $Id$ */ +use EGroupware\Api; +use EGroupware\Api\Acl; + class addressbook_wizard_import_vcard extends addressbook_import_vcard { - /** * constructor */ function __construct() { - $this->steps = array( 'wizard_step40' => lang('Choose charset'), 'wizard_step60' => lang('Choose owner of imported data'), ); - } function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) - { - if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); - // return from step40 - if ($content['step'] == 'wizard_step40') + { + if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true)); + // return from step40 + if ($content['step'] == 'wizard_step40') { switch (array_search('pressed', $content['button'])) { @@ -50,20 +50,20 @@ class addressbook_wizard_import_vcard extends addressbook_import_vcard $content['msg'] = $this->steps['wizard_step40']; $content['step'] = 'wizard_step40'; if(!$content['charset'] && $content['plugin_options']['charset']) { - $content['charset'] = $content['plugin_options']['charset']; - } - $sel_options['charset'] = $GLOBALS['egw']->translation->get_installed_charsets()+ - array( - 'user' => lang('User preference'), - ); + $content['charset'] = $content['plugin_options']['charset']; + } + $sel_options['charset'] = Api\Translation::get_installed_charsets()+ + array( + 'user' => lang('User preference'), + ); // Add in extra allowed charsets - $config = config::read('importexport'); - $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings()); - if($extra_charsets) - { - $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets)); - } + $config = Api\Config::read('importexport'); + $extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings()); + if($extra_charsets) + { + $sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets)); + } $preserv = $content; unset ($preserv['button']); @@ -102,13 +102,12 @@ class addressbook_wizard_import_vcard extends addressbook_import_vcard $content['change_owner'] = $content['plugin_options']['change_owner']; } - $bocontacts = new addressbook_bo(); - $sel_options['contact_owner'] = array('personal' => lang("Importer's personal")) + $bocontacts->get_addressbooks(EGW_ACL_ADD); + $bocontacts = new Api\Contacts(); + $sel_options['contact_owner'] = array('personal' => lang("Importer's personal")) + $bocontacts->get_addressbooks(Acl::ADD); $preserv = $content; unset ($preserv['button']); return 'addressbook.importexport_wizard_vcard_chooseowner'; } - } } diff --git a/addressbook/inc/class.addressbook_zpush.inc.php b/addressbook/inc/class.addressbook_zpush.inc.php index ec2b146191..6f82e1fef9 100644 --- a/addressbook/inc/class.addressbook_zpush.inc.php +++ b/addressbook/inc/class.addressbook_zpush.inc.php @@ -12,6 +12,9 @@ * @version $Id$ */ +use EGroupware\Api; +use EGroupware\Api\Acl; + /** * Addressbook activesync plugin */ @@ -25,7 +28,7 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se /** * Instance of addressbook_bo * - * @var addressbook_bo + * @var Api\Contacts */ private $addressbook; @@ -134,11 +137,11 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se } else { - translation::add_app('addressbook'); // we need the addressbook translations + Api\Translation::add_app('addressbook'); // we need the addressbook translations - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); + if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); - // error_log(print_r($this->addressbook->get_addressbooks(EGW_ACL_READ),true)); + // error_log(print_r($this->addressbook->get_addressbooks(Acl::READ),true)); $pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs']; $pref_abs = (string)$pref !== '' ? explode(',',$pref) : array(); @@ -172,7 +175,7 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se */ public function GetFolderList() { - // error_log(print_r($this->addressbook->get_addressbooks(EGW_ACL_READ),true)); + // error_log(print_r($this->addressbook->get_addressbooks(Acl::READ),true)); $folderlist = array(); foreach ($this->get_addressbooks() as $account => $label) { @@ -278,7 +281,7 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se function GetMessageList($id, $cutoffdate=NULL) { unset($cutoffdate); // not used, but required by function signature - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); + if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); $type = $user = null; $this->backend->splitID($id,$type,$user); @@ -329,7 +332,7 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se */ public function GetMessage($folderid, $id, $contentparameters) { - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); + if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); //$truncsize = Utils::GetTruncSize($contentparameters->GetTruncation()); //$mimesupport = $contentparameters->GetMimeSupport(); @@ -386,7 +389,7 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se $message->$key = array(); foreach($contact[$attr] ? explode(',',$contact[$attr]) : array() as $cat_id) { - $message->categories[] = categories::id2name($cat_id); + $message->categories[] = Api\Categories::id2name($cat_id); } // for all addressbooks in one, add addressbook name itself as category if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one']) @@ -437,7 +440,7 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se public function StatMessage($folderid, $contact) { unset($folderid); // not used (contact_id is global), but required by function signaure - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); + if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); if (!is_array($contact)) $contact = $this->addressbook->read($contact); @@ -511,7 +514,7 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se public function ChangeMessage($folderid, $id, $message, $contentParameters) { unset($contentParameters); // not used, but required by function signature - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); + if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); $type = $account = null; $this->backend->splitID($folderid, $type, $account); @@ -528,13 +531,13 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se debugLog(__METHOD__." Folder wrong or contact not existing"); return false; } - if ($account == 0) // as a precausion, we currently do NOT allow to change accounts + if ($account == 0) // as a precausion, we currently do NOT allow to change Api\Accounts { - debugLog(__METHOD__." Changing of accounts denied!"); - return false; //no changing of accounts + debugLog(__METHOD__." Changing of Api\Accounts denied!"); + return false; //no changing of Api\Accounts } $contact = array(); - if (empty($id) && ($this->addressbook->grants[$account] & EGW_ACL_EDIT) || ($contact = $this->addressbook->read($id)) && $this->addressbook->check_perms(EGW_ACL_EDIT, $contact)) + if (empty($id) && ($this->addressbook->grants[$account] & Acl::EDIT) || ($contact = $this->addressbook->read($id)) && $this->addressbook->check_perms(Acl::EDIT, $contact)) { // remove all fields supported by AS, leaving all unsupported fields unchanged $contact = array_diff_key($contact, array_flip(self::$mapping)); @@ -601,7 +604,7 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se } } // for all-in-one addressbook, account is meaningless and wrong! - // addressbook_bo::save() keeps the owner or sets an appropriate one if none given + // Api\Contacts::save() keeps the owner or sets an appropriate one if none given if (!isset($contact['private'])) $contact['private'] = (int)$is_private; if (!$GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one']) { @@ -670,7 +673,8 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se */ public function DeleteMessage($folderid, $id, $contentParameters) { - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); + unset($contentParameters); // not used, but required by function signature + if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); $ret = $this->addressbook->delete($id); debugLog(__METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret)); @@ -732,7 +736,7 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se if ($type != 'addressbook') return false; - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); + if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); // handle all-in-one addressbook if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] && @@ -783,7 +787,7 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se */ function getSearchResultsGAL($searchquery) { - if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo(); + if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); //error_log(__METHOD__.'('.array2string($searchquery).')'); // only return items in given range, eg. "0-50" @@ -841,8 +845,8 @@ class addressbook_zpush implements activesync_plugin_write, activesync_plugin_se if (!isset($hook_data['setup']) && in_array($hook_data['type'], array('user', 'group'))) { $user = $hook_data['account_id']; - $addressbook_bo = new addressbook_bo(); - $addressbooks = $addressbook_bo->get_addressbooks(EGW_ACL_READ, null, $user); + $addressbook_bo = new Api\Contacts(); + $addressbooks = $addressbook_bo->get_addressbooks(Acl::READ, null, $user); if ($user > 0) { unset($addressbooks[$user]); // personal addressbook is allways synced diff --git a/addressbook/index.php b/addressbook/index.php index 9966fd768a..b078478d17 100755 --- a/addressbook/index.php +++ b/addressbook/index.php @@ -8,6 +8,8 @@ * @version $Id$ */ +use EGroupware\Api; + $GLOBALS['egw_info'] = array( 'flags' => array( 'currentapp' => 'addressbook', @@ -17,10 +19,10 @@ $GLOBALS['egw_info'] = array( include('../header.inc.php'); // check if we have an advanced search and reset it in case -$old_state = $GLOBALS['egw']->session->appsession('index','addressbook'); +$old_state = Api\Cache::getSession('addressbook', 'index'); if ($old_state['advanced_search']) { unset($old_state['advanced_search']); - $GLOBALS['egw']->session->appsession('index','addressbook',$old_state); + Api\Cache::setSession('addressbook', 'index', $old_state); } -$GLOBALS['egw']->redirect_link('/index.php','menuaction=addressbook.addressbook_ui.index'); +Api\Egw::redirect_link('/index.php','menuaction=addressbook.addressbook_ui.index'); diff --git a/addressbook/setup/setup.inc.php b/addressbook/setup/setup.inc.php index bd677eb585..0a6b1da6c4 100755 --- a/addressbook/setup/setup.inc.php +++ b/addressbook/setup/setup.inc.php @@ -10,7 +10,7 @@ /* Basic information about this app */ $setup_info['addressbook']['name'] = 'addressbook'; $setup_info['addressbook']['title'] = 'Addressbook'; -$setup_info['addressbook']['version'] = '14.1'; +$setup_info['addressbook']['version'] = '16.1'; $setup_info['addressbook']['app_order'] = 4; $setup_info['addressbook']['enable'] = 1; $setup_info['addressbook']['index'] = 'addressbook.addressbook_ui.index&ajax=true'; @@ -51,12 +51,8 @@ $setup_info['addressbook']['hooks']['groupdav_root_props'] = 'addressbook_groupd /* Dependencies for this app to work */ $setup_info['addressbook']['depends'][] = array( - 'appname' => 'phpgwapi', - 'versions' => Array('14.1') -); -$setup_info['addressbook']['depends'][] = array( - 'appname' => 'etemplate', - 'versions' => Array('14.1') + 'appname' => 'api', + 'versions' => Array('16.1') ); // installation checks for addresbook diff --git a/addressbook/sitemgr/class.module_addressbook_contactform.inc.php b/addressbook/sitemgr/class.module_addressbook_contactform.inc.php index 5b926fedb5..f9e73b563b 100644 --- a/addressbook/sitemgr/class.module_addressbook_contactform.inc.php +++ b/addressbook/sitemgr/class.module_addressbook_contactform.inc.php @@ -10,6 +10,9 @@ * @version $Id$ */ +use EGroupware\Api; +use EGroupware\Api\Acl; + /** * SiteMgr contact form for the addressbook * @@ -38,7 +41,7 @@ class module_addressbook_contactform extends sitemgr_module */ function get_user_interface() { - $GLOBALS['egw']->translation->add_app('addressbook'); + Api\Translation::add_app('addressbook'); $uicontacts = new addressbook_ui(); @@ -76,7 +79,7 @@ class module_addressbook_contactform extends sitemgr_module 'label' => lang('Addressbook the contact should be saved to').' ('.lang('The anonymous user needs add rights for it!').')', 'options' => array( '' => lang('None'), - )+$uicontacts->get_addressbooks(EGW_ACL_ADD) // add to not show the accounts! + )+$uicontacts->get_addressbooks(Acl::ADD) // add to not show the accounts! ), 'arg4' => array( 'type' => 'textfield', diff --git a/addressbook/sitemgr/class.module_addressbook_display.inc.php b/addressbook/sitemgr/class.module_addressbook_display.inc.php index e3a90be10d..b288930a05 100755 --- a/addressbook/sitemgr/class.module_addressbook_display.inc.php +++ b/addressbook/sitemgr/class.module_addressbook_display.inc.php @@ -1,5 +1,5 @@ translation->add_app('addressbook'); + Api\Translation::add_app('addressbook'); $uicontacts = new addressbook_ui(); @@ -68,7 +71,7 @@ class module_addressbook_display extends sitemgr_module 'label' => lang('Addressbook the contact should be shown').' ('.lang('The anonymous user needs read it!').')', 'options' => array( '' => lang('All'), - )+$uicontacts->get_addressbooks(EGW_ACL_ADD) // add to not show the accounts! + )+$uicontacts->get_addressbooks(Acl::ADD) // add to not show the accounts! ), 'arg2' => array( 'type' => 'select',