Commit b3bdbdc9 authored by Robert Lyon's avatar Robert Lyon Committed by Cecilia Vela Gurovic

Bug 1742347: Allow $versioning variable for block rendering

To allow us to restrict things being shown for block when in older
version.

behatnotneeded

Change-Id: I8d9ffe1e7b26a07fc84e3ce64e988b9d7babc396
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 4aa41f44
......@@ -115,7 +115,7 @@ class PluginBlocktypeAnnotation extends MaharaCoreBlocktype {
return false;
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$smarty = smarty_core();
$artefactid = '';
$text = '';
......@@ -131,7 +131,7 @@ class PluginBlocktypeAnnotation extends MaharaCoreBlocktype {
$text = $artefact->get('description');
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($viewid);
list($feedbackcount, $annotationfeedback) = ArtefactTypeAnnotationfeedback::get_annotation_feedback_for_view($artefact, $view, $instance->get('id'), true, $editing);
list($feedbackcount, $annotationfeedback) = ArtefactTypeAnnotationfeedback::get_annotation_feedback_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
$smarty->assign('annotationfeedback', $annotationfeedback);
}
$smarty->assign('text', $text);
......
......@@ -46,7 +46,7 @@ class PluginBlocktypeBlog extends MaharaCoreBlocktype {
}
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $exporter;
$configdata = $instance->get('configdata');
......@@ -56,6 +56,7 @@ class PluginBlocktypeBlog extends MaharaCoreBlocktype {
$blog = $instance->get_artefact_instance($configdata['artefactid']);
$configdata['hidetitle'] = true;
$configdata['countcomments'] = true;
$configdata['versioning'] = $versioning;
$configdata['viewid'] = $instance->get('view');
if ($instance->get_view()->is_submitted()) {
// Don't display posts added after the submitted date.
......@@ -67,7 +68,7 @@ class PluginBlocktypeBlog extends MaharaCoreBlocktype {
$limit = isset($configdata['count']) ? intval($configdata['count']) : 5;
$posts = ArtefactTypeBlogpost::get_posts($blog->get('id'), $limit, 0, $configdata);
$template = 'artefact:blog:viewposts.tpl';
if ($exporter) {
if ($exporter || $versioning) {
$pagination = false;
}
else {
......@@ -225,6 +226,25 @@ class PluginBlocktypeBlog extends MaharaCoreBlocktype {
return $artefacts;
}
public static function get_current_artefacts(BlockInstance $instance) {
$configdata = $instance->get('configdata');
$artefacts = array();
if (isset($configdata['artefactid'])) {
$blog = $instance->get_artefact_instance($configdata['artefactid']);
if ($blogposts = $blog->get_children_instances()) {
foreach ($blogposts as $blogpost) {
if ($blogpost->get('published')) {
$artefacts[] = $blogpost->get('id');
}
}
$artefacts = array_unique($artefacts);
}
}
return $artefacts;
}
public static function artefactchooser_element($default=null, $blogids=array()) {
return array(
'name' => 'artefactid',
......
......@@ -38,7 +38,7 @@ class PluginBlocktypeBlogpost extends MaharaCoreBlocktype {
return array('blog' => 11000);
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$configdata = $instance->get('configdata');
$result = '';
......@@ -55,7 +55,7 @@ class PluginBlocktypeBlogpost extends MaharaCoreBlocktype {
require_once(get_config('docroot') . 'artefact/comment/lib.php');
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($configdata['viewid']);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
}
$smarty = smarty_core();
......
......@@ -107,7 +107,7 @@ class PluginBlocktypeRecentposts extends MaharaCoreBlocktype {
return $mostrecent;
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $USER;
$result = '';
......
......@@ -168,7 +168,7 @@ class PluginBlocktypeTaggedposts extends MaharaCoreBlocktype {
return $results;
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $USER;
$configdata = $instance->get('configdata');
......@@ -231,7 +231,7 @@ class PluginBlocktypeTaggedposts extends MaharaCoreBlocktype {
$result->commentcount = null;
}
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $viewobj, null, false);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $viewobj, null, false, false, $versioning);
$result->comments = $comments;
// get all tags for this post
......
......@@ -1016,6 +1016,9 @@ class ArtefactTypeBlogPost extends ArtefactType {
}
$draftentries = count_records_sql('SELECT COUNT(*) ' . $from, array($id));
$from .= ' AND bp.published = 1';
if (!empty($viewoptions['existing_artefacts'])) {
$from .= ' AND bp.blogpost IN (' . join(',', (array)$viewoptions['existing_artefacts']) . ')';
}
}
$results['count'] = count_records_sql('SELECT COUNT(*) ' . $from, array($id));
......@@ -1078,9 +1081,12 @@ class ArtefactTypeBlogPost extends ArtefactType {
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($viewoptions['viewid']);
$artefact = artefact_instance_from_id($post->id);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, null, false);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, null, false, false, $viewoptions['versioning']);
$post->commentcount = $commentcount;
$post->comments = $comments;
if ($viewoptions['versioning']) {
$post->allowcomments = false;
}
}
}
if ($post->ctime != $post->mtime) {
......
......@@ -38,7 +38,7 @@ class PluginBlocktypeComment extends MaharaCoreBlocktype {
return array('portfolio');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $USER;
if ($editing) {
......
......@@ -677,11 +677,12 @@ class ArtefactTypeComment extends ArtefactType {
* @param int $blockid The id of the block instance that connects the artefact to the view
* @param bool $html Whether to return the information rendered as html or not
* @param bool $editing Whether we are view edit mode or not
* @param bool $versioning Whether we are view versioning mode or not
*
* @return array $commentcount, $comments The count of comments and either the comments
* or the html to render them.
*/
public function get_artefact_comments_for_view(ArtefactType $artefact, $view, $blockid, $html = true, $editing = false) {
public function get_artefact_comments_for_view(ArtefactType $artefact, $view, $blockid, $html = true, $editing = false, $versioning = false) {
global $USER;
if (!is_object($artefact) || !is_object($view)) {
......@@ -712,6 +713,7 @@ class ArtefactTypeComment extends ArtefactType {
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
$smarty->assign('editing', $editing);
$smarty->assign('versioning', $versioning); // Do not show comments in versioning
$smarty->assign('allowcomments', $artefact->get('allowcomments'));
$smarty->assign('allowcommentsadd', ($artefact->get('allowcomments') && ( $USER->is_logged_in() || (!$USER->is_logged_in() && get_config('anonymouscomments')))));
$render = $smarty->fetch('artefact/artefactcommentsview.tpl');
......
......@@ -25,7 +25,7 @@ class PluginBlocktypeFiledownload extends MaharaCoreBlocktype {
return array('fileimagevideo' => 3000);
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$configdata = $instance->get('configdata');
......
......@@ -38,7 +38,7 @@ class PluginBlocktypeFolder extends MaharaCoreBlocktype {
return array('fileimagevideo' => 4000);
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$configdata = $instance->get('configdata');
$configdata['viewid'] = $instance->get('view');
......@@ -56,7 +56,7 @@ class PluginBlocktypeFolder extends MaharaCoreBlocktype {
require_once(get_config('docroot') . 'artefact/comment/lib.php');
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($configdata['viewid']);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
}
$smarty = smarty_core();
if ($artefactid) {
......@@ -204,4 +204,19 @@ class PluginBlocktypeFolder extends MaharaCoreBlocktype {
return 'full';
}
public static function get_current_artefacts(BlockInstance $instance) {
$configdata = $instance->get('configdata');
$artefacts = array();
if (isset($configdata['artefactid'])) {
$folder = $instance->get_artefact_instance($configdata['artefactid']);
if ($files = $folder->get_children_instances()) {
foreach ($files as $file) {
$artefacts[] = $file->get('id');
}
}
$artefacts = array_unique($artefacts);
}
return $artefacts;
}
}
......@@ -78,7 +78,7 @@ class PluginBlocktypeGallery extends MaharaCoreBlocktype {
);
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$configdata = $instance->get('configdata'); // this will make sure to unserialize it for us
$configdata['viewid'] = $instance->get('view');
$style = isset($configdata['style']) ? intval($configdata['style']) : 2;
......@@ -328,6 +328,9 @@ class PluginBlocktypeGallery extends MaharaCoreBlocktype {
if (isset($configdata['select']) && $configdata['select'] == 1 && is_array($configdata['artefactids'])) {
$artefactids = $configdata['artefactids'];
}
else if ($versioning && !empty($configdata['existing_artefacts'])) {
$artefactids = (array) $configdata['existing_artefacts'];
}
else if (!empty($configdata['artefactid'])) {
// Get descendents of this folder.
$artefactids = artefact_get_descendants(array(intval($configdata['artefactid'])));
......@@ -425,7 +428,7 @@ class PluginBlocktypeGallery extends MaharaCoreBlocktype {
require_once(get_config('docroot') . 'artefact/comment/lib.php');
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($configdata['viewid']);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
}
......@@ -836,4 +839,14 @@ class PluginBlocktypeGallery extends MaharaCoreBlocktype {
public static function default_copy_type() {
return 'full';
}
public static function get_current_artefacts(BlockInstance $instance) {
$configdata = $instance->get('configdata');
$artefacts = array();
if (isset($configdata['artefactid'])) {
safe_require('artefact', 'file');
$artefacts = artefact_get_descendants(array(intval($configdata['artefactid'])));
}
return $artefacts;
}
}
......@@ -25,7 +25,7 @@ class PluginBlocktypeHtml extends MaharaCoreBlocktype {
return array('fileimagevideo' => 9000);
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$configdata = $instance->get('configdata'); // this will make sure to unserialize it for us
$configdata['viewid'] = $instance->get('view');
......@@ -43,7 +43,7 @@ class PluginBlocktypeHtml extends MaharaCoreBlocktype {
require_once(get_config('docroot') . 'artefact/comment/lib.php');
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($configdata['viewid']);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
}
$smarty = smarty_core();
......
......@@ -32,7 +32,7 @@ class PluginBlocktypeImage extends MaharaCoreBlocktype {
return array('shortcut' => 2000);
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$configdata = $instance->get('configdata'); // this will make sure to unserialize it for us
if (!isset($configdata['artefactid'])) {
......@@ -61,7 +61,7 @@ class PluginBlocktypeImage extends MaharaCoreBlocktype {
require_once(get_config('docroot') . 'artefact/comment/lib.php');
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($viewid);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($image, $view, $instance->get('id'), true, $editing);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($image, $view, $instance->get('id'), true, $editing, $versioning);
$smarty = smarty_core();
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
......
......@@ -44,7 +44,7 @@ class PluginBlocktypeInternalmedia extends MaharaCoreBlocktype {
}
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
list($artefact, $width, $height) = self::get_mediaplayer_details($instance);
if (!$artefact) {
return '';
......@@ -73,7 +73,7 @@ class PluginBlocktypeInternalmedia extends MaharaCoreBlocktype {
require_once(get_config('docroot') . 'artefact/comment/lib.php');
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($instance->get('view'));
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
$smarty = smarty_core();
......
......@@ -29,7 +29,7 @@ class PluginBlocktypePdf extends MaharaCoreBlocktype {
return array('fileimagevideo' => 8000);
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $USER;
require_once(get_config('docroot') . 'lib/view.php');
$configdata = $instance->get('configdata'); // this will make sure to unserialize it for us
......@@ -79,7 +79,7 @@ class PluginBlocktypePdf extends MaharaCoreBlocktype {
require_once(get_config('docroot') . 'artefact/comment/lib.php');
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($configdata['viewid']);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
}
$smarty = smarty_core();
if ($artefactid) {
......
......@@ -2143,7 +2143,15 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
$smarty->assign('folderid', $this->get('id'));
$smarty->assign('downloadfolderzip', get_config_plugin('blocktype', 'folder', 'folderdownloadzip') ? !empty($options['folderdownloadzip']) : false);
if ($childrecords = $this->folder_contents()) {
$childrecords = false;
if (!empty($options['existing_artefacts'])) {
$childrecords = get_records_sql_array("SELECT * FROM {artefact} WHERE id IN (" . join(',', (array)$options['existing_artefacts']) . ")");
}
else {
$childrecords = $this->folder_contents();
}
if ($childrecords) {
$sortorder = (isset($options['sortorder']) && $options['sortorder'] == 'desc') ? 'my_files_cmp_desc' : 'my_files_cmp';
usort($childrecords, array('ArtefactTypeFileBase', $sortorder));
$children = array();
......
......@@ -29,8 +29,8 @@ class PluginBlocktypeProfileinfo extends MaharaCoreBlocktype {
return array('js/configform.js');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
safe_require('artefact', 'internal');
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
safe_require('artefact', 'internal');
$smarty = smarty_core();
$configdata = $instance->get('configdata');
......
......@@ -26,7 +26,7 @@ class PluginBlocktypeSocialprofile extends MaharaCoreBlocktype {
return array('internal' => 27000);
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$configdata = $instance->get('configdata');
$type = (isset($configdata['displaytype']) ? $configdata['displaytype'] : 'texticon');
......
......@@ -29,7 +29,7 @@ class PluginBlocktypeTextbox extends MaharaCoreBlocktype {
return true;
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$configdata = $instance->get('configdata');
if (!empty($configdata['artefactid'])) {
......@@ -61,7 +61,7 @@ class PluginBlocktypeTextbox extends MaharaCoreBlocktype {
$smarty->assign('attachments', $attachments);
require_once(get_config('docroot') . 'lib/view.php');
$view = new View($viewid);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
$smarty->assign('blockid', $instance->get('id'));
......
......@@ -42,7 +42,7 @@ class PluginBlocktypePeerassessment extends MaharaCoreBlocktype {
return true;
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $USER;
$configdata = $instance->get('configdata');
......
......@@ -50,7 +50,7 @@ class PluginBlocktypeSignoff extends MaharaCoreBlocktype {
return true;
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $USER;
$configdata = $instance->get('configdata');
......
......@@ -52,7 +52,7 @@ class PluginBlocktypePlans extends MaharaCoreBlocktype {
);
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $exporter;
require_once(get_config('docroot') . 'artefact/lib.php');
......@@ -70,7 +70,7 @@ class PluginBlocktypePlans extends MaharaCoreBlocktype {
$tasks = ArtefactTypeTask::get_tasks($planid, 0, $limit);
$template = 'artefact:plans:taskrows.tpl';
$blockid = $instance->get('id');
if ($exporter) {
if ($exporter || $versioning) {
$pagination = false;
}
else {
......@@ -85,6 +85,7 @@ class PluginBlocktypePlans extends MaharaCoreBlocktype {
}
$configdata['view'] = $instance->get('view');
$configdata['block'] = $blockid;
$configdata['versioning'] = $versioning;
ArtefactTypeTask::render_tasks($tasks, $template, $configdata, $pagination, $editing);
if ($exporter && $tasks['count'] > $tasks['limit']) {
......@@ -115,6 +116,7 @@ class PluginBlocktypePlans extends MaharaCoreBlocktype {
$smarty->assign('noplans', get_string('noplansselectone', 'blocktype.plans/plans'));
}
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('versioning', $versioning);
return $smarty->fetch('blocktype:plans:content.tpl');
}
......
......@@ -703,7 +703,12 @@ class ArtefactTypeTask extends ArtefactType {
$view = new View($options['view']);
$owner = $view->get('owner');
if ($owner && $owner == $USER->get('id')) {
$smarty->assign('canedit', true);
if (!empty($options) && !empty($options['versioning'])) {
$smarty->assign('canedit', false);
}
else {
$smarty->assign('canedit', true);
}
}
}
......
......@@ -29,7 +29,7 @@ class PluginBlocktypeEntireresume extends MaharaCoreBlocktype {
return array('entireresume' => array('resume'));
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$smarty = smarty_core();
// Get data about the resume fields the user has
......
......@@ -42,8 +42,8 @@ class PluginBlocktypeResumefield extends MaharaCoreBlocktype {
return '';
}
public static function render_instance(BlockInstance $instance, $editing=false) {
safe_require('artefact', 'resume');
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$smarty = smarty_core();
$configdata = $instance->get('configdata');
$configdata['viewid'] = $instance->get('view');
......
......@@ -35,7 +35,7 @@ class PluginBlocktypeCreativecommons extends MaharaCoreBlocktype {
return array('general' => 15000);
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $THEME;
$configdata = $instance->get('configdata');
if (!isset($configdata['license'])) {
......
......@@ -64,7 +64,7 @@ class PluginBlocktypeExternalfeed extends MaharaCoreBlocktype {
return array('externalfeed' => array('media'));
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$configdata = $instance->get('configdata');
if (!empty($configdata['feedid'])) {
......
......@@ -118,7 +118,7 @@ class PluginBlocktypeExternalvideo extends MaharaCoreBlocktype {
return array('externalvideo' => array('media'));
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $THEME;
$configdata = $instance->get('configdata');
......
......@@ -32,7 +32,7 @@ class PluginBlocktypeGoogleApps extends MaharaCoreBlocktype {
return array('googleapps' => array('media'));
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$configdata = $instance->get('configdata');
if (!isset($configdata['appsid'])) {
return;
......
......@@ -39,7 +39,7 @@ class PluginBlocktypeGroupInfo extends MaharaCoreBlocktype {
return array('grouphomepage');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$groupid = $instance->get_view()->get('group');
if (!$groupid) {
return '';
......
......@@ -40,7 +40,7 @@ class PluginBlocktypeGroupMembers extends MaharaCoreBlocktype {
return true;
}
public static function render_instance (BlockInstance $instance, $editing = false) {
public static function render_instance (BlockInstance $instance, $editing = false, $versioning=false) {
global $USER;
// Not render if the block is in a template
......
......@@ -79,7 +79,7 @@ class PluginBlocktypeGroupViews extends MaharaCoreBlocktype {
}
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $USER;
$configdata = $instance->get('configdata');
......
......@@ -34,7 +34,7 @@ class PluginBlocktypeInbox extends MaharaCoreBlocktype {
return $data;
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $USER, $THEME;
$configdata = $instance->get('configdata');
require_once('activity.php');
......
......@@ -49,7 +49,7 @@ interface IPluginBlocktype {
*/
public static function get_categories();
public static function render_instance(BlockInstance $instance, $editing=false);
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false);
}
/**
......@@ -264,6 +264,17 @@ abstract class PluginBlocktype extends Plugin implements IPluginBlocktype {
}
return false;
}
/**
* Some blocktype plugins will have related artefacts based on artefactid.
* They should implement this function to keep a list of which ones. The
* result of this method is used to work out what artefacts where present at
* the time of the version creation to save in view_versioning.
*
* Note that it should just handle child level artefacts.
*/
public static function get_current_artefacts(BlockInstance $instance) {
return array();
}
/**
* If this blocktype contains artefacts, and uses the artefactchooser
......@@ -1130,9 +1141,11 @@ class BlockInstance {
*
* @param boolean $exporting Indicate the rendering is for an export
* If we are doing an export we can't render the block to be loaded via ajax
* @param boolean $versioning Indicate the rendering is for an older view version
*
* @return the rendered block
*/
public function render_viewing($exporting=false) {
public function render_viewing($exporting=false, $versioning=false) {
global $USER;
if (!safe_require_plugin('blocktype', $this->get('blocktype'))) {
......@@ -1156,7 +1169,7 @@ class BlockInstance {
else {
$smarty->assign('loadbyajax', false);
try {
$content = call_static_method($classname, 'render_instance', $this);
$content = call_static_method($classname, 'render_instance', $this, false, $versioning);
}
catch (NotFoundException $e) {
// Whoops - where did the image go? There is possibly a bug
......@@ -1212,7 +1225,7 @@ class BlockInstance {
$smarty->assign('retractedonload', $configdata['retractedonload']);
}
}
$smarty->assign('versioning', $versioning);
return $smarty->fetch('view/blocktypecontainerviewing.tpl');
}
......
......@@ -65,7 +65,7 @@ class PluginBlocktypeMyfriends extends MaharaCoreBlocktype {
$friends['pagination_js'] = $pagination['javascript'];
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $USER, $exporter;
$userid = $instance->get_view()->get('owner');
......
......@@ -65,7 +65,7 @@ class PluginBlocktypeMyGroups extends MaharaCoreBlocktype {