original_string: public static function get_sql($userid, $capability) {
          // Get a tree of capability permission at various contexts for current user.
          $root = self::get_tree($userid, $capability);
  
          // The root node always has permission false. If there are no child nodes then the user
          // cannot access anything.
          if (!$root->children) {
              return [false, false];
          }
  
          // Get SQL to limit contexts based on the permission tree.
          return self::create_sql($root);
  
      }
code: public static function get_sql($userid, $capability) {
          // Get a tree of capability permission at various contexts for current user.
          $root = self::get_tree($userid, $capability);
  
          // The root node always has permission false. If there are no child nodes then the user
          // cannot access anything.
          if (!$root->children) {
              return [false, false];
          }
  
          // Get SQL to limit contexts based on the permission tree.
          return self::create_sql($root);
  
      }
code_tokens: public static function get_sql ( $ userid , $ capability ) { // Get a tree of capability permission at various contexts for current user. $ root = self :: get_tree ( $ userid , $ capability ) ; // The root node always has permission false. If there are no child nodes then the user // cannot access anything. if ( ! $ root -> children ) { return [ false , false ] ; } // Get SQL to limit contexts based on the permission tree. return self :: create_sql ( $ root ) ; }
docstring: Gets SQL to restrict a query to contexts in which the user has a capability.
  
  This returns an array with two elements (SQL containing ? placeholders, and a params array).
  The SQL is intended to be used as part of a WHERE clause. It relies on the prefix 'x' being
  used for the Moodle context table.
  
  If the user does not have the permission anywhere at all (so that there is no point doing
  the query) then the two returned values will both be false.
  
  @param int $userid User id
  @param string $capability Capability e.g. 'moodle/course:view'
  @return array Two-element array of SQL (containing ? placeholders) and then a params array
docstring_tokens: Gets SQL to restrict a query to contexts in which the user has a capability .