summaryrefslogtreecommitdiffstats
path: root/apps/contacts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/contacts')
-rw-r--r--apps/contacts/ajax/addproperty.php6
-rw-r--r--apps/contacts/ajax/categories/delete.php13
-rw-r--r--apps/contacts/ajax/categories/rescan.php13
-rw-r--r--apps/contacts/ajax/contactdetails.php6
-rw-r--r--apps/contacts/ajax/contacts.php5
-rw-r--r--apps/contacts/ajax/createaddressbook.php13
-rw-r--r--apps/contacts/ajax/currentphoto.php6
-rw-r--r--apps/contacts/ajax/deletecard.php19
-rw-r--r--apps/contacts/ajax/deleteproperty.php7
-rw-r--r--apps/contacts/ajax/editname.php6
-rw-r--r--apps/contacts/ajax/loadphoto.php6
-rw-r--r--apps/contacts/ajax/loghandler.php40
-rw-r--r--apps/contacts/ajax/movetoaddressbook.php41
-rw-r--r--apps/contacts/ajax/oc_photo.php6
-rw-r--r--apps/contacts/ajax/savecrop.php6
-rw-r--r--apps/contacts/ajax/saveproperty.php12
-rw-r--r--apps/contacts/ajax/updateaddressbook.php13
-rw-r--r--apps/contacts/ajax/uploadimport.php6
-rw-r--r--apps/contacts/ajax/uploadphoto.php9
-rw-r--r--apps/contacts/css/contacts.css11
-rw-r--r--apps/contacts/index.php2
-rw-r--r--apps/contacts/js/contacts.js56
-rw-r--r--apps/contacts/lib/hooks.php9
-rw-r--r--apps/contacts/lib/vcard.php9
-rw-r--r--apps/contacts/thumbnail.php2
25 files changed, 188 insertions, 134 deletions
diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php
index f888b94e386..1b6db0c8f81 100644
--- a/apps/contacts/ajax/addproperty.php
+++ b/apps/contacts/ajax/addproperty.php
@@ -25,11 +25,7 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-function bailOut($msg) {
- OCP\JSON::error(array('data' => array('message' => $msg)));
- OCP\Util::writeLog('contacts','ajax/addproperty.php: '.$msg, OCP\Util::DEBUG);
- exit();
-}
+require_once('loghandler.php');
$id = isset($_POST['id'])?$_POST['id']:null;
$name = isset($_POST['name'])?$_POST['name']:null;
diff --git a/apps/contacts/ajax/categories/delete.php b/apps/contacts/ajax/categories/delete.php
index bee2dbe3f6b..76c23d6487d 100644
--- a/apps/contacts/ajax/categories/delete.php
+++ b/apps/contacts/ajax/categories/delete.php
@@ -10,18 +10,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-foreach ($_POST as $key=>$element) {
- debug('_POST: '.$key.'=>'.print_r($element, true));
-}
-
-function bailOut($msg) {
- OCP\JSON::error(array('data' => array('message' => $msg)));
- OCP\Util::writeLog('contacts','ajax/categories/delete.php: '.$msg, OCP\Util::DEBUG);
- exit();
-}
-function debug($msg) {
- OCP\Util::writeLog('contacts','ajax/categories/delete.php: '.$msg, OCP\Util::DEBUG);
-}
+require_once('../loghandler.php');
$categories = isset($_POST['categories'])?$_POST['categories']:null;
diff --git a/apps/contacts/ajax/categories/rescan.php b/apps/contacts/ajax/categories/rescan.php
index 84a67dec0b1..48ec165381f 100644
--- a/apps/contacts/ajax/categories/rescan.php
+++ b/apps/contacts/ajax/categories/rescan.php
@@ -10,18 +10,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-foreach ($_POST as $key=>$element) {
- debug('_POST: '.$key.'=>'.print_r($element, true));
-}
-
-function bailOut($msg) {
- OCP\JSON::error(array('data' => array('message' => $msg)));
- OCP\Util::writeLog('contacts','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG);
- exit();
-}
-function debug($msg) {
- OCP\Util::writeLog('contacts','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG);
-}
+require_once('../loghandler.php');
$addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser());
if(count($addressbooks) == 0) {
diff --git a/apps/contacts/ajax/contactdetails.php b/apps/contacts/ajax/contactdetails.php
index a6ca10f9c94..b697b1a8e5b 100644
--- a/apps/contacts/ajax/contactdetails.php
+++ b/apps/contacts/ajax/contactdetails.php
@@ -20,11 +20,7 @@
*
*/
-function bailOut($msg) {
- OCP\JSON::error(array('data' => array('message' => $msg)));
- OCP\Util::writeLog('contacts','ajax/contactdetails.php: '.$msg, OCP\Util::DEBUG);
- exit();
-}
+require_once('loghandler.php');
// Check if we are a user
OCP\JSON::checkLoggedIn();
diff --git a/apps/contacts/ajax/contacts.php b/apps/contacts/ajax/contacts.php
index 16730ec9474..4bb7801cb2d 100644
--- a/apps/contacts/ajax/contacts.php
+++ b/apps/contacts/ajax/contacts.php
@@ -18,7 +18,6 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
$active_addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
-error_log('active_addressbooks: '.print_r($active_addressbooks, true));
$contacts_addressbook = array();
$ids = array();
@@ -29,9 +28,7 @@ foreach($active_addressbooks as $addressbook) {
$contacts_addressbook[$addressbook['id']]['displayname'] = $addressbook['displayname'];
}
}
-error_log('ids: '.print_r($ids, true));
$contacts_alphabet = OC_Contacts_VCard::all($ids);
-error_log('contacts_alphabet: '.print_r($contacts_alphabet, true));
// Our new array for the contacts sorted by addressbook
foreach($contacts_alphabet as $contact) {
@@ -48,7 +45,7 @@ foreach($contacts_alphabet as $contact) {
}
$contacts_addressbook[$contact['addressbookid']]['contacts'][] = array('id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'displayname' => htmlspecialchars($display));
}
-
+unset($contacts_alphabet);
uasort($contacts_addressbook, 'cmp');
$tmpl = new OCP\Template("contacts", "part.contacts");
diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php
index 616766bb1a0..2ec5f542bb3 100644
--- a/apps/contacts/ajax/createaddressbook.php
+++ b/apps/contacts/ajax/createaddressbook.php
@@ -12,25 +12,20 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
+require_once('loghandler.php');
$userid = OCP\USER::getUser();
$name = trim(strip_tags($_POST['name']));
if(!$name) {
- OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add addressbook with an empty name.'))));
- OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Cannot add addressbook with an empty name: '.strip_tags($_POST['name']), OCP\Util::ERROR);
- exit();
+ bailOut('Cannot add addressbook with an empty name.');
}
$bookid = OC_Contacts_Addressbook::add($userid, $name, null);
if(!$bookid) {
- OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding addressbook.'))));
- OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OCP\Util::ERROR);
- exit();
+ bailOut('Error adding addressbook: '.$name);
}
if(!OC_Contacts_Addressbook::setActive($bookid, 1)) {
- OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error activating addressbook.'))));
- OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Error activating addressbook: '.$bookid, OCP\Util::ERROR);
- //exit();
+ bailOut('Error activating addressbook.');
}
$addressbook = OC_Contacts_App::getAddressbook($bookid);
$tmpl = new OCP\Template('contacts', 'part.chooseaddressbook.rowfields');
diff --git a/apps/contacts/ajax/currentphoto.php b/apps/contacts/ajax/currentphoto.php
index 5f90128f321..b10e752c453 100644
--- a/apps/contacts/ajax/currentphoto.php
+++ b/apps/contacts/ajax/currentphoto.php
@@ -24,11 +24,7 @@
OCP\JSON::setContentTypeHeader('text/plain');
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-function bailOut($msg) {
- OCP\JSON::error(array('data' => array('message' => $msg)));
- OCP\Util::writeLog('contacts','ajax/currentphoto.php: '.$msg, OCP\Util::ERROR);
- exit();
-}
+require_once('loghandler.php');
if (!isset($_GET['id'])) {
bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php
index 2a6bd277d19..1161c18abda 100644
--- a/apps/contacts/ajax/deletecard.php
+++ b/apps/contacts/ajax/deletecard.php
@@ -19,26 +19,21 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
-function bailOut($msg) {
- OCP\JSON::error(array('data' => array('message' => $msg)));
- OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG);
- exit();
-}
-
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
+require_once('loghandler.php');
// foreach($_SERVER as $key=>$value) {
// OCP\Util::writeLog('contacts','ajax/saveproperty.php: _SERVER: '.$key.'=>'.$value, OCP\Util::DEBUG);
// }
-foreach($_POST as $key=>$value) {
- OCP\Util::writeLog('contacts','ajax/saveproperty.php: _POST: '.$key.'=>'.print_r($value, true), OCP\Util::DEBUG);
-}
-foreach($_GET as $key=>$value) {
- OCP\Util::writeLog('contacts','ajax/saveproperty.php: _GET: '.$key.'=>'.print_r($value, true), OCP\Util::DEBUG);
-}
+// foreach($_POST as $key=>$value) {
+// debug($key.'=>'.print_r($value, true));
+// }
+// foreach($_GET as $key=>$value) {
+// debug($key.'=>'.print_r($value, true));
+// }
$id = isset($_POST['id'])?$_POST['id']:null;
if(!$id) {
diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php
index 55f7e323083..90e5e64903e 100644
--- a/apps/contacts/ajax/deleteproperty.php
+++ b/apps/contacts/ajax/deleteproperty.php
@@ -24,6 +24,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
+require_once('loghandler.php');
$id = $_POST['id'];
$checksum = $_POST['checksum'];
@@ -31,16 +32,14 @@ $checksum = $_POST['checksum'];
$vcard = OC_Contacts_App::getContactVCard( $id );
$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
if(is_null($line)){
- OCP\JSON::error(array('data' => array( 'message' => OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.'))));
+ bailOut(OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.'));
exit();
}
unset($vcard->children[$line]);
if(!OC_Contacts_VCard::edit($id,$vcard)) {
- OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error deleting contact property.'))));
- OCP\Util::writeLog('contacts','ajax/deleteproperty.php: Error deleting contact property', OCP\Util::ERROR);
- exit();
+ bailOut(OC_Contacts_App::$l10n->t('Error deleting contact property.'));
}
OCP\JSON::success(array('data' => array( 'id' => $id )));
diff --git a/apps/contacts/ajax/editname.php b/apps/contacts/ajax/editname.php
index 62cae894b6f..868ca222e0a 100644
--- a/apps/contacts/ajax/editname.php
+++ b/apps/contacts/ajax/editname.php
@@ -9,11 +9,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-function bailOut($msg) {
- OCP\JSON::error(array('data' => array('message' => $msg)));
- OCP\Util::writeLog('contacts','ajax/editname.php: '.$msg, OCP\Util::DEBUG);
- exit();
-}
+require_once('loghandler.php');
$tmpl = new OCP\Template("contacts", "part.edit_name_dialog");
diff --git a/apps/contacts/ajax/loadphoto.php b/apps/contacts/ajax/loadphoto.php
index eac7ca7d02f..61b5356edce 100644
--- a/apps/contacts/ajax/loadphoto.php
+++ b/apps/contacts/ajax/loadphoto.php
@@ -24,11 +24,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-function bailOut($msg) {
- OCP\JSON::error(array('data' => array('message' => $msg)));
- OCP\Util::writeLog('contacts','ajax/loadphoto.php: '.$msg, OCP\Util::DEBUG);
- exit();
-}
+require_once('loghandler.php');
$id = isset($_GET['id']) ? $_GET['id'] : '';
$refresh = isset($_GET['refresh']) ? true : false;
diff --git a/apps/contacts/ajax/loghandler.php b/apps/contacts/ajax/loghandler.php
new file mode 100644
index 00000000000..831b2e50c1e
--- /dev/null
+++ b/apps/contacts/ajax/loghandler.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * ownCloud - Addressbook
+ *
+ * @author Thomas Tanghus
+ * @copyright 2012 Thomas Tanghus <thomas@tanghus.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+function bailOut($msg, $tracelevel=1, $debuglevel=OCP\Util::ERROR) {
+ OCP\JSON::error(array('data' => array('message' => $msg)));
+ debug($msg, $tracelevel, $debuglevel);
+ exit();
+}
+
+function debug($msg, $tracelevel=0, $debuglevel=OCP\Util::DEBUG) {
+ if(PHP_VERSION >= "5.4") {
+ $call = debug_backtrace(false, $tracelevel+1);
+ } else {
+ $call = debug_backtrace(false);
+ }
+ error_log('trace: '.print_r($call, true));
+ $call = $call[$tracelevel];
+ if($debuglevel !== false) {
+ OCP\Util::writeLog('contacts', $call['file'].'. Line: '.$call['line'].': '.$msg, $debuglevel);
+ }
+}
diff --git a/apps/contacts/ajax/movetoaddressbook.php b/apps/contacts/ajax/movetoaddressbook.php
new file mode 100644
index 00000000000..a3336c3cb6c
--- /dev/null
+++ b/apps/contacts/ajax/movetoaddressbook.php
@@ -0,0 +1,41 @@
+<?php
+/**
+* @author Victor Dubiniuk
+* Copyright (c) 2012 Victor Dubiniuk <victor.dubiniuk@gmail.com>
+* Copyright (c) 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.
+*/
+
+OCP\JSON::checkLoggedIn();
+OCP\JSON::checkAppEnabled('contacts');
+OCP\JSON::callCheck();
+
+$ids = $_POST['ids'];
+$aid = intval($_POST['aid']);
+OC_Contacts_App::getAddressbook($aid);
+
+if(!is_array($ids)) {
+ $ids = array($ids,);
+}
+$goodids = array();
+foreach ($ids as $id){
+ try {
+ $card = OC_Contacts_App::getContactObject( intval($id) );
+ if($card) {
+ $goodids[] = $id;
+ }
+ } catch (Exception $e) {
+ OCP\Util::writeLog('contacts', 'Error moving contact "'.$id.'" to addressbook "'.$aid.'"'.$e->getMessage(), OCP\Util::ERROR);
+ }
+}
+try {
+ OC_Contacts_VCard::moveToAddressBook($aid, $ids);
+} catch (Exception $e) {
+ $msg = $e->getMessage();
+ OCP\Util::writeLog('contacts', 'Error moving contacts "'.implode(',', $ids).'" to addressbook "'.$aid.'"'.$msg, OCP\Util::ERROR);
+ OC_JSON::error(array('data' => array('message' => $msg,)));
+}
+
+OC_JSON::success(array('data' => array('ids' => $goodids,))); \ No newline at end of file
diff --git a/apps/contacts/ajax/oc_photo.php b/apps/contacts/ajax/oc_photo.php
index ea25ebf1763..5c50ba92dbe 100644
--- a/apps/contacts/ajax/oc_photo.php
+++ b/apps/contacts/ajax/oc_photo.php
@@ -22,11 +22,7 @@
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-function bailOut($msg) {
- OCP\JSON::error(array('data' => array('message' => $msg)));
- OCP\Util::writeLog('contacts','ajax/oc_photo.php: '.$msg, OCP\Util::ERROR);
- exit();
-}
+require_once('loghandler.php');
if(!isset($_GET['id'])) {
bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
diff --git a/apps/contacts/ajax/savecrop.php b/apps/contacts/ajax/savecrop.php
index 6faf6a173d5..adce6be3b39 100644
--- a/apps/contacts/ajax/savecrop.php
+++ b/apps/contacts/ajax/savecrop.php
@@ -27,11 +27,7 @@ OCP\JSON::callCheck();
// Firefox and Konqueror tries to download application/json for me. --Arthur
OCP\JSON::setContentTypeHeader('text/plain');
-function bailOut($msg) {
- OCP\JSON::error(array('data' => array('message' => $msg)));
- OCP\Util::writeLog('contacts','ajax/savecrop.php: '.$msg, OCP\Util::DEBUG);
- exit();
-}
+require_once('loghandler.php');
$image = null;
diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php
index 6ee9ec90b56..34fc3cc5351 100644
--- a/apps/contacts/ajax/saveproperty.php
+++ b/apps/contacts/ajax/saveproperty.php
@@ -19,21 +19,11 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
-
-function bailOut($msg) {
- OCP\JSON::error(array('data' => array('message' => $msg)));
- OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG);
- exit();
-}
-function debug($msg) {
- OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG);
-}
-
+require_once('loghandler.php');
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-
$id = isset($_POST['id'])?$_POST['id']:null;
$name = isset($_POST['name'])?$_POST['name']:null;
$value = isset($_POST['value'])?$_POST['value']:null;
diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/updateaddressbook.php
index 19b5b3bddce..d3a772c727f 100644
--- a/apps/contacts/ajax/updateaddressbook.php
+++ b/apps/contacts/ajax/updateaddressbook.php
@@ -11,27 +11,22 @@
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
+require_once('loghandler.php');
$bookid = $_POST['id'];
OC_Contacts_App::getAddressbook($bookid); // is owner access check
$name = trim(strip_tags($_POST['name']));
if(!$name) {
- OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.'))));
- OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Cannot update addressbook with an empty name: '.strip_tags($_POST['name']), OCP\Util::ERROR);
- exit();
+ bailOut(OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.'));
}
if(!OC_Contacts_Addressbook::edit($bookid, $name, null)) {
- OCP\JSON::error(array('data' => array('message' => $l->t('Error updating addressbook.'))));
- OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Error adding addressbook: ', OCP\Util::ERROR);
- //exit();
+ bailOut(OC_Contacts_App::$l10n->t('Error updating addressbook.'));
}
if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) {
- OCP\JSON::error(array('data' => array('message' => $l->t('Error (de)activating addressbook.'))));
- OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Error (de)activating addressbook: '.$bookid, OCP\Util::ERROR);
- //exit();
+ bailOut(OC_Contacts_App::$l10n->t('Error (de)activating addressbook.'));
}
$addressbook = OC_Contacts_App::getAddressbook($bookid);
diff --git a/apps/contacts/ajax/uploadimport.php b/apps/contacts/ajax/uploadimport.php
index 463ca161e56..c1e9c8b1ad1 100644
--- a/apps/contacts/ajax/uploadimport.php
+++ b/apps/contacts/ajax/uploadimport.php
@@ -23,11 +23,7 @@
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
-function bailOut($msg) {
- OCP\JSON::error(array('data' => array('message' => $msg)));
- OCP\Util::writeLog('contacts','ajax/uploadimport.php: '.$msg, OCP\Util::ERROR);
- exit();
-}
+require_once('loghandler.php');
$view = OCP\Files::getStorage('contacts');
$tmpfile = md5(rand());
diff --git a/apps/contacts/ajax/uploadphoto.php b/apps/contacts/ajax/uploadphoto.php
index 889de6a1f8b..8545ca84eee 100644
--- a/apps/contacts/ajax/uploadphoto.php
+++ b/apps/contacts/ajax/uploadphoto.php
@@ -27,14 +27,7 @@ OCP\JSON::callCheck();
// Firefox and Konqueror tries to download application/json for me. --Arthur
OCP\JSON::setContentTypeHeader('text/plain');
-function bailOut($msg) {
- OCP\JSON::error(array('data' => array('message' => $msg)));
- OCP\Util::writeLog('contacts','ajax/uploadphoto.php: '.$msg, OCP\Util::DEBUG);
- exit();
-}
-function debug($msg) {
- OCP\Util::writeLog('contacts','ajax/uploadphoto.php: '.$msg, OCP\Util::DEBUG);
-}
+require_once('loghandler.php');
// If it is a Drag'n'Drop transfer it's handled here.
$fn = (isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : false);
diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css
index 6c65db2b772..1766c28761e 100644
--- a/apps/contacts/css/contacts.css
+++ b/apps/contacts/css/contacts.css
@@ -5,9 +5,12 @@
#leftcontent a { padding: 0 0 0 25px; }
#rightcontent { top: 3.5em !important; padding-top: 5px; }
#leftcontent h3 { cursor: pointer; -moz-transition: background 300ms ease 0s; background: none no-repeat scroll 1em center #eee; border-bottom: 1px solid #ddd; border-top: 1px solid #fff; display: block; max-width: 100%; padding: 0.5em 0.8em; color: #666; text-shadow: 0 1px 0 #f8f8f8; font-size: 1.2em; }
-#leftcontent h3:hover { background-color: #DBDBDB; border-bottom: 1px solid #CCCCCC; border-top: 1px solid #D4D4D4; color: #333333; }
+#leftcontent h3:hover,#leftcontent h3:active,#leftcontent h3.active { background-color: #DBDBDB; border-bottom: 1px solid #CCCCCC; border-top: 1px solid #D4D4D4; color: #333333; }
#contacts { position: fixed; background: #fff; max-width: 100%; width: 20em; left: 12.5em; top: 3.7em; bottom: 3em; overflow: auto; padding: 0; margin: 0; }
.contacts a { height: 23px; display: block; left: 12.5em; margin: 0 0 0 0; padding: 0 0 0 25px; }
+.contacts li.ui-draggable { height: 23px; }
+.ui-draggable-dragging { width: 16em; }
+.ui-state-hover { border: 1px solid dashed; }
#bottomcontrols { padding: 0; bottom:0px; height:2.8em; width: 20em; margin:0; background:#eee; border-top:1px solid #ccc; position:fixed; -moz-box-shadow: 0 -3px 3px -3px #000; -webkit-box-shadow: 0 -3px 3px -3px #000; box-shadow: 0 -3px 3px -3px #000;}
#contacts_newcontact { float: left; margin: 0.2em 0 0 1em; }
#chooseaddressbook { float: right; margin: 0.2em 1em 0 0; }
@@ -16,7 +19,7 @@
#contacts_downloadcard {position:relative; float:left; background:url('%webroot%/core/img/actions/download.svg') no-repeat center; }
#contacts_propertymenu { clear: both; max-width: 15em; margin: 2em; }
#contacts_propertymenu_button { position:relative;top:0;left:0; margin: 0; }
-#contacts_propertymenu_dropdown { background-color: #fff; position:relative; right:0; overflow:hidden; text-overflow:ellipsis; /*border: thin solid #1d2d44;*/ -moz-box-shadow:0 0 10px #000; -webkit-box-shadow:0 0 10px #000; box-shadow:0 0 10px #000; -moz-border-radius:0.5em; -webkit-border-radius:0.5em; border-radius:0.5em; -moz-border-radius:0.5em; -webkit-border-radius:0.5em; border-radius:0.5em; }
+#contacts_propertymenu_dropdown { background-color: #fff; position:relative; right:0; overflow:hidden; text-overflow:ellipsis; border: thin solid #1d2d44; box-shadow: 0 3px 5px #bbb; /* -moz-box-shadow:0 0 10px #000; -webkit-box-shadow:0 0 10px #000; box-shadow:0 0 10px #000; -moz-border-radius:0.5em; -webkit-border-radius:0.5em; border-radius:0.5em; -moz-border-radius:0.5em; -webkit-border-radius:0.5em;*/ border-radius: 3px; }
#contacts_propertymenu li { display: block; font-weight: bold; height: 20px; }
#contacts_propertymenu li a { padding: 3px; display: block }
#contacts_propertymenu li:hover { background-color: #1d2d44; }
@@ -30,7 +33,7 @@
#card input[type="text"],input[type="email"],input[type="url"],input[type="tel"],input[type="date"], select, textarea { background-color: #fefefe; border: 0 !important; -webkit-appearance:none !important; -moz-appearance:none !important; -webkit-box-sizing:none !important; -moz-box-sizing:none !important; box-sizing:none !important; -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: none; -moz-border-radius: 0px; -webkit-border-radius: 0px; border-radius: 0px; float: left; }
#card input[type="text"]:hover, input[type="text"]:focus, input[type="text"]:active,input[type="email"]:hover,input[type="url"]:hover,input[type="tel"]:hover,input[type="date"]:hover,input[type="date"],input[type="date"]:hover,input[type="date"]:active,input[type="date"]:active,input[type="date"]:active,input[type="email"]:active,input[type="url"]:active,input[type="tel"]:active, select:hover, select:focus, select:active, textarea:focus, textarea:hover { border: 0 !important; -webkit-appearance:textfield; -moz-appearance:textfield; -webkit-box-sizing:content-box; -moz-box-sizing:content-box; box-sizing:content-box; background:#fff; color:#333; border:1px solid #ddd; -moz-box-shadow:0 1px 1px #ddd, 0 2px 0 #bbb inset; -webkit-box-shadow:0 1px 1px #ddd, 0 1px 0 #bbb inset; box-shadow:0 1px 1px #ddd, 0 1px 0 #bbb inset; -moz-border-radius:.5em; -webkit-border-radius:.5em; border-radius:.5em; outline:none; float: left; }
textarea { width: 80%; min-height: 5em; min-width: 30em; margin: 0 !important; padding: 0 !important; outline: 0 !important;}
-dl.form { width: 100%; float: left; clear: right; margin: 0; padding: 0; }
+dl.form { width: 100%; float: left; clear: right; margin: 0; padding: 0; cursor: normal; }
.form dt { display: table-cell; clear: left; float: left; width: 7em; margin: 0; padding: 0.8em 0.5em 0 0; text-align:right; text-overflow:ellipsis; o-text-overflow: ellipsis; vertical-align: text-bottom; color: #bbb;/* white-space: pre-wrap; white-space: -moz-pre-wrap !important; white-space: -pre-wrap; white-space: -o-pre-wrap;*/ }
.form dd { display: table-cell; clear: right; float: left; margin: 0; padding: 0px; white-space: nowrap; vertical-align: text-bottom; }
label:hover, dt:hover { color: #333; }
@@ -70,7 +73,7 @@ label:hover, dt:hover { color: #333; }
.contactsection { position: relative; float: left; /*max-width: 40em;*/ padding: 0.5em; height: auto: border: thin solid lightgray;/* -webkit-border-radius: 0.5em; -moz-border-radius: 0.5em; border-radius: 0.5em; background-color: #f8f8f8;*/ }
#cropbox { margin: auto; }
-#contacts_details_photo_wrapper { min-width: 80px; }
+#contacts_details_photo_wrapper { min-width: 120px; }
#contacts_details_photo_wrapper.wait { opacity: 0.6; filter:alpha(opacity=0.6); z-index:1000; background: url('%webroot%/core/img/loading.gif') no-repeat center center; cursor: wait; }
#contacts_details_photo { border-radius: 0.5em; border: thin solid #bbb; margin: 0.3em; background: url('%webroot%/core/img/loading.gif') no-repeat center center; -moz-box-shadow: 0 1px 3px #777; -webkit-box-shadow: 0 1px 3px #777; box-shadow: 0 1px 3px #777; }
#contacts_details_photo:hover { background: #fff; cursor: default; }
diff --git a/apps/contacts/index.php b/apps/contacts/index.php
index bdb52c123ce..f6b37409ea7 100644
--- a/apps/contacts/index.php
+++ b/apps/contacts/index.php
@@ -28,6 +28,7 @@ $details = array();
if(is_null($id) && count($contacts) > 0) {
$id = $contacts[0]['id'];
}
+unset($contacts);
if(!is_null($id)) {
$vcard = OC_Contacts_App::getContactVCard($id);
$details = OC_Contacts_VCard::structureContact($vcard);
@@ -66,7 +67,6 @@ $tmpl->assign('phone_types', $phone_types);
$tmpl->assign('email_types', $email_types);
$tmpl->assign('categories', $categories);
$tmpl->assign('addressbooks', $addressbooks);
-$tmpl->assign('contacts', $contacts, false);
$tmpl->assign('details', $details );
$tmpl->assign('id',$id);
$tmpl->printPage();
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index 6f5602c2112..036734049b6 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -314,6 +314,7 @@ Contacts={
return false;
},
add:function(n, fn, aid, isnew){ // add a new contact
+ aid = aid?aid:$('#contacts h3.active').first().data('id');
var localAddcontact = function(n, fn, aid, isnew) {
$.post(OC.filePath('contacts', 'ajax', 'addcontact.php'), { n: n, fn: fn, aid: aid, isnew: isnew },
function(jsondata) {
@@ -380,12 +381,12 @@ Contacts={
if(jsondata.status == 'success'){
var newid = '', bookid;
var curlistitem = $('#contacts li[data-id="'+jsondata.data.id+'"]');
- var newlistitem = curlistitem.prev();
+ var newlistitem = curlistitem.prev('li');
if(newlistitem == undefined) {
- newlistitem = curlistitem.next();
+ newlistitem = curlistitem.next('li');
}
curlistitem.remove();
- if(newlistitem != undefined) {
+ if(!$(newlistitem).is('li')) {
newid = newlistitem.data('id');
bookid = newlistitem.data('id');
}
@@ -1504,6 +1505,36 @@ Contacts={
}
},
Contacts:{
+ drop:function(event, ui) {
+ var dragitem = ui.draggable, droptarget = $(this);
+ //console.log('Drop ' + dragitem.data('id') +' on: ' + droptarget.data('id'));
+ if(dragitem.data('bookid') == droptarget.data('id')) {
+ return false;
+ }
+ var droplist = (droptarget.is('ul'))?droptarget:droptarget.next();
+ $.post(OC.filePath('contacts', 'ajax', 'movetoaddressbook.php'), { ids: dragitem.data('id'), aid: $(this).data('id') },
+ function(jsondata){
+ if(jsondata.status == 'success'){
+ // Do some inserting/removing/sorting magic
+ var name = $(dragitem).find('a').html();
+ var added = false;
+ $(droplist).children().each(function(){
+ if ($(this).text().toLowerCase() > name.toLowerCase()) {
+ $(this).before(dragitem.detach()); //.fadeIn('slow');
+ added = true;
+ return false;
+ }
+ });
+ if(!added) {
+ $(droplist).append(dragitem.detach());
+ }
+ dragitem.data('bookid', droptarget.data('id'));
+ Contacts.UI.Contacts.scrollTo(dragitem.data('id'));
+ } else {
+ OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
+ }
+ });
+ },
// Reload the contacts list.
update:function(id){
$.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),{},function(jsondata){
@@ -1519,6 +1550,23 @@ Contacts={
}
})}, 100);
setTimeout(Contacts.UI.Contacts.lazyupdate, 500);*/
+ if($('#contacts h3').length > 1) {
+ $('#contacts h3,#contacts ul').each(function(index) {
+ var id = $(this).data('id');
+ var accept = 'li:not([data-bookid="'+id+'"])';
+ $(this).droppable({
+ drop: Contacts.UI.Contacts.drop,
+ activeClass: 'ui-state-hover',
+ accept: accept
+ });
+ });
+ $('#contacts li').draggable({
+ revert: 'invalid',
+ axis: 'y', containment: '#contacts',
+ scroll: true, scrollSensitivity: 100,
+ opacity: 0.7, helper: 'clone'
+ });
+ }
});
Contacts.UI.Card.update(id);
}
@@ -1605,6 +1653,8 @@ $(document).ready(function(){
});
$(document).on('click', '.addressbook', function(event){
+ $('#contacts h3').removeClass('active');
+ $(this).addClass('active');
$(this).next().slideToggle(300);
return false;
});
diff --git a/apps/contacts/lib/hooks.php b/apps/contacts/lib/hooks.php
index e74b465a47b..0a920fc519d 100644
--- a/apps/contacts/lib/hooks.php
+++ b/apps/contacts/lib/hooks.php
@@ -21,6 +21,15 @@
*/
/**
+ * The following signals are being emitted:
+ *
+ * OC_Contacts_VCard::post_moveToAddressbook(array('aid' => $aid, 'id' => $id))
+ * OC_Contacts_VCard::pre_deleteVCard(array('aid' => $aid, 'id' => $id, 'uri' = $uri)); (NOTE: the values can be null depending on which method emits them)
+ * OC_Contacts_VCard::post_updateVCard($id)
+ * OC_Contacts_VCard::post_createVCard($newid)
+ */
+
+/**
* This class contains all hooks.
*/
class OC_Contacts_Hooks{
diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php
index 110d721ace0..0f3a08844b1 100644
--- a/apps/contacts/lib/vcard.php
+++ b/apps/contacts/lib/vcard.php
@@ -293,7 +293,7 @@ class OC_Contacts_VCard{
$newid = OCP\DB::insertid('*PREFIX*contacts_cards');
OC_Contacts_Addressbook::touch($aid);
-
+ OC_Hook::emit('OC_Contacts_VCard', 'post_createVCard', $newid);
return $newid;
}
@@ -360,7 +360,7 @@ class OC_Contacts_VCard{
$result = $stmt->execute(array($fn,$data,time(),$id));
OC_Contacts_Addressbook::touch($oldcard['addressbookid']);
-
+ OC_Hook::emit('OC_Contacts_VCard', 'post_updateVCard', $id);
return true;
}
@@ -388,6 +388,7 @@ class OC_Contacts_VCard{
*/
public static function delete($id){
// FIXME: Add error checking.
+ OC_Hook::emit('OC_Contacts_VCard', 'pre_deleteVCard', array('aid' => null, 'id' => $id, 'uri' => null));
$stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' );
$stmt->execute(array($id));
@@ -402,6 +403,7 @@ class OC_Contacts_VCard{
*/
public static function deleteFromDAVData($aid,$uri){
// FIXME: Add error checking. Deleting a card gives an Kontact/Akonadi error.
+ OC_Hook::emit('OC_Contacts_VCard', 'pre_deleteVCard', array('aid' => $aid, 'id' => null, 'uri' => $uid));
$stmt = OCP\DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' );
$stmt->execute(array($aid,$uri));
OC_Contacts_Addressbook::touch($aid);
@@ -559,9 +561,8 @@ class OC_Contacts_VCard{
return false;
}
}
-
+ OC_Hook::emit('OC_Contacts_VCard', 'post_moveToAddressbook', array('aid' => $aid, 'id' => $id));
OC_Contacts_Addressbook::touch($aid);
return true;
}
-
}
diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php
index 8378507163e..a69e9c74f72 100644
--- a/apps/contacts/thumbnail.php
+++ b/apps/contacts/thumbnail.php
@@ -23,7 +23,7 @@
OCP\JSON::checkLoggedIn();
//OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('contacts');
-session_close_write();
+session_write_close();
function getStandardImage(){
//OCP\Response::setExpiresHeader('P10D');