// Creating new form and giving the var it needs to pass. $editcommentform = new EditCommentForm(null, array('text' => $editingcomment->text, 'cmid' => $cm->id, 'commentid' => $commentid)); // Condition of form cancelation. if ($editcommentform->is_cancelled()) { $action = "list"; } else { if ($fromform = $editcommentform->get_data()) { // Setup of var record to update record in moodle DB. $editingcomment->text = $fromform->comment['text']; $editingcomment->markerid = $USER->id; // Updating the record. $DB->update_record('emarking_predefined_comment', $editingcomment); echo $OUTPUT->notification(get_string('changessaved', 'mod_emarking'), 'notifysuccess'); $action = "list"; } else { $editcommentform->display(); } } } // Action actions on "list". if ($action == 'list') { // Create button url. $urlcreate = new moodle_url('/mod/emarking/marking/predefinedcomments.php', array('id' => $cm->id, 'action' => 'create')); $predefinedcomments = $DB->get_records('emarking_predefined_comment', array('emarkingid' => $emarking->id)); // Creating list. $table = new html_table(); $table->head = array(get_string('comment', 'mod_emarking'), get_string('creator', 'mod_emarking'), get_string('actions', 'mod_emarking')); foreach ($predefinedcomments as $predefinedcomment) { $deleteurlcomment = new moodle_url('', array('action' => 'delete', 'id' => $cm->id, 'commentid' => $predefinedcomment->id)); $deleteiconcomment = new pix_icon('t/delete', get_string('delete')); $deleteactioncomment = $OUTPUT->action_icon($deleteurlcomment, $deleteiconcomment, new confirm_action(get_string('questiondeletecomment', 'mod_emarking')));
/** * Edit comment. * @param $commentId int */ function editComment($paper, $comment, $reviewId) { if (!HookRegistry::call('ReviewerAction::editComment', array(&$paper, &$comment, &$reviewId))) { import("submission.form.comment.EditCommentForm"); $commentForm = new EditCommentForm($paper, $comment); $commentForm->initData(); $commentForm->setData('reviewId', $reviewId); $commentForm->display(array('reviewId' => $reviewId)); } }
/** * Save comment. * @param $commentId int */ function saveComment($article, &$comment, $emailComment) { if (!HookRegistry::call('Action::saveComment', array(&$article, &$comment, &$emailComment))) { import('classes.submission.form.comment.EditCommentForm'); $commentForm = new EditCommentForm($article, $comment); $commentForm->readInputData(); if ($commentForm->validate()) { $commentForm->execute(); // Send a notification to associated users import('lib.pkp.classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationUsers = $article->getAssociatedUserIds(true, false); foreach ($notificationUsers as $userRole) { $url = Request::url(null, $userRole['role'], 'submissionReview', $article->getId(), null, 'editorDecision'); $notificationManager->createNotification($userRole['id'], 'notification.type.submissionComment', $article->getLocalizedTitle(), $url, 1, NOTIFICATION_TYPE_SUBMISSION_COMMENT); } if ($emailComment) { $commentForm->email($commentForm->emailHelper()); } } else { $commentForm->display(); } } }
/** * Save comment. * @param $commentId int */ function saveComment($article, &$comment, $emailComment, $request) { if (!HookRegistry::call('Action::saveComment', array(&$article, &$comment, &$emailComment))) { import('classes.submission.form.comment.EditCommentForm'); $commentForm = new EditCommentForm($article, $comment); $commentForm->readInputData(); if ($commentForm->validate()) { $commentForm->execute(); // Send a notification to associated users import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $notificationUsers = $article->getAssociatedUserIds(true, false); foreach ($notificationUsers as $userRole) { $notificationManager->createNotification($request, $userRole['id'], NOTIFICATION_TYPE_SUBMISSION_COMMENT, $article->getJournalId(), ASSOC_TYPE_ARTICLE, $article->getId()); } if ($emailComment) { $commentForm->email($commentForm->emailHelper(), $request); } } else { $commentForm->display(); } } }
if ($action == "delete") { //geting record to delete $DB->delete_records('emarking_predefined_comment', array('id' => $deleteid)); $action = "list"; } // action action on edit if ($action == "edit") { echo $OUTPUT->heading(get_string('editcomment', 'mod_emarking')); //getting record to edit $comment_edition = $DB->get_record('emarking_predefined_comment', array('id' => $deleteid)); //creating a var which contains the message to adit $comment_var = $comment_edition->text; //Creating new form and giving the var it needs to pass $newcommentform = new EditCommentForm(null, array('text' => $comment_var, 'id' => $cm->id, 'deleteid' => $deleteid)); //Dislay of the form $newcommentform->display(); } if ($action == "edited") { //Creating new form and giving the var it needs to pass $newcommentform = new EditCommentForm(null, array('text' => "", 'id' => $cm->id, 'deleteid' => $deleteid)); //condition of form cancelation if ($newcommentform->is_cancelled()) { $action = "list"; } elseif ($fromform = $newcommentform->get_data()) { $record = new stdClass(); //geting previous data, so we can reuse it $comment_setup = $DB->get_record('emarking_predefined_comment', array('id' => $fromform->delete)); //setup of var record to update record in moodle DB $record->id = $comment_setup->id; $record->emarkingid = $comment_setup->emarkingid; $record->text = $fromform->comment['text'];