This is a how-to geared especially toward our add-on developers, but it'll be useful to anyone who wants to create a cycling concrete5 demo that automatically resets. In this how-to I'll explain how to prepare a database for the demo, setup special demo-specific permissions overrides, create a demo administrative user, install one or more add-ons along with the demo, and provide a script that can be run at any time to reset the demo.
Note: This requires concrete5 5.5.0 and greater. Another how-to is available for older versions of concrete5.
This how-to references a reset script and permissions overrides. You can download these files here:
Download Reset Script and Permissions Overrides
CREATE DATABASE concretedemo;
Then I grant permissions to the user on the database:
GRANT ALL ON concretedemo.* TO concretedemo@localhost IDENTIFIED BY 'concretedemo';
Download the latest version of concrete5, unzip it to the web directory that will house your demo, and install it.
We want our demo user to be added to the Administrators group, so they can access the dashboard, but we don't want to give out full and complete access. We don't want sitewide settings to be looked at, or file access permissions to change, for example. Fortunately there's a little-used feature that allows us to lock down single page permissions at the time of their creation: access.xml files. These files live in the specific controllers/ directory for the given single page.
A sample access.xml file looks like this:
<access> <node handle="dashboard/files/access"> <guests canRead="0" ></guests> <registered canRead="0" ></registered> <administrators canRead="0" canWrite="0" canAdmin="0" ></administrators> </node> </access>
This locks the admnistrators group out of accessing the /dashboard/files/access page.
In the .zip file above, you'll see a controllers/ directory. Copy the contents of this controllers/ directory into your root controllers/ directory. The next time your demo site is reset, these access restrictions will be in place.
Also contained within the .zip file above is a reset script. When run, this script does the following:
Please, rename the reset script! Anyone who hits the URL of the reset script will be able to reset your demo.
There are a number of values at the beginning of the script that deserve explanation.
It is easy to cron this script so that it will clean out data every hour. Something like this can be entered into a crontab on a Linux server. For example, if your reset script is
http://www.yoursite.com/reset_128273282.php
You can can make it run every hour on the hour with
0 * * * * /usr/bin/wget -T 0 -q http://www.yoursite.com/reset_128273282.php
in your crontab file.
That's it! Now you should have a fully functional concrete5 demo with a full admin account, a limited admin account, and any add-ons preinstalled that you wish to demonstrate.