From d825164820cb04dabd9d3b2106fcee128019a8b1 Mon Sep 17 00:00:00 2001 From: Friederike Schwager <schwager@cil.rwth-aachen.de> Date: Fri, 7 Jun 2019 13:06:20 +0200 Subject: [PATCH] cleanup: remove commented out code, correct lang strings --- classes/privacy/provider.php | 35 +++-------------------------------- lang/de/pdfannotator.php | 8 ++++---- lang/en/pdfannotator.php | 4 ++-- mod_form.php | 10 +++++----- model/comment.class.php | 4 ++-- 5 files changed, 16 insertions(+), 45 deletions(-) diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 0052c5e..ab9d48c 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -182,8 +182,6 @@ class provider implements \core_privacy\local\metadata\provider, \core_privacy\l ) "; - // $params = []; - // $params += $contextparams; // Keep a mapping of pdfannotatorid to contextid. $mappings = []; @@ -198,9 +196,6 @@ class provider implements \core_privacy\local\metadata\provider, \core_privacy\l $sql1 = "SELECT c.content, c.timecreated, c.visibility FROM {pdfannotator_comments} c WHERE c.isquestion = 1 AND c.userid = :userid AND c.pdfannotatorid = :pdfannotator"; - // $sql1 = "SELECT c.content, c.timecreated, c.visibility - // FROM {pdfannotator_comments} c JOIN {pdfannotator_annotations} a ON c.annotationid = a.id - // WHERE c.isquestion = 1 AND c.userid = :userid AND a.pdfannotatorid = :pdfannotator"; $myquestions = $DB->get_records_sql($sql1, array('userid' => $userid, 'pdfannotator' => $pdfannotator->id)); foreach ($myquestions as $myquestion) { @@ -229,9 +224,6 @@ class provider implements \core_privacy\local\metadata\provider, \core_privacy\l $sql4 = "SELECT c.content FROM {pdfannotator_comments} c JOIN {pdfannotator_votes} v on v.commentid = c.id WHERE v.userid = :userid AND c.pdfannotatorid = :pdfannotator"; - // $sql4 = "SELECT c.content - // FROM {pdfannotator_comments} c JOIN {pdfannotator_votes} v on v.commentid = c.id JOIN {pdfannotator_annotations} a ON c.annotationid = a.id - // WHERE v.userid = :userid AND a.pdfannotatorid = :pdfannotator"; $myvotes = $DB->get_records_sql($sql4, array('userid' => $userid, 'pdfannotator' => $pdfannotator->id)); // Get all reports this user wrote. @@ -270,8 +262,6 @@ class provider implements \core_privacy\local\metadata\provider, \core_privacy\l public static function delete_data_for_all_users_in_context(\context $context) { global $DB; - // require_once($CFG->dirroot.'/mod/pdfannotator/model/annotation.class.php'); - if ($context->contextlevel != CONTEXT_MODULE) { return; } @@ -304,25 +294,16 @@ class provider implements \core_privacy\local\metadata\provider, \core_privacy\l } // 4. Delete all comments in this annotator. - $sql = "SELECT c.id, c.isquestion, c.annotationid FROM {pdfannotator_comments} c " - . "WHERE c.annotationid IN (SELECT a.id FROM {pdfannotator_annotations} a WHERE a.pdfannotatorid = ?)"; - // $comments = $DB->get_records_sql($sql, array($instanceid)); $sql = "SELECT c.id FROM {pdfannotator_comments} c WHERE c.annotationid IN (SELECT a.id FROM {pdfannotator_annotations} a WHERE a.pdfannotatorid = ?)"; $comments = $DB->get_records_sql($sql, array($instanceid)); foreach ($comments as $comment) { $DB->delete_records('pdfannotator_comments', array("id" => $comment->id)); - // if ($comment->isquestion === 1) { // delete question comments, their underlying annotation as well as all answers and subscriptions - // annotation::delete($comment->annotationid, null, true); - // } else { // empty all other comments - // $DB->update_record('pdfannotator_comments', array("id" => $comment->id, "content" => "", "isdeleted" => 1), $bulk=false); - // } } - // 6. Select the IDs of all annotations that were made by this user in this annotator. Then call the function to delete the annotation and any adjacent comments. + // 5. Delete all annotations in this annotator. $annotations = $DB->get_fieldset_select('pdfannotator_annotations', 'id', "pdfannotatorid = ?", array($instanceid)); foreach ($annotations as $annotationid) { $DB->delete_records('pdfannotator_annotations', array("id" => $annotationid)); - // annotation::delete($annotationid, null, true); } } @@ -336,8 +317,6 @@ class provider implements \core_privacy\local\metadata\provider, \core_privacy\l global $DB; - // require_once($CFG->dirroot.'/mod/pdfannotator/model/annotation.class.php'); - if (empty($contextlist->count())) { return; } @@ -353,9 +332,6 @@ class provider implements \core_privacy\local\metadata\provider, \core_privacy\l // 2. Delete all votes this user made in this annotator. $sql = "SELECT v.id FROM {pdfannotator_votes} v WHERE v.userid = ? AND v.commentid IN (SELECT c.id FROM {pdfannotator_comments} c WHERE c.pdfannotatorid = ?)"; $votes = $DB->get_records_sql($sql , array($userid, $instanceid)); - // $sql = "SELECT v.id FROM {pdfannotator_votes} v WHERE v.userid = ? AND v.commentid IN " - // . "(SELECT c.id FROM {pdfannotator_comments} c JOIN {pdfannotator_annotations} a ON c.annotationid = a.id WHERE a.pdfannotatorid = ?)"; - // $votes = $DB->get_records_sql($sql, array($userid, $instanceid)); foreach ($votes as $vote) { $DB->delete_records('pdfannotator_votes', array("id" => $vote->id)); } @@ -368,11 +344,8 @@ class provider implements \core_privacy\local\metadata\provider, \core_privacy\l $DB->delete_records('pdfannotator_subscriptions', array("id" => $subscription->id)); } - // 4. Select (the ID and isquestion attributes of) every comment this user made in this annotator. + // 4. Select all comments this user made in this annotator. $comments = $DB->get_records_sql("SELECT c.* FROM {pdfannotator_comments} c WHERE c.pdfannotatorid = ? AND c.userid = ?", array($instanceid, $userid)); - // $sql = "SELECT c.* FROM {pdfannotator_comments} c WHERE c.annotationid IN " - // . "(SELECT a.id FROM {pdfannotator_annotations} a WHERE a.pdfannotatorid = ?) AND c.userid = ?"; - // $comments = $DB->get_records_sql($sql, array($instanceid, $userid)); foreach ($comments as $comment) { // Delete question comments, their underlying annotation as well as all answers and subscriptions. @@ -384,12 +357,10 @@ class provider implements \core_privacy\local\metadata\provider, \core_privacy\l self::empty_or_delete_comment($comment); } - // 6. Select the IDs of all annotations that were made by this user in this annotator. Then call the function to delete the annotation and any adjacent comments. + // 5. Select the IDs of all annotations that were made by this user in this annotator. Then call the function to delete the annotation and any adjacent comments. $annotations = $DB->get_fieldset_select('pdfannotator_annotations', 'id', "pdfannotatorid = ? AND userid = ?", array($instanceid, $userid)); foreach ($annotations as $annotationid) { self::delete_annotation($annotationid); - // $DB->delete_records('pdfannotator_annotations', array("id" => $annotationid)); - // annotation::delete($annotationid, null, true); } } } diff --git a/lang/de/pdfannotator.php b/lang/de/pdfannotator.php index c65caea..d7e149e 100644 --- a/lang/de/pdfannotator.php +++ b/lang/de/pdfannotator.php @@ -100,11 +100,11 @@ $string['setting_use_studenttextbox_help'] = "Bitte beachten Sie, dass mit der T $string['setting_use_studentdrawing'] = "Freihandzeichnung"; $string['setting_use_studentdrawing_help'] = "Bitte beachten Sie, dass Freihandzeichnungen immer mit Verfasser und Erstellungsdatum angezeigt werden. Diese Annotationen können weder kommentiert noch gemeldet wedern."; -$string['setting_useprint'] = "Speichern/Drucken"; +$string['setting_useprint'] = "Dokument speichern/drucken"; $string['setting_useprint_help'] = "Sollen Teilnehmer/innen das PDF-Dokument ohne Annotationen und Kommentare herunterladen dürfen?"; -$string['setting_useprint_document'] = 'Dokument Speichern/Drucken'; -$string['setting_useprint_document_help'] = 'Sollen Teilnehmer/innen das PDF-Dokument herunterladen dürfen?'; -$string['setting_useprint_comments'] = 'Kommentare Speichern/Drucken'; +$string['setting_useprint_document'] = 'Dokument speichern/drucken'; +$string['setting_useprint_document_help'] = 'Sollen Teilnehmer/innen das PDF-Dokument ohne Annotationen und Kommentare herunterladen dürfen?'; +$string['setting_useprint_comments'] = 'Kommentare speichern/drucken'; $string['setting_useprint_comments_help'] = 'Sollen Teilnehmer/innen die Annotationen und Kommentaren herunterladen dürfen?'; $string['setting_choosetimespanfornews'] = "Wie lange soll ein Kommentar als neu angezeigt werden?"; diff --git a/lang/en/pdfannotator.php b/lang/en/pdfannotator.php index 308540a..e6cb116 100644 --- a/lang/en/pdfannotator.php +++ b/lang/en/pdfannotator.php @@ -103,9 +103,9 @@ $string['setting_use_studentdrawing_help'] = "Allow participants to save and pri $string['setting_useprint'] = "save and print"; $string['setting_useprint_help'] = "Please note that drawings are not anonymous and can neither be commented nor reported."; -$string['setting_useprint_document'] = 'save and print pdf document'; +$string['setting_useprint_document'] = 'Save and print pdf document'; $string['setting_useprint_document_help'] = 'Allow participants to save and print the pdf document'; -$string['setting_useprint_comments'] = 'save and print comments'; +$string['setting_useprint_comments'] = 'Save and print comments'; $string['setting_useprint_comments_help'] = 'Allow participants to save and print the annotations and comments'; $string['setting_choosetimespanfornews'] = "For how long should a comment be marked as new?"; diff --git a/mod_form.php b/mod_form.php index b6b7c2c..fd5f380 100644 --- a/mod_form.php +++ b/mod_form.php @@ -92,15 +92,15 @@ class mod_pdfannotator_mod_form extends moodleform_mod { $mform->addHelpButton('use_studentdrawing', 'setting_use_studentdrawing', 'pdfannotator'); // XXX second checkbox or change to select. - $mform->addElement('advcheckbox', 'useprint', get_string('setting_useprint', 'pdfannotator'), get_string('useprint', 'pdfannotator'), null, array(0, 1)); + $mform->addElement('advcheckbox', 'useprint', get_string('setting_useprint_document', 'pdfannotator'), get_string('useprint', 'pdfannotator'), null, array(0, 1)); $mform->setType('useprint', PARAM_BOOL); $mform->setDefault('useprint', $config->useprint); - $mform->addHelpButton('useprint', 'setting_useprint', 'pdfannotator'); + $mform->addHelpButton('useprint', 'setting_useprint_document', 'pdfannotator'); $mform->addElement('advcheckbox', 'useprintcomments', get_string('setting_useprint_comments', 'pdfannotator'), get_string('useprint_comments', 'pdfannotator'), null, array(0, 1)); - $mform->setType('useprint', PARAM_BOOL); - $mform->setDefault('useprint', $config->useprintcomments); - $mform->addHelpButton('useprint', 'setting_useprint_comments', 'pdfannotator'); + $mform->setType('useprintcomments', PARAM_BOOL); + $mform->setDefault('useprintcomments', $config->useprintcomments); + $mform->addHelpButton('useprintcomments', 'setting_useprint_comments', 'pdfannotator'); // Add legacy files flag only if used. if (isset($this->current->legacyfiles) and $this->current->legacyfiles != RESOURCELIB_LEGACYFILES_NO) { diff --git a/model/comment.class.php b/model/comment.class.php index 21679d9..5f70694 100644 --- a/model/comment.class.php +++ b/model/comment.class.php @@ -106,7 +106,7 @@ class pdfannotator_comment { $question->answeruser = $visibility == 'public' ? fullname($USER) : 'Anonymous'; $question->content = $content; - $page = $DB->get_field('pdfannotator_annotations', 'page', array('id' => $annotationid), $strictness = MUST_EXIST); // annotation::getPageID($annotationid); + $page = $DB->get_field('pdfannotator_annotations', 'page', array('id' => $annotationid), $strictness = MUST_EXIST); $question->urltoanswer = $CFG->wwwroot . '/mod/pdfannotator/view.php?id=' . $cm->id . '&page=' . $page . '&annoid=' . $annotationid . '&commid=' . $commentuuid; $messagetext = new stdClass(); @@ -286,7 +286,7 @@ class pdfannotator_comment { $success = $DB->update_record('pdfannotator_comments', array("id" => $commentid, "ishidden" => 1), $bulk = false); if ($success == 1) { - return ['status' => 'success', 'hideannotation' => $hideannotation, 'wasanswered' => $wasanswered, 'followups' => $tobedeletedaswell]; // , 'deleteannotation' => $deleteannotation]; + return ['status' => 'success', 'hideannotation' => $hideannotation, 'wasanswered' => $wasanswered, 'followups' => $tobedeletedaswell]; } else { return ['status' => 'error']; } -- GitLab