summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfgang Ziegler2007-02-21 17:54:01 (GMT)
committerWolfgang Ziegler2007-02-21 17:54:01 (GMT)
commit6bcfa4d4f243cc27617874d945800335416b93fb (patch)
treecac5e11b30f254eecc3db0e3b9f5f965571f4fc0
parentfcca422b69bcc8451ad61f363d6f1bd52b03f34e (diff)
#111355 by smk-ka: port of buddylist invite integration to 5.x
-rw-r--r--contrib/buddylistinvite/buddylistinvite.info5
-rw-r--r--contrib/buddylistinvite/buddylistinvite.module50
2 files changed, 55 insertions, 0 deletions
diff --git a/contrib/buddylistinvite/buddylistinvite.info b/contrib/buddylistinvite/buddylistinvite.info
new file mode 100644
index 0000000..38c458f
--- /dev/null
+++ b/contrib/buddylistinvite/buddylistinvite.info
@@ -0,0 +1,5 @@
+; $Id$
+name = Buddylist Invite
+description = Integrates the buddylist and invite modules.
+package = Social networking
+dependencies = buddylist
diff --git a/contrib/buddylistinvite/buddylistinvite.module b/contrib/buddylistinvite/buddylistinvite.module
new file mode 100644
index 0000000..908e8e3
--- /dev/null
+++ b/contrib/buddylistinvite/buddylistinvite.module
@@ -0,0 +1,50 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_help().
+ */
+function buddylistinvite_help($section) {
+ if (!module_exists('buddylist')) {
+ return;
+ }
+ switch ($section) {
+ case 'admin/settings/userpoints':
+ return t('Integrates the @buddylist and invite modules.', buddylist_translation());
+ case 'admin/help#buddylistinvite':
+ return '<p>'. t("Whenever a person responds to an invitation from the invite module and joins the site, the inviter and invitee are added to each other's @buddylist.", buddylist_translation()) .'</p>';
+ case 'invite':
+ if (user_access('maintain buddy list')) {
+ return '<p>'. t("The people you invite will be automatically added to your @buddylist when they accept the invitation.", buddylist_translation()) .'</p>';
+ }
+ break;
+ }
+}
+
+/**
+ * Implementation of hook_form_alter().
+ */
+function buddylistinvite_form_alter($form_id, &$form) {
+ if ($form_id == 'buddylist_admin_settings') {
+ if (!module_exists('invite')) {
+ drupal_set_message(t('The buddylistinvite module depends on the invite module. Please <a href="!modules_url">enable</a> the invite module first.', array('!modules_url' => url('admin/build/modules'))), 'error');
+ }
+ }
+}
+
+/**
+ * Implementation of hook_invite().
+ * @see invite.module
+ */
+function buddylistinvite_invite($op, $args) {
+ if (!module_exists('buddylist')) {
+ return;
+ }
+
+ if ($op == 'escalate' && user_access('maintain buddy list', $args['invitee']) && user_access('maintain buddy list', $args['inviter'])) {
+ $time = time();
+ watchdog('buddylistinvite', t("Users %user1 and %user2 are becoming @buddies", array('%user1' => theme('username', $args['invitee']), '%user2' => theme('username', $args['inviter'])) + buddylist_translation()));
+ db_query('INSERT INTO {buddylist} (received, uid, buddy, timestamp) VALUES (1, %d, %d, %d)', $args['invitee']->uid, $args['inviter']->uid, $time);
+ db_query('INSERT INTO {buddylist} (received, uid, buddy, timestamp) VALUES (1, %d, %d, %d)', $args['inviter']->uid, $args['invitee']->uid, $time);
+ }
+}