summaryrefslogtreecommitdiffstats
path: root/apps/contacts/ajax
diff options
context:
space:
mode:
authorFrank Karlitschek <frank@owncloud.org>2012-08-26 17:30:07 +0200
committerFrank Karlitschek <frank@owncloud.org>2012-08-26 17:30:07 +0200
commit72e9a2ce57ee88503db83614cec5ccda71f0b58e (patch)
tree8bc301ca22d9ca08ea54426bcb61f62bd1c1cb75 /apps/contacts/ajax
parent32bad688bdb4fea55eba9d4255fc55f1c60a0aca (diff)
downloadnextcloud-server-72e9a2ce57ee88503db83614cec5ccda71f0b58e.tar.gz
nextcloud-server-72e9a2ce57ee88503db83614cec5ccda71f0b58e.zip
moved to apps repository
Diffstat (limited to 'apps/contacts/ajax')
-rw-r--r--apps/contacts/ajax/addressbook/activate.php32
-rw-r--r--apps/contacts/ajax/addressbook/add.php37
-rw-r--r--apps/contacts/ajax/addressbook/delete.php36
-rw-r--r--apps/contacts/ajax/addressbook/update.php39
-rw-r--r--apps/contacts/ajax/categories/categoriesfor.php34
-rw-r--r--apps/contacts/ajax/categories/delete.php48
-rw-r--r--apps/contacts/ajax/categories/list.php15
-rw-r--r--apps/contacts/ajax/categories/rescan.php17
-rw-r--r--apps/contacts/ajax/contact/add.php62
-rw-r--r--apps/contacts/ajax/contact/addproperty.php168
-rw-r--r--apps/contacts/ajax/contact/delete.php44
-rw-r--r--apps/contacts/ajax/contact/deleteproperty.php54
-rw-r--r--apps/contacts/ajax/contact/details.php62
-rw-r--r--apps/contacts/ajax/contact/list.php97
-rw-r--r--apps/contacts/ajax/contact/move.php29
-rw-r--r--apps/contacts/ajax/contact/saveproperty.php176
-rw-r--r--apps/contacts/ajax/cropphoto.php36
-rw-r--r--apps/contacts/ajax/currentphoto.php53
-rw-r--r--apps/contacts/ajax/editaddress.php41
-rw-r--r--apps/contacts/ajax/editname.php34
-rw-r--r--apps/contacts/ajax/importdialog.php15
-rw-r--r--apps/contacts/ajax/loadcard.php58
-rw-r--r--apps/contacts/ajax/loadintro.php31
-rw-r--r--apps/contacts/ajax/loghandler.php44
-rw-r--r--apps/contacts/ajax/oc_photo.php62
-rw-r--r--apps/contacts/ajax/savecrop.php121
-rw-r--r--apps/contacts/ajax/selectaddressbook.php24
-rw-r--r--apps/contacts/ajax/uploadimport.php80
-rw-r--r--apps/contacts/ajax/uploadphoto.php116
29 files changed, 0 insertions, 1665 deletions
diff --git a/apps/contacts/ajax/addressbook/activate.php b/apps/contacts/ajax/addressbook/activate.php
deleted file mode 100644
index a8dec21dac7..00000000000
--- a/apps/contacts/ajax/addressbook/activate.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-/**
- * Copyright (c) 2011 Thomas Tanghus <thomas@tanghus.net>
- * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
- * 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 = $_POST['id'];
-$book = OC_Contacts_App::getAddressbook($id);// is owner access check
-
-if(!OC_Contacts_Addressbook::setActive($id, $_POST['active'])) {
- OCP\Util::writeLog('contacts',
- 'ajax/activation.php: Error activating addressbook: '. $id,
- OCP\Util::ERROR);
- OCP\JSON::error(array(
- 'data' => array(
- 'message' => OC_Contacts_App::$l10n->t('Error (de)activating addressbook.'))));
- exit();
-}
-
-OCP\JSON::success(array(
- 'active' => OC_Contacts_Addressbook::isActive($id),
- 'id' => $id,
- 'addressbook' => $book,
-));
diff --git a/apps/contacts/ajax/addressbook/add.php b/apps/contacts/ajax/addressbook/add.php
deleted file mode 100644
index 65077743ed5..00000000000
--- a/apps/contacts/ajax/addressbook/add.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-/**
- * Copyright (c) 2011-2012 Thomas Tanghus <thomas@tanghus.net>
- * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-
-// Check if we are a user
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-OCP\JSON::callCheck();
-require_once __DIR__.'/../loghandler.php';
-
-debug('name: '.$_POST['name']);
-
-$userid = OCP\USER::getUser();
-$name = isset($_POST['name'])?trim(strip_tags($_POST['name'])):null;
-$description = isset($_POST['description'])
- ? trim(strip_tags($_POST['description']))
- : null;
-
-if(is_null($name)) {
- bailOut('Cannot add addressbook with an empty name.');
-}
-$bookid = OC_Contacts_Addressbook::add($userid, $name, $description);
-if(!$bookid) {
- bailOut('Error adding addressbook: '.$name);
-}
-
-if(!OC_Contacts_Addressbook::setActive($bookid, 1)) {
- bailOut('Error activating addressbook.');
-}
-$addressbook = OC_Contacts_App::getAddressbook($bookid);
-OCP\JSON::success(array('data' => array('addressbook' => $addressbook)));
diff --git a/apps/contacts/ajax/addressbook/delete.php b/apps/contacts/ajax/addressbook/delete.php
deleted file mode 100644
index f59c605f4e4..00000000000
--- a/apps/contacts/ajax/addressbook/delete.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-/**
- * ownCloud - Addressbook
- *
- * @author Jakob Sack
- * @copyright 2011 Jakob Sack mail@jakobsack.de
- *
- * 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/>.
- *
- */
-
-// Check if we are a user
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-OCP\JSON::callCheck();
-require_once __DIR__.'/../loghandler.php';
-
-$id = $_POST['id'];
-if(!$id) {
- bailOut(OC_Contacts_App::$l10n->t('id is not set.'));
-}
-OC_Contacts_App::getAddressbook( $id ); // is owner access check
-
-OC_Contacts_Addressbook::delete($id);
-OCP\JSON::success(array('data' => array( 'id' => $id )));
diff --git a/apps/contacts/ajax/addressbook/update.php b/apps/contacts/ajax/addressbook/update.php
deleted file mode 100644
index 0fc66c3a3bf..00000000000
--- a/apps/contacts/ajax/addressbook/update.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/**
- * Copyright (c) 2011-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.
- */
-
-
-
-// Check if we are a user
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-require_once __DIR__.'/../loghandler.php';
-
-$id = $_POST['id'];
-$name = trim(strip_tags($_POST['name']));
-$description = trim(strip_tags($_POST['description']));
-if(!$id) {
- bailOut(OC_Contacts_App::$l10n->t('id is not set.'));
-}
-
-if(!$name) {
- bailOut(OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.'));
-}
-
-if(!OC_Contacts_Addressbook::edit($id, $name, $description)) {
- bailOut(OC_Contacts_App::$l10n->t('Error updating addressbook.'));
-}
-
-if(!OC_Contacts_Addressbook::setActive($id, $_POST['active'])) {
- bailOut(OC_Contacts_App::$l10n->t('Error (de)activating addressbook.'));
-}
-
-OC_Contacts_App::getAddressbook($id); // is owner access check
-$addressbook = OC_Contacts_App::getAddressbook($id);
-OCP\JSON::success(array(
- 'addressbook' => $addressbook,
-));
diff --git a/apps/contacts/ajax/categories/categoriesfor.php b/apps/contacts/ajax/categories/categoriesfor.php
deleted file mode 100644
index 8391b14b545..00000000000
--- a/apps/contacts/ajax/categories/categoriesfor.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/**
- * 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');
-
-$id = isset($_GET['id'])?$_GET['id']:null;
-if(is_null($id)) {
- OCP\JSON::error(array(
- 'data' => array(
- 'message' => OC_Contacts_App::$l10n->t('No ID provided'))));
- exit();
-}
-$vcard = OC_Contacts_App::getContactVCard( $id );
-foreach($vcard->children as $property){
- if($property->name == 'CATEGORIES') {
- $checksum = md5($property->serialize());
- OCP\JSON::success(array(
- 'data' => array(
- 'value' => $property->value,
- 'checksum' => $checksum,
- )));
- exit();
- }
-}
-OCP\JSON::error(array(
- 'data' => array(
- 'message' => OC_Contacts_App::$l10n->t('Error setting checksum.'))));
diff --git a/apps/contacts/ajax/categories/delete.php b/apps/contacts/ajax/categories/delete.php
deleted file mode 100644
index bc9f3e14e87..00000000000
--- a/apps/contacts/ajax/categories/delete.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-/**
- * 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();
-
-require_once __DIR__.'/../loghandler.php';
-
-$categories = isset($_POST['categories'])?$_POST['categories']:null;
-
-if(is_null($categories)) {
- bailOut(OC_Contacts_App::$l10n->t('No categories selected for deletion.'));
-}
-
-debug(print_r($categories, true));
-
-$addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser());
-if(count($addressbooks) == 0) {
- bailOut(OC_Contacts_App::$l10n->t('No address books found.'));
-}
-$addressbookids = array();
-foreach($addressbooks as $addressbook) {
- $addressbookids[] = $addressbook['id'];
-}
-$contacts = OC_Contacts_VCard::all($addressbookids);
-if(count($contacts) == 0) {
- bailOut(OC_Contacts_App::$l10n->t('No contacts found.'));
-}
-
-$cards = array();
-foreach($contacts as $contact) {
- $cards[] = array($contact['id'], $contact['carddata']);
-}
-
-debug('Before delete: '.print_r($categories, true));
-
-$catman = new OC_VCategories('contacts');
-$catman->delete($categories, $cards);
-debug('After delete: '.print_r($catman->categories(), true));
-OC_Contacts_VCard::updateDataByID($cards);
-OCP\JSON::success(array('data' => array('categories'=>$catman->categories())));
diff --git a/apps/contacts/ajax/categories/list.php b/apps/contacts/ajax/categories/list.php
deleted file mode 100644
index f234116ba8c..00000000000
--- a/apps/contacts/ajax/categories/list.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-/**
- * 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');
-
-$categories = OC_Contacts_App::getCategories();
-
-OCP\JSON::success(array('data' => array('categories'=>$categories)));
diff --git a/apps/contacts/ajax/categories/rescan.php b/apps/contacts/ajax/categories/rescan.php
deleted file mode 100644
index a06e7803955..00000000000
--- a/apps/contacts/ajax/categories/rescan.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-/**
- * 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();
-
-OC_Contacts_App::scanCategories();
-$categories = OC_Contacts_App::getCategories();
-
-OCP\JSON::success(array('data' => array('categories'=>$categories)));
diff --git a/apps/contacts/ajax/contact/add.php b/apps/contacts/ajax/contact/add.php
deleted file mode 100644
index c7cec7d9461..00000000000
--- a/apps/contacts/ajax/contact/add.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?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/>.
- *
- */
-
-// Check if we are a user
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-OCP\JSON::callCheck();
-
-$aid = isset($_POST['aid'])?$_POST['aid']:null;
-if(!$aid) {
- $aid = min(OC_Contacts_Addressbook::activeIds()); // first active addressbook.
-}
-OC_Contacts_App::getAddressbook( $aid ); // is owner access check
-
-$isnew = isset($_POST['isnew'])?$_POST['isnew']:false;
-$fn = trim($_POST['fn']);
-$n = trim($_POST['n']);
-
-$vcard = new OC_VObject('VCARD');
-$vcard->setUID();
-$vcard->setString('FN', $fn);
-$vcard->setString('N', $n);
-
-$id = OC_Contacts_VCard::add($aid, $vcard, null, $isnew);
-if(!$id) {
- OCP\JSON::error(array(
- 'data' => array(
- 'message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.'))));
- OCP\Util::writeLog('contacts', 'ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OCP\Util::ERROR);
- exit();
-}
-
-$lastmodified = OC_Contacts_App::lastModified($vcard);
-if(!$lastmodified) {
- $lastmodified = new DateTime();
-}
-OCP\JSON::success(array(
- 'data' => array(
- 'id' => $id,
- 'aid' => $aid,
- 'lastmodified' => $lastmodified->format('U')
- )
-));
diff --git a/apps/contacts/ajax/contact/addproperty.php b/apps/contacts/ajax/contact/addproperty.php
deleted file mode 100644
index 2b80ebd58bf..00000000000
--- a/apps/contacts/ajax/contact/addproperty.php
+++ /dev/null
@@ -1,168 +0,0 @@
-<?php
-/**
- * ownCloud - Addressbook
- *
- * @author Jakob Sack
- * @copyright 2011 Jakob Sack mail@jakobsack.de
- *
- * 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/>.
- *
- */
-
-// Check if we are a user
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-OCP\JSON::callCheck();
-
-require_once __DIR__.'/../loghandler.php';
-
-$id = isset($_POST['id'])?$_POST['id']:null;
-$name = isset($_POST['name'])?$_POST['name']:null;
-$value = isset($_POST['value'])?$_POST['value']:null;
-$parameters = isset($_POST['parameters'])?$_POST['parameters']:array();
-
-$vcard = OC_Contacts_App::getContactVCard($id);
-$l10n = OC_Contacts_App::$l10n;
-
-if(!$name) {
- bailOut($l10n->t('element name is not set.'));
-}
-if(!$id) {
- bailOut($l10n->t('id is not set.'));
-}
-
-if(!$vcard) {
- bailOut($l10n->t('Could not parse contact: ').$id);
-}
-
-if(!is_array($value)) {
- $value = trim($value);
- if(!$value
- && in_array(
- $name,
- array('TEL', 'EMAIL', 'ORG', 'BDAY', 'URL', 'NICKNAME', 'NOTE'))
- ) {
- bailOut($l10n->t('Cannot add empty property.'));
- }
-} elseif($name === 'ADR') { // only add if non-empty elements.
- $empty = true;
- foreach($value as $part) {
- if(trim($part) != '') {
- $empty = false;
- break;
- }
- }
- if($empty) {
- bailOut($l10n->t('At least one of the address fields has to be filled out.'));
- }
-}
-
-// Prevent setting a duplicate entry
-$current = $vcard->select($name);
-foreach($current as $item) {
- $tmpvalue = (is_array($value)?implode(';', $value):$value);
- if($tmpvalue == $item->value) {
- bailOut($l10n->t('Trying to add duplicate property: '.$name.': '.$tmpvalue));
- }
-}
-
-if(is_array($value)) {
- // NOTE: Important, otherwise the compound value will
- // be set in the order the fields appear in the form!
- ksort($value);
- $value = array_map('strip_tags', $value);
-} else {
- $value = strip_tags($value);
-}
-
-/* preprocessing value */
-switch($name) {
- case 'BDAY':
- $date = New DateTime($value);
- $value = $date->format(DateTime::ATOM);
- case 'FN':
- if(!$value) {
- // create a method thats returns an alternative for FN.
- //$value = getOtherValue();
- }
- case 'N':
- case 'ORG':
- case 'NOTE':
- $value = str_replace('\n', ' \\n', $value);
- break;
- case 'NICKNAME':
- // TODO: Escape commas and semicolons.
- break;
- case 'EMAIL':
- $value = strtolower($value);
- break;
- case 'TEL':
- case 'ADR':
- break;
- case 'IMPP':
- if(is_null($parameters) || !isset($parameters['X-SERVICE-TYPE'])) {
- bailOut(OC_Contacts_App::$l10n->t('Missing IM parameter.'));
- }
- $impp = OC_Contacts_App::getIMOptions($parameters['X-SERVICE-TYPE']);
- if(is_null($impp)) {
- bailOut(OC_Contacts_App::$l10n->t('Unknown IM: '.$parameters['X-SERVICE-TYPE']));
- }
- $value = $impp['protocol'] . ':' . $value;
- break;
-}
-
-switch($name) {
- case 'NOTE':
- $vcard->setString('NOTE', $value);
- break;
- default:
- $property = $vcard->addProperty($name, $value); //, $parameters);
- break;
-}
-
-$line = count($vcard->children) - 1;
-
-// Apparently Sabre_VObject_Parameter doesn't do well with
-// multiple values or I don't know how to do it. Tanghus.
-foreach ($parameters as $key=>$element) {
- if(is_array($element) /*&& strtoupper($key) == 'TYPE'*/) {
- // NOTE: Maybe this doesn't only apply for TYPE?
- // And it probably shouldn't be done here anyways :-/
- foreach($element as $e) {
- if($e != '' && !is_null($e)) {
- if(trim($e)) {
- $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $e);
- }
- }
- }
- } else {
- if(trim($element)) {
- $vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $element);
- }
- }
-}
-$checksum = md5($vcard->children[$line]->serialize());
-
-try {
- OC_Contacts_VCard::edit($id, $vcard);
-} catch(Exception $e) {
- bailOut($e->getMessage());
-}
-
-OCP\JSON::success(array(
- 'data' => array(
- 'checksum' => $checksum,
- 'lastmodified' => OC_Contacts_App::lastModified($vcard)->format('U'))
- )
-);
diff --git a/apps/contacts/ajax/contact/delete.php b/apps/contacts/ajax/contact/delete.php
deleted file mode 100644
index e73f34f898d..00000000000
--- a/apps/contacts/ajax/contact/delete.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-/**
- * ownCloud - Addressbook
- *
- * @author Jakob Sack
- * @copyright 2011 Jakob Sack mail@jakobsack.de
- * @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/>.
- *
- */
-// Check if we are a user
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-OCP\JSON::callCheck();
-
-require_once __DIR__.'/../loghandler.php';
-
-$id = isset($_POST['id'])?$_POST['id']:null;
-if(!$id) {
- bailOut(OC_Contacts_App::$l10n->t('id is not set.'));
-}
-
-try {
- OC_Contacts_VCard::delete($id);
-} catch(Exception $e) {
- $msg = $e->getMessage();
- OCP\Util::writeLog('contacts', __METHOD__.', exception: '.$msg,
- OCP\Util::DEBUG);
- OCP\Util::writeLog('contacts', __METHOD__.', id'.$id, OCP\Util::DEBUG);
- bailOut($msg);
-}
-OCP\JSON::success(array('data' => array( 'id' => $id )));
diff --git a/apps/contacts/ajax/contact/deleteproperty.php b/apps/contacts/ajax/contact/deleteproperty.php
deleted file mode 100644
index b76b6e55ede..00000000000
--- a/apps/contacts/ajax/contact/deleteproperty.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-/**
- * ownCloud - Addressbook
- *
- * @author Jakob Sack
- * @copyright 2011 Jakob Sack mail@jakobsack.de
- *
- * 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/>.
- *
- */
-
-// Check if we are a user
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-OCP\JSON::callCheck();
-
-require_once __DIR__.'/../loghandler.php';
-
-$id = $_POST['id'];
-$checksum = $_POST['checksum'];
-$l10n = OC_Contacts_App::$l10n;
-
-$vcard = OC_Contacts_App::getContactVCard( $id );
-$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
-if(is_null($line)) {
- bailOut($l10n->t('Information about vCard is incorrect. Please reload the page.'));
- exit();
-}
-
-unset($vcard->children[$line]);
-
-try {
- OC_Contacts_VCard::edit($id, $vcard);
-} catch(Exception $e) {
- bailOut($e->getMessage());
-}
-
-OCP\JSON::success(array(
- 'data' => array(
- 'id' => $id,
- 'lastmodified' => OC_Contacts_App::lastModified($vcard)->format('U'),
- )
-));
diff --git a/apps/contacts/ajax/contact/details.php b/apps/contacts/ajax/contact/details.php
deleted file mode 100644
index 5bf337e645e..00000000000
--- a/apps/contacts/ajax/contact/details.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?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/>.
- *
- */
-
-require_once __DIR__.'/../loghandler.php';
-
-// Check if we are a user
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-
-$id = isset($_GET['id'])?$_GET['id']:null;
-if(is_null($id)) {
- bailOut(OC_Contacts_App::$l10n->t('Missing ID'));
-}
-$card = OC_Contacts_VCard::find($id);
-$vcard = OC_VObject::parse($card['carddata']);
-if(is_null($vcard)) {
- bailOut(OC_Contacts_App::$l10n->t('Error parsing VCard for ID: "'.$id.'"'));
-}
-$details = OC_Contacts_VCard::structureContact($vcard);
-
-// Make up for not supporting the 'N' field in earlier version.
-if(!isset($details['N'])) {
- $details['N'] = array();
- $details['N'][0] = array($details['FN'][0]['value'],'','','','');
-}
-
-// Don't wanna transfer the photo in a json string.
-if(isset($details['PHOTO'])) {
- $details['PHOTO'] = true;
- //unset($details['PHOTO']);
-} else {
- $details['PHOTO'] = false;
-}
-$lastmodified = OC_Contacts_App::lastModified($vcard);
-if(!$lastmodified) {
- $lastmodified = new DateTime();
-}
-$details['id'] = $id;
-$details['displayname'] = $card['fullname'];
-$details['addressbookid'] = $card['addressbookid'];
-$details['lastmodified'] = $lastmodified->format('U');
-OC_Contacts_App::setLastModifiedHeader($vcard);
-OCP\JSON::success(array('data' => $details));
diff --git a/apps/contacts/ajax/contact/list.php b/apps/contacts/ajax/contact/list.php
deleted file mode 100644
index 4e2509d8d5a..00000000000
--- a/apps/contacts/ajax/contact/list.php
+++ /dev/null
@@ -1,97 +0,0 @@
-<?php
-/**
- * Copyright (c) 2011 Thomas Tanghus <thomas@tanghus.net>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-function cmp($a, $b)
-{
- if ($a['displayname'] == $b['displayname']) {
- return 0;
- }
- return ($a['displayname'] < $b['displayname']) ? -1 : 1;
-}
-
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-
-$start = isset($_GET['startat'])?$_GET['startat']:0;
-$aid = isset($_GET['aid'])?$_GET['aid']:null;
-
-if(is_null($aid)) {
- // Called initially to get the active addressbooks.
- $active_addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
-} else {
- // called each time more contacts has to be shown.
- $active_addressbooks = array(OC_Contacts_Addressbook::find($aid));
-}
-
-
-session_write_close();
-
-// create the addressbook associate array
-$contacts_addressbook = array();
-$ids = array();
-foreach($active_addressbooks as $addressbook) {
- $ids[] = $addressbook['id'];
- if(!isset($contacts_addressbook[$addressbook['id']])) {
- $contacts_addressbook[$addressbook['id']]
- = array('contacts' => array('type' => 'book',));
- $contacts_addressbook[$addressbook['id']]['displayname']
- = $addressbook['displayname'];
- $contacts_addressbook[$addressbook['id']]['permissions']
- = isset($addressbook['permissions'])
- ? $addressbook['permissions']
- : '0';
- }
-}
-
-$contacts_alphabet = array();
-
-// get next 50 for each addressbook.
-foreach($ids as $id) {
- if($id) {
- $contacts_alphabet = array_merge(
- $contacts_alphabet,
- OC_Contacts_VCard::all($id, $start, 50)
- );
- }
-}
-// Our new array for the contacts sorted by addressbook
-if($contacts_alphabet) {
- foreach($contacts_alphabet as $contact) {
- // This should never execute.
- if(!isset($contacts_addressbook[$contact['addressbookid']])) {
- $contacts_addressbook[$contact['addressbookid']] = array(
- 'contacts' => array('type' => 'book',)
- );
- }
- $display = trim($contact['fullname']);
- if(!$display) {
- $vcard = OC_Contacts_App::getContactVCard($contact['id']);
- if(!is_null($vcard)) {
- $struct = OC_Contacts_VCard::structureContact($vcard);
- $display = isset($struct['EMAIL'][0])
- ? $struct['EMAIL'][0]['value']
- : '[UNKNOWN]';
- }
- }
- $contacts_addressbook[$contact['addressbookid']]['contacts'][] = array(
- 'type' => 'contact',
- 'id' => $contact['id'],
- 'addressbookid' => $contact['addressbookid'],
- 'displayname' => htmlspecialchars($display),
- 'permissions' =>
- isset($contacts_addressbook[$contact['addressbookid']]['permissions'])
- ? $contacts_addressbook[$contact['addressbookid']]['permissions']
- : '0',
- );
- }
-}
-unset($contacts_alphabet);
-uasort($contacts_addressbook, 'cmp');
-
-OCP\JSON::success(array('data' => array('entries' => $contacts_addressbook)));
-
diff --git a/apps/contacts/ajax/contact/move.php b/apps/contacts/ajax/contact/move.php
deleted file mode 100644
index 053343c47ed..00000000000
--- a/apps/contacts/ajax/contact/move.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?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
-OC_Contacts_App::getAddressbook($aid);
-try {
- OC_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,)));
-}
-
-OC_JSON::success(array('data' => array('ids' => $id,))); \ No newline at end of file
diff --git a/apps/contacts/ajax/contact/saveproperty.php b/apps/contacts/ajax/contact/saveproperty.php
deleted file mode 100644
index 7ae183538b6..00000000000
--- a/apps/contacts/ajax/contact/saveproperty.php
+++ /dev/null
@@ -1,176 +0,0 @@
-<?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/>.
- *
- */
-
-require_once __DIR__.'/../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;
-$parameters = isset($_POST['parameters'])?$_POST['parameters']:null;
-$checksum = isset($_POST['checksum'])?$_POST['checksum']:null;
-
-if(!$name) {
- bailOut(OC_Contacts_App::$l10n->t('element name is not set.'));
-}
-if(!$id) {
- bailOut(OC_Contacts_App::$l10n->t('id is not set.'));
-}
-if(!$checksum) {
- bailOut(OC_Contacts_App::$l10n->t('checksum is not set.'));
-}
-if(is_array($value)) {
- $value = array_map('strip_tags', $value);
- // NOTE: Important, otherwise the compound value will be
- // set in the order the fields appear in the form!
- ksort($value);
- //if($name == 'CATEGORIES') {
- // $value = OC_Contacts_VCard::escapeDelimiters($value, ',');
- //} else {
- $value = OC_Contacts_VCard::escapeDelimiters($value, ';');
- //}
-} else {
- $value = trim(strip_tags($value));
-}
-
-$vcard = OC_Contacts_App::getContactVCard( $id );
-$line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
-if(is_null($line)) {
- bailOut(OC_Contacts_App::$l10n->t(
- 'Information about vCard is incorrect. Please reload the page: ').$checksum
- );
-}
-$element = $vcard->children[$line]->name;
-
-if($element != $name) {
- bailOut(OC_Contacts_App::$l10n->t(
- 'Something went FUBAR. ').$name.' != '.$element
- );
-}
-
-/* preprocessing value */
-switch($element) {
- case 'BDAY':
- $date = New DateTime($value);
- $value = $date->format('Y-m-d');
- break;
- case 'FN':
- if(!$value) {
- // create a method thats returns an alternative for FN.
- //$value = getOtherValue();
- }
- break;
- case 'NOTE':
- $value = str_replace('\n', '\\n', $value);
- break;
- case 'EMAIL':
- $value = strtolower($value);
- break;
- case 'IMPP':
- if(is_null($parameters) || !isset($parameters['X-SERVICE-TYPE'])) {
- bailOut(OC_Contacts_App::$l10n->t('Missing IM parameter.'));
- }
- $impp = OC_Contacts_App::getIMOptions($parameters['X-SERVICE-TYPE']);
- if(is_null($impp)) {
- bailOut(OC_Contacts_App::$l10n->t('Unknown IM: '.$parameters['X-SERVICE-TYPE']));
- }
- $value = $impp['protocol'] . ':' . $value;
- break;
-}
-
-if(!$value) {
- unset($vcard->children[$line]);
- $checksum = '';
-} else {
- /* setting value */
- switch($element) {
- case 'BDAY':
- // I don't use setDateTime() because that formats it as YYYYMMDD instead
- // of YYYY-MM-DD which is what the RFC recommends.
- $vcard->children[$line]->setValue($value);
- $vcard->children[$line]->parameters = array();
- $vcard->children[$line]->add(
- new Sabre_VObject_Parameter('VALUE', 'DATE')
- );
- debug('Setting value:'.$name.' '.$vcard->children[$line]);
- break;
- case 'CATEGORIES':
- debug('Setting string:'.$name.' '.$value);
- $vcard->children[$line]->setValue($value);
- break;
- case 'EMAIL':
- case 'TEL':
- case 'ADR':
- case 'IMPP':
- debug('Setting element: (EMAIL/TEL/ADR)'.$element);
- $vcard->children[$line]->setValue($value);
- $vcard->children[$line]->parameters = array();
- if(!is_null($parameters)) {
- debug('Setting parameters: '.$parameters);
- foreach($parameters as $key => $parameter) {
- debug('Adding parameter: '.$key);
- if(is_array($parameter)) {
- foreach($parameter as $val) {
- if(trim($val)) {
- debug('Adding parameter: '.$key.'=>'.$val);
- $vcard->children[$line]->add(new Sabre_VObject_Parameter(
- $key,
- strtoupper(strip_tags($val)))
- );
- }
- }
- } else {
- if(trim($parameter)) {
- $vcard->children[$line]->add(new Sabre_VObject_Parameter(
- $key,
- strtoupper(strip_tags($parameter)))
- );
- }
- }
- }
- }
- break;
- default:
- debug('Setting string:'.$name.' '.$value);
- $vcard->setString($name, $value);
- break;
- }
- // Do checksum and be happy
- $checksum = md5($vcard->children[$line]->serialize());
-}
-//debug('New checksum: '.$checksum);
-
-try {
- OC_Contacts_VCard::edit($id, $vcard);
-} catch(Exception $e) {
- bailOut($e->getMessage());
-}
-
-OCP\JSON::success(array('data' => array(
- 'line' => $line,
- 'checksum' => $checksum,
- 'oldchecksum' => $_POST['checksum'],
- 'lastmodified' => OC_Contacts_App::lastModified($vcard)->format('U'),
-)));
diff --git a/apps/contacts/ajax/cropphoto.php b/apps/contacts/ajax/cropphoto.php
deleted file mode 100644
index eb9f1fcdb5d..00000000000
--- a/apps/contacts/ajax/cropphoto.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?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/>.
- *
- */
-
-// Check if we are a user
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-
-$tmpkey = $_GET['tmpkey'];
-$requesttoken = $_GET['requesttoken'];
-$id = $_GET['id'];
-$tmpl = new OCP\Template("contacts", "part.cropphoto");
-$tmpl->assign('tmpkey', $tmpkey);
-$tmpl->assign('id', $id);
-$tmpl->assign('requesttoken', $requesttoken);
-$page = $tmpl->fetchPage();
-
-OCP\JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/contacts/ajax/currentphoto.php b/apps/contacts/ajax/currentphoto.php
deleted file mode 100644
index 96080e661ef..00000000000
--- a/apps/contacts/ajax/currentphoto.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?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/>.
- *
- */
-
-// Firefox and Konqueror tries to download application/json for me. --Arthur
-OCP\JSON::setContentTypeHeader('text/plain');
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-require_once 'loghandler.php';
-
-if (!isset($_GET['id'])) {
- bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
-}
-
-$contact = OC_Contacts_App::getContactVCard($_GET['id']);
-// invalid vcard
-if( is_null($contact)) {
- bailOut(OC_Contacts_App::$l10n->t('Error reading contact photo.'));
-} else {
- $image = new OC_Image();
- if(!$image->loadFromBase64($contact->getAsString('PHOTO'))) {
- $image->loadFromBase64($contact->getAsString('LOGO'));
- }
- if($image->valid()) {
- $tmpkey = 'contact-photo-'.$contact->getAsString('UID');
- if(OC_Cache::set($tmpkey, $image->data(), 600)) {
- OCP\JSON::success(array('data' => array('id'=>$_GET['id'], 'tmp'=>$tmpkey)));
- exit();
- } else {
- bailOut(OC_Contacts_App::$l10n->t('Error saving temporary file.'));
- }
- } else {
- bailOut(OC_Contacts_App::$l10n->t('The loading photo is not valid.'));
- }
-}
diff --git a/apps/contacts/ajax/editaddress.php b/apps/contacts/ajax/editaddress.php
deleted file mode 100644
index b5e4b72ed57..00000000000
--- a/apps/contacts/ajax/editaddress.php
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-/**
- * Copyright (c) 2011 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');
-
-$id = $_GET['id'];
-$checksum = isset($_GET['checksum'])?$_GET['checksum']:'';
-$vcard = OC_Contacts_App::getContactVCard($id);
-$adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
-
-$tmpl = new OCP\Template("contacts", "part.edit_address_dialog");
-if($checksum) {
- $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
- $element = $vcard->children[$line];
- $adr = OC_Contacts_VCard::structureProperty($element);
- $types = array();
- if(isset($adr['parameters']['TYPE'])) {
- if(is_array($adr['parameters']['TYPE'])) {
- $types = array_map('htmlspecialchars', $adr['parameters']['TYPE']);
- $types = array_map('strtoupper', $types);
- } else {
- $types = array(strtoupper(htmlspecialchars($adr['parameters']['TYPE'])));
- }
- }
- $tmpl->assign('types', $types, false);
- $adr = array_map('htmlspecialchars', $adr['value']);
- $tmpl->assign('adr', $adr, false);
-}
-
-$tmpl->assign('id', $id);
-$tmpl->assign('adr_types', $adr_types);
-
-$page = $tmpl->fetchPage();
-OCP\JSON::success(array('data' => array('page'=>$page, 'checksum'=>$checksum)));
diff --git a/apps/contacts/ajax/editname.php b/apps/contacts/ajax/editname.php
deleted file mode 100644
index eb55634011d..00000000000
--- a/apps/contacts/ajax/editname.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-/**
- * Copyright (c) 2011 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');
-require_once 'loghandler.php';
-
-$tmpl = new OCP\Template("contacts", "part.edit_name_dialog");
-
-$id = isset($_GET['id'])?$_GET['id']:'';
-
-if($id) {
- $vcard = OC_Contacts_App::getContactVCard($id);
- $name = array('', '', '', '', '');
- if($vcard->__isset('N')) {
- $property = $vcard->__get('N');
- if($property) {
- $name = OC_Contacts_VCard::structureProperty($property);
- }
- }
- $name = array_map('htmlspecialchars', $name['value']);
- $tmpl->assign('name', $name, false);
- $tmpl->assign('id', $id, false);
-} else {
- bailOut(OC_Contacts_App::$l10n->t('Contact ID is missing.'));
-}
-$page = $tmpl->fetchPage();
-OCP\JSON::success(array('data' => array('page'=>$page)));
diff --git a/apps/contacts/ajax/importdialog.php b/apps/contacts/ajax/importdialog.php
deleted file mode 100644
index 691522538fb..00000000000
--- a/apps/contacts/ajax/importdialog.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-/**
- * Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
- */
-
-
-OCP\JSON::checkLoggedIn();
-OCP\App::checkAppEnabled('contacts');
-$tmpl = new OCP\Template('contacts', 'part.import');
-$tmpl->assign('path', $_POST['path']);
-$tmpl->assign('filename', $_POST['filename']);
-$tmpl->printpage();
diff --git a/apps/contacts/ajax/loadcard.php b/apps/contacts/ajax/loadcard.php
deleted file mode 100644
index 82501ffd2ff..00000000000
--- a/apps/contacts/ajax/loadcard.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?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/>.
- *
- */
-
-// Check if we are a user
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-
-$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
-$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
-$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
-$requesttoken = $_GET['requesttoken'];
-
-$freeSpace=OC_Filesystem::free_space('/');
-$freeSpace=max($freeSpace, 0);
-$maxUploadFilesize = min($maxUploadFilesize, $freeSpace);
-$adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
-$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
-$email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
-$impp_types = OC_Contacts_App::getTypesOfProperty('IMPP');
-$ims = OC_Contacts_App::getIMOptions();
-$im_protocols = array();
-foreach($ims as $name => $values) {
- $im_protocols[$name] = $values['displayname'];
-}
-
-$tmpl = new OCP\Template('contacts', 'part.contact');
-$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
-$tmpl->assign('requesttoken', $_SERVER['HTTP_REQUESTTOKEN']);
-$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
-$tmpl->assign('adr_types', $adr_types);
-$tmpl->assign('phone_types', $phone_types);
-$tmpl->assign('email_types', $email_types);
-$tmpl->assign('impp_types', $impp_types, false);
-$tmpl->assign('im_protocols', $im_protocols, false);
-$tmpl->assign('requesttoken', $requesttoken);
-$tmpl->assign('id', '');
-$page = $tmpl->fetchPage();
-
-OCP\JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/contacts/ajax/loadintro.php b/apps/contacts/ajax/loadintro.php
deleted file mode 100644
index 1da08950ca0..00000000000
--- a/apps/contacts/ajax/loadintro.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?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/>.
- *
- */
-
-// Check if we are a user
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-
-
-$tmpl = new OCP\Template('contacts', 'part.no_contacts');
-$page = $tmpl->fetchPage();
-
-OCP\JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/contacts/ajax/loghandler.php b/apps/contacts/ajax/loghandler.php
deleted file mode 100644
index be4b98c1112..00000000000
--- a/apps/contacts/ajax/loghandler.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?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/oc_photo.php b/apps/contacts/ajax/oc_photo.php
deleted file mode 100644
index fe37b530f82..00000000000
--- a/apps/contacts/ajax/oc_photo.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?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/>.
- *
- */
-// Check if we are a user
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-require_once 'loghandler.php';
-
-if(!isset($_GET['id'])) {
- bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
-}
-
-if(!isset($_GET['path'])) {
- bailOut(OC_Contacts_App::$l10n->t('No photo path was submitted.'));
-}
-
-$localpath = OC_Filesystem::getLocalFile($_GET['path']);
-$tmpkey = 'contact-photo-'.$_GET['id'];
-
-if(!file_exists($localpath)) {
- bailOut(OC_Contacts_App::$l10n->t('File doesn\'t exist:').$localpath);
-}
-
-$image = new OC_Image();
-if(!$image) {
- bailOut(OC_Contacts_App::$l10n->t('Error loading image.'));
-}
-if(!$image->loadFromFile($localpath)) {
- bailOut(OC_Contacts_App::$l10n->t('Error loading image.'));
-}
-if($image->width() > 400 || $image->height() > 400) {
- $image->resize(400); // Prettier resizing than with browser and saves bandwidth.
-}
-if(!$image->fixOrientation()) { // No fatal error so we don't bail out.
- OCP\Util::writeLog('contacts',
- 'ajax/oc_photo.php: Couldn\'t save correct image orientation: '.$localpath,
- OCP\Util::DEBUG);
-}
-if(OC_Cache::set($tmpkey, $image->data(), 600)) {
- OCP\JSON::success(array('data' => array('id'=>$_GET['id'], 'tmp'=>$tmpkey)));
- exit();
-} else {
- bailOut('Couldn\'t save temporary image: '.$tmpkey);
-}
diff --git a/apps/contacts/ajax/savecrop.php b/apps/contacts/ajax/savecrop.php
deleted file mode 100644
index 2483d0f7128..00000000000
--- a/apps/contacts/ajax/savecrop.php
+++ /dev/null
@@ -1,121 +0,0 @@
-<?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/>.
- *
- */
-// Check if we are a user
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-OCP\JSON::callCheck();
-
-// Firefox and Konqueror tries to download application/json for me. --Arthur
-OCP\JSON::setContentTypeHeader('text/plain; charset=utf-8');
-
-require_once 'loghandler.php';
-
-$image = null;
-
-$x1 = (isset($_POST['x1']) && $_POST['x1']) ? $_POST['x1'] : 0;
-//$x2 = isset($_POST['x2']) ? $_POST['x2'] : -1;
-$y1 = (isset($_POST['y1']) && $_POST['y1']) ? $_POST['y1'] : 0;
-//$y2 = isset($_POST['y2']) ? $_POST['y2'] : -1;
-$w = (isset($_POST['w']) && $_POST['w']) ? $_POST['w'] : -1;
-$h = (isset($_POST['h']) && $_POST['h']) ? $_POST['h'] : -1;
-$tmpkey = isset($_POST['tmpkey']) ? $_POST['tmpkey'] : '';
-$id = isset($_POST['id']) ? $_POST['id'] : '';
-
-if($tmpkey == '') {
- bailOut('Missing key to temporary file.');
-}
-
-if($id == '') {
- bailOut('Missing contact id.');
-}
-
-OCP\Util::writeLog('contacts', 'savecrop.php: key: '.$tmpkey, OCP\Util::DEBUG);
-
-$data = OC_Cache::get($tmpkey);
-if($data) {
- $image = new OC_Image();
- if($image->loadFromdata($data)) {
- $w = ($w != -1 ? $w : $image->width());
- $h = ($h != -1 ? $h : $image->height());
- OCP\Util::writeLog('contacts',
- 'savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h,
- OCP\Util::DEBUG);
- if($image->crop($x1, $y1, $w, $h)) {
- if(($image->width() <= 200 && $image->height() <= 200)
- || $image->resize(200)) {
- $vcard = OC_Contacts_App::getContactVCard($id);
- if(!$vcard) {
- OC_Cache::remove($tmpkey);
- bailOut(OC_Contacts_App::$l10n
- ->t('Error getting contact object.'));
- }
- if($vcard->__isset('PHOTO')) {
- OCP\Util::writeLog('contacts',
- 'savecrop.php: PHOTO property exists.',
- OCP\Util::DEBUG);
- $property = $vcard->__get('PHOTO');
- if(!$property) {
- OC_Cache::remove($tmpkey);
- bailOut(OC_Contacts_App::$l10n
- ->t('Error getting PHOTO property.'));
- }
- $property->setValue($image->__toString());
- $property->parameters[]
- = new Sabre_VObject_Parameter('ENCODING', 'b');
- $property->parameters[]
- = new Sabre_VObject_Parameter('TYPE', $image->mimeType());
- $vcard->__set('PHOTO', $property);
- } else {
- OCP\Util::writeLog('contacts',
- 'savecrop.php: files: Adding PHOTO property.',
- OCP\Util::DEBUG);
- $vcard->addProperty('PHOTO',
- $image->__toString(), array('ENCODING' => 'b',
- 'TYPE' => $image->mimeType()));
- }
- $now = new DateTime;
- $vcard->setString('REV', $now->format(DateTime::W3C));
- if(!OC_Contacts_VCard::edit($id, $vcard)) {
- bailOut(OC_Contacts_App::$l10n->t('Error saving contact.'));
- }
- OCP\JSON::success(array(
- 'data' => array(
- 'id' => $id,
- 'width' => $image->width(),
- 'height' => $image->height(),
- 'lastmodified' => OC_Contacts_App::lastModified($vcard)->format('U')
- )
- ));
- } else {
- bailOut(OC_Contacts_App::$l10n->t('Error resizing image'));
- }
- } else {
- bailOut(OC_Contacts_App::$l10n->t('Error cropping image'));
- }
- } else {
- bailOut(OC_Contacts_App::$l10n->t('Error creating temporary image'));
- }
-} else {
- bailOut(OC_Contacts_App::$l10n->t('Error finding image: ').$tmpkey);
-}
-
-OC_Cache::remove($tmpkey);
diff --git a/apps/contacts/ajax/selectaddressbook.php b/apps/contacts/ajax/selectaddressbook.php
deleted file mode 100644
index e5527c8e5f1..00000000000
--- a/apps/contacts/ajax/selectaddressbook.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-/**
- * Copyright (c) 2011 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');
-
-$books = OC_Contacts_Addressbook::all(OCP\USER::getUser());
-if(count($books) > 1) {
- $addressbooks = array();
- foreach($books as $book) {
- $addressbooks[] = array('id' => $book['id'], 'name' => $book['displayname']);
- }
- $tmpl = new OCP\Template("contacts", "part.selectaddressbook");
- $tmpl->assign('addressbooks', $addressbooks);
- $page = $tmpl->fetchPage();
- OCP\JSON::success(array('data' => array( 'type' => 'dialog', 'page' => $page )));
-} else {
- OCP\JSON::success(array('data' => array( 'type' => 'result', 'id' => $books[0]['id'] )));
-} \ No newline at end of file
diff --git a/apps/contacts/ajax/uploadimport.php b/apps/contacts/ajax/uploadimport.php
deleted file mode 100644
index 87032b731a5..00000000000
--- a/apps/contacts/ajax/uploadimport.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?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/>.
- *
- */
-
-// Check if we are a user
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-OCP\JSON::callCheck();
-require_once 'loghandler.php';
-
-$l10n = OC_Contacts_App::$l10n;
-
-$view = OCP\Files::getStorage('contacts');
-if(!$view->file_exists('imports')) {
- $view->mkdir('imports');
-}
-$tmpfile = md5(rand());
-
-// 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);
-if($fn) {
- if($view->file_put_contents('/imports/'.$fn, file_get_contents('php://input'))) {
- OCP\JSON::success(array('data' => array('file'=>$tmpfile, 'name'=>$fn)));
- exit();
- } else {
- bailOut($l10n->t('Error uploading contacts to storage.'));
- }
-}
-
-// File input transfers are handled here
-if (!isset($_FILES['importfile'])) {
- OCP\Util::writeLog('contacts',
- 'ajax/uploadphoto.php: No file was uploaded. Unknown error.',
- OCP\Util::DEBUG);
- OCP\JSON::error(array('
- data' => array(
- 'message' => 'No file was uploaded. Unknown error' )));
- exit();
-}
-$error = $_FILES['importfile']['error'];
-if($error !== UPLOAD_ERR_OK) {
- $errors = array(
- 0=>$l10n->t("There is no error, the file uploaded with success"),
- 1=>$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
- 2=>$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
- 3=>$l10n->t("The uploaded file was only partially uploaded"),
- 4=>$l10n->t("No file was uploaded"),
- 6=>$l10n->t("Missing a temporary folder")
- );
- bailOut($errors[$error]);
-}
-$file=$_FILES['importfile'];
-
-if(file_exists($file['tmp_name'])) {
- if($view->file_put_contents('/imports/'.$file['name'], file_get_contents($file['tmp_name']))) {
- OCP\JSON::success(array('data' => array('file'=>$file['name'], 'name'=>$file['name'])));
- } else {
- bailOut($l10n->t('Error uploading contacts to storage.'));
- }
-} else {
- bailOut('Temporary file: \''.$file['tmp_name'].'\' has gone AWOL?');
-}
diff --git a/apps/contacts/ajax/uploadphoto.php b/apps/contacts/ajax/uploadphoto.php
deleted file mode 100644
index 34830b291d2..00000000000
--- a/apps/contacts/ajax/uploadphoto.php
+++ /dev/null
@@ -1,116 +0,0 @@
-<?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/>.
- *
- */
-
-// Check if we are a user
-OCP\JSON::checkLoggedIn();
-OCP\JSON::checkAppEnabled('contacts');
-OCP\JSON::callCheck();
-
-// Firefox and Konqueror tries to download application/json for me. --Arthur
-OCP\JSON::setContentTypeHeader('text/plain; charset=utf-8');
-require_once 'loghandler.php';
-$l10n = OC_Contacts_App::$l10n;
-// 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);
-if ($fn) {
- if (!isset($_GET['id'])) {
- bailOut($l10n->t('No contact ID was submitted.'));
- }
- $id = $_GET['id'];
- $tmpkey = 'contact-photo-'.md5($fn);
- $data = file_get_contents('php://input');
- $image = new OC_Image();
- sleep(1); // Apparently it needs time to load the data.
- if($image->loadFromData($data)) {
- if($image->width() > 400 || $image->height() > 400) {
- $image->resize(400); // Prettier resizing than with browser and saves bandwidth.
- }
- if(!$image->fixOrientation()) { // No fatal error so we don't bail out.
- debug('Couldn\'t save correct image orientation: '.$tmpkey);
- }
- if(OC_Cache::set($tmpkey, $image->data(), 600)) {
- OCP\JSON::success(array(
- 'data' => array(
- 'mime'=>$_SERVER['CONTENT_TYPE'],
- 'name'=>$fn,
- 'id'=>$id,
- 'tmp'=>$tmpkey)));
- exit();
- } else {
- bailOut($l10n->t('Couldn\'t save temporary image: ').$tmpkey);
- }
- } else {
- bailOut($l10n->t('Couldn\'t load temporary image: ').$tmpkey);
- }
-}
-
-// Uploads from file dialog are handled here.
-if (!isset($_POST['id'])) {
- bailOut($l10n->t('No contact ID was submitted.'));
-}
-if (!isset($_FILES['imagefile'])) {
- bailOut($l10n->t('No file was uploaded. Unknown error'));
-}
-
-$error = $_FILES['imagefile']['error'];
-if($error !== UPLOAD_ERR_OK) {
- $errors = array(
- 0=>$l10n->t("There is no error, the file uploaded with success"),
- 1=>$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
- 2=>$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
- 3=>$l10n->t("The uploaded file was only partially uploaded"),
- 4=>$l10n->t("No file was uploaded"),
- 6=>$l10n->t("Missing a temporary folder")
- );
- bailOut($errors[$error]);
-}
-$file=$_FILES['imagefile'];
-
-if(file_exists($file['tmp_name'])) {
- $tmpkey = 'contact-photo-'.md5(basename($file['tmp_name']));
- $image = new OC_Image();
- if($image->loadFromFile($file['tmp_name'])) {
- if($image->width() > 400 || $image->height() > 400) {
- $image->resize(400); // Prettier resizing than with browser and saves bandwidth.
- }
- if(!$image->fixOrientation()) { // No fatal error so we don't bail out.
- debug('Couldn\'t save correct image orientation: '.$tmpkey);
- }
- if(OC_Cache::set($tmpkey, $image->data(), 600)) {
- OCP\JSON::success(array(
- 'data' => array(
- 'mime'=>$file['type'],
- 'size'=>$file['size'],
- 'name'=>$file['name'],
- 'id'=>$_POST['id'],
- 'tmp'=>$tmpkey,
- )));
- exit();
- } else {
- bailOut($l10n->t('Couldn\'t save temporary image: ').$tmpkey);
- }
- } else {
- bailOut($l10n->t('Couldn\'t load temporary image: ').$file['tmp_name']);
- }
-} else {
- bailOut('Temporary file: \''.$file['tmp_name'].'\' has gone AWOL?');
-}