Source for file _groupsettings.class.php
Documentation is available at _groupsettings.class.php
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
load_class( 'settings/model/_abstractsettings.class.php', 'AbstractSettings' );
load_class( '_core/model/db/_sql.class.php', 'SQL' );
* This class represents group permissions
* Current or default permission values
var $_permissions =
array();
{ // call parent constructor
parent::AbstractSettings( 'T_groups__groupsettings', array( 'gset_grp_ID', 'gset_name' ), 'gset_value', 1 );
* @param integer Group ID
// Get default group permission from each module
foreach( $modules as $module )
$Module =
& $GLOBALS[$module.
'_Module'];
{ // Module has pluggable permissions and we can add them to the current setting
$this->add( $module, $Module->get_default_group_permissions( $grp_ID ), $grp_ID );
// Select current group permission from database
$SQL->FROM( 'T_groups__groupsettings' );
$SQL->WHERE( 'gset_grp_ID = '.
$grp_ID );
// Set current group permissions
$existing_perm =
array();
foreach( $DB->get_results( $SQL->get() ) as $row )
$existing_perm[] =
$row->gset_name;
// Set default group permission if these permissions don't exist
$update_permissions =
false;
if( ! in_array( $name, $existing_perm ) )
$this->set( $name, $value, $grp_ID );
$update_permissions =
true;
if( $update_permissions )
{ // We can update permission as there are some new permnissions
* Add default permission to the group.
* Each module can define its own default permissions.
* @param string module name
* @param array permissions
* @param integer Group ID
function add( $module, $permissions, $grp_ID )
if( ! empty( $permissions ) )
foreach( $permissions as $key =>
$value )
* Get a permission from the DB group settings table
* @param string name of permission
function get( $permission, $grp_ID )
{ // We can get permission from database, because the current group setting are available in database
* Temporarily sets a group permission ({@link dbupdate()} writes it to DB)
* @param string name of permission
* @param integer Group ID
function set( $permission, $value, $grp_ID )
{ // We can set permission, because the current group is already in database
return parent::set( $grp_ID, $permission, $value );
$this->_permissions[$permission] =
$value;
* Update the DB based on previously recorded changes
* @param integer Group ID
if( ! empty( $this->_permissions ) )
{ // Set temporary permissions. It is only for the new creating group
foreach( $this->_permissions as $name =>
$value )
$this->set( $name, $value, $grp_ID );
$this->_permissions =
array();
return parent::dbupdate();
* Delete all of the group permissions
* @param @param integer Group ID
parent::delete( $grp_ID, $name );