Blame view

administrator/components/com_creativecontactform/controllers/creativeform.php 1.64 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
<?php
/**
 * Joomla! component Creative Contact Form
 *
 * @version $Id: 2012-04-05 14:30:25 svn $
 * @author creative-solutions.net
 * @package Creative Contact Form
 * @subpackage com_creativecontactform
 * @license GNU/GPL
 *
 */

// no direct access
defined('_JEXEC') or die('Restircted access');

jimport('joomla.application.component.controllerform');

class CreativeContactFormControllerCreativeForm extends JControllerForm
{
	function __construct($default = array()) {
		parent::__construct($default);
	
		$this->registerTask('save', 'saveForm');
		$this->registerTask('apply', 'saveForm');
		$this->registerTask('save2new', 'saveForm');

		$this->registerTask('save2copy', 'copyForm');
	}

	function saveForm() {
		$id = JRequest::getInt('id',0);
		$model = $this->getModel('creativeform');
	
		$response = $model->saveForm();

		$msg_string = $response[0];
		$insert_id = $response[1];

		$id = ($id == 0 && $insert_id != 0) ? $insert_id : $id; 

		if ($msg_string == 'no') {
			$msg = JText::_( 'COM_CREATIVECONTACTFORM_FORM_SAVED' );
			$msg_type = 'message';
		} else {
			$msg = JText::_( $msg_string );
			$msg_type = 'error';
		}
		
		if($_REQUEST['task'] == 'apply' && $id != 0)
			$link = 'index.php?option=com_creativecontactform&view=creativeform&layout=edit&id='.$id;
		elseif($_REQUEST['task'] == 'save2new')
			$link = 'index.php?option=com_creativecontactform&view=creativeform&layout=edit';
		else
			$link = 'index.php?option=com_creativecontactform&view=creativeforms';
		$this->setRedirect($link, $msg, $msg_type);
	}

	function copyForm() {
		$link = 'index.php?option=com_creativecontactform&view=creativeforms';
		$this->setRedirect($link);
	}


}