Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\Content;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -53,6 +53,19 @@ trait ClubContainer
|
||||
return static::$nodeTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if we need to re-acknowledge rules
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clubCheckRules()
|
||||
{
|
||||
if ( $club = $this->club() AND !$club->rulesAcknowledged() )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $club->url()->setQueryString( 'do', 'rules' )->addRef( \IPS\Request::i()->url() ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated club
|
||||
*
|
||||
@@ -96,7 +109,7 @@ trait ClubContainer
|
||||
*/
|
||||
public function saveClubForm( \IPS\Member\Club $club, $values )
|
||||
{
|
||||
$nodeClass = get_called_class();
|
||||
$nodeClass = \get_called_class();
|
||||
$itemClass = $nodeClass::$contentItemClass;
|
||||
$haveId = (bool) $this->_id;
|
||||
|
||||
@@ -136,8 +149,16 @@ trait ClubContainer
|
||||
$followApp = $itemClass::$application;
|
||||
$followArea = mb_strtolower( mb_substr( $nodeClass, mb_strrpos( $nodeClass, '\\' ) + 1 ) );
|
||||
$time = time();
|
||||
\IPS\Db::i()->insert( 'core_follow', \IPS\Db::i()->select( "MD5( CONCAT( '{$followApp};{$followArea};{$this->_id};', follow_member_id ) ) AS follow_id, '{$followApp}' AS follow_app, '{$followArea}' AS follow_area, '{$this->_id}' AS follow_rel_id, follow_member_id, follow_is_anon, '{$time}' AS follow_added, follow_notify_do, follow_notify_meta, follow_notify_freq, 0 AS follow_notify_sent, follow_visible", 'core_follow', array(
|
||||
'follow_app=? AND follow_area=? AND follow_rel_id=?', 'core', 'club', $club->id ) ) );
|
||||
$follows = array();
|
||||
foreach( \IPS\Db::i()->select( "MD5( CONCAT( '{$followApp};{$followArea};{$this->_id};', follow_member_id ) ) AS follow_id, '{$followApp}' AS follow_app, '{$followArea}' AS follow_area, '{$this->_id}' AS follow_rel_id, follow_member_id, follow_is_anon, '{$time}' AS follow_added, follow_notify_do, follow_notify_meta, follow_notify_freq, 0 AS follow_notify_sent, follow_visible", 'core_follow', array( 'follow_app=? AND follow_area=? AND follow_rel_id=?', 'core', 'club', $club->id ) ) AS $follow )
|
||||
{
|
||||
$follows[] = $follow;
|
||||
}
|
||||
|
||||
if ( \count( $follows ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_follow', $follows );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +189,7 @@ trait ClubContainer
|
||||
$insert = array( 'app' => static::$permApp, 'perm_type' => static::$permType, 'perm_type_id' => $this->_id );
|
||||
foreach ( static::$permissionMap as $k => $v )
|
||||
{
|
||||
if ( in_array( $k, array( 'view', 'read' ) ) )
|
||||
if ( \in_array( $k, array( 'view', 'read' ) ) )
|
||||
{
|
||||
switch ( $club->type )
|
||||
{
|
||||
@@ -184,7 +205,7 @@ trait ClubContainer
|
||||
break;
|
||||
}
|
||||
}
|
||||
elseif ( in_array( $k, array( 'add', 'edit', 'reply', 'review' ) ) )
|
||||
elseif ( \in_array( $k, array( 'add', 'edit', 'reply', 'review' ) ) )
|
||||
{
|
||||
switch ( $club->type )
|
||||
{
|
||||
@@ -240,12 +261,14 @@ trait ClubContainer
|
||||
* @param string|NULL $permissionCheck The permission key to check for or NULL to not check permissions
|
||||
* @param \IPS\Member|NULL $member The member to check permissions for or NULL for the currently logged in member
|
||||
* @param mixed $where Additional WHERE clause
|
||||
* @param array|NULL $limit Limit/offset to use, or NULL for no limit (default)
|
||||
* @return array
|
||||
*/
|
||||
public static function rootsWithClubs( $permissionCheck='view', $member=NULL, $where=array() )
|
||||
public static function rootsWithClubs( $permissionCheck='view', $member=NULL, $where=array(), $limit=NULL )
|
||||
{
|
||||
/* Will we need to check permissions? */
|
||||
if ( $permissionCheck !== NULL )
|
||||
$usingPermssions = ( \in_array( 'IPS\Node\Permissions', class_implements( \get_called_class() ) ) and $permissionCheck !== NULL );
|
||||
if ( $usingPermssions )
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
}
|
||||
@@ -262,7 +285,7 @@ trait ClubContainer
|
||||
$order .= ', ' . static::$databasePrefix . static::$databaseColumnOrder;
|
||||
}
|
||||
|
||||
return static::nodesWithPermission( $permissionCheck, $member, $where, $order );
|
||||
return static::nodesWithPermission( $usingPermssions ? $permissionCheck : NULL, $member, $where, $order, $limit );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,9 +305,36 @@ trait ClubContainer
|
||||
{
|
||||
if( static::$cachedClubNodes === NULL )
|
||||
{
|
||||
$where[] = array( static::$databasePrefix . static::clubIdColumn() . ' IS NOT NULL' );
|
||||
$clubIdColumn = static::clubIdColumn();
|
||||
|
||||
$where[] = array( static::$databasePrefix . $clubIdColumn . ' IS NOT NULL' );
|
||||
|
||||
static::$cachedClubNodes = static::nodesWithPermission( $permissionCheck, $member, $where );
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
|
||||
if( $member->canAccessModule( \IPS\Application\Module::get( 'core', 'clubs', 'front' ) ) )
|
||||
{
|
||||
static::$cachedClubNodes = static::nodesWithPermission( $permissionCheck, $member, $where );
|
||||
}
|
||||
else
|
||||
{
|
||||
static::$cachedClubNodes = array();
|
||||
}
|
||||
|
||||
/* Preload the clubs so we don't query each one individually later */
|
||||
$clubIds = array();
|
||||
|
||||
foreach( static::$cachedClubNodes as $node )
|
||||
{
|
||||
$clubIds[] = $node->$clubIdColumn;
|
||||
}
|
||||
|
||||
if( \count( $clubIds ) )
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_clubs', array( 'id IN(' . implode( ',', $clubIds ) . ')' ) ) as $clubData )
|
||||
{
|
||||
\IPS\Member\Club::constructFromData( $clubData );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return static::$cachedClubNodes;
|
||||
@@ -295,16 +345,17 @@ trait ClubContainer
|
||||
*
|
||||
* @param string $type 'edit', 'hide', 'unhide', 'delete', etc.
|
||||
* @param \IPS\Member|NULL $member The member to check for or NULL for the currently logged in member
|
||||
* @param string|NULL $itemClass The item class to check against, or NULL to check against static::$contentItemClass
|
||||
* @param string $class The class to check against
|
||||
* @return bool
|
||||
*/
|
||||
public function modPermission( $type, \IPS\Member $member, $itemClass=NULL )
|
||||
public function modPermission( $type, \IPS\Member $member, $class )
|
||||
{
|
||||
if ( \IPS\Settings::i()->clubs )
|
||||
{
|
||||
$clubIdColumn = $this->clubIdColumn();
|
||||
$itemClass = $itemClass ?: static::$contentItemClass;
|
||||
$title = $itemClass::$title;
|
||||
|
||||
$class = $class ?: static::$contentItemClass;
|
||||
$title = $class::$title;
|
||||
|
||||
if ( $this->$clubIdColumn and $club = $this->club() )
|
||||
{
|
||||
@@ -325,7 +376,7 @@ trait ClubContainer
|
||||
}
|
||||
}
|
||||
|
||||
return parent::modPermission( $type, $member, $itemClass );
|
||||
return parent::modPermission( $type, $member, $class );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user