Skip to content

Commit b693508

Browse files
Merge remote-tracking branch 'upstream/master' into GH-3201
2 parents 1c7772f + 9386218 commit b693508

2 files changed

Lines changed: 37 additions & 21 deletions

File tree

public/main/lp/lp_add.php

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,35 @@ function activate_end_date() {
3636

3737
/* Constants and variables */
3838

39-
$is_allowed_to_edit = api_is_allowed_to_create_course();
40-
$isStudentView = filter_var($_REQUEST['isStudentView'] ?? 'false', FILTER_VALIDATE_BOOLEAN);
4139
$lpId = (int)($_REQUEST['lp_id'] ?? 0);
40+
$is_allowed_to_edit = api_is_allowed_to_edit(false, true, false, false);
41+
42+
// Only treat student view as enabled if it was explicitly passed in the URL.
43+
// This avoids picking it up from cookies/$_REQUEST.
44+
$rawQuery = $_SERVER['QUERY_STRING'] ?? '';
45+
$hasStudentViewInUrl = preg_match('/(?:^|&)isStudentView=/i', $rawQuery) === 1;
46+
$isStudentView = $hasStudentViewInUrl
47+
? filter_var($_GET['isStudentView'] ?? 'false', FILTER_VALIDATE_BOOLEAN)
48+
: false;
4249

4350
if (!$is_allowed_to_edit || $isStudentView) {
4451
$course = api_get_course_entity(api_get_course_int_id());
45-
$nodeId = method_exists($course,'getResourceNode') && $course->getResourceNode()
46-
? (int)$course->getResourceNode()->getId()
52+
$nodeId = method_exists($course, 'getResourceNode') && $course->getResourceNode()
53+
? (int) $course->getResourceNode()->getId()
4754
: 0;
4855

49-
$cid = (int)($_REQUEST['cid'] ?? api_get_course_int_id());
50-
$sid = (int)($_REQUEST['sid'] ?? api_get_session_id());
51-
$qs = ['cid' => $cid, 'isStudentView' => 'true'];
56+
$cid = (int) ($_REQUEST['cid'] ?? api_get_course_int_id());
57+
$sid = (int) ($_REQUEST['sid'] ?? api_get_session_id());
58+
59+
$qs = ['cid' => $cid];
5260
if ($sid > 0) $qs['sid'] = $sid;
53-
if (isset($_REQUEST['gid'])) $qs['gid'] = (int)$_REQUEST['gid'];
54-
if (isset($_REQUEST['gradebook'])) $qs['gradebook'] = (int)$_REQUEST['gradebook'];
61+
if (isset($_REQUEST['gid'])) $qs['gid'] = (int) $_REQUEST['gid'];
62+
if (isset($_REQUEST['gradebook'])) $qs['gradebook'] = (int) $_REQUEST['gradebook'];
63+
64+
// Preserve student view only if it was explicitly requested.
65+
if ($isStudentView) {
66+
$qs['isStudentView'] = 'true';
67+
}
5568

5669
$listUrl = api_get_path(WEB_PATH).'resources/lp/'.$nodeId.'?'.http_build_query($qs);
5770
header('Location: '.$listUrl);

src/CoreBundle/Entity/ExtraFieldOptions.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,12 @@ class ExtraFieldOptions
4545
#[Gedmo\Locale]
4646
private ?string $locale = null;
4747

48-
/**
49-
* @return int
50-
*/
51-
public function getId()
48+
public function getId(): ?int
5249
{
5350
return $this->id;
5451
}
5552

56-
/**
57-
* @return int
58-
*/
59-
public function getOptionOrder()
53+
public function getOptionOrder(): ?int
6054
{
6155
return $this->optionOrder;
6256
}
@@ -80,10 +74,7 @@ public function setField(ExtraField $field): self
8074
return $this;
8175
}
8276

83-
/**
84-
* @return string
85-
*/
86-
public function getValue()
77+
public function getValue(): ?string
8778
{
8879
return $this->value;
8980
}
@@ -131,6 +122,18 @@ public function setPriorityMessage(string $priorityMessage): self
131122
return $this;
132123
}
133124

125+
/**
126+
* Backward-compatibility alias for legacy code calling setLocale().
127+
* Gedmo Translatable expects the locale to be injected through the "Locale" field.
128+
*/
129+
public function setLocale(string $locale): self
130+
{
131+
return $this->setTranslatableLocale($locale);
132+
}
133+
134+
/**
135+
* Sets the locale used by Gedmo Translatable for this entity.
136+
*/
134137
public function setTranslatableLocale(string $locale): self
135138
{
136139
$this->locale = $locale;

0 commit comments

Comments
 (0)