original_string: public function moveSnippet(SS_HTTPRequest $request) {
          $snippet=Snippet::get()->byID(intval($request->getVar('ID')));
          
          if(empty($snippet) || $snippet===false || $snippet->ID==0) {
              $this->response->setStatusCode(403, _t('CodeBank.SNIPPIT_NOT_EXIST', '_Snippit does not exist'));
              return;
          }
          
          $parentID=$request->getVar('ParentID');
          if(strpos($parentID, 'language-')!==false) {
              $lang=SnippetLanguage::get()->byID(intval(str_replace('language-', '', $parentID)));
              if(empty($lang) || $lang===false || $lang->ID==0) {
                  $this->response->setStatusCode(403, _t('CodeBank.LANGUAGE_NOT_EXIST', '_Language does not exist'));
                  return;
              }
              
              
              if($lang->ID!=$snippet->LanguageID) {
                  $this->response->setStatusCode(403, _t('CodeBank.CANNOT_MOVE_TO_LANGUAGE', '_You cannot move a snippet to another language'));
                  return;
              }
              
              //Move out of folder
              DB::query('UPDATE "Snippet" SET "FolderID"=0 WHERE "ID"='.$snippet->ID);
              
              
              $this->response->addHeader('X-Status', rawurlencode(_t('CodeBank.SNIPPET_MOVED', '_Snippet moved successfully')));
              return;
          }else if(strpos($parentID, 'folder-')!==false) {
              $folder=SnippetFolder::get()->byID(intval(str_replace('folder-', '', $parentID)));
              if(empty($folder) || $folder===false || $folder->ID==0) {
                  $this->response->setStatusCode(403, _t('CodeBank.FOLDER_NOT_EXIST', '_Folder does not exist'));
                  return;
              }
              
              
              if($folder->LanguageID!=$snippet->LanguageID) {
                  $this->response->setStatusCode(403, _t('CodeBank.CANNOT_MOVE_TO_FOLDER', '_You cannot move a snippet to a folder in another language'));
                  return;
              }
              
              //Move to folder
              DB::query('UPDATE "Snippet" SET "FolderID"='.$folder->ID.' WHERE "ID"='.$snippet->ID);
              
              
              $this->response->addHeader('X-Status', rawurlencode(_t('CodeBank.SNIPPET_MOVED', '_Snippet moved successfully')));
              return;
          }
          
          $this->response->setStatusCode(403, _t('CodeBank.UNKNOWN_PARENT', '_Unknown Parent'));
      }
code: public function moveSnippet(SS_HTTPRequest $request) {
          $snippet=Snippet::get()->byID(intval($request->getVar('ID')));
          
          if(empty($snippet) || $snippet===false || $snippet->ID==0) {
              $this->response->setStatusCode(403, _t('CodeBank.SNIPPIT_NOT_EXIST', '_Snippit does not exist'));
              return;
          }
          
          $parentID=$request->getVar('ParentID');
          if(strpos($parentID, 'language-')!==false) {
              $lang=SnippetLanguage::get()->byID(intval(str_replace('language-', '', $parentID)));
              if(empty($lang) || $lang===false || $lang->ID==0) {
                  $this->response->setStatusCode(403, _t('CodeBank.LANGUAGE_NOT_EXIST', '_Language does not exist'));
                  return;
              }
              
              
              if($lang->ID!=$snippet->LanguageID) {
                  $this->response->setStatusCode(403, _t('CodeBank.CANNOT_MOVE_TO_LANGUAGE', '_You cannot move a snippet to another language'));
                  return;
              }
              
              //Move out of folder
              DB::query('UPDATE "Snippet" SET "FolderID"=0 WHERE "ID"='.$snippet->ID);
              
              
              $this->response->addHeader('X-Status', rawurlencode(_t('CodeBank.SNIPPET_MOVED', '_Snippet moved successfully')));
              return;
          }else if(strpos($parentID, 'folder-')!==false) {
              $folder=SnippetFolder::get()->byID(intval(str_replace('folder-', '', $parentID)));
              if(empty($folder) || $folder===false || $folder->ID==0) {
                  $this->response->setStatusCode(403, _t('CodeBank.FOLDER_NOT_EXIST', '_Folder does not exist'));
                  return;
              }
              
              
              if($folder->LanguageID!=$snippet->LanguageID) {
                  $this->response->setStatusCode(403, _t('CodeBank.CANNOT_MOVE_TO_FOLDER', '_You cannot move a snippet to a folder in another language'));
                  return;
              }
              
              //Move to folder
              DB::query('UPDATE "Snippet" SET "FolderID"='.$folder->ID.' WHERE "ID"='.$snippet->ID);
              
              
              $this->response->addHeader('X-Status', rawurlencode(_t('CodeBank.SNIPPET_MOVED', '_Snippet moved successfully')));
              return;
          }
          
          $this->response->setStatusCode(403, _t('CodeBank.UNKNOWN_PARENT', '_Unknown Parent'));
      }
code_tokens: public function moveSnippet ( SS_HTTPRequest $ request ) { $ snippet = Snippet :: get ( ) -> byID ( intval ( $ request -> getVar ( 'ID' ) ) ) ; if ( empty ( $ snippet ) || $ snippet === false || $ snippet -> ID == 0 ) { $ this -> response -> setStatusCode ( 403 , _t ( 'CodeBank.SNIPPIT_NOT_EXIST' , '_Snippit does not exist' ) ) ; return ; } $ parentID = $ request -> getVar ( 'ParentID' ) ; if ( strpos ( $ parentID , 'language-' ) !== false ) { $ lang = SnippetLanguage :: get ( ) -> byID ( intval ( str_replace ( 'language-' , '' , $ parentID ) ) ) ; if ( empty ( $ lang ) || $ lang === false || $ lang -> ID == 0 ) { $ this -> response -> setStatusCode ( 403 , _t ( 'CodeBank.LANGUAGE_NOT_EXIST' , '_Language does not exist' ) ) ; return ; } if ( $ lang -> ID != $ snippet -> LanguageID ) { $ this -> response -> setStatusCode ( 403 , _t ( 'CodeBank.CANNOT_MOVE_TO_LANGUAGE' , '_You cannot move a snippet to another language' ) ) ; return ; } //Move out of folder DB :: query ( 'UPDATE "Snippet" SET "FolderID"=0 WHERE "ID"=' . $ snippet -> ID ) ; $ this -> response -> addHeader ( 'X-Status' , rawurlencode ( _t ( 'CodeBank.SNIPPET_MOVED' , '_Snippet moved successfully' ) ) ) ; return ; } else if ( strpos ( $ parentID , 'folder-' ) !== false ) { $ folder = SnippetFolder :: get ( ) -> byID ( intval ( str_replace ( 'folder-' , '' , $ parentID ) ) ) ; if ( empty ( $ folder ) || $ folder === false || $ folder -> ID == 0 ) { $ this -> response -> setStatusCode ( 403 , _t ( 'CodeBank.FOLDER_NOT_EXIST' , '_Folder does not exist' ) ) ; return ; } if ( $ folder -> LanguageID != $ snippet -> LanguageID ) { $ this -> response -> setStatusCode ( 403 , _t ( 'CodeBank.CANNOT_MOVE_TO_FOLDER' , '_You cannot move a snippet to a folder in another language' ) ) ; return ; } //Move to folder DB :: query ( 'UPDATE "Snippet" SET "FolderID"=' . $ folder -> ID . ' WHERE "ID"=' . $ snippet -> ID ) ; $ this -> response -> addHeader ( 'X-Status' , rawurlencode ( _t ( 'CodeBank.SNIPPET_MOVED' , '_Snippet moved successfully' ) ) ) ; return ; } $ this -> response -> setStatusCode ( 403 , _t ( 'CodeBank.UNKNOWN_PARENT' , '_Unknown Parent' ) ) ; }
docstring: Handles moving of a snippet when the tree is reordered
  @param {SS_HTTPRequest} $request HTTP Request
docstring_tokens: Handles moving of a snippet when the tree is reordered