/[drupal]/contributions/modules/volunteer/volunteer.module
ViewVC logotype

Diff of /contributions/modules/volunteer/volunteer.module

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

revision 1.54, Wed Mar 1 23:14:43 2006 UTC revision 1.55, Fri May 12 21:36:08 2006 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: volunteer.module,v 1.53 2006/02/12 00:59:52 killes Exp $  // $Id: volunteer.module,v 1.54 2006/03/01 23:14:43 killes Exp $
3    
4    
5  /**  /**
# Line 48  function volunteer_settings() { Line 48  function volunteer_settings() {
48    $wildcards = implode(', ',array_keys($variables));    $wildcards = implode(', ',array_keys($variables));
49    
50    //end set all_volunteer_coordinators    //end set all_volunteer_coordinators
51    $group = form_radios(t('Events volunteer-enabled by default'), 'volunteer_event_default', variable_get('volunteer_event_default',1), array('no','yes'), t('Should events be volunteer-enabled (with these settings) by default?'));    $form['default_settings'] = array(
52    $group .= form_textfield(t('Default number of volunteers wanted'), 'volunteer_wanted', variable_get('volunteer_wanted', '2'), 3, 6, t('This will be the default number of volunteers entered into new events.'));      '#type' => 'fieldset',
53    $group .= form_select (t('Default volunteer coordinator'), 'volunteer_coordinator', variable_get('volunteer_coordinator', ''), $all_volunteer_coordinators, t('Select the default volunteer to coordinate events'), 0, FALSE, TRUE);      '#title' => t('Default Settings'),
54    $output = form_group(t('Default Settings'), $group);    );
55      $form['default_settings']['volunteer_event_default'] = array(
56        '#type' => 'radios',
57        '#title' => t('Events volunteer-enabled by default'),
58        '#default_value' => variable_get('volunteer_event_default',1),
59        '#options' => array('no','yes'),
60        '#description' => t('Should events be volunteer-enabled (with these settings) by default?'),
61      );
62      $form['default_settings']['volunteer_wanted'] = array(
63        '#type' => 'textfield',
64        '#title' => t('Default number of volunteers wanted'),
65        '#default_value' => variable_get('volunteer_wanted', '2'),
66        '#size' => 3,
67        '#maxlength' => 6,
68        '#description' => t('This will be the default number of volunteers entered into new events.'),
69      );
70      $form['default_settings']['volunteer_coordinator'] = array(
71        '#type' => 'select',
72        '#title' => t('Default volunteer coordinator'),
73        '#default_value' => variable_get('volunteer_coordinator', ''),
74        '#options' => $all_volunteer_coordinators,
75        '#description' => t('Select the default volunteer to coordinate events'),
76        '#extra' => 0,
77        '#multiple' => FALSE,
78        '#required' => TRUE,
79      );
80    
81    if (module_exist('civicrm')) {    if (module_exist('civicrm')) {
82      civicrm_initialize(TRUE);      civicrm_initialize(TRUE);
# Line 64  function volunteer_settings() { Line 89  function volunteer_settings() {
89        foreach ($groups as $group) {        foreach ($groups as $group) {
90          $contact_sources[$group->id] = $group->title;          $contact_sources[$group->id] = $group->title;
91        }        }
92        $group_form .= form_select (t('Add/Update contacts to CiviCRM group when volunteering'), 'volunteer_contact_source', variable_get('volunteer_contact_source',''), $contact_sources, t('Select a CiviCRM group for users to be added or updated to as contacts when volunteering for an event. You can <a href="%url">add</a> a volunteer specific group. You can later see a list of all users that volunteered by selecting the chosen group from <a href="%search">this page</a> and clicking Show Group Members.', array('%url' => url('civicrm/group/add'), '%search' => url('civicrm/group'))), 0, FALSE, TRUE);        $form['contact_settings'] = array(
93            '#type' => 'fieldset',
94            '#title' => t('Contact Settings'),
95          );
96          $form['contact_settings']['volunteer_contact_source'] = array(
97            '#type' => 'select',
98            '#title' => t('Add/Update contacts to CiviCRM group when volunteering'),
99            '#default_value' => variable_get('volunteer_contact_source',''),
100            '#options' => $contact_sources,
101            '#description' => t('Select a CiviCRM group for users to be added or updated to as contacts when volunteering for an event. You can <a href="%url">add</a> a volunteer specific group. You can later see a list of all users that volunteered by selecting the chosen group from <a href="%search">this page</a> and clicking Show Group Members.', array('%url' => url('civicrm/group/add'), '%search' => url('civicrm/group'))),
102            '#extra' => 0,
103            '#multiple' => FALSE,
104            '#required' => TRUE,
105          );
106      }      }
107      else {      else {
108        drupal_set_message(t('You need to <a href="%url">define</a> a CiviCRM group for use with volunteer module.', array('%url' => url('civicrm/group/add'))), 'error');        drupal_set_message(t('You need to <a href="%url">define</a> a CiviCRM group for use with volunteer module.', array('%url' => url('civicrm/group/add'))), 'error');
# Line 81  function volunteer_settings() { Line 119  function volunteer_settings() {
119        foreach ($ufGroups as $id => $title) {        foreach ($ufGroups as $id => $title) {
120          $profile = crm_uf_get_profile_fields($id, TRUE);          $profile = crm_uf_get_profile_fields($id, TRUE);
121          $has_correct_email = FALSE;          $has_correct_email = FALSE;
122          foreach($profile as $field) {          foreach ($profile as $field) {
123            if (strpos($field['name'], 'email-') === 0) {            if (strpos($field['name'], 'email') === 0) {
124              $email_exists = TRUE;              $email_exists = TRUE;
125              if ($field['is_required'] == 1) {              if ($field['is_required'] == 1) {
126                $has_correct_email = TRUE;                $has_correct_email = TRUE;
# Line 97  function volunteer_settings() { Line 135  function volunteer_settings() {
135        db_set_active();        db_set_active();
136        if ($email_exists) {        if ($email_exists) {
137          if ($correct_email_exists) {          if ($correct_email_exists) {
138            $group_form .= form_select(t('CiviCRM profile form for volunteers'), 'volunteer_form', variable_get('volunteer_form', ''), $forms, t('Select a CiviCRM Profile form for volunteers. Users will fill out required fields in this form when volunteering for an event. You can <a href="%url">add</a> a volunteer specific profile. The profile needs at least an email field and it needs to be set to "Required" and "Active".', array('%url' => url('civicrm/admin/uf/group'))), 0, FALSE, TRUE);            $form['contact_settings']['volunteer_form'] = array(
139                '#type' => 'select',
140                '#title' => t('CiviCRM profile form for volunteers'),
141                '#default_value' => variable_get('volunteer_form', ''),
142                '#options' => $forms,
143                '#description' => t('Select a CiviCRM Profile form for volunteers. Users will fill out required fields in this form when volunteering for an event. You can <a href="%url">add</a> a volunteer specific profile. The profile needs at least an email field and it needs to be set to "Required" and "Active".', array('%url' => url('civicrm/admin/uf/group'))),
144                '#extra' => 0,
145                '#multiple' => FALSE,
146                '#required' => TRUE,
147              );
148          }          }
149          else {          else {
150            drupal_set_message(t('You need to <a href="%url">define</a> a CiviCRM profile for use with the volunteer module. The profile needs at least an email field and it needs to be set to "Required" and "Active". A profile with an email field could be found, but it does not have the correct settings. ', array('%url' => url('civicrm/admin/uf/group'))), 'error');            drupal_set_message(t('You need to <a href="%url">define</a> a CiviCRM profile for use with the volunteer module. The profile needs at least an email field and it needs to be set to "Required" and "Active". A profile with an email field could be found, but it does not have the correct settings. ', array('%url' => url('civicrm/admin/uf/group'))), 'error');
# Line 110  function volunteer_settings() { Line 157  function volunteer_settings() {
157      else {      else {
158        drupal_set_message(t('You need to <a href="%url">define</a> a CiviCRM profile for use with the volunteer module. The profile needs at least an email field and it needs to be set to "Required" and "Active".', array('%url' => url('civicrm/admin/uf/group'))), 'error');        drupal_set_message(t('You need to <a href="%url">define</a> a CiviCRM profile for use with the volunteer module. The profile needs at least an email field and it needs to be set to "Required" and "Active".', array('%url' => url('civicrm/admin/uf/group'))), 'error');
159      }      }
     $output .= form_group(t('Contact Settings'), $group_form);  
160    }    }
161    else {    else {
162      drupal_set_message(t('You need to enable the CiviCRM module in order to use the volunteer module.'), 'error');      drupal_set_message(t('You need to enable the CiviCRM module in order to use the volunteer module.'), 'error');
163    }    }
164      $form['message_settings'] = array(
165        '#type' => 'fieldset',
166        '#title' => t('Message Settings'),
167        '#prefix' => '<p>'. t("NOTE - wildcards are <b>inactive</b> for these messages.") .'</p>',
168      );
169      $form['message_settings']['volunteer_message_sign_up'] = array(
170        '#type' => 'textarea',
171        '#title' => t('Volunteer message'),
172        '#default_value' => variable_get('volunteer_message_sign_up', t('Fill out this quick form to volunteer for this event.')),
173        '#cols' => 75,
174        '#rows' => 5,
175        '#description' => t('Message to display when volunteers are signing up'),
176      );
177      $form['message_settings']['volunteer_message_thanks'] = array(
178        '#type' => 'textarea',
179        '#title' => t('Volunteer thank you message'),
180        '#default_value' => variable_get('volunteer_message_thanks', t('Thank you for offering to volunteer! Someone will be in touch with you shortly with details.')),
181        '#cols' => 75,
182        '#rows' => 5,
183        '#description' => t('Message to display to user after they have signed up to volunteer for an event.'),
184      );
185    
186    $group = form_textarea (t('Volunteer message'), 'volunteer_message_sign_up', variable_get('volunteer_message_sign_up', t('Fill out this quick form to volunteer for this event.')), 75, 5, t('Message to display when volunteers are signing up'));    $form['email_settings'] = array(
187    $group .= form_textarea (t('Volunteer thank you message'), 'volunteer_message_thanks', variable_get('volunteer_message_thanks', t('Thank you for offering to volunteer! Someone will be in touch with you shortly with details.')), 75, 5, t('Message to display to user after they have signed up to volunteer for an event.'));      '#type' => 'fieldset',
188    $group .= '<p>'. t("NOTE - wildcards are <b>inactive</b> for these messages.") .'</p>';      '#title' => t('Email Settings'),
189    $output .= form_group(t('Message Settings'), $group);      '#prefix' => '<p>'. t("FYI - The following 'Wildcards' can be used in messages to insert live data about the volunteer event: $wildcards") .'</p>',
190      );
191    $group = form_textfield(t('Default email from address for automailer'), 'volunteer_default_from', variable_get('volunteer_default_from', 'VOLUNTEER_AUTO_MAILER'), 30, 75, t("This is the from address that the coordinator's will see when they get automated messages from the module"));    $form['email_settings']['volunteer_default_from'] = array(
192    $group .= form_textarea (t('Default message for approval'), 'volunteer_message_approve', variable_get('volunteer_message_approve', t(_volunteer_default_messages('approve'))), 75, 5, t('Default message sent to users when they have been approved to volunteer for an event'));      '#type' => 'textfield',
193    $group .= form_textarea (t('Default message for denial'), 'volunteer_message_denial', variable_get('volunteer_message_deny', t(_volunteer_default_messages('deny'))), 75, 5, t('Default message sent to users when they have been denied to volunteer for an event'));      '#title' => t('Default email from address for automailer'),
194    $group .= form_textarea (t('Default message for waiting list'), 'volunteer_message_wait', variable_get('volunteer_message_wait', t(_volunteer_default_messages('wait'))), 75, 5, t('Default message sent to users to notify them that they have been put on the wait list for an event'));      '#default_value' => variable_get('volunteer_default_from', 'VOLUNTEER_AUTO_MAILER'),
195    $group .= form_textarea (t('Default message for reminder'), 'volunteer_message_reminder', variable_get('volunteer_message_reminder', t(_volunteer_default_messages('reminder'))), 75, 5, t('Default message sent to users to remind them of event 24 hours before hand'));      '#size' => 30,
196    $group .= form_textarea (t('Default message for follow-up'), 'volunteer_message_follow_up', variable_get('volunteer_message_follow_up', t(_volunteer_default_messages('follow_up'))), 75, 5, t('Default message sent to users 24 hours after the event'));      '#maxlength' => 75,
197    $group .= '<p>'. t("FYI - The following 'Wildcards' can be used in messages to insert live data about the volunteer event: $wildcards") .'</p>';      '#description' => t("This is the from address that the coordinator's will see when they get automated messages from the module"),
198    $output .= form_group(t('Email Settings'), $group);    );
199      $form['email_settings']['volunteer_message_approve'] = array(
200    return ($output);      '#type' => 'textarea',
201        '#title' => t('Default message for approval'),
202        '#default_value' => variable_get('volunteer_message_approve', t(_volunteer_default_messages('approve'))),
203        '#cols' => 75,
204        '#rows' => 5,
205        '#description' => t('Default message sent to users when they have been approved to volunteer for an event'),
206      );
207      $form['email_settings']['volunteer_message_denial'] = array(
208        '#type' => 'textarea',
209        '#title' => t('Default message for denial'),
210        '#default_value' => variable_get('volunteer_message_deny', t(_volunteer_default_messages('deny'))),
211        '#cols' => 75,
212        '#rows' => 5,
213        '#description' => t('Default message sent to users when they have been denied to volunteer for an event'),
214      );
215      $form['email_settings']['volunteer_message_wait'] = array(
216        '#type' => 'textarea',
217        '#title' => t('Default message for waiting list'),
218        '#default_value' => variable_get('volunteer_message_wait', t(_volunteer_default_messages('wait'))),
219        '#cols' => 75,
220        '#rows' => 5,
221        '#description' => t('Default message sent to users to notify them that they have been put on the wait list for an event'),
222      );
223      $form['email_settings']['volunteer_message_reminder'] = array(
224        '#type' => 'textarea',
225        '#title' => t('Default message for reminder'),
226        '#default_value' => variable_get('volunteer_message_reminder', t(_volunteer_default_messages('reminder'))),
227        '#cols' => 75,
228        '#rows' => 5,
229        '#description' => t('Default message sent to users to remind them of event 24 hours before hand'),
230      );
231      $form['email_settings']['volunteer_message_follow_up'] = array(
232        '#type' => 'textarea',
233        '#title' => t('Default message for follow-up'),
234        '#default_value' => variable_get('volunteer_message_follow_up', t(_volunteer_default_messages('follow_up'))),
235        '#cols' => 75,
236        '#rows' => 5,
237        '#description' => t('Default message sent to users 24 hours after the event'),
238      );
239    
240      return $form;
241  }  }
242    
243  /**  /**
# Line 149  function volunteer_perm() { Line 256  function volunteer_perm() {
256  function volunteer_link($type, $node = 0, $main = 0) {  function volunteer_link($type, $node = 0, $main = 0) {
257    switch ($type) {    switch ($type) {
258    case 'node' :    case 'node' :
259      if (module_invoke('event','is_enabled', $node->type)) {      if (module_invoke('event', 'is_enabled', $node->type)) {
260        if (volunteer_event_is_volunteer($node)) {        if (volunteer_event_is_volunteer($node)) {
261          if (volunteer_count($node->nid) >= $node->volunteer['wanted']) {          if (volunteer_count($node->nid) >= $node->volunteer['wanted']) {
262             $links[] = l(t('volunteer (full)'), "volunteer/volunteer/$node->nid/wait_list", array("title" => t('you can volunteer for this event, but the event is already full.')) );             $links[] = l(t('volunteer (full)'), "volunteer/volunteer/$node->nid/wait_list", array("title" => t('you can volunteer for this event, but the event is already full.')) );
# Line 204  function volunteer_menu($may_cache) { Line 311  function volunteer_menu($may_cache) {
311                         'callback' => 'volunteer_overview',                         'callback' => 'volunteer_overview',
312                         'access' => user_access('volunteer coordinate'));                         'access' => user_access('volunteer coordinate'));
313      }      }
314      elseif(arg(0)=='node' && is_numeric(arg(1))) {      elseif (arg(0)=='node' && is_numeric(arg(1))) {
315        $node = node_load(array('nid'=>arg(1)));        $node = node_load(array('nid'=>arg(1)));
316        if (function_exists('event_is_enabled') && event_is_enabled($node->type)) {        if (function_exists('event_is_enabled') && event_is_enabled($node->type)) {
317          $items[] = array('path' => 'node/'. arg(1) .'/volunteer', 'title' => t('volunteer admin'),          $items[] = array('path' => 'node/'. arg(1) .'/volunteer', 'title' => t('volunteer admin'),
# Line 281  function volunteer_overview() { Line 388  function volunteer_overview() {
388      $new_rows[] = $row;      $new_rows[] = $row;
389    }    }
390    
391    if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) {    if ($pager = theme('pager', NULL, 50, 0)) {
392      $new_rows[] = array(array('data' => $pager, 'colspan' => '3'));      $new_rows[] = array(array('data' => $pager, 'colspan' => '3'));
393    }    }
394    
# Line 290  function volunteer_overview() { Line 397  function volunteer_overview() {
397    }    }
398    
399    drupal_set_title(t('Volunteer Overview'));    drupal_set_title(t('Volunteer Overview'));
400    print theme('page',  theme('table', $header, $new_rows));    print theme('page', theme('table', $header, $new_rows));
401  }  }
402    
403  function volunteer_question_coordinator($cid, $nid) {  function volunteer_question_coordinator($cid, $nid) {
# Line 319  function volunteer_question_coordinator( Line 426  function volunteer_question_coordinator(
426    }    }
427    else {    else {
428      $rating = volunteer_get_rating($cid);      $rating = volunteer_get_rating($cid);
429      $output = form_item(t('Avg. Rating'), l($rating['average'], "volunteer/rating/$cid/$node->nid"));      $form['average'] = array(
430          '#type' => 'item',
431          '#title' => t('Avg. Rating'),
432          '#default_value' => l($rating['average'], "volunteer/rating/$cid/$node->nid"),
433        );
434      $form_title = variable_get('volunteer_form', '');      $form_title = variable_get('volunteer_form', '');
435      db_set_active('civicrm');      db_set_active('civicrm');
436      $title = crm_uf_get_profile_title($form_title);      $title = crm_uf_get_profile_title($form_title);
437      $output .= crm_uf_get_profile_html( $cid, $title, CRM_CORE_ACTION_VIEW, false, true );      $output .= crm_uf_get_profile_html( $cid, $title, CRM_CORE_ACTION_VIEW, false, true );
438      db_set_active();      db_set_active();
439      $form .= form_submit(t('Approve'));      $form['approve'] = array(
440      $form .= form_submit(t('Wait List'));        '#type' => 'submit',
441      $form .= form_submit(t('Deny'));        '#value' => t('Approve'),
442      $form .= form_submit(t('Cancel'));      );
443      $output .= form($form);      $form['wait_list'] = array(
444          '#type' => 'submit',
445          '#value' => t('Wait List'),
446        );
447        $form['deny'] = array(
448          '#type' => 'submit',
449          '#value' => t('Deny'),
450        );
451        $form['cancel'] = array(
452          '#type' => 'submit',
453          '#value' => t('Cancel'),
454        );
455    }    }
456    
457    drupal_set_title(t('Volunteer Status'));    drupal_set_title(t('Volunteer Status'));
458    print theme('page', $output);    print theme('page', drupal_get_form('volunteer_question_coordinator', $form));
459  }  }
460    
461  /********************************/  /********************************/
# Line 476  function volunteer_volunteer_form($nid, Line 598  function volunteer_volunteer_form($nid,
598    else {    else {
599      //Either an error occurred, or we haven't      //Either an error occurred, or we haven't
600      //done anything yet.      //done anything yet.
     $form = $crm_form;  
     $form .= form_submit(t('Volunteer'));  
601      $url = url("volunteer/volunteer/$nid");      $url = url("volunteer/volunteer/$nid");
602      return form($form, 'post', $url);      $form = $crm_form;
603        $form['#method'] = 'post';
604        $form['#action'] = $url;
605        $form['submit'] = array(
606          '#type' => 'submit',
607          '#value' => t('Volunteer'),
608        );
609    
610        return drupal_get_form('volunteer_volunteer_form', $form);
611    }    }
612  }  }
613    
# Line 504  function volunteer_rate($cid, $nid = 0) Line 632  function volunteer_rate($cid, $nid = 0)
632                              3 => 3,                              3 => 3,
633                              4 => 4,                              4 => 4,
634                              5 => 5);                              5 => 5);
635        $form .= form_select(t('Rating'), 'rating', $volunteer_contact_event->rating, $rating_list, '1 being the worst and 5 being the best.');        $form['#method'] = 'post';
636        $form .= form_textarea(t('Comments'), 'comments', $volunteer_contact_event->comments, 70, 5, 'Leave comment specific to this event here');        $form['#action'] = url("volunteer/rating/$cid/$nid");
637        $form .= form_submit(t('Submit'));        $form[$event->title] = array(
638        $form = form_group($event->title, $form);          '#type' => 'fieldset',
639        $output = form($form, 'post', url("volunteer/rating/$cid/$nid"));          '#title' => $event->title,
640          );
641          $form[$event->title]['rating'] = array(
642            '#type' => 'select',
643            '#title' => t('Rating'),
644            '#default_value' => $volunteer_contact_event->rating,
645            '#options' => $rating_list,
646            '#description' => '1 being the worst and 5 being the best.',
647          );
648          $form[$event->title]['comments'] = array(
649            '#type' => 'textarea',
650            '#title' => t('Comments'),
651            '#default_value' => $volunteer_contact_event->comments,
652            '#cols' => 70,
653            '#rows' => 5,
654            '#description' => 'Leave comment specific to this event here',
655          );
656          $form[$event->title]['submit'] = array(
657            '#type' => 'submit',
658            '#value' => t('Submit'),
659          );
660      }      }
661      // output view of past ratings      // output view of past ratings
662      $data = volunteer_get_rating($cid);      $data = volunteer_get_rating($cid);
663      if(count($data['events'])) {      if (count($data['events'])) {
664        $header = array('Event', 'Rating', 'Coordinator', 'Comments');        $header = array('Event', 'Rating', 'Coordinator', 'Comments');
665        $output .= form_group(t('Other Events which %name has volunteered for:', array('%name'=>$mail)), theme('table', $header, $data['events']));        $form['other_events'] = array(
666            '#type' => 'fieldset',
667            '#title' => t('Other Events which %name has volunteered for:', array('%name'=>$mail)),
668          );
669          $form['other_events']['events'] = array(
670            '#value' => theme('table', $header, $data['events']),
671          );
672      }      }
673    
674        print theme('page', drupal_get_form('volunteer_rate', $form), t('Rate Volunteer'));
     print theme('page', $output, t('Rate Volunteer'));  
675    }    }
676    else{    else{
677      db_query("UPDATE {volunteer_contact_event} SET comments = '%s', rating = %d WHERE cid = %d AND nid = %d", $_POST['edit']['comments'], $_POST['edit']['rating'], $cid, $nid);      db_query("UPDATE {volunteer_contact_event} SET comments = '%s', rating = %d WHERE cid = %d AND nid = %d", $_POST['edit']['comments'], $_POST['edit']['rating'], $cid, $nid);
# Line 754  function volunteer_approve_volunteer($ci Line 907  function volunteer_approve_volunteer($ci
907    }    }
908    else {    else {
909      drupal_set_message(t('Event overloaded'));      drupal_set_message(t('Event overloaded'));
910      $form .= form_submit (t('Cancel'));      $form['overload'] = array(
911      $form .= form_submit (t('Overload'));        '#type' => 'fieldset',
912      $form = form(form_group(t('Would you like to overload the event?'), $form));        '#title' => t('Would you like to overload the event?'),
913      return $form;      );
914        $form['cancel'] = array(
915          '#type' => 'submit',
916          '#value' => t('Cancel'),
917        );
918        $form['overload'] = array(
919          '#type' => 'submit',
920          '#value' => t('Overload'),
921        );
922        return drupal_get_form('overload_event', $form);
923    }    }
924  }  }
925    
# Line 859  function volunteer_form() { Line 1021  function volunteer_form() {
1021      $all_volunteer_coordinators[$user->uid] = $user->name;      $all_volunteer_coordinators[$user->uid] = $user->name;
1022    }    }
1023    if (volunteer_event_is_volunteer($node)) {    if (volunteer_event_is_volunteer($node)) {
1024      $output = form_group(t('Volunteer Status'), volunteer_initial_user_view($node).volunteer_view_volunteers($node));      $form['volunteer_status'] = array(
1025    }        '#type' => 'fieldset',
1026    $output .= form_textfield(t('Number of volunteers wanted for \'%title\'', array('%title' => $node->title)), 'volunteer_wanted', isset($edit['volunteer_wanted']) ? $edit['volunteer_wanted'] : $node->volunteer['wanted'], 3, 6, t('To remove all volunteering from this event set the number of volunteers wanted to 0.'));        '#title' => t('Volunteer Status'),
1027    $output .= form_select (t('Volunteer Coordinator'), 'volunteer_coordinator', isset($edit['volunteer_coordinator']) ? $edit['volunteer_coordinator'] : $node->volunteer['coordinator'], $all_volunteer_coordinators, t('Select the volunteer to coordinate this event.'), 0, FALSE, TRUE);      );
1028    $output .= form_textarea (t('Custom message for approval'), 'volunteer_message_approve', isset($edit['volunteer_message_approve']) ? $edit['volunteer_message_approve'] : $node->volunteer['message_approve'], 75, 5, t('Custom message sent to users when they have been approved to volunteer for an event'));      $form['volunteer_status']['status'] = array(
1029    $output .= form_textarea (t('Custom message for denial'), 'volunteer_message_denial', isset($edit['volunteer_message_denial']) ? $edit['volunteer_message_denial'] : $node->volunteer['message_deny'], 75, 5, t('Custom message sent to users when they have been denied to volunteer for an event'));        '#value' => volunteer_initial_user_view($node).volunteer_view_volunteers($node),
1030    $output .= form_textarea (t('Custom message for waiting list'), 'volunteer_message_wait', isset($edit['volunteer_message_wait']) ? $edit['volunteer_message_wait'] : $node->volunteer['message_wait'], 75, 5, t('Custom message sent to users to notify them that they have been put on the wait list for an event'));      );
1031    $output .= form_textarea (t('Custom message for reminder'), 'volunteer_message_reminder', isset($edit['volunteer_message_reminder']) ? $edit['volunteer_message_reminder'] : $node->volunteer['message_reminder'], 75, 5, t('Custom message sent to users to remind them of event 24 hours before hand'));    }
1032    $output .= form_textarea (t('Custom message for follow-up'), 'volunteer_message_follow', isset($edit['volunteer_message_follow']) ? $edit['volunteer_message_follow'] : $node->volunteer['message_follow_up'], 75, 5, t('Custom message sent to users 24 hours after the event'));    $form['volunteer_wanted'] = array(
1033    $output .= form_submit(t('Submit'));      '#type' => 'textfield',
1034        '#title' => t('Number of volunteers wanted for \'%title\'', array('%title' => $node->title)),
1035        '#default_value' => isset($edit['volunteer_wanted']) ? $edit['volunteer_wanted'] : $node->volunteer['wanted'],
1036        '#size' => 3,
1037        '#maxlength' => 6,
1038        '#description' => t('To remove all volunteering from this event set the number of volunteers wanted to 0.'),
1039      );
1040      $form['volunteer_coordinator'] = array(
1041        '#type' => 'select',
1042        '#title' => t('Volunteer Coordinator'),
1043        '#default_value' => isset($edit['volunteer_coordinator']) ? $edit['volunteer_coordinator'] : $node->volunteer['coordinator'],
1044        '#options' => $all_volunteer_coordinators,
1045        '#description' => t('Select the volunteer to coordinate this event.'),
1046        '#extra' => 0,
1047        '#multiple' => FALSE,
1048        '#required' => TRUE,
1049      );
1050      $form['volunteer_message_approve'] = array(
1051        '#type' => 'textarea',
1052        '#title' => t('Custom message for approval'),
1053        '#default_value' => isset($edit['volunteer_message_approve']) ? $edit['volunteer_message_approve'] : $node->volunteer['message_approve'],
1054        '#cols' => 75,
1055        '#rows' => 5,
1056        '#description' => t('Custom message sent to users when they have been approved to volunteer for an event'),
1057      );
1058      $form['volunteer_message_denial'] = array(
1059        '#type' => 'textarea',
1060        '#title' => t('Custom message for denial'),
1061        '#default_value' => isset($edit['volunteer_message_denial']) ? $edit['volunteer_message_denial'] : $node->volunteer['message_deny'],
1062        '#cols' => 75,
1063        '#rows' => 5,
1064        '#description' => t('Custom message sent to users when they have been denied to volunteer for an event'),
1065      );
1066      $form['volunteer_message_wait'] = array(
1067        '#type' => 'textarea',
1068        '#title' => t('Custom message for waiting list'),
1069        '#default_value' => isset($edit['volunteer_message_wait']) ? $edit['volunteer_message_wait'] : $node->volunteer['message_wait'],
1070        '#cols' => 75,
1071        '#rows' => 5,
1072        '#description' => t('Custom message sent to users to notify them that they have been put on the wait list for an event'),
1073      );
1074      $form['volunteer_message_reminder'] = array(
1075        '#type' => 'textarea',
1076        '#title' => t('Custom message for reminder'),
1077        '#default_value' => isset($edit['volunteer_message_reminder']) ? $edit['volunteer_message_reminder'] : $node->volunteer['message_reminder'],
1078        '#cols' => 75,
1079        '#rows' => 5,
1080        '#description' => t('Custom message sent to users to remind them of event 24 hours before hand'),
1081      );
1082      $form['volunteer_message_follow'] = array(
1083        '#type' => 'textarea',
1084        '#title' => t('Custom message for follow-up'),
1085        '#default_value' => isset($edit['volunteer_message_follow']) ? $edit['volunteer_message_follow'] : $node->volunteer['message_follow_up'],
1086        '#cols' => 75,
1087        '#rows' => 5,
1088        '#description' => t('Custom message sent to users 24 hours after the event'),
1089      );
1090      $form['submit'] = array(
1091        '#type' => 'submit',
1092        '#value' => t('Submit'),
1093      );
1094    
1095    drupal_set_title($node->title);    drupal_set_title($node->title);
1096    print theme('page', form($output));    print theme('page', drupal_get_form('volunteer_form', $form));
1097  }  }
1098    
1099  function theme_volunteer_calendar_link($type, $nid) {  function theme_volunteer_calendar_link($type, $nid) {
# Line 948  function volunteer_get_properties($conta Line 1170  function volunteer_get_properties($conta
1170    return $new_contact;    return $new_contact;
1171  }  }
1172    
1173    /**
1174     * Implementation of hook_form_alter().
1175     */
1176    function volunteer_form_alter($form_id, &$form) {
1177      // Check for module dependencies
1178      if ($form_id == 'system_modules' && !$_POST) {
1179        volunteer_system_module_validate($form);
1180      }
1181    }
1182    
1183    
1184    /**
1185     * Module dependency checker
1186     */
1187    function volunteer_system_module_validate(&$form) {
1188      $module = 'volunteer';
1189      $dependencies = array('civicrm');
1190    
1191      foreach ($dependencies as $dependency) {
1192        if (!in_array($dependency, $form['status']['#default_value'])) {
1193          $missing_dependency = TRUE;
1194          $missing_dependency_list[] = $dependency;
1195        }
1196      }
1197    
1198      if (in_array($module, $form['status']['#default_value']) && isset($missing_dependency)) {
1199        db_query("UPDATE {system} SET status = 0 WHERE type = 'module' AND name = '%s'", $module);
1200        $key = array_search($module, $form['status']['#default_value']);
1201        unset($form['status']['#default_value'][$key]);
1202        drupal_set_message(t('The module %module was deactivated--it requires the following disabled/non-existant modules to function properly: %dependencies', array('%module' => $module, '%dependencies' => implode(', ', $missing_dependency_list))), 'error');
1203      }
1204    
1205    }
1206    
1207  // from php.net  // from php.net
1208  function _volunteer_array_mergedown() {  function _volunteer_array_mergedown() {
1209      global $outarray;      global $outarray;
# Line 967  function array_walk_recphp4(&$val,$key) Line 1223  function array_walk_recphp4(&$val,$key)
1223         $outarray[$key] = $val;         $outarray[$key] = $val;
1224     }     }
1225  }  }
 ?>  

Legend:
Removed from v.1.54  
changed lines
  Added in v.1.55

  ViewVC Help
Powered by ViewVC 1.1.2