original_string: public function filter_by_non_approved($constant, $userid = null) {
          global $USER;
          if (!$userid) {
              $userid = $USER->id;
          }
  
          if ($constant === self::NON_APPROVED_ALL) {
              // Nothing to do.
  
          } else if ($constant === self::NON_APPROVED_SELF) {
              $this->where[] = sprintf('%s != 0 OR %s = :toapproveuserid',
                  self::resolve_field('approved', 'entries'), self::resolve_field('userid', 'entries'));
              $this->params['toapproveuserid'] = $USER->id;
  
          } else if ($constant === self::NON_APPROVED_NONE) {
              $this->where[] = sprintf('%s != 0', self::resolve_field('approved', 'entries'));
  
          } else if ($constant === self::NON_APPROVED_ONLY) {
              $this->where[] = sprintf('%s = 0', self::resolve_field('approved', 'entries'));
  
          } else {
              throw new coding_exception('Invalid constant');
          }
      }
code: public function filter_by_non_approved($constant, $userid = null) {
          global $USER;
          if (!$userid) {
              $userid = $USER->id;
          }
  
          if ($constant === self::NON_APPROVED_ALL) {
              // Nothing to do.
  
          } else if ($constant === self::NON_APPROVED_SELF) {
              $this->where[] = sprintf('%s != 0 OR %s = :toapproveuserid',
                  self::resolve_field('approved', 'entries'), self::resolve_field('userid', 'entries'));
              $this->params['toapproveuserid'] = $USER->id;
  
          } else if ($constant === self::NON_APPROVED_NONE) {
              $this->where[] = sprintf('%s != 0', self::resolve_field('approved', 'entries'));
  
          } else if ($constant === self::NON_APPROVED_ONLY) {
              $this->where[] = sprintf('%s = 0', self::resolve_field('approved', 'entries'));
  
          } else {
              throw new coding_exception('Invalid constant');
          }
      }
code_tokens: public function filter_by_non_approved ( $ constant , $ userid = null ) { global $ USER ; if ( ! $ userid ) { $ userid = $ USER -> id ; } if ( $ constant === self :: NON_APPROVED_ALL ) { // Nothing to do. } else if ( $ constant === self :: NON_APPROVED_SELF ) { $ this -> where [ ] = sprintf ( '%s != 0 OR %s = :toapproveuserid' , self :: resolve_field ( 'approved' , 'entries' ) , self :: resolve_field ( 'userid' , 'entries' ) ) ; $ this -> params [ 'toapproveuserid' ] = $ USER -> id ; } else if ( $ constant === self :: NON_APPROVED_NONE ) { $ this -> where [ ] = sprintf ( '%s != 0' , self :: resolve_field ( 'approved' , 'entries' ) ) ; } else if ( $ constant === self :: NON_APPROVED_ONLY ) { $ this -> where [ ] = sprintf ( '%s = 0' , self :: resolve_field ( 'approved' , 'entries' ) ) ; } else { throw new coding_exception ( 'Invalid constant' ) ; } }
docstring: Filter non approved entries.
  
  @param string $constant One of the NON_APPROVED_* constants.
  @param int    $userid   The user ID when relevant, otherwise current user.
docstring_tokens: Filter non approved entries .