当前位置: 首页>>代码示例>>PHP>>正文


PHP JApplicationCms::setUserState方法代码示例

本文整理汇总了PHP中JApplicationCms::setUserState方法的典型用法代码示例。如果您正苦于以下问题:PHP JApplicationCms::setUserState方法的具体用法?PHP JApplicationCms::setUserState怎么用?PHP JApplicationCms::setUserState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JApplicationCms的用法示例。


在下文中一共展示了JApplicationCms::setUserState方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * 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;
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:64,代码来源:save.php

示例2: onUserLogin

 /**
  * Method to handle any login logic and report back to the subject.
  *
  * @param   array  $user     Holds the user data.
  * @param   array  $options  Array holding options (remember, autoregister, group).
  *
  * @return  boolean  True on success.
  *
  * @since   1.5
  */
 public function onUserLogin($user, $options = array())
 {
     $menu = $this->app->getMenu();
     if ($this->app->isSite() && $this->params->get('automatic_change', 1)) {
         $assoc = JLanguageAssociations::isEnabled();
         $lang_code = $user['language'];
         if (empty($lang_code)) {
             $lang_code = $this->default_lang;
         }
         // Get a 1-dimensional array of published language codes
         $query = $this->db->getQuery(true)->select($this->db->quoteName('a.lang_code'))->from($this->db->quoteName('#__languages', 'a'))->where($this->db->quoteName('published') . ' = 1');
         $this->db->setQuery($query);
         $lang_codes = $this->db->loadColumn();
         // The user language has been deleted/disabled or the related content language does not exist/has been unpublished
         // or the related home page does not exist/has been unpublished
         if (!array_key_exists($lang_code, MultilangstatusHelper::getSitelangs()) || !in_array($lang_code, $lang_codes) || !array_key_exists($lang_code, MultilangstatusHelper::getHomepages())) {
             $lang_code = $this->current_lang;
         }
         // Try to get association from the current active menu item
         $active = $menu->getActive();
         $foundAssociation = false;
         if ($active) {
             if ($assoc) {
                 $associations = MenusHelper::getAssociations($active->id);
             }
             if (isset($associations[$lang_code]) && $menu->getItem($associations[$lang_code])) {
                 $associationItemid = $associations[$lang_code];
                 $this->app->setUserState('users.login.form.return', 'index.php?Itemid=' . $associationItemid);
                 $foundAssociation = true;
             } elseif ($active->home) {
                 // We are on a Home page, we redirect to the user site language home page
                 $item = $menu->getDefault($lang_code);
                 if ($item && $item->language != $active->language && $item->language != '*') {
                     $this->app->setUserState('users.login.form.return', 'index.php?Itemid=' . $item->id);
                     $foundAssociation = true;
                 }
             }
         }
         if ($foundAssociation && $lang_code != $this->current_lang) {
             // Change language.
             $this->current_lang = $lang_code;
             // Create a cookie.
             $this->setLanguageCookie($lang_code);
             // Change the language code.
             JFactory::getLanguage()->setLanguage($lang_code);
         }
     }
 }
开发者ID:holodyn,项目名称:joomla-cms,代码行数:58,代码来源:languagefilter.php

示例3: onUserLogin

 /**
  * Method to handle any login logic and report back to the subject.
  *
  * @param   array  $user     Holds the user data.
  * @param   array  $options  Array holding options (remember, autoregister, group).
  *
  * @return  boolean  True on success.
  *
  * @since   1.5
  */
 public function onUserLogin($user, $options = array())
 {
     $menu = $this->app->getMenu();
     if ($this->app->isSite() && $this->params->get('automatic_change', 1)) {
         $assoc = JLanguageAssociations::isEnabled();
         $lang_code = $user['language'];
         // If no language is specified for this user, we set it to the site default language
         if (empty($lang_code)) {
             $lang_code = $this->default_lang;
         }
         jimport('joomla.filesystem.folder');
         // The language has been deleted/disabled or the related content language does not exist/has been unpublished
         // or the related home page does not exist/has been unpublished
         if (!array_key_exists($lang_code, $this->lang_codes) || !array_key_exists($lang_code, JLanguageMultilang::getSiteHomePages()) || !JFolder::exists(JPATH_SITE . '/language/' . $lang_code)) {
             $lang_code = $this->current_lang;
         }
         // Try to get association from the current active menu item
         $active = $menu->getActive();
         $foundAssociation = false;
         if ($active) {
             if ($assoc) {
                 $associations = MenusHelper::getAssociations($active->id);
             }
             if (isset($associations[$lang_code]) && $menu->getItem($associations[$lang_code])) {
                 $associationItemid = $associations[$lang_code];
                 $this->app->setUserState('users.login.form.return', 'index.php?Itemid=' . $associationItemid);
                 $foundAssociation = true;
             } elseif ($active->home) {
                 // We are on a Home page, we redirect to the user site language home page
                 $item = $menu->getDefault($lang_code);
                 if ($item && $item->language != $active->language && $item->language != '*') {
                     $this->app->setUserState('users.login.form.return', 'index.php?Itemid=' . $item->id);
                     $foundAssociation = true;
                 }
             }
         }
         if ($foundAssociation && $lang_code != $this->current_lang) {
             // Change language.
             $this->current_lang = $lang_code;
             // Create a cookie.
             $this->setLanguageCookie($lang_code);
             // Change the language code.
             JFactory::getLanguage()->setLanguage($lang_code);
         }
     }
 }
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:56,代码来源:languagefilter.php

示例4: validateFiles

 /**
  * Validates uploaded files from a form.
  *
  * @param   array                    $files             Array containing the files to validate.
  * @param   array                    $data              Other data from the form.
  * @param   MonitorModelAttachments  $modelAttachments  Model to use.
  *
  * @return  array|null  A filtered array if all files are valid, null if not.
  */
 public function validateFiles($files, $data, $modelAttachments = null)
 {
     if (!$modelAttachments) {
         $modelAttachments = new MonitorModelAttachments($this->app);
     }
     foreach ($files as $i => $file) {
         if ($file[0]['error'] === UPLOAD_ERR_NO_FILE) {
             unset($files[$i]);
         }
     }
     if (!$modelAttachments->canUpload($files)) {
         // Store data for redirects.
         if (!$this->form) {
             $this->loadForm();
         }
         $this->app->setUserState($this->form->getName() . '.data', $data);
         return null;
     }
     return $files;
 }
开发者ID:Harmageddon,项目名称:com_monitor,代码行数:29,代码来源:abstract.php

示例5: onUserLogin

 /**
  * Method to handle any login logic and report back to the subject.
  *
  * @param   array  $user     Holds the user data.
  * @param   array  $options  Array holding options (remember, autoregister, group).
  *
  * @return  boolean  True on success.
  *
  * @since   1.5
  */
 public function onUserLogin($user, $options = array())
 {
     $menu = $this->app->getMenu();
     if ($this->app->isSite() && $this->params->get('automatic_change', 1)) {
         // Load associations.
         $assoc = JLanguageAssociations::isEnabled();
         if ($assoc) {
             $active = $menu->getActive();
             if ($active) {
                 $associations = MenusHelper::getAssociations($active->id);
             }
         }
         $lang_code = $user['language'];
         if (empty($lang_code)) {
             $lang_code = $this->default_lang;
         }
         if ($lang_code != $this->default_lang) {
             // Change language.
             $this->default_lang = $lang_code;
             // Create a cookie.
             $cookie_domain = $this->app->get('cookie_domain', '');
             $cookie_path = $this->app->get('cookie_path', '/');
             setcookie(JApplicationHelper::getHash('language'), $lang_code, $this->getLangCookieTime(), $cookie_path, $cookie_domain);
             // Change the language code.
             JFactory::getLanguage()->setLanguage($lang_code);
             // Change the redirect (language has changed).
             if (isset($associations[$lang_code]) && $menu->getItem($associations[$lang_code])) {
                 $itemid = $associations[$lang_code];
                 $this->app->setUserState('users.login.form.return', 'index.php?&Itemid=' . $itemid);
             } else {
                 JLoader::register('MultilangstatusHelper', JPATH_ADMINISTRATOR . '/components/com_languages/helpers/multilangstatus.php');
                 $homes = MultilangstatusHelper::getHomepages();
                 $itemid = isset($homes[$lang_code]) ? $homes[$lang_code]->id : $homes['*']->id;
                 $this->app->setUserState('users.login.form.return', 'index.php?&Itemid=' . $itemid);
             }
         }
     }
 }
开发者ID:educakanchay,项目名称:kanchay,代码行数:48,代码来源:languagefilter.php

示例6: execute

 /**
  * Method to save global configuration.
  *
  * @return  mixed  Calls $app->redirect() for all cases except JSON
  *
  * @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 ConfigModelApplication();
     $data = $this->input->post->get('jform', array(), 'array');
     // Complete data array if needed
     $oldData = $model->getData();
     $data = array_replace($oldData, $data);
     // Get request type
     $saveFormat = JFactory::getDocument()->getType();
     // Handle service requests
     if ($saveFormat == 'json') {
         return $model->save($data);
     }
     // Must load after serving service-requests
     $form = $model->getForm();
     // 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.application', false));
     }
     // Attempt to save the configuration.
     $data = $return;
     $return = $model->save($data);
     // 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.application', false));
     }
     // Set the success message.
     $this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'));
     // Set the redirect based on the task.
     switch ($this->options[3]) {
         case 'apply':
             $this->app->redirect(JRoute::_('index.php?option=com_config', false));
             break;
         case 'save':
         default:
             $this->app->redirect(JRoute::_('index.php', false));
             break;
     }
 }
开发者ID:JonatanLiecheski,项目名称:MeditecJoomla,代码行数:72,代码来源:save.php

示例7: execute

 /**
  * Method to save global configuration.
  *
  * @return  mixed  Calls $app->redirect()
  *
  * @since   3.2
  */
 public function execute()
 {
     // Check for request forgeries.
     if (!JSession::checkToken()) {
         $this->app->enqueueMessage(JText::_('JINVALID_TOKEN'));
         $this->app->redirect('index.php');
     }
     // Set FTP credentials, if given.
     JClientHelper::setCredentialsFromRequest('ftp');
     $model = new ConfigModelComponent();
     $form = $model->getForm();
     $data = $this->input->get('jform', array(), 'array');
     $id = $this->input->getInt('id');
     $option = $this->input->get('component');
     // Check if the user is authorized to do this.
     if (!JFactory::getUser()->authorise('core.admin', $option)) {
         $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
         $this->app->redirect('index.php');
     }
     $returnUri = $this->input->post->get('return', null, 'base64');
     $redirect = '';
     if (!empty($returnUri)) {
         $redirect = '&return=' . urlencode($returnUri);
     }
     // 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&view=component&component=' . $option . $redirect, false));
     }
     // Attempt to save the configuration.
     $data = array('params' => $return, 'id' => $id, 'option' => $option);
     try {
         $model->save($data);
     } catch (RuntimeException $e) {
         // 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->enqueueMessage(JText::sprintf('JERROR_SAVE_FAILED', $e->getMessage()), 'error');
         $this->app->redirect(JRoute::_('index.php?option=com_config&view=component&component=' . $option . $redirect, false));
     }
     // Set the redirect based on the task.
     switch ($this->options[3]) {
         case 'apply':
             $this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'));
             $this->app->redirect(JRoute::_('index.php?option=com_config&view=component&component=' . $option . $redirect, false));
             break;
         case 'save':
         default:
             $redirect = 'index.php?option=' . $option;
             if (!empty($returnUri)) {
                 $redirect = base64_decode($returnUri);
             }
             $this->app->redirect(JRoute::_($redirect, false));
             break;
     }
     return true;
 }
开发者ID:WineWorld,项目名称:joomlatrialcmbg,代码行数:71,代码来源:save.php

示例8: storeRequestData

 /**
  * Store filters in the registry
  *
  * @param   array  $request  filters to store
  *
  * @return  void
  */
 public function storeRequestData($request)
 {
     $package = $this->app->getUserState('com_fabrik.package', 'fabrik');
     $input = $this->app->input;
     $registry = $this->session->get('registry');
     $option = 'com_' . $package;
     $tid = 'list' . $this->getRenderContext();
     // Make sure that we only store data thats been entered from this page first test we aren't in a plugin
     if ($input->get('option') == $option && is_object($registry)) {
         // Don't do this when you are viewing a form or details page as it wipes out the table filters
         $reg = $registry->get('_registry');
         if (isset($reg[$option]) && !in_array($input->get('view'), array('form', 'details'))) {
             unset($reg[$option]['data']->{$tid}->filter);
         }
     }
     $context = $option . '.' . $tid . '.filter';
     // @TODO test for _clear_ in values and if so delete session data
     foreach ($request as $key => $val) {
         if (is_array($val)) {
             $key = $context . '.' . $key;
             $this->app->setUserState($key, array_values($val));
         }
     }
 }
开发者ID:pascal26,项目名称:fabrik,代码行数:31,代码来源:list.php


注:本文中的JApplicationCms::setUserState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。