mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-18 07:52:21 +01:00
Remove use of deprecated API class
This commit is contained in:
parent
513b1d6875
commit
ac70af510d
@ -9,9 +9,6 @@
|
|||||||
|
|
||||||
namespace OCA\Contacts;
|
namespace OCA\Contacts;
|
||||||
|
|
||||||
use \OC\AppFramework\Core\API;
|
|
||||||
|
|
||||||
//require_once __DIR__ . '/../lib/controller/pagecontroller.php';
|
|
||||||
\Sabre\VObject\Component\VCard::$componentMap['VCARD'] = '\OCA\Contacts\VObject\VCard';
|
\Sabre\VObject\Component\VCard::$componentMap['VCARD'] = '\OCA\Contacts\VObject\VCard';
|
||||||
\Sabre\VObject\Component\VCard::$propertyMap['CATEGORIES'] = '\OCA\Contacts\VObject\GroupProperty';
|
\Sabre\VObject\Component\VCard::$propertyMap['CATEGORIES'] = '\OCA\Contacts\VObject\GroupProperty';
|
||||||
|
|
||||||
@ -24,18 +21,16 @@ use \OC\AppFramework\Core\API;
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$api = new API('contacts');
|
\OCP\Util::connectHook('OC_User', 'post_createUser', '\OCA\Contacts\Hooks', 'userCreated');
|
||||||
|
\OCP\Util::connectHook('OC_User', 'post_deleteUser', '\OCA\Contacts\Hooks', 'userDeleted');
|
||||||
$api->connectHook('OC_User', 'post_createUser', '\OCA\Contacts\Hooks', 'userCreated');
|
\OCP\Util::connectHook('OCA\Contacts', 'pre_deleteAddressBook', '\OCA\Contacts\Hooks', 'addressBookDeletion');
|
||||||
$api->connectHook('OC_User', 'post_deleteUser', '\OCA\Contacts\Hooks', 'userDeleted');
|
\OCP\Util::connectHook('OCA\Contacts', 'pre_deleteContact', '\OCA\Contacts\Hooks', 'contactDeletion');
|
||||||
$api->connectHook('OCA\Contacts', 'pre_deleteAddressBook', '\OCA\Contacts\Hooks', 'addressBookDeletion');
|
\OCP\Util::connectHook('OCA\Contacts', 'post_createContact', 'OCA\Contacts\Hooks', 'contactAdded');
|
||||||
$api->connectHook('OCA\Contacts', 'pre_deleteContact', '\OCA\Contacts\Hooks', 'contactDeletion');
|
\OCP\Util::connectHook('OCA\Contacts', 'post_updateContact', '\OCA\Contacts\Hooks', 'contactUpdated');
|
||||||
$api->connectHook('OCA\Contacts', 'post_createContact', 'OCA\Contacts\Hooks', 'contactAdded');
|
\OCP\Util::connectHook('OCA\Contacts', 'scanCategories', '\OCA\Contacts\Hooks', 'scanCategories');
|
||||||
$api->connectHook('OCA\Contacts', 'post_updateContact', '\OCA\Contacts\Hooks', 'contactUpdated');
|
\OCP\Util::connectHook('OCA\Contacts', 'indexProperties', '\OCA\Contacts\Hooks', 'indexProperties');
|
||||||
$api->connectHook('OCA\Contacts', 'scanCategories', '\OCA\Contacts\Hooks', 'scanCategories');
|
\OCP\Util::connectHook('OC_Calendar', 'getEvents', 'OCA\Contacts\Hooks', 'getBirthdayEvents');
|
||||||
$api->connectHook('OCA\Contacts', 'indexProperties', '\OCA\Contacts\Hooks', 'indexProperties');
|
\OCP\Util::connectHook('OC_Calendar', 'getSources', 'OCA\Contacts\Hooks', 'getCalenderSources');
|
||||||
$api->connectHook('OC_Calendar', 'getEvents', 'OCA\Contacts\Hooks', 'getBirthdayEvents');
|
|
||||||
$api->connectHook('OC_Calendar', 'getSources', 'OCA\Contacts\Hooks', 'getCalenderSources');
|
|
||||||
|
|
||||||
\OCP\Util::addscript('contacts', 'loader');
|
\OCP\Util::addscript('contacts', 'loader');
|
||||||
\OCP\Util::addscript('contacts', 'admin');
|
\OCP\Util::addscript('contacts', 'admin');
|
||||||
@ -47,12 +42,16 @@ $api->connectHook('OC_Calendar', 'getSources', 'OCA\Contacts\Hooks', 'getCalende
|
|||||||
\OCP\App::registerAdmin('contacts', 'admin');
|
\OCP\App::registerAdmin('contacts', 'admin');
|
||||||
|
|
||||||
if (\OCP\User::isLoggedIn()) {
|
if (\OCP\User::isLoggedIn()) {
|
||||||
$app = new App($api->getUserId());
|
$cm = \OC::$server->getContactsManager();
|
||||||
$addressBooks = $app->getAddressBooksForUser();
|
$cm->register(function() use ($cm) {
|
||||||
foreach ($addressBooks as $addressBook) {
|
$userId = \OC::$server->getUserSession()->getUser()->getUID();
|
||||||
if ($addressBook->isActive()) {
|
$app = new App($userId);
|
||||||
\OCP\Contacts::registerAddressBook($addressBook->getSearchProvider());
|
$addressBooks = $app->getAddressBooksForUser();
|
||||||
}
|
foreach ($addressBooks as $addressBook) {
|
||||||
}
|
if ($addressBook->isActive()) {
|
||||||
|
$cm->registerAddressBook($addressBook->getSearchProvider());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class App {
|
|||||||
/**
|
/**
|
||||||
* @brief language object for calendar app
|
* @brief language object for calendar app
|
||||||
*
|
*
|
||||||
* @var OC_L10N
|
* @var \OCP\IL10N
|
||||||
*/
|
*/
|
||||||
public static $l10n;
|
public static $l10n;
|
||||||
|
|
||||||
|
@ -11,26 +11,14 @@
|
|||||||
|
|
||||||
namespace OCA\Contacts;
|
namespace OCA\Contacts;
|
||||||
|
|
||||||
use OCP\AppFramework\IAppContainer,
|
use OCP\AppFramework\Controller as BaseController;
|
||||||
OCP\AppFramework\Controller as BaseController,
|
use OCP\IRequest;
|
||||||
OCP\IRequest,
|
|
||||||
OCA\Contacts\App;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base Controller class for Contacts App
|
* Base Controller class for Contacts App
|
||||||
*/
|
*/
|
||||||
class Controller extends BaseController {
|
class Controller extends BaseController {
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Api
|
|
||||||
*/
|
|
||||||
protected $api;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var IRequest
|
|
||||||
*/
|
|
||||||
protected $request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var App
|
* @var App
|
||||||
*/
|
*/
|
||||||
|
@ -14,7 +14,6 @@ use OCA\Contacts\App,
|
|||||||
OCA\Contacts\Utils\JSONSerializer,
|
OCA\Contacts\Utils\JSONSerializer,
|
||||||
OCA\Contacts\Controller,
|
OCA\Contacts\Controller,
|
||||||
OCP\AppFramework\Http,
|
OCP\AppFramework\Http,
|
||||||
OCP\AppFramework\IApi,
|
|
||||||
OCP\IRequest;
|
OCP\IRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,14 +21,12 @@ use OCA\Contacts\App,
|
|||||||
*/
|
*/
|
||||||
class AddressBookController extends Controller {
|
class AddressBookController extends Controller {
|
||||||
|
|
||||||
/**
|
/** @var string */
|
||||||
* @var \OCP\AppFramework\IApi
|
protected $userId;
|
||||||
*/
|
|
||||||
protected $api;
|
|
||||||
|
|
||||||
public function __construct($appName, IRequest $request, App $app, IApi $api) {
|
public function __construct($appName, IRequest $request, App $app, $userId) {
|
||||||
parent::__construct($appName, $request, $app);
|
parent::__construct($appName, $request, $app);
|
||||||
$this->api = $api;
|
$this->userId = $userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,7 +52,7 @@ class AddressBookController extends Controller {
|
|||||||
// To avoid invalid cache deletion time is saved
|
// To avoid invalid cache deletion time is saved
|
||||||
/*$lastModified = max(
|
/*$lastModified = max(
|
||||||
$lastModified,
|
$lastModified,
|
||||||
\OCP\Config::getUserValue($this->api->getUserId(), 'contacts', 'last_address_book_deleted', 0)
|
\OCP\Config::getUserValue($this->userId, 'contacts', 'last_address_book_deleted', 0)
|
||||||
);*/
|
);*/
|
||||||
|
|
||||||
$response = new JSONResponse(array(
|
$response = new JSONResponse(array(
|
||||||
@ -222,7 +219,7 @@ class AddressBookController extends Controller {
|
|||||||
), 500);
|
), 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
\OCP\Config::setUserValue($this->api->getUserId(), 'contacts', 'last_address_book_deleted', time());
|
\OCP\Config::setUserValue($this->userId, 'contacts', 'last_address_book_deleted', time());
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,8 +12,7 @@ namespace OCA\Contacts\Controller;
|
|||||||
|
|
||||||
use OCA\Contacts\App,
|
use OCA\Contacts\App,
|
||||||
OCA\Contacts\JSONResponse,
|
OCA\Contacts\JSONResponse,
|
||||||
OCP\AppFramework\Controller,
|
OCP\AppFramework\Controller;
|
||||||
OCA\AppFramework\Core\API;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,7 +57,8 @@ class Dispatcher extends MainApp {
|
|||||||
parent::__construct($this->appName, $params);
|
parent::__construct($this->appName, $params);
|
||||||
$this->container = $this->getContainer();
|
$this->container = $this->getContainer();
|
||||||
$this->server = $this->container->getServer();
|
$this->server = $this->container->getServer();
|
||||||
$this->app = new App($this->container->query('API')->getUserId());
|
$userId = \OC::$server->getUserSession()->getUser()->getUID();
|
||||||
|
$this->app = new App($userId);
|
||||||
$this->registerServices();
|
$this->registerServices();
|
||||||
$this->container->registerMiddleware('HttpMiddleware');
|
$this->container->registerMiddleware('HttpMiddleware');
|
||||||
}
|
}
|
||||||
@ -76,8 +77,8 @@ class Dispatcher extends MainApp {
|
|||||||
});
|
});
|
||||||
$this->container->registerService('AddressBookController', function(IAppContainer $container) use($app, $appName) {
|
$this->container->registerService('AddressBookController', function(IAppContainer $container) use($app, $appName) {
|
||||||
$request = $container->query('Request');
|
$request = $container->query('Request');
|
||||||
$api = $container->query('API');
|
$userId = \OC::$server->getUserSession()->getUser()->getUID();
|
||||||
return new AddressBookController($appName, $request, $app, $api);
|
return new AddressBookController($appName, $request, $app, $userId);
|
||||||
});
|
});
|
||||||
$this->container->registerService('BackendController', function(IAppContainer $container) use($app, $appName) {
|
$this->container->registerService('BackendController', function(IAppContainer $container) use($app, $appName) {
|
||||||
$request = $container->query('Request');
|
$request = $container->query('Request');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user