Commit 8aad351a authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Gerrit Code Review
Browse files

Merge "Bug 1863804: Adjust code to avoid Read in write context error"

parents 566e5aa3 29f9123d
......@@ -63,7 +63,7 @@ $subtype = param_alpha('subtype', '');
if (isset($institution)) {
if (!$USER->get('admin') && !$USER->is_institutional_admin($institution) &&
$USER->is_institutional_staff($institution) && empty(get_config('staffstats')) && !empty(get_config('staffreports'))) {
$USER->is_institutional_staff($institution) && empty($allstaffstats) && !empty($userstaffstats)) {
// we need to give them the correct default report
$subtype = !empty($subtype) ? $subtype : 'information';
}
......
......@@ -2115,8 +2115,9 @@ function login_submit(Pieform $form, $values) {
if ($requesturi == '/' || $requesturi == '/index.php') {
// we are going to the homepage
if (get_config('homepageredirect') && !empty(get_config('homepageredirecturl'))) {
$requesturi = get_config('homepageredirecturl');
$homepageredirecturl = get_config('homepageredirecturl');
if (get_config('homepageredirect') && !empty($homepageredirecturl)) {
$requesturi = $homepageredirecturl;
}
}
redirect($requesturi);
......
......@@ -207,8 +207,9 @@ if ($can_login) {
$wantsurl = $CFG->wwwroot;
}
// if redirecting to using homepage but using custom landing page
if ($wantsurl === $CFG->wwwroot && get_config('homepageredirect') && !empty(get_config('homepageredirecturl'))) {
$wantsurl = get_config('homepageredirecturl');
$homepageredirecturl = get_config('homepageredirecturl');
if ($wantsurl === $CFG->wwwroot && get_config('homepageredirect') && !empty($homepageredirecturl)) {
$wantsurl = $homepageredirecturl;
}
@session_write_close();
redirect($wantsurl);
......
......@@ -1455,7 +1455,8 @@ class User {
* admin to delete its account
*/
public function requires_delete_approval() {
$institutions = !empty($this->get('institutions')) ? array_keys($this->get('institutions')) : array('mahara');
$institutions = $this->get('institutions');
$institutions = !empty($institutions) ? array_keys($institutions) : array('mahara');
foreach ($institutions as $institution) {
$instobj = new Institution($institution);
if ($instobj->requires_user_deletion_approval()) {
......
......@@ -545,8 +545,9 @@ function editgroup_submit(Pieform $form, $values) {
);
// Check to see if the group's forum is being used as a landing page url and if the changes affect it
if ($group_data->id && get_config('homepageredirect') && !empty(get_config('homepageredirecturl'))) {
$landing = translate_landingpage_to_tags(array(get_config('homepageredirecturl')));
$homepageredirecturl = get_config('homepageredirecturl');
if ($group_data->id && get_config('homepageredirect') && !empty($homepageredirecturl)) {
$landing = translate_landingpage_to_tags(array($homepageredirecturl));
foreach ($landing as $land) {
$forumgroup = get_field('interaction_instance', 'group', 'id', $land->typeid);
if ($land->type == 'forum' && !empty($forumgroup) && $forumgroup == $group_data->id && empty($newvalues['public'])) {
......
......@@ -32,8 +32,9 @@ define('TITLE', get_string('deleteinteraction', 'group', get_string('name', 'int
// Check to see if the forum is being used as a landing page url
$landingpagenote = '';
if (get_config('homepageredirect') && !empty(get_config('homepageredirecturl'))) {
$landing = translate_landingpage_to_tags(array(get_config('homepageredirecturl')));
$homepageredirecturl = get_config('homepageredirecturl');
if (get_config('homepageredirect') && !empty($homepageredirecturl)) {
$landing = translate_landingpage_to_tags(array($homepageredirecturl));
foreach ($landing as $land) {
if ($land->type == 'forum' && $land->typeid == $id) {
$landingpagenote = get_string('islandingpage', 'admin');
......
......@@ -929,8 +929,9 @@ class InteractionForumInstance extends InteractionInstance {
db_begin();
// Check to see if the group's forum is being used as a landing page url and if the changes affect it
if (get_config('homepageredirect') && !empty(get_config('homepageredirecturl'))) {
$landing = translate_landingpage_to_tags(array(get_config('homepageredirecturl')));
$homepageredirecturl = get_config('homepageredirecturl');
if (get_config('homepageredirect') && !empty($homepageredirecturl)) {
$landing = translate_landingpage_to_tags(array($homepageredirecturl));
foreach ($landing as $land) {
if ($land->type == 'forum' && $land->typeid == $this->id) {
set_config('homepageredirecturl', null);
......
......@@ -163,7 +163,8 @@ function ensure_sanity() {
}
function get_dwoo_dir() {
return !empty(get_config('customdwoocachedir')) ? get_config('customdwoocachedir') . '/dwoo/' : get_config('dataroot') . 'dwoo/';
$custom = get_config('customdwoocachedir');
return !empty($custom) ? get_config('customdwoocachedir') . '/dwoo/' : get_config('dataroot') . 'dwoo/';
}
/**
......@@ -5705,7 +5706,8 @@ function get_institutions_to_associate() {
* @param bool $parts When true we return an array of the policy parts and when false return the policy string
*/
function get_password_policy($parts = false) {
$policy = !empty(get_config('passwordpolicy')) ? get_config('passwordpolicy') : '8_ulns';
$passwordpolicy = get_config('passwordpolicy');
$policy = !empty($passwordpolicy) ? $passwordpolicy : '8_ulns';
if ($parts) {
return explode('_', $policy);
}
......
......@@ -4702,9 +4702,11 @@ function get_report_types($institution = null) {
}
// But ignore $optgroups above if $USER is only institution staff and only allowed to see old user related reports
$allstaffstats = get_config('staffstats');
$userstaffstats = get_config('staffreports'); // The old 'Users/access list/masquerading' reports from users section
if (!empty($institution)) {
if (!$USER->get('admin') && !$USER->is_institutional_admin($institution) &&
$USER->is_institutional_staff($institution) && empty(get_config('staffstats')) && !empty(get_config('staffreports'))) {
$USER->is_institutional_staff($institution) && empty($allstaffstats) && !empty($userstaffstats)) {
$usersoptions = array(
'users_accesslist' => get_string('reportaccesslist', 'statistics'),
'users_masquerading' => get_string('reportmasquerading', 'statistics'),
......@@ -4756,11 +4758,13 @@ function userhasaccess($institution, $report) {
if ($USER->get('admin') || $USER->is_institutional_admin($institution)) {
return true;
}
if ($USER->is_institutional_staff($institution) && !empty(get_config('staffstats'))) {
$allstaffstats = get_config('staffstats');
$userstaffstats = get_config('staffreports'); // The old 'Users/access list/masquerading' reports from users section
if ($USER->is_institutional_staff($institution) && !empty($allstaffstats)) {
return true;
}
if ($USER->is_institutional_staff($institution) && empty(get_config('staffstats')) && !empty(get_config('staffreports'))) {
if ($USER->is_institutional_staff($institution) && empty($allstaffstats) && !empty($userstaffstats)) {
if (in_array($report, array('accesslist', 'masquerading', 'userdetails'))) {
return true;
}
......
......@@ -3559,7 +3559,8 @@ function isolatedinstitution_access($userid, $currentuserid = null) {
$userinsts = array_keys($userobj->get('institutions'));
$loggedininsts = array_keys($user->get('institutions'));
$ok = (empty($userinsts) && empty($loggedininsts)) ? true : false; // both users in 'mahara'
if (!$userobj->get('admin') && !$ok && empty(array_intersect($userinsts, $loggedininsts))) {
$instintersect = array_intersect($userinsts, $loggedininsts);
if (!$userobj->get('admin') && !$ok && empty($instintersect)) {
throw new AccessDeniedException(get_string('notinthesameinstitution', 'error'));
}
else {
......
......@@ -984,8 +984,9 @@ class View {
}
}
// Check if this view is being used as the custom landing page
if (get_config('homepageredirect') && !empty(get_config('homepageredirecturl'))) {
$landing = translate_landingpage_to_tags(array(get_config('homepageredirecturl')));
$homepageredirecturl = get_config('homepageredirecturl');
if (get_config('homepageredirect') && !empty($homepageredirecturl)) {
$landing = translate_landingpage_to_tags(array($homepageredirecturl));
foreach ($landing as $land) {
if ($land->type == 'view' && $land->typeid == $this->id) {
set_config('homepageredirecturl', null);
......@@ -1124,8 +1125,9 @@ class View {
$firstview->copy_access($viewids);
// Check to see if the view is being used as a landing page url and if the access changes affect it
if (get_config('homepageredirect') && !empty(get_config('homepageredirecturl'))) {
$landing = translate_landingpage_to_tags(array(get_config('homepageredirecturl')));
$homepageredirecturl = get_config('homepageredirecturl');
if (get_config('homepageredirect') && !empty($homepageredirecturl)) {
$landing = translate_landingpage_to_tags(array($homepageredirecturl));
foreach ($landing as $land) {
if ($land->type == 'view' && in_array($land->typeid, $viewids)) {
$landingproblem = true;
......
......@@ -32,8 +32,9 @@ if ($collection) {
// Check to see if the view is being used as a landing page url
$landingpagenote = '';
if (get_config('homepageredirect') && !empty(get_config('homepageredirecturl'))) {
$landing = translate_landingpage_to_tags(array(get_config('homepageredirecturl')));
$homepageredirecturl = get_config('homepageredirecturl');
if (get_config('homepageredirect') && !empty($homepageredirecturl)) {
$landing = translate_landingpage_to_tags(array($homepageredirecturl));
foreach ($landing as $land) {
if ($land->type == 'view' && $land->typeid == $viewid) {
$landingpagenote = get_string('islandingpage', 'admin');
......
Supports Markdown
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