original_string: public static function get_expired_requests($userid = 0) {
          global $DB;
  
          $expiryseconds = get_config('tool_dataprivacy', 'privacyrequestexpiry');
          $expirytime = strtotime("-{$expiryseconds} second");
          $table = self::TABLE;
          $sqlwhere = 'type = :export_type AND status = :completestatus AND timemodified <= :expirytime';
          $params = array(
              'export_type' => api::DATAREQUEST_TYPE_EXPORT,
              'completestatus' => api::DATAREQUEST_STATUS_DOWNLOAD_READY,
              'expirytime' => $expirytime,
          );
          $sort = 'id';
          $fields = 'id, userid';
  
          // Filter by user ID if specified.
          if ($userid > 0) {
              $sqlwhere .= ' AND (userid = :userid OR requestedby = :requestedby)';
              $params['userid'] = $userid;
              $params['requestedby'] = $userid;
          }
  
          return $DB->get_records_select_menu($table, $sqlwhere, $params, $sort, $fields, 0, 2000);
      }
code: public static function get_expired_requests($userid = 0) {
          global $DB;
  
          $expiryseconds = get_config('tool_dataprivacy', 'privacyrequestexpiry');
          $expirytime = strtotime("-{$expiryseconds} second");
          $table = self::TABLE;
          $sqlwhere = 'type = :export_type AND status = :completestatus AND timemodified <= :expirytime';
          $params = array(
              'export_type' => api::DATAREQUEST_TYPE_EXPORT,
              'completestatus' => api::DATAREQUEST_STATUS_DOWNLOAD_READY,
              'expirytime' => $expirytime,
          );
          $sort = 'id';
          $fields = 'id, userid';
  
          // Filter by user ID if specified.
          if ($userid > 0) {
              $sqlwhere .= ' AND (userid = :userid OR requestedby = :requestedby)';
              $params['userid'] = $userid;
              $params['requestedby'] = $userid;
          }
  
          return $DB->get_records_select_menu($table, $sqlwhere, $params, $sort, $fields, 0, 2000);
      }
code_tokens: public static function get_expired_requests ( $ userid = 0 ) { global $ DB ; $ expiryseconds = get_config ( 'tool_dataprivacy' , 'privacyrequestexpiry' ) ; $ expirytime = strtotime ( "-{$expiryseconds} second" ) ; $ table = self :: TABLE ; $ sqlwhere = 'type = :export_type AND status = :completestatus AND timemodified <= :expirytime' ; $ params = array ( 'export_type' => api :: DATAREQUEST_TYPE_EXPORT , 'completestatus' => api :: DATAREQUEST_STATUS_DOWNLOAD_READY , 'expirytime' => $ expirytime , ) ; $ sort = 'id' ; $ fields = 'id, userid' ; // Filter by user ID if specified. if ( $ userid > 0 ) { $ sqlwhere .= ' AND (userid = :userid OR requestedby = :requestedby)' ; $ params [ 'userid' ] = $ userid ; $ params [ 'requestedby' ] = $ userid ; } return $ DB -> get_records_select_menu ( $ table , $ sqlwhere , $ params , $ sort , $ fields , 0 , 2000 ) ; }
docstring: Fetch completed data requests which are due to expire.
  
  @param int $userid Optional user ID to filter by.
  
  @return array Details of completed requests which are due to expire.
docstring_tokens: Fetch completed data requests which are due to expire .