/[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.55, Fri May 12 21:36:08 2006 UTC revision 1.56, Fri May 12 21:37:23 2006 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: volunteer.module,v 1.54 2006/03/01 23:14:43 killes Exp $  // $Id: volunteer.module,v 1.55 2006/05/12 21:36:08 killes Exp $
3    
4    
5  /**  /**
# Line 164  function volunteer_settings() { Line 164  function volunteer_settings() {
164    $form['message_settings'] = array(    $form['message_settings'] = array(
165      '#type' => 'fieldset',      '#type' => 'fieldset',
166      '#title' => t('Message Settings'),      '#title' => t('Message Settings'),
     '#prefix' => '<p>'. t("NOTE - wildcards are <b>inactive</b> for these messages.") .'</p>',  
167    );    );
168    $form['message_settings']['volunteer_message_sign_up'] = array(    $form['message_settings']['volunteer_message_sign_up'] = array(
169      '#type' => 'textarea',      '#type' => 'textarea',
# Line 182  function volunteer_settings() { Line 181  function volunteer_settings() {
181      '#rows' => 5,      '#rows' => 5,
182      '#description' => t('Message to display to user after they have signed up to volunteer for an event.'),      '#description' => t('Message to display to user after they have signed up to volunteer for an event.'),
183    );    );
184      $form['message_settings']['wildcards'] = array(
185        '#value' => '<p>'. t("NOTE - wildcards are <b>inactive</b> for these messages.") .'</p>',
186      );
187    
188    $form['email_settings'] = array(    $form['email_settings'] = array(
189      '#type' => 'fieldset',      '#type' => 'fieldset',
190      '#title' => t('Email Settings'),      '#title' => t('Email Settings'),
     '#prefix' => '<p>'. t("FYI - The following 'Wildcards' can be used in messages to insert live data about the volunteer event: $wildcards") .'</p>',  
191    );    );
192    $form['email_settings']['volunteer_default_from'] = array(    $form['email_settings']['volunteer_default_from'] = array(
193      '#type' => 'textfield',      '#type' => 'textfield',
# Line 236  function volunteer_settings() { Line 237  function volunteer_settings() {
237      '#rows' => 5,      '#rows' => 5,
238      '#description' => t('Default message sent to users 24 hours after the event'),      '#description' => t('Default message sent to users 24 hours after the event'),
239    );    );
240      $form['email_settings']['wildcards'] = array(
241        '#value' => '<p>'. t("FYI - The following 'Wildcards' can be used in messages to insert live data about the volunteer event: $wildcards") .'</p>',
242      );
243    
244    return $form;    return $form;
245  }  }
# Line 312  function volunteer_menu($may_cache) { Line 316  function volunteer_menu($may_cache) {
316                         'access' => user_access('volunteer coordinate'));                         'access' => user_access('volunteer coordinate'));
317      }      }
318      elseif (arg(0)=='node' && is_numeric(arg(1))) {      elseif (arg(0)=='node' && is_numeric(arg(1))) {
319        $node = node_load(array('nid'=>arg(1)));        $node = node_load(arg(1));
320        if (function_exists('event_is_enabled') && event_is_enabled($node->type)) {        if (function_exists('event_is_enabled') && event_is_enabled($node->type)) {
321          $items[] = array('path' => 'node/'. arg(1) .'/volunteer', 'title' => t('volunteer admin'),          $items[] = array('path' => 'node/'. arg(1) .'/volunteer', 'title' => t('volunteer admin'),
322                           'callback' => 'volunteer_form', 'access' => user_access('volunteer coordinate'),                           'callback' => 'volunteer_form', 'access' => user_access('volunteer coordinate'),
# Line 455  function volunteer_question_coordinator( Line 459  function volunteer_question_coordinator(
459    }    }
460    
461    drupal_set_title(t('Volunteer Status'));    drupal_set_title(t('Volunteer Status'));
462    print theme('page', drupal_get_form('volunteer_question_coordinator', $form));    return drupal_get_form('volunteer_question_coordinator', $form);
463  }  }
464    
465  /********************************/  /********************************/
# Line 477  function volunteer_volunteer($nid, $wait Line 481  function volunteer_volunteer($nid, $wait
481    global $user;    global $user;
482    $edit = $_POST['edit'];    $edit = $_POST['edit'];
483    $op = $_POST['op'];    $op = $_POST['op'];
484    
485    civicrm_initialize(TRUE);    civicrm_initialize(TRUE);
486    // Not a Drupal form, so we need to let CRM have a crack    // Not a Drupal form, so we need to let CRM have a crack
487    //at it before we do    //at it before we do
# Line 517  function volunteer_volunteer($nid, $wait Line 521  function volunteer_volunteer($nid, $wait
521     }     }
522     else {     else {
523       // display form       // display form
524        $event = node_load(array('nid' => $nid));        $event = node_load($nid);
525        $output = '<p>'.        $form['#prefix'] = '<p>'. variable_get('volunteer_message_sign_up', t('Fill out this quick form to volunteer for this event.')) .'</p>';
526        variable_get('volunteer_message_sign_up',        $form['crm_form'] = array(
527          t('Fill out this quick form to volunteer for this event.')) .'</p>';          '#value' => $crm_form,
528        $output .= $crm_form;        );
529        $output = theme('box', t('Volunteer for %event', array('%event' => theme('placeholder', $event->title))), $output);        $form['placeholder'] = array(
530            '#value' => theme('box', t('Volunteer for %event', array('%event' => theme('placeholder', $event->title))), $output),
531          );
532    }    }
533    drupal_set_title('Volunteering');    drupal_set_title('Volunteering');
534    print theme('page', $output);    return drupal_get_form('volunteer_volunteer', $form);
535  }  }
536    
537  /********************************/  /********************************/
# Line 598  function volunteer_volunteer_form($nid, Line 604  function volunteer_volunteer_form($nid,
604    else {    else {
605      //Either an error occurred, or we haven't      //Either an error occurred, or we haven't
606      //done anything yet.      //done anything yet.
607      $url = url("volunteer/volunteer/$nid");      $form['#action'] = url("volunteer/volunteer/$nid");
     $form = $crm_form;  
608      $form['#method'] = 'post';      $form['#method'] = 'post';
609      $form['#action'] = $url;      $form['crm_form'] = array(
610          '#value' => $crm_form,
611        );
612      $form['submit'] = array(      $form['submit'] = array(
613        '#type' => 'submit',        '#type' => 'submit',
614        '#value' => t('Volunteer'),        '#value' => t('Volunteer'),
615      );      );
616    
617      return drupal_get_form('volunteer_volunteer_form', $form);      return drupal_get_form('volunteer_form_form', $form);
618    
619    /*    // We do not use Forms API here, because CiviCRM
620        // ouputs HTML for the form
621        $output .= '<form action="'. $url. '" method="post">';
622        $output .= ;
623        $output .= '<input type="submit" value="'. t('Volunteer') .'"/>';
624        $output .= '</form>';
625    
626        return $output;
627    */
628    
629    }    }
630  }  }
631    
# Line 671  function volunteer_rate($cid, $nid = 0) Line 689  function volunteer_rate($cid, $nid = 0)
689        );        );
690      }      }
691    
692      print theme('page', drupal_get_form('volunteer_rate', $form), t('Rate Volunteer'));      return drupal_get_form('volunteer_rate', $form);
693    }    }
694    else{    else{
695      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 746  function volunteer_mail($cid, $nid, $mes Line 764  function volunteer_mail($cid, $nid, $mes
764    $vcid = db_fetch_object(db_query('SELECT uid FROM {volunteer} v WHERE nid = %d', $nid));    $vcid = db_fetch_object(db_query('SELECT uid FROM {volunteer} v WHERE nid = %d', $nid));
765    $coordinator = user_load(array('uid'=>$vcid->uid));    $coordinator = user_load(array('uid'=>$vcid->uid));
766    
767    $event = node_load(array('nid'=>$nid));    $event = node_load($nid);
768    
769    db_set_active('civicrm');    db_set_active('civicrm');
770    $volunteer = crm_get_contact(array('contact_id' => $cid));    $volunteer = crm_get_contact(array('contact_id' => $cid));
# Line 965  function volunteer_nodeapi(&$node, $op, Line 983  function volunteer_nodeapi(&$node, $op,
983          break;          break;
984        case 'insert':        case 'insert':
985          if (variable_get('volunteer_event_default',1)) {          if (variable_get('volunteer_event_default',1)) {
986            $coordinator = user_access('volunteer coordinate',$node->uid) ? $node->uid : variable_get('volunteer_coordinator', 1);            $coordinator = user_access('volunteer coordinate', $node->uid) ? $node->uid : variable_get('volunteer_coordinator', 1);
987            $result = db_query("INSERT INTO {volunteer} (nid, wanted, uid) VALUES (%d, %d, %d)", $node->nid, variable_get('volunteer_wanted',2), $coordinator);            $result = db_query("INSERT INTO {volunteer} (nid, wanted, uid) VALUES (%d, %d, %d)", $node->nid, variable_get('volunteer_wanted',2), $coordinator);
988          }          }
989          break;          break;
# Line 992  function volunteer_form() { Line 1010  function volunteer_form() {
1010    if ($nid) {    if ($nid) {
1011      switch ($op) {      switch ($op) {
1012        case t('Submit'):        case t('Submit'):
1013            $result = db_fetch_object(db_query('SELECT count(nid) as count FROM {volunteer} WHERE nid = %d', $nid));          $result = db_fetch_object(db_query('SELECT count(nid) as count FROM {volunteer} WHERE nid = %d', $nid));
1014            if ($result->count) {          if ($result->count) {
1015              db_query("UPDATE {volunteer} SET wanted = %d, uid = %d, message_approve = '%s', message_deny = '%s', message_wait = '%s', message_reminder = '%s', message_follow_up = '%s' WHERE nid = %d", $edit['volunteer_wanted'], $edit['volunteer_coordinator'], $edit['volunteer_message_approve'], $edit['volunteer_message_denial'], $edit['volunteer_message_wait'], $edit['volunteer_message_reminder'], $edit['volunteer_message_follow'], $nid);            db_query("UPDATE {volunteer} SET wanted = %d, uid = %d, message_approve = '%s', message_deny = '%s', message_wait = '%s', message_reminder = '%s', message_follow_up = '%s' WHERE nid = %d", $edit['volunteer_wanted'], $edit['volunteer_coordinator'], $edit['volunteer_message_approve'], $edit['volunteer_message_denial'], $edit['volunteer_message_wait'], $edit['volunteer_message_reminder'], $edit['volunteer_message_follow'], $nid);
1016            }          }
1017            else {          else {
1018              if ($edit['volunteer_wanted'] > 0) {            if ($edit['volunteer_wanted'] > 0) {
1019                db_query("INSERT INTO {volunteer} (nid, wanted, uid, message_approve, message_deny, message_wait, message_reminder, message_follow_up) VALUES (%d, %d, %d, '%s', '%s', '%s', '%s', '%s')", $nid, $edit['volunteer_wanted'], $edit['volunteer_coordinator'], $edit['volunteer_message_approve'], $edit['volunteer_message_denial'], $edit['volunteer_message_wait'], $edit['volunteer_message_reminder'], $edit['volunteer_message_follow']);              db_query("INSERT INTO {volunteer} (nid, wanted, uid, message_approve, message_deny, message_wait, message_reminder, message_follow_up) VALUES (%d, %d, %d, '%s', '%s', '%s', '%s', '%s')", $nid, $edit['volunteer_wanted'], $edit['volunteer_coordinator'], $edit['volunteer_message_approve'], $edit['volunteer_message_denial'], $edit['volunteer_message_wait'], $edit['volunteer_message_reminder'], $edit['volunteer_message_follow']);
             }  
1020            }            }
1021            drupal_set_message('Information Updated');          }
1022            drupal_set_message('Information Updated');
1023          break;          break;
1024      }      }
1025      $node = node_load(array('nid' => $nid));      $node = node_load($nid);
1026    
1027      // volunteer edit form      // volunteer edit form
1028      if (!isset($node->volunteer['wanted'])) {      if (!isset($node->volunteer['wanted'])) {
# Line 1093  function volunteer_form() { Line 1111  function volunteer_form() {
1111    );    );
1112    
1113    drupal_set_title($node->title);    drupal_set_title($node->title);
1114    print theme('page', drupal_get_form('volunteer_form', $form));    return drupal_get_form('volunteer_form', $form);
1115  }  }
1116    
1117  function theme_volunteer_calendar_link($type, $nid) {  function theme_volunteer_calendar_link($type, $nid) {
# Line 1111  function _volunteer_default_messages($me Line 1129  function _volunteer_default_messages($me
1129                      'deny' => 'Thanks for volunteering for %event_title. Unfortunately the event is full.  Please check back for other events.',                      'deny' => 'Thanks for volunteering for %event_title. Unfortunately the event is full.  Please check back for other events.',
1130                      'wait' => 'Thanks for volunteering!  The event is full, but we have put you on the wait-list, so cross your fingers.',                      'wait' => 'Thanks for volunteering!  The event is full, but we have put you on the wait-list, so cross your fingers.',
1131                      'reminder' => 'Hey we just wanted to remind you that the event you volunteered for is happening soon.  Thanks again for volunteering.',                      'reminder' => 'Hey we just wanted to remind you that the event you volunteered for is happening soon.  Thanks again for volunteering.',
1132                      'follow_up' => 'Thanks for volunteering.  We are hopeing that you could take a second and tell us your experience of volunteering.');                      'follow_up' => 'Thanks for volunteering.  We are hoping that you could take a second and tell us about your volunteer experience.');
1133    return $messages[$message]."\n\n-%coordinator\n\n%site_link";    return $messages[$message]."\n\n-%coordinator\n\n%site_link";
1134  }  }
1135    
# Line 1217  function _volunteer_array_mergedown() { Line 1235  function _volunteer_array_mergedown() {
1235    
1236  function array_walk_recphp4(&$val,$key) {  function array_walk_recphp4(&$val,$key) {
1237     global $outarray;     global $outarray;
1238     $val = object2array($val);     $val = (array)$val;
1239     if (is_array($val)) array_walk($val,'array_walk_recphp4');     if (is_array($val)) array_walk($val,'array_walk_recphp4');
1240     else {     else {
1241         $outarray[$key] = $val;         $outarray[$key] = $val;

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

  ViewVC Help
Powered by ViewVC 1.1.2