original_string: public function set_hidden($hidden, $cascade=false) {
          $this->load_grade_item();
          //this hides the associated grade item (the course total)
          $this->grade_item->set_hidden($hidden, $cascade);
          //this hides the category itself and everything it contains
          parent::set_hidden($hidden, $cascade);
  
          if ($cascade) {
  
              if ($children = grade_item::fetch_all(array('categoryid'=>$this->id))) {
  
                  foreach ($children as $child) {
                      if ($child->can_control_visibility()) {
                          $child->set_hidden($hidden, $cascade);
                      }
                  }
              }
  
              if ($children = grade_category::fetch_all(array('parent'=>$this->id))) {
  
                  foreach ($children as $child) {
                      $child->set_hidden($hidden, $cascade);
                  }
              }
          }
  
          //if marking category visible make sure parent category is visible MDL-21367
          if( !$hidden ) {
              $category_array = grade_category::fetch_all(array('id'=>$this->parent));
              if ($category_array && array_key_exists($this->parent, $category_array)) {
                  $category = $category_array[$this->parent];
                  //call set_hidden on the category regardless of whether it is hidden as its parent might be hidden
                  //if($category->is_hidden()) {
                      $category->set_hidden($hidden, false);
                  //}
              }
          }
      }
code: public function set_hidden($hidden, $cascade=false) {
          $this->load_grade_item();
          //this hides the associated grade item (the course total)
          $this->grade_item->set_hidden($hidden, $cascade);
          //this hides the category itself and everything it contains
          parent::set_hidden($hidden, $cascade);
  
          if ($cascade) {
  
              if ($children = grade_item::fetch_all(array('categoryid'=>$this->id))) {
  
                  foreach ($children as $child) {
                      if ($child->can_control_visibility()) {
                          $child->set_hidden($hidden, $cascade);
                      }
                  }
              }
  
              if ($children = grade_category::fetch_all(array('parent'=>$this->id))) {
  
                  foreach ($children as $child) {
                      $child->set_hidden($hidden, $cascade);
                  }
              }
          }
  
          //if marking category visible make sure parent category is visible MDL-21367
          if( !$hidden ) {
              $category_array = grade_category::fetch_all(array('id'=>$this->parent));
              if ($category_array && array_key_exists($this->parent, $category_array)) {
                  $category = $category_array[$this->parent];
                  //call set_hidden on the category regardless of whether it is hidden as its parent might be hidden
                  //if($category->is_hidden()) {
                      $category->set_hidden($hidden, false);
                  //}
              }
          }
      }
code_tokens: public function set_hidden ( $ hidden , $ cascade = false ) { $ this -> load_grade_item ( ) ; //this hides the associated grade item (the course total) $ this -> grade_item -> set_hidden ( $ hidden , $ cascade ) ; //this hides the category itself and everything it contains parent :: set_hidden ( $ hidden , $ cascade ) ; if ( $ cascade ) { if ( $ children = grade_item :: fetch_all ( array ( 'categoryid' => $ this -> id ) ) ) { foreach ( $ children as $ child ) { if ( $ child -> can_control_visibility ( ) ) { $ child -> set_hidden ( $ hidden , $ cascade ) ; } } } if ( $ children = grade_category :: fetch_all ( array ( 'parent' => $ this -> id ) ) ) { foreach ( $ children as $ child ) { $ child -> set_hidden ( $ hidden , $ cascade ) ; } } } //if marking category visible make sure parent category is visible MDL-21367 if ( ! $ hidden ) { $ category_array = grade_category :: fetch_all ( array ( 'id' => $ this -> parent ) ) ; if ( $ category_array && array_key_exists ( $ this -> parent , $ category_array ) ) { $ category = $ category_array [ $ this -> parent ] ; //call set_hidden on the category regardless of whether it is hidden as its parent might be hidden //if($category->is_hidden()) { $ category -> set_hidden ( $ hidden , false ) ; //} } } }
docstring: Sets the grade_item's hidden variable and updates the grade_item.
  
  Overrides grade_item::set_hidden() to add cascading of the hidden value to grade items in this grade category
  
  @param int $hidden 0 mean always visible, 1 means always hidden and a number > 1 is a timestamp to hide until
  @param bool $cascade apply to child objects too
docstring_tokens: Sets the grade_item s hidden variable and updates the grade_item .