public function display($cachable = false, $urlparams = false)
 {
     require_once JPATH_COMPONENT . '/helpers/jnotification.php';
     $view = JRequest::getCmd('view', 'inbox');
     $layout = JRequest::getCmd('layout', 'default');
     $id = JRequest::getInt('id');
     $model = $this->getModel('Domains', 'JNotificationModel');
     $numberofdomains = (int) count($model->getItems());
     $app = JFactory::getApplication();
     $flagNotification = $app->getUserState('notification.flag');
     $flagDomains = $app->getUserState('domains.flag');
     if ($view != 'domain') {
         // Load the submenu.
         JNotificationHelper::addSubmenu(JRequest::getCmd('view', 'inbox'));
     }
     // Check for edit form.
     if ($view == 'notification' && $layout == 'edit' && !$this->checkEditId('com_jnotification.edit.notification', $id) || $view == 'notification' && $layout == 'edit' && $numberofdomains == 0) {
         // Somehow the person just went to the form - we don't allow that.
         $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
         $this->setMessage($this->getError(), 'error');
         $this->setRedirect(JRoute::_('index.php?option=com_jnotification&view=inbox', false));
         return false;
     }
     // Check for edit form.
     if ($view == 'notification' && $layout == 'viewMessage') {
         $model1 = $model = $this->getModel('Inbox', 'JNotificationModel');
         $items = $model1->getItems();
         for ($i = 0; $i < count($items); $i++) {
             if ((int) $items[$i]->id == (int) JRequest::getInt('id')) {
                 $app->setUserState('com_jnotification.edit.notification.id', (int) JRequest::getInt('id'));
             }
         }
         // Somehow the person just went to the form - we don't allow that.
         if (!$this->checkEditId('com_jnotification.edit.notification', $id)) {
             $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
             $this->setMessage($this->getError(), 'error');
             $this->setRedirect(JRoute::_('index.php?option=com_jnotification&view=inbox', false));
             return false;
         }
     }
     if ($view == 'notification' && $layout == 'edit' && $flagNotification) {
         $flagNotification = $app->setUserState('notification.flag', false);
         //$this->releaseEditId('com_jnotification.edit.notification', $id);
         $this->setRedirect(JRoute::_('index.php?option=com_jnotification&view=domains&layout=default&id=' . (int) $postId . '&' . JSession::getFormToken() . '=1', false));
     }
     // Check for edit form.
     if ($view == 'domains' && $layout == 'default' && $flagDomains) {
         $app->setUserState('domains.flag', false);
     } else {
         if ($view == 'domains' && $layout == 'default' && !$flagDomains) {
             // Somehow the person just went to the form - we don't allow that.
             $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
             $this->setMessage($this->getError(), 'error');
             $this->setRedirect(JRoute::_('index.php?option=com_jnotification&view=inbox', false));
             return false;
         }
     }
     parent::display();
     return $this;
 }
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     require_once JPATH_COMPONENT . '/helpers/jnotification.php';
     $state = $this->get('State');
     $canDo = JNotificationHelper::getActions($state->get('filter.category_id'));
     $user = JFactory::getUser();
     JToolBarHelper::title(JText::_('COM_JNOTIFICATION_MANAGER_SEARCH_NOTIFICATIONS'), 'jnotification');
     if ($canDo->get('core.edit')) {
         JToolBarHelper::cancel('search.cancel');
     }
     JToolBarHelper::help('JHELP_COMPONENTS_JNOTIFICATION_LINKS_EDIT', true);
 }
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     require_once JPATH_COMPONENT . '/helpers/jnotification.php';
     $state = $this->get('State');
     $canDo = JNotificationHelper::getActions($state->get('filter.category_id'));
     $user = JFactory::getUser();
     if ($canDo->get('core.edit')) {
         JRequest::setVar('hidemainmenu', true);
         JToolBarHelper::title(JText::_('COM_JNOTIFICATION_SELECT_JDOMAIN'), 'jnotification');
         JToolBarHelper::apply('domains.save');
         JToolBarHelper::cancel('domains.cancel');
         JToolBarHelper::help('JHELP_COMPONENTS_JNOTIFICATION_LINKS_EDIT', true);
     }
 }
 /**
  * Add the page title and toolbar.
  *
  * @since	1.6
  */
 protected function addToolbar()
 {
     require_once JPATH_COMPONENT . '/helpers/jnotification.php';
     $state = $this->get('State');
     $canDo = JNotificationHelper::getActions($state->get('filter.category_id'));
     $user = JFactory::getUser();
     JToolBarHelper::title(JText::_('COM_JNOTIFICATION_MANAGER_INBOX_NOTIFICATIONS'), 'jnotification');
     if ($canDo->get('core.edit')) {
         if (count($this->domains) > 0) {
             JToolBarHelper::addNew('notification.add');
         }
         JToolBarHelper::editList('notification.edit');
         JToolBarHelper::custom('inbox.display', 'inbox', 'inbox', 'Inbox', false);
         JToolBarHelper::custom('outbox.display', 'outbox', '', 'Outbox', false);
         JToolBarHelper::custom('domain.add', 'domain16', '', 'Add Domain', false);
         JToolBarHelper::custom('search.display', 'search', '', 'Search', false);
     }
     JToolBarHelper::help('JHELP_COMPONENTS_JNOTIFICATION_LINKS_EDIT', true);
 }