Commit 8aa40aa3 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add function to get comment redirect url


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent b7eecf56
......@@ -48,13 +48,7 @@ if ($onview && $onview != $viewid) {
$maxage = (int) get_config_plugin('artefact', 'comment', 'commenteditabletime');
$editableafter = time() - 60 * $maxage;
$onartefact = $comment->get('onartefact');
if ($onartefact) {
$goto = get_config('wwwroot') . 'view/artefact.php?artefact=' . $onartefact . '&view='.$viewid;
}
else {
$goto = get_config('wwwroot') . 'view/view.php?id='.$viewid;
}
$goto = $comment->get_view_url($viewid, false);
if ($comment->get('ctime') < $editableafter) {
$SESSION->add_error_msg(get_string('cantedittooold', 'artefact.comment', $maxage));
......
......@@ -559,6 +559,19 @@ class ArtefactTypeComment extends ArtefactType {
public function exportable() {
return empty($this->deletedby);
}
public function get_view_url($viewid, $showcomment=true) {
if ($artefact = $this->get('onartefact')) {
$url = get_config('wwwroot') . 'view/artefact.php?view=' . $viewid . '&artefact=' . $artefact;
}
else {
$url = get_config('wwwroot') . 'view/view.php?id=' . $viewid;
}
if ($showcomment) {
$url .= '&showcomment=' . $this->get('id');
}
return $url;
}
}
/* To make private comments public, both the author and the owner must agree. */
......@@ -580,14 +593,7 @@ function make_public_submit(Pieform $form, $values) {
$comment = new ArtefactTypeComment((int) $values['comment']);
$viewid = $view->get('id');
if ($artefact = $comment->get('onartefact')) {
$url = get_config('wwwroot') . 'view/artefact.php?view=' . $viewid . '&artefact=' . $artefact;
}
else {
$url = get_config('wwwroot') . 'view/view.php?id=' . $viewid;
}
$url .= '&showcomment=' . $comment->get('id');
$url = $comment->get_view_url($view->get('id'));
$author = $comment->get('author');
$owner = $comment->get('owner');
......
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