Commit 79201b7d authored by Lisa Seeto's avatar Lisa Seeto

Bug 1827811: Redirects

This change cleans up the last of the redirects to artefact/artefact.php
Update the links for the journal and journal entries for elasticsearch to go to blog
Update the links for the journal and journal entries in consideration of new reqs
Update artefact/artefact with session msg + access denied error

Change-Id: Ied34542632bd4e49a353ec17937d685614117643
Signed-off-by: default avatarLisa Seeto <lisaseeto@catalyst.net.nz>
parent e6b6ecf9
......@@ -27,212 +27,27 @@ $blockid = param_integer('block', null);
$view = new View($viewid);
if (!can_view_view($view)) {
throw new AccessDeniedException();
throw new AccessDeniedException();
}
require_once(get_config('docroot') . 'artefact/lib.php');
$artefact = artefact_instance_from_id($artefactid);
if (!$artefact->in_view_list()) {
throw new AccessDeniedException(get_string('artefactonlyviewableinview', 'error'));
}
// Build the path to the artefact through its parents.
$artefactpath = array();
// Reverse the order of ancestors so we can get $baseobject by working backwards through the ancestors
$ancestors = array_reverse($artefact->get_item_ancestors());
$artefactok = false;
if (artefact_in_view($artefact, $viewid)) {
$artefactok = true;
$baseobject = $artefact;
}
if (!empty($ancestors)) {
foreach ($ancestors as $ancestor) {
if ($ancestor != $artefactid) {
$pathitem = artefact_instance_from_id($ancestor);
if (artefact_in_view($pathitem, $viewid)) {
$artefactpath[] = array(
'url' => get_config('wwwroot') . 'artefact/blog/view/index.php?id=' . $pathitem->get('id') ,
'title' => $pathitem->display_title(),
);
$artefactok = true;
$baseobject = $pathitem;
}
}
}
}
// Reverse the order back again so $artefactpath can display the paths from highest ancestor first
$artefactpath = array_reverse($artefactpath);
if ($artefactok == false) {
if (!artefact_in_view($artefact, $viewid)) {
throw new AccessDeniedException(get_string('artefactnotinview', 'error', $artefactid, $viewid));
}
// Comment list pagination requires limit/offset params
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);
$showcomment = param_integer('showcomment', null);
if ($artefact && $viewid && $blockid) {
// use the block instance title rather than the artefact title if it exists
$title = artefact_title_for_view_and_block($artefact, $viewid, $blockid);
}
else {
$title = $artefact->display_title();
}
// Create the "make comment private form" now if it's been submitted
if (param_exists('make_public_submit')) {
pieform(ArtefactTypeComment::make_public_form(param_integer('comment')));
}
else if (param_exists('delete_comment_submit')) {
pieform(ArtefactTypeComment::delete_comment_form(param_integer('comment')));
}
define('TITLE', $title . ' ' . get_string('in', 'view') . ' ' . $view->get('title'));
// Render the artefact
$options = array(
'viewid' => $viewid,
'details' => true,
'metadata' => 1,
);
if ($artefact->get('artefacttype') == 'folder') {
// Get folder block sort order - returns the first instance of folder on view unless $blockid is set.
// TODO: get the clicking on a subfolder to carry the block id as well - that way we can get exact configdata.
if ($block = get_records_sql_array('SELECT block FROM {view_artefact} WHERE view = ? AND artefact = ?', array($viewid, $baseobject->get('id')))) {
require_once(get_config('docroot') . 'blocktype/lib.php');
$key = 0;
// If we have a $blockid, then we will use block's configdata.
if ($blockid) {
foreach ($block as $k => $b) {
if ($b->block == $blockid) {
$key = $k;
break;
}
}
}
$bi = new BlockInstance($block[$key]->block);
$configdata = $bi->get('configdata');
if (!empty($configdata['sortorder'])) {
$options['sortorder'] = $configdata['sortorder'];
}
if (!empty($configdata['folderdownloadzip'])) {
$options['folderdownloadzip'] = true;
}
}
}
$rendered = $artefact->render_self($options);
$content = '';
if (!empty($rendered['javascript'])) {
$content = '<script>' . $rendered['javascript'] . '</script>';
}
$content .= $rendered['html'];
// Comments
$commentoptions = ArtefactTypeComment::get_comment_options();
$commentoptions->limit = $limit;
$commentoptions->offset = $offset;
$commentoptions->showcomment = $showcomment;
$commentoptions->view = $view;
$commentoptions->artefact = $artefact;
$feedback = ArtefactTypeComment::get_comments($commentoptions);
$url = parse_url($_SERVER['QUERY_STRING']);
$query = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);
parse_str($query, $params);
$inlinejavascript = <<<EOF
var viewid = {$viewid};
var artefactid = {$artefactid};
jQuery(function () {
paginator = {$feedback->pagination_js}
});
EOF;
$javascript = array('paginator', 'viewmenu');
if ($artefact->get('allowcomments') && ( $USER->is_logged_in() || (!$USER->is_logged_in() && get_config('anonymouscomments')))) {
$commenttype = $view->user_comments_allowed($USER);
$moderate = !$USER->is_logged_in() || (isset($commenttype) && $commenttype === 'private');
$addfeedbackform = pieform(ArtefactTypeComment::add_comment_form(false, $moderate));
}
$objectionform = pieform(objection_form());
if ($notrudeform = notrude_form()) {
$notrudeform = pieform($notrudeform);
}
// For for admin to review objection claim, add comment
// about objectionable content and possibly remove access
if ($stillrudeform = stillrude_form()) {
$stillrudeform = pieform($stillrudeform);
}
$viewbeingwatched = (int)record_exists('usr_watchlist_view', 'usr', $USER->get('id'), 'view', $viewid);
// Set up theme
$viewtheme = $view->get('theme');
if ($viewtheme && $THEME->basename != $viewtheme) {
$THEME = new Theme($view);
}
$headers = array();
// Set up skin, if the page has one
$owner = $view->get('owner');
$viewskin = $view->get('skin');
if ($viewskin && get_config('skins') && can_use_skins($owner) && (!isset($THEME->skins) || $THEME->skins !== false)) {
$skin = array('skinid' => $viewskin, 'viewid' => $view->get('id'));
$skindata = unserialize(get_field('skin', 'viewskin', 'id', $viewskin));
$viewtype = $view->get('type');
switch ($viewtype) {
case 'portfolio':
case 'grouphomepage':
redirect(get_config('wwwroot') . 'view/view.php?id=' . $params['view'] . '&modal=1&artefact=' . $params['artefact']);
break;
default:
redirect('/');
$SESSION->add_error_msg(get_string('viewartefactdatavuamodal', 'mahara', $artefact->artefacttype, $artefact->title, $view->title));
}
else {
$skin = false;
}
$hasfeed = false;
$feedlink = '';
// add a link to the ATOM feed in the header if the view is public
if ($artefact->get('artefacttype') == 'blog' && $view->is_public()) {
$hasfeed = true;
$feedlink = get_config('wwwroot') . 'artefact/blog/atom.php?artefact=' .
$artefactid . '&view=' . $viewid;
$headers[] = '<link rel="alternate" type="application/atom+xml" href="' . $feedlink . '">';
}
$smarty = smarty(
$javascript,
$headers,
array(),
array(
'sidebars' => false,
'skin' => $skin,
)
);
$smarty->assign('artefacttitle', $title);
$smarty->assign('artefact', $content);
$smarty->assign('artefactpath', $artefactpath);
$smarty->assign('INLINEJAVASCRIPT', $inlinejavascript);
$smarty->assign('PAGEHEADING', null);
$smarty->assign('view', $view);
$smarty->assign('viewid', $viewid);
$smarty->assign('feedback', $feedback);
$smarty->assign('hasfeed', $hasfeed);
$smarty->assign('feedlink', $feedlink);
$smarty->assign('userisowner', ($owner && $owner == $USER->get('id')));
if (isset($addfeedbackform)) {
$smarty->assign('enablecomments', 1);
$smarty->assign('addfeedbackform', $addfeedbackform);
}
if ($objectionform) {
$smarty->assign('objectionform', $objectionform);
$smarty->assign('notrudeform', $notrudeform);
$smarty->assign('stillrudeform', $stillrudeform);
$smarty->assign('objectedpage', $view->is_objectionable());
$smarty->assign('objector', $view->is_objectionable($USER->get('id')));
$smarty->assign('objectionreplied', $view->is_objectionable(null, true));
}
$smarty->assign('viewbeingwatched', $viewbeingwatched);
$smarty->assign('viewtitle', $view->get('title'));
$smarty->assign('viewdisplaytitle', $view->display_title(true, true, $view->display_author()));
$smarty->display('artefact/artefact.tpl');
......@@ -1366,3 +1366,6 @@ $string['tabgroup'] = 'Group';
$string['tabinstitution'] = 'Institution';
$string['version.'] = 'v.'; // version shortname, used when duplicating pages and collections
$string['viewartefact'] = 'View ';
//Accessing an outdated url that will now redirect with session message
$string['viewartefactdatavuamodal'] = 'The data for %s artefact "%s" cannot be viewed this way anymore. Please go to page "%s" to view it.';
......@@ -1008,7 +1008,7 @@ class ActivityTypeObjectionable extends ActivityTypeAdmin {
$this->url = $this->view->get_url(false, true) . '&objection=1';
}
else {
$this->url = 'artefact/artefact.php?artefact=' . $this->artefact->get('id') . '&view=' . $this->view->get('id') . '&objection=1';
$this->url = 'view/view.php?id=' . $this->view->get('id') . '&modal=1&artefact=' . $this->artefact->get('id') . '&objection=1';
}
if (empty($this->strings->subject)) {
......@@ -1049,7 +1049,7 @@ class ActivityTypeObjectionable extends ActivityTypeAdmin {
return get_string_from_language(
$user->lang, $key, 'activity',
$this->view->get('title'), $this->artefact->get('title'), display_default_name($this->reporter), $ctime,
$this->message, get_config('wwwroot') . "artefact/artefact.php?artefact=" . $this->artefact->get('id') . "&view=" . $this->view->get('id') . "&objection=1", $reporterurl
$this->message, get_config('wwwroot') . "view/view.php?id=" . $this->view->get('id') . '&modal=1&artefact=' . $this->artefact->get('id') . "&objection=1", $reporterurl
);
}
}
......@@ -1074,7 +1074,7 @@ class ActivityTypeObjectionable extends ActivityTypeAdmin {
return get_string_from_language(
$user->lang, $key, 'activity',
$viewtitle, hsc($this->artefact->get('title')), $reportername, $ctime,
$message, get_config('wwwroot') . "artefact/artefact.php?artefact=" . $this->artefact->get('id') . "&view=" . $this->view->get('id') . "&objection=1", hsc($this->artefact->get('title')),
$message, get_config('wwwroot') . "view/view.php?id=" . $this->view->get('id') . '&modal=1&artefact=' . $this->artefact->get('id') . "&objection=1", hsc($this->artefact->get('title')),
$reporterurl, $reportername
);
}
......
......@@ -99,7 +99,7 @@
<!-- Profile artefact can only be displayed in views -->
{if $secfacetterm != "Profile"} |
<span class="viewartefact">
<a href="{$WWWROOT}artefact/artefact.php?artefact={$record->id}&view={$id}">
<a href="{$WWWROOT}view/view.php?id={$id}&modal=1&artefact={$record->id}">
{str tag=viewartefact}
{if $secfacetterm == "Journalentry"}
{str tag=blogpost section=search.elasticsearch}
......
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