Commit 2a30b1ce authored by Robert Lyon's avatar Robert Lyon Committed by Aaron Wells

Bug 1503103: Making sure the correct quota is set

behatnotneeded

Change-Id: I1aa52a076843ff0dc4dcaf86a01e76b9673885b5
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit 0a6860a9)
parent c144fcfa
...@@ -1575,6 +1575,9 @@ class LiveUser extends User { ...@@ -1575,6 +1575,9 @@ class LiveUser extends User {
* should be occasionally reloaded into the session. * should be occasionally reloaded into the session.
*/ */
public function reload_background_fields() { public function reload_background_fields() {
if ($this->id == '0') {
return;
}
$reload = array( $reload = array(
'active', 'deleted', 'expiry', 'expirymailsent', 'inactivemailsent', 'suspendedctime', 'suspendedreason', 'active', 'deleted', 'expiry', 'expirymailsent', 'inactivemailsent', 'suspendedctime', 'suspendedreason',
'suspendedcusr', 'quota', 'unread', 'suspendedcusr', 'quota', 'unread',
......
...@@ -2262,6 +2262,12 @@ function addfriend_submit(Pieform $form, $values) { ...@@ -2262,6 +2262,12 @@ function addfriend_submit(Pieform $form, $values) {
function create_user($user, $profile=array(), $institution=null, $remoteauth=null, $remotename=null, $accountprefs=array(), $quickhash=false) { function create_user($user, $profile=array(), $institution=null, $remoteauth=null, $remotename=null, $accountprefs=array(), $quickhash=false) {
db_begin(); db_begin();
if (!empty($institution)) {
if (is_string($institution)) {
$institution = new Institution($institution);
}
}
if ($user instanceof User) { if ($user instanceof User) {
$user->create(); $user->create();
$user->quota_init(); $user->quota_init();
...@@ -2276,7 +2282,11 @@ function create_user($user, $profile=array(), $institution=null, $remoteauth=nul ...@@ -2276,7 +2282,11 @@ function create_user($user, $profile=array(), $institution=null, $remoteauth=nul
$user->urlid = get_new_profile_urlid($user->urlid); $user->urlid = get_new_profile_urlid($user->urlid);
} }
if (empty($user->quota)) { if (empty($user->quota)) {
$user->quota = get_config_plugin('artefact', 'file', 'defaultquota'); $quota = get_config_plugin('artefact', 'file', 'defaultquota');
if (!empty($institution) && !empty($institution->quota)) {
$quota = min($quota, $institution->quota);
}
$user->quota = $quota;
} }
if (get_config('defaultaccountlifetime')) { if (get_config('defaultaccountlifetime')) {
// we need to set the user expiry to the site default one // we need to set the user expiry to the site default one
...@@ -2302,9 +2312,6 @@ function create_user($user, $profile=array(), $institution=null, $remoteauth=nul ...@@ -2302,9 +2312,6 @@ function create_user($user, $profile=array(), $institution=null, $remoteauth=nul
} }
if (!empty($institution)) { if (!empty($institution)) {
if (is_string($institution)) {
$institution = new Institution($institution);
}
if ($institution->name != 'mahara') { if ($institution->name != 'mahara') {
$institution->addUserAsMember($user); // uses $user->newuser $institution->addUserAsMember($user); // uses $user->newuser
if (empty($accountprefs['licensedefault'])) { if (empty($accountprefs['licensedefault'])) {
......
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