application/Controllers/AjaxControllers/Write.php
/**
     * Rename Draft to new name
     * Validate if name is correct
     * 
     * @route true
     * @postParams [new_name, draft_id]
     */
Rename Draft to new name
Validate if name is correct


Rename Draft to new name Validate if name is correct
public function renameDraft() {
        $newName = $_POST['new_name'];
        $draftId = $_POST['draft_id'];
        $data = [];
        $data['status'] = 500;
        if($this->writeModel->isUserDraft($draftId)) {
            $errors = [];
            if(!(mb_strlen($newName) > $this->minDraftName && mb_strlen($newName) < $this->maxDraftName && !Str::isEmptyStr($newName))) {
                $errors['draft_name_err'] = "Draft Name must be 5-50 characters";
            }
            $data = $errors;
            $data['status'] = 500;
            if(Str::emptyStrings($errors)) {
                if($this->writeModel->renameDraft($draftId, $newName)) {
                    $data['status'] = 200;
                } else {
                    $data['err'] = "Error Occurred";
                }
            }
        }
        echo json_encode($data);
    }
public function renameDraft ( ) { $ newName = $ _POST [ 'new_name' ] ; $ draftId = $ _POST [ 'draft_id' ] ; $ data = [ ] ; $ data [ 'status' ] = 500 ; if ( $ this -> writeModel -> isUserDraft ( $ draftId ) ) { $ errors = [ ] ; if ( ! ( mb_strlen ( $ newName ) > $ this -> minDraftName && mb_strlen ( $ newName ) < $ this -> maxDraftName && ! Str :: isEmptyStr ( $ newName ) ) ) { $ errors [ 'draft_name_err' ] = " Draft Name must be 5-50 characters " ; } $ data = $ errors ; $ data [ 'status' ] = 500 ; if ( Str :: emptyStrings ( $ errors ) ) { if ( $ this -> writeModel -> renameDraft ( $ draftId , $ newName ) ) { $ data [ 'status' ] = 200 ; } else { $ data [ 'err' ] = " Error Occurred " ; } } } echo json_encode ( $ data ) ; }
Rename Draft to new name
 Validate if name is correct
Rename Draft to new name Validate if name is correct