Example #1
0
 /**
  * Execute the controller.
  *
  * @return  boolean  True if controller finished execution, false if the controller did not
  *                   finish execution. A controller might return false if some precondition for
  *                   the controller to run has not been satisfied.
  *
  * @since   12.1
  * @throws  LogicException
  * @throws  RuntimeException
  */
 public function execute()
 {
     $model = new MonitorModelIssue();
     $id = $this->input->getInt('id');
     $user = JFactory::getUser();
     // Get the params
     // TODO: may be removed when new MVC is implemented completely
     $this->app = JFactory::getApplication();
     if ($this->app instanceof JApplicationSite) {
         $params = $this->app->getParams();
     }
     if (!$model->canEdit($user, $id)) {
         if ($user->guest && isset($params) && $params->get('redirect_login', 1)) {
             $this->app->enqueueMessage(JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'), 'error');
             $this->app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode(JUri::getInstance()->toString()), '403'));
         } else {
             throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
         }
     }
     if ($id) {
         $model->setIssueId($id);
     }
     $model->loadForm();
     $view = new MonitorViewIssueHtml($model);
     $view->setLayout('edit');
     $view->loadForm();
     echo $view->render();
     return true;
 }
Example #2
0
 /**
  * MonitorRouter constructor.
  *
  * @param   JApplicationCms      $app           Application object that the router should use
  * @param   JMenu                $menu          Menu object that the router should use
  * @param   MonitorModelProject  $modelProject  Project model to use in the router.
  * @param   MonitorModelIssue    $modelIssue    Issue model to use in the router.
  *
  * @throws Exception
  */
 public function __construct($app = null, $menu = null, $modelProject = null, $modelIssue = null)
 {
     JLoader::register('MonitorModelAbstract', JPATH_ROOT . '/administrator/components/com_monitor/model/abstract.php');
     JLoader::register('MonitorModelProject', JPATH_ROOT . '/administrator/components/com_monitor/model/project.php');
     JLoader::register('MonitorModelIssue', JPATH_ROOT . '/administrator/components/com_monitor/model/issue.php');
     if ($app) {
         $this->app = $app;
     } else {
         $this->app = JFactory::getApplication();
     }
     if ($menu) {
         $this->menu = $menu;
     } else {
         $this->menu = $this->app->getMenu();
     }
     if ($modelProject) {
         $this->modelProject = $modelProject;
     } else {
         $this->modelProject = new MonitorModelProject($app, false);
     }
     if ($modelIssue) {
         $this->modelIssue = $modelIssue;
     } else {
         $this->modelIssue = new MonitorModelIssue($app, false);
     }
 }
Example #3
0
 public function onUserLoginFailure($response)
 {
     var_dump($response);
     if ($response['status'] === 4 && $response['error_message'] == "suspended") {
         $this->app->redirect(JRoute::_('account-suspended', false));
     }
     //die();
 }
Example #4
0
 /**
  * Method to remove root in global configuration.
  *
  * @return  boolean  True on success.
  *
  * @since   3.2
  */
 public function execute()
 {
     // Check for request forgeries.
     if (!JSession::checkToken('get')) {
         $this->app->enqueueMessage(JText::_('JINVALID_TOKEN'));
         $this->app->redirect('index.php');
     }
     // Check if the user is authorized to do this.
     if (!JFactory::getUser()->authorise('core.admin')) {
         $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
         $this->app->redirect('index.php');
     }
     // Initialise model.
     $model = new ConfigModelApplication();
     // Attempt to save the configuration and remove root.
     try {
         $model->removeroot();
     } catch (RuntimeException $e) {
         // Save failed, go back to the screen and display a notice.
         $this->app->enqueueMessage(JText::sprintf('JERROR_SAVE_FAILED', $e->getMessage()), 'error');
         $this->app->redirect(JRoute::_('index.php', false));
     }
     // Set the redirect based on the task.
     $this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'));
     $this->app->redirect(JRoute::_('index.php', false));
 }
Example #5
0
 /**
  * Listener for the `onAfterInitialise` event
  *
  * @return  void
  *
  * @since   3.5
  */
 public function onAfterInitialise()
 {
     if (!$this->app->isAdmin() || !$this->isAllowedUser()) {
         return;
     }
     if (!$this->isDebugEnabled() && !$this->isUpdateRequired()) {
         return;
     }
     JHtml::_('jquery.framework');
     JHtml::script('plg_system_stats/stats.js', false, true, false);
 }
Example #6
0
 /**
  * Constructor
  *
  * @param   array  $config  An array of configuration options (name, state, dbo, table_path, ignore_request).
  *
  * @since   3.3.4
  * @throws  Exception
  */
 public function __construct($config = array())
 {
     $this->app = JArrayHelper::getValue($config, 'app', JFactory::getApplication());
     $this->user = JArrayHelper::getValue($config, 'user', JFactory::getUser());
     $this->config = JArrayHelper::getValue($config, 'config', JFactory::getConfig());
     $this->session = JArrayHelper::getValue($config, 'session', JFactory::getSession());
     $this->date = JArrayHelper::getValue($config, 'date', JFactory::getDate());
     $this->lang = JArrayHelper::getValue($config, 'lang', JFactory::getLanguage());
     $this->package = $this->app->getUserState('com_fabrik.package', 'fabrik');
     parent::__construct($config);
 }
 /**
  * @param array $data
  * @return Renderer
  */
 public function createView(array $data = array())
 {
     $renderer = new Renderer($data);
     $name = $this->getName();
     // Add the default view path
     $renderer->addIncludePath(COMPONENT_ROOT . '/src/views/' . $this->getName());
     $template = $this->app->getTemplate();
     $option = $this->input->get('option');
     // Prepend the template path
     $renderer->addIncludePath(JPATH_ROOT . '/templates/' . $template . '/html/' . $option . '/' . $this->getName(), true);
     return $renderer;
 }
Example #8
0
 /**
  * Method to save global configuration.
  *
  * @return  boolean  True on success.
  *
  * @since   3.2
  */
 public function execute()
 {
     // Check for request forgeries.
     if (!JSession::checkToken()) {
         $this->app->enqueueMessage(JText::_('JINVALID_TOKEN'));
         $this->app->redirect('index.php');
     }
     // Check if the user is authorized to do this.
     if (!JFactory::getUser()->authorise('core.admin')) {
         $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
         $this->app->redirect('index.php');
     }
     // Set FTP credentials, if given.
     JClientHelper::setCredentialsFromRequest('ftp');
     $model = new ConfigModelConfig();
     $form = $model->getForm();
     $data = $this->input->post->get('jform', array(), 'array');
     // Validate the posted data.
     $return = $model->validate($form, $data);
     // Check for validation errors.
     if ($return === false) {
         /*
          * The validate method enqueued all messages for us, so we just need to redirect back.
          */
         // Save the data in the session.
         $this->app->setUserState('com_config.config.global.data', $data);
         // Redirect back to the edit screen.
         $this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.config', false));
     }
     // Attempt to save the configuration.
     $data = $return;
     // Access back-end com_config
     JLoader::registerPrefix('Config', JPATH_ADMINISTRATOR . '/components/com_config');
     $saveClass = new ConfigControllerApplicationSave();
     // Get a document object
     $document = JFactory::getDocument();
     // Set back-end required params
     $document->setType('json');
     // Execute back-end controller
     $return = $saveClass->execute();
     // Reset params back after requesting from service
     $document->setType('html');
     // Check the return value.
     if ($return === false) {
         /*
          * The save method enqueued all messages for us, so we just need to redirect back.
          */
         // Save the data in the session.
         $this->app->setUserState('com_config.config.global.data', $data);
         // Save failed, go back to the screen and display a notice.
         $this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.config', false));
     }
     // Redirect back to com_config display
     $this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'));
     $this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.config', false));
     return true;
 }
Example #9
0
 public function onUserLogout($options)
 {
     // No remember me for admin
     if ($this->app->isAdmin()) {
         return false;
     }
     $cookieName = JUserHelper::getShortHashedUserAgent();
     // Check for the cookie
     if ($this->app->input->cookie->get($cookieName)) {
         // Make sure authentication group is loaded to process onUserAfterLogout event
         JPluginHelper::importPlugin('authentication');
     }
 }
Example #10
0
 /**
  * Class constructor.
  *
  * @param   JApplicationCms  $app   Application-object that the router should use
  * @param   JMenu            $menu  Menu-object that the router should use
  *
  * @since   3.4
  */
 public function __construct($app = null, $menu = null)
 {
     if ($app) {
         $this->app = $app;
     } else {
         $this->app = JFactory::getApplication('site');
     }
     if ($menu) {
         $this->menu = $menu;
     } else {
         $this->menu = $this->app->getMenu();
     }
 }
Example #11
0
 /**
  * Listener for onAfterInitialise event
  *
  * @return  void
  */
 public function onAfterInitialise()
 {
     // Only for site
     if (!$this->app->isSite()) {
         return;
     }
     // Register listeners for JHtml helpers
     if (!JHtml::isRegistered('bootstrap.loadCss')) {
         JHtml::register('bootstrap.loadCss', 'PlgSystemBootstrap3::loadCss');
     }
     if (!JHtml::isRegistered('bootstrap.carousel')) {
         JHtml::register('bootstrap.carousel', 'PlgSystemBootstrap3::carousel');
     }
 }
Example #12
0
 /**
  * Execute the controller.
  *
  * @return  boolean  True if controller finished execution, false if the controller did not
  *                   finish execution. A controller might return false if some precondition for
  *                   the controller to run has not been satisfied.
  *
  * @since   12.1
  * @throws  LogicException
  * @throws  RuntimeException
  */
 public function execute()
 {
     $id = $this->input->getInt('id');
     $user = JFactory::getUser();
     if ($user->guest) {
         $this->app->enqueueMessage(JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'), 'error');
     } else {
         $model = new MonitorModelSubscription();
         if ($model->isSubscriberIssue($id, $user->id)) {
             $model->unsubscribeIssue($id, $user->id);
             $this->app->enqueueMessage(JText::_('COM_MONITOR_SUBSCRIPTION_ISSUE_UNSUBSCRIBED'), 'message');
         }
     }
     $this->app->redirect(JRoute::_('index.php?option=com_monitor&view=issue&id=' . $id, false));
 }
Example #13
0
 /**
  * Re-route Gantry templates to Gantry Administration component.
  */
 private function onAfterRouteAdmin()
 {
     $input = $this->app->input;
     $option = $input->getCmd('option');
     $task = $input->getCmd('task');
     if (in_array($option, ['com_templates', 'com_advancedtemplates']) && $task && strpos($task, 'style') === 0) {
         // Get all ids.
         $cid = $input->post->get('cid', (array) $input->getInt('id'), 'array');
         if ($cid) {
             $styles = $this->getStyles();
             $selected = array_intersect(array_keys($styles), $cid);
             // If no Gantry templates were selected, just let com_templates deal with the request.
             if (!$selected) {
                 return;
             }
             // Special handling for tasks coming from com_template.
             if ($task == 'style.edit') {
                 $id = (int) array_shift($cid);
                 if (isset($styles[$id])) {
                     $token = JSession::getFormToken();
                     $this->app->redirect("index.php?option=com_gantry5&view=configurations/{$id}/styles&style={$id}&{$token}=1");
                 }
             }
         }
     }
 }
Example #14
0
 /**
  * This method should handle any logout logic and report back to the subject
  *
  * @param   array  $user     Holds the user data.
  * @param   array  $options  Array holding options (client, ...).
  *
  * @return  object  True on success
  *
  * @since   1.5
  */
 public function onUserLogout($user, $options = array())
 {
     $my = JFactory::getUser();
     $session = JFactory::getSession();
     // Make sure we're a valid user first
     if ($user['id'] == 0 && !$my->get('tmp_user')) {
         return true;
     }
     // Check to see if we're deleting the current session
     if ($my->get('id') == $user['id'] && $options['clientid'] == $this->app->getClientId()) {
         // Hit the user last visit field
         $my->setLastVisit();
         // Destroy the php session for this user
         $session->destroy();
     }
     // Enable / Disable Forcing logout all users with same userid
     $forceLogout = $this->params->get('forceLogout', 1);
     if ($forceLogout) {
         $query = $this->db->getQuery(true)->delete($this->db->quoteName('#__session'))->where($this->db->quoteName('userid') . ' = ' . (int) $user['id'])->where($this->db->quoteName('client_id') . ' = ' . (int) $options['clientid']);
         try {
             $this->db->setQuery($query)->execute();
         } catch (RuntimeException $e) {
             return false;
         }
     }
     return true;
 }
 /**
  * Class constructor.
  *
  * @since   3.1
  */
 public function __construct()
 {
     // Run the parent constructor
     parent::__construct();
     // Load and set the dispatcher
     $this->loadDispatcher();
     // Enable sessions by default.
     if (is_null($this->config->get('session'))) {
         $this->config->set('session', true);
     }
     // Set the session default name.
     if (is_null($this->config->get('session_name'))) {
         $this->config->set('session_name', 'installation');
     }
     // Create the session if a session name is passed.
     if ($this->config->get('session') !== false) {
         $this->loadSession();
         // Register the session with JFactory
         JFactory::$session = $this->getSession();
     }
     // Store the debug value to config based on the JDEBUG flag
     $this->config->set('debug', JDEBUG);
     // Register the config to JFactory
     JFactory::$config = $this->config;
     // Register the application to JFactory
     JFactory::$application = $this;
     // Register the application name
     $this->_name = 'installation';
     // Register the client ID
     $this->_clientId = 2;
     // Set the root in the URI one level up.
     $parts = explode('/', JUri::base(true));
     array_pop($parts);
     JUri::root(null, implode('/', $parts));
 }
 /**
  * Listener for the `onAfterInitialise` event
  *
  * @return  void
  *
  * @since   3.5
  */
 public function onAfterInitialise()
 {
     if (!$this->app->isAdmin() || !$this->isAllowedUser()) {
         return;
     }
     if (!$this->isDebugEnabled() && !$this->isUpdateRequired()) {
         return;
     }
     if (JUri::getInstance()->getVar("tmpl") === "component") {
         return;
     }
     // Load plugin language files only when needed (ex: they are not needed in site client).
     $this->loadLanguage();
     JHtml::_('jquery.framework');
     JHtml::script('plg_system_stats/stats.js', false, true, false);
 }
 /**
  * This method should handle any logout logic and report back to the subject
  *
  * @param   array  $user     Holds the user data.
  * @param   array  $options  Array holding options (client, ...).
  *
  * @return  object  True on success
  *
  * @since   1.5
  */
 public function onUserLogout($user, $options = array())
 {
     $my = JFactory::getUser();
     $session = JFactory::getSession();
     // Make sure we're a valid user first
     if ($user['id'] == 0 && !$my->get('tmp_user')) {
         return true;
     }
     // Check to see if we're deleting the current session
     if ($my->get('id') == $user['id'] && $options['clientid'] == $this->app->getClientId()) {
         // Hit the user last visit field
         $my->setLastVisit();
         // Destroy the php session for this user
         $session->destroy();
     }
     // Enable / Disable Forcing logout all users with same userid
     $forceLogout = $this->params->get('forceLogout', 1);
     if ($forceLogout) {
         $query = $this->db->getQuery(true)->delete($this->db->quoteName('#__session'))->where($this->db->quoteName('userid') . ' = ' . (int) $user['id'])->where($this->db->quoteName('client_id') . ' = ' . (int) $options['clientid']);
         try {
             $this->db->setQuery($query)->execute();
         } catch (RuntimeException $e) {
             return false;
         }
     }
     // Delete "user state" cookie used for reverse caching proxies like Varnish, Nginx etc.
     $conf = JFactory::getConfig();
     $cookie_domain = $conf->get('cookie_domain', '');
     $cookie_path = $conf->get('cookie_path', '/');
     if ($this->app->isSite()) {
         $this->app->input->cookie->set("joomla_user_state", "", time() - 86400, $cookie_path, $cookie_domain, 0);
     }
     return true;
 }
 /**
  * Remember me method to run onAfterInitialise
  *
  * @return  boolean
  *
  * @since   1.5
  * @throws  InvalidArgumentException
  */
 public function onAfterInitialise()
 {
     // No remember me for admin
     if ($this->app->isAdmin()) {
         return false;
     }
     $user = JFactory::getUser();
     $this->app->rememberCookieLifetime = $this->lifetime;
     $this->app->rememberCookieSecure = $this->secure;
     $this->app->rememberCookieLength = $this->length;
     // Check for a cookie
     if ($user->get('guest') == 1) {
         // Create the cookie name and data
         $rememberArray = JUserHelper::getRememberCookieData();
         if ($rememberArray !== false) {
             if (count($rememberArray) != 3) {
                 // Destroy the cookie in the browser.
                 $this->app->input->cookie->set(end($rememberArray), false, time() - 42000, $this->app->get('cookie_path'), $this->app->get('cookie_domain'));
                 JLog::add('Invalid cookie detected.', JLog::WARNING, 'error');
                 return false;
             }
             list($privateKey, $series, $uastring) = $rememberArray;
             if (!JUserHelper::clearExpiredTokens($this)) {
                 JLog::add('Error in deleting expired cookie tokens.', JLog::WARNING, 'error');
             }
             // Find the matching record if it exists
             $query = $this->db->getQuery(true)->select($this->db->quoteName(array('user_id', 'token', 'series', 'time', 'invalid')))->from($this->db->quoteName('#__user_keys'))->where($this->db->quoteName('series') . ' = ' . $this->db->quote(base64_encode($series)))->where($this->db->quoteName('uastring') . ' = ' . $this->db->quote($uastring))->order($this->db->quoteName('time') . ' DESC');
             $results = $this->db->setQuery($query)->loadObjectList();
             $countResults = count($results);
             // We have a user but a cookie that is not in the database, or it is invalid. This is a possible attack, so invalidate everything.
             if (($countResults === 0 || $results[0]->invalid != 0) && !empty($results[0]->user_id)) {
                 JUserHelper::invalidateCookie($results[0]->user_id, $uastring);
                 JLog::add(JText::sprintf('PLG_SYSTEM_REMEMBER_ERROR_LOG_INVALIDATED_COOKIES', $user->username), JLog::WARNING, 'security');
                 // Possibly e-mail user and admin here.
                 return false;
             }
             // We have a user with one cookie with a valid series and a corresponding record in the database.
             if ($countResults === 1) {
                 if (substr($results[0]->token, 0, 4) === '$2y$') {
                     if (JCrypt::hasStrongPasswordSupport()) {
                         $match = password_verify($privateKey, $results[0]->token);
                     }
                 } else {
                     if (JCrypt::timingSafeCompare($results[0]->token, $privateKey)) {
                         $match = true;
                     }
                 }
                 if (empty($match)) {
                     JUserHelper::invalidateCookie($results[0]->user_id, $uastring);
                     JLog::add(JText::sprintf('PLG_SYSTEM_REMEMBER_ERROR_LOG_LOGIN_FAILED', $user->username), JLog::WARNING, 'security');
                     return false;
                 }
                 // Set up the credentials array to pass to onUserAuthenticate
                 $credentials = array('username' => $results[0]->user_id);
                 return $this->app->login($credentials, array('silent' => true, 'lifetime' => $this->lifetime, 'secure' => $this->secure, 'length' => $this->length));
             }
         }
     }
     return false;
 }
Example #19
0
 /**
  * Converting the site URL to fit to the HTTP request
  */
 public function onAfterRoute()
 {
     $params = JComponentHelper::getParams('com_userxtd');
     if ($params->get('CoreRegistration_Redirect', 0)) {
         $option = $this->input->get('option');
         $view = $this->input->get('view');
         $layout = $this->input->get('layout', 'default');
         $id = $this->input->get('id', JFactory::getUser()->id);
         if ($option == 'com_users') {
             $this->initComponent();
             if ($view == 'registration' && $layout == 'default') {
                 $this->app->redirect(Route::_('register'));
             }
             if ($view == 'profile' && $layout == 'default') {
                 if ($id) {
                     $this->app->redirect(Route::_('user_id', array('id' => $id)));
                 } else {
                     $this->app->redirect(Route::_('user'));
                 }
             }
             if ($view == 'profile' && $layout == 'edit') {
                 $this->app->redirect(Route::_('user_layout', array('task' => 'user.edit.edit', 'layout' => 'edit', 'id' => $id)));
             }
         }
     }
 }
 /**
  * Execute and display a template script.
  *
  * @param   string $tpl The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a Error object.
  *
  * @since   3.6
  */
 public function display($tpl = null)
 {
     // Do not allow cache
     $this->app->allowCache(false);
     $foldersModel = $this->getFoldersModel();
     $currentFolder = $foldersModel->getCurrentFolder();
     $folders = $foldersModel->getFolders();
     $filesModel = $this->getFilesModel();
     $files = $filesModel->setFileFilter($this->getFileFilter())->getFiles();
     $state = $this->get('state');
     $this->currentFolder = $currentFolder;
     $this->files = $files;
     $this->folders = $folders;
     $this->state = $state;
     return parent::display($tpl);
 }
Example #21
0
 /**
  * This is where we delete any authentication cookie when a user logs out
  *
  * @param   array  $options  Array holding options (length, timeToExpiration)
  *
  * @return  boolean  True on success
  *
  * @since   3.2
  */
 public function onUserAfterLogout($options)
 {
     // No remember me for admin
     if ($this->app->isAdmin()) {
         return false;
     }
     $cookieName = 'joomla_remember_me_' . JUserHelper::getShortHashedUserAgent();
     $cookieValue = $this->app->input->cookie->get($cookieName);
     // There are no cookies to delete.
     if (!$cookieValue) {
         return true;
     }
     $cookieArray = explode('.', $cookieValue);
     // Filter series since we're going to use it in the query
     $filter = new JFilterInput();
     $series = $filter->clean($cookieArray[1], 'ALNUM');
     // Remove the record from the database
     $query = $this->db->getQuery(true)->delete('#__user_keys')->where($this->db->quoteName('series') . ' = ' . $this->db->quote($series));
     try {
         $this->db->setQuery($query)->execute();
     } catch (RuntimeException $e) {
         // We aren't concerned with errors from this query, carry on
     }
     // Destroy the cookie
     $this->app->input->cookie->set($cookieName, false, time() - 42000, $this->app->get('cookie_path', '/'), $this->app->get('cookie_domain'));
     return true;
 }
Example #22
0
 /**
  * method to run after an install/update/uninstall method
  *
  * @return void
  */
 function postflight($type, $parent)
 {
     // $parent is the class calling this method
     // $type is the type of change (install, update or discover_install)
     $siteApp = JApplicationCms::getInstance('site');
     $menu = $siteApp->getMenu()->getItems('link', 'index.php?option=com_alfcontact&view=alfcontact');
     $firstmenu = array_shift($menu);
     if ($type == 'update' && !$firstmenu->params->exists('header')) {
         //upgrade v3.1.1: moved parameters from component to menu-item
         echo 'The Title, Header and Footer parameters have now been moved to the menu-item settings!';
         //check for component parameters
         $c_params = JComponentHelper::getParams('com_alfcontact');
         // get the 'old' values from the component settings
         $temp_title = $c_params->get('title');
         $temp_header = $c_params->get('header');
         $temp_footer = $c_params->get('footer');
         //clear the 'old' settings in the component settings
         $c_params->set('title', '');
         $c_params->set('header', '');
         $c_params->set('footer', '');
         //Copy the parameteres to the menu-item settings
         $db = JFactory::getDBO();
         $name = 'com_alfcontact';
         $query = "UPDATE #__extensions SET params =" . $db->quote((string) $c_params) . "WHERE name =" . $db->quote((string) $name);
         $db->setQuery($query);
         foreach ($menu as $val) {
             $val->params->set('title', $temp_title);
             $val->params->set('header', $temp_header);
             $val->params->set('footer', $temp_footer);
             $query = "UPDATE #__menu SET params = " . $db->quote((string) $val->params) . " WHERE id = " . $db->quote((string) $val->id);
             $db->setQuery($query);
         }
     }
     echo '<p>' . JText::_('COM_ALFCONTACT_POSTFLIGHT_' . $type . '_TEXT') . '</p>';
 }
Example #23
0
 /**
  * Dispatch the application.
  *
  * @param JApplicationCms $app
  *
  * @return string An rendered view from executing the controller.
  */
 public function execute()
 {
     $view = $this->app->input->get('view');
     if ($view === null) {
         throw new ControllerResolutionException('No view was specified.');
     }
     $fqcn = __NAMESPACE__ . '\\Controllers\\' . ($this->app->isAdmin() ? 'Admin\\' : '') . ucfirst($view) . 'Controller';
     if (!class_exists($fqcn)) {
         throw new ControllerResolutionException(sprintf('Controller for view (%s) cannot be found.', $view));
     }
     /** @var \Framework\Controllers\AbstractBaseController $controller */
     $controller = $this->container->buildObject($fqcn);
     $controller->setContainer($this->container);
     $controller->createDefaultModel();
     $controller->createDefaultView();
     return $controller->execute();
 }
Example #24
0
 /**
  * System render.
  *
  * @return void
  */
 public function onAfterRender()
 {
     $this->getFunction('includes.insertHeader');
     $this->getFunction('includes.setStyle');
     if ($this->params->get('cacheManagerEnabled', 0) && $this->app->isSite()) {
         $this->getFunction('system.cacheManager');
     }
     @(include $this->includeEvent(__FUNCTION__));
 }
Example #25
0
 /**
  * Execute the controller.
  *
  * @return  boolean  True if controller finished execution, false if the controller did not
  *                   finish execution. A controller might return false if some precondition for
  *                   the controller to run has not been satisfied.
  *
  * @since   12.1
  * @throws  LogicException
  * @throws  RuntimeException
  */
 public function execute()
 {
     $id = $this->input->getInt('id');
     $user = JFactory::getUser();
     if ($user->guest) {
         $this->app->enqueueMessage(JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'), 'error');
     } else {
         $model = new MonitorModelSubscription();
         if (!$model->isSubscriberProject($id, $user->id)) {
             $model->subscribeProject($id, $user->id);
             $this->app->enqueueMessage(JText::_('COM_MONITOR_SUBSCRIPTION_PROJECT'), 'message');
         }
     }
     $return = base64_decode($this->app->input->get('return', '', 'BASE64'));
     if (!JUri::isInternal($return)) {
         $return = 'index.php?option=com_monitor&view=project&id=' . $id;
     }
     $this->app->redirect(JRoute::_($return, false));
 }
Example #26
0
 /**
  * Get menu item by id
  *
  * @param   string  $language  The language code.
  *
  * @return  mixed  The item object or null when not found for given language
  *
  * @since   1.6
  */
 public function getDefault($language = '*')
 {
     if (array_key_exists($language, $this->_default) && $this->app->isSite() && $this->app->getLanguageFilter()) {
         return $this->_items[$this->_default[$language]];
     }
     if (array_key_exists('*', $this->_default)) {
         return $this->_items[$this->_default['*']];
     }
     return null;
 }
 /**
  * Execute the controller.
  *
  * @return  mixed  A rendered view or true
  *
  * @since   3.2
  */
 public function execute()
 {
     // Get the document object.
     $document = JFactory::getDocument();
     $componentFolder = $this->input->getWord('option', 'com_config');
     if ($this->app->isAdmin()) {
         $viewName = $this->input->getWord('view', 'application');
     } else {
         $viewName = $this->input->getWord('view', 'config');
     }
     $viewFormat = $document->getType();
     $layoutName = $this->input->getWord('layout', 'default');
     // Register the layout paths for the view
     $paths = new SplPriorityQueue();
     if ($this->app->isAdmin()) {
         $paths->insert(JPATH_ADMINISTRATOR . '/components/' . $componentFolder . '/view/' . $viewName . '/tmpl', 1);
     } else {
         $paths->insert(JPATH_BASE . '/components/' . $componentFolder . '/view/' . $viewName . '/tmpl', 1);
     }
     $viewClass = $this->prefix . 'View' . ucfirst($viewName) . ucfirst($viewFormat);
     $modelClass = $this->prefix . 'Model' . ucfirst($viewName);
     if (class_exists($viewClass)) {
         $model = new $modelClass();
         $component = $model->getState()->get('component.option');
         // Access check.
         if (!JFactory::getUser()->authorise('core.admin', $component) && !JFactory::getUser()->authorise('core.options', $component)) {
             $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error');
             return;
         }
         $view = new $viewClass($model, $paths);
         $view->setLayout($layoutName);
         // Push document object into the view.
         $view->document = $document;
         // Reply for service requests
         if ($viewFormat == 'json') {
             return $view->render();
         }
         // Render view.
         echo $view->render();
     }
     return true;
 }
Example #28
0
 /**
  * Execute the controller.
  *
  * @return  boolean  True if controller finished execution, false if the controller did not
  *                   finish execution. A controller might return false if some precondition for
  *                   the controller to run has not been satisfied.
  *
  * @since   12.1
  * @throws  LogicException
  * @throws  RuntimeException
  */
 public function execute()
 {
     if (!JFactory::getUser()->authorise('attachment.delete', 'com_monitor')) {
         throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
     }
     $app = JFactory::getApplication();
     $model = new MonitorModelAttachments($app);
     $id = $app->input->getInt('id');
     if (!$id) {
         throw new Exception(JText::_('JERROR_NO_ITEMS_SELECTED'), 404);
     }
     $model->delete(array($id));
     $app->enqueueMessage(JText::_('COM_MONITOR_ATTACHMENT_DELETED'));
     $return = base64_decode($this->app->input->get('return', '', 'BASE64'));
     if (!JUri::isInternal($return)) {
         $return = 'index.php?option=com_monitor&view=projects';
     }
     $this->app->redirect(JRoute::_($return, false));
     return true;
 }
Example #29
0
 /**
  * onAfterRender
  *
  * @return  void
  */
 public function onAfterRender()
 {
     $this->call(array('Article\\CodeInsert', 'insertHeader'));
     $this->call(array('Asset\\Style', 'register'));
     if ($this->app->get('caching', 0)) {
         $this->call(array('System\\Cache', 'cacheEzsetData'), $this);
     }
     if ($this->params->get('cacheManagerEnabled', 0) && $this->app->isSite()) {
         $this->call(array('System\\Cache', 'manage'));
     }
     @(include $this->includeEvent(__FUNCTION__));
 }
Example #30
0
 /**
  * Get base menu item.
  *
  * If itemid is not specified or does not exist, return active menu item.
  * If there is no active menu item, fall back to home page for the current language.
  * If there is no home page, return null.
  *
  * @param   int  $itemid
  *
  * @return  object|null
  */
 protected function calcBase($itemid = null)
 {
     $menu = $this->app->getMenu();
     // Get base menu item.
     $base = $itemid ? $menu->getItem($itemid) : null;
     if (!$base) {
         // Use active menu item or fall back to default menu item.
         $base = $this->active ?: $this->default;
     }
     // Return base menu item.
     return $base;
 }