Skip to content

Commit b6b6a53

Browse files
v2.0.2
Signed-off-by: Diego Andrés <diegoandres_cortes@outlook.com>
1 parent c7fe16b commit b6b6a53

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
#### 2.0.2 - 10 November 2022
4+
- ![Bug Fix](https://smftricks.com/assets/changelog/bug--minus.png) Prevent non creators from managing other users quizzes.
5+
36
#### 2.0.1 - 07 November 2022
47
- ![Bug Fix](https://smftricks.com/assets/changelog/bug--minus.png) Fixed stats issue when there are no quizzes/questions created.
58

Sources/Quiz/Quiz.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ function GetQuestionsData()
186186
{
187187
global $context;
188188

189+
// They need a quiz to access here...
190+
if (!isset($_GET['id_quiz']) || empty($_GET['id_quiz']))
191+
fatal_lang_error('no_access', false);
192+
189193
if (isset($_GET['questionId']))
190194
{
191195
QuestionScript();
@@ -810,14 +814,18 @@ function GetNewQuestionData()
810814

811815
function GetEditQuizData()
812816
{
813-
global $context;
817+
global $context, $user_info;
814818

815819
QuizScript();
816820

817821
AddShowImageScript();
818822

819823
GetQuiz($context['id_quiz']);
820824

825+
// Only the quiz creator can edit the quiz
826+
if ($user_info['id'] != $context['SMFQuiz']['quiz'][0]['creator_id'] && !allowedTo('quiz_admin'))
827+
fatal_lang_error('no_access', false);
828+
821829
// The edit quiz page also shows a list of categories, so we must get this data
822830
GetAllCategoryDetails();
823831

@@ -1009,11 +1017,20 @@ function GetKeysFromPost($id)
10091017

10101018
function GetDeleteQuizData()
10111019
{
1012-
global $context;
1020+
global $context, $user_info;
1021+
1022+
// Get the key ids for the questions to delete. This function returns a string containing a comma separated list of id's
10131023

10141024
// Get the key ids for the quiz leagues to delete. This function returns a string containing a comma separated list of id's
10151025
$deleteKeys = GetKeysFromPost('quiz');
10161026

1027+
// Get quiz info
1028+
GetQuiz($context['id_quiz']);
1029+
1030+
// Check if the user is the owner of the quiz
1031+
if ($user_info['id'] != $context['SMFQuiz']['quiz'][0]['creator_id'] && !allowedTo('quiz_admin'))
1032+
fatal_lang_error('no_access', false);
1033+
10171034
if (!empty($context['id_quiz']))
10181035
DeleteQuizes($context['id_quiz']);
10191036

Themes/default/Quiz/Quiz.template.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,10 +2263,6 @@ function template_edit_quiz()
22632263

22642264
foreach ($context['SMFQuiz']['quiz'] as $row)
22652265
{
2266-
// Only the creator should be able to edit the quiz
2267-
if ($context['user']['id'] != $row['creator_id'])
2268-
break;
2269-
22702266
echo '
22712267
<input type="hidden" name="id_quiz" value="' , $context['id_quiz'] , '"/>
22722268
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">

package-info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
44
<id>SMF_Modding:SMFQuiz</id>
55
<name>SMF Quiz</name>
6-
<version>2.0.1</version>
6+
<version>2.0.2</version>
77
<type>modification</type>
88

99
<!-- Install -->

0 commit comments

Comments
 (0)