summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-02-20 23:42:06 +0100
committerThomas Tanghus <thomas@tanghus.net>2012-02-20 23:42:06 +0100
commit7a49c8e59cfd59f6fa33b4f16b9fe48ac06c7ac2 (patch)
treed775c296244ebf3ff967d5296985e2adf395f01f /apps
parent8ed42623930b16f7cf5d1e02d5f0d0621e50c93d (diff)
parent6540bda238f1b659444016d433c7aeb11873b9be (diff)
downloadnextcloud-server-7a49c8e59cfd59f6fa33b4f16b9fe48ac06c7ac2.tar.gz
nextcloud-server-7a49c8e59cfd59f6fa33b4f16b9fe48ac06c7ac2.zip
Merge gitorious.org:owncloud/owncloud into vcategories
Diffstat (limited to 'apps')
-rw-r--r--apps/contacts/ajax/addproperty.php1
-rw-r--r--apps/contacts/ajax/createaddressbook.php8
-rw-r--r--apps/contacts/ajax/saveproperty.php1
-rw-r--r--apps/contacts/ajax/updateaddressbook.php9
-rw-r--r--apps/contacts/js/contacts.js22
-rw-r--r--apps/contacts/js/interface.js8
-rw-r--r--apps/contacts/js/jquery.inview.js52
-rw-r--r--apps/contacts/lib/vcard.php3
8 files changed, 72 insertions, 32 deletions
diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php
index 03a45532f9b..028974e1c66 100644
--- a/apps/contacts/ajax/addproperty.php
+++ b/apps/contacts/ajax/addproperty.php
@@ -66,6 +66,7 @@ foreach($current as $item) {
if(is_array($value)) {
ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form!
+ $value = array_map('strip_tags', $value);
} else {
$value = strip_tags($value);
}
diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php
index fbd70bae583..28944fe864c 100644
--- a/apps/contacts/ajax/createaddressbook.php
+++ b/apps/contacts/ajax/createaddressbook.php
@@ -13,7 +13,13 @@ OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$userid = OC_User::getUser();
-$bookid = OC_Contacts_Addressbook::add($userid, strip_tags($_POST['name']), null);
+$name = trim(strip_tags($_POST['name']));
+if(!$name) {
+ OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add addressbook with an empty name.'))));
+ OC_Log::write('contacts','ajax/createaddressbook.php: Cannot add addressbook with an empty name: '.strip_tags($_POST['name']), OC_Log::ERROR);
+ exit();
+}
+$bookid = OC_Contacts_Addressbook::add($userid, $name, null);
if(!$bookid) {
OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding addressbook.'))));
OC_Log::write('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OC_Log::ERROR);
diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php
index 6c8132c1dbf..0c9e0cc7836 100644
--- a/apps/contacts/ajax/saveproperty.php
+++ b/apps/contacts/ajax/saveproperty.php
@@ -52,6 +52,7 @@ $checksum = isset($_POST['checksum'])?$_POST['checksum']:null;
// }
if(is_array($value)){ // FIXME: How to strip_tags for compound values?
+ $value = array_map('strip_tags', $value);
ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form!
$value = OC_VObject::escapeSemicolons($value);
} else {
diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/updateaddressbook.php
index b43b5b93a32..211df84b1d1 100644
--- a/apps/contacts/ajax/updateaddressbook.php
+++ b/apps/contacts/ajax/updateaddressbook.php
@@ -15,7 +15,14 @@ OC_JSON::checkAppEnabled('contacts');
$bookid = $_POST['id'];
OC_Contacts_App::getAddressbook($bookid); // is owner access check
-if(!OC_Contacts_Addressbook::edit($bookid, $_POST['name'], null)) {
+$name = trim(strip_tags($_POST['name']));
+if(!$name) {
+ OC_JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.'))));
+ OC_Log::write('contacts','ajax/updateaddressbook.php: Cannot update addressbook with an empty name: '.strip_tags($_POST['name']), OC_Log::ERROR);
+ exit();
+}
+
+if(!OC_Contacts_Addressbook::edit($bookid, $name, null)) {
OC_JSON::error(array('data' => array('message' => $l->t('Error updating addressbook.'))));
OC_Log::write('contacts','ajax/updateaddressbook.php: Error adding addressbook: ', OC_Log::ERROR);
//exit();
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index d33f983a429..0e06b650a18 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -1043,13 +1043,13 @@ Contacts={
return false;
}else{
$.post(OC.filePath('contacts', 'ajax', 'deletebook.php'), { id: bookid},
- function(data) {
- if (data.status == 'success'){
+ function(jsondata) {
+ if (jsondata.status == 'success'){
$('#chooseaddressbook_dialog').dialog('destroy').remove();
Contacts.UI.Contacts.update();
Contacts.UI.Addressbooks.overview();
} else {
- Contacts.UI.messageBox(t('contacts', 'Error'), data.message);
+ Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
//alert('Error: ' + data.message);
}
});
@@ -1059,10 +1059,14 @@ Contacts={
Contacts.UI.notImplemented();
},
submit:function(button, bookid){
- var displayname = $("#displayname_"+bookid).val();
+ var displayname = $("#displayname_"+bookid).val().trim();
var active = $("#edit_active_"+bookid+":checked").length;
var description = $("#description_"+bookid).val();
-
+
+ if(displayname.length == 0) {
+ Contacts.UI.messageBox(t('contacts', 'Error'), t('contacts', 'Displayname cannot be empty.'));
+ return false;
+ }
var url;
if (bookid == 'new'){
url = OC.filePath('contacts', 'ajax', 'createaddressbook.php');
@@ -1070,12 +1074,14 @@ Contacts={
url = OC.filePath('contacts', 'ajax', 'updateaddressbook.php');
}
$.post(url, { id: bookid, name: displayname, active: active, description: description },
- function(data){
- if(data.status == 'success'){
+ function(jsondata){
+ if(jsondata.status == 'success'){
$(button).closest('tr').prev().html(data.page).show().next().remove();
+ Contacts.UI.Contacts.update();
+ } else {
+ Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
}
});
- Contacts.UI.Contacts.update();
},
cancel:function(button, bookid){
$(button).closest('tr').prev().show().next().remove();
diff --git a/apps/contacts/js/interface.js b/apps/contacts/js/interface.js
index fe58a46d247..5908dd767a2 100644
--- a/apps/contacts/js/interface.js
+++ b/apps/contacts/js/interface.js
@@ -124,12 +124,14 @@ Contacts={
url = OC.filePath('contacts', 'ajax', 'updateaddressbook.php');
}
$.post(url, { id: bookid, name: displayname, active: active, description: description },
- function(data){
- if(data.status == 'success'){
+ function(jsondata){
+ if(jsondata.status == 'success'){
$(button).closest('tr').prev().html(data.page).show().next().remove();
+ Contacts.UI.Contacts.update();
+ } else {
+ Contacts.UI.messageBox(t('contacts', 'Error'), jsondata.data.message);
}
});
- Contacts.UI.Contacts.update();
},
cancel:function(button, bookid){
$(button).closest('tr').prev().show().next().remove();
diff --git a/apps/contacts/js/jquery.inview.js b/apps/contacts/js/jquery.inview.js
index a38ab164977..01900b0b4b4 100644
--- a/apps/contacts/js/jquery.inview.js
+++ b/apps/contacts/js/jquery.inview.js
@@ -5,18 +5,40 @@
*/
(function ($) {
var inviewObjects = {}, viewportSize, viewportOffset,
- d = document, w = window, documentElement = d.documentElement, expando = $.expando;
+ d = document, w = window, documentElement = d.documentElement, expando = $.expando, isFiring = false, $elements = {};
$.event.special.inview = {
add: function(data) {
- inviewObjects[data.guid + "-" + this[expando]] = { data: data, $element: $(this) };
+ var inviewObject = { data: data, $element: $(this) }
+ inviewObjects[data.guid + "-" + this[expando]] = inviewObject;
+ var selector = inviewObject.data.selector,
+ $element = inviewObject.$element;
+ var hash = parseInt(getHash( data.guid + this[expando]));
+ $elements[hash] = selector ? $element.find(selector) : $element;
},
remove: function(data) {
try { delete inviewObjects[data.guid + "-" + this[expando]]; } catch(e) {}
+ try {
+ var hash = parseInt(getHash(data.guid + this[expando]));
+ delete($elements[hash]);
+ } catch (e){}
}
};
+
+ function getHash(str){
+ str = str+'';
+ var hash = 0;
+ if (str.length == 0) return hash;
+ for (i = 0; i < str.length; i++) {
+ char = str.charCodeAt(i);
+ hash = ((hash<<5)-hash)+char;
+ hash = hash & hash; // Convert to 32bit integer
+ }
+ return Math.abs(hash);
+ }
+
function getViewportSize() {
var mode, domObject, size = { height: w.innerHeight, width: w.innerWidth };
@@ -46,22 +68,15 @@
}
function checkInView() {
- var $elements = $(), elementsLength, i = 0;
-
- $.each(inviewObjects, function(i, inviewObject) {
- var selector = inviewObject.data.selector,
- $element = inviewObject.$element;
- $elements = $elements.add(selector ? $element.find(selector) : $element);
- });
-
- elementsLength = $elements.length;
- if (elementsLength) {
+ if (isFiring){
+ return;
+ }
+ isFiring = true;
viewportSize = viewportSize || getViewportSize();
viewportOffset = viewportOffset || getViewportOffset();
-
- for (; i<elementsLength; i++) {
- // Ignore elements that are not in the DOM tree
- if (!$.contains(documentElement, $elements[i])) {
+
+ for (var i in $elements) {
+ if (isNaN(parseInt(i))) {
continue;
}
@@ -72,13 +87,14 @@
visiblePartX,
visiblePartY,
visiblePartsMerged;
-
+
// Don't ask me why because I haven't figured out yet:
// viewportOffset and viewportSize are sometimes suddenly null in Firefox 5.
// Even though it sounds weird:
// It seems that the execution of this function is interferred by the onresize/onscroll event
// where viewportOffset and viewportSize are unset
if (!viewportOffset || !viewportSize) {
+ isFiring = false;
return;
}
@@ -100,7 +116,7 @@
$element.data('inview', false).trigger('inview', [false]);
}
}
- }
+ isFiring = false;
}
$(w).bind("scroll resize", function() {
diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php
index de95e732559..a10d052a2d1 100644
--- a/apps/contacts/lib/vcard.php
+++ b/apps/contacts/lib/vcard.php
@@ -309,7 +309,7 @@ class OC_Contacts_VCard{
* @return boolean
*/
public static function delete($id){
- // FIXME: Add error checking.
+ // FIXME: Add error checking. Touch addressbook.
$stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' );
$stmt->execute(array($id));
@@ -334,6 +334,7 @@ class OC_Contacts_VCard{
// FIXME: Add error checking. Deleting a card gives an Kontact/Akonadi error.
$stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' );
$stmt->execute(array($aid,$uri));
+ OC_Contacts_Addressbook::touch($aid);
return true;
}