summaryrefslogtreecommitdiffstats
path: root/apps/contacts
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-04-29 22:10:16 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-04-29 22:12:27 +0200
commitf6fefe9a36b83466bf551065296d8ff56e7ecbb2 (patch)
tree335facdc1b71e18628c86cf8059a56f9ba5d40c8 /apps/contacts
parent023479b1e2a8f33e7d540bd77dc7d1070f9554f8 (diff)
downloadnextcloud-server-f6fefe9a36b83466bf551065296d8ff56e7ecbb2.tar.gz
nextcloud-server-f6fefe9a36b83466bf551065296d8ff56e7ecbb2.zip
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.
Diffstat (limited to 'apps/contacts')
-rw-r--r--apps/contacts/ajax/contactdetails.php3
-rw-r--r--apps/contacts/ajax/loadcard.php2
-rw-r--r--apps/contacts/ajax/loadintro.php31
-rw-r--r--apps/contacts/ajax/newcontact.php62
-rw-r--r--apps/contacts/index.php2
-rw-r--r--apps/contacts/js/contacts.js38
-rw-r--r--apps/contacts/lib/app.php6
-rw-r--r--apps/contacts/lib/vcard.php2
-rw-r--r--apps/contacts/templates/part.contact.php6
9 files changed, 27 insertions, 125 deletions
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 @@
-<?php
-/**
- * ownCloud - Addressbook
- *
- * @author Thomas Tanghus
- * @copyright 2012 Thomas Tanghus <thomas@tanghus.net>
- *
- * 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 <http://www.gnu.org/licenses/>.
- *
- */
-
-// 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'] : '';
<ul id="emaillist" class="propertylist">
<li class="template" style="white-space: nowrap; display: none;" data-element="EMAIL">
<input type="checkbox" class="contacts_property tip" name="parameters[TYPE][]" value="PREF" title="<?php echo $l->t('Preferred'); ?>" />
- <input type="email" required="required" class="nonempty contacts_property" style="width:15em;" name="value" value="" x-moz-errormessage="<?php echo $l->t('Please specify a valid email address.'); ?>" placeholder="<?php echo $l->t('Enter email address'); ?>" /><span class="listactions"><a onclick="Contacts.UI.mailTo(this)" class="action mail" title="<?php echo $l->t('Mail to address'); ?>"></a>
+ <input type="email" required="required" class="nonempty contacts_property" style="width:15em;" name="value" value="" x-moz-errormessage="<?php echo $l->t('Please specify a valid email address.'); ?>" placeholder="<?php echo $l->t('Enter email address'); ?>" />
+ <select class="hidden" multiple="multiple" name="parameters[TYPE][]">
+ <?php echo html_select_options($_['email_types'], array()) ?>
+ </select>
+ <span class="listactions"><a onclick="Contacts.UI.mailTo(this)" class="action mail" title="<?php echo $l->t('Mail to address'); ?>"></a>
<a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'list');" title="<?php echo $l->t('Delete email address'); ?>"></a></span></li>
</ul><!-- a id="add_email" class="add" title="<?php echo $l->t('Add email address'); ?>"></a -->
</div> <!-- email addresses-->