2011-08-06 22:32:06 +02:00
|
|
|
<?php
|
2014-01-26 00:40:22 +01:00
|
|
|
/**
|
|
|
|
* @author Thomas Tanghus
|
|
|
|
* @copyright 2011-2014 Thomas Tanghus (thomas@tanghus.net)
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
2013-04-18 01:12:04 +02:00
|
|
|
|
|
|
|
namespace OCA\Contacts;
|
2014-03-08 16:22:51 +01:00
|
|
|
|
2013-09-16 21:30:16 +02:00
|
|
|
use \OC\AppFramework\Core\API;
|
2013-04-18 01:12:04 +02:00
|
|
|
|
2013-10-17 02:10:34 +02:00
|
|
|
//require_once __DIR__ . '/../lib/controller/pagecontroller.php';
|
2013-05-15 23:52:41 +02:00
|
|
|
\Sabre\VObject\Component::$classMap['VCARD'] = '\OCA\Contacts\VObject\VCard';
|
2014-03-18 00:56:57 +01:00
|
|
|
\Sabre\VObject\Property::$classMap['CATEGORIES'] = '\OCA\Contacts\VObject\GroupProperty';
|
2013-05-15 23:52:41 +02:00
|
|
|
\Sabre\VObject\Property::$classMap['FN'] = '\OC\VObject\StringProperty';
|
|
|
|
\Sabre\VObject\Property::$classMap['TITLE'] = '\OC\VObject\StringProperty';
|
|
|
|
\Sabre\VObject\Property::$classMap['ROLE'] = '\OC\VObject\StringProperty';
|
|
|
|
\Sabre\VObject\Property::$classMap['NOTE'] = '\OC\VObject\StringProperty';
|
|
|
|
\Sabre\VObject\Property::$classMap['NICKNAME'] = '\OC\VObject\StringProperty';
|
|
|
|
\Sabre\VObject\Property::$classMap['EMAIL'] = '\OC\VObject\StringProperty';
|
|
|
|
\Sabre\VObject\Property::$classMap['TEL'] = '\OC\VObject\StringProperty';
|
|
|
|
\Sabre\VObject\Property::$classMap['IMPP'] = '\OC\VObject\StringProperty';
|
|
|
|
\Sabre\VObject\Property::$classMap['URL'] = '\OC\VObject\StringProperty';
|
2014-03-02 23:41:20 +01:00
|
|
|
\Sabre\VObject\Property::$classMap['LABEL'] = '\OC\VObject\StringProperty';
|
2014-01-12 20:23:58 +01:00
|
|
|
\Sabre\VObject\Property::$classMap['X-EVOLUTION-FILE-AS'] = '\OC\VObject\StringProperty';
|
2013-05-15 23:52:41 +02:00
|
|
|
\Sabre\VObject\Property::$classMap['N'] = '\OC\VObject\CompoundProperty';
|
|
|
|
\Sabre\VObject\Property::$classMap['ADR'] = '\OC\VObject\CompoundProperty';
|
|
|
|
\Sabre\VObject\Property::$classMap['GEO'] = '\OC\VObject\CompoundProperty';
|
2013-10-03 18:08:49 +02:00
|
|
|
\Sabre\VObject\Property::$classMap['ORG'] = '\OC\VObject\CompoundProperty';
|
2013-04-18 01:12:04 +02:00
|
|
|
|
2013-09-27 16:37:51 +02:00
|
|
|
\OC::$server->getNavigationManager()->add(array(
|
|
|
|
'id' => 'contacts',
|
2013-09-25 23:38:31 +02:00
|
|
|
'order' => 10,
|
|
|
|
'href' => \OCP\Util::linkToRoute('contacts_index'),
|
|
|
|
'icon' => \OCP\Util::imagePath( 'contacts', 'contacts.svg' ),
|
|
|
|
'name' => \OCP\Util::getL10N('contacts')->t('Contacts')
|
|
|
|
)
|
|
|
|
);
|
2013-10-17 02:10:34 +02:00
|
|
|
|
|
|
|
$api = new API('contacts');
|
2013-09-25 23:38:31 +02:00
|
|
|
|
|
|
|
$api->connectHook('OC_User', 'post_createUser', '\OCA\Contacts\Hooks', 'userCreated');
|
|
|
|
$api->connectHook('OC_User', 'post_deleteUser', '\OCA\Contacts\Hooks', 'userDeleted');
|
|
|
|
$api->connectHook('OCA\Contacts', 'pre_deleteAddressBook', '\OCA\Contacts\Hooks', 'addressBookDeletion');
|
|
|
|
$api->connectHook('OCA\Contacts', 'pre_deleteContact', '\OCA\Contacts\Hooks', 'contactDeletion');
|
|
|
|
$api->connectHook('OCA\Contacts', 'post_createContact', 'OCA\Contacts\Hooks', 'contactAdded');
|
|
|
|
$api->connectHook('OCA\Contacts', 'post_updateContact', '\OCA\Contacts\Hooks', 'contactUpdated');
|
|
|
|
$api->connectHook('OCA\Contacts', 'scanCategories', '\OCA\Contacts\Hooks', 'scanCategories');
|
|
|
|
$api->connectHook('OCA\Contacts', 'indexProperties', '\OCA\Contacts\Hooks', 'indexProperties');
|
|
|
|
$api->connectHook('OC_Calendar', 'getEvents', 'OCA\Contacts\Hooks', 'getBirthdayEvents');
|
|
|
|
$api->connectHook('OC_Calendar', 'getSources', 'OCA\Contacts\Hooks', 'getCalenderSources');
|
|
|
|
|
|
|
|
\OCP\Util::addscript('contacts', 'loader');
|
|
|
|
|
|
|
|
\OC_Search::registerProvider('OCA\Contacts\SearchProvider');
|
|
|
|
//\OCP\Share::registerBackend('contact', 'OCA\Contacts\Share_Backend_Contact');
|
|
|
|
\OCP\Share::registerBackend('addressbook', 'OCA\Contacts\Share\Addressbook', 'contact');
|
|
|
|
//\OCP\App::registerPersonal('contacts','personalsettings');
|
|
|
|
|
2014-03-08 16:22:51 +01:00
|
|
|
if (\OCP\User::isLoggedIn()) {
|
2013-09-25 23:38:31 +02:00
|
|
|
$app = new App($api->getUserId());
|
|
|
|
$addressBooks = $app->getAddressBooksForUser();
|
2014-03-08 16:22:51 +01:00
|
|
|
foreach ($addressBooks as $addressBook) {
|
|
|
|
if ($addressBook->isActive()) {
|
2014-04-23 08:42:17 +02:00
|
|
|
\OCP\Contacts::registerAddressBook($addressBook->getSearchProvider());
|
2014-02-26 11:28:01 +01:00
|
|
|
}
|
2013-03-13 20:49:27 +01:00
|
|
|
}
|
2013-09-25 23:38:31 +02:00
|
|
|
}
|
2014-04-03 18:36:11 +02:00
|
|
|
|