From f6fefe9a36b83466bf551065296d8ff56e7ecbb2 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 29 Apr 2012 22:10:16 +0200 Subject: [PATCH] Contacts: Ensure TYPE parameters on email aren't deleted on edit. They are still not shown in the UI. Remove an obsolute file and did some cleanup. --- apps/contacts/ajax/contactdetails.php | 3 -- apps/contacts/ajax/loadcard.php | 2 + apps/contacts/ajax/loadintro.php | 31 ------------ apps/contacts/ajax/newcontact.php | 62 ------------------------ apps/contacts/index.php | 2 + apps/contacts/js/contacts.js | 38 +++++---------- apps/contacts/lib/app.php | 6 +++ apps/contacts/lib/vcard.php | 2 +- apps/contacts/templates/part.contact.php | 6 ++- 9 files changed, 27 insertions(+), 125 deletions(-) delete mode 100644 apps/contacts/ajax/newcontact.php diff --git a/apps/contacts/ajax/contactdetails.php b/apps/contacts/ajax/contactdetails.php index 13c3f80c3b5..87c2ecbcdad 100644 --- a/apps/contacts/ajax/contactdetails.php +++ b/apps/contacts/ajax/contactdetails.php @@ -27,9 +27,6 @@ function bailOut($msg) { OC_Log::write('contacts','ajax/contactdetails.php: '.$msg, OC_Log::DEBUG); exit(); } -function debug($msg) { - OC_Log::write('contacts','ajax/contactdetails.php: '.$msg, OC_Log::DEBUG); -} // Check if we are a user OC_JSON::checkLoggedIn(); diff --git a/apps/contacts/ajax/loadcard.php b/apps/contacts/ajax/loadcard.php index 4b2a65db911..b2650a76f0e 100644 --- a/apps/contacts/ajax/loadcard.php +++ b/apps/contacts/ajax/loadcard.php @@ -47,12 +47,14 @@ $freeSpace=max($freeSpace,0); $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace); $adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); $phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); +$email_types = OC_Contacts_App::getTypesOfProperty('EMAIL'); $tmpl = new OC_Template('contacts','part.contact'); $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize)); $tmpl->assign('adr_types',$adr_types); $tmpl->assign('phone_types',$phone_types); +$tmpl->assign('email_types',$email_types); $tmpl->assign('id',''); $page = $tmpl->fetchPage(); diff --git a/apps/contacts/ajax/loadintro.php b/apps/contacts/ajax/loadintro.php index 7185c5cbe0a..1aa03a62f38 100644 --- a/apps/contacts/ajax/loadintro.php +++ b/apps/contacts/ajax/loadintro.php @@ -20,43 +20,12 @@ * */ -// Init owncloud - -function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); - OC_Log::write('contacts','ajax/loadintro.php: '.$msg, OC_Log::DEBUG); - exit(); -} -function debug($msg) { - OC_Log::write('contacts','ajax/loadintro.php: '.$msg, OC_Log::DEBUG); -} -// foreach ($_POST as $key=>$element) { -// debug('_POST: '.$key.'=>'.$element); -// } - // Check if we are a user OC_JSON::checkLoggedIn(); OC_JSON::checkAppEnabled('contacts'); -// $addressbooks = OC_Contacts_Addressbook::all(OC_USER::getUser()); -// -// $upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize')); -// $post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size')); -// $maxUploadFilesize = min($upload_max_filesize, $post_max_size); -// -// $freeSpace=OC_Filesystem::free_space('/'); -// $freeSpace=max($freeSpace,0); -// $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace); -// $adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); -// $phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); $tmpl = new OC_Template('contacts','part.no_contacts'); -// $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); -// $tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize)); -// $tmpl->assign('adr_types',$adr_types); -// $tmpl->assign('phone_types',$phone_types); -// $tmpl->assign('addressbooks',$addressbooks); -// $tmpl->assign('id',''); $page = $tmpl->fetchPage(); OC_JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/contacts/ajax/newcontact.php b/apps/contacts/ajax/newcontact.php deleted file mode 100644 index 36c37e039e9..00000000000 --- a/apps/contacts/ajax/newcontact.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE - * License as published by the Free Software Foundation; either - * version 3 of the License, or any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU Affero General Public - * License along with this library. If not, see . - * - */ - -// Init owncloud - -function bailOut($msg) { - OC_JSON::error(array('data' => array('message' => $msg))); - OC_Log::write('contacts','ajax/newcontact.php: '.$msg, OC_Log::DEBUG); - exit(); -} -function debug($msg) { - OC_Log::write('contacts','ajax/newcontact.php: '.$msg, OC_Log::DEBUG); -} -foreach ($_POST as $key=>$element) { - debug('_POST: '.$key.'=>'.$element); -} - -// Check if we are a user -OC_JSON::checkLoggedIn(); -OC_JSON::checkAppEnabled('contacts'); - -$addressbooks = OC_Contacts_Addressbook::all(OC_USER::getUser()); - -$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize')); -$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size')); -$maxUploadFilesize = min($upload_max_filesize, $post_max_size); - -$freeSpace=OC_Filesystem::free_space('/'); -$freeSpace=max($freeSpace,0); -$maxUploadFilesize = min($maxUploadFilesize ,$freeSpace); -$adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); -$phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); - -$tmpl = new OC_Template('contacts','part.contact'); -$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); -$tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize)); -$tmpl->assign('adr_types',$adr_types); -$tmpl->assign('phone_types',$phone_types); -$tmpl->assign('addressbooks',$addressbooks); -$tmpl->assign('id',''); -$page = $tmpl->fetchPage(); - -OC_JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/contacts/index.php b/apps/contacts/index.php index d5545e76197..61cec6c24a8 100644 --- a/apps/contacts/index.php +++ b/apps/contacts/index.php @@ -34,6 +34,7 @@ if(!is_null($id)) { } $property_types = OC_Contacts_App::getAddPropertyOptions(); $phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); +$email_types = OC_Contacts_App::getTypesOfProperty('EMAIL'); $categories = OC_Contacts_App::getCategories(); $upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize')); @@ -61,6 +62,7 @@ $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); $tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize)); $tmpl->assign('property_types', $property_types); $tmpl->assign('phone_types', $phone_types); +$tmpl->assign('email_types', $email_types); $tmpl->assign('categories', $categories); $tmpl->assign('addressbooks', $addressbooks); $tmpl->assign('contacts', $contacts); diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index edb7da70407..7333b0e8d42 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -535,36 +535,9 @@ Contacts={ } }); }, - /*loadCategories:function(){ // On loading contact. - var categories = $('#categories_value').find('select'); - if(this.data.CATEGORIES) { - $('#categories_value').data('checksum', this.data.CATEGORIES[0]['checksum']); - } else { - $('#categories_value').data('checksum', ''); - } - categories.find('option').each(function(){ - if(Contacts.UI.Card.hasCategory($(this).val())) { - $(this).attr('selected', 'selected'); - } else { - $(this).removeAttr('selected'); - } - }); - categories.multiselect('refresh'); - },*/ editNew:function(){ // add a new contact this.id = ''; this.fn = ''; this.fullname = ''; this.givname = ''; this.famname = ''; this.addname = ''; this.honpre = ''; this.honsuf = ''; Contacts.UI.Card.add(t('contacts', 'Contact')+';'+t('contacts', 'New')+';;;', t('contacts', 'New Contact'), '', true); - /*$.getJSON(OC.filePath('contacts', 'ajax', 'newcontact.php'),{},function(jsondata){ - if(jsondata.status == 'success'){ - id = ''; - $('#rightcontent').data('id',''); - $('#rightcontent').html(jsondata.data.page); - //Contacts.UI.Card.editName(); - } else { - OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); - //alert(jsondata.data.message); - } - });*/ }, savePropertyInternal:function(name, fields, oldchecksum, checksum){ // TODO: Add functionality for new fields. @@ -1212,6 +1185,7 @@ Contacts={ addMail:function() { //alert('addMail'); $('#emaillist li.template:first-child').clone().appendTo($('#emaillist')).show(); + $('#emaillist li.template:last-child').find('select').addClass('contacts_property'); $('#emaillist li.template:last-child').removeClass('template').addClass('propertycontainer'); $('#emaillist li:last-child').find('input[type="email"]').focus(); Contacts.UI.loadListHandlers(); @@ -1229,6 +1203,16 @@ Contacts={ if(param.toUpperCase() == 'PREF') { $('#emaillist li:last-child').find('input[type="checkbox"]').attr('checked', 'checked') } + else if(param.toUpperCase() == 'TYPE') { + for(etype in this.data.EMAIL[mail]['parameters'][param]) { + var et = this.data.EMAIL[mail]['parameters'][param][etype]; + $('#emaillist li:last-child').find('select option').each(function(){ + if($.inArray($(this).val().toUpperCase(), et.toUpperCase().split(',')) > -1) { + $(this).attr('selected', 'selected'); + } + }); + } + } } } if($('#emaillist li').length > 1) { diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php index ee8b0c550b3..128b9cd660d 100644 --- a/apps/contacts/lib/app.php +++ b/apps/contacts/lib/app.php @@ -121,6 +121,12 @@ class OC_Contacts_App { 'VIDEO' => $l->t('Video'), 'PAGER' => $l->t('Pager'), ); + case 'EMAIL': + return array( + 'WORK' => $l->t('Work'), + 'HOME' => $l->t('Home'), + 'INTERNET' => $l->t('Internet'), + ); } } diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index 96fc8cf7121..d8cce36b80b 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -493,7 +493,7 @@ class OC_Contacts_VCard{ } // NOTE: Apparently Sabre_VObject_Reader can't always deal with value list parameters // like TYPE=HOME,CELL,VOICE. Tanghus. - if ($property->name == 'TEL' && $parameter->name == 'TYPE'){ + if (in_array($property->name, array('TEL', 'EMAIL')) && $parameter->name == 'TYPE'){ if (isset($temp['parameters'][$parameter->name])){ $temp['parameters'][$parameter->name][] = $parameter->value; } diff --git a/apps/contacts/templates/part.contact.php b/apps/contacts/templates/part.contact.php index 64a024c0926..a35d38e8867 100644 --- a/apps/contacts/templates/part.contact.php +++ b/apps/contacts/templates/part.contact.php @@ -71,7 +71,11 @@ $id = isset($_['id']) ? $_['id'] : ''; -- 2.39.5