Demo Page for Dashboard Addon

Permalink 1 user found helpful
Hi folks

I have a question which is, I think, an opinion based one. I've completed my backend addon and am now writing the docs for it and thinking about a demo page. Now the thing is, that I'd like to serve a demo-site, where customers may play around with the package.
But as it is a backend addon it would be wise to not give any permissions to anything else than to the addon wouldn't it?

So I set up a site with advanced permissions turned on and gave all permissions possible to the admin user (uID 1) instead of the Administrator group. But then there are still many dashboard pages available to the Admin group which is normal.

So one idea is to override all those pages/controllers and do something like this in the view or on_start methods:
//Override demo
        $u = new User();
        if ($u->uID != '1'){
            $session = \Core::make('session');
            $session->set('no_access', t('This is a demo site. You don\'t have access to the page \'%s\'', Page::getCurrentPage()->getCollectionName()));
            $response = \Redirect::to('/dashboard');
            $response->send();
            exit;
        }
and output the $session message on the dasboards index page.

But this results in a load of overrides which may or sureley will make problems when upgrading the site. Also it gives me a lot of work for maybe not much results?

Another idea is to not make a backend demo page at all but just serving print screens at the frontend of the demo site.

Is there any other solution which is less overriding the core, maybe with routing or something like that?

It would be interesting to know what you guys think about, especially those who are already selling backend addons.

Thank you in advance for taking part to this discussion.

daenu
 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi Daenu,

I am also interested in how to setup a site for demo use.
ramonleenders replied on at Permalink Reply
ramonleenders
Why not check the page in the on_start function of you Add-On (controller.php)? You can get the current page and make the check there, instead of each specific controller.
daenu replied on at Permalink Reply
daenu
A good idea, but in the controller.php it doesn't work. it's returning NULL... Anything I'm missing ?

EDIT:
I could work with $_SERVER['REQUEST_URI']. What do you think about?
ramonleenders replied on at Permalink Best Answer Reply
ramonleenders
I've made an example with a "cFilename" and a "cPath". You can choose to have both or just one of them, up to you. I've indeed used the request URI, the current page is not being grabbed I guess. Not dived into detail much, but perhaps there's a better way to get the current page instead.

$u = new User();
        if ($u->uID != '1') {
            $page = Page::getByPath(str_replace('index.php/', '', $_SERVER['REQUEST_URI']));
            $excludes = array(
                'cFilename' => array(
                    '/dashboard/view.php',
                    '/dashboard/my_addon/view.php',
                ),
                'cPath' => array(
                    '/dashboard/system',
                    '/or-any-other-c-path',
                ),
            );
            $continue = false;
            foreach ($excludes as $k => $v) {


In the above example the dashboard page, system & settings page and 2 other (fake) URL's work. You can change those fake ones to your addon handle and view file of course!
daenu replied on at Permalink Reply
daenu
Works like a charme. I was on a similar way...
WebcentricLtd replied on at Permalink Reply
hello,
the superuser id doesn't fall under permissions so you wouldn't need to add any permissions to that user.

Why don't you create a demo user outside of the Groups system. That way you can either do as you say and use that speciifc user id in some kind of controller magic or just use advanced permissions to add only the permissions the test user needs to view / use your plugin?

Apologies if I missed the point.
daenu replied on at Permalink Reply
daenu
Just to make the thread complete. Here's my solution for a demo page with backend access.

Thx to ramonleenders for pointing to the right direction!

I've added some code to show the frontend page, just the first one 'home' (cID 1) and the login page too. This is a bit of a workaround but it works. Feel free to improve ;-).

So in the package controllers on_start method as first thing:
public function on_start()
{
    // *******************  Start Demo Override *************
    $u = new User();
    // IMPORTANT! If login is allowed you must check also for $u->uID != NULL
    if ($u->uID != '1' && $u->uID != NULL) {
        $page = Page::getByPath(str_replace('index.php/', '', $_SERVER['REQUEST_URI']));
        // whatever backend-pages allowed comes in $excludes array
        $excludes = array(
            'my_package_starting_page',
            'users/search',
            'login'
        );
        $session = \Core::make('session');
        $continue = false;
WillemAnchor replied on at Permalink Reply
WillemAnchor
nice work !