summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-03-27 20:54:16 +0200
committerGeorg Ehrke <dev@georgswebsite.de>2012-03-27 20:54:16 +0200
commit536a3ecb428b9450a188de4a0fcca2f9be6318f3 (patch)
tree26e866877d07e528ca12c1317698f5debe0c30c4 /apps
parentac0c5ba6daf5ffe84088571ea307f5223bd1049a (diff)
parentcb2dd97509ffd039fbd321aea4a8d631e3effcc7 (diff)
downloadnextcloud-server-536a3ecb428b9450a188de4a0fcca2f9be6318f3.tar.gz
nextcloud-server-536a3ecb428b9450a188de4a0fcca2f9be6318f3.zip
Merge branch 'master' into sabredav_1.6
Diffstat (limited to 'apps')
-rw-r--r--apps/contacts/ajax/addproperty.php11
-rw-r--r--apps/contacts/ajax/saveproperty.php29
-rw-r--r--apps/contacts/js/contacts.js15
-rw-r--r--apps/contacts/js/jquery.multi-autocomplete.js13
-rw-r--r--apps/contacts/lib/vcard.php4
-rw-r--r--apps/contacts/templates/part.contact.php18
-rw-r--r--apps/gallery/lib/photo.php17
-rw-r--r--apps/gallery/lib/scanner.php2
8 files changed, 74 insertions, 35 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 )));
diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php
index 95a7ac20193..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;
@@ -83,16 +83,38 @@ 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;
+}
+
+if(!$value) {
+ bailOut(OC_Contacts_App::$l10n->t('Cannot save empty value.'));
+}
+
+/* setting value */
+switch($element) {
+ case 'BDAY':
+ case 'FN':
case 'N':
case 'ORG':
case 'NOTE':
@@ -102,7 +124,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/js/contacts.js b/apps/contacts/js/contacts.js
index 18214cb1cc5..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;
}
@@ -667,9 +670,16 @@ 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 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);
@@ -990,7 +1000,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 +1202,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');
}
}
}
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] == ',') {
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);
}
/**
diff --git a/apps/contacts/templates/part.contact.php b/apps/contacts/templates/part.contact.php
index cb1e080a40a..a93069fa722 100644
--- a/apps/contacts/templates/part.contact.php
+++ b/apps/contacts/templates/part.contact.php
@@ -51,11 +51,11 @@ $id = isset($_['id']) ? $_['id'] : '';
</select><a id="edit_name" class="action edit" title="<?php echo $l->t('Edit name details'); ?>"></a>
</dd>
<dt style="display:none;" id="org_label" data-element="ORG"><label for="org"><?php echo $l->t('Organization'); ?></label></dt>
- <dd style="display:none;" class="propertycontainer" id="org_value" data-element="ORG"><input id="org" required="required" name="value[ORG]" type="text" class="contacts_property" style="width:16em;" name="value" value="" placeholder="<?php echo $l->t('Organization'); ?>" /><a class="delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a></dd>
+ <dd style="display:none;" class="propertycontainer" id="org_value" data-element="ORG"><input id="org" required="required" name="value[ORG]" type="text" class="contacts_property" style="width:16em;" name="value" value="" placeholder="<?php echo $l->t('Organization'); ?>" /><a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a></dd>
<dt style="display:none;" id="nickname_label" data-element="NICKNAME"><label for="nickname"><?php echo $l->t('Nickname'); ?></label></dt>
- <dd style="display:none;" class="propertycontainer" id="nickname_value" data-element="NICKNAME"><input id="nickname" required="required" name="value[NICKNAME]" type="text" class="contacts_property" style="width:16em;" name="value" value="" placeholder="<?php echo $l->t('Enter nickname'); ?>" /><a class="delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a></dd>
+ <dd style="display:none;" class="propertycontainer" id="nickname_value" data-element="NICKNAME"><input id="nickname" required="required" name="value[NICKNAME]" type="text" class="contacts_property" style="width:16em;" name="value" value="" placeholder="<?php echo $l->t('Enter nickname'); ?>" /><a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a></dd>
<dt style="display:none;" id="bday_label" data-element="BDAY"><label for="bday"><?php echo $l->t('Birthday'); ?></label></dt>
- <dd style="display:none;" class="propertycontainer" id="bday_value" data-element="BDAY"><input id="bday" required="required" name="value" type="text" class="contacts_property" value="" placeholder="<?php echo $l->t('dd-mm-yyyy'); ?>" /><a class="delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a></dd>
+ <dd style="display:none;" class="propertycontainer" id="bday_value" data-element="BDAY"><input id="bday" required="required" name="value" type="text" class="contacts_property" value="" placeholder="<?php echo $l->t('dd-mm-yyyy'); ?>" /><a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a></dd>
<!-- dt id="categories_label" data-element="CATEGORIES"><label for="categories"><?php echo $l->t('Categories'); ?></label></dt>
<dd class="propertycontainer" id="categories_value" data-element="CATEGORIES">
<select class="contacts_property" multiple="multiple" id="categories" name="value[]">
@@ -64,11 +64,11 @@ $id = isset($_['id']) ? $_['id'] : '';
<a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"></a>
</dd -->
<dt style="display:none;" id="categories_label" data-element="CATEGORIES"><label for="categories"><?php echo $l->t('Categories'); ?></label></dt>
- <dd style="display:none;" class="propertycontainer" id="categories_value" data-element="CATEGORIES"><input id="categories" required="required" name="value[CATEGORIES]" type="text" class="contacts_property" style="width:16em;" name="value" value="" placeholder="<?php echo $l->t('Categories'); ?>" /><a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a><a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"></a></dd>
+ <dd style="display:none;" class="propertycontainer" id="categories_value" data-element="CATEGORIES"><input id="categories" required="required" name="value[CATEGORIES]" type="text" class="contacts_property" style="width:16em;" name="value" value="" placeholder="<?php echo $l->t('Categories'); ?>" /><a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a><a class="action edit" onclick="$(this).tipsy('hide');OCCategories.edit();" title="<?php echo $l->t('Edit categories'); ?>"></a></dd>
</dl>
</fieldset>
<fieldset id="note" class="formfloat propertycontainer contactpart" style="display:none;" data-element="NOTE">
- <legend><?php echo $l->t('Note'); ?><a class="delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a></legend>
+ <legend><?php echo $l->t('Note'); ?><a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'single');" title="<?php echo $l->t('Delete'); ?>"></a></legend>
<textarea class="contacts_property note" name="value" cols="60" rows="10"></textarea>
</fieldset>
</form>
@@ -84,8 +84,8 @@ $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" 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="mail" title="<?php echo $l->t('Mail to address'); ?>"></a>
- <a class="delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'list');" title="<?php echo $l->t('Delete email address'); ?>"></a></span></li>
+ <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>
+ <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-->
@@ -100,7 +100,7 @@ $id = isset($_['id']) ? $_['id'] : '';
<select multiple="multiple" name="parameters[TYPE][]">
<?php echo html_select_options($_['phone_types'], array()) ?>
</select>
- <a class="delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'list');" title="<?php echo $l->t('Delete phone number'); ?>"></a></li>
+ <a class="action delete" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'list');" title="<?php echo $l->t('Delete phone number'); ?>"></a></li>
</ul><!-- a id="add_phone" class="add" title="<?php echo $l->t('Add phone number'); ?>"></a -->
</div> <!-- Phone numbers -->
@@ -112,7 +112,7 @@ $id = isset($_['id']) ? $_['id'] : '';
<dl class="addresscard template" style="display: none;" data-element="ADR"><dt>
<input class="adr contacts_property" name="value" type="hidden" value="" />
<input type="hidden" class="adr_type contacts_property" name="parameters[TYPE][]" value="" />
- <span class="adr_type_label"></span><a class="globe" style="float:right;" onclick="$(this).tipsy('hide');Contacts.UI.searchOSM(this);" title="<?php echo $l->t('View on map'); ?>"></a><a class="edit" style="float:right;" onclick="$(this).tipsy('hide');Contacts.UI.Card.editAddress(this, false);" title="<?php echo $l->t('Edit address details'); ?>"></a><a class="delete" style="float:right;" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'list');" title="Delete address"></a>
+ <span class="adr_type_label"></span><a class="action globe" style="float:right;" onclick="$(this).tipsy('hide');Contacts.UI.searchOSM(this);" title="<?php echo $l->t('View on map'); ?>"></a><a class="action edit" style="float:right;" onclick="$(this).tipsy('hide');Contacts.UI.Card.editAddress(this, false);" title="<?php echo $l->t('Edit address details'); ?>"></a><a class="action delete" style="float:right;" onclick="$(this).tipsy('hide');Contacts.UI.Card.deleteProperty(this, 'list');" title="Delete address"></a>
</dt><dd><ul class="addresslist"></ul></dd></dl>
</fieldset>
diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php
index 0c0f16e659a..3bb6f9129fa 100644
--- a/apps/gallery/lib/photo.php
+++ b/apps/gallery/lib/photo.php
@@ -66,12 +66,15 @@ 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);
+ 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 c8825c267eb..0317f943e5d 100644
--- a/apps/gallery/lib/scanner.php
+++ b/apps/gallery/lib/scanner.php
@@ -78,9 +78,11 @@ 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();
}
}
imagepng($thumbnail, OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/gallery/' . $albumName.'.png');
+ imagedestroy($thumbnail);
}
public static function createIntermediateAlbums() {