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

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
......@@ -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 {
}
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$configdata = $instance->get('configdata');
$sort = !empty($configdata['sort']) ? $configdata['sort'] : null;
$limit = !empty($configdata['limitto']) ? $configdata['limitto'] : null;
......
......@@ -68,7 +68,7 @@ class PluginBlocktypeMyviews extends MaharaCoreBlocktype {
}
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$userid = $instance->get_view()->get('owner');
if (!$userid) {
return '';
......
......@@ -38,7 +38,7 @@ class PluginBlocktypeNavigation extends MaharaCoreBlocktype {
return '';
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$configdata = $instance->get('configdata');
$smarty = smarty_core();
......
......@@ -29,7 +29,7 @@ class PluginBlocktypeNewViews extends MaharaCoreBlocktype {
return array('dashboard');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $USER;
require_once('view.php');
$configdata = $instance->get('configdata');
......
......@@ -78,7 +78,7 @@ class PluginBlocktypeOpenbadgedisplayer extends SystemBlocktype {
return array('openbadgedisplayer' => 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) || !isset($configdata['badgegroup']) || !get_config('openbadgedisplayer_source')) {
return;
......
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