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: default avatarRobert Lyon <robertl@catalyst.net.nz>
parent 4aa41f44
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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);
+22 −2
Original line number Diff line number Diff line
@@ -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',
+2 −2
Original line number Diff line number Diff line
@@ -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();
+1 −1
Original line number Diff line number Diff line
@@ -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 = '';
+2 −2
Original line number Diff line number Diff line
@@ -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
Loading