original_string: public function set_parent($parentid, $updateaggregationfields = true) {
          if ($this->is_course_item() or $this->is_category_item()) {
              print_error('cannotsetparentforcatoritem');
          }
  
          if ($this->categoryid == $parentid) {
              return true;
          }
  
          // find parent and check course id
          if (!$parent_category = grade_category::fetch(array('id'=>$parentid, 'courseid'=>$this->courseid))) {
              return false;
          }
  
          $currentparent = $this->load_parent_category();
  
          if ($updateaggregationfields) {
              $this->set_aggregation_fields_for_aggregation($currentparent->aggregation, $parent_category->aggregation);
          }
  
          $this->force_regrading();
  
          // set new parent
          $this->categoryid = $parent_category->id;
          $this->parent_category =& $parent_category;
  
          return $this->update();
      }
code: public function set_parent($parentid, $updateaggregationfields = true) {
          if ($this->is_course_item() or $this->is_category_item()) {
              print_error('cannotsetparentforcatoritem');
          }
  
          if ($this->categoryid == $parentid) {
              return true;
          }
  
          // find parent and check course id
          if (!$parent_category = grade_category::fetch(array('id'=>$parentid, 'courseid'=>$this->courseid))) {
              return false;
          }
  
          $currentparent = $this->load_parent_category();
  
          if ($updateaggregationfields) {
              $this->set_aggregation_fields_for_aggregation($currentparent->aggregation, $parent_category->aggregation);
          }
  
          $this->force_regrading();
  
          // set new parent
          $this->categoryid = $parent_category->id;
          $this->parent_category =& $parent_category;
  
          return $this->update();
      }
code_tokens: public function set_parent ( $ parentid , $ updateaggregationfields = true ) { if ( $ this -> is_course_item ( ) or $ this -> is_category_item ( ) ) { print_error ( 'cannotsetparentforcatoritem' ) ; } if ( $ this -> categoryid == $ parentid ) { return true ; } // find parent and check course id if ( ! $ parent_category = grade_category :: fetch ( array ( 'id' => $ parentid , 'courseid' => $ this -> courseid ) ) ) { return false ; } $ currentparent = $ this -> load_parent_category ( ) ; if ( $ updateaggregationfields ) { $ this -> set_aggregation_fields_for_aggregation ( $ currentparent -> aggregation , $ parent_category -> aggregation ) ; } $ this -> force_regrading ( ) ; // set new parent $ this -> categoryid = $ parent_category -> id ; $ this -> parent_category = & $ parent_category ; return $ this -> update ( ) ; }
docstring: Sets this item's categoryid. A generic method shared by objects that have a parent id of some kind.
  
  @param int $parentid The ID of the new parent
  @param bool $updateaggregationfields Whether or not to convert the aggregation fields when switching between category.
  Set this to false when the aggregation fields have been updated in prevision of the new
  category, typically when the item is freshly created.
  @return bool True if success
docstring_tokens: Sets this item s categoryid . A generic method shared by objects that have a parent id of some kind .