You are here

function merci_permissions_form_alter in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6

Same name and namespace in other branches
  1. 6.2 modules/merci_permissions/merci_permissions.module \merci_permissions_form_alter()

File

modules/merci_permissions/merci_permissions.module, line 64
Provides functions for resetting permissions on the permission page.

Code

function merci_permissions_form_alter(&$form, $form_state, $form_id) {
  return;
  if ($form_id == 'user_admin_perm') {

    // Have to build checkboxes here after checkbox arrays are built
    $merci_types = merci_permissions_load_merci_type_settings();
    $perms = array();
    foreach ($merci_types as $key => $value) {
      $perms[] = "delete own {$key} content";
      $perms[] = "delete any {$key} content";
      $perms[] = "edit own {$key} content";
      $perms[] = "edit any {$key} content";
    }
    foreach (element_children($form['checkboxes']) as $rid) {
      if (is_array($form['checkboxes'][$rid])) {
        $options = array();
        foreach ($form['checkboxes'][$rid]['#options'] as $option => $value) {
          if (!in_array($option, $perms)) {
            $options[$option] = '';
          }
        }
        $form['checkboxes'][$rid]['#options'] = $options;
        $defaults = array();
        foreach ($form['checkboxes'][$rid]['#default_value'] as $default) {
          if (!in_array($default, $perms)) {
            $defaults[] = $default;
          }
        }
        $form['checkboxes'][$rid]['#default_value'] = $defaults;
      }
    }
    $new_perms = array();
    $new_perms[0] = $form['permission'][0];
    foreach ($form['permission'] as $key => $value) {
      if (!in_array($key, $perms)) {
        $new_perms[$key] = $form['permission'][$key];
      }
    }
    $form['permission'] = $new_perms;
    merci_permissions_add_form($form);
  }
}