Blame view

sources/apps/contacts/ajax/contact/move.php 1.07 KB
03e52840d   Kload   Init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  <?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();
  
  $id = intval($_POST['id']);
  $aid = intval($_POST['aid']);
  $isaddressbook = isset($_POST['isaddressbook']) ? true: false;
  
  // Ownership checking
  try {
  	OCA\Contacts\Addressbook::find($id); // is owner access check
  } catch(Exception $e) {
  	OCP\JSON::error(
  		array(
  			'data' => array(
  				'message' => $e->getMessage(),
  			)
  		)
  	);
  	exit();
  }
  
  try {
  	OCA\Contacts\VCard::moveToAddressBook($aid, $id, $isaddressbook);
  }  catch (Exception $e) {
  	$msg = $e->getMessage();
  	OCP\Util::writeLog('contacts', 'Error moving contacts "'.implode(',', $id).'" to addressbook "'.$aid.'"'.$msg, OCP\Util::ERROR);
  	OC_JSON::error(array('data' => array('message' => $msg,)));
  	exit();
  }
  
  OC_JSON::success(array('data' => array('ids' => $id,)));