From ec40f69c9e7a6aba39bd74ff1549e70a93357e4f Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sun, 25 Mar 2012 14:16:39 +0200 Subject: [PATCH 01/21] add error 403 site --- .htaccess | 1 + core/templates/403.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 core/templates/403.php diff --git a/.htaccess b/.htaccess index ebb28b0887b..11520d743dc 100644 --- a/.htaccess +++ b/.htaccess @@ -1,3 +1,4 @@ +ErrorDocument 403 /core/templates/403.php ErrorDocument 404 /core/templates/404.php php_value upload_max_filesize 512M diff --git a/core/templates/403.php b/core/templates/403.php new file mode 100644 index 00000000000..cdfef08ac76 --- /dev/null +++ b/core/templates/403.php @@ -0,0 +1,15 @@ +printPage(); + exit; +} +?> + From 102cf150b3a1de43877878debf9aef5f386d543b Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Mon, 26 Mar 2012 02:04:34 +0200 Subject: [PATCH 02/21] Fixed error in OC_Contacts_VCard::addFromDAVData as pointed out by Guillaume ZITTA --- apps/contacts/lib/vcard.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index 3736f18c647..15a6176d40c 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -228,7 +228,7 @@ class OC_Contacts_VCard{ * @param string $uri the uri of the card, default based on the UID * @return insertid on success or null if no card. */ - public static function add($aid, $card, $uri=null){ + public static function add($aid, OC_VObject $card, $uri=null){ if(is_null($card)){ OC_Log::write('contacts','OC_Contacts_VCard::add. No vCard supplied', OC_Log::ERROR); return null; @@ -267,7 +267,7 @@ class OC_Contacts_VCard{ */ public static function addFromDAVData($id,$uri,$data){ $card = OC_VObject::parse($data); - return self::add($id, $data, $uri); + return self::add($id, $card, $uri); } /** From 6ff89dcf727ab140c766c093b6f91b92a50ef7e9 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Mon, 26 Mar 2012 19:13:48 +0200 Subject: [PATCH 03/21] Removed obsolete code. --- apps/contacts/ajax/addproperty.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index e1a31292837..d2c0291e8c6 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -122,13 +122,4 @@ if(!OC_Contacts_VCard::edit($id,$vcard)) { exit(); } -$adr_types = OC_Contacts_App::getTypesOfProperty('ADR'); -$phone_types = OC_Contacts_App::getTypesOfProperty('TEL'); - -$tmpl = new OC_Template('contacts','part.property'); -$tmpl->assign('adr_types',$adr_types); -$tmpl->assign('phone_types',$phone_types); -$tmpl->assign('property',OC_Contacts_VCard::structureProperty($property,$line)); -$page = $tmpl->fetchPage(); - -OC_JSON::success(array('data' => array( 'checksum' => $checksum, 'page' => $page ))); +OC_JSON::success(array('data' => array( 'checksum' => $checksum ))); From 31e20d22834fd492f97ae38e6919f798ab6be932 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 26 Mar 2012 21:45:51 +0200 Subject: [PATCH 04/21] added some authors to the Authors file --- AUTHORS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/AUTHORS b/AUTHORS index 02439884d2f..f618df9311d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -5,6 +5,13 @@ ownCloud is written by: Jan-Christoph Borchardt Michael Gapczynski Arthur Schiwon + Bart Visscher + Georg Ehrke + Brice Maron + Tom Needham + Marvin Thomas Rabe + Florian Pritz + Bartek Przybylski … With help from many libraries and frameworks including: From ee31bc7995eaef0741dc1579d8b6b7e58f359ce4 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Mon, 26 Mar 2012 21:46:18 +0200 Subject: [PATCH 05/21] Contacts: Fix saveproperty for categories --- apps/contacts/ajax/saveproperty.php | 19 ++++++++++++++++++- apps/contacts/templates/part.contact.php | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php index 95a7ac20193..272a3f9b325 100644 --- a/apps/contacts/ajax/saveproperty.php +++ b/apps/contacts/ajax/saveproperty.php @@ -83,16 +83,34 @@ if($element != $name) { bailOut(OC_Contacts_App::$l10n->t('Something went FUBAR. ').$name.' != '.$element); } +/* preprocessing value */ switch($element) { case 'BDAY': $date = New DateTime($value); //$vcard->setDateTime('BDAY', $date, Sabre_VObject_Element_DateTime::DATE); $value = $date->format(DateTime::ATOM); + break; case 'FN': if(!$value) { // create a method thats returns an alternative for FN. //$value = getOtherValue(); } + break; + case 'CATEGORIES': + /* multi autocomplete triggers an save with empty value */ + if (!$value) { + $value = $vcard->getAsString('CATEGORIES'); + } + break; + case 'EMAIL': + $value = strtolower($value); + break; +} + +/* setting value */ +switch($element) { + case 'BDAY': + case 'FN': case 'N': case 'ORG': case 'NOTE': @@ -102,7 +120,6 @@ switch($element) { $vcard->setString($name, $value); break; case 'EMAIL': - $value = strtolower($value); case 'TEL': case 'ADR': // should I delete the property if empty or throw an error? debug('Setting element: (EMAIL/TEL/ADR)'.$element); diff --git a/apps/contacts/templates/part.contact.php b/apps/contacts/templates/part.contact.php index cb1e080a40a..a1acb20b9cb 100644 --- a/apps/contacts/templates/part.contact.php +++ b/apps/contacts/templates/part.contact.php @@ -64,7 +64,7 @@ $id = isset($_['id']) ? $_['id'] : ''; - + From 60a939dfcfceddbe1563e1712044a4a625bc70ac Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Mon, 26 Mar 2012 22:26:06 +0200 Subject: [PATCH 07/21] Small change and muting debug. --- apps/contacts/ajax/saveproperty.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php index 112d9031cea..924d873652c 100644 --- a/apps/contacts/ajax/saveproperty.php +++ b/apps/contacts/ajax/saveproperty.php @@ -35,9 +35,9 @@ function bailOut($msg) { function debug($msg) { OC_Log::write('contacts','ajax/saveproperty.php: '.$msg, OC_Log::DEBUG); } -foreach ($_POST as $key=>$element) { - debug('_POST: '.$key.'=>'.print_r($element, true)); -} +// foreach ($_POST as $key=>$element) { +// debug('_POST: '.$key.'=>'.print_r($element, true)); +// } $id = isset($_POST['id'])?$_POST['id']:null; $name = isset($_POST['name'])?$_POST['name']:null; @@ -71,11 +71,6 @@ if(is_array($value)){ } else { $value = trim(strip_tags($value)); } -if(!$value) { - bailOut(OC_Contacts_App::$l10n->t('Cannot save empty value.')); -} - -debug('Element: '.$name.', value: '.print_r($value, true)); $vcard = OC_Contacts_App::getContactVCard( $id ); $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); @@ -112,6 +107,10 @@ switch($element) { break; } +if(!$value) { + bailOut(OC_Contacts_App::$l10n->t('Cannot save empty value.')); +} + /* setting value */ switch($element) { case 'BDAY': From 0c19e44a61229fe1376c8436b8a73e974b424539 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 26 Mar 2012 22:28:40 +0200 Subject: [PATCH 08/21] some more memory cleanup in OC_Image --- lib/image.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/image.php b/lib/image.php index 60a714880d0..62f35b4fc99 100644 --- a/lib/image.php +++ b/lib/image.php @@ -526,6 +526,7 @@ class OC_Image { imagedestroy($process); return false; } + imagedestroy($this->resource); $this->resource = $process; return true; } @@ -558,7 +559,14 @@ class OC_Image { imagedestroy($process); return false; } + imagedestroy($this->resource); $this->resource = $process; return true; } + + public function __destruct(){ + if(is_resource($this->resource)){ + imagedestroy($this->resource); + } + } } From 0ba93323585cd277d845eb7d7600cd4cac4f84da Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 26 Mar 2012 22:33:37 +0200 Subject: [PATCH 09/21] some more memory cleanup in OC_Image --- lib/image.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/image.php b/lib/image.php index 62f35b4fc99..4717f81af7d 100644 --- a/lib/image.php +++ b/lib/image.php @@ -317,10 +317,7 @@ class OC_Image { */ public function loadFromFileHandle($handle) { OC_Log::write('core',__METHOD__.'(): Trying', OC_Log::DEBUG); - $contents = ''; - while (!feof($handle)) { - $contents .= fread($handle, 8192); - } + $contents = stream_get_contents($handle); if($this->loadFromData($contents)) { return $this->resource; } @@ -486,6 +483,7 @@ class OC_Image { imagedestroy($process); return false; } + imagedestroy($this->resource); $this->resource = $process; return true; } From 3f881f1ca50b50bb1d564c6bdf55789cda10d4d4 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 26 Mar 2012 22:40:38 +0200 Subject: [PATCH 10/21] memory cleanup in gallery --- apps/gallery/lib/photo.php | 6 +++--- apps/gallery/lib/scanner.php | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php index 0c0f16e659a..2263608dcc2 100644 --- a/apps/gallery/lib/photo.php +++ b/apps/gallery/lib/photo.php @@ -66,9 +66,9 @@ class OC_Gallery_Photo { $stmt->execute(array($newpath, $newAlbumId, $oldAlbumId, $oldpath)); } - public static function getThumbnail($image_name, $owner = null) { - if (!$owner) $owner = OC_User::getUser(); - $save_dir = OC_Config::getValue("datadirectory").'/'. $owner .'/gallery/'; + public static function getThumbnail($image_name, $owner = null) { + if (!$owner) $owner = OC_User::getUser(); + $save_dir = OC_Config::getValue("datadirectory").'/'. $owner .'/gallery/'; $save_dir .= dirname($image_name). '/'; $image_path = $image_name; $thumb_file = $save_dir . basename($image_name); diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php index c8825c267eb..34b9bb8da3d 100644 --- a/apps/gallery/lib/scanner.php +++ b/apps/gallery/lib/scanner.php @@ -81,6 +81,7 @@ class OC_Gallery_Scanner { } } imagepng($thumbnail, OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/gallery/' . $albumName.'.png'); + imagedestroy($thumbnail); } public static function createIntermediateAlbums() { From 73c6db5c8e6d876adf7b6c1c91049c66be26ba87 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 26 Mar 2012 23:53:48 +0200 Subject: [PATCH 11/21] crop and resize in a single step when creating thumbnail also so more explicit memory cleanup --- apps/gallery/lib/photo.php | 11 ++++++----- apps/gallery/lib/scanner.php | 1 + lib/image.php | 26 ++++++++++++++++++++------ 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php index 2263608dcc2..3bb6f9129fa 100644 --- a/apps/gallery/lib/photo.php +++ b/apps/gallery/lib/photo.php @@ -72,6 +72,9 @@ class OC_Gallery_Photo { $save_dir .= dirname($image_name). '/'; $image_path = $image_name; $thumb_file = $save_dir . basename($image_name); + if (!is_dir($save_dir)) { + mkdir($save_dir, 0777, true); + } if (file_exists($thumb_file)) { $image = new OC_Image($thumb_file); } else { @@ -81,17 +84,15 @@ class OC_Gallery_Photo { } $image = new OC_Image($image_path); if ($image->valid()) { - $image->centerCrop(); - $image->resize(200); + $image->centerCrop(200); $image->fixOrientation(); - if (!is_dir($save_dir)) { - mkdir($save_dir, 0777, true); - } $image->save($thumb_file); } } if ($image->valid()) { return $image; + }else{ + $image->destroy(); } return null; } diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php index 34b9bb8da3d..6d2d44d428f 100644 --- a/apps/gallery/lib/scanner.php +++ b/apps/gallery/lib/scanner.php @@ -79,6 +79,7 @@ class OC_Gallery_Scanner { if ($image && $image->valid()) { imagecopyresampled($thumbnail, $image->resource(), $i*200, 0, 0, 0, 200, 200, 200, 200); } + $image->destroy(); } imagepng($thumbnail, OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/gallery/' . $albumName.'.png'); imagedestroy($thumbnail); diff --git a/lib/image.php b/lib/image.php index 4717f81af7d..b3c7d52ec2c 100644 --- a/lib/image.php +++ b/lib/image.php @@ -216,7 +216,7 @@ class OC_Image { OC_Log::write('core','OC_Image->fixOrientation() No readable file path set.', OC_Log::DEBUG); return false; } - $exif = @exif_read_data($this->filepath, 'IFD0'); + $exif = @exif_read_data($this->filepath, 'IFD0'); if(!$exif) { return false; } @@ -267,6 +267,7 @@ class OC_Image { if($res) { if(imagealphablending($res, true)) { if(imagesavealpha($res, true)) { + imagedestroy($this->resource); $this->resource = $res; return true; } else { @@ -490,9 +491,10 @@ class OC_Image { /** * @brief Crops the image to the middle square. If the image is already square it just returns. + * @param int maximum size for the result (optional) * @returns bool for success or failure */ - public function centerCrop() { + public function centerCrop($size=0) { if(!$this->valid()) { OC_Log::write('core','OC_Image->centerCrop, No image loaded', OC_Log::ERROR); return false; @@ -512,13 +514,20 @@ class OC_Image { $y = ($height_orig/2) - ($height/2); $x = 0; } - $process = imagecreatetruecolor($width, $height); + if($size>0){ + $targetWidth=$size; + $targetHeight=$size; + }else{ + $targetWidth=$width; + $targetHeight=$height; + } + $process = imagecreatetruecolor($targetWidth, $targetHeight); if ($process == false) { OC_Log::write('core','OC_Image->centerCrop. Error creating true color image',OC_Log::ERROR); imagedestroy($process); return false; } - imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $width, $height, $width, $height); + imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $targetWidth, $targetHeight, $width, $height); if ($process == false) { OC_Log::write('core','OC_Image->centerCrop. Error resampling process image '.$width.'x'.$height,OC_Log::ERROR); imagedestroy($process); @@ -562,9 +571,14 @@ class OC_Image { return true; } - public function __destruct(){ - if(is_resource($this->resource)){ + public function destroy(){ + if($this->valid()){ imagedestroy($this->resource); } + $this->resource=null; + } + + public function __destruct(){ + $this->destroy(); } } From eb3ec05f882ec54cc19009966e62feb31f5577a4 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 26 Mar 2012 23:56:07 +0200 Subject: [PATCH 12/21] fix gallery scan when an image cant be loaded --- apps/gallery/lib/scanner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php index 6d2d44d428f..0317f943e5d 100644 --- a/apps/gallery/lib/scanner.php +++ b/apps/gallery/lib/scanner.php @@ -78,8 +78,8 @@ class OC_Gallery_Scanner { $image = OC_Gallery_Photo::getThumbnail($files[$i]); if ($image && $image->valid()) { imagecopyresampled($thumbnail, $image->resource(), $i*200, 0, 0, 0, 200, 200, 200, 200); + $image->destroy(); } - $image->destroy(); } imagepng($thumbnail, OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/gallery/' . $albumName.'.png'); imagedestroy($thumbnail); From 128d446f39de93ce63bda3b8ef261446ad6efb0b Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 27 Mar 2012 00:21:31 +0200 Subject: [PATCH 13/21] fix timestamps when viewing logs --- settings/js/log.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings/js/log.js b/settings/js/log.js index 3814d9c10bf..ae83f0a6283 100644 --- a/settings/js/log.js +++ b/settings/js/log.js @@ -32,7 +32,7 @@ OC.Log={ row.append(messageTd); var timeTd=$(''); - timeTd.text(formatDate(entry.time)); + timeTd.text(formatDate(entry.time*1000)); row.append(timeTd); $('#log').append(row); } From 266699ddf90a074aa4c4f5b50a63f5f430842bde Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 27 Mar 2012 00:42:15 +0200 Subject: [PATCH 14/21] fix square images not getting proper thumbnails --- lib/image.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/image.php b/lib/image.php index b3c7d52ec2c..4c53dc32f58 100644 --- a/lib/image.php +++ b/lib/image.php @@ -501,7 +501,7 @@ class OC_Image { } $width_orig=imageSX($this->resource); $height_orig=imageSY($this->resource); - if($width_orig === $height_orig) { + if($width_orig === $height_orig and $size==0) { return true; } $ratio_orig = $width_orig/$height_orig; From bcef775d6bc93144316d4eea74f90c5be03576b0 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 27 Mar 2012 01:18:38 +0200 Subject: [PATCH 15/21] Overwrite Download-ZIP if it already exists. We do not want to show alien content. --- lib/files.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/files.php b/lib/files.php index 57ebb9005ad..f1cf7573bae 100644 --- a/lib/files.php +++ b/lib/files.php @@ -64,7 +64,7 @@ class OC_Files { set_time_limit(0); $zip = new ZipArchive(); $filename = get_temp_dir()."/ownCloud.zip"; - if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) { + if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) { exit("cannot open <$filename>\n"); } foreach($files as $file){ @@ -85,7 +85,7 @@ class OC_Files { set_time_limit(0); $zip = new ZipArchive(); $filename = get_temp_dir()."/ownCloud.zip"; - if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) { + if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) { exit("cannot open <$filename>\n"); } $file=$dir.'/'.$files; From 24bc639222b3f4344bed388ca7fd834f8e70dff8 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 27 Mar 2012 01:19:34 +0200 Subject: [PATCH 16/21] Do not use always the same name for download-zip to avoid collisions. --- lib/files.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/files.php b/lib/files.php index f1cf7573bae..e7bfbbc19bb 100644 --- a/lib/files.php +++ b/lib/files.php @@ -63,7 +63,7 @@ class OC_Files { $executionTime = intval(ini_get('max_execution_time')); set_time_limit(0); $zip = new ZipArchive(); - $filename = get_temp_dir()."/ownCloud.zip"; + $filename = get_temp_dir().'/ownCloud_'.mt_rand(10000,99999).'.zip'; if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) { exit("cannot open <$filename>\n"); } @@ -84,7 +84,7 @@ class OC_Files { $executionTime = intval(ini_get('max_execution_time')); set_time_limit(0); $zip = new ZipArchive(); - $filename = get_temp_dir()."/ownCloud.zip"; + $filename = get_temp_dir().'/ownCloud_'.mt_rand(10000,99999).'.zip'; if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==TRUE) { exit("cannot open <$filename>\n"); } From c92fc9bf651e79aa44803eeeed1d16499a5f08e6 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 27 Mar 2012 02:24:52 +0200 Subject: [PATCH 17/21] return path of tmp file like filestorage/common does. Fixes broken folder-/multifile-download. --- lib/filesystemview.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/filesystemview.php b/lib/filesystemview.php index 89e0385fe9c..39e47975b28 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -23,11 +23,11 @@ class OC_FilesystemView { private $fakeRoot=''; - + public function __construct($root){ $this->fakeRoot=$root; } - + public function getAbsolutePath($path){ if(!$path){ $path='/'; @@ -141,7 +141,7 @@ class OC_FilesystemView { while (!feof($handle)) { echo fread($handle, $chunkSize); @ob_flush(); - flush(); + flush(); } return $this->filesize($path); } @@ -282,7 +282,8 @@ class OC_FilesystemView { if($source){ $extention=substr($path,strrpos($path,'.')); $tmpFile=OC_Helper::tmpFile($extention); - return file_put_contents($tmpFile,$source); + file_put_contents($tmpFile,$source); + return $tmpFile; } } } From 0a07e5fdaabfc5652ec96b4179e2c9433ab42002 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 27 Mar 2012 01:09:28 +0200 Subject: [PATCH 18/21] Added some documentation. --- core/js/oc-vcategories.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/js/oc-vcategories.txt b/core/js/oc-vcategories.txt index 76d4245f5eb..31216f80bd3 100644 --- a/core/js/oc-vcategories.txt +++ b/core/js/oc-vcategories.txt @@ -17,7 +17,7 @@ Set the app specific values in your javascript file. This is what I've used for OCCategories.app = 'contacts'; OCCategories.changed = Contacts.UI.Card.categoriesChanged; -If OCCategories.changed point is set that function will be called each time the categories have been changed +If OCCategories.changed is set that function will be called each time the categories have been changed in the editor (add/delete/rescan) to allow the app to update the UI accordingly. The only argument to the function is an array of the updated categories e.g.: @@ -25,4 +25,9 @@ OCCategories.changed = function(categories) { for(var category in categories) { console.log(categories[category]); } -} \ No newline at end of file +} + +To show the categories editor call: + + OCCategories.edit() + From ff038f8766d49b2a4913ef5ae0a206758f2cdaaa Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 27 Mar 2012 10:12:30 +0200 Subject: [PATCH 19/21] Contacts: Update contact list thumbnail when deleting PHOTO. --- apps/contacts/js/contacts.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 18214cb1cc5..82aadb54b84 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -667,6 +667,10 @@ Contacts={ console.log('NOTE or PHOTO'); Contacts.UI.propertyContainerFor(obj).hide(); Contacts.UI.propertyContainerFor(obj).data('checksum', ''); + if(proptype == 'PHOTO') { + console.log('Delete PHOTO'); + Contacts.UI.Contacts.refreshThumbnail(Contacts.UI.Card.id); + } } else { $('dl dt[data-element="'+proptype+'"],dd[data-element="'+proptype+'"]').hide(); $('dl dd[data-element="'+proptype+'"]').data('checksum', ''); @@ -990,7 +994,7 @@ Contacts={ OC.dialogs.alert(response.data.message, t('contacts', 'Error')); } }); - $('#contacts [data-id="'+this.id+'"]').find('a').css('background','url(thumbnail.php?id='+this.id+'&refresh=1'+Math.random()+') no-repeat'); + Contacts.UI.Contacts.refreshThumbnail(this.id); }, addMail:function() { //alert('addMail'); @@ -1192,6 +1196,9 @@ Contacts={ $(this).find('a').css('background','url(thumbnail.php?id='+$(this).data('id')+') no-repeat'); } }); + }, + refreshThumbnail:function(id){ + $('#contacts [data-id="'+id+'"]').find('a').css('background','url(thumbnail.php?id='+id+'&refresh=1'+Math.random()+') no-repeat'); } } } From fa165498ccfe2becbdaf997b4e36336e794cce50 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 27 Mar 2012 12:26:59 +0200 Subject: [PATCH 20/21] Improvements in adding/deleting properties. --- apps/contacts/js/contacts.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 82aadb54b84..e1827027453 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -613,10 +613,12 @@ Contacts={ this.loadPhoto(true); $('#file_upload_form').show(); $('#contacts_propertymenu a[data-type="'+type+'"]').parent().hide(); + $('#file_upload_start').trigger('click'); break; case 'NOTE': $('#note').show(); $('#contacts_propertymenu a[data-type="'+type+'"]').parent().hide(); + $('#note').find('textarea').focus(); break; case 'EMAIL': if($('#emaillist>li').length == 1) { @@ -644,6 +646,7 @@ Contacts={ case 'BDAY': case 'CATEGORIES': $('dl dt[data-element="'+type+'"],dd[data-element="'+type+'"]').show(); + $('dd[data-element="'+type+'"]').find('input').focus(); $('#contacts_propertymenu a[data-type="'+type+'"]').parent().hide(); break; } @@ -670,10 +673,13 @@ Contacts={ if(proptype == 'PHOTO') { console.log('Delete PHOTO'); Contacts.UI.Contacts.refreshThumbnail(Contacts.UI.Card.id); + } else if(proptype == 'NOTE') { + $('#note').find('textarea').val(''); } } else { $('dl dt[data-element="'+proptype+'"],dd[data-element="'+proptype+'"]').hide(); $('dl dd[data-element="'+proptype+'"]').data('checksum', ''); + $('dl dd[data-element="'+proptype+'"]').find('input').val(''); } $('#contacts_propertymenu a[data-type="'+proptype+'"]').parent().show(); Contacts.UI.loading(obj, false); From cb2dd97509ffd039fbd321aea4a8d631e3effcc7 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 27 Mar 2012 12:29:19 +0200 Subject: [PATCH 21/21] Trigger autocomplete wo button. --- apps/contacts/js/jquery.multi-autocomplete.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/contacts/js/jquery.multi-autocomplete.js b/apps/contacts/js/jquery.multi-autocomplete.js index 1c923a2543d..7607de3f918 100644 --- a/apps/contacts/js/jquery.multi-autocomplete.js +++ b/apps/contacts/js/jquery.multi-autocomplete.js @@ -5,14 +5,25 @@ (function( $ ) { $.widget('ui.multiple_autocomplete', { _create: function() { + var self = this; function split( val ) { return val.split( /,\s*/ ); } function extractLast( term ) { return split( term ).pop(); } + function showOptions() { + if(!self.element.autocomplete('widget').is(':visible') && self.element.val().trim() == '') { + self.element.autocomplete('search', ''); + } + } //console.log('_create: ' + this.options['id']); - var self = this; + this.element.bind('click', function( event ) { + showOptions(); + }); + this.element.bind('input', function( event ) { + showOptions(); + }); this.element.bind('blur', function( event ) { var tmp = self.element.val().trim(); if(tmp[tmp.length-1] == ',') {