Example #1
0
 /**
  * Method to cancel module editing.
  *
  * @return  boolean  True on success.
  *
  * @since   3.2
  */
 public function execute()
 {
     // Check if the user is authorized to do this.
     $user = JFactory::getUser();
     if (!$user->authorise('module.edit.frontend', 'com_modules.module.' . $this->input->get('id'))) {
         $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
         $this->app->redirect('index.php');
     }
     $this->context = 'com_config.config.global';
     // Get returnUri
     $returnUri = $this->input->post->get('return', null, 'base64');
     if (!empty($returnUri)) {
         $this->redirect = base64_decode(urldecode($returnUri));
     } else {
         $this->redirect = JUri::base();
     }
     $id = $this->input->getInt('id');
     // Access back-end com_module
     JLoader::register('ModulesControllerModule', JPATH_ADMINISTRATOR . '/components/com_modules/controllers/module.php');
     JLoader::register('ModulesViewModule', JPATH_ADMINISTRATOR . '/components/com_modules/views/module/view.json.php');
     JLoader::register('ModulesModelModule', JPATH_ADMINISTRATOR . '/components/com_modules/models/module.php');
     $cancelClass = new ModulesControllerModule();
     $cancelClass->cancel($id);
     parent::execute();
 }
 public function setModuleType()
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     // Get the result of the parent method. If an error, just return it.
     $result = parent::add();
     if (JError::isError($result)) {
         return $result;
     }
     // Look for the Extension ID.
     $extensionId = JRequest::getInt('eid');
     $position = JRequest::getVar('position');
     if (empty($extensionId)) {
         $this->setRedirect(JRoute::_('index.php?option=com_poweradmin&view=selectmoduletypes&tmpl=component&position=' . $position, false));
     } else {
         $this->setRedirect(JRoute::_('index.php?option=com_poweradmin&view=module&layout=edit&tmpl=component&id=0&position=' . $position, false));
     }
     $app->setUserState('com_poweradmin.add.module.extension_id', $extensionId);
 }
Example #3
0
 /**
  * Method to save module editing.
  *
  * @return  bool	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.
     $user = JFactory::getUser();
     if (!$user->authorise('module.edit.frontend', 'com_modules.module.' . $this->input->get('id')) && !$user->authorise('module.edit.frontend', 'com_modules')) {
         $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
         $this->app->redirect('index.php');
     }
     // Set FTP credentials, if given.
     JClientHelper::setCredentialsFromRequest('ftp');
     // Get sumitted module id
     $moduleId = '&id=' . $this->input->get('id');
     // Get returnUri
     $returnUri = $this->input->post->get('return', null, 'base64');
     $redirect = '';
     if (!empty($returnUri)) {
         $redirect = '&return=' . $returnUri;
     }
     // Access back-end com_modules to be done
     JLoader::register('ModulesControllerModule', JPATH_ADMINISTRATOR . '/components/com_modules/controllers/module.php');
     JLoader::register('ModulesModelModule', JPATH_ADMINISTRATOR . '/components/com_modules/models/module.php');
     $controllerClass = new ModulesControllerModule();
     // Get a document object
     $document = JFactory::getDocument();
     // Set back-end required params
     $document->setType('json');
     // Execute back-end controller
     $return = $controllerClass->save();
     // Reset params back after requesting from service
     $document->setType('html');
     // Check the return value.
     if ($return === false) {
         // Save the data in the session.
         $app->setUserState('com_config.modules.global.data', $data);
         // Save failed, go back to the screen and display a notice.
         $this->app->enqueueMessage(JText::_('JERROR_SAVE_FAILED'));
         $this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.modules' . $moduleId . $redirect, false));
     }
     // Redirect back to com_config display
     $this->app->enqueueMessage(JText::_('COM_CONFIG_MODULES_SAVE_SUCCESS'));
     // Set the redirect based on the task.
     switch ($this->options[3]) {
         case 'apply':
             $this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.modules' . $moduleId . $redirect, false));
             break;
         case 'save':
         default:
             if (!empty($returnUri)) {
                 $redirect = base64_decode(urldecode($returnUri));
                 // Don't redirect to an external URL.
                 if (!JUri::isInternal($redirect)) {
                     $redirect = JUri::base();
                 }
             } else {
                 $redirect = JUri::base();
             }
             $this->app->redirect($redirect);
             break;
     }
 }