function regcode_dynamic_create_submit in Registration codes 6.2
Form submit: Create a new rule set
File
- regcode_dynamic/
regcode_dynamic.module, line 241 - The dynamic code module creates codes on the fly as they are used.
Code
function regcode_dynamic_create_submit($form, $form_state) {
// Grab all of the existing handlers so we can know the next ID to create
$res = db_query("SELECT name FROM {variable} WHERE name like 'regcode_dynamic_settings_%' ORDER BY name DESC");
$count = db_affected_rows($res);
if ($count === 0) {
$id = 1;
}
else {
$key = explode('_', db_result($res));
// Strip the integer out of the key name
$id = (int) $key[3] + 1;
}
$data = array(
'name' => $form_state['values']['name'],
'handler' => $form_state['values']['handler'],
);
variable_set(sprintf('regcode_dynamic_settings_%d', $id), $data);
drupal_set_message('New dynamic rule created');
drupal_goto('admin/user/regcode/dynamic/rule/' . $id);
}