1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-04 15:24:35 +01:00
OwncloudContactsOfficial/ajax/contact/move.php

41 lines
1.1 KiB
PHP
Raw Normal View History

<?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.
*/
2012-08-16 00:24:38 +02:00
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
2012-08-16 00:24:38 +02:00
$id = intval($_POST['id']);
$aid = intval($_POST['aid']);
2012-08-16 00:24:38 +02:00
$isaddressbook = isset($_POST['isaddressbook']) ? true: false;
// Ownership checking
2012-10-05 05:05:49 +02:00
try {
2012-10-25 03:34:12 +02:00
OCA\Contacts\Addressbook::find($id); // is owner access check
2012-10-05 05:05:49 +02:00
} catch(Exception $e) {
OCP\JSON::error(
array(
'data' => array(
'message' => $e->getMessage(),
)
)
);
exit();
}
try {
2012-10-25 03:34:12 +02:00
OCA\Contacts\VCard::moveToAddressBook($aid, $id, $isaddressbook);
} catch (Exception $e) {
$msg = $e->getMessage();
2012-08-16 00:24:38 +02:00
OCP\Util::writeLog('contacts', 'Error moving contacts "'.implode(',', $id).'" to addressbook "'.$aid.'"'.$msg, OCP\Util::ERROR);
OC_JSON::error(array('data' => array('message' => $msg,)));
}
2012-08-16 00:24:38 +02:00
OC_JSON::success(array('data' => array('ids' => $id,)));