Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function rsvp_menu() {
- $items['invite'] = array (
- 'title' => 'Invite Guests',
- 'page callback' => 'rsvp_invite',
- 'access arguments' => array('administer content'),
- 'type' => MENU_CALLBACK,
- );
- \
- return $items;
- }
- /*
- * Implement hook_mail().
- */
- function rsvp_mail($key, &$message, $params) {
- switch($key) {
- case "send_invite" :
- $options = array('absolute' => TRUE);
- $message['subject'] = "An invitation for you.";
- $message['body'][] = "Hook it up!";
- $message['body'][] = url("test/url",$options); //if I remove this line everything works fine.
- dpm($message);
- break;
- }
- }
- //dpm($saccount); shows the account object as expected...
- function rsvp_mail_send($account) {
- $module = 'rsvp';
- $from = "starsinmypockets@gmail.com";
- $key = "send_invite";
- $params['account'] = $account;
- $to = $account->mail;
- $language = language_default();
- $send = TRUE;
- $result = drupal_mail($module, $key, $to, $language, $params, $from, $send);
- //dpm($result['result']);
- }
- /* menu callback */
- function rsvp_invite() {
- $guests = rsvp_query();
- foreach ($guests as $account) {
- //dpm($account);
- $result[] = rsvp_mail_send($account);
- }
- return "Unobtrusive output.";
- }
- /**
- * Return array of guests as user objects.
- */
- function rsvp_query() {
- //make sure these haven't been sent invites already..
- $result = db_query('SELECT uid FROM {users_roles} WHERE rid = :rid', array(':rid' => 4));
- foreach ($result as $row) {
- $guests[] = user_load($row->uid);
- }
- //dpm($guests);
- return $guests;
- }
- /* generate info for one-time login link */
- function rsvp_get_link($account) {
- $timestamp = REQUEST_TIME;
- $hash = md5($account->pass . $timestamp);
- $uid = (string)$account->uid;
- $path = 'http://wedding.juicywatermelon.com/rsvp/'; //. $uid . "/" . $timestamp . "/" . $hash . "/" . 'user/' . $ . '/edit/Wedding';
- $options = array('absolute' => TRUE);
- $url = url($path, $options);
- dpm($url);
- return $url;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement