. * */ namespace OCA\News\Controller; use \OCA\AppFramework\Controller\Controller; use \OCA\AppFramework\Core\API; use \OCA\AppFramework\Http\Request; use \OCA\News\Bl\ItemBl; class ItemController extends Controller { private $itemBl; public function __construct(API $api, Request $request, ItemBl $itemBl){ parent::__construct($api, $request); $this->itemBl = $itemBl; } /** * @IsAdminExemption * @IsSubAdminExemption * @Ajax */ public function items(){ // TBD } /** * @IsAdminExemption * @IsSubAdminExemption * @Ajax */ public function starred(){ $userId = $this->api->getUserId(); $starredCount = $this->itemBl->starredCount($userId); $params = array( 'starred' => $starredCount ); return $this->renderJSON($params); } private function setStarred($isStarred){ $userId = $this->api->getUserId(); $itemId = $this->params('itemId'); $this->itemBl->star($itemId, $isStarred, $userId); } /** * @IsAdminExemption * @IsSubAdminExemption * @Ajax */ public function star(){ $this->setStarred(true); } /** * @IsAdminExemption * @IsSubAdminExemption * @Ajax */ public function unstar(){ $this->setStarred(false); } private function setRead($isRead){ $userId = $this->api->getUserId(); $itemId = $this->params('itemId'); $this->itemBl->read($itemId, $isRead, $userId); } /** * @IsAdminExemption * @IsSubAdminExemption * @Ajax */ public function read(){ $this->setRead(true); } /** * @IsAdminExemption * @IsSubAdminExemption * @Ajax */ public function unread(){ $this->setRead(false); } /** * @IsAdminExemption * @IsSubAdminExemption * @Ajax */ public function readFeed(){ $userId = $this->api->getUserId(); $feedId = $this->params('feedId'); $this->itemBl->readFeed($feedId, $userId); } }