From 6461be715c442fc3d3e3ee17da591de6f54474e9 Mon Sep 17 00:00:00 2001 From: poleumdev <64774219+poleumdev@users.noreply.github.com> Date: Mon, 1 Feb 2021 09:09:57 +0100 Subject: [PATCH] Add files via upload --- changeconversationparams.php | 7 +++---- cli/cleanuporphans.php | 1 - conversation/edit.php | 10 +++++----- db/access.php | 7 +++++++ lang/en/dialoguegrade.php | 2 ++ lang/fr/dialoguegrade.php | 3 ++- renderer.php | 23 +++++++++++++---------- version.php | 6 +++--- 8 files changed, 35 insertions(+), 24 deletions(-) diff --git a/changeconversationparams.php b/changeconversationparams.php index b6a9f88..6bbf0cd 100644 --- a/changeconversationparams.php +++ b/changeconversationparams.php @@ -119,9 +119,8 @@ if ($datas->subject != $valdefault['subject']) { $request = " UPDATE {dialoguegrade_conversations} SET subject = ? - WHERE course = ? and dialogueid = ?"; - - $DB->execute($request, array($datas->subject, $course->id, $dialogueid)); + WHERE id = ?"; + $DB->execute($request, array($datas->subject, $conversationid)); } $messageid = $conversation->__get('messageid'); @@ -206,4 +205,4 @@ function chgt_teacher($conversationid, $dialogueid, $messageid, $newteacher, $ol WHERE userid = ? and conversationid = ? and dialogueid = ? and messageid = ?"; $DB->execute($request, array($newteacher, $oldteacher, $conversationid, $dialogueid, $messageid)); -} +} \ No newline at end of file diff --git a/cli/cleanuporphans.php b/cli/cleanuporphans.php index 979e57d..7c87b9b 100644 --- a/cli/cleanuporphans.php +++ b/cli/cleanuporphans.php @@ -74,7 +74,6 @@ $starttime = microtime(); mtrace("Server Time: ".date('r')."\n"); -// Do work! $sql = "SELECT dm.* FROM {dialoguegrade_messages} dm WHERE NOT EXISTS (SELECT dc.id diff --git a/conversation/edit.php b/conversation/edit.php index a53ecaa..327efea 100644 --- a/conversation/edit.php +++ b/conversation/edit.php @@ -49,14 +49,14 @@ if ($form->is_validated()) { $conversation->save_form_data(); $conversation->send(); - $sendmessage = get_string('conversationopened', 'dialoguegrade'); - // Trigger conversation created event. - $eventparams = array( + $sendmessage = get_string('conversationopened', 'dialoguegrade'); + // Trigger conversation created event. + $eventparams = array( 'context' => $context, 'objectid' => $conversation->conversationid ); - $event = \mod_dialoguegrade\event\conversation_created::create($eventparams); - $event->trigger(); + $event = \mod_dialoguegrade\event\conversation_created::create($eventparams); + $event->trigger(); redirect($returnurl, $sendmessage); } break; // Leave switch to display form page. diff --git a/db/access.php b/db/access.php index 88638cc..671afd1 100644 --- a/db/access.php +++ b/db/access.php @@ -177,5 +177,12 @@ 'editingteacher' => CAP_ALLOW, ) ), + 'mod/dialoguegrade:modifytitle' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => array( + 'manager' => CAP_ALLOW + ) + ), ); diff --git a/lang/en/dialoguegrade.php b/lang/en/dialoguegrade.php index e021c10..5f788b2 100644 --- a/lang/en/dialoguegrade.php +++ b/lang/en/dialoguegrade.php @@ -216,3 +216,5 @@ $string['updatedialoguegrade'] = 'Changing the logbook'; $string['updateok'] = 'Modifications made'; $string['proofreader'] = 'Teacher'; +$string['helpediticon'] = 'Modify the subject and/or the corrector.'; +$string['dialoguegrade:modifytitle'] = 'Changing the title and the corrector of a log book'; \ No newline at end of file diff --git a/lang/fr/dialoguegrade.php b/lang/fr/dialoguegrade.php index cae166b..46c839a 100644 --- a/lang/fr/dialoguegrade.php +++ b/lang/fr/dialoguegrade.php @@ -221,4 +221,5 @@ $string['updatedialoguegrade'] = 'Modifier le carnet de bord'; $string['updateok'] = 'Modifications réalisées'; $string['proofreader'] = 'Correcteur'; - +$string['helpediticon'] = 'Modifier le sujet et/ou le correcteur'; +$string['dialoguegrade:modifytitle'] = 'Modifier le sujet et/ou le correcteur d\'un carnet de bord'; diff --git a/renderer.php b/renderer.php index 8d636cc..d74c65f 100644 --- a/renderer.php +++ b/renderer.php @@ -47,15 +47,17 @@ public function render_conversation(mod_dialoguegrade\conversation $conversation $html .= html_writer::start_div('conversation-heading'); $html .= html_writer::tag('span', $conversation->subject, array('style' => 'font-size: 1.75rem;')); - $html .= html_writer::start_tag('ul', array('class' => "message-actions pull-right")); - $html .= html_writer::start_tag('li'); - $editicon = html_writer::tag('i', '', array('class' => "fa fa-pencil-square-o")); - $editurl = new moodle_url('/mod/dialoguegrade/changeconversationparams.php'); - $editurl->param('id', $cm->id); - $editurl->param('conversationid', $conversation->conversationid); - $html .= html_writer::link($editurl, $editicon); - $html .= html_writer::end_tag('li'); - $html .= html_writer::end_tag('ul'); + if (has_capability('mod/dialoguegrade:modifytitle', $context)) { + $html .= html_writer::start_tag('ul', array('class' => "message-actions pull-right")); + $html .= html_writer::start_tag('li'); + $editicon = html_writer::tag('i', '', array('class' => "fa fa-pencil-square-o")); + $editurl = new moodle_url('/mod/dialoguegrade/changeconversationparams.php'); + $editurl->param('id', $cm->id); + $editurl->param('conversationid', $conversation->conversationid); + $html .= html_writer::link($editurl, $editicon, array('title' => get_string('helpediticon', 'dialoguegrade'))); + $html .= html_writer::end_tag('li'); + $html .= html_writer::end_tag('ul'); + } $html .= html_writer::end_div(); // Close header. @@ -358,8 +360,9 @@ public function render_attachments(array $attachments) { $html .= html_writer::start_tag('tbody'); $html .= html_writer::start_tag('tr'); $html .= html_writer::start_tag('td'); + $html .= html_writer::link($downloadurl, html_writer::empty_tag('img', - array('src' => $this->output->pix_url(file_mimetype_icon($mimetype)), + array('src' => $this->output->image_url(file_mimetype_icon($mimetype)), 'class' => 'icon', 'alt' => $mimetype))); $html .= html_writer::end_tag('td'); diff --git a/version.php b/version.php index c3e4d6d..b243fca 100644 --- a/version.php +++ b/version.php @@ -23,9 +23,9 @@ */ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2021010409; -$plugin->requires = 2016111500; // See http://docs.moodle.org/dev/Moodle_Versions -$plugin->component = 'mod_dialoguegrade'; // Full name of the plugin (used for diagnostics) +$plugin->version = 2021020103; +$plugin->requires = 2016111500; // See http://docs.moodle.org/dev/Moodle_Versions . +$plugin->component = 'mod_dialoguegrade'; // Full name of the plugin (used for diagnostics). $plugin->release = '1.1.0 (clone of dialogue)';// Ajout reset cours. $plugin->maturity = MATURITY_STABLE; // This version's maturity level. $plugin->dependencies = array();