Example #1
0
echo $OUTPUT->tabtree(emarking_tabs($context, $cm, $emarking), "comment");
// Action action on delete.
if ($action == "delete") {
    // Getting record to delete.
    $DB->delete_records('emarking_predefined_comment', array('id' => $commentid));
    echo $OUTPUT->notification(get_string('changessaved', 'mod_emarking'), 'notifysuccess');
    $action = "list";
}
// Action on edit.
if ($action == "edit") {
    // Geting previous data, so we can reuse it.
    if (!($editingcomment = $DB->get_record('emarking_predefined_comment', array('id' => $commentid)))) {
        print_error(get_string('invalidid', 'mod_emarking'));
    }
    // 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();
        }
Example #2
0
 /**
  * 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));
     }
 }
Example #3
0
 /**
  * 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();
         }
     }
 }
Example #4
0
 /**
  * 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();
         }
     }
 }
Example #5
0
}
// 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'];
        $record->markerid = $USER->id;
        //updating the record
        $DB->update_record('emarking_predefined_comment', $record);
        $action = "list";