original_string: protected static function validate_access_and_filters($rawwsfilters) {
          global $CFG;
  
          if (empty($CFG->enableblogs)) {
              throw new moodle_exception('blogdisable', 'blog');
          }
  
          // Init filters.
          $filterstype = array(
              'courseid' => PARAM_INT,
              'groupid' => PARAM_INT,
              'userid' => PARAM_INT,
              'tagid' => PARAM_INT,
              'tag' => PARAM_NOTAGS,
              'cmid' => PARAM_INT,
              'entryid' => PARAM_INT,
              'search' => PARAM_RAW
          );
          $filters = array(
              'courseid' => null,
              'groupid' => null,
              'userid' => null,
              'tagid' => null,
              'tag' => null,
              'cmid' => null,
              'entryid' => null,
              'search' => null
          );
  
          foreach ($rawwsfilters as $filter) {
              $name = trim($filter['name']);
              if (!isset($filterstype[$name])) {
                  throw new moodle_exception('errorinvalidparam', 'webservice', '', $name);
              }
              $filters[$name] = clean_param($filter['value'], $filterstype[$name]);
          }
  
          // Do not overwrite here the filters, blog_get_headers and blog_listing will take care of that.
          list($courseid, $userid) = blog_validate_access($filters['courseid'], $filters['cmid'], $filters['groupid'],
              $filters['entryid'], $filters['userid']);
  
          if ($courseid && $courseid != SITEID) {
              $context = context_course::instance($courseid);
              self::validate_context($context);
          } else {
              $context = context_system::instance();
              if ($CFG->bloglevel == BLOG_GLOBAL_LEVEL) {
                  // Everybody can see anything - no login required unless site is locked down using forcelogin.
                  if ($CFG->forcelogin) {
                      self::validate_context($context);
                  }
              } else {
                  self::validate_context($context);
              }
          }
          // Courseid and userid may not be the same that the ones in $filters.
          return array($context, $filters, $courseid, $userid);
      }
code: protected static function validate_access_and_filters($rawwsfilters) {
          global $CFG;
  
          if (empty($CFG->enableblogs)) {
              throw new moodle_exception('blogdisable', 'blog');
          }
  
          // Init filters.
          $filterstype = array(
              'courseid' => PARAM_INT,
              'groupid' => PARAM_INT,
              'userid' => PARAM_INT,
              'tagid' => PARAM_INT,
              'tag' => PARAM_NOTAGS,
              'cmid' => PARAM_INT,
              'entryid' => PARAM_INT,
              'search' => PARAM_RAW
          );
          $filters = array(
              'courseid' => null,
              'groupid' => null,
              'userid' => null,
              'tagid' => null,
              'tag' => null,
              'cmid' => null,
              'entryid' => null,
              'search' => null
          );
  
          foreach ($rawwsfilters as $filter) {
              $name = trim($filter['name']);
              if (!isset($filterstype[$name])) {
                  throw new moodle_exception('errorinvalidparam', 'webservice', '', $name);
              }
              $filters[$name] = clean_param($filter['value'], $filterstype[$name]);
          }
  
          // Do not overwrite here the filters, blog_get_headers and blog_listing will take care of that.
          list($courseid, $userid) = blog_validate_access($filters['courseid'], $filters['cmid'], $filters['groupid'],
              $filters['entryid'], $filters['userid']);
  
          if ($courseid && $courseid != SITEID) {
              $context = context_course::instance($courseid);
              self::validate_context($context);
          } else {
              $context = context_system::instance();
              if ($CFG->bloglevel == BLOG_GLOBAL_LEVEL) {
                  // Everybody can see anything - no login required unless site is locked down using forcelogin.
                  if ($CFG->forcelogin) {
                      self::validate_context($context);
                  }
              } else {
                  self::validate_context($context);
              }
          }
          // Courseid and userid may not be the same that the ones in $filters.
          return array($context, $filters, $courseid, $userid);
      }
code_tokens: protected static function validate_access_and_filters ( $ rawwsfilters ) { global $ CFG ; if ( empty ( $ CFG -> enableblogs ) ) { throw new moodle_exception ( 'blogdisable' , 'blog' ) ; } // Init filters. $ filterstype = array ( 'courseid' => PARAM_INT , 'groupid' => PARAM_INT , 'userid' => PARAM_INT , 'tagid' => PARAM_INT , 'tag' => PARAM_NOTAGS , 'cmid' => PARAM_INT , 'entryid' => PARAM_INT , 'search' => PARAM_RAW ) ; $ filters = array ( 'courseid' => null , 'groupid' => null , 'userid' => null , 'tagid' => null , 'tag' => null , 'cmid' => null , 'entryid' => null , 'search' => null ) ; foreach ( $ rawwsfilters as $ filter ) { $ name = trim ( $ filter [ 'name' ] ) ; if ( ! isset ( $ filterstype [ $ name ] ) ) { throw new moodle_exception ( 'errorinvalidparam' , 'webservice' , '' , $ name ) ; } $ filters [ $ name ] = clean_param ( $ filter [ 'value' ] , $ filterstype [ $ name ] ) ; } // Do not overwrite here the filters, blog_get_headers and blog_listing will take care of that. list ( $ courseid , $ userid ) = blog_validate_access ( $ filters [ 'courseid' ] , $ filters [ 'cmid' ] , $ filters [ 'groupid' ] , $ filters [ 'entryid' ] , $ filters [ 'userid' ] ) ; if ( $ courseid && $ courseid != SITEID ) { $ context = context_course :: instance ( $ courseid ) ; self :: validate_context ( $ context ) ; } else { $ context = context_system :: instance ( ) ; if ( $ CFG -> bloglevel == BLOG_GLOBAL_LEVEL ) { // Everybody can see anything - no login required unless site is locked down using forcelogin. if ( $ CFG -> forcelogin ) { self :: validate_context ( $ context ) ; } } else { self :: validate_context ( $ context ) ; } } // Courseid and userid may not be the same that the ones in $filters. return array ( $ context , $ filters , $ courseid , $ userid ) ; }
docstring: Validate access to the blog and the filters to apply when listing entries.
  
  @param  array  $rawwsfilters array containing the filters in WS format
  @return array  context, filters to apply and the calculated courseid and user
  @since  Moodle 3.6
docstring_tokens: Validate access to the blog and the filters to apply when listing entries .