Esempio n. 1
0
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('contacts');
// Get active address books. This creates a default one if none exists.
$ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser());
$has_contacts = count(OC_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 = OC_Contacts_App::getTypesOfProperty('IMPP');
$phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
$email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
$ims = OC_Contacts_App::getIMOptions();
$im_protocols = array();
foreach ($ims as $name => $values) {
    $im_protocols[$name] = $values['displayname'];
}
$categories = OC_Contacts_App::getCategories();
$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);
$freeSpace = OC_Filesystem::free_space('/');
$freeSpace = max($freeSpace, 0);
$maxUploadFilesize = min($maxUploadFilesize, $freeSpace);
OCP\Util::addscript('', 'jquery.multiselect');
OCP\Util::addscript('', 'oc-vcategories');
OCP\Util::addscript('contacts', 'contacts');
Esempio n. 2
0
 /**
  * @brief Format property TYPE parameters for upgrading from v. 2.1
  * @param $property Reference to a Sabre_VObject_Property.
  * In version 2.1 e.g. a phone can be formatted like: TEL;HOME;CELL:123456789
  * This has to be changed to either TEL;TYPE=HOME,CELL:123456789 or TEL;TYPE=HOME;TYPE=CELL:123456789 - both are valid.
  */
 public static function formatPropertyTypes(&$property)
 {
     foreach ($property->parameters as $key => &$parameter) {
         $types = OC_Contacts_App::getTypesOfProperty($property->name);
         if (is_array($types) && in_array(strtoupper($parameter->name), array_keys($types)) || strtoupper($parameter->name) == 'PREF') {
             $property->parameters[] = new Sabre_VObject_Parameter('TYPE', $parameter->name);
         }
         unset($property->parameters[$key]);
     }
 }
Esempio n. 3
0
<?php

/**
 * Copyright (c) 2011 Thomas Tanghus <*****@*****.**>
 * 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);