You are here

function block_role_delete in Patterns 7.2

Wraps a call to drupal_form_submit to remove a visualization relationship between the given block and role

Parameters

string $form_id String containing the form ID. In the case of custom functions the value is empty.:

array $form_state Set of values after parsing the action.:

1 string reference to 'block_role_delete'
block_patterns in patterns_components/components/block.inc

File

patterns_components/components/block.inc, line 654

Code

function block_role_delete($form_id, &$form_state) {

  //Obtain the rid from the rolename, we don't need to check existance since we did it previously
  $rid = user_role_load_by_name($form_state['values']['role'])->rid;

  //All the fields are mandatory, so it is not necessary to perform any checking
  $query = db_delete('block_role')
    ->condition('module', $form_state['values']['module'])
    ->condition('delta', $form_state['values']['delta'])
    ->condition('rid', $rid)
    ->execute();
  $msg = t('The block defined by module %module with delta %delta will not be shown for role %role.', array(
    '%module' => $form_state['values']['module'],
    '%delta' => $form_state['values']['delta'],
    '%type' => $form_state['values']['role'],
  ));
  return patterns_results(PATTERNS_SUCCESS, $msg);
}