Esempio n. 1
0
<?php

/**
 * Copyright (c) 2012 Thomas Tanghus <*****@*****.**>
 * Copyright (c) 2011 Jakob Sack mail@jakobsack.de
 * 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\User::checkLoggedIn();
OCP\App::checkAppEnabled('contacts');
// Get active address books. This creates a default one if none exists.
$ids = OCA\Contacts\Addressbook::activeIds(OCP\USER::getUser());
$has_contacts = count(OCA\Contacts\VCard::all($ids, 0, 1)) > 0 ? true : false;
// just to check if there are any contacts.
if ($has_contacts === false) {
    OCP\Util::writeLog('contacts', 'index.html: No contacts found.', OCP\Util::DEBUG);
}
// Load the files we need
OCP\App::setActiveNavigationEntry('contacts_index');
// Load a specific user?
$id = isset($_GET['id']) ? $_GET['id'] : null;
$impp_types = OCA\Contacts\App::getTypesOfProperty('IMPP');
$adr_types = OCA\Contacts\App::getTypesOfProperty('ADR');
$phone_types = OCA\Contacts\App::getTypesOfProperty('TEL');
$email_types = OCA\Contacts\App::getTypesOfProperty('EMAIL');
$ims = OCA\Contacts\App::getIMOptions();
$im_protocols = array();
foreach ($ims as $name => $values) {
    $im_protocols[$name] = $values['displayname'];
Esempio n. 2
0
 * 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';
$aid = isset($_POST['aid']) ? $_POST['aid'] : null;
if (!$aid) {
    $aid = min(OCA\Contacts\Addressbook::activeIds());
    // first active addressbook.
}
debug('Adding new contact to: ' . $aid);
$isnew = isset($_POST['isnew']) ? $_POST['isnew'] : false;
$vcard = Sabre\VObject\Component::create('VCARD');
$uid = substr(md5(rand() . time()), 0, 10);
$vcard->add('UID', $uid);
debug('vobject: ', print_r($vcard->serialize(), true));
$id = null;
try {
    $id = OCA\Contacts\VCard::add($aid, $vcard, null, $isnew);
} catch (Exception $e) {
    bailOut($e->getMessage());
}
if (!$id) {