| 40 |
$module_sets = module_invoke_all('voting_actions_sets'); |
$module_sets = module_invoke_all('voting_actions_sets'); |
| 41 |
|
|
| 42 |
foreach ($module_sets as $name => $set) { |
foreach ($module_sets as $name => $set) { |
| 43 |
$set += array( |
$set += _voting_actions_populate_set_defaults(); |
|
'source' => 'user', |
|
|
'required' => TRUE, |
|
|
'condition_mask' => 'AND', |
|
|
'weight' => 0, |
|
|
'conditions' => array(), |
|
|
'actions' => array(), |
|
|
'subsets' => array(), |
|
|
); |
|
| 44 |
$set['status'] = voting_actions_get_status($name); |
$set['status'] = voting_actions_get_status($name); |
| 45 |
|
|
| 46 |
$links = array(); |
$links = array(); |
| 140 |
$errors = _voting_actions_validate_set($set); |
$errors = _voting_actions_validate_set($set); |
| 141 |
if (count($errors) == 0) { |
if (count($errors) == 0) { |
| 142 |
_voting_actions_insert_set($set); |
_voting_actions_insert_set($set); |
| 143 |
voting_actions_get_sets(TRUE); |
return 'admin/settings/voting_actions'; |
|
drupal_goto('admin/settings/voting_actions'); |
|
| 144 |
} |
} |
| 145 |
else { |
else { |
| 146 |
foreach ($errors as $error) { |
foreach ($errors as $error) { |
| 147 |
drupal_set_message($error); |
drupal_set_message($error); |
| 148 |
|
return FALSE; |
| 149 |
} |
} |
| 150 |
} |
} |
| 151 |
} |
} |
| 152 |
else { |
else { |
| 153 |
drupal_set_message(t('Unable to get an action set out of that.')); |
drupal_set_message(t('Unable to get an action set out of that.')); |
| 154 |
return; |
return FALSE; |
| 155 |
} |
} |
| 156 |
} |
} |
| 157 |
} |
} |
| 174 |
$data = cache_get('voting_actions_cache'); |
$data = cache_get('voting_actions_cache'); |
| 175 |
$action_sets = unserialize($data->data); |
$action_sets = unserialize($data->data); |
| 176 |
$set = $action_sets[$set_name]; |
$set = $action_sets[$set_name]; |
| 177 |
|
|
| 178 |
|
unset($set['vasid']); |
| 179 |
|
foreach($set['conditions'] as $key => $condition) { |
| 180 |
|
unset($set['conditions'][$key]['vacid']); |
| 181 |
|
unset($set['conditions'][$key]['vasid']); |
| 182 |
|
} |
| 183 |
|
|
| 184 |
if (!empty($set)) { |
if (!empty($set)) { |
| 185 |
unset($set['name']); |
$code .= '$set = '; |
|
$code = "\n\$sets = array(\n"; |
|
|
$code .= "'$set_name' => "; |
|
| 186 |
ob_start(); |
ob_start(); |
| 187 |
var_export($set); |
var_export($set); |
| 188 |
$code .= ob_get_clean(); |
$code .= ob_get_clean(); |
| 189 |
ob_end_clean(); |
ob_end_clean(); |
| 190 |
$code .= "\n);\n"; |
|
| 191 |
|
$code .= "\n\$sets['$set_name'] = \$set;"; |
| 192 |
|
$code .= "\nreturn \$sets;"; |
| 193 |
} |
} |
| 194 |
|
|
| 195 |
return $code; |
return $code; |
| 278 |
|
|
| 279 |
function voting_actions_set_form_validate($form_id, $form_values) { |
function voting_actions_set_form_validate($form_id, $form_values) { |
| 280 |
if ($form_values['op'] == t('Submit')) { |
if ($form_values['op'] == t('Submit')) { |
| 281 |
|
|
| 282 |
if (empty($form_values['name'])) { |
if (empty($form_values['name'])) { |
| 283 |
form_set_error('name', t('Action sets must be named.')); |
form_set_error('name', t('Action sets must be named.')); |
| 284 |
} |
} |
| 285 |
elseif ($form_values['name'] != strtolower(form_clean_id($form_values['name']))) { |
elseif ($form_values['name'] != strtolower(str_replace(array(' ', '&', '%', '#', '$', '@', '.', ','), '_', $form_values['name']))) { |
| 286 |
form_set_error('name', t('The set name must consist of lowercase letters with no spaces or special symbols -- use underscores or dashes instead of spaces.')); |
form_set_error('name', t('The set name must consist of lowercase letters with no spaces or special symbols -- use underscores or dashes instead of spaces.')); |
| 287 |
} |
} |
| 288 |
elseif(empty($form_values['vasid'])) { |
elseif(empty($form_values['vasid'])) { |
| 303 |
if ($form_values['op'] == t('Submit')) { |
if ($form_values['op'] == t('Submit')) { |
| 304 |
$set = _voting_actions_set_from_values(array(), $form_values); |
$set = _voting_actions_set_from_values(array(), $form_values); |
| 305 |
if (empty($set['vasid'])) { |
if (empty($set['vasid'])) { |
| 306 |
_voting_actions_insert_set($set); |
_voting_actions_insert_set($set); |
| 307 |
} |
} |
| 308 |
else { |
else { |
| 309 |
_voting_actions_update_set($set); |
_voting_actions_update_set($set); |
| 329 |
$set['required'] = $form_values['required']; |
$set['required'] = $form_values['required']; |
| 330 |
$set['weight'] = $form_values['weight']; |
$set['weight'] = $form_values['weight']; |
| 331 |
$set['condition_mask'] = $form_values['conditions']['condition_mask']; |
$set['condition_mask'] = $form_values['conditions']['condition_mask']; |
| 332 |
|
if (!empty($form_values['vasid'])) { |
| 333 |
|
$set['vasid'] = $form_values['vasid']; |
| 334 |
|
} |
| 335 |
|
|
| 336 |
$set += array( |
$set += array( |
| 337 |
'conditions' => array(), |
'conditions' => array(), |
| 376 |
'#default_value' => $set['description'], |
'#default_value' => $set['description'], |
| 377 |
); |
); |
| 378 |
|
|
| 379 |
if (isset($set['parent'])) { |
if (!empty($set['parent'])) { |
| 380 |
$form['parent'] = array( |
$form['parent'] = array( |
| 381 |
'#type' => 'hidden', |
'#type' => 'hidden', |
| 382 |
'#value' => $set['parent'], |
'#value' => $set['parent'], |