english/libraries/joomla/application/component/controllerform.php
/**
	 * Method to cancel an edit.
	 *
	 * @param   string  $key  The name of the primary key of the URL variable.
	 *
	 * @return  boolean  True if access level checks pass, false otherwise.
	 * @since   11.1
	 */
Method to cancel an edit.
@param   string  $key  The name of the primary key of the URL variable.

@return  boolean  True if access level checks pass, false otherwise.
Method to cancel an edit . @param string $key The name of the primary key of the URL variable . @return boolean True if access level checks pass false otherwise .
public function cancel($key = null)
	{
		JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
		$app		= JFactory::getApplication();
		$model		= $this->getModel();
		$table		= $model->getTable();
		$checkin	= property_exists($table, 'checked_out');
		$context	= "$this->option.edit.$this->context";
		if (empty($key)) {
			$key = $table->getKeyName();
		}
		$recordId	= JRequest::getInt($key);
		if ($recordId) {
			if (!$this->checkEditId($context, $recordId)) {
				$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $recordId));
				$this->setMessage($this->getError(), 'error');
				$this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_list.$this->getRedirectToListAppend(), false));
				return false;
			}
			if ($checkin) {
				if ($model->checkin($recordId) === false) {
					$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()));
					$this->setMessage($this->getError(), 'error');
					$this->setRedirect('index.php?option='.$this->option.'&view='.$this->view_item.$this->getRedirectToItemAppend($recordId, $key));
					return false;
				}
			}
		}
		$this->releaseEditId($context, $recordId);
		$app->setUserState($context.'.data',	null);
		$this->setRedirect(JRoute::_('index.php?option='.$this->option.'&view='.$this->view_list.$this->getRedirectToListAppend(), false));
		return true;
	}
public function cancel ( $ key = null ) { JRequest :: checkToken ( ) or jexit ( JText :: _ ( 'JINVALID_TOKEN' ) ) ; $ app = JFactory :: getApplication ( ) ; $ model = $ this -> getModel ( ) ; $ table = $ model -> getTable ( ) ; $ checkin = property_exists ( $ table , 'checked_out' ) ; $ context = " $ this -> option .edit. $ this -> context " ; if ( empty ( $ key ) ) { $ key = $ table -> getKeyName ( ) ; } $ recordId = JRequest :: getInt ( $ key ) ; if ( $ recordId ) { if ( ! $ this -> checkEditId ( $ context , $ recordId ) ) { $ this -> setError ( JText :: sprintf ( 'JLIB_APPLICATION_ERROR_UNHELD_ID' , $ recordId ) ) ; $ this -> setMessage ( $ this -> getError ( ) , 'error' ) ; $ this -> setRedirect ( JRoute :: _ ( 'index.php?option=' . $ this -> option . '&view=' . $ this -> view_list . $ this -> getRedirectToListAppend ( ) , false ) ) ; return false ; } if ( $ checkin ) { if ( $ model -> checkin ( $ recordId ) === false ) { $ this -> setError ( JText :: sprintf ( 'JLIB_APPLICATION_ERROR_CHECKIN_FAILED' , $ model -> getError ( ) ) ) ; $ this -> setMessage ( $ this -> getError ( ) , 'error' ) ; $ this -> setRedirect ( 'index.php?option=' . $ this -> option . '&view=' . $ this -> view_item . $ this -> getRedirectToItemAppend ( $ recordId , $ key ) ) ; return false ; } } } $ this -> releaseEditId ( $ context , $ recordId ) ; $ app -> setUserState ( $ context . '.data' , null ) ; $ this -> setRedirect ( JRoute :: _ ( 'index.php?option=' . $ this -> option . '&view=' . $ this -> view_list . $ this -> getRedirectToListAppend ( ) , false ) ) ; return true ; }
Method to cancel an edit.
Method to cancel an edit .
// Initialise variables. // Attempt to check-in the current record. // Check we are holding the id in the edit list. // Somehow the person just went to the form - we don't allow that. // Check-in failed, go back to the record and display a notice. // Clean the session data and redirect.