Skip to content

Commit f76ecb2

Browse files
committed
add icon to move a topic
1 parent ff4dfd5 commit f76ecb2

File tree

6 files changed

+52
-5
lines changed

6 files changed

+52
-5
lines changed

Diff for: db/access.php

+9
Original file line numberDiff line numberDiff line change
@@ -243,4 +243,13 @@
243243
),
244244
),
245245

246+
'mod/moodleoverflow:movetopic' => array(
247+
'captype' => 'write',
248+
'contextlevel' => CONTEXT_MODULE,
249+
'archetypes' => array(
250+
'teacher' => CAP_ALLOW,
251+
'editingteacher' => CAP_ALLOW,
252+
'manager' => CAP_ALLOW
253+
),
254+
),
246255
);

Diff for: lang/en/moodleoverflow.php

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
$string['moodleoverflow:reviewpost'] = 'Review (approve or reject) posts';
5757
$string['nowallsubscribed'] = 'All forums in {$a} are subscribed.';
5858
$string['nowallunsubscribed'] = 'All forums in {$a} are unsubscribed.';
59+
$string['moodleoverflow:movetopic'] = 'Move Topic to another Moddleoverflow Forum';
5960

6061
// Strings for the view.php.
6162
$string['noviewdiscussionspermission'] = 'You do not have the permission to view discussions in this forum';
@@ -339,6 +340,7 @@
339340
$string['downvote'] = 'Downvote';
340341
$string['downvotenotchangeable'] = 'Downvote (not changeable)';
341342
$string['nodownvote'] = 'No downvote';
343+
$string['movetopicicon'] = 'The icon to move a topic';
342344

343345
// Privacy.
344346
$string['privacy:metadata:core_files'] = 'Moodleoverflow stores files which have been uploaded by the user to form part of a forum post.';

Diff for: locallib.php

+10
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ function moodleoverflow_print_latest_discussions($moodleoverflow, $cm, $page = -
178178
$markallread = null;
179179
}
180180

181+
// Check wether the user can move a topic
182+
$canmovetopic = false;
183+
if ((!is_guest($context, $USER) && isloggedin()) && has_capability('mod/moodleoverflow:movetopic', $context)) {
184+
$canmovetopic = true;
185+
}
186+
181187
// Check whether the user can subscribe to the discussion.
182188
$cansubtodiscussion = false;
183189
if ((!is_guest($context, $USER) && isloggedin()) && has_capability('mod/moodleoverflow:viewdiscussion', $context)) {
@@ -346,6 +352,9 @@ function moodleoverflow_print_latest_discussions($moodleoverflow, $cm, $page = -
346352
], 'p' . $reviewinfo->first))->out(false);
347353
}
348354

355+
// build linktopopup to move a topic
356+
$linktopopup = $CFG->wwwroot . '/mod/moodleoverflow/view.php?id=' . $cm->id . '&movetopopup=' . $discussion->discussion;
357+
$preparedarray[$i]['linktopopup'] = $linktopopup;
349358
// Add all created data to an array.
350359

351360
$preparedarray[$i]['statusstarter'] = $statusstarter;
@@ -370,6 +379,7 @@ function moodleoverflow_print_latest_discussions($moodleoverflow, $cm, $page = -
370379
$mustachedata->istracked = $istracked;
371380
$mustachedata->markallread = $markallread;
372381
$mustachedata->cansubtodiscussion = $cansubtodiscussion;
382+
$mustachedata->canmovetopic = $canmovetopic;
373383

374384
// Print the template.
375385
echo $renderer->render_discussion_list($mustachedata);

Diff for: templates/discussion_list.mustache

+12-3
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,19 @@
202202
{{^ lastpostusername }}-{{/ lastpostusername }}<br />
203203
<a href="{{ lastpostlink }}">{{ lastpostdate }}</a>
204204
</td>
205+
206+
207+
<td class="discussionsubscription">
208+
{{#cansubtodiscussion}}
209+
{{{discussionsubicon}}} <br>
210+
{{/cansubtodiscussion}}
211+
{{#canmovetopic}}
212+
<a href='{{ linktopopup }}'>{{#pix}} i/arrow-right, core, {{#str}}movetopicicon, moodleoverflow{{/str}} {{/pix}}</a>
213+
{{/canmovetopic}}
214+
</td>
215+
216+
205217

206-
{{#cansubtodiscussion}}
207-
<td class="discussionsubscription">{{{discussionsubicon}}}</td>
208-
{{/cansubtodiscussion}}
209218

210219
</tr>
211220

Diff for: version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
defined('MOODLE_INTERNAL') || die();
2929

3030
$plugin->component = 'mod_moodleoverflow';
31-
$plugin->version = 2023022405;
31+
$plugin->version = 2023022406;
3232
$plugin->release = 'v4.1-r1';
3333
$plugin->requires = 2020061500; // Requires Moodle 3.9+.
3434
$plugin->maturity = MATURITY_STABLE;

Diff for: view.php

+18-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
$id = optional_param('id', 0, PARAM_INT); // Course Module ID.
3535
$m = optional_param('m', 0, PARAM_INT); // MoodleOverflow ID.
3636
$page = optional_param('page', 0, PARAM_INT); // Which page to show.
37-
37+
$movetopopup = optional_param('movetopopup', 0, PARAM_INT);
3838
// Set the parameters.
3939
$params = array();
4040
if ($id) {
@@ -114,6 +114,23 @@
114114
}
115115
}
116116

117+
if ($movetopopup) {
118+
// make a list of all moodleoverflows in the course.
119+
$forumarray = array();
120+
$currentforum = $DB->get_record('moodleoverflow_discussions', array('id' => $movetopopup), 'moodleoverflow');
121+
$forums = $DB->get_records('moodleoverflow', array('course' => $course->id));
122+
// write the moodleoverflow-names in an array.
123+
foreach ($forums as $forum) {
124+
if ($forum->id == $currentforum->moodleoverflow) {
125+
continue;
126+
} else {
127+
array_push($forumarray, $forum->name);
128+
}
129+
}
130+
// build popup
131+
132+
133+
}
117134
// Return here after posting, etc.
118135
$SESSION->fromdiscussion = qualified_me();
119136

0 commit comments

Comments
 (0)