API15

JControllerForm/cancel

< API15:JControllerForm

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description

Method to cancel an edit

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

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";

        // 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.'&layout=edit', $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));
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples

Code Examples


Advertisement