Actions

API16

JControllerForm/cancel

From Joomla! Documentation

< API16:JControllerForm
Revision as of 17:35, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Method to cancel an edit

[Edit Descripton]

Description:JControllerForm/cancel

Syntax

cancel()


Defined in

libraries/joomla/application/component/controllerform.php

Importing

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

Source Body

public function cancel()
{
        JRequest::checkToken() or jexit(JText::_('JInvalid_Token'));
 
        // Initialise variables.
        $app            = JFactory::getApplication();
        $model          = &$this->getModel();
        $table          = $model->getTable();
        $checkin        = property_exists($table, 'checked_out');
        $context        = "$this->_option.edit.$this->_context";
        $tmpl           = JRequest::getString('tmpl');
        $layout         = JRequest::getString('layout', 'edit');
        $append         = '';
 
        // Setup redirect info.
        if ($tmpl) {
                $append .= '&tmpl='.$tmpl;
        }
        if ($layout) {
                $append .= '&layout='.$layout;
        }
 
        // Get the record id.
        $recordId = (int) $app->getUserState($context.'.id');
 
        // Attempt to check-in the current record.
        if ($checkin && $recordId)
        {
                if(!$model->checkin($recordId))
                {
                        // Check-in failed, go back to the record and display a notice.
                        $message = JText::sprintf('JError_Checkin_failed', $model->getError());
                        $this->setRedirect('index.php?option='.$this->_option.'&view='.$this->_view_item.$append, $message, 'error');
                        return false;
                }
        }
 
        // Clean the session data and redirect.
        $app->setUserState($context.'.id',              null);
        $app->setUserState($context.'.data',    null);
        $this->setRedirect(JRoute::_('index.php?option='.$this->_option.'&view='.$this->_view_list, false));
}

[Edit See Also] SeeAlso:JControllerForm/cancel

Examples

<CodeExamplesForm />