Miss "break" in front_page_admin_submit and front_page_admin_validate for role "themed"
switch ($role['mode']) {
case 'themed':
//miss break;
case 'full':
if (empty($role['data']['value'])) {
form_set_error('roles][' . $rid . '][data][value', 'You must set the data field for ' . $role['mode'] . ' mode.');
}
break;
case 'redirect':
if (empty($role['path'])) {
form_set_error('roles][' . $rid . '][path', 'You must set the path field for redirect mode.');
}
break;
case 'alias':
if (empty($role['path'])) {
form_set_error('roles][' . $rid . '][path', 'You must set the path field for alias mode.');
}
elseif (!preg_match('@^[^?#]+$@', $role['path'])) {
form_set_error('roles][' . $rid . '][path', 'You must set only the URI part of a URL in alias mode.');
}
break;
}
switch ($role['mode']) {
case 'themed':
//miss break;
case 'full':
db_merge('front_page')
->key(array('rid' => $rid))
->fields(array(
'mode' => $role['mode'],
'data' => $role['data']['value'],
'filter_format' => $role['data']['format'],
))
->execute();
break;
case 'redirect':
case 'alias':
db_merge('front_page')
->key(array('rid' => $rid))
->fields(array(
'mode' => $role['mode'],
'data' => $role['path'],
'filter_format' => '',
))
->execute();
break;
default:
db_merge('front_page')
->key(array('rid' => $rid))
->fields(array(
'mode' => '',
'data' => '',
'filter_format' => '',
))
->execute();
break;
}
Comments
Comment #1
timhilliard commentedHi chunglk,
That missing break is on purpose. What that code signifies is that the logic should be used for both the 'themed' and 'full' cases. It saves having to write the logic out twice and maintain it in different places. If the logic needed to be different for either of those cases then I would need to break it out and use the break statement for both.
Does that make sense?
Cheers,
Tim
Comment #2
chunglk commentedOh. I already know it. Because I only need case "themed". Thanks.