You are here

function regcode_import_code in Registration codes 5.3

Import a single codes from a single ine string (plain one-field or CSV)

Parameters

$data: The single-line string containing the code data to import (a single field or CSV)

$action: Import action: overwrite - overwrite any existing code with same code identifier as the imported one skip - skip import of code, if any code with same code identifier exists

  • - "^

$fieldorder: List of field keys indicating the order of field to expect in the $data string (array or delimiter-seperated string of keys)

$code: Optional code data template to use as default data setting for each imported code (key/value pairs for any applicable code field, see regcode_save_code)

Return value

Whether the import operation has been successful (TRUE) or not (FALSE)

1 call to regcode_import_code()
regcode_import_stream in ./regcode_api.inc.php
Import codes from a stream (plain list or CSV text data)

File

./regcode_api.inc.php, line 449
regcode_api.inc.php contains general low-level functions for the registration-code module, for tasks like

Code

function regcode_import_code($data, $action, $fieldorder = NULL, $code = array()) {
  if (empty($fieldorder)) {
    $fieldorder = variable_get('regcode_import_csv_fieldorder', 'code');
  }
  if (!is_array($fieldorder)) {
    $fieldorder = explode(variable_get('regcode_import_csv_delimiter', ','), $fieldorder);
  }
  foreach ($data as $key => $value) {
    $code[$fieldorder[$key]] = $value;
  }
  return regcode_save_code($code, $action);
}