]> source.dussan.org Git - nextcloud-server.git/commitdiff
Contacts: Ensure TYPE parameters on email aren't deleted on edit. They are still...
authorThomas Tanghus <thomas@tanghus.net>
Sun, 29 Apr 2012 20:10:16 +0000 (22:10 +0200)
committerThomas Tanghus <thomas@tanghus.net>
Sun, 29 Apr 2012 20:12:27 +0000 (22:12 +0200)
Remove an obsolute file and did some cleanup.

apps/contacts/ajax/contactdetails.php
apps/contacts/ajax/loadcard.php
apps/contacts/ajax/loadintro.php
apps/contacts/ajax/newcontact.php [deleted file]
apps/contacts/index.php
apps/contacts/js/contacts.js
apps/contacts/lib/app.php
apps/contacts/lib/vcard.php
apps/contacts/templates/part.contact.php

index 13c3f80c3b5a9d1b1fa4741116d259ab56d53813..87c2ecbcdadb4cce49335088a32568faa71eb6fd 100644 (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();
index 4b2a65db911e12b4cf1d65f5a3265f2909668759..b2650a76f0e3ed698511ea8c875bd36d04a1441e 100644 (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();
 
index 7185c5cbe0ace8e5e3063b73e0cac910ded6241f..1aa03a62f3820b7cec2edb2726ea6e330c815368 100644 (file)
  *
  */
 
-// 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 (file)
index 36c37e0..0000000
+++ /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 )));
index d5545e761971600cc73d29d4af3fa83a55dbab37..61cec6c24a8079b5b33138d5361a938ac81af0f0 100644 (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);
index edb7da70407be80a20a56f729dc2c5fc8d38456d..7333b0e8d42271f52689d151bcc8c9dcb2ccb648 100644 (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) {
index ee8b0c550b3aef014cb9078e20aa779d00f70fa5..128b9cd660d5530d3d1ae6c0dc1fd6934fb2b2e7 100644 (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'),
+                       );
                }
        }
 
index 96fc8cf71211281ce74fb063bdc951bac0317ce3..d8cce36b80bc746462ef8578ec930724bd9bf2ac 100644 (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;
                                }
index 64a024c0926d56cdfdf1dcc348761c84f3d7ae8d..a35d38e8867434cde8546d9c5d57c0920da2faa3 100644 (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-->