]> source.dussan.org Git - nextcloud-server.git/commitdiff
CSS cleanup, more error checking, better error messages, general cleanup.
authorThomas Tanghus <thomas@tanghus.net>
Wed, 11 Jan 2012 02:56:53 +0000 (03:56 +0100)
committerThomas Tanghus <thomas@tanghus.net>
Wed, 11 Jan 2012 03:05:30 +0000 (04:05 +0100)
apps/contacts/ajax/addproperty.php
apps/contacts/css/styles.css
apps/contacts/export.php
apps/contacts/index.php
apps/contacts/js/interface.js
apps/contacts/lib/addressbook.php
apps/contacts/lib/app.php
apps/contacts/lib/vcard.php
apps/contacts/templates/index.php
apps/contacts/templates/part.addcardform.php

index 0f76add3c9bc0f11b56f5578e7fbf8bb54adce5c..74f1c3d0e9eecd121b07eee24c0acceb03a22a9e 100644 (file)
@@ -26,13 +26,21 @@ require_once('../../../lib/base.php');
 // Check if we are a user
 OC_JSON::checkLoggedIn();
 OC_JSON::checkAppEnabled('contacts');
+$l=new OC_L10N('contacts');
 
 $id = $_POST['id'];
 $vcard = OC_Contacts_App::getContactVCard( $id );
 
 $name = $_POST['name'];
 $value = $_POST['value'];
-$parameters = isset($_POST['parameters'])?$_POST['parameters']:array();
+if(!is_array($value)){
+       $value = trim($value);
+       if(!$value && in_array($name, array('TEL', 'EMAIL'))) {
+               OC_JSON::error(array('data' => array('message' => $l->t('Cannot add empty property.'))));
+               exit();
+       }
+}
+$parameters = isset($_POST['parameters']) ? $_POST['parameters'] : array();
 
 $property = $vcard->addProperty($name, $value); //, $parameters);
 
index 7b56767bab024fdc84ef97570f4c8ec70a1ae3b3..dfc296a221bd2c515db340deb8430d53765d4ea9 100644 (file)
@@ -8,9 +8,46 @@
 #contacts_details_list { list-style:none; }
 #contacts_details_list li { overflow:visible; }
 #contacts_details_list li p.contacts_property_name { width:25%; float:left;text-align:right;padding-right:0.3em;color:#666; }
-#contacts_details_list li p.contacts_property_data, #contacts_details_list li ul.contacts_property_data { width:72%;float:left; }
+#contacts_details_list li p.contacts_property_data, #contacts_details_list li ul.contacts_property_data { width:72%;float:left; clear: right; }
 #contacts_setproperty_button { margin-left:25%; }
 
+dl.form
+{
+       width: 100%;
+       float: left;
+       clear: right;
+       margin: 1em;
+       padding: 0;
+}
+
+.form dt
+{
+       display: table-cell;
+       clear: left;
+       float: left;
+       min-width: 10em;
+       margin: 0;
+       padding-top: 0.5em;
+       padding-right: 1em;
+       font-weight: bold;
+       text-align:right;
+       vertical-align: text-bottom;
+       bottom: 0px;
+}
+
+.form dd
+{
+       display: table-cell;
+       clear: right;
+       float: left;
+       min-width: 20em;
+       margin: 0;
+       padding: 0;
+       white-space: nowrap;
+       top: 0px;
+}
+.form input { position: relative; width: 20em; }
+
 .contacts_property_data ul, ol.contacts_property_data { list-style:none; }
 .contacts_property_data li { overflow: hidden; }
 .contacts_property_data li label { width:20%; float:left; text-align:right;padding-right:0.3em; }
index fd2d7da175084501d937aab1102d39dfa528ea44..a1e974c962b8169fe9f9d33056e9a2dda36b5426 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
+ * Copyright (c) 2011-2012 Thomas Tanghus <thomas@tanghus.net>
  * This file is licensed under the Affero General Public License version 3 or
  * later.
  * See the COPYING-README file.
@@ -20,9 +20,9 @@ if(isset($book)){
        $cardobjects = OC_Contacts_VCard::all($book);
        header('Content-Type: text/directory');
        header('Content-Disposition: inline; filename=' . str_replace(' ', '_', $addressbook['displayname']) . '.vcf'); 
-       for($i = 0;$i <= count($cardobjects); $i++){
-               echo $cardobjects[$i]['carddata'];
-               //echo '\r\n';
+
+       foreach($cardobjects as $card) {
+               echo $card['carddata'];
        }
 }elseif(isset($contact)){      
        $data = OC_Contacts_App::getContactObject($contact);
index 0b705e71b5d0d5fef423669784b0ef9d4c227fc3..6f65ac1c6055e7b4780e93917f56bfad6aba75f5 100644 (file)
@@ -60,10 +60,10 @@ if(!is_null($id)) {
 
 // Include Style and Script
 OC_Util::addScript('contacts','interface');
-OC_Util::addStyle('contacts','styles');
-OC_Util::addStyle('contacts','formtastic');
+OC_Util::addScript('contacts','jquery.inview');
 OC_Util::addScript('', 'jquery.multiselect');
-OC_Util::addStyle('', 'jquery.multiselect');
+OC_Util::addStyle('contacts','styles');
+//OC_Util::addStyle('contacts','formtastic');
 
 $property_types = OC_Contacts_App::getAddPropertyOptions();
 $adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
index 4a27073c156bb52bfd6cd0839b54f0c153b891b5..9547c581c878157ca58c8ad3039f3f857f4b35f6 100644 (file)
@@ -29,18 +29,28 @@ Contacts={
                        $('#carddav_url_close').show();
                },
                messageBox:function(title, msg) {
-                       var $dialog = $('<div></div>')
-                               .html(msg)
-                               .dialog({
-                                       autoOpen: true,
-                                       title: title,buttons: [
+                       if($('#messagebox').dialog('isOpen') == true){
+                               // NOTE: Do we ever get here?
+                               $('#messagebox').dialog('moveToTop');
+                       }else{
+                               $('#dialog_holder').load(OC.filePath('contacts', 'ajax', 'messagebox.php'), function(){
+                                       $('#messagebox').dialog(
                                                {
-                                                       text: "Ok",
-                                                       click: function() { $(this).dialog("close"); }
-                                               }
-                                       ]
-                               }
-                       );                      
+                                                       autoOpen: true,
+                                                       title: title,
+                                                       buttons: [{
+                                                                               text: "Ok",
+                                                                               click: function() { $(this).dialog("close"); }
+                                                                       }],
+                                                       close: function(event, ui) {
+                                                               $(this).dialog('destroy').remove();
+                                                       },
+                                                       open: function(event, ui) {
+                                                               $('#messagebox_msg').html(msg);
+                                                       }
+                                       });
+                               });
+                       }
                },
                Addressbooks:{
                        overview:function(){
@@ -159,6 +169,10 @@ $(document).ready(function(){
        /*-------------------------------------------------------------------------
         * Event handlers
         *-----------------------------------------------------------------------*/
+       
+       /**
+        * Load the details view for a contact.
+        */
        $('#leftcontent li').live('click',function(){
                var id = $(this).data('id');
                var oldid = $('#rightcontent').data('id');
@@ -179,6 +193,9 @@ $(document).ready(function(){
                return false;
        });
 
+       /**
+        * Delete currently selected contact (and clear form?)
+        */
        $('#contacts_deletecard').live('click',function(){
                var id = $('#rightcontent').data('id');
                $.getJSON('ajax/deletecard.php',{'id':id},function(jsondata){
@@ -195,6 +212,10 @@ $(document).ready(function(){
                return false;
        });
 
+       /**
+        * Add a property to the contact.
+        * NOTE: Where does 'contacts_addproperty' exist?
+        */
        $('#contacts_addproperty').live('click',function(){
                var id = $('#rightcontent').data('id');
                $.getJSON('ajax/showaddproperty.php',{'id':id},function(jsondata){
@@ -204,12 +225,15 @@ $(document).ready(function(){
                        }
                        else{
                                Contacts.UI.messageBox('Error', jsondata.data.message);
-                               //alert(jsondata.data.message);
+                               alert('From handler: '+jsondata.data.message);
                        }
                });
                return false;
        });
 
+       /**
+        * Change the inputs based on which type of property is selected for addition.
+        */
        $('#contacts_addpropertyform [name="name"]').live('change',function(){
                $('#contacts_addpropertyform #contacts_addresspart').remove();
                $('#contacts_addpropertyform #contacts_phonepart').remove();
@@ -234,12 +258,14 @@ $(document).ready(function(){
                        }
                        else{
                                Contacts.UI.messageBox('Error', jsondata.data.message);
-                               //alert(jsondata.data.message);
                        }
                }, 'json');
                return false;
        });
 
+       /**
+        * Show the Addressbook chooser
+        */
        $('#chooseaddressbook').click(function(){
                Contacts.UI.Addressbooks.overview();
                return false;
@@ -292,6 +318,10 @@ $(document).ready(function(){
                }, 'json');
                return false;
        });
+       
+       /**
+        * Show inputs for editing a property.
+        */
        $('.contacts_property [data-use="edit"]').live('click',function(){
                var id = $('#rightcontent').data('id');
                var checksum = $(this).parents('.contacts_property').first().data('checksum');
@@ -308,6 +338,9 @@ $(document).ready(function(){
                return false;
        });
 
+       /**
+        * Save the edited property
+        */
        $('#contacts_setpropertyform input[type="submit"]').live('click',function(){
                $.post('ajax/setproperty.php',$(this).parents('form').first().serialize(),function(jsondata){
                        if(jsondata.status == 'success'){
index 78792f5f9482329f6f22117ee4f49cde1ab9ecce..41d488c09f90c69dea6d6b4a9eb7213242b14cab 100644 (file)
@@ -203,15 +203,6 @@ class OC_Contacts_Addressbook{
                while( $row = $result->fetchRow()){
                        $addressbooks[] = $row;
                }
-               /*
-               foreach( $active as $aid ){
-                       $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id = ? ORDER BY displayname' );
-                       $result = $stmt->execute(array($aid,));
-
-                       while( $row = $result->fetchRow()){
-                               $addressbooks[] = $row;
-                       }
-               }*/
 
                return $addressbooks;
        }
@@ -240,6 +231,7 @@ class OC_Contacts_Addressbook{
                                unset($openaddressbooks[array_search($id, $openaddressbooks)]);
                        }
                }
+               // NOTE: Ugly hack...
                $openaddressbooks = self::cleanArray($openaddressbooks, false);
                sort($openaddressbooks, SORT_NUMERIC);
                // FIXME: I alway end up with a ';' prepending when imploding the array..?
index 79e00920a65fbc00201569bb2f86ea864dfb45ad..907ce82c76af4517b05f34b2b437559d633ed635 100644 (file)
@@ -73,6 +73,7 @@ class OC_Contacts_App{
                for($i=0;$i<count($vcard->children);$i++){
                        if(md5($vcard->children[$i]->serialize()) == $checksum ){
                                $line = $i;
+                               break;
                        }
                }
                if(is_null($line)){
index 6a248ff59e4eac7e9cf30b9f4e1185b294efb354..401f962254729f4b7694ab3e5412d92f33c96847 100644 (file)
@@ -151,6 +151,7 @@ class OC_Contacts_VCard{
                        foreach($card->children as $property){
                                if($property->name == 'FN'){
                                        $fn = $property->value;
+                                       break;
                                }
                        }
                }
@@ -178,6 +179,7 @@ class OC_Contacts_VCard{
                        foreach($card->children as $property){
                                if($property->name == 'FN'){
                                        $fn = $property->value;
+                                       break;
                                }
                        }
                }
@@ -206,6 +208,7 @@ class OC_Contacts_VCard{
                        foreach($card->children as $property){
                                if($property->name == 'FN'){
                                        $fn = $property->value;
+                                       break;
                                }
                        }
                }
index 24484231af44d8b681e675afb535827fdf644c0e..d548f17172d955b701b0ffdbc507ad8c584ab7a1 100644 (file)
@@ -1,10 +1,3 @@
-<?php // Include Style and Script
-//OC_Util::addScript('contacts','interface'); // this line caused entry duplication, cause contacts/index.php already inlcudes it
-OC_Util::addScript('contacts','jquery.inview');
-OC_Util::addStyle('contacts','styles');
-OC_Util::addStyle('contacts','formtastic');
-?>
-
 <script type='text/javascript'>
        var totalurl = '<?php echo OC_Helper::linkTo('contacts', 'carddav.php', null, true); ?>/addressbooks';
 </script>
index 627053547addae94f6262759cdeae91c152d09fc..510096a9e81d36ccc90b8c9d07211261df13e038 100644 (file)
                <input type="hidden" name="id" value="<?php echo $_['addressbooks'][0]['id']; ?>">
        <?php else: ?>
                <fieldset class="inputs">
-                       <ol>
-                               <li class="input stringish">
+                       <dl class="form">
+                               <dt>
                                        <label class="label" for="id"><?php echo $l->t('Group'); ?></label>
+                               </dt>
+                               <dd>
                                        <select name="id" size="1">
                                                <?php echo html_select_options($_['addressbooks'], null, array('value'=>'id', 'label'=>'displayname')); ?>
                                        </select>
-                               </li>
-                       </ol>
+                               </dd>
+                       </dl>
                </fieldset>
        <?php endif; ?>
        <fieldset class="inputs">
-               <ol>
-                       <li class="input stringish">
+               <dl class="form">
+                       <dt>
                                <label class="label" for="fn"><?php echo $l->t('Name'); ?></label>
+                       </dd>
+                       <dd>
                                <input id="fn" type="text" name="fn" value=""><br>
-                       </li>
-                       <li class="input stringish">
+                       </dd>
+                       <dt>
                                <label class="label" for="org"><?php echo $l->t('Organization'); ?></label>
+                       </dt>
+                       <dd>
                                <input id="org" type="text" name="value[ORG]" value="">
-                       </li>
-               </ol>
+                       </dd>
+               </dl>
        </fieldset>
        <fieldset class="inputs">
-               <ol>
-                       <li class="input stringish">
+               <dl class="form">
+                       <dt>
                                <label class="label" for="email"><?php echo $l->t('Email'); ?></label>
+                       </dt>
+                       <dd>
                                <input id="email" type="text" name="value[EMAIL]" value="">
-                       </li>
-                       <li class="input">
-                               <fieldset class="fragments">
-                                       <legend class="label">
-                                               <label for="tel"><?php echo $l->t('Telephone'); ?></label>
-                                       </legend>
-                                       <ol class="fragments-group">
-                                               <li class="fragment">
-                                                       <label for="tel"><?php echo $l->t('Number'); ?></label>
-                                                       <input type="phone" id="tel" name="value[TEL]" value="">
-                                               </li>
-                                               <li class="fragment">
-                                                       <label for="tel_type"><?php echo $l->t('Type'); ?></label>
-                                                       <select id="TEL" name="parameters[TEL][TYPE][]" multiple="multiple">
-                                                               <?php echo html_select_options($_['phone_types'], 'CELL') ?>
-                                                       </select>
-                                               </li>
-                                       </ol>
-                               </fieldset>
-                       </li>
-               </ol>
+                       </dd>
+                       <dt>
+                               <label for="tel"><?php echo $l->t('Telephone'); ?></label>
+                       </dt>
+                       <dd>
+                               <input type="phone" id="tel" name="value[TEL]" value="">
+                               <select id="TEL" name="parameters[TEL][TYPE][]" multiple="multiple">
+                                       <?php echo html_select_options($_['phone_types'], 'CELL') ?>
+                               </select>
+                       </dd>
+               </dl>
        </fieldset>
        <fieldset class="inputs">
                <legend><?php echo $l->t('Address'); ?></legend>
-               <ol>
-                       <li class="input">
+               <dl class="form">
+                       <dt>
                                <label class="label" for="adr_type"><?php echo $l->t('Type'); ?></label>
+                       </dt>
+                       <dd>
                                <select id="adr_type" name="parameters[ADR][TYPE]" size="1">
                                        <?php echo html_select_options($_['adr_types'], 'HOME') ?>
                                </select>
-                       </li>
-                       <li class="input stringish">
+                       </dd>
+                       <dt>
                                <label class="label" for="adr_pobox"><?php echo $l->t('PO Box'); ?></label>
+                       </dt>
+                       <dd>
                                <input type="text" id="adr_pobox" name="value[ADR][0]" value="">
-                       </li>
-                       <li class="input stringish">
+                       </dd>
+                       <dd>
+                       <dt>
                                <label class="label" for="adr_extended"><?php echo $l->t('Extended'); ?></label>
+                       </dt>
+                       <dd>
                                <input type="text" id="adr_extended" name="value[ADR][1]" value="">
-                       </li>
-                       <li class="input stringish">
+                       </dd>
+                       <dt>
                                <label class="label" for="adr_street"><?php echo $l->t('Street'); ?></label>
+                       </dt>
+                       <dd>
                                <input type="text" id="adr_street" name="value[ADR][2]" value="">
-                       </li>
-                       <li class="input stringish">
+                       </dd>
+                       <dt>
                                <label class="label" for="adr_city"><?php echo $l->t('City'); ?></label>
+                       </dt>
+                       <dd>
                                <input type="text" id="adr_city" name="value[ADR][3]" value="">
-                       </li>
-                       <li class="input stringish">
+                       </dd>
+                       <dt>
                                <label class="label" for="adr_region"><?php echo $l->t('Region'); ?></label>
+                       </dt>
+                       <dd>
                                <input type="text" id="adr_region" name="value[ADR][4]" value="">
-                       </li>
-                       <li class="input stringish">
+                       </dd>
+                       <dt>
                                <label class="label" for="adr_zipcode"><?php echo $l->t('Zipcode'); ?></label>
+                       </dtl>
+                       <dd>
                                <input type="text" id="adr_zipcode" name="value[ADR][5]" value="">
-                       </li>
-                       <li class="input stringish">
+                       </dd>
+                       <dt>
                                <label class="label" for="adr_country"><?php echo $l->t('Country'); ?></label>
+                       </dt>
+                       <dd>
                                <input type="text" id="adr_country" name="value[ADR][6]" value="">
-                       </li>
-               </ol>
+                       </dd>
+               </dl>
        </fieldset>
        <fieldset class="buttons">
                <ol>