function regcode_convert_codes_query in Registration codes 5.3
Helper function to actually convert existing codes from variable-storage to database-storage
Parameters
codes: The string containing the codes to insert into the db (one code per line)
rid: The role the given codes will grant
Return value
The rendered output for the requested admin page
1 call to regcode_convert_codes_query()
- regcode_convert_codes in ./
regcode.install - Helper function to iterate through code-variables and initiating code conversion to database-storage
File
- ./
regcode.install, line 107
Code
function regcode_convert_codes_query($codes, $rid) {
if (empty($codes)) {
return 0;
}
$codes = preg_split('/[\\n\\r]+/', $codes, $max_lines = 100000);
$rid = intval($rid);
$time = time();
$count = 0;
foreach ($codes as $code) {
$count++;
db_query("\n INSERT DELAYED INTO {regcode}\n (`code`, `available`, `uid`, `rid`, `created`, `expire`, `revoke`, `info`)\n VALUES ('%s', '1', NULL, " . ($rid ? "%d" : "NULL") . ", UNIX_TIMESTAMP(), '0', '0', 'converted');\n ", $code, $rid);
}
return $count;
}