original_string: protected function prepare_sql_courses() {
          global $DB;
          if (!preg_match('/\\%COURSEFILTER\\%/', $this->sql)) {
              return;
          }
          $this->init_course_access();
          $unaccessiblecourses = array_filter($this->courseaccess, function($item) {
              return !$item;
          });
          $idx = 0;
          while (preg_match('/^([^\\0]*?)\\%COURSEFILTER\\%([^\\0]*)$/', $this->sql, $matches)) {
              list($sql, $params) = $DB->get_in_or_equal(array_keys($unaccessiblecourses),
                      SQL_PARAMS_NAMED, 'ca_'.($idx++).'_', false, 0);
              $this->sql = $matches[1].' '.$sql.' '.$matches[2];
              $this->params += $params;
          }
      }
code: protected function prepare_sql_courses() {
          global $DB;
          if (!preg_match('/\\%COURSEFILTER\\%/', $this->sql)) {
              return;
          }
          $this->init_course_access();
          $unaccessiblecourses = array_filter($this->courseaccess, function($item) {
              return !$item;
          });
          $idx = 0;
          while (preg_match('/^([^\\0]*?)\\%COURSEFILTER\\%([^\\0]*)$/', $this->sql, $matches)) {
              list($sql, $params) = $DB->get_in_or_equal(array_keys($unaccessiblecourses),
                      SQL_PARAMS_NAMED, 'ca_'.($idx++).'_', false, 0);
              $this->sql = $matches[1].' '.$sql.' '.$matches[2];
              $this->params += $params;
          }
      }
code_tokens: protected function prepare_sql_courses ( ) { global $ DB ; if ( ! preg_match ( '/\\%COURSEFILTER\\%/' , $ this -> sql ) ) { return ; } $ this -> init_course_access ( ) ; $ unaccessiblecourses = array_filter ( $ this -> courseaccess , function ( $ item ) { return ! $ item ; } ) ; $ idx = 0 ; while ( preg_match ( '/^([^\\0]*?)\\%COURSEFILTER\\%([^\\0]*)$/' , $ this -> sql , $ matches ) ) { list ( $ sql , $ params ) = $ DB -> get_in_or_equal ( array_keys ( $ unaccessiblecourses ) , SQL_PARAMS_NAMED , 'ca_' . ( $ idx ++ ) . '_' , false , 0 ) ; $ this -> sql = $ matches [ 1 ] . ' ' . $ sql . ' ' . $ matches [ 2 ] ; $ this -> params += $ params ; } }
docstring: Substitute %COURSEFILTER% with an expression filtering out courses where current user does not have access
docstring_tokens: Substitute %COURSEFILTER% with an expression filtering out courses where current user does not have access