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.
This commit is contained in:
Thomas Tanghus 2012-04-29 22:10:16 +02:00
parent 023479b1e2
commit f6fefe9a36
9 changed files with 27 additions and 125 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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 )));

View File

@ -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 )));

View File

@ -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);

View File

@ -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) {

View File

@ -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'),
);
}
}

View File

@ -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;
}

View File

@ -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-->