From: Wolfgang Ziegler Date: Wed, 21 Feb 2007 17:54:01 +0000 (+0000) Subject: #111355 by smk-ka: port of buddylist invite integration to 5.x X-Git-Url: http://drupalcode.org/project/buddylist.git/commitdiff_plain/6bcfa4d4f243cc27617874d945800335416b93fb #111355 by smk-ka: port of buddylist invite integration to 5.x --- 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 @@ +'. 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()) .'

'; + case 'invite': + if (user_access('maintain buddy list')) { + return '

'. t("The people you invite will be automatically added to your @buddylist when they accept the invitation.", buddylist_translation()) .'

'; + } + 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 enable 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); + } +}