Commit 871baf39 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Copy views for new users and users joining institutions

parent a05043e6
......@@ -259,6 +259,8 @@ class Institution {
}
insert_record('usr_institution', $userinst);
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));
activity_occurred('maharamessage', $message);
handle_event('updateuser', $userinst->usr);
db_commit();
......
......@@ -1126,9 +1126,34 @@ function create_user($user, $profile=array(), $institution=null, $remoteauth=nul
));
}
// Copy site views to the new user's profile
copy_views_for_user($user->id, get_column('view', 'id', 'institution', 'mahara', 'copynewuser', 1));
handle_event('createuser', $user);
db_commit();
return $user->id;
}
function copy_views_for_user($userid, $templateids) {
if (!$templateids) {
return;
}
require_once(get_config('libroot') . 'view.php');
foreach ($templateids as $tid) {
$template = new View($tid);
$v = new View(0, (object) array(
'template' => 0,
'numcolumns' => 3,
'owner' => $userid,
'title' => $template->get('title'),
'description' => $template->get('description'),
));
$v->commit();
$v->copy_contents($template);
$v->commit();
}
}
?>
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