Commit d90afcb5 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add note to comment form when moderated; set moderated comments to private and...


Add note to comment form when moderated; set moderated comments to private and notify the view owner to moderate
Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 8aa40aa3
......@@ -34,6 +34,7 @@ $string['comments'] = 'comments';
$string['Allow'] = 'Allow';
$string['allowcomments'] = 'Allow comments';
$string['approvalrequired'] = 'Comments are moderated, so if you choose to make this comment public, it will not be visible to others until it is approved by the owner.';
$string['attachfile'] = "Attach file";
$string['Attachments'] = "Attachments";
$string['cantedithasreplies'] = 'You can only edit the most recent comment';
......
......@@ -509,6 +509,13 @@ class ArtefactTypeComment extends ArtefactType {
'title' => get_string('makepublic', 'artefact.comment'),
'defaultvalue' => !$defaultprivate,
);
if ($privateonly) {
$form['elements']['ispublic']['description'] = get_string('approvalrequired', 'artefact.comment');
$form['elements']['moderate'] = array(
'type' => 'hidden',
'value' => true,
);
}
if ($USER->is_logged_in()) {
$form['elements']['attachments'] = array(
'type' => 'files',
......@@ -761,7 +768,6 @@ function add_feedback_form_submit(Pieform $form, $values) {
$data = (object) array(
'title' => get_string('Comment', 'artefact.comment'),
'description' => $values['message'],
'private' => 1 - (int) $values['ispublic'],
);
if ($artefact) {
......@@ -784,11 +790,48 @@ function add_feedback_form_submit(Pieform $form, $values) {
$data->authorname = $values['authorname'];
}
db_begin();
if (isset($values['moderate']) && $values['ispublic'] && !$USER->can_edit_view($view)) {
$data->private = 1;
$data->requestpublic = 'author';
}
else {
$data->private = (int) !$values['ispublic'];
}
$comment = new ArtefactTypeComment(0, $data);
db_begin();
$comment->commit();
$goto = $comment->get_view_url($view->get('id'));
if ($data->requestpublic == 'author' && $data->owner) { // Fix for group views
$arg = $author ? display_name($USER, null, true) : $data->authorname;
$moderatemsg = (object) array(
'subject' => false,
'message' => false,
'strings' => (object) array(
'subject' => (object) array(
'key' => 'makepublicrequestsubject',
'section' => 'artefact.comment',
'args' => array(),
),
'message' => (object) array(
'key' => 'makepublicrequestbyauthormessage',
'section' => 'artefact.comment',
'args' => array(hsc($arg)),
),
'urltext' => (object) array(
'key' => 'Comment',
'section' => 'artefact.comment',
),
),
'users' => array($data->owner),
'url' => $goto,
);
}
if (!empty($values['attachments']) && is_array($values['attachments']) && !empty($data->author)) {
require_once(get_config('libroot') . 'uploadmanager.php');
......@@ -851,16 +894,14 @@ function add_feedback_form_submit(Pieform $form, $values) {
);
activity_occurred('feedback', $data, 'artefact', 'comment');
if (isset($moderatemsg)) {
activity_occurred('maharamessage', $moderatemsg);
}
db_commit();
if ($artefact) {
$goto = get_config('wwwroot') . 'view/artefact.php?artefact=' . $artefact->get('id') . '&view='.$view->get('id');
$newlist = ArtefactTypeComment::get_comments(10, 0, 'last', $view, $artefact);
}
else {
$goto = get_config('wwwroot') . 'view/view.php?id='.$view->get('id');
$newlist = ArtefactTypeComment::get_comments(10, 0, 'last', $view);
}
$newlist = ArtefactTypeComment::get_comments(10, 0, 'last', $view, $artefact);
$form->reply(PIEFORM_OK, array(
'message' => get_string('feedbacksubmitted', 'artefact.comment'),
'goto' => $goto,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment