You are here

function regcode_admin_list_getresource in Registration codes 6

Grab the result resource based on the form state

@parma bool $conditions Use the variables table to filter the result set

Parameters

bool $count_only Return the rowcount only:

Return value

resource The drupal result resource

5 calls to regcode_admin_list_getresource()
regcode_admin_list in ./regcode.admin.php
Return the code list page content with(in) the according filter form
regcode_admin_list_action_export in ./regcode.admin.php
Regcode Action: Exports to CSV
regcode_admin_list_getmarkup in ./regcode.admin.php
Return the marked up list for display
regcode_mailer_admin_list_form in regcode_mailer/regcode_mailer.module
Return the code list page content with(in) the according filter form
regcode_mailer_list_action_mail in regcode_mailer/regcode_mailer.module
Submit action for the form

File

./regcode.admin.php, line 588
Functions and pages needed for the administration interface for the regcode module.

Code

function regcode_admin_list_getresource($count_only = FALSE, $conditions = TRUE) {

  // Which query to use
  if ($count_only) {
    $query = 'SELECT COUNT(regcode.rid) AS count FROM {regcode} AS regcode';
  }
  else {
    module_load_include('regcode.api', 'regcode', 'php');

    // Prepend the table name
    $fields = regcode_get_fields();
    $f = array();
    foreach (array_keys($fields) as $field) {
      $f[] = 'regcode.' . $field;
    }
    $what = implode(',', $f);
    $query = 'SELECT ' . $what . ' FROM {regcode} AS regcode';
  }

  // Add conditions
  if ($conditions) {
    module_load_include('regcode.api', 'regcode', 'php');
    $query .= regcode_admin_list_getwhere();
  }

  // Allow plugins to alter the query
  foreach (module_implements('regcode_query_alter') as $module) {
    $hook = $module . '_regcode_query_alter';
    $hook($query, $count_only, $conditions);
  }
  return db_query($query);
}