summaryrefslogtreecommitdiffstats
path: root/apps/contacts/ajax/contact/move.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/contacts/ajax/contact/move.php')
-rw-r--r--apps/contacts/ajax/contact/move.php30
1 files changed, 9 insertions, 21 deletions
diff --git a/apps/contacts/ajax/contact/move.php b/apps/contacts/ajax/contact/move.php
index a3336c3cb6c..053343c47ed 100644
--- a/apps/contacts/ajax/contact/move.php
+++ b/apps/contacts/ajax/contact/move.php
@@ -7,35 +7,23 @@
* later.
* See the COPYING-README file.
*/
-
+
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
-$ids = $_POST['ids'];
+$id = intval($_POST['id']);
$aid = intval($_POST['aid']);
+$isaddressbook = isset($_POST['isaddressbook']) ? true: false;
+
+// Ownership checking
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);
+ OC_Contacts_VCard::moveToAddressBook($aid, $id, $isaddressbook);
} catch (Exception $e) {
$msg = $e->getMessage();
- OCP\Util::writeLog('contacts', 'Error moving contacts "'.implode(',', $ids).'" to addressbook "'.$aid.'"'.$msg, OCP\Util::ERROR);
+ OCP\Util::writeLog('contacts', 'Error moving contacts "'.implode(',', $id).'" 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
+
+OC_JSON::success(array('data' => array('ids' => $id,))); \ No newline at end of file