← Back to team overview

mahara-contributors team mailing list archive

[Bug 1027739] Re: Enhance tagged posts block - copy block

 

Hello,
The piece of code included is brought as a solution to the Mahara Community Developers Forum conversation « Copy "tagged journal entry" bloc », which is found at the URL https://mahara.org/interaction/forum/topic.php?id=7448.

Our will was to be able to copy a page from a model user containing a
"tagged journal entry" block , while keeping the block presence and its
configuration, i.e., it's tag.

As the tag must exist in the destination user portfolio, we ensure the
tags presence by first copy a page from the model user containing a
journal in which only one article is written and is marked as draft.
This draft article is tagged by all the wished tags.

Moreover, in htdocs/artefact,blog/blocktype/taggedposts/lib.php file, we
change the return value of the default_copy_type function, from 'nocopy'
to 'shallow'

Once those prerequisites in place, we modified the htdocs/blocktype/lib.php file. Those following lines has been inserted under the line 1525 (on which we can see a newblock -> commit ) 
(The complete file is found attached)

        //Change - BEGIN - By Helene Bouley
        $viewid=$template->get('id');
        $bid=get_record('block_instance', 'view', $viewid,'blocktype','taggedposts');
        if ($this -> id ==   $bid -> id ) {
            $tagrecords = get_records_array('blocktype_taggedposts_tags', 'block_instance', $bid-> id, 'tagtype desc, tag', 'tag, tagtype');
            $newid=$newblock -> get('id');
            foreach ($tagrecords as $k => $v) {
                $o=new   stdClass();
                $o ->  block_instance= $newid;
                $o -> tag=$v -> tag;
                $o -> tagtype=1;
                insert_record('blocktype_taggedposts_tags', $o);
            }
        }  //Change - END - By Helene Bouley 


** Attachment added: "This file is a modified version of Mahara-15.04 htdocs/blocktype/lib.php file"
   https://bugs.launchpad.net/mahara/+bug/1027739/+attachment/4550769/+files/lib.php

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1027739

Title:
  Enhance tagged posts block - copy block

Status in Mahara:
  Confirmed

Bug description:
  This is a follow-up from https://reviews.mahara.org/#/c/1072/ for
  milestone 1.6

  Add block copy permission selector

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1027739/+subscriptions


References