| 1 |
<?php
|
| 2 |
// $Id: rsvp.actions.inc,v 1.1 2009/01/17 20:29:02 ulf1 Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @module rsvp_action
|
| 6 |
* @package rsvp - A drupal module developed for civicspace - a distribution of drupal.
|
| 7 |
* @description Provides rsvp actions that can be automatically called by other modules
|
| 8 |
* @author Ulf Schenk (ulf@schenkunlimited.net)
|
| 9 |
*
|
| 10 |
*/
|
| 11 |
|
| 12 |
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
| 13 |
|
| 14 |
|
| 15 |
/*
|
| 16 |
* @ingroup rsvp_action
|
| 17 |
*
|
| 18 |
* Implementation of hook_action_info()
|
| 19 |
*/
|
| 20 |
function rsvp_action_info() {
|
| 21 |
|
| 22 |
return array(
|
| 23 |
'rsvp_create_invitation_action' => array(
|
| 24 |
'description' => t('RSVP: Create invitation'),
|
| 25 |
'type' => 'node',
|
| 26 |
'configurable' => FALSE,
|
| 27 |
'hooks' => array(
|
| 28 |
'nodeapi' => array('update', 'insert'),
|
| 29 |
),
|
| 30 |
),
|
| 31 |
'rsvp_remove_invitation_action' => array(
|
| 32 |
'description' => t('RSVP: Remove invitation'),
|
| 33 |
'type' => 'node',
|
| 34 |
'configurable' => FALSE,
|
| 35 |
'hooks' => array(
|
| 36 |
'any' => TRUE,
|
| 37 |
),
|
| 38 |
),
|
| 39 |
'rsvp_add_guests_action' => array(
|
| 40 |
'description' => t('RSVP: Add guests to invitation'),
|
| 41 |
'type' => 'node',
|
| 42 |
'configurable' => FALSE,
|
| 43 |
'hooks' => array(
|
| 44 |
'any' => TRUE,
|
| 45 |
),
|
| 46 |
),
|
| 47 |
'rsvp_remove_guests_action' => array(
|
| 48 |
'description' => t('RSVP: Remove guests from invitation'),
|
| 49 |
'type' => 'node',
|
| 50 |
'configurable' => FALSE,
|
| 51 |
'hooks' => array(
|
| 52 |
'any' => TRUE,
|
| 53 |
),
|
| 54 |
),
|
| 55 |
'rsvp_send_invitations_action' => array(
|
| 56 |
'description' => t('RSVP: Send invitations to guests'),
|
| 57 |
'type' => 'node',
|
| 58 |
'configurable' => FALSE,
|
| 59 |
'hooks' => array(
|
| 60 |
'any' => TRUE,
|
| 61 |
),
|
| 62 |
),
|
| 63 |
'rsvp_send_message_action' => array(
|
| 64 |
'description' => t('RSVP: Send message to guests'),
|
| 65 |
'type' => 'node',
|
| 66 |
'configurable' => FALSE,
|
| 67 |
'hooks' => array(
|
| 68 |
'any' => TRUE,
|
| 69 |
),
|
| 70 |
),
|
| 71 |
|
| 72 |
);
|
| 73 |
}
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
/**
|
| 78 |
* A nonconfigurable Drupal action. Creates invitation
|
| 79 |
* hook = nodeapi: Create RSVP for this node
|
| 80 |
*
|
| 81 |
* Available contexts:
|
| 82 |
* $context['nid'] The node id you want to create an invitation for.
|
| 83 |
* $context['invite_text'] The invitation message you want to use.
|
| 84 |
* $context['startdate'] The startdate you want to write your invitation for (only required if you have events with multiple startdates).
|
| 85 |
*
|
| 86 |
*/
|
| 87 |
function rsvp_create_invitation_action(&$node, $context = array()) {
|
| 88 |
|
| 89 |
if (isset($node->nid)) {
|
| 90 |
rsvp_api_create_invitation($node->nid, $context['invite_text'], $context['startdate']);
|
| 91 |
}
|
| 92 |
elseif (isset($context['nid'])) {
|
| 93 |
rsvp_api_create_invitation($context['nid'], $context['invite_text'], $context['startdate']);
|
| 94 |
}
|
| 95 |
|
| 96 |
}
|
| 97 |
|
| 98 |
|
| 99 |
/**
|
| 100 |
* A nonconfigurable Drupal action. Removes an invitation
|
| 101 |
* hook = any
|
| 102 |
*
|
| 103 |
* Available contexts:
|
| 104 |
* $context['rid'] The invitation id you want to delete.
|
| 105 |
* or
|
| 106 |
* $context['nid'] The node id you want to delete the invitations for. (could potentially be multiple invitations)
|
| 107 |
*
|
| 108 |
*/
|
| 109 |
function rsvp_remove_invitation_action(&$object, $context = array()) {
|
| 110 |
|
| 111 |
if (($context['hook'] == 'node') || (isset($context['nid']))) {
|
| 112 |
|
| 113 |
if ($context['hook'] == 'node') {
|
| 114 |
$node = $object;
|
| 115 |
rsvp_api_remove_invitation(NULL, $node->nid);
|
| 116 |
}
|
| 117 |
else {
|
| 118 |
rsvp_api_remove_invitation(NULL, $context['nid']);
|
| 119 |
}
|
| 120 |
}
|
| 121 |
elseif (isset($context['rid'])) {
|
| 122 |
rsvp_api_remove_invitation($context['rid'], NULL);
|
| 123 |
}
|
| 124 |
}
|
| 125 |
|
| 126 |
/**
|
| 127 |
* A nonconfigurable Drupal action. Adds guests to an invitation (host permissions) and send the invitation message
|
| 128 |
* hook = any
|
| 129 |
*
|
| 130 |
* Required contexts:
|
| 131 |
* $context['rid'] The invitation id you want to add guests to.
|
| 132 |
* $context['guestarray'] Stringarray Contains a mix of email addresses and drupal usernames.
|
| 133 |
* $context['send_rsvp'] Boolean also send the invitations or just add the guests to the invitation.
|
| 134 |
*
|
| 135 |
*/
|
| 136 |
function rsvp_add_guests_action(&$object, $context = array()) {
|
| 137 |
|
| 138 |
if ((!isset($context['rid'])) || (!isset($context['guestarray'])) || (!isset($context['send_rsvp'])) ) {
|
| 139 |
return false;
|
| 140 |
}
|
| 141 |
|
| 142 |
rsvp_api_add_guests($context['rid'], NULL, $context['guestarray'], $context['send_rsvp']);
|
| 143 |
}
|
| 144 |
|
| 145 |
/**
|
| 146 |
* A nonconfigurable Drupal action. Remove guests from an invitation (host permissions)
|
| 147 |
* hook = any
|
| 148 |
*
|
| 149 |
* Required contexts:
|
| 150 |
* $context['rid'] The invitation id you want to add guests to.
|
| 151 |
* $context['guestarray'] Stringarray Contains a mix of email addresses, drupal usernames and hash.
|
| 152 |
*
|
| 153 |
*/
|
| 154 |
function rsvp_remove_guests_action(&$object, $context = array()) {
|
| 155 |
|
| 156 |
if ((!isset($context['rid'])) || (!isset($context['guestarray'])) ) {
|
| 157 |
return false;
|
| 158 |
}
|
| 159 |
|
| 160 |
rsvp_api_remove_guests($context['rid'], NULL, $context['guestarray']);
|
| 161 |
}
|
| 162 |
|
| 163 |
/**
|
| 164 |
* A nonconfigurable Drupal action. Sends the invitation to all invitees of an rsvp instance (host permissions).
|
| 165 |
* hook = any
|
| 166 |
*
|
| 167 |
* Required contexts:
|
| 168 |
* $context['rid'] The invitation id you want to send invitations to.
|
| 169 |
* $context['resend'] Boolean If true, sends to all guests even when received flag is already set. default: false.
|
| 170 |
*
|
| 171 |
*/
|
| 172 |
function rsvp_send_invitations_action(&$object, $context = array()) {
|
| 173 |
|
| 174 |
if (!isset($context['rid']))
|
| 175 |
return false;
|
| 176 |
|
| 177 |
$resend = (isset($context['resend'])) ? $context['resend'] : false;
|
| 178 |
|
| 179 |
rsvp_api_send_invitations($rid, NULL, $resend);
|
| 180 |
}
|
| 181 |
|
| 182 |
/**
|
| 183 |
* A nonconfigurable Drupal action. Send a message to selective guests of an invitation (host permissions).
|
| 184 |
* hook = any
|
| 185 |
*
|
| 186 |
* Required contexts:
|
| 187 |
* $context['rid'] The invitation id you want to send a message to.
|
| 188 |
* $context['audience'] Const The audience for the message (RSVP_ATT_ALL,...)
|
| 189 |
* $context['subject'] String The subject you want to send.
|
| 190 |
* $context['body'] String The body you want to send.
|
| 191 |
*
|
| 192 |
*/
|
| 193 |
function rsvp_send_message_action(&$object, $context = array()) {
|
| 194 |
|
| 195 |
if ((!isset($context['rid'])) || (!isset($context['audience'])) || (!isset($context['subject'])) || (!isset($context['body'])) ) {
|
| 196 |
return false;
|
| 197 |
}
|
| 198 |
|
| 199 |
rsvp_api_send_message($context['rid'], $context['audience'], $context['subject'], $context['body'], NULL);
|
| 200 |
}
|
| 201 |
|