]> source.dussan.org Git - nextcloud-server.git/commitdiff
UI fixes in contact editor and address book dialog.
authorThomas Tanghus <thomas@tanghus.net>
Thu, 19 Jan 2012 15:04:39 +0000 (16:04 +0100)
committerThomas Tanghus <thomas@tanghus.net>
Thu, 19 Jan 2012 15:07:17 +0000 (16:07 +0100)
Error checking in ajax methods.
Localize menu entry.

apps/contacts/ajax/addproperty.php
apps/contacts/ajax/getdetails.php
apps/contacts/ajax/setproperty.php
apps/contacts/lib/app.php
apps/contacts/photo.php
apps/contacts/templates/part.addcardform.php
apps/contacts/templates/part.chooseaddressbook.php

index 0050f5f49aa115ddd04863880382ebb95562db9c..f016820ce5f492c3ff60b3fef38c813af8652f95 100644 (file)
@@ -35,7 +35,7 @@ $name = $_POST['name'];
 $value = $_POST['value'];
 if(!is_array($value)){
        $value = trim($value);
-       if(!$value && in_array($name, array('TEL', 'EMAIL', 'ORG'))) {
+       if(!$value && in_array($name, array('TEL', 'EMAIL', 'ORG', 'BDAY', 'NICKNAME'))) {
                OC_JSON::error(array('data' => array('message' => $l->t('Cannot add empty property.'))));
                exit();
        }
@@ -72,6 +72,7 @@ foreach ($parameters as $key=>$element) {
                        $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key,$element);
        }
 }
+$checksum = md5($vcard->children[$line]->serialize());
 
 if(!OC_Contacts_VCard::edit($id,$vcard->serialize())) {
        OC_JSON::error(array('data' => array('message' => $l->t('Error adding contact property.'))));
@@ -88,4 +89,4 @@ $tmpl->assign('phone_types',$phone_types);
 $tmpl->assign('property',OC_Contacts_VCard::structureProperty($property,$line));
 $page = $tmpl->fetchPage();
 
-OC_JSON::success(array('data' => array( 'page' => $page )));
+OC_JSON::success(array('data' => array( 'checksum' => $checksum, 'page' => $page )));
index 8cc0f9cbb0fe2f1e91eb8af6a6a94a713fe7b6ab..4819916f4c301ae8d9ab088599f55b9b3aacc53d 100644 (file)
@@ -28,6 +28,7 @@ OC_JSON::checkLoggedIn();
 OC_JSON::checkAppEnabled('contacts');
 
 $id = $_GET['id'];
+$new = isset($_GET['new']) ? true : false;
 $vcard = OC_Contacts_App::getContactVCard( $id );
 
-OC_Contacts_App::renderDetails($id, $vcard);
+OC_Contacts_App::renderDetails($id, $vcard, $new);
index e0cd70236c80df1ab09852cd3f8c96d35e53ce4e..cdc6d34c52472c00106aa9986d6092b7d302cdd5 100644 (file)
@@ -95,4 +95,4 @@ $tmpl->assign('phone_types',$phone_types);
 $tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line],$line));
 $page = $tmpl->fetchPage();
 
-OC_JSON::success(array('data' => array( 'page' => $page, 'line' => $line, 'oldchecksum' => $_POST['checksum'] )));
+OC_JSON::success(array('data' => array( 'page' => $page, 'line' => $line, 'checksum' => $checksum, 'oldchecksum' => $_POST['checksum'] )));
index 00a830d5e5f92070f22914431a07367a2a429cde..bc1e4974b3042b76beb8b7ec9155a8fd99185cc1 100644 (file)
@@ -18,16 +18,26 @@ class OC_Contacts_App{
        * @param int $id of contact
        * @param Sabre_VObject_Component $vcard to render
        */
-       public static function renderDetails($id, $vcard){
+       public static function renderDetails($id, $vcard, $new=false){
                $property_types = self::getAddPropertyOptions();
                $adr_types = self::getTypesOfProperty('ADR');
                $phone_types = self::getTypesOfProperty('TEL');
+               $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);
 
                $details = OC_Contacts_VCard::structureContact($vcard);
                $name = $details['FN'][0]['value'];
-               $tmpl = new OC_Template('contacts','part.details');
+               $t = $new ? 'part.contact' : 'part.details';
+               $tmpl = new OC_Template('contacts',$t);
                $tmpl->assign('details',$details);
                $tmpl->assign('id',$id);
+               $tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
+               $tmpl->assign( 'uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
                $tmpl->assign('property_types',$property_types);
                $tmpl->assign('adr_types',$adr_types);
                $tmpl->assign('phone_types',$phone_types);
index 60dd81140bf13a3e414eda461cecffefd5af1b2f..478ef829cae74a7863d973a1126f9e73923bd09d 100644 (file)
@@ -26,7 +26,9 @@ OC_Util::checkLoggedIn();
 OC_Util::checkAppEnabled('contacts');
 
 $id = $_GET['id'];
-
+if(isset($GET['refresh'])) {
+       header("Cache-Control: no-cache, no-store, must-revalidate");
+}
 $l10n = new OC_L10N('contacts');
 
 $card = OC_Contacts_VCard::find( $id );
@@ -42,28 +44,45 @@ if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
 }
 
 $content = OC_VObject::parse($card['carddata']);
-
+$image = new OC_Image();
 // invalid vcard
 if( is_null($content)){
-       echo $l10n->t('This card is not RFC compatible.');
+       $image->loadFromFile('img/person_large.png');
+       header('Content-Type: '.$image->mimeType());
+       $image();
+       //echo $l10n->t('This card is not RFC compatible.');
        exit();
-}
-// Photo :-)
-foreach($content->children as $child){
-       if($child->name == 'PHOTO'){
-               $mime = 'image/jpeg';
-               foreach($child->parameters as $parameter){
-                       if( $parameter->name == 'TYPE' ){
-                               $mime = $parameter->value;
+} else {
+       // Photo :-)
+       foreach($content->children as $child){
+               if($child->name == 'PHOTO'){
+                       $mime = 'image/jpeg';
+                       foreach($child->parameters as $parameter){
+                               if( $parameter->name == 'TYPE' ){
+                                       $mime = $parameter->value;
+                               }
+                       }
+                       if($image->loadFromBase64($child->value)) {
+                               header('Content-Type: '.$mime);
+                               $image();
+                               exit();
+                       } else {
+                               $image->loadFromFile('img/person_large.png');
+                               header('Content-Type: '.$image->mimeType());
+                               $image();
                        }
+                       //$photo = base64_decode($child->value);
+                       //header('Content-Type: '.$mime);
+                       //header('Content-Length: ' . strlen($photo));
+                       //echo $photo;
+                       //exit();
                }
-               $photo = base64_decode($child->value);
-               header('Content-Type: '.$mime);
-               header('Content-Length: ' . strlen($photo));
-               echo $photo;
-               exit();
        }
 }
+$image->loadFromFile('img/person_large.png');
+header('Content-Type: '.$image->mimeType());
+$image();
+/*
 // Logo :-/
 foreach($content->children as $child){
        if($child->name == 'PHOTO'){
@@ -80,6 +99,6 @@ foreach($content->children as $child){
                exit();
        }
 }
-
+*/
 // Not found :-(
-echo $l10n->t('This card does not contain a photo.');
+//echo $l10n->t('This card does not contain a photo.');
index 53b32188ddf2cb733cffd43ac2ef04df6f79a8c6..11457ff26970bf373b87a09d34e6b8ebe0c50004 100644 (file)
@@ -94,7 +94,7 @@
                        </dd>
                        <dt>
                                <label class="label" for="adr_zipcode"><?php echo $l->t('Zipcode'); ?></label>
-                       </dtl>
+                       </dt>
                        <dd>
                                <input type="text" id="adr_zipcode" name="value[ADR][5]" value="">
                        </dd>
index ba008837f0e58b68276ef211e904f5f0f78d9c85..90894220ef8bdf9a0b1e2bac5006c0f8ce59d44f 100644 (file)
@@ -12,8 +12,8 @@ for($i = 0; $i < count($option_addressbooks); $i++){
 }
 ?>
 <tr>
-       <td colspan="5">
-               <a href="#" onclick="Contacts.UI.Addressbooks.newAddressbook(this);"><?php echo $l->t('New Address Book') ?></a>
+       <td colspan="5" style="padding: 0.5em;">
+               <a class="button" href="#" onclick="Contacts.UI.Addressbooks.newAddressbook(this);"><?php echo $l->t('New Address Book') ?></a>
        </td>
 </tr>
 <tr>