original_string: protected function can_add_activity() {
          global $CFG;
          if (!($modname = $this->get_activitytype())) {
              return false;
          }
          if (!has_capability('moodle/course:manageactivities', context_course::instance($this->courseid))) {
              return false;
          }
          if (!course_allowed_module($this->get_course(), $modname)) {
              return false;
          }
          $libfile = "$CFG->dirroot/mod/$modname/lib.php";
          if (!file_exists($libfile)) {
              return null;
          }
          return true;
      }
code: protected function can_add_activity() {
          global $CFG;
          if (!($modname = $this->get_activitytype())) {
              return false;
          }
          if (!has_capability('moodle/course:manageactivities', context_course::instance($this->courseid))) {
              return false;
          }
          if (!course_allowed_module($this->get_course(), $modname)) {
              return false;
          }
          $libfile = "$CFG->dirroot/mod/$modname/lib.php";
          if (!file_exists($libfile)) {
              return null;
          }
          return true;
      }
code_tokens: protected function can_add_activity ( ) { global $ CFG ; if ( ! ( $ modname = $ this -> get_activitytype ( ) ) ) { return false ; } if ( ! has_capability ( 'moodle/course:manageactivities' , context_course :: instance ( $ this -> courseid ) ) ) { return false ; } if ( ! course_allowed_module ( $ this -> get_course ( ) , $ modname ) ) { return false ; } $ libfile = "$CFG->dirroot/mod/$modname/lib.php" ; if ( ! file_exists ( $ libfile ) ) { return null ; } return true ; }
docstring: Checks if the current user can add the activity of the specified type to this course.
  
  @return bool
docstring_tokens: Checks if the current user can add the activity of the specified type to this course .