| 1 |
<?php |
<?php |
| 2 |
// $Id: node_invite.module,v 1.11.2.1 2009/09/02 00:56:32 hadsie Exp $ |
// $Id: node_invite.module,v 1.11.2.2 2009/09/02 07:35:01 hadsie Exp $ |
| 3 |
/** |
/** |
| 4 |
* @file |
* @file |
| 5 |
* Provides the overall functionality for the node_invite module. |
* Provides the overall functionality for the node_invite module. |
| 158 |
/** |
/** |
| 159 |
* Implementation of hook_load(). |
* Implementation of hook_load(). |
| 160 |
*/ |
*/ |
| 161 |
function node_invite_load($iid, $reset = NULL) { |
function node_invite_load($invite_id, $reset = NULL) { |
| 162 |
static $invite_cache = array(); |
static $invite_cache = array(); |
| 163 |
if ($reset) { |
if ($reset) { |
| 164 |
$invite_cache = array(); |
$invite_cache = array(); |
| 165 |
} |
} |
| 166 |
if (!isset($invite_cache[$hash])) { |
if (!isset($invite_cache[$invite_id])) { |
| 167 |
$invite_cache[$iid] = db_fetch_object(db_query("SELECT * FROM {node_invites} WHERE iid = %d", $iid)); |
// The id can be either a hash or an iid... figure it out |
| 168 |
|
if (is_numeric($invite_id)) { |
| 169 |
|
$invite_cache[$invite_id] = db_fetch_object(db_query("SELECT * FROM {node_invites} WHERE iid = %d", $invite_id)); |
| 170 |
|
} |
| 171 |
|
else { |
| 172 |
|
$invite_cache[$invite_id] = db_fetch_object(db_query("SELECT * FROM {node_invites} WHERE hash = '%s'", $invite_id)); |
| 173 |
|
} |
| 174 |
} |
} |
| 175 |
return $invite_cache[$iid]; |
return $invite_cache[$invite_id]; |
| 176 |
} |
} |
| 177 |
|
|
| 178 |
/** |
/** |
| 452 |
if ($row = db_fetch_array($q)) { |
if ($row = db_fetch_array($q)) { |
| 453 |
$default_message = variable_get('node_invite_message_default', NODE_INVITE_MESSAGE_DEFAULT); |
$default_message = variable_get('node_invite_message_default', NODE_INVITE_MESSAGE_DEFAULT); |
| 454 |
$node = node_load($row['nid']); |
$node = node_load($row['nid']); |
| 455 |
$inviter_rsvp_url = url('node_invite/rsvp/' . $row['nid'] . '/' . $row['iid'], array('absolute' => TRUE)); |
$inviter_rsvp_url = url(node_invite_rsvp_path($row['iid']), array('absolute' => TRUE)); |
| 456 |
$new_default_message = str_replace("[inviter-rsvp-url]", $inviter_rsvp_url, $default_message); |
$new_default_message = str_replace("[inviter-rsvp-url]", $inviter_rsvp_url, $default_message); |
| 457 |
$replaced_message = token_replace($new_default_message, 'node', $node); |
$replaced_message = token_replace($new_default_message, 'node', $node); |
| 458 |
$subj = token_replace( |
$subj = token_replace( |
| 770 |
); |
); |
| 771 |
} |
} |
| 772 |
} |
} |
| 773 |
|
|
| 774 |
|
/** |
| 775 |
|
* Return the path for the RSVP page for the specified invite. |
| 776 |
|
*/ |
| 777 |
|
function node_invite_rsvp_path($invite) { |
| 778 |
|
if (!is_object($invite)) { |
| 779 |
|
$invite = node_invite_load($invite); |
| 780 |
|
} |
| 781 |
|
|
| 782 |
|
$url = 'node_invite/rsvp/' . $invite->nid . '/'; |
| 783 |
|
if (variable_get('node_invite_hash_urls', FALSE)) { |
| 784 |
|
$url .= $invite->hash; |
| 785 |
|
} |
| 786 |
|
else { |
| 787 |
|
$url .= $invite->iid; |
| 788 |
|
} |
| 789 |
|
return $url; |
| 790 |
|
} |