original_string: public function set_parent($parentid, $source=null) {
          if ($this->parent == $parentid) {
              return true;
          }
  
          if ($parentid == $this->id) {
              print_error('cannotassignselfasparent');
          }
  
          if (empty($this->parent) and $this->is_course_category()) {
              print_error('cannothaveparentcate');
          }
  
          // find parent and check course id
          if (!$parent_category = grade_category::fetch(array('id'=>$parentid, 'courseid'=>$this->courseid))) {
              return false;
          }
  
          $this->force_regrading();
  
          // set new parent category
          $this->parent          = $parent_category->id;
          $this->parent_category =& $parent_category;
          $this->path            = null;       // remove old path and depth - will be recalculated in update()
          $this->depth           = 0;          // remove old path and depth - will be recalculated in update()
          $this->update($source);
  
          return $this->update($source);
      }
code: public function set_parent($parentid, $source=null) {
          if ($this->parent == $parentid) {
              return true;
          }
  
          if ($parentid == $this->id) {
              print_error('cannotassignselfasparent');
          }
  
          if (empty($this->parent) and $this->is_course_category()) {
              print_error('cannothaveparentcate');
          }
  
          // find parent and check course id
          if (!$parent_category = grade_category::fetch(array('id'=>$parentid, 'courseid'=>$this->courseid))) {
              return false;
          }
  
          $this->force_regrading();
  
          // set new parent category
          $this->parent          = $parent_category->id;
          $this->parent_category =& $parent_category;
          $this->path            = null;       // remove old path and depth - will be recalculated in update()
          $this->depth           = 0;          // remove old path and depth - will be recalculated in update()
          $this->update($source);
  
          return $this->update($source);
      }
code_tokens: public function set_parent ( $ parentid , $ source = null ) { if ( $ this -> parent == $ parentid ) { return true ; } if ( $ parentid == $ this -> id ) { print_error ( 'cannotassignselfasparent' ) ; } if ( empty ( $ this -> parent ) and $ this -> is_course_category ( ) ) { print_error ( 'cannothaveparentcate' ) ; } // find parent and check course id if ( ! $ parent_category = grade_category :: fetch ( array ( 'id' => $ parentid , 'courseid' => $ this -> courseid ) ) ) { return false ; } $ this -> force_regrading ( ) ; // set new parent category $ this -> parent = $ parent_category -> id ; $ this -> parent_category = & $ parent_category ; $ this -> path = null ; // remove old path and depth - will be recalculated in update() $ this -> depth = 0 ; // remove old path and depth - will be recalculated in update() $ this -> update ( $ source ) ; return $ this -> update ( $ source ) ; }
docstring: Sets this category's parent id
  
  @param int $parentid The ID of the category that is the new parent to $this
  @param string $source From where was the object updated (mod/forum, manual, etc.)
  @return bool success
docstring_tokens: Sets this category s parent id