Ejemplo n.º 1
0
 public function apply($discussion, $all, $selected, $formdata)
 {
     global $CFG;
     $filecontext = $discussion->get_context();
     $forum = $discussion;
     if (!isset($formdata->mailnow)) {
         $formdata->mailnow = false;
     }
     foreach ($selected as $postid) {
         // Call the lock for selected discussions.
         $discussion = mod_forumng_discussion::get_from_id($postid, $formdata->clone);
         if (!$discussion->is_deleted() && !$discussion->is_locked()) {
             $newpostid = $discussion->lock($formdata->subject, $formdata->message['text'], $formdata->message['format'], $formdata->attachments, $formdata->mailnow, '', '', $formdata->asmoderator);
             // Save attachments.
             file_save_draft_area_files($formdata->attachments, $filecontext->id, 'mod_forumng', 'attachment', $newpostid, null);
             $newtext = file_save_draft_area_files($formdata->message['itemid'], $filecontext->id, 'mod_forumng', 'message', $newpostid, null, $formdata->message['text']);
             if ($newtext !== $formdata->message['text']) {
                 mod_forumng_post::update_message_for_files($newpostid, $newtext);
             }
         }
     }
     // Redirect to the Main page.
     redirect('../../view.php?' . $forum->get_link_params(mod_forumng::PARAM_PLAIN));
 }
Ejemplo n.º 2
0
             if ($newtext !== $fromform->message['text']) {
                 mod_forumng_post::update_message_for_files($postid, $newtext);
             }
             // Redirect to view discussion
             $transaction->allow_commit();
             finish($postid, $cloneid, 'discuss.php?' . $replyto->get_discussion()->get_link_params(mod_forumng::PARAM_PLAIN) . $expandparam, $fromform);
         } else {
             // Create a new reply
             $transaction = $DB->start_delegated_transaction();
             $postid = $replyto->reply($fromform->subject, $fromform->message['text'], $fromform->message['format'], $hasattachments, !empty($fromform->setimportant), !empty($fromform->mailnow));
             // Save attachments
             file_save_draft_area_files($fromform->attachments, $filecontext->id, 'mod_forumng', 'attachment', $postid, $fileoptions);
             if (!empty($fromform->message['itemid'])) {
                 $newtext = file_save_draft_area_files($fromform->message['itemid'], $filecontext->id, 'mod_forumng', 'message', $postid, $fileoptions, $fromform->message['text']);
                 if ($newtext !== $fromform->message['text']) {
                     mod_forumng_post::update_message_for_files($postid, $newtext);
                 }
             }
             // If there's a draft, get rid of it
             if ($draft) {
                 $draft->delete($filecontext);
             }
             // Redirect to view discussion
             $transaction->allow_commit();
             finish($postid, $cloneid, 'discuss.php?' . $replyto->get_discussion()->get_link_params(mod_forumng::PARAM_PLAIN) . $expandparam . '#p' . $postid, $fromform);
         }
     }
 } else {
     // Editing
     // Group changes together
     $transaction = $DB->start_delegated_transaction();