public function doRenameFolder($data, Form $form) {
        $folder=SnippetFolder::get()->byID(intval($data['ID']));
        if(empty($folder) || $folder===false || $folder->ID==0) {
            $form->sessionMessage(_t('CodeBank.FOLDER_NOT_FOUND', '_Folder could not be found'), 'bad');
            return $this->redirectBack();
        }
        
        //Existing Check
        $existingCheck=SnippetFolder::get()
                                            ->filter('Name:nocase', Convert::raw2sql($data['Name']))
                                            ->filter('LanguageID', $folder->LanguageID)
                                            ->filter('ParentID', $folder->ParentID)
                                            ->filter('ID:not', $folder->ID);
        if($existingCheck->Count()>0) {
            $form->sessionMessage(_t('CodeBank.FOLDER_EXISTS', '_A folder already exists with that name'), 'bad');
            return $this->redirectBack();
        }
        
        //Update Folder
        $form->saveInto($folder);
        $folder->write();
        
        
        //Add script to rename the folder in the tree
        Requirements::customScript('window.parent.renameCodeBankTreeNode("folder-'.$folder->ID.'", "'.addslashes($folder->TreeTitle).'");');
        
        
        //Re-render the form
        $form->setMessage(_t('CodeBank.FOLDER_RENAMED', '_Folder Renamed'), 'good');
        return $this->customise(array(
                                    'Content'=>' ',
                                    'Form'=>$form
                                ))->renderWith('CMSDialog');
    }
public function doRenameFolder($data, Form $form) {
        $folder=SnippetFolder::get()->byID(intval($data['ID']));
        if(empty($folder) || $folder===false || $folder->ID==0) {
            $form->sessionMessage(_t('CodeBank.FOLDER_NOT_FOUND', '_Folder could not be found'), 'bad');
            return $this->redirectBack();
        }
        
        //Existing Check
        $existingCheck=SnippetFolder::get()
                                            ->filter('Name:nocase', Convert::raw2sql($data['Name']))
                                            ->filter('LanguageID', $folder->LanguageID)
                                            ->filter('ParentID', $folder->ParentID)
                                            ->filter('ID:not', $folder->ID);
        if($existingCheck->Count()>0) {
            $form->sessionMessage(_t('CodeBank.FOLDER_EXISTS', '_A folder already exists with that name'), 'bad');
            return $this->redirectBack();
        }
        
        //Update Folder
        $form->saveInto($folder);
        $folder->write();
        
        
        //Add script to rename the folder in the tree
        Requirements::customScript('window.parent.renameCodeBankTreeNode("folder-'.$folder->ID.'", "'.addslashes($folder->TreeTitle).'");');
        
        
        //Re-render the form
        $form->setMessage(_t('CodeBank.FOLDER_RENAMED', '_Folder Renamed'), 'good');
        return $this->customise(array(
                                    'Content'=>' ',
                                    'Form'=>$form
                                ))->renderWith('CMSDialog');
    }
public function doRenameFolder ( $ data , Form $ form ) { $ folder = SnippetFolder :: get ( ) -> byID ( intval ( $ data [ 'ID' ] ) ) ; if ( empty ( $ folder ) || $ folder === false || $ folder -> ID == 0 ) { $ form -> sessionMessage ( _t ( 'CodeBank.FOLDER_NOT_FOUND' , '_Folder could not be found' ) , 'bad' ) ; return $ this -> redirectBack ( ) ; } //Existing Check $ existingCheck = SnippetFolder :: get ( ) -> filter ( 'Name:nocase' , Convert :: raw2sql ( $ data [ 'Name' ] ) ) -> filter ( 'LanguageID' , $ folder -> LanguageID ) -> filter ( 'ParentID' , $ folder -> ParentID ) -> filter ( 'ID:not' , $ folder -> ID ) ; if ( $ existingCheck -> Count ( ) > 0 ) { $ form -> sessionMessage ( _t ( 'CodeBank.FOLDER_EXISTS' , '_A folder already exists with that name' ) , 'bad' ) ; return $ this -> redirectBack ( ) ; } //Update Folder $ form -> saveInto ( $ folder ) ; $ folder -> write ( ) ; //Add script to rename the folder in the tree Requirements :: customScript ( 'window.parent.renameCodeBankTreeNode("folder-' . $ folder -> ID . '", "' . addslashes ( $ folder -> TreeTitle ) . '");' ) ; //Re-render the form $ form -> setMessage ( _t ( 'CodeBank.FOLDER_RENAMED' , '_Folder Renamed' ) , 'good' ) ; return $ this -> customise ( array ( 'Content' => ' ' , 'Form' => $ form ) ) -> renderWith ( 'CMSDialog' ) ; }
Performs the rename of the folder
@param {array} $data Submitted data
@param {Form} $form Submitting form
@return {string} HTML to be rendered
Performs the rename of the folder