Source for file config.php

Documentation is available at config.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_messages
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * Messages Component Message Model
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_messages
  17.  * @since       1.6
  18.  */
  19. {
  20.     /**
  21.      * Method to save a record.
  22.      */
  23.     public function save()
  24.     {
  25.         // Check for request forgeries.
  26.         JSession::checkToken(or jexit(JText::_('JINVALID_TOKEN'));
  27.  
  28.         $app   JFactory::getApplication();
  29.         $model $this->getModel('Config''MessagesModel');
  30.         $data  $this->input->post->get('jform'array()'array');
  31.  
  32.         // Validate the posted data.
  33.         $form    $model->getForm();
  34.         if (!$form)
  35.         {
  36.             JError::raiseError(500$model->getError());
  37.             return false;
  38.         }
  39.         $data $model->validate($form$data);
  40.  
  41.         // Check for validation errors.
  42.         if ($data === false)
  43.         {
  44.             // Get the validation messages.
  45.             $errors    $model->getErrors();
  46.  
  47.             // Push up to three validation messages out to the user.
  48.             for ($i 0$n count($errors)$i $n && $i 3$i++)
  49.             {
  50.                 if ($errors[$iinstanceof Exception)
  51.                 {
  52.                     $app->enqueueMessage($errors[$i]->getMessage()'warning');
  53.                 else {
  54.                     $app->enqueueMessage($errors[$i]'warning');
  55.                 }
  56.             }
  57.  
  58.             // Redirect back to the main list.
  59.             $this->setRedirect(JRoute::_('index.php?option=com_messages&view=messages'false));
  60.             return false;
  61.         }
  62.  
  63.         // Attempt to save the data.
  64.         if (!$model->save($data))
  65.         {
  66.             // Redirect back to the main list.
  67.             $this->setMessage(JText::sprintf('JERROR_SAVE_FAILED'$model->getError())'warning');
  68.             $this->setRedirect(JRoute::_('index.php?option=com_messages&view=messages'false));
  69.             return false;
  70.         }
  71.  
  72.         // Redirect to the list screen.
  73.         $this->setMessage(JText::_('COM_MESSAGES_CONFIG_SAVED'));
  74.         $this->setRedirect(JRoute::_('index.php?option=com_messages&view=messages'false));
  75.  
  76.         return true;
  77.     }
  78. }

Documentation generated on Tue, 19 Nov 2013 14:56:29 +0100 by phpDocumentor 1.4.3