Commit 67a8357b authored by Derek Wright's avatar Derek Wright
Browse files

[#397458] by dww: UI follow-up to remove the fieldset from the main table.

parent 7f11480f
Loading
Loading
Loading
Loading
+17 −19
Changes for includes/notification.inc: 17 added lines, 19 removed lines.
Original line number Diff line number Diff line
@@ -37,21 +37,19 @@ function project_issue_notification_user_form(&$form_state, $account) {
  );
  $form['#tree'] = TRUE;

  $form['project_issue_notification'] = array(
    '#type' => 'fieldset',
    '#title' => t('Issue e-mail notifications'),
    '#collapsible' => TRUE,
  $form['issue_notification_header'] = array(
    '#value' => '<h3>' . t('Issue e-mail notifications') . '</h3>',
  );

  $token = drupal_get_token('project-issue-manage-notifications');

  // Per-project notification levels.
  $form['project_issue_notification']['projects'] = array(
  $form['projects'] = array(
    '#theme' => 'project_issue_notification_projects_table',
    '#header' => array(t('Project'), t('Send e-mail'), t('Operations')),
  );

  $form['project_issue_notification']['projects']['default'] = array(
  $form['projects']['default'] = array(
    'title' => array(
      '#type' => 'item',
      '#value' => t('Default'),
@@ -61,7 +59,7 @@ function project_issue_notification_user_form(&$form_state, $account) {
      '#type' => 'select',
      '#options' => $options,
      '#default_value' => $account->project_issue_notification['level'],
      '#parents' => array('project_issue_notification', 'projects', 'default'),
      '#parents' => array('projects', 'default'),
    ),
    // We don't need any operations for this one.
    'operations' => array(),
@@ -73,7 +71,7 @@ function project_issue_notification_user_form(&$form_state, $account) {
    WHERE n.status = 1 AND pisp.uid = %d ORDER BY n.title
    ", 'n'), $account->uid);
  while ($project = db_fetch_object($result)) {
    $form['project_issue_notification']['projects'][$project->nid] = array(
    $form['projects'][$project->nid] = array(
      'title' => array(
        '#value' => l($project->title, "node/$project->nid"),
      ),
@@ -84,7 +82,7 @@ function project_issue_notification_user_form(&$form_state, $account) {
        // Adjust #parents to get a simple $project->nid => $level mapping in
        // the submit handler. Without adjustment, the value would be
        // array('level' => $level).
        '#parents' => array('project_issue_notification', 'projects', $project->nid),
        '#parents' => array('projects', $project->nid),
      ),
      'operations' => array(
        '#value' => l(t('delete'), "user/$account->uid/project-issue/delete/$project->nid", array('query' => array('token' => $token))),
@@ -92,7 +90,7 @@ function project_issue_notification_user_form(&$form_state, $account) {
    );
  }

  $form['project_issue_notification']['projects']['new'] = array(
  $form['projects']['new'] = array(
    'title' => array(
      '#type' => 'textfield',
      '#size' => 30,
@@ -154,14 +152,14 @@ function project_issue_notification_user_form(&$form_state, $account) {
 * use that in the submit handler.
 */
function project_issue_notification_user_form_validate($form, &$form_state) {
  $new_project = $form_state['values']['project_issue_notification']['projects']['new'];
  $new_project = $form_state['values']['projects']['new'];
  if (!empty($new_project['title'])) {
    $nid = db_result(db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.title = '%s' AND n.type = '%s'", 'n'), $new_project['title'], 'project_project'));
    if (empty($nid)) {
      form_set_error('project_issue_notification][projects][new][title', t('The name you entered (%title) is not a valid project.', array('%title' => $new_project['title'])));
      form_set_error('projects][new][title', t('The name you entered (%title) is not a valid project.', array('%title' => $new_project['title'])));
    }
    else {
      $form_state['values']['project_issue_notification']['projects']['new']['nid'] = $nid;
      $form_state['values']['projects']['new']['nid'] = $nid;
    }
  }
}
@@ -175,26 +173,26 @@ function project_issue_notification_user_form_submit($form, &$form_state) {

  // First, save the default setting for this user.
  $account->project_issue_notification = array(
    'level' => (int) $form_state['values']['project_issue_notification']['projects']['default'],
    'level' => (int) $form_state['values']['projects']['default'],
    'mail_body' => (int) $form_state['values']['content']['project_issue_mail_body'],
    'mail_subject_project' => (int) !empty($form_state['values']['content']['project_issue_mail_subject']['mail_subject_project']),
    'mail_subject_category' => (int) !empty($form_state['values']['content']['project_issue_mail_subject']['mail_subject_category']),
  );
  project_issue_notification_user_settings_save($account);

  unset($form_state['values']['project_issue_notification']['projects']['default']);
  unset($form_state['values']['projects']['default']);

  // Now, see if they're trying to add notifications for a new project.
  $new_project = $form_state['values']['project_issue_notification']['projects']['new'];
  $new_project = $form_state['values']['projects']['new'];
  if (!empty($new_project['nid'])) {
    project_issue_notification_project_setting_save($account->uid, $new_project['nid'], $new_project['level']);
  }
  // Either way, we're now done with this row.
  unset($form_state['values']['project_issue_notification']['projects']['new']);
  unset($form_state['values']['projects']['new']);

  // Finally, save any changes to the per-project settings.
  if (!empty($form_state['values']['project_issue_notification']['projects'])) {
    foreach ($form_state['values']['project_issue_notification']['projects'] as $nid => $level) {
  if (!empty($form_state['values']['projects'])) {
    foreach ($form_state['values']['projects'] as $nid => $level) {
      project_issue_notification_project_setting_save($account->uid, $nid, $level);
    }
  }