Advertisement
Guest User

Untitled

a guest
May 4th, 2011
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.08 KB | None | 0 0
  1. <?php
  2. function rsvp_menu() {
  3.   $items['invite'] = array (
  4.     'title' => 'Invite Guests',
  5.     'page callback' => 'rsvp_invite',
  6.     'access arguments' => array('administer content'),
  7.     'type' => MENU_CALLBACK,
  8.   );    
  9. \
  10.   return $items;
  11.  
  12. }
  13.  
  14. /*
  15.  * Implement hook_mail().
  16.  */
  17.  
  18. function rsvp_mail($key, &$message, $params) {
  19.    
  20.    
  21.     switch($key) {
  22.       case "send_invite" :
  23.         $options = array('absolute' => TRUE);
  24.         $message['subject'] = "An invitation for you.";
  25.         $message['body'][] = "Hook it up!";
  26.         $message['body'][] = url("test/url",$options); //if I remove this line everything works fine.
  27.         dpm($message);
  28.         break;
  29.     }
  30.   }
  31.  
  32.  
  33. //dpm($saccount); shows the account object as expected...
  34.  
  35. function rsvp_mail_send($account) {
  36.   $module = 'rsvp';
  37.   $from = "starsinmypockets@gmail.com";
  38.   $key = "send_invite";
  39.   $params['account'] = $account;
  40.   $to = $account->mail;
  41.   $language = language_default();
  42.   $send = TRUE;
  43.   $result = drupal_mail($module, $key, $to, $language, $params, $from, $send);
  44.   //dpm($result['result']);
  45. }
  46.  
  47. /* menu callback */
  48. function rsvp_invite() {
  49.   $guests = rsvp_query();
  50.   foreach ($guests as $account) {
  51.   //dpm($account);
  52.   $result[] = rsvp_mail_send($account);
  53.   }
  54.   return "Unobtrusive output.";
  55. }
  56.  
  57. /**
  58.  * Return array of guests as user objects.
  59.  */
  60. function rsvp_query() {
  61.   //make sure these haven't been sent invites already..
  62.   $result = db_query('SELECT uid FROM {users_roles} WHERE rid = :rid', array(':rid' => 4));
  63.   foreach ($result as $row) {
  64.     $guests[] = user_load($row->uid);
  65.   }  
  66.   //dpm($guests);
  67.   return $guests;
  68. }
  69.  
  70. /* generate info for one-time login link */
  71. function rsvp_get_link($account) {
  72.   $timestamp = REQUEST_TIME;
  73.   $hash = md5($account->pass . $timestamp);
  74.   $uid = (string)$account->uid;
  75.  
  76.   $path = 'http://wedding.juicywatermelon.com/rsvp/'; //. $uid . "/" . $timestamp . "/" . $hash . "/" . 'user/' . $ . '/edit/Wedding';
  77.   $options = array('absolute' => TRUE);
  78.   $url = url($path, $options);
  79.   dpm($url);
  80.   return $url;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement