Clone group plugin as new type

Hi, I'm newbie,

I'm trying to develop Elgg, and I want to create a new plugin for new type (Ex: Course) as same as group plugin.

I already searched old topics about clone group plugin, but all topics are very old, and they don't have good solutions.

Do you have any solution in the current version?

  • Why every newbie want to clone a Group?

    they don't have good solutions

    Of course, because...

    There's an awesome plugin. Use it!

  • Quang Nguyen , Cloning elgg group to Course plugin is not hard but it will be messy. There are core classes that do check for Elgg entity when Elgg engine starts e.g ElggDataTable classs, ElggEntity, and a few other classes. Even if you change the whole group files and code plugin to course, you will need to create some database tables which Elgg core team discourages. In addition, after cloning, the Elgg Course will load just normal, and after creating a new Course title and description, the database will be updated just fine but the site will crash because the ElggEntity class will not recognize your new entity called course in your database and hence a Fatal error will be generated and hence a blue screen with several error messages will politely greet your screen. This means that you have to change most of the Elgg core classes to include the entity called course and a Class called ElggCourse to run your Course plugin.

    After going through all the pain of modifying the core Class, after an Update of the elgg core versions or releases, you will have to go back in and change the core again and this can be pain in the brain for a site administrator.

    Here is how the tables you will need to setup just for your Course plugin activate.php file located at.

    mod/course/activate.php

    <?php
    /*
    *
    * course Table creator
    *
    */
    // create tables if not exist
    $prefix = elgg_get_config('dbprefix');
    $tables = get_db_tables();
    if (! in_array("{$prefix}courses_entity", $tables)) {
    
    // create remember me table
    $query1 = <<<SQL
    
    CREATE TABLE IF NOT EXISTS `{$prefix}courses_entity` (
      `guid` bigint(20) unsigned NOT NULL,
      `name` text NOT NULL,
      `description` text NOT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
    
    CREATE TABLE IF NOT EXISTS `{$prefix}course_access_collections` (
      `id` int(11) NOT NULL,
      `name` text NOT NULL,
      `owner_guid` bigint(20) unsigned NOT NULL,
      `site_guid` bigint(20) unsigned NOT NULL DEFAULT '0'
    ) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
    
    
    SQL;
    update_data($query1);
    
    $query3 = "ALTER TABLE `{$prefix}courses_entity`
      ADD PRIMARY KEY (`guid`), ADD KEY `name` (`name`(50)), ADD KEY `description` (`description`(50)), ADD FULLTEXT KEY `name_2` (`name`,`description`)";
    
    $query4 = "ALTER TABLE `{$prefix}course_access_collections`
      ADD PRIMARY KEY (`id`), ADD KEY `owner_guid` (`owner_guid`), ADD KEY `site_guid` (`site_guid`)";
    
    $query5 = "ALTER TABLE `{$prefix}course_access_collections`
      MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=7";
    
    $query6 = "ALTER TABLE `elgg_entities` CHANGE `type` `type` ENUM('object','user','group','site','course') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL";
    
    update_data($query3);
    
    update_data($query4);
    
    update_data($query5);

    For now you have to stick with what RvR RvR has suggested you. However, hope in the near future Elgg team can make it possible for Elgg developers to create extra entities than (user, group, site, and object ) to serve different projects or purposes without changing the core code.

    From my understanding, the plugin that RVR recommended an awesome plugin normally will create a link on the site which will show groups then the subtype will show up next segment on the link. I think a browser with group context and then subtype e.g localhost/group/course/...  is what most users are trying to avoid at the same time they want to maintain or run the group plugin on the site while the clone of group plugin is running. Hence having a clean url like localhost/course/... instead of the other way round e.g localhost/group/course/... 

  • Many thanks @RvR and @Tom.

    I will try an awesome plugin first, I don't want to change anything inside Elgg core.

    Hope in the near future Elgg team can make it possible for Elgg developers to create extra entities

  • Adding new base types (user, site, group or object) is very hard to do and (i think) not needed. You can easily extend the existing base type.

    For example you could make your course entities extend the group entity and set a different subtype (eg 'course'). This is done everywhere in core for objects and also works for the other base types.

    No database alterations needed ;)

    Just make sure you register the correct class for the subtype (elgg_add_subtype('group', 'course', 'MyCustomClass');)

    But as RvR suggested check out the subtype groups plugin

  • I am very interested in this plugin (alas, not a coder/developer, so very limited ability to be a contributing participant!).

    Our use case is that of making use of Elgg as our "virtual learning environment" for small higher education institution. We use the "groups" (with the "group_tools" plugin) to provide support for courses/modules. Several of these run every year.

    It would be VERY convenient to be able to clone the group structure and assets (files, pages, bookmarks) as a new instance, but without the membership (or the blogs or discussions). This way, instructors can start with a "fresh" group for the next course cohort, with the "assets" intact, but without the "bespoke" content generated by the previous cohort.

    The might be other ways of realizing this goal (e.g., deleting generated content, renaming/editing for the new session, etc.), but that is not so desirable as the possibility of "archiving" the past "group", and cloning for the next cohort.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking