original_string: public function update_moved(context $newparent) {
          global $DB;
  
          $frompath = $this->_path;
          $newpath  = $newparent->path . '/' . $this->_id;
  
          $trans = $DB->start_delegated_transaction();
  
          $setdepth = '';
          if (($newparent->depth +1) != $this->_depth) {
              $diff = $newparent->depth - $this->_depth + 1;
              $setdepth = ", depth = depth + $diff";
          }
          $sql = "UPDATE {context}
                     SET path = ?
                         $setdepth
                   WHERE id = ?";
          $params = array($newpath, $this->_id);
          $DB->execute($sql, $params);
  
          $this->_path  = $newpath;
          $this->_depth = $newparent->depth + 1;
  
          $sql = "UPDATE {context}
                     SET path = ".$DB->sql_concat("?", $DB->sql_substr("path", strlen($frompath)+1))."
                         $setdepth
                   WHERE path LIKE ?";
          $params = array($newpath, "{$frompath}/%");
          $DB->execute($sql, $params);
  
          $this->mark_dirty();
  
          context::reset_caches();
  
          $trans->allow_commit();
      }
code: public function update_moved(context $newparent) {
          global $DB;
  
          $frompath = $this->_path;
          $newpath  = $newparent->path . '/' . $this->_id;
  
          $trans = $DB->start_delegated_transaction();
  
          $setdepth = '';
          if (($newparent->depth +1) != $this->_depth) {
              $diff = $newparent->depth - $this->_depth + 1;
              $setdepth = ", depth = depth + $diff";
          }
          $sql = "UPDATE {context}
                     SET path = ?
                         $setdepth
                   WHERE id = ?";
          $params = array($newpath, $this->_id);
          $DB->execute($sql, $params);
  
          $this->_path  = $newpath;
          $this->_depth = $newparent->depth + 1;
  
          $sql = "UPDATE {context}
                     SET path = ".$DB->sql_concat("?", $DB->sql_substr("path", strlen($frompath)+1))."
                         $setdepth
                   WHERE path LIKE ?";
          $params = array($newpath, "{$frompath}/%");
          $DB->execute($sql, $params);
  
          $this->mark_dirty();
  
          context::reset_caches();
  
          $trans->allow_commit();
      }
code_tokens: public function update_moved ( context $ newparent ) { global $ DB ; $ frompath = $ this -> _path ; $ newpath = $ newparent -> path . '/' . $ this -> _id ; $ trans = $ DB -> start_delegated_transaction ( ) ; $ setdepth = '' ; if ( ( $ newparent -> depth + 1 ) != $ this -> _depth ) { $ diff = $ newparent -> depth - $ this -> _depth + 1 ; $ setdepth = ", depth = depth + $diff" ; } $ sql = "UPDATE {context}
                     SET path = ?
                         $setdepth
                   WHERE id = ?" ; $ params = array ( $ newpath , $ this -> _id ) ; $ DB -> execute ( $ sql , $ params ) ; $ this -> _path = $ newpath ; $ this -> _depth = $ newparent -> depth + 1 ; $ sql = "UPDATE {context}
                     SET path = " . $ DB -> sql_concat ( "?" , $ DB -> sql_substr ( "path" , strlen ( $ frompath ) + 1 ) ) . "
                         $setdepth
                   WHERE path LIKE ?" ; $ params = array ( $ newpath , "{$frompath}/%" ) ; $ DB -> execute ( $ sql , $ params ) ; $ this -> mark_dirty ( ) ; context :: reset_caches ( ) ; $ trans -> allow_commit ( ) ; }
docstring: Update context info after moving context in the tree structure.
  
  @param context $newparent
  @return void
docstring_tokens: Update context info after moving context in the tree structure .