Commit 44c98b7a authored by Richard Mansfield's avatar Richard Mansfield

Add events for friend requests, etc.

parent 28d7b655
......@@ -1106,6 +1106,13 @@ function xmldb_core_upgrade($oldversion=0) {
};
}
if ($oldversion < 2009070700) {
foreach (array('addfriend', 'removefriend', 'addfriendrequest', 'removefriendrequest') as $eventtype) {
$event = (object) array('name' => $eventtype);
ensure_record_exists('event_type', $event, $event);
}
}
return $status;
}
......
......@@ -1208,6 +1208,9 @@ function acceptfriend_submit(Pieform $form, $values) {
insert_record('usr_friend', $f);
db_commit();
handle_event('addfriend' array('user' => $f->usr2, 'friend' => $f->usr1));
$SESSION->add_ok_msg(get_string('friendformacceptsuccess', 'group'));
redirect('/user/view.php?id=' . $values['id']);
}
......@@ -1238,6 +1241,9 @@ function addfriend_submit(Pieform $form, $values) {
require_once('activity.php');
activity_occurred('maharamessage', $n);
handle_event('addfriend' array('user' => $f->usr2, 'friend' => $f->usr1));
$SESSION->add_ok_msg(get_string('friendformaddsuccess', 'group', display_name($user)));
redirect('/user/view.php?id=' . $values['id']);
}
......
......@@ -27,7 +27,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2009070600;
$config->version = 2009070700;
$config->release = '1.2.0alpha3dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
......@@ -93,6 +93,9 @@ function denyrequest_submit(Pieform $form, $values) {
}
require_once('activity.php');
activity_occurred('maharamessage', $n);
handle_event('removefriendrequest' array('owner' => $loggedinid, 'requester' => $id));
$SESSION->add_ok_msg(get_string('friendformrejectsuccess', 'group'));
switch (param_alpha('returnto', 'myfriends')) {
case 'find':
......
......@@ -94,6 +94,8 @@ function removefriend_submit(Pieform $form, $values) {
require_once('activity.php');
activity_occurred('maharamessage', $n);
handle_event('removefriend' array('user' => $loggedinid, 'friend' => $id));
$SESSION->add_ok_msg(get_string('friendformremovesuccess', 'group', display_name($id)));
switch (param_alpha('returnto', 'myfriends')) {
case 'find':
......
......@@ -99,6 +99,8 @@ function requestfriendship_submit(Pieform $form, $values) {
require_once('activity.php');
activity_occurred('maharamessage', $n);
handle_event('addfriendrequest' array('requester' => $loggedinid, 'owner' => $id));
$SESSION->add_ok_msg(get_string('friendformrequestsuccess', 'group', display_name($id)));
switch (param_alpha('returnto', 'myfriends')) {
case 'find':
......
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