2017-01-24 06:47:14 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
|
|
*
|
|
|
|
* @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* 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 program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OC\Core\Controller;
|
|
|
|
|
|
|
|
use OC\Contacts\ContactsMenu\Manager;
|
|
|
|
use OCP\AppFramework\Controller;
|
2017-04-24 09:39:03 +00:00
|
|
|
use OCP\AppFramework\Http;
|
2017-01-24 06:47:14 +00:00
|
|
|
use OCP\AppFramework\Http\JSONResponse;
|
|
|
|
use OCP\IRequest;
|
2017-04-03 16:04:14 +00:00
|
|
|
use OCP\IUserSession;
|
2017-01-24 06:47:14 +00:00
|
|
|
|
|
|
|
class ContactsMenuController extends Controller {
|
|
|
|
|
|
|
|
/** @var Manager */
|
|
|
|
private $manager;
|
|
|
|
|
2017-04-03 16:04:14 +00:00
|
|
|
/** @var IUserSession */
|
|
|
|
private $userSession;
|
2017-01-24 06:47:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param IRequest $request
|
2017-04-03 16:04:14 +00:00
|
|
|
* @param IUserSession $userSession
|
2017-01-24 06:47:14 +00:00
|
|
|
* @param Manager $manager
|
|
|
|
*/
|
2017-04-03 16:04:14 +00:00
|
|
|
public function __construct(IRequest $request, IUserSession $userSession, Manager $manager) {
|
2017-01-24 06:47:14 +00:00
|
|
|
parent::__construct('core', $request);
|
2017-04-03 16:04:14 +00:00
|
|
|
$this->userSession = $userSession;
|
2017-01-24 06:47:14 +00:00
|
|
|
$this->manager = $manager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @NoAdminRequired
|
|
|
|
*
|
|
|
|
* @param string|null filter
|
|
|
|
* @return JSONResponse
|
|
|
|
*/
|
|
|
|
public function index($filter = null) {
|
2017-04-03 16:04:14 +00:00
|
|
|
return $this->manager->getEntries($this->userSession->getUser(), $filter);
|
2017-01-24 06:47:14 +00:00
|
|
|
}
|
|
|
|
|
2017-04-24 09:39:03 +00:00
|
|
|
/**
|
|
|
|
* @NoAdminRequired
|
|
|
|
*
|
|
|
|
* @param integer $shareType
|
|
|
|
* @param string $shareWith
|
|
|
|
* @return JSONResponse
|
|
|
|
*/
|
|
|
|
public function findOne($shareType, $shareWith) {
|
|
|
|
$contact = $this->manager->findOne($this->userSession->getUser(), $shareType, $shareWith);
|
|
|
|
|
|
|
|
if ($contact) {
|
|
|
|
return $contact;
|
|
|
|
} else {
|
|
|
|
return new JSONResponse([], Http::STATUS_NOT_FOUND);
|
|
|
|
}
|
|
|
|
}
|
2017-01-24 06:47:14 +00:00
|
|
|
}
|