* Invision Power Services * IP.Board v3.3.4 * ACP restrictions skin file * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $ * * * @author $Author: bfarber $ * @copyright (c) 2001 - 2009 Invision Power Services, Inc. * @license http://www.invisionpower.com/company/standards.php#license * @package IP.Board * @subpackage Members * @link http://www.invisionpower.com * @since 20th February 2002 * @version $Rev: 10914 $ * */ class cp_skin_restrictions { /** * Registry Object Shortcuts * * @var $registry * @var $DB * @var $settings * @var $request * @var $lang * @var $member * @var $memberData * @var $cache * @var $caches */ protected $registry; protected $DB; protected $settings; protected $request; protected $lang; protected $member; protected $memberData; protected $cache; protected $caches; /** * Constructor * * @param object $registry Registry object * @return @e void */ public function __construct( ipsRegistry $registry ) { $this->registry = $registry; $this->DB = $this->registry->DB(); $this->settings =& $this->registry->fetchSettings(); $this->request =& $this->registry->fetchRequest(); $this->member = $this->registry->member(); $this->memberData =& $this->registry->member()->fetchMemberData(); $this->cache = $this->registry->cache(); $this->caches =& $this->registry->cache()->fetchCaches(); $this->lang = $this->registry->class_localization; } /** * Form to add a new restricted member * * @return string HTML */ public function restrictionsMemberForm() { $IPBHTML = ""; //--starthtml--// $IPBHTML .= <<

{$this->lang->words['r_title']}

_admin_auth_key}' />

{$this->lang->words['r_findadmin']}

{$this->lang->words['r_displayname']}
{$this->lang->words['r_displayname_info']}
HTML; //--endhtml--// return $IPBHTML; } /** * Form to add a new restricted group * * @return string HTML */ public function restrictionsGroupForm() { $IPBHTML = ""; //--starthtml--// $all_groups = array(); foreach( $this->cache->getCache('group_cache') as $group_data ) { if( $group_data['g_access_cp'] ) { $all_groups[] = array( $group_data['g_id'], $group_data['g_title'] ); } } $dropDown = $this->registry->output->formDropdown( "entered_group", $all_groups ); $IPBHTML .= <<

{$this->lang->words['r_title']}

_admin_auth_key}' />

{$this->lang->words['r_selectgroup']}

{$this->lang->words['r_whatgroup']} {$dropDown}
HTML; //--endhtml--// return $IPBHTML; } /** * ACP restrictions overview * * @param array Members * @param array Groups * @return string HTML */ public function acpPermsOverview( $members, $groups ) { $IPBHTML = ""; //--starthtml--// $IPBHTML .= <<

{$this->lang->words['r_title']}

{$this->lang->words['r_memberrestrict']}

{$members}
{$this->lang->words['r_member']} {$this->lang->words['r_primary']} {$this->lang->words['r_secondary']} {$this->lang->words['r_updated']}  

{$this->lang->words['r_grouprestrict']}

{$groups}
{$this->lang->words['r_group']} {$this->lang->words['r_totalmem']} {$this->lang->words['r_updated']}  
HTML; //--endhtml--// return $IPBHTML; } /** * Restricted member * * @param array Member data * @return string HTML */ public function acpMemberRow( $data ) { $IPBHTML = ""; //--starthtml--// $IPBHTML .= << @ {$data['members_display_name']} {$data['_group_name']} {$data['_other_groups']} {$data['_date']} HTML; //--endhtml--// return $IPBHTML; } /** * Restricted group * * @param array Group data * @return string HTML */ public function acpGroupRow( $data ) { $IPBHTML = ""; //--starthtml--// $IPBHTML .= << @ {$data['_group_name']} {$data['_total']} {$data['_date']} HTML; //--endhtml--// return $IPBHTML; } /** * Add new restrictions form * * @param int Role id * @param string Role type * @param array Permissions * @param array Access capabilities * @return string HTML */ public function restrictionsForm( $role_id=0, $role_type='member', $permissions=array(), $access=array() ) { $itemsByModules = array(); $IPBHTML = ""; //--starthtml--// $IPBHTML .= <<

{$this->lang->words['r_title']}

form_code}&do=acpperms-save&secure_key={$this->registry->getClass('adminFunctions')->_admin_auth_key}' method='post' id='adform' name='adform'>

Set Restrictions

« »
    HTML; foreach( ipsRegistry::$applications as $app_dir => $application ) { if( is_array(ipsRegistry::$modules[ $app_dir ]) AND count(ipsRegistry::$modules[ $app_dir ]) ) { $IPBHTML .= "
  • {$application['app_title']}
  • \n"; } } $IPBHTML .= <<
HTML; foreach( ipsRegistry::$applications as $app_dir => $application ) { $checked = in_array( $application['app_id'], $access['applications'] ) ? 1 : 0; $form = $this->registry->output->formCheckbox( 'app_' . $application['app_id'], $checked, 1, 'app_' . $application['app_id'], "onclick='checkApp( {$application['app_id']} );'" ); if( is_array(ipsRegistry::$modules[ $app_dir ]) AND count(ipsRegistry::$modules[ $app_dir ]) ) { $IPBHTML .= <<
HTML; foreach( ipsRegistry::$modules[ $app_dir ] as $module ) { $checked = in_array( $module['sys_module_id'], $access['modules'] ) ? 1 : 0; $form = $this->registry->output->formCheckbox( 'module_' . $module['sys_module_id'], $checked, 1, 'module_' . $module['sys_module_id'], "onclick='checkModule( {$module['sys_module_id']} );'" ); if( ! $module['sys_module_admin'] ) { continue; } $IPBHTML .= <<       HTML; if( is_array( $permissions ) AND is_array($permissions[ $application['app_id'] ][ $module['sys_module_id'] ]) AND count($permissions[ $application['app_id'] ][ $module['sys_module_id'] ]) ) { // Call me lazy if you wish :P $shorten = $permissions[ $application['app_id'] ][ $module['sys_module_id'] ]; foreach( $shorten as $group => $shorter ) { if( !is_array($shorter) OR !count($shorter) ) { continue; } $IPBHTML .= <<           {$shorter['title']} HTML; if( is_array($shorter['items']) AND count($shorter['items']) ) { foreach( $shorter['items'] as $item_key => $item_text ) { $itemsByModules[ $module['sys_module_id'] ][] = $item_key; $checked = (is_array($access['items'][ $module['sys_module_id'] ]) AND in_array($item_key, $access['items'][ $module['sys_module_id'] ] )) ? 1 : 0; $form = $this->registry->output->formCheckbox( 'item_' . $module['sys_module_id'] . '_' . $item_key, $checked, 1, 'item_' . $module['sys_module_id'] . '_' . $item_key, "onclick='checkItem( {$module['sys_module_id']} );'" ); $IPBHTML .= <<                 HTML; } } $IPBHTML .= << HTML; } } } $IPBHTML .= << HTML; } } $IPBHTML .= <<
HTML; $IPBHTML .= << var modulesByApp = []; var appsByModule = []; var itemsByModule = []; HTML; foreach( ipsRegistry::$applications as $app_dir => $application ) { $modules = array(); foreach( ipsRegistry::$modules[ $app_dir ] as $module ) { if( ! $module['sys_module_admin'] ) { continue; } $modules[] = $module['sys_module_id']; $IPBHTML .= << $items ) { $items = implode( ',', array_map( create_function( '$v', 'return "\'$v\'";' ), $items ) ); $IPBHTML .= << HTML; //--endhtml--// return $IPBHTML; } }