Source for file _maintenance.init.php
Documentation is available at _maintenance.init.php
if( !defined('EVO_CONFIG_LOADED') ) die( 'Please, do not access this page directly.' );
* For each controller name, we associate a controller file to be found in /inc/ .
* The advantage of this indirection is that it is easy to reorganize the controllers into
* subdirectories by modules. It is also easy to deactivate some controllers if you don't
* want to provide this functionality on a given installation.
* Note: while the controller mappings might more or less follow the menu structure, we do not merge
* the two tables since we could, at any time, decide to make a skin with a different menu structure.
* The controllers however would most likely remain the same.
$ctrl_mappings['backup'] =
'maintenance/backup.ctrl.php';
$ctrl_mappings['upgrade'] =
'maintenance/upgrade.ctrl.php';
* maintenance_Module definition
* Do the initializations. Called from in _main.inc.php.
* This is typically where classes matching DB tables for this module are registered/loaded.
* Note: this should only load/register things that are going to be needed application wide,
* for example: for constructing menus.
* Anything that is needed only in a specific controller should be loaded only there.
* Anything that is needed only in a specific view should be loaded only there.
load_funcs( 'maintenance/model/_maintenance.funcs.php' );
* Get default module permissions
* @param integer Group ID
case 1:
// Administrators group ID equals 1
case 2:
// Privileged Bloggers group equals 2
case 3:
// Bloggers group ID equals 3
// We can return as many default permissions as we want:
// e.g. array ( permission_name => permission_value, ... , ... )
return $permissions =
array( 'perm_maintenance' =>
$permname );
* Get available group permissions
* @return array (may contain several permission blocks)
// 'label' is used in the group form as label for radio buttons group
// 'user_func' function used to check user permission. This function should be defined in Module.
// 'group_func' function used to check group permission. This function should be defined in Module.
// 'perm_block' group form block where this permissions will be displayed. Now available, the following blocks: additional, system
// 'options' is permission options
'perm_maintenance' =>
array(
'label' =>
T_('Maintenance'),
'user_func' =>
'check_maintenance_user_perm',
'group_func' =>
'check_maintenance_group_perm',
'perm_block' =>
'system',
// format: array( radio_button_value, radio_button_label, radio_button_note )
array( 'none', T_( 'No Access' ), '' ),
array( 'backup', T_( 'Create backups' ), '' ),
array( 'upgrade', T_( 'Create backups & upgrade b2evolution' ), '' ),
* Check a permission for the user. ( see 'user_func' in get_available_group_permissions() function )
* @param string Requested permission level
* @param string Permission value
* @param mixed Permission target (blog ID, array of cat IDs...)
* @return boolean True on success (permission is granted), false if permission is not granted
* Check a permission for the group. ( see 'group_func' in get_available_group_permissions() function )
* @param string Requested permission level
* @param string Permission value
* @param mixed Permission target (blog ID, array of cat IDs...)
* @return boolean True on success (permission is granted), false if permission is not granted
// Users can create backups & upgrade the app.
if( $permlevel ==
'upgrade' )
{ // User can ask for delete perm...
// Users can create backups
if( $permlevel ==
'backup' )
* Builds the 3rd half of the menu. This is the one with the configuration features
* At some point this might be displayed differently than the 1st half.
global $AdminUI, $current_User;
if( $current_User->check_perm( 'perm_maintenance', 'backup' ) )
// Display Backup tab in Tools menu
$AdminUI->add_menu_entries( 'tools', array(
'href' =>
'?ctrl=backup' ),
if( $current_User->check_perm( 'perm_maintenance', 'upgrade' ) )
// Display Updates tab in Tools menu
$AdminUI->add_menu_entries( 'tools', array(
'text' =>
T_('Check for updates'),
'href' =>
'?ctrl=upgrade' ),
* $Log: _maintenance.init.php,v $
* Revision 1.5 2010/01/30 18:55:32 blueyed
* Fix "Assigning the return value of new by reference is deprecated" (PHP 5.3)
* Revision 1.4 2009/10/28 14:55:11 efy-maxim
* pluggable permissions separated by blocks in group form
* Revision 1.3 2009/10/27 18:21:52 fplanque
* Revision 1.2 2009/10/19 07:04:20 efy-maxim
* Revision 1.1 2009/10/18 20:15:51 efy-maxim
* 1. backup, upgrade have been moved to maintenance module
* 2. maintenance module permissions