/[drupal]/contributions/modules/signup/includes/node_admin_summary.inc
ViewVC logotype

Contents of /contributions/modules/signup/includes/node_admin_summary.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Mon Sep 21 05:23:02 2009 UTC (2 months, 1 week ago) by dww
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +21 -11 lines
File MIME type: text/x-php
#578592 by dww: Cleaned up and fixed the "Signup summary" at the top
of the node/N/signups/admin. The UI also makes sense now for signups
that don't count towards the signup limit (#581652).
1 <?php
2 // $Id: node_admin_summary.inc,v 1.2 2009/09/19 01:42:52 dww Exp $
3
4
5 /**
6 * @file
7 * Code related to the signup administration tab on each node.
8 */
9
10 function signup_node_admin_summary_form($form_state, $node) {
11 $form = array();
12 if ($node->signup_close_signup_limit &&
13 $node->signup_effective_total >= $node->signup_close_signup_limit
14 ) {
15 $form['status'] = array(
16 '#type' => 'item',
17 '#title' => t('Signups are'),
18 '#value' => t('Closed (limit reached)'),
19 );
20 }
21 else {
22 $form['status'] = array(
23 '#type' => 'select',
24 '#title' => t('Signups are'),
25 '#options' => array(0 => t('Closed'), 1 => t('Open')),
26 '#default_value' => $node->signup_status,
27 );
28 $form['submit'] = array(
29 '#type' => 'submit',
30 '#value' => t('Update'),
31 '#submit' => array('signup_node_admin_summary_form_submit'),
32 );
33 }
34 $form['total_signups'] = array(
35 '#type' => 'item',
36 '#title' => t('Total signups'),
37 '#value' => isset($node->signup_total) ? $node->signup_total : 0,
38 );
39 $form['slots_used'] = array(
40 '#type' => 'item',
41 '#title' => t('Signup slots used'),
42 '#value' => isset($node->signup_effective_total) ? $node->signup_effective_total : 0,
43 );
44 $form['limit'] = array(
45 '#type' => 'item',
46 '#title' => t('Signup limit'),
47 '#value' => l($node->signup_close_signup_limit, 'node/'. $node->nid .'/signups/settings', array('fragment' => 'signup-limit')),
48 );
49 $form['nid'] = array(
50 '#type' => 'value',
51 '#value' => $node->nid,
52 );
53 return $form;
54 }
55
56 function signup_node_admin_summary_form_submit($form, &$form_state) {
57 $nid = $form_state['values']['nid'];
58 $node = node_load($nid);
59 $limit_status = 0;
60 if (isset($form_state['values']['limit']) && ($form_state['values']['limit'] != $node->signup_close_signup_limit)) {
61 db_query("UPDATE {signup} SET close_signup_limit = %d WHERE nid = %d", $form_state['values']['limit'], $nid);
62 $node->signup_close_signup_limit = $form_state['values']['limit'];
63 $limit_status = _signup_check_limit($node, 'limit');
64 }
65
66 // Only consider the form's status value if the signup limit didn't
67 // touch the status already.
68 if (!$limit_status && isset($form_state['values']['status']) && ($form_state['values']['status'] != $node->signup_status)) {
69 if ($form_state['values']['status']) {
70 signup_open_signup($nid);
71 drupal_set_message(t('Signups opened for !title.', array('!title' => l($node->title, "node/$node->nid"))));
72 }
73 else {
74 signup_close_signup($nid);
75 drupal_set_message(t('Signups closed for !title.', array('!title' => l($node->title, "node/$node->nid"))));
76 }
77 }
78 }
79

  ViewVC Help
Powered by ViewVC 1.1.2