Forums | Mahara Community

Developers /
Impacts of assigning that value shallow to the default_copy_type function


07 December 2015, 10:29

Dear Mahara developers' team,

I recently learned about the "shallow" value, which can be assigned to the default_copy_type function.

 

I wanted to know more about it and find a note on this page https://wiki.mahara.org/wiki/Developer_Area/Development_Tutorials/Basic_blocktype_plugin. We can there read :

This function returns what should be copied, when exporting this blocktype to LEAP2A.
Possible values are: full, shallow and nocopy.

 

My initial interest towards the shallow value of the default_copy_type function, is in the context when a user needs to copy a collection from a model user.

However, while reading this documentation, I am a little concern with possible collateral consequences.

Let's say, for example, that I turn to "shallow" the value of the default_copy_type function for the navigation block in htdocs/blocktype/navigation/lib.php.

So, when a user copy a collection from a model containing a navigation block, he would be happy to avoid the presence in his own pages of a block that make him navigate in the model user collection (which his the case when we keep the default value "full")

On another hand, when the same user will eventually export his portfolio en LEAP2A format, I guess now from the documentation that  he will loose the block configuration.

Am I right?

If so, could we isolate the behavior of one action (copy a collection - for which it could be valuable to assign the shallow value) from the other (export the portfolio - for which the full value seems more adequate)?

Warm regards,


Stéphanie

[Edit: wiki link corrected by Aaron W]

Edits to this post:

Aaron Wells's profile picture
Posts: 896

07 December 2015, 13:11

Hi Stéphanie,

Sorry, the Wiki was actually incorrect on that one. Unfortunately, Mahara's developer documentation on the wiki is very incomplete, and often outdated. It's always on my "to-do" list to clean it up. So your best bet is to read through the code itself. For the most part Mahara's code is not particularly abstract and the course of execution is relatively easy to follow, especially if you use an editor like Eclipse for PHP, which lets you easily search the code to find the definition of a method and where it gets called.

Anyway, the default_copy_type method is actually not used during Leap2a export. It's only used when copying a page within Mahara. (Specifically, it's called by the BlockInstance->copy() method in htdocs/blocktype/lib.php). I've updated the documentation on that page to be more accurate on that.

The closest equivalent for Leap2a export is probably the the export_blockinstance_config() method, and the matching import-side import_rewrite_blockinstance_extra_config_leap() and import_rewrite_blockinstance_relationships_leap() methods, which control custom behavior for blocks during import and export.

It's also worth noting, the Navigation block was actually broken on leap2a import until quite recently. I just fixed it two minor releases back. I actually had to add the new import_rewrite_blockinstance_relationships_leap() hook method to fix it, because before then there was no Leap2a code for rewriting a block's references to views or collections.: https://bugs.launchpad.net/mahara/+bug/1333424

Cheers,

Aaron

16 December 2015, 8:48

Hello Aaron,

Please be sure that I wasn't criticizing the information available on the wiki; my unique intention was to show my interest on the shallow feature.

 

Thank you for the infos.

 

All the best,

 

Stéphanie

 

Aaron Wells's profile picture
Posts: 896

16 December 2015, 16:07

No worries! I didn't think you were being critical.

I see now from your other post that you do not know much PHP, so perhaps my advice of reading the code itself is not too helpful. That is one of the reasons I'd like to update the wiki; to make things easier for people who are not as experienced at PHP programming.

Cheers,

Aaron

4 results