| 1 |
<?php |
<?php |
| 2 |
// $Id: node_invite.module,v 1.11 2009/09/01 19:00:13 hadsie Exp $ |
// $Id: node_invite.module,v 1.11.2.1 2009/09/02 00:56:32 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. |
| 61 |
$items = array(); |
$items = array(); |
| 62 |
|
|
| 63 |
$items['admin/settings/node_invite'] = array( |
$items['admin/settings/node_invite'] = array( |
| 64 |
'title' => t('Node Invite'), |
'title' => 'Node Invite', |
| 65 |
'description' => t('Node Invite module is similar to RSVP. Invite people to nodes, manage your invites, etc.'), |
'description' => t('Node Invite module is similar to RSVP. Invite people to nodes, manage your invites, etc.'), |
| 66 |
'access arguments' => array('admin node invite settings'), |
'access arguments' => array('admin node invite settings'), |
| 67 |
'page callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 69 |
'file' => 'node_invite.admin.inc', |
'file' => 'node_invite.admin.inc', |
| 70 |
); |
); |
| 71 |
$items['admin/settings/node_invite/settings'] = array( |
$items['admin/settings/node_invite/settings'] = array( |
| 72 |
'title' => t('Settings'), |
'title' => 'Settings', |
| 73 |
'type' => MENU_DEFAULT_LOCAL_TASK, |
'type' => MENU_DEFAULT_LOCAL_TASK, |
| 74 |
'weight' => 0, |
'weight' => 0, |
| 75 |
); |
); |
| 76 |
$items['admin/settings/node_invite/notifications'] = array( |
$items['admin/settings/node_invite/notifications'] = array( |
| 77 |
'title' => t('Notifications'), |
'title' => 'Notifications', |
| 78 |
'type' => MENU_LOCAL_TASK, |
'type' => MENU_LOCAL_TASK, |
| 79 |
'access arguments' => array('admin node invite settings'), |
'access arguments' => array('admin node invite settings'), |
| 80 |
'page callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 83 |
'file' => 'node_invite.admin.inc', |
'file' => 'node_invite.admin.inc', |
| 84 |
); |
); |
| 85 |
$items['admin/settings/node_invite/manage'] = array( |
$items['admin/settings/node_invite/manage'] = array( |
| 86 |
'title' => t('Manage Invites'), |
'title' => 'Manage Invites', |
| 87 |
'type' => MENU_LOCAL_TASK, |
'type' => MENU_LOCAL_TASK, |
| 88 |
'access arguments' => array('manage all invites'), |
'access arguments' => array('manage all invites'), |
| 89 |
'page callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 92 |
'file' => 'node_invite.admin.inc', |
'file' => 'node_invite.admin.inc', |
| 93 |
); |
); |
| 94 |
$items['node_invite/invite/%node'] = array( |
$items['node_invite/invite/%node'] = array( |
| 95 |
'title' => t('Invite'), |
'title' => 'Invite', |
| 96 |
'type' => MENU_CALLBACK, |
'type' => MENU_CALLBACK, |
| 97 |
'access arguments' => array('invite users to invite-enabled nodes'), |
'access arguments' => array('invite users to invite-enabled nodes'), |
| 98 |
'page callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 99 |
'page arguments' => array('node_invite_send', 2), |
'page arguments' => array('node_invite_send', 2), |
| 100 |
'file' => 'node_invite.send.inc', |
'file' => 'node_invite.send.inc', |
| 101 |
); |
); |
| 102 |
$items['node_invite/rsvp/%node/%'] = array( |
$items['node_invite/rsvp/%node/%node_invite'] = array( |
| 103 |
'title' => t('Invite'), |
'title arguments' => array(2, 3), |
| 104 |
|
'title callback' => 'node_invite_rsvp_title', |
| 105 |
'type' => MENU_CALLBACK, |
'type' => MENU_CALLBACK, |
| 106 |
'access arguments' => array('respond to invites'), |
'access arguments' => array('respond to invites'), |
| 107 |
'page callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 109 |
'file' => 'node_invite.rsvp.inc', |
'file' => 'node_invite.rsvp.inc', |
| 110 |
); |
); |
| 111 |
$items['node_invite/revoke/%'] = array( |
$items['node_invite/revoke/%'] = array( |
| 112 |
'title' => t('Revoke'), |
'title' => 'Revoke', |
| 113 |
'type' => MENU_CALLBACK, |
'type' => MENU_CALLBACK, |
| 114 |
'access callback' => 'node_invite_access_revoke', |
'access callback' => 'node_invite_access_revoke', |
| 115 |
'page callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 116 |
'page arguments' => array('node_invite_revoke', 2), |
'page arguments' => array('node_invite_revoke', 2), |
| 117 |
); |
); |
| 118 |
$items['node_invite/resend/%'] = array( |
$items['node_invite/resend/%'] = array( |
| 119 |
'title' => t('Resend'), |
'title' => 'Resend', |
| 120 |
'type' => MENU_CALLBACK, |
'type' => MENU_CALLBACK, |
| 121 |
'access callback' => 'node_invite_access_resend', |
'access callback' => 'node_invite_access_resend', |
| 122 |
'page callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 130 |
'access arguments' => array('manage own invites'), |
'access arguments' => array('manage own invites'), |
| 131 |
'weight' => 2, |
'weight' => 2, |
| 132 |
); |
); |
|
/* |
|
|
$items['node_invite/resend'] = array( |
|
|
'title' => t('Invite'), |
|
|
'type' => MENU_CALLBACK, |
|
|
'access arguments' => array('invite users to invite-enabled nodes'), |
|
|
'page callback' => 'drupal_get_form', |
|
|
'page arguments' => array('node_invite_resend'), |
|
|
); |
|
|
*/ |
|
| 133 |
|
|
| 134 |
return $items; |
return $items; |
| 135 |
} |
} |
| 136 |
|
|
| 137 |
/** |
/** |
| 138 |
|
* The title callback for the rsvp page |
| 139 |
|
*/ |
| 140 |
|
function node_invite_rsvp_title($node, $invite) { |
| 141 |
|
$account = user_load($invite->uid_inviter); |
| 142 |
|
$node->invite_specific_info = array( |
| 143 |
|
'node-invite-iid' => $invite->iid, |
| 144 |
|
'node-invite-recip-name' => $invite->email_invitee, |
| 145 |
|
'node-invite-recip-mail' => $invite->email_invitee, |
| 146 |
|
'inviter-name' => $account->name, |
| 147 |
|
'inviter-mail' => $account->mail, |
| 148 |
|
); |
| 149 |
|
|
| 150 |
|
$page_title = token_replace( |
| 151 |
|
variable_get('node_invite_rsvp_page_title', NODE_INVITE_RSVP_PAGE_TITLE), |
| 152 |
|
'node', |
| 153 |
|
$node |
| 154 |
|
); |
| 155 |
|
return t($page_title); |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
/** |
| 159 |
|
* Implementation of hook_load(). |
| 160 |
|
*/ |
| 161 |
|
function node_invite_load($iid, $reset = NULL) { |
| 162 |
|
static $invite_cache = array(); |
| 163 |
|
if ($reset) { |
| 164 |
|
$invite_cache = array(); |
| 165 |
|
} |
| 166 |
|
if (!isset($invite_cache[$hash])) { |
| 167 |
|
$invite_cache[$iid] = db_fetch_object(db_query("SELECT * FROM {node_invites} WHERE iid = %d", $iid)); |
| 168 |
|
} |
| 169 |
|
return $invite_cache[$iid]; |
| 170 |
|
} |
| 171 |
|
|
| 172 |
|
/** |
| 173 |
* Implementation of hook_link(). |
* Implementation of hook_link(). |
| 174 |
*/ |
*/ |
| 175 |
function node_invite_link( $type, $node = NULL, $teaser = FALSE ) { |
function node_invite_link( $type, $node = NULL, $teaser = FALSE ) { |