public static function render_instance(BlockInstance $instance, $editing = false) { global $USER; if ($editing) { $smarty = smarty_core(); $smarty->assign('editing', get_string('ineditordescription1', 'blocktype.comment/comment')); $html = $smarty->fetch('blocktype:comment:comment.tpl'); return $html; } // Feedback list pagination requires limit/offset params $limit = param_integer('limit', 10); $offset = param_integer('offset', 0); $showcomment = param_integer('showcomment', null); // Create the "make feedback private form" now if it's been submitted if (param_variable('make_public_submit', null)) { pieform(ArtefactTypeComment::make_public_form(param_integer('comment'))); } else { if (param_variable('delete_comment_submit_x', null)) { pieform(ArtefactTypeComment::delete_comment_form(param_integer('comment'))); } } $view = new View($instance->get('view')); $submittedgroup = (int) $view->get('submittedgroup'); if ($USER->is_logged_in() && $submittedgroup && group_user_can_assess_submitted_views($submittedgroup, $USER->get('id'))) { $releaseform = true; } else { $releaseform = false; } // If the view has comments turned off, tutors can still leave // comments if the view is submitted to their group. if (!empty($releaseform) || $view->user_comments_allowed($USER)) { $addfeedbackpopup = true; } safe_require('artefact', 'comment'); $commentoptions = ArtefactTypeComment::get_comment_options(); $commentoptions->limit = $limit; $commentoptions->offset = $offset; $commentoptions->showcomment = $showcomment; $commentoptions->view = $instance->get_view(); $feedback = ArtefactTypeComment::get_comments($commentoptions); $smarty = smarty_core(); $smarty->assign('feedback', $feedback); if (isset($addfeedbackpopup)) { $smarty->assign('enablecomments', 1); $smarty->assign('addfeedbackpopup', $addfeedbackpopup); } $html = $smarty->fetch('blocktype:comment:comment.tpl'); return $html; }
function edit_comment_submit(Pieform $form, $values) { global $viewid, $comment, $SESSION, $goto, $USER; require_once 'embeddedimage.php'; db_begin(); $comment->set('rating', valid_rating($values['rating'])); require_once get_config('libroot') . 'view.php'; $view = new View($viewid); $owner = $view->get('owner'); $group = $comment->get('group'); $newdescription = EmbeddedImage::prepare_embedded_images($values['message'], 'comment', $comment->get('id'), $group); $comment->set('description', $newdescription); $approvecomments = $view->get('approvecomments'); if (!empty($group) && ($approvecomments || !$approvecomments && $view->user_comments_allowed($USER) == 'private') && $values['ispublic'] && !$USER->can_edit_view($view)) { $comment->set('requestpublic', 'author'); } else { if (($approvecomments || !$approvecomments && $view->user_comments_allowed($USER) == 'private') && $values['ispublic'] && (!empty($owner) && $owner != $comment->get('author'))) { $comment->set('requestpublic', 'author'); } else { $comment->set('private', 1 - (int) $values['ispublic']); $comment->set('requestpublic', null); } } $comment->commit(); require_once 'activity.php'; $data = (object) array('commentid' => $comment->get('id'), 'viewid' => $viewid); activity_occurred('feedback', $data, 'artefact', 'comment'); if ($comment->get('requestpublic') == 'author') { if (!empty($owner)) { edit_comment_notify($view, $comment->get('author'), $owner); } else { if (!empty($group)) { $group_admins = group_get_admin_ids($group); // TODO: need to notify the group admins bug #1197197 } } } db_commit(); $SESSION->add_ok_msg(get_string('commentupdated', 'artefact.comment')); redirect($goto); }
function edit_annotation_feedback_submit(Pieform $form, $values) { global $viewid, $annotationfeedback, $annotation, $SESSION, $goto, $USER; db_begin(); $annotationfeedback->set('description', $values['message']); require_once get_config('libroot') . 'view.php'; $view = new View($viewid); $owner = $view->get('owner'); $group = $annotationfeedback->get('group'); $oldispublic = !$annotationfeedback->get('private'); $approvecomments = $view->get('approvecomments'); // We need to figure out what to set the 'requestpublic' field in the artefact_annotation_feedback table. // Then, set who is requesting to make it public - if the public flag has changed. if (!empty($group) && ($approvecomments || !$approvecomments && $view->user_comments_allowed($USER) == 'private') && $values['ispublic'] && !$USER->can_edit_view($view) && $values['ispublic'] != $oldispublic) { // This annotation belongs to a group - but this shouldn't really happen - keeping in case // we allow annotations in group views. // 1. If approvecomments on this view is switched on and // the author of the feedback wants to make it public and // the author of the feeback can't edit the group view and // the auther of the feedback has changed the public setting, // the owner of the view needs to approve the feedback before it's made public. // 2. If approvecomments on this view is switched off and // the access (for the author of the feedback) of the view forces private comments and // the author of the feeback can't edit the view and // the auther of the feedback has changed the public setting, // the owner of the view needs to approve the feedback before it's made public. // The author of the feedback wants to make the feedback public. $annotationfeedback->set('requestpublic', 'author'); } else { if (($approvecomments || !$approvecomments && $view->user_comments_allowed($USER) == 'private') && $values['ispublic'] && !empty($owner) && $owner != $annotationfeedback->get('author') && $values['ispublic'] != $oldispublic) { // 1. If approvecomments on this view is switched on and // the author of the feedback would like to make this public and // the author of the feeback is not the owner of the view and // the auther of the feedback has changed the public setting, // the owner of the view needs to approve the feedback before it's made public. // 2. If approvecomments on this view is switched off and // the access (for the author of the feedback) of the view forces private feedback and // the author of the feeback is not the owner of the view and // the auther of the feedback has changed the public setting, // the owner of the view needs to approve the feedback before it's made public. // The author of the feedback wants to make the feedback public. $annotationfeedback->set('requestpublic', 'author'); } else { // Otherwise, the owner of the feedback is editing the feedback. // Set the privacy setting of the feedback - based on the 'ispublic' flag set by the user. // And, clear the request to make the feedback public. $annotationfeedback->set('private', 1 - (int) $values['ispublic']); $annotationfeedback->set('requestpublic', null); } } $annotationfeedback->commit(); require_once 'activity.php'; $data = (object) array('annotationfeedbackid' => $annotationfeedback->get('id'), 'annotationid' => $annotation->get('id'), 'viewid' => $viewid, 'artefactid' => ''); activity_occurred('annotationfeedback', $data, 'artefact', 'annotation'); if ($annotationfeedback->get('requestpublic') == 'author') { if (!empty($owner)) { edit_annotation_feedback_notify($view, $annotationfeedback->get('author'), $owner); } else { if (!empty($group)) { $group_admins = group_get_admin_ids($group); // TODO: need to notify the group admins bug #1197197 } } } db_commit(); $SESSION->add_ok_msg(get_string('annotationfeedbackupdated', 'artefact.annotation')); redirect($goto); }
function releaseview_submit() { global $USER, $SESSION, $view; $groupid = $view->get('submittedgroup'); $view->release($USER); $SESSION->add_ok_msg(get_string('viewreleasedsuccess', 'group')); if ($groupid) { // The tutor might not have access to the view any more; send // them back to the group page. redirect(get_config('wwwroot') . 'group/view.php?id=' . $groupid); } redirect(get_config('wwwroot') . 'view/view.php?id=' . $view->get('id')); } // If the view has comments turned off, tutors can still leave // comments if the view is submitted to their group. if (!empty($releaseform) || ($commenttype = $view->user_comments_allowed($USER))) { $defaultprivate = !empty($releaseform); $moderate = isset($commenttype) && $commenttype === 'private'; $addfeedbackform = pieform(ArtefactTypeComment::add_comment_form($defaultprivate, $moderate)); } if ($USER->is_logged_in()) { $objectionform = pieform(objection_form()); if ($notrudeform = $view->notrude_form()) { $notrudeform = pieform($notrudeform); } } $viewbeingwatched = (int) record_exists('usr_watchlist_view', 'usr', $USER->get('id'), 'view', $viewid); $feedback = ArtefactTypeComment::get_comments($limit, $offset, $showcomment, $view); // Set up theme $viewtheme = $view->get('theme'); if ($viewtheme && $THEME->basename != $viewtheme) {