Version 5.0.13

This commit is contained in:
Neo committed 2025-12-19 19:04:57 -08:00
1 parent b89858b2ff
commit 5efe744c5f
1407 files changed
+69690 -30177

No files matched your search

+62 -11
View File
@@ -20,11 +20,13 @@ use IPS\Helpers\Form\Text;
use IPS\Lang;
use IPS\Member;
use IPS\Member\Club;
use IPS\Member\Club\Template;
use IPS\Node\Model;
use IPS\Output;
use IPS\Output\UI\UiExtension;
use IPS\Request;
use IPS\Settings;
use IPS\Task;
use OutOfRangeException;
use UnderflowException;
use function count;
@@ -107,8 +109,6 @@ trait ClubContainer
*/
public function club(): Club|NULL
{
if ( Settings::i()->clubs )
{
$clubIdColumn = $this->clubIdColumn();
if ( $this->$clubIdColumn )
{
@@ -118,7 +118,6 @@ trait ClubContainer
}
catch ( OutOfRangeException $e ) { }
}
}
return NULL;
}
@@ -179,9 +178,10 @@ trait ClubContainer
*
* @param Club $club The club
* @param array $values Values
* @param Template|null $template
* @return void
*/
public function saveClubForm( Club $club, array $values ): void
public function saveClubForm( Club $club, array $values, ?Template $template = null ): void
{
/* @var Model $nodeClass */
$nodeClass = get_called_class();
@@ -219,11 +219,18 @@ trait ClubContainer
'node_class' => $nodeClass,
'node_id' => $this->_id,
'name' => $values['club_node_name'],
'public' => $values['club_node_public'] ?? 0,
'creators' => $values['club_node_creators'] ?? 0
'public' => $values['club_node_public'] ?? Club::NODE_PRIVATE,
'creators' => $values['club_node_creators'] ?? 0,
'template_id' => $template ? $template->id : 0
) );
$needToUpdatePermissions = TRUE;
/* If auto-follow is enabled in the club, queue the task so all members will follow the node */
if( $this->auto_follow )
{
Task::queue( 'core', 'AutoFollowClubs', [ 'club' => $this->club()->id, 'node' => $nodeClass, 'nodeId' => $this->_id ], 3, [ 'club', 'node', 'nodeId' ] );
}
}
else
{
@@ -235,7 +242,7 @@ trait ClubContainer
$this->save();
Db::i()->update( 'core_clubs_node_map', array(
'name' => $values['club_node_name'],
'public' => isset( $values['club_node_public'] ) ? (int) $values['club_node_public'] : 0,
'public' => isset( $values['club_node_public'] ) ? (int) $values['club_node_public'] : Club::NODE_PRIVATE,
'creators' => isset( $values['club_node_creators'] ) ? (int) $values['club_node_creators'] : 0
), array( 'club_id=? AND node_class=? AND node_id=?', $club->id, $nodeClass, $this->_id ) );
}
@@ -313,10 +320,21 @@ trait ClubContainer
$insert[ 'perm_' . $v ] = '*';
break;
case $club::TYPE_CLOSED:
$insert[ 'perm_' . $v ] = ( $this->isPublic() ) ? "*" : "cm,c{$club->id}";
switch( $this->isPublic() )
{
case Club::NODE_PRIVATE:
$insert['perm_' . $v ] = "cm,c{$club->id}";
break;
case Club::NODE_PUBLIC:
$insert['perm_' . $v ] = '*';
break;
case Club::NODE_MODERATORS:
$insert['perm_' . $v ] = 'cm';
break;
}
break;
case $club::TYPE_PRIVATE:
$insert[ 'perm_' . $v ] = "cm,c{$club->id}";
$insert[ 'perm_' . $v ] = ( $this->isPublic() == Club::NODE_MODERATORS ) ? "cm" : "cm,c{$club->id}";
break;
}
}
@@ -492,7 +510,7 @@ trait ClubContainer
return TRUE;
}
}
elseif ( $member->modPermission( "can_{$type}_{$title}" ) and is_array( $member->modPermission( static::$modPerm ) ) and $member->modPermission('can_access_all_clubs') )
elseif ( $member->modPermission( "can_{$type}_{$title}" ) and ( is_array( $member->modPermission( static::$modPerm ) ) or $member->modPermission( static::$modPerm ) === true ) and $member->modPermission('can_access_all_clubs') )
{
if ( in_array( $type, explode( ',', Settings::i()->clubs_modperms ) ) )
{
@@ -518,7 +536,7 @@ trait ClubContainer
}
catch ( UnderflowException $e )
{
return 0;
return Club::NODE_PRIVATE;
}
}
@@ -538,4 +556,37 @@ trait ClubContainer
return 0;
}
}
/**
* @return Template|null
*/
public function template() : ?Template
{
try
{
$templateId = Db::i()->select( 'template_id', 'core_clubs_node_map', [ 'node_class=? and node_id=?', get_called_class(), $this->_id ] )->first();
return Template::load( $templateId );
}
catch( UnderflowException | OutOfRangeException ){}
return null;
}
/**
* Determines if the club leader can manage this node
*
* @return bool
*/
public function canLeaderManage() : bool
{
if( $template = $this->template() )
{
if( array_key_exists( 'clubtemplates_leader_edit', $template->node_data ) )
{
return $template->node_data['clubtemplates_leader_edit'];
}
}
return true;
}
}