Jump to:

10994 Posts in 2728 Topics by 1819 members

All other Modules

SilverStripe Forums » All other Modules » Default simplify configuration

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 866 Views
  • klikhier
    Avatar
    Community Member
    150 Posts

    Default simplify configuration Link to this post

    froog,

    Great module you've created! One question though: I have set up all simplify permissions for a group, and would like to reuse this simplify config for other sites as well. is it possible to define a default simplify config in e.g. _config.php?

  • JL
    Avatar
    Community Member
    10 Posts

    Re: Default simplify configuration Link to this post

    You can create a simple setup module to create the necessary simplify permissions when you are setting up the site.

    setup/_config.php:

    <?php

    Director::addRules(100, array(
    'admin/setup/$Action/$ID' => 'SetupCMS',
    ));

    setup/code/SetupCMS.php:

    <?php

    class SetupCMS extends Controller {

    static $url_segment = 'simplify';

    static $allowed_actions = array(
    'simplify'
    );

    function simplify() {
    if (!Member::currentUser()->isAdmin()) {
    return Security::permissionFailure($this);
    }

    // GroupID => Code
    $general_permissions = array(
    1 => array(
    "SIMPLIFY_HIDE_HELP",
    "SIMPLIFY_HIDE_VERSION",
    "SIMPLIFY_HIDE_NON_EDIT_PAGES",
    "SIMPLIFY_HIDE_CREATE",
    "SIMPLIFY_HIDE_SEARCH",
    "SIMPLIFY_HIDE_BATCH_ACTIONS",
    "SIMPLIFY_SHOW_CREATE_OPEN",
    "SIMPLIFY_HIDE_TREE_OPTIONS",
    "SIMPLIFY_DRAGGABLE_ON",
    "SIMPLIFY_HIDE_DRAGGABLE",
    ),
    );

    // GroupID => array(HidePage, HideName, HideType)
    $page_permissions = array(
    1 => array(
    array('Page', 'Behaviour', 'Tab'),
    array('Page', 'Access', 'Tab'),
    array('BlogEntry', 'Behaviour', 'Tab'),
    array('BlogEntry', 'Access', 'Tab'),
    ),
    );

    foreach ($general_permissions as $groupID => $codes) {
    foreach ($codes as $code) {
    $perm = DataObject::get_one("Permission", "Code='{$code}' AND GroupID={$groupID}");
    if (!$perm) {
    Permission::grant($groupID, $code);
    }
    }
    }

    foreach ($page_permissions as $groupID => $permissions) {
    foreach ($permissions as $permission) {
    $perm = SimplifyPermission::checkField($permission[0], $permission[1], $permission[2], $groupID);
    if (!$perm) {
    $perm = new SimplifyPermission;
    $perm->HidePage = $permission[0];
    $perm->HideName = $permission[1];
    $perm->HideType = $permission[2];
    $perm->GroupID = $groupID;
    $perm->write();
    }
    }
    }

    echo "Simplify settings updated. Simplify rocks!";
    }

    }

    After that, just access the url /admin/setup/simplify

    For a list of simplify permission in the $general_permissions array, you can refer to simplify/code/SimplifyPermissionProvider.php
    For a list of simplify permission in the $page_permissions array, you will need to refer to the "Field Tree" after you click on the "Load Field Tree" button in the Simplify interface.

  • klikhier
    Avatar
    Community Member
    150 Posts

    Re: Default simplify configuration Link to this post

    Thanks!!!

    866 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.