mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-18 07:52:21 +01:00
Finally works with core master
This commit is contained in:
parent
44fb5c5d14
commit
1d29b943ae
@ -3,7 +3,7 @@
|
|||||||
namespace OCA\Contacts;
|
namespace OCA\Contacts;
|
||||||
use \OC\AppFramework\Core\API;
|
use \OC\AppFramework\Core\API;
|
||||||
|
|
||||||
//require_once __DIR__ . '/../controller/groupcontroller.php';
|
//require_once __DIR__ . '/../lib/controller/pagecontroller.php';
|
||||||
\Sabre\VObject\Component::$classMap['VCARD'] = '\OCA\Contacts\VObject\VCard';
|
\Sabre\VObject\Component::$classMap['VCARD'] = '\OCA\Contacts\VObject\VCard';
|
||||||
\Sabre\VObject\Property::$classMap['CATEGORIES'] = 'OCA\Contacts\VObject\GroupProperty';
|
\Sabre\VObject\Property::$classMap['CATEGORIES'] = 'OCA\Contacts\VObject\GroupProperty';
|
||||||
\Sabre\VObject\Property::$classMap['FN'] = '\OC\VObject\StringProperty';
|
\Sabre\VObject\Property::$classMap['FN'] = '\OC\VObject\StringProperty';
|
||||||
@ -20,8 +20,6 @@ use \OC\AppFramework\Core\API;
|
|||||||
\Sabre\VObject\Property::$classMap['GEO'] = '\OC\VObject\CompoundProperty';
|
\Sabre\VObject\Property::$classMap['GEO'] = '\OC\VObject\CompoundProperty';
|
||||||
\Sabre\VObject\Property::$classMap['ORG'] = '\OC\VObject\CompoundProperty';
|
\Sabre\VObject\Property::$classMap['ORG'] = '\OC\VObject\CompoundProperty';
|
||||||
|
|
||||||
$api = new API('contacts');
|
|
||||||
|
|
||||||
\OC::$server->getNavigationManager()->add(array(
|
\OC::$server->getNavigationManager()->add(array(
|
||||||
'id' => 'contacts',
|
'id' => 'contacts',
|
||||||
'order' => 10,
|
'order' => 10,
|
||||||
@ -30,7 +28,8 @@ $api = new API('contacts');
|
|||||||
'name' => \OCP\Util::getL10N('contacts')->t('Contacts')
|
'name' => \OCP\Util::getL10N('contacts')->t('Contacts')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
\OC::$server->getNavigationManager()->setActiveEntry('contacts_index');
|
|
||||||
|
$api = new API('contacts');
|
||||||
|
|
||||||
$api->connectHook('OC_User', 'post_createUser', '\OCA\Contacts\Hooks', 'userCreated');
|
$api->connectHook('OC_User', 'post_createUser', '\OCA\Contacts\Hooks', 'userCreated');
|
||||||
$api->connectHook('OC_User', 'post_deleteUser', '\OCA\Contacts\Hooks', 'userDeleted');
|
$api->connectHook('OC_User', 'post_deleteUser', '\OCA\Contacts\Hooks', 'userDeleted');
|
||||||
|
@ -11,28 +11,26 @@ namespace OCA\Contacts;
|
|||||||
use OCA\Contacts\Dispatcher;
|
use OCA\Contacts\Dispatcher;
|
||||||
|
|
||||||
//define the routes
|
//define the routes
|
||||||
//for the index
|
|
||||||
$this->create('contacts_index', '/')
|
$this->create('contacts_index', '/')
|
||||||
->actionInclude('contacts/index.php');
|
->get()
|
||||||
// ->action(
|
->action(
|
||||||
// function($params){
|
function($params){
|
||||||
// //
|
session_write_close();
|
||||||
// }
|
$dispatcher = new Dispatcher($params);
|
||||||
// );
|
$dispatcher->dispatch('PageController', 'index');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$this->create('contacts_jsconfig', 'ajax/config.js')
|
$this->create('contacts_jsconfig', 'ajax/config.js')
|
||||||
->actionInclude('contacts/js/config.php');
|
->actionInclude('contacts/js/config.php');
|
||||||
|
|
||||||
/* TODO: Check what it requires to be a RESTful API. I think maybe {user}
|
|
||||||
shouldn't be in the URI but be authenticated in headers or elsewhere.
|
|
||||||
*/
|
|
||||||
$this->create('contacts_address_books_for_user', 'addressbooks/')
|
$this->create('contacts_address_books_for_user', 'addressbooks/')
|
||||||
->get()
|
->get()
|
||||||
->action(
|
->action(
|
||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('AddressBookController', 'userAddressBooks', $params);
|
$dispatcher->dispatch('AddressBookController', 'userAddressBooks');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -42,7 +40,7 @@ $this->create('contacts_address_book_add', 'addressbook/{backend}/add')
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('AddressBookController', 'addAddressBook', $params);
|
$dispatcher->dispatch('AddressBookController', 'addAddressBook');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend'));
|
->requirements(array('backend'));
|
||||||
@ -53,7 +51,7 @@ $this->create('contacts_address_book', 'addressbook/{backend}/{addressBookId}')
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('AddressBookController', 'getAddressBook', $params);
|
$dispatcher->dispatch('AddressBookController', 'getAddressBook');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressBookId'));
|
->requirements(array('backend', 'addressBookId'));
|
||||||
@ -64,7 +62,7 @@ $this->create('contacts_address_book_update', 'addressbook/{backend}/{addressBoo
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('AddressBookController', 'updateAddressBook', $params);
|
$dispatcher->dispatch('AddressBookController', 'updateAddressBook');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressBookId'));
|
->requirements(array('backend', 'addressBookId'));
|
||||||
@ -75,7 +73,7 @@ $this->create('contacts_address_book_delete', 'addressbook/{backend}/{addressBoo
|
|||||||
function($params) {
|
function($params) {
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher->dispatch('AddressBookController', 'deleteAddressBook', $params);
|
$dispatcher->dispatch('AddressBookController', 'deleteAddressBook');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressBookId'));
|
->requirements(array('backend', 'addressBookId'));
|
||||||
@ -86,7 +84,7 @@ $this->create('contacts_address_book_activate', 'addressbook/{backend}/{addressB
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('AddressBookController', 'activateAddressBook', $params);
|
$dispatcher->dispatch('AddressBookController', 'activateAddressBook');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressBookId'));
|
->requirements(array('backend', 'addressBookId'));
|
||||||
@ -97,7 +95,7 @@ $this->create('contacts_address_book_add_contact', 'addressbook/{backend}/{addre
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('AddressBookController', 'addChild', $params);
|
$dispatcher->dispatch('AddressBookController', 'addChild');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressBookId'));
|
->requirements(array('backend', 'addressBookId'));
|
||||||
@ -108,7 +106,7 @@ $this->create('contacts_address_book_delete_contact', 'addressbook/{backend}/{ad
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('AddressBookController', 'deleteChild', $params);
|
$dispatcher->dispatch('AddressBookController', 'deleteChild');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressBookId', 'contactId'));
|
->requirements(array('backend', 'addressBookId', 'contactId'));
|
||||||
@ -119,7 +117,7 @@ $this->create('contacts_address_book_delete_contacts', 'addressbook/{backend}/{a
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('AddressBookController', 'deleteChildren', $params);
|
$dispatcher->dispatch('AddressBookController', 'deleteChildren');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressBookId', 'contactId'));
|
->requirements(array('backend', 'addressBookId', 'contactId'));
|
||||||
@ -130,7 +128,7 @@ $this->create('contacts_address_book_move_contact', 'addressbook/{backend}/{addr
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('AddressBookController', 'moveChild', $params);
|
$dispatcher->dispatch('AddressBookController', 'moveChild');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressBookId', 'contactId'));
|
->requirements(array('backend', 'addressBookId', 'contactId'));
|
||||||
@ -141,7 +139,7 @@ $this->create('contacts_import_upload', 'addressbook/{backend}/{addressBookId}/i
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ImportController', 'upload', $params);
|
$dispatcher->dispatch('ImportController', 'upload');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressBookId'));
|
->requirements(array('backend', 'addressBookId'));
|
||||||
@ -152,7 +150,7 @@ $this->create('contacts_import_prepare', 'addressbook/{backend}/{addressBookId}/
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ImportController', 'prepare', $params);
|
$dispatcher->dispatch('ImportController', 'prepare');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressBookId'));
|
->requirements(array('backend', 'addressBookId'));
|
||||||
@ -163,7 +161,7 @@ $this->create('contacts_import_start', 'addressbook/{backend}/{addressBookId}/im
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ImportController', 'start', $params);
|
$dispatcher->dispatch('ImportController', 'start');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressBookId'));
|
->requirements(array('backend', 'addressBookId'));
|
||||||
@ -174,7 +172,7 @@ $this->create('contacts_import_status', 'addressbook/{backend}/{addressBookId}/i
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ImportController', 'status', $params);
|
$dispatcher->dispatch('ImportController', 'status');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressBookId'));
|
->requirements(array('backend', 'addressBookId'));
|
||||||
@ -185,7 +183,7 @@ $this->create('contacts_address_book_export', 'addressbook/{backend}/{addressBoo
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ExportController', 'exportAddressBook', $params);
|
$dispatcher->dispatch('ExportController', 'exportAddressBook');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressBookId'));
|
->requirements(array('backend', 'addressBookId'));
|
||||||
@ -196,7 +194,7 @@ $this->create('contacts_contact_export', 'addressbook/{backend}/{addressBookId}/
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ExportController', 'exportContact', $params);
|
$dispatcher->dispatch('ExportController', 'exportContact');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressbook', 'contactId'));
|
->requirements(array('backend', 'addressbook', 'contactId'));
|
||||||
@ -207,7 +205,7 @@ $this->create('contacts_export_selected', 'exportSelected')
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ExportController', 'exportSelected', $params);
|
$dispatcher->dispatch('ExportController', 'exportSelected');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -217,7 +215,7 @@ $this->create('contacts_contact_photo', 'addressbook/{backend}/{addressBookId}/c
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ContactPhotoController', 'getPhoto', $params);
|
$dispatcher->dispatch('ContactPhotoController', 'getPhoto');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressbook', 'contactId'));
|
->requirements(array('backend', 'addressbook', 'contactId'));
|
||||||
@ -228,7 +226,7 @@ $this->create('contacts_upload_contact_photo', 'addressbook/{backend}/{addressBo
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ContactPhotoController', 'uploadPhoto', $params);
|
$dispatcher->dispatch('ContactPhotoController', 'uploadPhoto');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressbook', 'contactId'));
|
->requirements(array('backend', 'addressbook', 'contactId'));
|
||||||
@ -239,7 +237,7 @@ $this->create('contacts_cache_contact_photo', 'addressbook/{backend}/{addressBoo
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ContactPhotoController', 'cacheCurrentPhoto', $params);
|
$dispatcher->dispatch('ContactPhotoController', 'cacheCurrentPhoto');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressbook', 'contactId'));
|
->requirements(array('backend', 'addressbook', 'contactId'));
|
||||||
@ -250,7 +248,7 @@ $this->create('contacts_cache_fs_photo', 'addressbook/{backend}/{addressBookId}/
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ContactPhotoController', 'cacheFileSystemPhoto', $params);
|
$dispatcher->dispatch('ContactPhotoController', 'cacheFileSystemPhoto');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressbook', 'contactId'));
|
->requirements(array('backend', 'addressbook', 'contactId'));
|
||||||
@ -261,7 +259,7 @@ $this->create('contacts_tmp_contact_photo', 'addressbook/{backend}/{addressBookI
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ContactPhotoController', 'getTempPhoto', $params);
|
$dispatcher->dispatch('ContactPhotoController', 'getTempPhoto');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressbook', 'contactId', 'key'));
|
->requirements(array('backend', 'addressbook', 'contactId', 'key'));
|
||||||
@ -272,7 +270,7 @@ $this->create('contacts_crop_contact_photo', 'addressbook/{backend}/{addressBook
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ContactPhotoController', 'cropPhoto', $params);
|
$dispatcher->dispatch('ContactPhotoController', 'cropPhoto');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressbook', 'contactId', 'key'));
|
->requirements(array('backend', 'addressbook', 'contactId', 'key'));
|
||||||
@ -284,7 +282,7 @@ $this->create('contacts_contact_patch', 'addressbook/{backend}/{addressBookId}/c
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ContactController', 'patch', $params);
|
$dispatcher->dispatch('ContactController', 'patch');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressbook', 'contactId'));
|
->requirements(array('backend', 'addressbook', 'contactId'));
|
||||||
@ -295,7 +293,7 @@ $this->create('contacts_contact_get', 'addressbook/{backend}/{addressBookId}/con
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ContactController', 'getContact', $params);
|
$dispatcher->dispatch('ContactController', 'getContact');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressbook', 'contactId'));
|
->requirements(array('backend', 'addressbook', 'contactId'));
|
||||||
@ -307,7 +305,7 @@ $this->create('contacts_contact_save_all', 'addressbook/{backend}/{addressBookId
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('ContactController', 'saveContact', $params);
|
$dispatcher->dispatch('ContactController', 'saveContact');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('backend', 'addressbook', 'contactId'));
|
->requirements(array('backend', 'addressbook', 'contactId'));
|
||||||
@ -318,7 +316,7 @@ $this->create('contacts_categories_list', 'groups/')
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('GroupController', 'getGroups', $params);
|
$dispatcher->dispatch('GroupController', 'getGroups');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -328,7 +326,7 @@ $this->create('contacts_categories_add', 'groups/add')
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('GroupController', 'addGroup', $params);
|
$dispatcher->dispatch('GroupController', 'addGroup');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -338,7 +336,7 @@ $this->create('contacts_categories_delete', 'groups/delete')
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('GroupController', 'deleteGroup', $params);
|
$dispatcher->dispatch('GroupController', 'deleteGroup');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -348,7 +346,7 @@ $this->create('contacts_categories_rename', 'groups/rename')
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('GroupController', 'renameGroup', $params);
|
$dispatcher->dispatch('GroupController', 'renameGroup');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -358,7 +356,7 @@ $this->create('contacts_categories_addto', 'groups/addto/{categoryId}')
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('GroupController', 'addToGroup', $params);
|
$dispatcher->dispatch('GroupController', 'addToGroup');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -368,7 +366,7 @@ $this->create('contacts_categories_removefrom', 'groups/removefrom/{categoryId}'
|
|||||||
function($params) {
|
function($params) {
|
||||||
session_write_close();
|
session_write_close();
|
||||||
$dispatcher = new Dispatcher($params);
|
$dispatcher = new Dispatcher($params);
|
||||||
$dispatcher->dispatch('GroupController', 'removeFromGroup', $params);
|
$dispatcher->dispatch('GroupController', 'removeFromGroup');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
->requirements(array('categoryId'));
|
->requirements(array('categoryId'));
|
||||||
|
165
import.php
165
import.php
@ -1,165 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace OCA\Contacts;
|
|
||||||
|
|
||||||
use Sabre\VObject;
|
|
||||||
|
|
||||||
//check for addressbooks rights or create new one
|
|
||||||
ob_start();
|
|
||||||
|
|
||||||
\OCP\JSON::checkLoggedIn();
|
|
||||||
\OCP\App::checkAppEnabled('contacts');
|
|
||||||
\OCP\JSON::callCheck();
|
|
||||||
session_write_close();
|
|
||||||
|
|
||||||
$nl = "\n";
|
|
||||||
|
|
||||||
global $progresskey;
|
|
||||||
$progresskey = 'contacts.import-' . (isset($_GET['progresskey'])?$_GET['progresskey']:'');
|
|
||||||
|
|
||||||
if (isset($_GET['progress']) && $_GET['progress']) {
|
|
||||||
echo \OC_Cache::get($progresskey);
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
|
|
||||||
function writeProgress($pct) {
|
|
||||||
global $progresskey;
|
|
||||||
\OC_Cache::set($progresskey, $pct, 300);
|
|
||||||
}
|
|
||||||
writeProgress('10');
|
|
||||||
$view = null;
|
|
||||||
$inputfile = strtr($_POST['file'], array('/' => '', "\\" => ''));
|
|
||||||
if(\OC\Files\Filesystem::isFileBlacklisted($inputfile)) {
|
|
||||||
\OCP\JSON::error(array('data' => array('message' => 'Upload of blacklisted file: ' . $inputfile)));
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') {
|
|
||||||
$view = \OCP\Files::getStorage('contacts');
|
|
||||||
$file = $view->file_get_contents('/imports/' . $inputfile);
|
|
||||||
} else {
|
|
||||||
$file = \OC\Files\Filesystem::file_get_contents($_POST['path'] . '/' . $inputfile);
|
|
||||||
}
|
|
||||||
if(!$file) {
|
|
||||||
\OCP\JSON::error(array('data' => array('message' => 'Import file was empty.')));
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
$id = $_POST['id'];
|
|
||||||
|
|
||||||
if(!$id) {
|
|
||||||
\OCP\JSON::error(
|
|
||||||
array(
|
|
||||||
'data' => array(
|
|
||||||
'message' => 'Error getting the ID of the address book.',
|
|
||||||
'file'=>\OCP\Util::sanitizeHTML($inputfile)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
$app = new App();
|
|
||||||
$addressBook = $app->getAddressBook('local', $id);
|
|
||||||
|
|
||||||
//analyse the contacts file
|
|
||||||
writeProgress('40');
|
|
||||||
$file = str_replace(array("\r","\n\n"), array("\n","\n"), $file);
|
|
||||||
$lines = explode($nl, $file);
|
|
||||||
|
|
||||||
$inelement = false;
|
|
||||||
$parts = array();
|
|
||||||
$card = array();
|
|
||||||
foreach($lines as $line) {
|
|
||||||
if(strtoupper(trim($line)) == 'BEGIN:VCARD') {
|
|
||||||
$inelement = true;
|
|
||||||
} elseif (strtoupper(trim($line)) == 'END:VCARD') {
|
|
||||||
$card[] = $line;
|
|
||||||
$parts[] = implode($nl, $card);
|
|
||||||
$card = array();
|
|
||||||
$inelement = false;
|
|
||||||
}
|
|
||||||
if ($inelement === true && trim($line) != '') {
|
|
||||||
$card[] = $line;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//import the contacts
|
|
||||||
writeProgress('70');
|
|
||||||
$imported = 0;
|
|
||||||
$failed = 0;
|
|
||||||
$partial = 0;
|
|
||||||
if(!count($parts) > 0) {
|
|
||||||
\OCP\JSON::error(
|
|
||||||
array(
|
|
||||||
'data' => array(
|
|
||||||
'message' => 'No contacts to import in '
|
|
||||||
. \OCP\Util::sanitizeHTML($inputfile).'. Please check if the file is corrupted.',
|
|
||||||
'file'=>OCP\Util::sanitizeHTML($inputfile)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') {
|
|
||||||
if(!$view->unlink('/imports/' . $inputfile)) {
|
|
||||||
\OCP\Util::writeLog('contacts',
|
|
||||||
'Import: Error unlinking OC_FilesystemView ' . '/' . \OCP\Util::sanitizeHTML($inputfile),
|
|
||||||
\OCP\Util::ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
foreach($parts as $part) {
|
|
||||||
try {
|
|
||||||
$vcard = VObject\Reader::read($part);
|
|
||||||
} catch (VObject\ParseException $e) {
|
|
||||||
try {
|
|
||||||
$vcard = VObject\Reader::read($part, VObject\Reader::OPTION_IGNORE_INVALID_LINES);
|
|
||||||
$partial += 1;
|
|
||||||
\OCP\Util::writeLog('contacts',
|
|
||||||
'Import: Retrying reading card. Error parsing VCard: ' . $e->getMessage(),
|
|
||||||
\OCP\Util::ERROR);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$failed += 1;
|
|
||||||
\OCP\Util::writeLog('contacts',
|
|
||||||
'Import: skipping card. Error parsing VCard: ' . $e->getMessage(),
|
|
||||||
\OCP\Util::ERROR);
|
|
||||||
continue; // Ditch cards that can't be parsed by Sabre.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if($addressBook->addChild($vcard)) {
|
|
||||||
$imported += 1;
|
|
||||||
} else {
|
|
||||||
$failed += 1;
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
\OCP\Util::writeLog('contacts', __LINE__ . ' ' .
|
|
||||||
'Error importing vcard: ' . $e->getMessage() . $nl . $vcard->serialize(),
|
|
||||||
\OCP\Util::ERROR);
|
|
||||||
$failed += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//done the import
|
|
||||||
writeProgress('100');
|
|
||||||
sleep(3);
|
|
||||||
\OC_Cache::remove($progresskey);
|
|
||||||
if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') {
|
|
||||||
if(!$view->unlink('/imports/' . $inputfile)) {
|
|
||||||
\OCP\Util::writeLog('contacts',
|
|
||||||
'Import: Error unlinking OC_FilesystemView ' . '/' . $inputfile,
|
|
||||||
\OCP\Util::ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
\OCP\JSON::success(
|
|
||||||
array(
|
|
||||||
'data' => array(
|
|
||||||
'imported'=>$imported,
|
|
||||||
'failed'=>$failed,
|
|
||||||
'file'=>\OCP\Util::sanitizeHTML($inputfile),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
59
index.php
59
index.php
@ -1,59 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Copyright (c) 2012, 2013 Thomas Tanghus <thomas@tanghus.net>
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace OCA\Contacts;
|
|
||||||
|
|
||||||
// Check if we are a user
|
|
||||||
\OCP\User::checkLoggedIn();
|
|
||||||
\OCP\App::checkAppEnabled('contacts');
|
|
||||||
|
|
||||||
\OCP\App::setActiveNavigationEntry('contacts_index');
|
|
||||||
|
|
||||||
$impp_types = Utils\Properties::getTypesForProperty('IMPP');
|
|
||||||
$adr_types = Utils\Properties::getTypesForProperty('ADR');
|
|
||||||
$phone_types = Utils\Properties::getTypesForProperty('TEL');
|
|
||||||
$email_types = Utils\Properties::getTypesForProperty('EMAIL');
|
|
||||||
$ims = Utils\Properties::getIMOptions();
|
|
||||||
$im_protocols = array();
|
|
||||||
foreach($ims as $name => $values) {
|
|
||||||
$im_protocols[$name] = $values['displayname'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
|
|
||||||
|
|
||||||
\OCP\Util::addScript('', 'jquery.multiselect');
|
|
||||||
\OCP\Util::addScript('', 'tags');
|
|
||||||
\OCP\Util::addScript('contacts', 'jquery.combobox');
|
|
||||||
\OCP\Util::addScript('contacts', 'modernizr.custom');
|
|
||||||
\OCP\Util::addScript('contacts', 'app');
|
|
||||||
\OCP\Util::addScript('contacts', 'addressbooks');
|
|
||||||
\OCP\Util::addScript('contacts', 'contacts');
|
|
||||||
\OCP\Util::addScript('contacts', 'storage');
|
|
||||||
\OCP\Util::addScript('contacts', 'groups');
|
|
||||||
\OCP\Util::addScript('contacts', 'jquery.ocaddnew');
|
|
||||||
\OCP\Util::addScript('files', 'jquery.fileupload');
|
|
||||||
\OCP\Util::addScript('3rdparty/Jcrop', 'jquery.Jcrop');
|
|
||||||
\OCP\Util::addStyle('3rdparty/fontawesome', 'font-awesome');
|
|
||||||
\OCP\Util::addStyle('contacts', 'font-awesome');
|
|
||||||
\OCP\Util::addStyle('', 'jquery.multiselect');
|
|
||||||
\OCP\Util::addStyle('contacts', 'jquery.combobox');
|
|
||||||
\OCP\Util::addStyle('contacts', 'jquery.ocaddnew');
|
|
||||||
\OCP\Util::addStyle('3rdparty/Jcrop', 'jquery.Jcrop');
|
|
||||||
\OCP\Util::addStyle('contacts', 'contacts');
|
|
||||||
|
|
||||||
$tmpl = new \OCP\Template( "contacts", "contacts", "user" );
|
|
||||||
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
|
|
||||||
$tmpl->assign('uploadMaxHumanFilesize',
|
|
||||||
\OCP\Util::humanFileSize($maxUploadFilesize), false);
|
|
||||||
$tmpl->assign('phone_types', $phone_types);
|
|
||||||
$tmpl->assign('email_types', $email_types);
|
|
||||||
$tmpl->assign('adr_types', $adr_types);
|
|
||||||
$tmpl->assign('impp_types', $impp_types);
|
|
||||||
$tmpl->assign('im_protocols', $im_protocols);
|
|
||||||
$tmpl->printPage();
|
|
@ -535,7 +535,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
*/
|
*/
|
||||||
AddressBookList.prototype.add = function(name, cb) {
|
AddressBookList.prototype.add = function(name, cb) {
|
||||||
console.log('AddressBookList.add', name, typeof cb);
|
console.log('AddressBookList.add', name, typeof cb);
|
||||||
var defer = $.Deferred;
|
var defer = $.Deferred();
|
||||||
// Check for wrong, duplicate or empty name
|
// Check for wrong, duplicate or empty name
|
||||||
if(typeof name !== 'string') {
|
if(typeof name !== 'string') {
|
||||||
throw new TypeError('BadArgument: AddressBookList.add() only takes String arguments.');
|
throw new TypeError('BadArgument: AddressBookList.add() only takes String arguments.');
|
||||||
|
@ -586,6 +586,7 @@ OC.Contacts = OC.Contacts || {
|
|||||||
if(data.deleteOther) {
|
if(data.deleteOther) {
|
||||||
self.contacts.delayedDelete(mergees);
|
self.contacts.delayedDelete(mergees);
|
||||||
}
|
}
|
||||||
|
console.log('merger', merger);
|
||||||
self.openContact(merger.getId());
|
self.openContact(merger.getId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -419,7 +419,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
this.setAsSaving(this.$fullelem, true);
|
this.setAsSaving(this.$fullelem, true);
|
||||||
var data = JSON.stringify(this.data);
|
var data = JSON.stringify(this.data);
|
||||||
//console.log('stringified', data);
|
//console.log('stringified', data);
|
||||||
$.when(this.storage.saveAllProperties(this.metadata.backend, this.metadata.parent, this.id, data))
|
$.when(this.storage.saveAllProperties(this.metadata.backend, this.metadata.parent, this.id, {data:this.data}))
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
if(!response.error) {
|
if(!response.error) {
|
||||||
self.data = response.data.data;
|
self.data = response.data.data;
|
||||||
@ -758,8 +758,9 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
self.data = response.data.data;
|
self.data = response.data.data;
|
||||||
self.$groupSelect.multiselect('enable');
|
self.$groupSelect.multiselect('enable');
|
||||||
// Add contact to current group
|
// Add contact to current group
|
||||||
if(self.groupprops && self.groupprops.currentgroup.id !== 'all'
|
if(self.groupprops
|
||||||
&& self.groupprops.currentgroup.id !== 'fav') {
|
&& ['all', 'fav', 'uncategorized'].indexOf(self.groupprops.currentgroup.id) === -1
|
||||||
|
) {
|
||||||
if(!self.data.CATEGORIES) {
|
if(!self.data.CATEGORIES) {
|
||||||
self.addToGroup(self.groupprops.currentgroup.name);
|
self.addToGroup(self.groupprops.currentgroup.name);
|
||||||
$(document).trigger('request.contact.addtogroup', {
|
$(document).trigger('request.contact.addtogroup', {
|
||||||
@ -1860,7 +1861,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
$(document).bind('status.contact.added', function(e, data) {
|
$(document).bind('status.contact.added', function(e, data) {
|
||||||
self.length += 1;
|
self.length += 1;
|
||||||
self.contacts[String(data.id)] = data.contact;
|
self.contacts[String(data.id)] = data.contact;
|
||||||
self.insertContact(data.contact.renderListItem(true));
|
//self.insertContact(data.contact.renderListItem(true));
|
||||||
});
|
});
|
||||||
$(document).bind('status.contact.moved', function(e, data) {
|
$(document).bind('status.contact.moved', function(e, data) {
|
||||||
var contact = data.contact;
|
var contact = data.contact;
|
||||||
|
@ -30,7 +30,7 @@ OC.Contacts = OC.Contacts || {};
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.error = false;
|
this.error = false;
|
||||||
this.data = response.data || response;
|
this.data = response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
18
lib/app.php
18
lib/app.php
@ -74,10 +74,10 @@ class App {
|
|||||||
* @param string $name
|
* @param string $name
|
||||||
* @return \Backend\AbstractBackend
|
* @return \Backend\AbstractBackend
|
||||||
*/
|
*/
|
||||||
public function getBackend($name, $user = null) {
|
public function getBackend($name) {
|
||||||
$name = $name ? $name : 'local';
|
$name = $name ? $name : 'local';
|
||||||
if (isset(self::$backendClasses[$name])) {
|
if (isset(self::$backendClasses[$name])) {
|
||||||
return new self::$backendClasses[$name]($user);
|
return new self::$backendClasses[$name]($this->user);
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception('No backend for: ' . $name, '404');
|
throw new \Exception('No backend for: ' . $name, '404');
|
||||||
}
|
}
|
||||||
@ -98,12 +98,16 @@ class App {
|
|||||||
$backend = self::getBackend($backendName, $this->user);
|
$backend = self::getBackend($backendName, $this->user);
|
||||||
$addressBooks = $backend->getAddressBooksForUser();
|
$addressBooks = $backend->getAddressBooksForUser();
|
||||||
if($backendName === 'local' && count($addressBooks) === 0) {
|
if($backendName === 'local' && count($addressBooks) === 0) {
|
||||||
$id = $backend->createAddressBook(array('displayname' => 'Contacts'));
|
$id = $backend->createAddressBook(array('displayname' => self::$l10n->t('Contacts')));
|
||||||
if($id !== false) {
|
if($id !== false) {
|
||||||
$addressBook = $backend->getAddressBook($id);
|
$addressBook = $backend->getAddressBook($id);
|
||||||
$addressBooks = array($addressBook);
|
$addressBooks = array($addressBook);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Write log
|
\OCP\Util::writeLog(
|
||||||
|
'contacts',
|
||||||
|
__METHOD__ . ', Error creating default address book',
|
||||||
|
\OCP\Util::ERROR
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach($addressBooks as $addressBook) {
|
foreach($addressBooks as $addressBook) {
|
||||||
@ -123,16 +127,15 @@ class App {
|
|||||||
* @return AddressBook|null
|
* @return AddressBook|null
|
||||||
*/
|
*/
|
||||||
public function getAddressBook($backendName, $addressbookid) {
|
public function getAddressBook($backendName, $addressbookid) {
|
||||||
\OCP\Util::writeLog('contacts', __METHOD__ . ': '. $backendName . ', ' . $addressbookid, \OCP\Util::DEBUG);
|
//\OCP\Util::writeLog('contacts', __METHOD__ . ': '. $backendName . ', ' . $addressbookid, \OCP\Util::DEBUG);
|
||||||
foreach(self::$addressBooks as $addressBook) {
|
foreach(self::$addressBooks as $addressBook) {
|
||||||
if($addressBook->getBackend()->name === $backendName
|
if($addressBook->getBackend()->name === $backendName
|
||||||
&& $addressBook->getId() === $addressbookid
|
&& $addressBook->getId() === $addressbookid
|
||||||
) {
|
) {
|
||||||
//\OCP\Util::writeLog('contacts', __METHOD__ . ' returning: '. print_r($addressBook, true), \OCP\Util::DEBUG);
|
|
||||||
return $addressBook;
|
return $addressBook;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Check for return values
|
|
||||||
$backend = self::getBackend($backendName, $this->user);
|
$backend = self::getBackend($backendName, $this->user);
|
||||||
$info = $backend->getAddressBook($addressbookid);
|
$info = $backend->getAddressBook($addressbookid);
|
||||||
if(!$info) {
|
if(!$info) {
|
||||||
@ -154,7 +157,6 @@ class App {
|
|||||||
*/
|
*/
|
||||||
public function getContact($backendName, $addressbookid, $id) {
|
public function getContact($backendName, $addressbookid, $id) {
|
||||||
$addressBook = $this->getAddressBook($backendName, $addressbookid);
|
$addressBook = $this->getAddressBook($backendName, $addressbookid);
|
||||||
// TODO: Check for return value
|
|
||||||
return $addressBook->getChild($id);
|
return $addressBook->getChild($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,11 +25,11 @@ class AddressBookController extends Controller {
|
|||||||
*/
|
*/
|
||||||
public function userAddressBooks() {
|
public function userAddressBooks() {
|
||||||
$addressBooks = $this->app->getAddressBooksForUser();
|
$addressBooks = $this->app->getAddressBooksForUser();
|
||||||
$response = array();
|
$result = array();
|
||||||
$lastModified = 0;
|
$lastModified = 0;
|
||||||
foreach($addressBooks as $addressBook) {
|
foreach($addressBooks as $addressBook) {
|
||||||
$data = $addressBook->getMetaData();
|
$data = $addressBook->getMetaData();
|
||||||
$response[] = $data;
|
$result[] = $data;
|
||||||
if(!is_null($data['lastmodified'])) {
|
if(!is_null($data['lastmodified'])) {
|
||||||
$lastModified = max($lastModified, $data['lastmodified']);
|
$lastModified = max($lastModified, $data['lastmodified']);
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ class AddressBookController extends Controller {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$response = new JSONResponse(array(
|
$response = new JSONResponse(array(
|
||||||
'addressbooks' => $response,
|
'addressbooks' => $result,
|
||||||
));
|
));
|
||||||
|
|
||||||
if($lastModified > 0) {
|
if($lastModified > 0) {
|
||||||
@ -57,7 +57,6 @@ class AddressBookController extends Controller {
|
|||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function getAddressBook() {
|
public function getAddressBook() {
|
||||||
\OCP\Util::writeLog('contacts', __METHOD__ . ' ' . print_r($this->request->urlParams, true), \OCP\Util::DEBUG);
|
|
||||||
$params = $this->request->urlParams;
|
$params = $this->request->urlParams;
|
||||||
|
|
||||||
$addressBook = $this->app->getAddressBook($params['backend'], $params['addressBookId']);
|
$addressBook = $this->app->getAddressBook($params['backend'], $params['addressBookId']);
|
||||||
@ -72,8 +71,10 @@ class AddressBookController extends Controller {
|
|||||||
$response->setETag($etag);
|
$response->setETag($etag);
|
||||||
}
|
}
|
||||||
|
|
||||||
$response->debug('comparing: "' . $etag . '" to ' . $this->request->getHeader('If-None-Match'));
|
//$response->debug('comparing: "' . $etag . '" to ' . $this->request->getHeader('If-None-Match'));
|
||||||
if(!is_null($etag) && $this->request->getHeader('If-None-Match') === '"'.$etag.'"') {
|
if(!is_null($etag)
|
||||||
|
&& $this->request->getHeader('If-None-Match') === '"'.$etag.'"')
|
||||||
|
{
|
||||||
return $response->setStatus(Http::STATUS_NOT_MODIFIED);
|
return $response->setStatus(Http::STATUS_NOT_MODIFIED);
|
||||||
} else {
|
} else {
|
||||||
$contacts = array();
|
$contacts = array();
|
||||||
@ -103,17 +104,13 @@ class AddressBookController extends Controller {
|
|||||||
try {
|
try {
|
||||||
$id = $backend->createAddressBook($this->request->post);
|
$id = $backend->createAddressBook($this->request->post);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$response->bailOut($e->getMessage());
|
return $response->bailOut($e->getMessage());
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
if($id === false) {
|
if($id === false) {
|
||||||
$response->bailOut(App::$l10n->t('Error creating address book'));
|
return $response->bailOut(App::$l10n->t('Error creating address book'));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$response->setStatus('201');
|
return $response->setStatus('201')->setParams($backend->getAddressBook($id));
|
||||||
$response->setParams($backend->getAddressBook($id));
|
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -127,15 +124,12 @@ class AddressBookController extends Controller {
|
|||||||
$addressBook = $this->app->getAddressBook($params['backend'], $params['addressBookId']);
|
$addressBook = $this->app->getAddressBook($params['backend'], $params['addressBookId']);
|
||||||
try {
|
try {
|
||||||
if(!$addressBook->update($this->request['properties'])) {
|
if(!$addressBook->update($this->request['properties'])) {
|
||||||
$response->bailOut(App::$l10n->t('Error updating address book'));
|
return $response->bailOut(App::$l10n->t('Error updating address book'));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$response->bailOut($e->getMessage());
|
return $response->bailOut($e->getMessage());
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
$response->setParams($addressBook->getMetaData());
|
return $response->setParams($addressBook->getMetaData());
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -157,16 +151,14 @@ class AddressBookController extends Controller {
|
|||||||
$addressBookInfo = $backend->getAddressBook($params['addressBookId']);
|
$addressBookInfo = $backend->getAddressBook($params['addressBookId']);
|
||||||
|
|
||||||
if(!$addressBookInfo['permissions'] & \OCP\PERMISSION_DELETE) {
|
if(!$addressBookInfo['permissions'] & \OCP\PERMISSION_DELETE) {
|
||||||
$response->bailOut(App::$l10n->t(
|
return $response->bailOut(App::$l10n->t(
|
||||||
'You do not have permissions to delete the "%s" address book'),
|
'You do not have permissions to delete the "%s" address book'),
|
||||||
array($addressBookInfo['displayname']
|
array($addressBookInfo['displayname']
|
||||||
));
|
));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$backend->deleteAddressBook($params['addressBookId'])) {
|
if(!$backend->deleteAddressBook($params['addressBookId'])) {
|
||||||
$response->bailOut(App::$l10n->t('Error deleting address book'));
|
return $response->bailOut(App::$l10n->t('Error deleting address book'));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
\OCP\Config::setUserValue($this->api->getUserId(), 'contacts', 'last_address_book_deleted', time());
|
\OCP\Config::setUserValue($this->api->getUserId(), 'contacts', 'last_address_book_deleted', time());
|
||||||
return $response;
|
return $response;
|
||||||
@ -200,13 +192,11 @@ class AddressBookController extends Controller {
|
|||||||
try {
|
try {
|
||||||
$id = $addressBook->addChild();
|
$id = $addressBook->addChild();
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$response->bailOut($e->getMessage());
|
return $response->bailOut($e->getMessage());
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($id === false) {
|
if($id === false) {
|
||||||
$response->bailOut(App::$l10n->t('Error creating contact.'));
|
return $response->bailOut(App::$l10n->t('Error creating contact.'));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$contact = $addressBook->getChild($id);
|
$contact = $addressBook->getChild($id);
|
||||||
@ -222,8 +212,7 @@ class AddressBookController extends Controller {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$response->setParams(JSONSerializer::serializeContact($contact));
|
return $response->setParams(JSONSerializer::serializeContact($contact));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -239,15 +228,13 @@ class AddressBookController extends Controller {
|
|||||||
try {
|
try {
|
||||||
$result = $addressBook->deleteChild($params['contactId']);
|
$result = $addressBook->deleteChild($params['contactId']);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$response->bailOut($e->getMessage());
|
return $response->bailOut($e->getMessage());
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($result === false) {
|
if($result === false) {
|
||||||
$response->bailOut(App::$l10n->t('Error deleting contact.'));
|
return $response->bailOut(App::$l10n->t('Error deleting contact.'));
|
||||||
}
|
}
|
||||||
$response->setStatus('204');
|
return $response->setStatus('204');
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -264,12 +251,10 @@ class AddressBookController extends Controller {
|
|||||||
try {
|
try {
|
||||||
$result = $addressBook->deleteChildren($contacts);
|
$result = $addressBook->deleteChildren($contacts);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$response->bailOut($e->getMessage());
|
return $response->bailOut($e->getMessage());
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$response->setParams(array('result' => $result));
|
return $response->setParams(array('result' => $result));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -293,20 +278,17 @@ class AddressBookController extends Controller {
|
|||||||
try {
|
try {
|
||||||
$contactId = $targetAddressBook->addChild($contact);
|
$contactId = $targetAddressBook->addChild($contact);
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$response->bailOut($e->getMessage());
|
return $response->bailOut($e->getMessage());
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
$contact = $targetAddressBook->getChild($contactId);
|
$contact = $targetAddressBook->getChild($contactId);
|
||||||
if(!$contact) {
|
if(!$contact) {
|
||||||
$response->bailOut(App::$l10n->t('Error saving contact.'));
|
return $response->bailOut(App::$l10n->t('Error saving contact.'));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
if(!$fromAddressBook->deleteChild($params['contactId'])) {
|
if(!$fromAddressBook->deleteChild($params['contactId'])) {
|
||||||
// Don't bail out because we have to return the contact
|
// Don't bail out because we have to return the contact
|
||||||
$response->debug(App::$l10n->t('Error removing contact from other address book.'));
|
return $response->debug(App::$l10n->t('Error removing contact from other address book.'));
|
||||||
}
|
}
|
||||||
$response->setParams(JSONSerializer::serializeContact($contact));
|
return $response->setParams(JSONSerializer::serializeContact($contact));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,15 +34,13 @@ class ContactController extends Controller {
|
|||||||
$contact = $addressBook->getChild($params['contactId']);
|
$contact = $addressBook->getChild($params['contactId']);
|
||||||
|
|
||||||
if(!$contact) {
|
if(!$contact) {
|
||||||
$response->bailOut(App::$l10n->t('Couldn\'t find contact.'));
|
return $response->bailOut(App::$l10n->t('Couldn\'t find contact.'));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = JSONSerializer::serializeContact($contact);
|
$data = JSONSerializer::serializeContact($contact);
|
||||||
|
|
||||||
$response->setParams($data);
|
return $response->setData($data);
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,29 +50,28 @@ class ContactController extends Controller {
|
|||||||
|
|
||||||
$request = $this->request;
|
$request = $this->request;
|
||||||
$params = $this->request->urlParams;
|
$params = $this->request->urlParams;
|
||||||
|
$data = isset($request->post['data']) ? $request->post['data'] : null;
|
||||||
$response = new JSONResponse();
|
$response = new JSONResponse();
|
||||||
|
|
||||||
$addressBook = $this->app->getAddressBook($params['backend'], $params['addressBookId']);
|
$addressBook = $this->app->getAddressBook($params['backend'], $params['addressBookId']);
|
||||||
$contact = $addressBook->getChild($params['contactId']);
|
$contact = $addressBook->getChild($params['contactId']);
|
||||||
|
|
||||||
if(!$contact) {
|
if(!$data) {
|
||||||
$response->bailOut(App::$l10n->t('Couldn\'t find contact.'));
|
return $response->bailOut(App::$l10n->t('No contact data in request.'));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$contact->mergeFromArray($request->params)) {
|
if(!$contact) {
|
||||||
$response->bailOut(App::$l10n->t('Error merging into contact.'));
|
return $response->bailOut(App::$l10n->t('Couldn\'t find contact.'));
|
||||||
return $response;
|
}
|
||||||
|
|
||||||
|
if(!$contact->mergeFromArray($data)) {
|
||||||
|
return $response->bailOut(App::$l10n->t('Error merging into contact.'));
|
||||||
}
|
}
|
||||||
if(!$contact->save()) {
|
if(!$contact->save()) {
|
||||||
$response->bailOut(App::$l10n->t('Error saving contact to backend.'));
|
return $response->bailOut(App::$l10n->t('Error saving contact to backend.'));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
$data = JSONSerializer::serializeContact($contact);
|
|
||||||
|
|
||||||
$response->setParams($data);
|
return $response->setData(JSONSerializer::serializeContact($contact));
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,19 +82,13 @@ class ContactController extends Controller {
|
|||||||
|
|
||||||
$patch = $this->request->patch;
|
$patch = $this->request->patch;
|
||||||
$response = new JSONResponse();
|
$response = new JSONResponse();
|
||||||
$response->debug(__METHOD__ .', upload_max_filesize: ' . ini_get('upload_max_filesize'));
|
|
||||||
|
|
||||||
$name = $patch['name'];
|
$name = $patch['name'];
|
||||||
$value = $patch['value'];
|
$value = $patch['value'];
|
||||||
$checksum = isset($patch['checksum']) ? $patch['checksum'] : null;
|
$checksum = isset($patch['checksum']) ? $patch['checksum'] : null;
|
||||||
$parameters = isset($patch['parameters']) ? $patch['parameters'] : null;
|
$parameters = isset($patch['parameters']) ? $patch['parameters'] : null;
|
||||||
$response->debug(__METHOD__ . ', name: ' . print_r($name, true));
|
|
||||||
$response->debug(__METHOD__ . ', value: ' . print_r($value, true));
|
|
||||||
$response->debug(__METHOD__ . ', checksum: ' . print_r($checksum, true));
|
|
||||||
$response->debug(__METHOD__ . ', parameters: ' . print_r($parameters, true));
|
|
||||||
|
|
||||||
$addressBook = $this->app->getAddressBook($params['backend'], $params['addressBookId']);
|
$addressBook = $this->app->getAddressBook($params['backend'], $params['addressBookId']);
|
||||||
//$response->debug(__METHOD__ . ', addressBook: ' . print_r($addressBook, true));
|
|
||||||
$contact = $addressBook->getChild($params['contactId']);
|
$contact = $addressBook->getChild($params['contactId']);
|
||||||
|
|
||||||
if(!$contact) {
|
if(!$contact) {
|
||||||
|
@ -192,17 +192,15 @@ class ContactPhotoController extends Controller {
|
|||||||
$tmpkey = 'contact-photo-' . $params['contactId'];
|
$tmpkey = 'contact-photo-' . $params['contactId'];
|
||||||
|
|
||||||
if(!file_exists($localpath)) {
|
if(!file_exists($localpath)) {
|
||||||
$response->bailOut(App::$l10n->t('File doesn\'t exist:').$localpath);
|
return $response->bailOut(App::$l10n->t('File doesn\'t exist:').$localpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
$image = new \OCP\Image();
|
$image = new \OCP\Image();
|
||||||
if(!$image) {
|
if(!$image) {
|
||||||
$response->bailOut(App::$l10n->t('Error loading image.'));
|
return $response->bailOut(App::$l10n->t('Error loading image.'));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
if(!$image->loadFromFile($localpath)) {
|
if(!$image->loadFromFile($localpath)) {
|
||||||
$response->bailOut(App::$l10n->t('Error loading image.'));
|
return $response->bailOut(App::$l10n->t('Error loading image.'));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
if($image->width() > 400 || $image->height() > 400) {
|
if($image->width() > 400 || $image->height() > 400) {
|
||||||
$image->resize(400); // Prettier resizing than with browser and saves bandwidth.
|
$image->resize(400); // Prettier resizing than with browser and saves bandwidth.
|
||||||
@ -211,11 +209,10 @@ class ContactPhotoController extends Controller {
|
|||||||
$response->debug('Couldn\'t save correct image orientation: '.$localpath);
|
$response->debug('Couldn\'t save correct image orientation: '.$localpath);
|
||||||
}
|
}
|
||||||
if(!$this->server->getCache()->set($tmpkey, $image->data(), 600)) {
|
if(!$this->server->getCache()->set($tmpkey, $image->data(), 600)) {
|
||||||
$response->bailOut('Couldn\'t save temporary image: '.$tmpkey);
|
return $response->bailOut('Couldn\'t save temporary image: '.$tmpkey);
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$response->setParams(array(
|
return $response->setData(array(
|
||||||
'tmp'=>$tmpkey,
|
'tmp'=>$tmpkey,
|
||||||
'metadata' => array(
|
'metadata' => array(
|
||||||
'contactId'=> $params['contactId'],
|
'contactId'=> $params['contactId'],
|
||||||
@ -224,8 +221,6 @@ class ContactPhotoController extends Controller {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
return $response;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -248,8 +243,7 @@ class ContactPhotoController extends Controller {
|
|||||||
return $response;
|
return $response;
|
||||||
} else {
|
} else {
|
||||||
$response = new JSONResponse();
|
$response = new JSONResponse();
|
||||||
$response->bailOut('Error getting temporary photo');
|
return $response->bailOut('Error getting temporary photo');
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,35 +268,30 @@ class ContactPhotoController extends Controller {
|
|||||||
$response = new JSONResponse();
|
$response = new JSONResponse();
|
||||||
|
|
||||||
if(!$contact) {
|
if(!$contact) {
|
||||||
$response->bailOut(App::$l10n->t('Couldn\'t find contact.'));
|
return $response->bailOut(App::$l10n->t('Couldn\'t find contact.'));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->server->getCache()->get($tmpkey);
|
$data = $this->server->getCache()->get($tmpkey);
|
||||||
if(!$data) {
|
if(!$data) {
|
||||||
$response->bailOut(App::$l10n->t('Image has been removed from cache'));
|
return $response->bailOut(App::$l10n->t('Image has been removed from cache'));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$image = new \OCP\Image();
|
$image = new \OCP\Image();
|
||||||
|
|
||||||
if(!$image->loadFromData($data)) {
|
if(!$image->loadFromData($data)) {
|
||||||
$response->bailOut(App::$l10n->t('Error creating temporary image'));
|
return $response->bailOut(App::$l10n->t('Error creating temporary image'));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$w = ($w !== -1 ? $w : $image->width());
|
$w = ($w !== -1 ? $w : $image->width());
|
||||||
$h = ($h !== -1 ? $h : $image->height());
|
$h = ($h !== -1 ? $h : $image->height());
|
||||||
|
|
||||||
if(!$image->crop($x, $y, $w, $h)) {
|
if(!$image->crop($x, $y, $w, $h)) {
|
||||||
$response->bailOut(App::$l10n->t('Error cropping image'));
|
return $response->bailOut(App::$l10n->t('Error cropping image'));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($image->width() < $maxSize || $image->height() < $maxSize) {
|
if($image->width() < $maxSize || $image->height() < $maxSize) {
|
||||||
if(!$image->resize(200)) {
|
if(!$image->resize(200)) {
|
||||||
$response->bailOut(App::$l10n->t('Error resizing image'));
|
return $response->bailOut(App::$l10n->t('Error resizing image'));
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +308,7 @@ class ContactPhotoController extends Controller {
|
|||||||
$property = $contact->PHOTO;
|
$property = $contact->PHOTO;
|
||||||
if(!$property) {
|
if(!$property) {
|
||||||
$this->server->getCache()->remove($tmpkey);
|
$this->server->getCache()->remove($tmpkey);
|
||||||
$response->bailOut(App::$l10n
|
return $response->bailOut(App::$l10n
|
||||||
->t('Error getting PHOTO property.'));
|
->t('Error getting PHOTO property.'));
|
||||||
}
|
}
|
||||||
$property->setValue(strval($image));
|
$property->setValue(strval($image));
|
||||||
@ -335,7 +324,7 @@ class ContactPhotoController extends Controller {
|
|||||||
'TYPE' => $type));
|
'TYPE' => $type));
|
||||||
}
|
}
|
||||||
if(!$contact->save()) {
|
if(!$contact->save()) {
|
||||||
$response->bailOut(App::$l10n->t('Error saving contact.'));
|
return $response->bailOut(App::$l10n->t('Error saving contact.'));
|
||||||
}
|
}
|
||||||
$thumbnail = $contact->cacheThumbnail($image);
|
$thumbnail = $contact->cacheThumbnail($image);
|
||||||
$response->setParams(array(
|
$response->setParams(array(
|
||||||
|
75
lib/controller/pagecontroller.php
Normal file
75
lib/controller/pagecontroller.php
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2012, 2013 Thomas Tanghus <thomas@tanghus.net>
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OCA\Contacts\Controller;
|
||||||
|
|
||||||
|
use OCA\Contacts\App,
|
||||||
|
OCA\Contacts\Controller,
|
||||||
|
OCA\Contacts\Utils\Properties,
|
||||||
|
OCP\AppFramework\Http\TemplateResponse;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller class for groups/categories
|
||||||
|
*/
|
||||||
|
class PageController extends Controller {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @NoAdminRequired
|
||||||
|
* @NoCSRFRequired
|
||||||
|
*/
|
||||||
|
public function index() {
|
||||||
|
\OC::$server->getNavigationManager()->setActiveEntry('contacts');
|
||||||
|
|
||||||
|
$impp_types = Properties::getTypesForProperty('IMPP');
|
||||||
|
$adr_types = Properties::getTypesForProperty('ADR');
|
||||||
|
$phone_types = Properties::getTypesForProperty('TEL');
|
||||||
|
$email_types = Properties::getTypesForProperty('EMAIL');
|
||||||
|
$ims = Properties::getIMOptions();
|
||||||
|
$im_protocols = array();
|
||||||
|
foreach($ims as $name => $values) {
|
||||||
|
$im_protocols[$name] = $values['displayname'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$maxUploadFilesize = \OCP\Util::maxUploadFilesize('/');
|
||||||
|
|
||||||
|
\OCP\Util::addScript('', 'jquery.multiselect');
|
||||||
|
\OCP\Util::addScript('', 'tags');
|
||||||
|
\OCP\Util::addScript('contacts', 'jquery.combobox');
|
||||||
|
\OCP\Util::addScript('contacts', 'modernizr.custom');
|
||||||
|
\OCP\Util::addScript('contacts', 'app');
|
||||||
|
\OCP\Util::addScript('contacts', 'addressbooks');
|
||||||
|
\OCP\Util::addScript('contacts', 'contacts');
|
||||||
|
\OCP\Util::addScript('contacts', 'storage');
|
||||||
|
\OCP\Util::addScript('contacts', 'groups');
|
||||||
|
\OCP\Util::addScript('contacts', 'jquery.ocaddnew');
|
||||||
|
\OCP\Util::addScript('files', 'jquery.fileupload');
|
||||||
|
\OCP\Util::addScript('3rdparty/Jcrop', 'jquery.Jcrop');
|
||||||
|
\OCP\Util::addStyle('3rdparty/fontawesome', 'font-awesome');
|
||||||
|
\OCP\Util::addStyle('contacts', 'font-awesome');
|
||||||
|
\OCP\Util::addStyle('', 'jquery.multiselect');
|
||||||
|
\OCP\Util::addStyle('contacts', 'jquery.combobox');
|
||||||
|
\OCP\Util::addStyle('contacts', 'jquery.ocaddnew');
|
||||||
|
\OCP\Util::addStyle('3rdparty/Jcrop', 'jquery.Jcrop');
|
||||||
|
\OCP\Util::addStyle('contacts', 'contacts');
|
||||||
|
|
||||||
|
$response = new TemplateResponse('contacts', 'contacts');
|
||||||
|
$response->setParams(array(
|
||||||
|
'uploadMaxFilesize' => $maxUploadFilesize,
|
||||||
|
'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
|
||||||
|
'phone_types' => $phone_types,
|
||||||
|
'email_types' => $email_types,
|
||||||
|
'adr_types' => $adr_types,
|
||||||
|
'impp_types' => $impp_types,
|
||||||
|
'im_protocols' => $im_protocols,
|
||||||
|
));
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,7 @@ use OCP\AppFramework\App as MainApp,
|
|||||||
OCP\AppFramework\IAppContainer,
|
OCP\AppFramework\IAppContainer,
|
||||||
OCA\Contacts\App,
|
OCA\Contacts\App,
|
||||||
OCA\Contacts\Middleware\Http as HttpMiddleware,
|
OCA\Contacts\Middleware\Http as HttpMiddleware,
|
||||||
|
OCA\Contacts\Controller\PageController,
|
||||||
OCA\Contacts\Controller\AddressBookController,
|
OCA\Contacts\Controller\AddressBookController,
|
||||||
OCA\Contacts\Controller\GroupController,
|
OCA\Contacts\Controller\GroupController,
|
||||||
OCA\Contacts\Controller\ContactController,
|
OCA\Contacts\Controller\ContactController,
|
||||||
@ -48,6 +49,9 @@ class Dispatcher extends MainApp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function registerServices() {
|
public function registerServices() {
|
||||||
|
$this->container->registerService('PageController', function(IAppContainer $container) {
|
||||||
|
return new PageController($container, $this->app);
|
||||||
|
});
|
||||||
$this->container->registerService('AddressBookController', function(IAppContainer $container) {
|
$this->container->registerService('AddressBookController', function(IAppContainer $container) {
|
||||||
return new AddressBookController($container, $this->app);
|
return new AddressBookController($container, $this->app);
|
||||||
});
|
});
|
||||||
|
@ -35,10 +35,11 @@ class ImageResponse extends Response {
|
|||||||
*/
|
*/
|
||||||
public function setImage(\OCP\Image $image) {
|
public function setImage(\OCP\Image $image) {
|
||||||
if(!$image->valid()) {
|
if(!$image->valid()) {
|
||||||
throw new InvalidArgumentException(__METHOD__. ' The image resource is not valid.');
|
throw new \InvalidArgumentException(__METHOD__. ' The image resource is not valid.');
|
||||||
}
|
}
|
||||||
$this->image = $image;
|
$this->image = $image;
|
||||||
$this->addHeader('Content-Type', $image->mimeType());
|
$this->addHeader('Content-Type', $image->mimeType());
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,7 +48,7 @@ class ImageResponse extends Response {
|
|||||||
*/
|
*/
|
||||||
public function render() {
|
public function render() {
|
||||||
if(is_null($this->image)) {
|
if(is_null($this->image)) {
|
||||||
throw new BadMethodCallException(__METHOD__. ' Image must be set either in constructor or with setImage()');
|
throw new \BadMethodCallException(__METHOD__. ' Image must be set either in constructor or with setImage()');
|
||||||
}
|
}
|
||||||
return $this->image->data();
|
return $this->image->data();
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,9 @@ use OCP\AppFramework\Http\JSONResponse as OriginalResponse,
|
|||||||
*/
|
*/
|
||||||
class JSONResponse extends OriginalResponse {
|
class JSONResponse extends OriginalResponse {
|
||||||
|
|
||||||
public function __construct($params = array(), $statusCode=Http::STATUS_OK) {
|
public function __construct($params = array(), $statusCode = Http::STATUS_OK) {
|
||||||
parent::__construct(array(), $statusCode);
|
parent::__construct(array(), $statusCode);
|
||||||
$this->data['data'] = $params;
|
$this->data = $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,11 +30,9 @@ class JSONResponse extends OriginalResponse {
|
|||||||
public function setParams(array $params) {
|
public function setParams(array $params) {
|
||||||
$this->setData($params);
|
$this->setData($params);
|
||||||
return $this;
|
return $this;
|
||||||
$this->data['data'] = $params;
|
|
||||||
$this->data['status'] = 'success';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setData($data){
|
public function setData($data) {
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -52,7 +50,6 @@ class JSONResponse extends OriginalResponse {
|
|||||||
$this->error = true;
|
$this->error = true;
|
||||||
$this->data = $message;
|
$this->data = $message;
|
||||||
return $this;
|
return $this;
|
||||||
//$this->data['status'] = 'error';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function bailOut($msg, $tracelevel = 1, $debuglevel = \OCP\Util::ERROR) {
|
function bailOut($msg, $tracelevel = 1, $debuglevel = \OCP\Util::ERROR) {
|
||||||
@ -61,8 +58,7 @@ class JSONResponse extends OriginalResponse {
|
|||||||
$this->setStatus($msg->getCode());
|
$this->setStatus($msg->getCode());
|
||||||
}
|
}
|
||||||
$this->setErrorMessage($msg);
|
$this->setErrorMessage($msg);
|
||||||
$this->debug($msg, $tracelevel, $debuglevel);
|
return $this->debug($msg, $tracelevel, $debuglevel);
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function debug($msg, $tracelevel = 0, $debuglevel = \OCP\Util::DEBUG) {
|
function debug($msg, $tracelevel = 0, $debuglevel = \OCP\Util::DEBUG) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user