developer.jelix.org is not used any more and exists only for history. Post new tickets on the Github account.
developer.jelix.org n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Ticket #330: patch-330.diff

File patch-330.diff, 3.0 KB (added by bastnic, 13 years ago)
  • lib/jelix/controllers/jControllerDaoCrud.class.php

     
    33* @package    jelix
    44* @subpackage controllers
    55* @author     Laurent Jouanneau
    6 * @contributor
     6* @contributor Bastien Jaillot
    77* @copyright  2007 Laurent Jouanneau
    88* @link        http://www.jelix.org
    99* @licence  http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
     
    251251            $id = $form->saveToDao($this->dao, null, $this->dbProfil);
    252252            $form->saveAllFiles($this->uploadsDirectory);
    253253            $rep->action = $this->_getAction('view');
    254             $this->_afterCreate($form, $id);
     254            $this->_afterCreate($form, $id, $rep);
    255255            jForms::destroy($this->form);
    256256            $rep->params['id'] = $id;
    257257            return $rep;
     
    266266     * a record
    267267     * @param jFormsBase $form the form object
    268268     * @param mixed $id the new id of the inserted record
     269     * @param jHtmlResponse $resp the response
    269270     */
    270     protected function _afterCreate($form, $id) {
     271    protected function _afterCreate($form, $id, $resp) {
    271272
    272273    }
    273274
     
    350351        if($form->check() && $this->_checkDatas($form, true)){
    351352            $id = $form->saveToDao($this->dao, null, $this->dbProfil);
    352353            $form->saveAllFiles($this->uploadsDirectory);
    353             $this->_afterUpdate($form, $id);
    354354            $rep->action = $this->_getAction('view');
     355            $this->_afterUpdate($form, $id, $rep);
    355356            jForms::destroy($this->form, $id);
    356357        } else {
    357358            $rep->action = $this->_getAction('editupdate');
     
    365366     * a record
    366367     * @param jFormsBase $form the form object
    367368     * @param mixed $id the new id of the updated record
     369     * @param jHtmlResponse $resp the response
    368370     */
    369     protected function _afterUpdate($form, $id) {
     371    protected function _afterUpdate($form, $id, $resp) {
    370372
    371373    }
    372374
     
    414416     */
    415417    function delete(){
    416418        $id = $this->param('id');
    417         if( $id !== null && $this->_delete($id) ){
     419        $rep = $this->getResponse('redirect');
     420        $rep->action = $this->_getAction('index');
     421        if( $id !== null && $this->_delete($id, $rep) ){
    418422            $dao = jDao::get($this->dao, $this->dbProfil);
    419423            $dao->delete($id);
    420424        }
    421         $rep = $this->getResponse('redirect');
    422         $rep->action = $this->_getAction('index');
    423425        return $rep;
    424426    }
    425427
     
    427429     * overload this method if you want to do additionnal things before the deletion of a record
    428430     * @param mixed $id the new id of the record
    429431     * @return boolean true if the record can be deleted
     432     * @param jHtmlResponse $resp the response
    430433     */
    431     protected function _delete($id) {
     434    protected function _delete($id, $resp) {
    432435        return true;
    433436    }
    434437