Commit 6bcfa4d4 authored by fago's avatar fago

#111355 by smk-ka: port of buddylist invite integration to 5.x

parent fcca422b
; $Id$
name = Buddylist Invite
description = Integrates the buddylist and invite modules.
package = Social networking
dependencies = buddylist
<?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);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment