You are here

function block_role_create in Patterns 7.2

Wraps a call to drupal_form_submit to define 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_create'
block_patterns in patterns_components/components/block.inc

File

patterns_components/components/block.inc, line 628

Code

function block_role_create($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_insert('block_role')
    ->fields(array(
    'module',
    'delta',
    'rid',
  ))
    ->values(array(
    'module' => $form_state['values']['module'],
    'delta' => $form_state['values']['delta'],
    'rid' => $rid,
  ))
    ->execute();
  $msg = t('The block defined by module %module with delta %delta will be shown for role %role.', array(
    '%module' => $form_state['values']['module'],
    '%delta' => $form_state['values']['delta'],
    '%role' => $form_state['values']['role'],
  ));
  return patterns_results(PATTERNS_SUCCESS, $msg);
}