original_string: public function can_change_parent($newparentcat) {
          if (!has_capability('moodle/category:manage', $this->get_context())) {
              return false;
          }
          if (is_object($newparentcat)) {
              $newparentcat = self::get($newparentcat->id, IGNORE_MISSING);
          } else {
              $newparentcat = self::get((int)$newparentcat, IGNORE_MISSING);
          }
          if (!$newparentcat) {
              return false;
          }
          if ($newparentcat->id == $this->id || in_array($this->id, $newparentcat->get_parents())) {
              // Can not move to itself or it's own child.
              return false;
          }
          if ($newparentcat->id) {
              return has_capability('moodle/category:manage', context_coursecat::instance($newparentcat->id));
          } else {
              return has_capability('moodle/category:manage', context_system::instance());
          }
      }
code: public function can_change_parent($newparentcat) {
          if (!has_capability('moodle/category:manage', $this->get_context())) {
              return false;
          }
          if (is_object($newparentcat)) {
              $newparentcat = self::get($newparentcat->id, IGNORE_MISSING);
          } else {
              $newparentcat = self::get((int)$newparentcat, IGNORE_MISSING);
          }
          if (!$newparentcat) {
              return false;
          }
          if ($newparentcat->id == $this->id || in_array($this->id, $newparentcat->get_parents())) {
              // Can not move to itself or it's own child.
              return false;
          }
          if ($newparentcat->id) {
              return has_capability('moodle/category:manage', context_coursecat::instance($newparentcat->id));
          } else {
              return has_capability('moodle/category:manage', context_system::instance());
          }
      }
code_tokens: public function can_change_parent ( $ newparentcat ) { if ( ! has_capability ( 'moodle/category:manage' , $ this -> get_context ( ) ) ) { return false ; } if ( is_object ( $ newparentcat ) ) { $ newparentcat = self :: get ( $ newparentcat -> id , IGNORE_MISSING ) ; } else { $ newparentcat = self :: get ( ( int ) $ newparentcat , IGNORE_MISSING ) ; } if ( ! $ newparentcat ) { return false ; } if ( $ newparentcat -> id == $ this -> id || in_array ( $ this -> id , $ newparentcat -> get_parents ( ) ) ) { // Can not move to itself or it's own child. return false ; } if ( $ newparentcat -> id ) { return has_capability ( 'moodle/category:manage' , context_coursecat :: instance ( $ newparentcat -> id ) ) ; } else { return has_capability ( 'moodle/category:manage' , context_system :: instance ( ) ) ; } }
docstring: Checks if user can move current category to the new parent
  
  This checks if new parent category exists, user has manage cap there
  and new parent is not a child of this category
  
  @param int|stdClass|core_course_category $newparentcat
  @return bool
docstring_tokens: Checks if user can move current category to the new parent