aboutsummaryrefslogtreecommitdiffstats
path: root/apps/contacts/ajax
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-06-25 03:41:28 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-06-25 03:42:27 +0200
commit052bd8efbb39096867fdb2c0922b77f468a45ef9 (patch)
treeace06cdccf97e4ac0c632e6da3b30cdaf9389d46 /apps/contacts/ajax
parent51d33768b84fe8467258bfe67a1f9cd7e0f0913a (diff)
downloadnextcloud-server-052bd8efbb39096867fdb2c0922b77f468a45ef9.tar.gz
nextcloud-server-052bd8efbb39096867fdb2c0922b77f468a45ef9.zip
Drag'n'Drop contacts between addressbook. Still needs some css magic.
Diffstat (limited to 'apps/contacts/ajax')
-rw-r--r--apps/contacts/ajax/movetoaddressbook.php41
1 files changed, 41 insertions, 0 deletions
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