Version 3.2.3
This commit is contained in:
1 parent
ae5c01cc78
commit
78706903a2
2641 files changed
+228363
-201264
No files matched your search
@@ -2,16 +2,16 @@
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* IP.Board v3.2.3
|
||||
* Manages public permissions
|
||||
* Last Updated: $Date: 2010-11-16 06:40:55 -0500 (Tue, 16 Nov 2010) $
|
||||
* Last Updated: $Date: 2011-05-20 04:06:50 -0400 (Fri, 20 May 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* @author Joshua Williams
|
||||
* @package IP.Board
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @link http://www.invisionpower.com
|
||||
* @license This is NULLED!
|
||||
* @link http://hatynka.in
|
||||
* @since Wednesday 14th May 2008 14:00
|
||||
*/
|
||||
|
||||
@@ -33,21 +33,70 @@ class classPublicPermissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $mappings = array();
|
||||
protected $mappings = array();
|
||||
|
||||
/**
|
||||
* Ability to set a different member for permission checks, etc
|
||||
* @var array
|
||||
*/
|
||||
protected $_memberData = array();
|
||||
|
||||
/**
|
||||
* Constructer
|
||||
*
|
||||
* @param object ipsRegistry $registry
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct( ipsRegistry $registry )
|
||||
{
|
||||
/* Make object */
|
||||
$this->registry = $registry;
|
||||
$this->lang = $this->registry->getClass('class_localization');
|
||||
$this->member = $this->registry->member();
|
||||
$this->registry = $registry;
|
||||
$this->lang = $this->registry->getClass('class_localization');
|
||||
$this->member = $this->registry->member();
|
||||
$this->memberData =& $this->registry->member()->fetchMemberData();
|
||||
|
||||
/* Set default memberData */
|
||||
$this->setMemberData( $this->memberData );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the $_memberData
|
||||
*/
|
||||
public function getMemberData( $k='' )
|
||||
{
|
||||
return ( ! empty( $k ) ) ? $this->_memberData[ $k ] : $this->_memberData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string key
|
||||
* @param string value
|
||||
*/
|
||||
public function setMemberData( $k, $v='' )
|
||||
{
|
||||
if ( is_integer( $k ) )
|
||||
{
|
||||
$this->_memberData = IPSMember::load( $k, 'all' );
|
||||
}
|
||||
else if ( is_array( $k ) )
|
||||
{
|
||||
$this->_memberData = $k;
|
||||
}
|
||||
else if ( ! empty( $k ) )
|
||||
{
|
||||
$this->_memberData[ $k ] = $v;
|
||||
}
|
||||
|
||||
/* Set perm ids and that */
|
||||
if ( $this->memberData['member_id'] == $this->_memberData['member_id'] )
|
||||
{
|
||||
$this->_memberData['_perm_id_array'] = $this->member->perm_id_array;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Force to guest for now */
|
||||
$permId = ( ! empty( $this->_memberData['org_perm_id'] ) ) ? $this->_memberData['org_perm_id'] : $this->_memberData['g_perm_id'];
|
||||
$this->_memberData['_perm_id_array'] = array_unique( explode( ",", $permId ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,13 +185,13 @@ class classPublicPermissions
|
||||
* @param array $otherMasks Masks to check (defaults to current viewer)
|
||||
* @return bool
|
||||
*/
|
||||
private function _help_check( $perm, $row, $otherMasks=array() )
|
||||
protected function _help_check( $perm, $row, $otherMasks=array() )
|
||||
{
|
||||
/* Permission column */
|
||||
$perm_column = '';
|
||||
|
||||
/* Masks to check */
|
||||
$masks = count($otherMasks) ? $otherMasks : $this->member->perm_id_array;
|
||||
$masks = count($otherMasks) ? $otherMasks : $this->_memberData['_perm_id_array'];
|
||||
|
||||
if( $perm == 'view' )
|
||||
{
|
||||
@@ -275,13 +324,14 @@ class classPublicPermissions
|
||||
/**
|
||||
* Builds a permission selection matrix
|
||||
*
|
||||
* @param string $type The permission type to build
|
||||
* @param array $default Current permissions
|
||||
* @param string [$app] App that the type belongs too, default is the current app
|
||||
* @param string [$only_perm] Only show this permission
|
||||
* @return string
|
||||
* @param string $type The permission type to build
|
||||
* @param array $default Current permissions
|
||||
* @param string $app App that the type belongs too, default is the current app
|
||||
* @param string $only_perm Only show this permission
|
||||
* @param boolean $addOutsideBox Add or not the outside acp-box
|
||||
* @return @e string HTML
|
||||
*/
|
||||
public function adminPermMatrix( $type, $default, $app='', $only_perm='' )
|
||||
public function adminPermMatrix( $type, $default, $app='', $only_perm='', $addOutsideBox=true )
|
||||
{
|
||||
/* INI */
|
||||
$app = ( $app ) ? $app : ipsRegistry::$current_application;
|
||||
@@ -295,10 +345,10 @@ class classPublicPermissions
|
||||
ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'admin_permissions' ), 'members' );
|
||||
|
||||
/* Get Mappings */
|
||||
require_once( IPSLib::getAppDir( $app ) . '/extensions/coreExtensions.php' );
|
||||
$mapping = new $map_class();
|
||||
$perm_names = $mapping->getPermNames();
|
||||
$perm_map = $mapping->getMapping();
|
||||
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $app ) . '/extensions/coreExtensions.php', $map_class, $app );
|
||||
$mapping = new $classToLoad();
|
||||
$perm_names = $mapping->getPermNames();
|
||||
$perm_map = $mapping->getMapping();
|
||||
|
||||
/* Language... */
|
||||
$this->lang->loadLanguageFile( array( 'admin_' . $app ), $app );
|
||||
@@ -359,7 +409,7 @@ class classPublicPermissions
|
||||
}
|
||||
|
||||
/* Return the matrix */
|
||||
return $html->permissionMatrix( $perm_names, $perm_matrix, $perm_checked, $mapping->getPermColors() );
|
||||
return $html->permissionMatrix( $perm_names, $perm_matrix, $perm_checked, $mapping->getPermColors(), $type, $addOutsideBox );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -368,7 +418,7 @@ class classPublicPermissions
|
||||
* @param array Input perm matrix
|
||||
* @param int Set ID
|
||||
* @param array Applications originally on the form
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function saveItemPermMatrix( $perm_matrix, $set_id, $applications=array() )
|
||||
{
|
||||
@@ -383,11 +433,11 @@ class classPublicPermissions
|
||||
$_perm_row = array();
|
||||
|
||||
/* We need the mappings for this application */
|
||||
require_once( IPSLib::getAppDir( $app ) . '/extensions/coreExtensions.php' );
|
||||
$map_class = $app . 'PermMapping' . $type;
|
||||
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $app ) . '/extensions/coreExtensions.php', $map_class, $app );
|
||||
|
||||
/* Create the mapping object */
|
||||
$map_class = $app . 'PermMapping' . $type;
|
||||
$mapping = new $map_class();
|
||||
$mapping = new $classToLoad();
|
||||
$mapping_array = $mapping->getMapping();
|
||||
|
||||
/* Loop through each perm in this app */
|
||||
@@ -516,11 +566,11 @@ class classPublicPermissions
|
||||
$perm_save_row = array();
|
||||
|
||||
/* Get Mappings */
|
||||
require_once( IPSLib::getAppDir( $app ) . '/extensions/coreExtensions.php' );
|
||||
$mapping = new $map_class();
|
||||
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $app ) . '/extensions/coreExtensions.php', $map_class, $app );
|
||||
$mapping = new $classToLoad();
|
||||
$mapping_array = $mapping->getMapping();
|
||||
$customTable = ( method_exists( $mapping, 'getCustomTable' ) ) ? $mapping->getCustomTable() : false;
|
||||
|
||||
|
||||
/* Loop through mapping and build save array */
|
||||
foreach( $mapping_array as $k => $col )
|
||||
{
|
||||
@@ -528,22 +578,22 @@ class classPublicPermissions
|
||||
$perm_save_row[$col] = '';
|
||||
|
||||
/* Check the matrix for this perm */
|
||||
if( $perm_matrix[$k] )
|
||||
if( $perm_matrix[$type . $k] )
|
||||
{
|
||||
/* Global? */
|
||||
if( isset( $perm_matrix[$k]['*'] ) && $perm_matrix[$k]['*'] == '1' )
|
||||
if( !empty( $perm_matrix[$type . $k]['*'] ) )
|
||||
{
|
||||
$perm_save_row[$col] = '*';
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Do we have permissions? */
|
||||
if( is_array( $perm_matrix[$k] ) && count( $perm_matrix[$k] ) )
|
||||
if( is_array( $perm_matrix[$type . $k] ) && count( $perm_matrix[$type . $k] ) )
|
||||
{
|
||||
/* Loop through the permissions */
|
||||
$perm_save_row[$col] = ',';
|
||||
|
||||
foreach( $perm_matrix[$k] as $mask => $v )
|
||||
foreach( $perm_matrix[$type . $k] as $mask => $v )
|
||||
{
|
||||
if( $v == 1 )
|
||||
{
|
||||
@@ -554,7 +604,7 @@ class classPublicPermissions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( ! $customTable )
|
||||
{
|
||||
/* Ensure all text fields have a default value */
|
||||
@@ -589,34 +639,34 @@ class classPublicPermissions
|
||||
* @param array $row Permission row from permission_index
|
||||
* @return bool
|
||||
*/
|
||||
private function load_mapping( $row )
|
||||
protected function load_mapping( $row )
|
||||
{
|
||||
if( !$row['app'] )
|
||||
if( !isset($row['app']) OR !$row['app'] )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Mapping Class */
|
||||
$mapping_class = $row['app'] . 'PermMapping' . ucfirst( $row['perm_type'] );
|
||||
$classToLoad = $row['app'] . 'PermMapping' . ucfirst( $row['perm_type'] );
|
||||
|
||||
/* Check for the class */
|
||||
if( ! class_exists( $mapping_class ) )
|
||||
if( ! class_exists( $classToLoad ) )
|
||||
{
|
||||
/* Check for the file */
|
||||
if( file_exists( IPSLib::getAppDir( $row['app'] ) . '/extensions/coreExtensions.php' ) )
|
||||
if( is_file( IPSLib::getAppDir( $row['app'] ) . '/extensions/coreExtensions.php' ) )
|
||||
{
|
||||
require_once IPSLib::getAppDir( $row['app'] ) . '/extensions/coreExtensions.php';
|
||||
$classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $row['app'] ) . '/extensions/coreExtensions.php', $classToLoad, $row['app'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Load the mapping */
|
||||
if( class_exists( $mapping_class ) )
|
||||
if( class_exists( $classToLoad ) )
|
||||
{
|
||||
$mapping = new $mapping_class();
|
||||
$mapping = new $classToLoad();
|
||||
$this->mappings[$row['app']][$row['perm_type']] = $mapping->getMapping();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user