original_string: public static function get_wikis_by_courses($courseids = array()) {
  
          $returnedwikis = array();
          $warnings = array();
  
          $params = self::validate_parameters(self::get_wikis_by_courses_parameters(), array('courseids' => $courseids));
  
          $mycourses = array();
          if (empty($params['courseids'])) {
              $mycourses = enrol_get_my_courses();
              $params['courseids'] = array_keys($mycourses);
          }
  
          // Ensure there are courseids to loop through.
          if (!empty($params['courseids'])) {
  
              list($courses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses);
  
              // Get the wikis in this course, this function checks users visibility permissions.
              // We can avoid then additional validate_context calls.
              $wikis = get_all_instances_in_courses('wiki', $courses);
  
              foreach ($wikis as $wiki) {
  
                  $context = context_module::instance($wiki->coursemodule);
  
                  // Entry to return.
                  $module = array();
  
                  // First, we return information that any user can see in (or can deduce from) the web interface.
                  $module['id'] = $wiki->id;
                  $module['coursemodule'] = $wiki->coursemodule;
                  $module['course'] = $wiki->course;
                  $module['name']  = external_format_string($wiki->name, $context->id);
  
                  $viewablefields = [];
                  if (has_capability('mod/wiki:viewpage', $context)) {
                      list($module['intro'], $module['introformat']) =
                          external_format_text($wiki->intro, $wiki->introformat, $context->id, 'mod_wiki', 'intro', null);
                      $module['introfiles'] = external_util::get_area_files($context->id, 'mod_wiki', 'intro', false, false);
  
                      $viewablefields = array('firstpagetitle', 'wikimode', 'defaultformat', 'forceformat', 'editbegin', 'editend',
                                              'section', 'visible', 'groupmode', 'groupingid');
                  }
  
                  // Check additional permissions for returning optional private settings.
                  if (has_capability('moodle/course:manageactivities', $context)) {
                      $additionalfields = array('timecreated', 'timemodified');
                      $viewablefields = array_merge($viewablefields, $additionalfields);
                  }
  
                  foreach ($viewablefields as $field) {
                      $module[$field] = $wiki->{$field};
                  }
  
                  // Check if user can add new pages.
                  $module['cancreatepages'] = wiki_can_create_pages($context);
  
                  $returnedwikis[] = $module;
              }
          }
  
          $result = array();
          $result['wikis'] = $returnedwikis;
          $result['warnings'] = $warnings;
          return $result;
      }
code: public static function get_wikis_by_courses($courseids = array()) {
  
          $returnedwikis = array();
          $warnings = array();
  
          $params = self::validate_parameters(self::get_wikis_by_courses_parameters(), array('courseids' => $courseids));
  
          $mycourses = array();
          if (empty($params['courseids'])) {
              $mycourses = enrol_get_my_courses();
              $params['courseids'] = array_keys($mycourses);
          }
  
          // Ensure there are courseids to loop through.
          if (!empty($params['courseids'])) {
  
              list($courses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses);
  
              // Get the wikis in this course, this function checks users visibility permissions.
              // We can avoid then additional validate_context calls.
              $wikis = get_all_instances_in_courses('wiki', $courses);
  
              foreach ($wikis as $wiki) {
  
                  $context = context_module::instance($wiki->coursemodule);
  
                  // Entry to return.
                  $module = array();
  
                  // First, we return information that any user can see in (or can deduce from) the web interface.
                  $module['id'] = $wiki->id;
                  $module['coursemodule'] = $wiki->coursemodule;
                  $module['course'] = $wiki->course;
                  $module['name']  = external_format_string($wiki->name, $context->id);
  
                  $viewablefields = [];
                  if (has_capability('mod/wiki:viewpage', $context)) {
                      list($module['intro'], $module['introformat']) =
                          external_format_text($wiki->intro, $wiki->introformat, $context->id, 'mod_wiki', 'intro', null);
                      $module['introfiles'] = external_util::get_area_files($context->id, 'mod_wiki', 'intro', false, false);
  
                      $viewablefields = array('firstpagetitle', 'wikimode', 'defaultformat', 'forceformat', 'editbegin', 'editend',
                                              'section', 'visible', 'groupmode', 'groupingid');
                  }
  
                  // Check additional permissions for returning optional private settings.
                  if (has_capability('moodle/course:manageactivities', $context)) {
                      $additionalfields = array('timecreated', 'timemodified');
                      $viewablefields = array_merge($viewablefields, $additionalfields);
                  }
  
                  foreach ($viewablefields as $field) {
                      $module[$field] = $wiki->{$field};
                  }
  
                  // Check if user can add new pages.
                  $module['cancreatepages'] = wiki_can_create_pages($context);
  
                  $returnedwikis[] = $module;
              }
          }
  
          $result = array();
          $result['wikis'] = $returnedwikis;
          $result['warnings'] = $warnings;
          return $result;
      }
code_tokens: public static function get_wikis_by_courses ( $ courseids = array ( ) ) { $ returnedwikis = array ( ) ; $ warnings = array ( ) ; $ params = self :: validate_parameters ( self :: get_wikis_by_courses_parameters ( ) , array ( 'courseids' => $ courseids ) ) ; $ mycourses = array ( ) ; if ( empty ( $ params [ 'courseids' ] ) ) { $ mycourses = enrol_get_my_courses ( ) ; $ params [ 'courseids' ] = array_keys ( $ mycourses ) ; } // Ensure there are courseids to loop through. if ( ! empty ( $ params [ 'courseids' ] ) ) { list ( $ courses , $ warnings ) = external_util :: validate_courses ( $ params [ 'courseids' ] , $ mycourses ) ; // Get the wikis in this course, this function checks users visibility permissions. // We can avoid then additional validate_context calls. $ wikis = get_all_instances_in_courses ( 'wiki' , $ courses ) ; foreach ( $ wikis as $ wiki ) { $ context = context_module :: instance ( $ wiki -> coursemodule ) ; // Entry to return. $ module = array ( ) ; // First, we return information that any user can see in (or can deduce from) the web interface. $ module [ 'id' ] = $ wiki -> id ; $ module [ 'coursemodule' ] = $ wiki -> coursemodule ; $ module [ 'course' ] = $ wiki -> course ; $ module [ 'name' ] = external_format_string ( $ wiki -> name , $ context -> id ) ; $ viewablefields = [ ] ; if ( has_capability ( 'mod/wiki:viewpage' , $ context ) ) { list ( $ module [ 'intro' ] , $ module [ 'introformat' ] ) = external_format_text ( $ wiki -> intro , $ wiki -> introformat , $ context -> id , 'mod_wiki' , 'intro' , null ) ; $ module [ 'introfiles' ] = external_util :: get_area_files ( $ context -> id , 'mod_wiki' , 'intro' , false , false ) ; $ viewablefields = array ( 'firstpagetitle' , 'wikimode' , 'defaultformat' , 'forceformat' , 'editbegin' , 'editend' , 'section' , 'visible' , 'groupmode' , 'groupingid' ) ; } // Check additional permissions for returning optional private settings. if ( has_capability ( 'moodle/course:manageactivities' , $ context ) ) { $ additionalfields = array ( 'timecreated' , 'timemodified' ) ; $ viewablefields = array_merge ( $ viewablefields , $ additionalfields ) ; } foreach ( $ viewablefields as $ field ) { $ module [ $ field ] = $ wiki -> { $ field } ; } // Check if user can add new pages. $ module [ 'cancreatepages' ] = wiki_can_create_pages ( $ context ) ; $ returnedwikis [ ] = $ module ; } } $ result = array ( ) ; $ result [ 'wikis' ] = $ returnedwikis ; $ result [ 'warnings' ] = $ warnings ; return $ result ; }
docstring: Returns a list of wikis in a provided list of courses,
  if no list is provided all wikis that the user can view will be returned.
  
  @param array $courseids The courses IDs.
  @return array Containing a list of warnings and a list of wikis.
  @since Moodle 3.1
docstring_tokens: Returns a list of wikis in a provided list of courses if no list is provided all wikis that the user can view will be returned .