You are here

function simple_access_profile_list in Simple Access 7.2

Same name and namespace in other branches
  1. 5.2 simple_access.module \simple_access_profile_list()
  2. 6.2 simple_access.admin.inc \simple_access_profile_list()

Access Profiles settings form.

1 string reference to 'simple_access_profile_list'
simple_access_menu in ./simple_access.module
Implements hook_menu().

File

./simple_access.admin.inc, line 147
House all the admin functions in inc to make the foot print a lot smaller.

Code

function simple_access_profile_list() {
  $form = array();
  $result = db_select('simple_access_profiles', 'p')
    ->fields('p', array(
    'pid',
    'name',
    'weight',
  ))
    ->orderBy('weight', 'ASC')
    ->orderBy('name', 'ASC')
    ->execute();
  $profiles = $result
    ->fetchAllAssoc('pid', PDO::FETCH_ASSOC);
  if (empty($profiles)) {
    drupal_set_message(t('You have not yet defined any access profiles.'));

    // drupal_goto('admin/config/content/simple-access/profiles/add');
  }
  $form['profiles'] = array(
    '#tree' => TRUE,
  );
  foreach ($profiles as $row) {
    $form['profiles'][$row['pid']]['name'] = array(
      '#markup' => $row['name'],
    );
    $form['profiles'][$row['pid']]['weight'] = array(
      '#type' => 'weight',
      '#default_value' => $row['weight'],
      '#attributes' => array(
        'class' => array(
          'sa-profile-weight',
        ),
      ),
    );
    $form['profiles'][$row['pid']]['operations'] = array(
      '#markup' => l(t('edit'), 'admin/config/content/simple-access/profiles/' . $row['pid'] . '/edit') . ' ' . l(t('delete'), 'admin/config/content/simple-access/profiles/' . $row['pid'] . '/delete'),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
  );
  return $form;
}