. */ namespace SP\Controller; defined('APP_ROOT') || die(_('No es posible acceder directamente a este archivo')); use SP\Core\ActionsInterface; use SP\Core\Init; use SP\Core\SessionUtil; use SP\Core\Template; use SP\DataModel\NoticeData; use SP\Mgmt\Notices\Notice; use SP\Util\Checks; use SP\Util\Json; use SP\Util\Util; /** * Class NoticeShowController * * @package SP\Controller */ class NoticeShowController extends ControllerBase implements ActionsInterface, ItemControllerInterface { use RequestControllerTrait; /** * Máximo numero de acciones antes de agrupar */ const MAX_NUM_ACTIONS = 3; /** * @var int */ private $module = 0; /** * Constructor * * @param $template Template con instancia de plantilla */ public function __construct(Template $template = null) { parent::__construct($template); $this->init(); $this->view->assign('isDemo', Checks::demoIsEnabled()); $this->view->assign('sk', SessionUtil::getSessionKey(true)); $this->view->assign('itemId', $this->itemId); $this->view->assign('activeTab', $this->activeTab); $this->view->assign('actionId', $this->actionId); $this->view->assign('isView', false); $this->view->assign('showViewPass', true); } /** * Comprobar si la sesión está activa * * @throws \SP\Core\Exceptions\SPException */ protected function checkSession() { if (!Init::isLoggedIn()) { Util::logout(); } } /** * Realizar la acción solicitada en la la petición HTTP * * @param mixed $type Tipo de acción * @throws \SP\Core\Exceptions\SPException */ public function doAction($type = null) { try { switch ($this->actionId) { case self::ACTION_NOT_USER_VIEW: $this->view->assign('header', _('Ver Notificación')); $this->view->assign('isView', true); $this->getNotice(); break; default: $this->invalidAction(); } if (count($this->jsonResponse->getData()) === 0) { $this->jsonResponse->setData(['html' => $this->render()]); } } catch (\Exception $e) { $this->jsonResponse->setDescription($e->getMessage()); } Json::returnJson($this->jsonResponse); } /** * Obtener los datos para la ficha de usuario * * @throws \SP\Core\Exceptions\SPException * @throws \SP\Core\Exceptions\InvalidClassException */ protected function getNotice() { $this->module = self::ACTION_USR_USERS; $this->view->addTemplate('notices'); $this->view->assign('notice', $this->itemId ? Notice::getItem()->getById($this->itemId) : new NoticeData()); $this->view->assign('isDisabled', ($this->view->isDemo || $this->view->actionId === self::ACTION_NOT_USER_VIEW) ? 'disabled' : ''); $this->view->assign('isReadonly', $this->view->isDisabled ? 'readonly' : ''); $this->jsonResponse->setStatus(0); } }