Commit 19cd7f72 authored by Nigel McNie's avatar Nigel McNie

Include the activity library just before calls to activity functions.

Side effect of the performance work done previously.
parent e263d34f
......@@ -219,6 +219,7 @@ function adduser_submit(Pieform $form, $values) {
$user->id = create_user($user, array(), $authinstance->institution, $authinstance, $values['remoteusername']);
if (isset($user->admin) && $user->admin) {
require_once('activity.php');
activity_add_admin_defaults(array($user->id));
}
......
......@@ -35,6 +35,7 @@ define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
define('SECTION_PAGE', 'adminusers');
require_once('pieforms/pieform.php');
require_once('activity.php');
$smarty = smarty();
// Get users who are currently administrators
......
......@@ -32,6 +32,7 @@ define('TITLE', get_string('accountsettings', 'admin'));
define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
require_once('pieforms/pieform.php');
require_once('activity.php');
$id = param_integer('id');
$user = new User;
......
......@@ -95,6 +95,7 @@ function adminusers_submit(Pieform $form, $values) {
SET admin = 1
WHERE usr IN (' . join(',', $values['users']) . ') AND institution = ' . db_quote($inst));
}
require_once('activity.php');
activity_add_admin_defaults($values['users']);
db_commit();
$SESSION->add_ok_msg(get_string('adminusersupdated', 'admin'));
......
......@@ -35,6 +35,7 @@ define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
define('SECTION_PAGE', 'staffusers');
require_once('pieforms/pieform.php');
require_once('activity.php');
$smarty = smarty();
// Get users who are currently staff
......
......@@ -938,6 +938,7 @@ function artefact_instance_from_type($artefact_type, $user_id=null) {
function artefact_watchlist_notification($artefactid) {
// gets all the views containing this artefact or a parent of this artefact and creates a watchlist activity for each view
if ($views = get_column_sql('SELECT DISTINCT view FROM {view_artefact} WHERE artefact IN (' . implode(',', array_merge(array_keys(artefact_get_parents_for_cache($artefactid)), array($artefactid))) . ')')) {
require_once('activity.php');
foreach ($views as $view) {
activity_occurred('watchlist', (object)array('view' => $view));
}
......
......@@ -93,6 +93,7 @@ function invitetogroup_submit(Pieform $form, $values) {
$data->role = $values['role'];
insert_record('group_member_invite', $data);
$lang = get_user_language($user->id);
require_once('activity.php');
activity_occurred('maharamessage',
array('users' => array($user->id),
'subject' => get_string_from_language($lang, 'invitetogroupsubject', 'group'),
......
......@@ -261,6 +261,7 @@ class Institution {
delete_records('usr_institution_request', 'usr', $userinst->usr, 'institution', $this->name);
// Copy institution views to the user's portfolio
copy_views_for_user($user->id, get_column('view', 'id', 'institution', $this->name, 'copynewuser', 1));
require_once('activity.php');
activity_occurred('maharamessage', $message);
handle_event('updateuser', $userinst->usr);
db_commit();
......@@ -287,6 +288,7 @@ class Institution {
delete_records('usr_institution_request', 'usr', $user->id);
}
insert_record('usr_institution_request', $request);
require_once('activity.php');
activity_occurred('institutionmessage', $message);
handle_event('updateuser', $user->id);
db_commit();
......@@ -305,6 +307,7 @@ class Institution {
db_begin();
delete_records('usr_institution_request', 'usr', $userid, 'institution', $this->name,
'confirmedusr', 1);
require_once('activity.php');
activity_occurred('maharamessage', $message);
handle_event('updateuser', $userid);
db_commit();
......@@ -319,6 +322,7 @@ class Institution {
'confirmedinstitution' => 1,
'ctime' => db_format_timestamp(time())
));
require_once('activity.php');
activity_occurred('institutionmessage', (object) array(
'messagetype' => 'invite',
'users' => array($userid),
......
......@@ -638,6 +638,7 @@ function suspend_user($suspendeduserid, $reason, $suspendinguserid=null) {
$message->users = array($suspendeduserid);
$message->subject = get_string_from_language($lang, 'youraccounthasbeensuspended');
$message->message = get_string_from_language($lang, 'youraccounthasbeensuspendedtext');
require_once('activity.php');
activity_occurred('maharamessage', $message);
handle_event('suspenduser', $suspendeduserid);
......@@ -661,6 +662,7 @@ function unsuspend_user($userid) {
$message->users = array($userid);
$message->subject = get_string_from_language($lang, 'youraccounthasbeenunsuspended');
$message->message = get_string_from_language($lang, 'youraccounthasbeenunsuspendedtext');
require_once('activity.php');
activity_occurred('maharamessage', $message);
handle_event('unsuspenduser', $userid);
......@@ -818,6 +820,7 @@ function send_user_message($to, $message, $from=null) {
$messagepref = get_account_preference($to->id, 'messages');
if ((is_friend($from->id, $to->id) && $messagepref == 'friends') || $messagepref == 'allow' || $from->get('admin')) {
require_once('activity.php');
activity_occurred('usermessage',
array(
'userto' => $to->id,
......@@ -1122,6 +1125,7 @@ function addfriend_submit(Pieform $form, $values) {
$n->subject = get_string_from_language($lang, 'addedtofriendslistsubject', 'group');
$n->message = get_string_from_language($lang, 'addedtofriendslistmessage', 'group', $displayname, $displayname);
require_once('activity.php');
activity_occurred('maharamessage', $n);
$SESSION->add_ok_msg(get_string('friendformaddsuccess', 'group', display_name($user)));
redirect('/user/view.php?id=' . $values['id']);
......
......@@ -318,7 +318,7 @@ class View {
public function set_access($accessdata) {
global $USER;
require_once(get_config('libroot') . 'activity.php');
require_once('activity.php');
// For users who are being removed from having access to this view, they
// need to have the view and any attached artefacts removed from their
......@@ -623,6 +623,7 @@ class View {
$data = (object)array(
'view' => $this->get('id'),
);
require_once('activity.php');
activity_occurred('watchlist', $data);
if (!defined('JSON')) {
......
......@@ -91,6 +91,7 @@ function denyrequest_submit(Pieform $form, $values) {
else {
$n->message = get_string_from_language($lang, 'friendrequestrejectedmessage', 'group', $displayname);
}
require_once('activity.php');
activity_occurred('maharamessage', $n);
$SESSION->add_ok_msg(get_string('friendformrejectsuccess', 'group'));
switch (param_alpha('returnto', 'myfriends')) {
......
......@@ -91,6 +91,7 @@ function removefriend_submit(Pieform $form, $values) {
else {
$n->message = get_string_from_language($lang, 'removedfromfriendslistmessage', 'group', $displayname);
}
require_once('activity.php');
activity_occurred('maharamessage', $n);
$SESSION->add_ok_msg(get_string('friendformremovesuccess', 'group', display_name($id)));
......
......@@ -96,6 +96,7 @@ function requestfriendship_submit(Pieform $form, $values) {
else {
$n->message = get_string_from_language($lang, 'requestedfriendlistmessage', 'group', $displayname);
}
require_once('activity.php');
activity_occurred('maharamessage', $n);
$SESSION->add_ok_msg(get_string('friendformrequestsuccess', 'group', display_name($id)));
......
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