function ad_owner_permissions_form_submit in Advertisement 6.3
Same name and namespace in other branches
- 6 owners/ad_owners.module \ad_owner_permissions_form_submit()
- 6.2 owners/ad_owners.module \ad_owner_permissions_form_submit()
- 7 owners/ad_owners.module \ad_owner_permissions_form_submit()
Store the ad owner's updated permissions in the ad_permissions table.
File
- owners/
ad_owners.module, line 540 - Enhances the ad module to support ad owners.
Code
function ad_owner_permissions_form_submit($form, &$form_state) {
$permissions = module_invoke_all('adapi', 'permissions', array());
$perms = array();
foreach ($permissions as $permission => $default) {
$perm = str_replace(' ', '_', $permission);
if (isset($form_state['values'][$perm]) && $form_state['values'][$perm] > 0) {
$perms[] = $permission;
}
}
db_query('DELETE FROM {ad_permissions} WHERE oid = %d', $form_state['values']['oid']);
db_query("INSERT INTO {ad_permissions} VALUES(%d, '%s')", $form_state['values']['oid'], implode('|,|', $perms));
drupal_set_message(t('The permissions have been saved.'));
$form_state['redirect'] = 'node/' . $form_state['values']['aid'] . '/adowners';
}