Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
+513
-444
File diff suppressed because it is too large.
Load diff
@@ -12,46 +12,58 @@
|
||||
namespace IPS\Member\Club;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use ArrayIterator;
|
||||
use IPS\CustomField as SystemCustomField;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Node\Permissions;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clubs Customer Field Node
|
||||
*/
|
||||
class _CustomField extends \IPS\CustomField
|
||||
class CustomField extends SystemCustomField implements Permissions
|
||||
{
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
protected static array $multitons;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'core_clubs_fields';
|
||||
public static ?string $databaseTable = 'core_clubs_fields';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'f_';
|
||||
public static string $databasePrefix = 'f_';
|
||||
|
||||
/**
|
||||
* @brief [Node] Order Database Column
|
||||
*/
|
||||
public static $databaseColumnOrder = 'position';
|
||||
public static ?string $databaseColumnOrder = 'position';
|
||||
|
||||
/**
|
||||
* @brief [CustomField] Title/Description lang prefix
|
||||
*/
|
||||
protected static $langKey = 'core_clubfield';
|
||||
protected static string $langKey = 'core_clubfield';
|
||||
|
||||
/**
|
||||
* @brief [CustomField] Content database table
|
||||
*/
|
||||
protected static $contentDatabaseTable = 'core_clubs_fieldvalues';
|
||||
protected static string $contentDatabaseTable = 'core_clubs_fieldvalues';
|
||||
|
||||
/**
|
||||
* @brief [Node] ACP Restrictions
|
||||
@@ -69,7 +81,7 @@ class _CustomField extends \IPS\CustomField
|
||||
'prefix' => 'foo_', // [Optional] Rather than specifying each key in the map, you can specify a prefix, and it will automatically look for restrictions with the key "[prefix]_add/edit/permissions/delete"
|
||||
* @endcode
|
||||
*/
|
||||
protected static $restrictions = array(
|
||||
protected static ?array $restrictions = array(
|
||||
'app' => 'core',
|
||||
'module' => 'clubs',
|
||||
'all' => 'fields_manage'
|
||||
@@ -78,17 +90,17 @@ class _CustomField extends \IPS\CustomField
|
||||
/**
|
||||
* @brief [Node] Node Title
|
||||
*/
|
||||
public static $nodeTitle = 'clubs_custom_fields';
|
||||
public static string $nodeTitle = 'clubs_custom_fields';
|
||||
|
||||
/**
|
||||
* @brief [Node] Title prefix. If specified, will look for a language key with "{$key}_title" as the key
|
||||
*/
|
||||
public static $titleLangPrefix = 'core_clubfield_';
|
||||
public static ?string $titleLangPrefix = 'core_clubfield_';
|
||||
|
||||
/**
|
||||
* @brief [CustomField] Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
public static array $databaseColumnMap = array(
|
||||
'content' => 'extra',
|
||||
'not_null' => 'required',
|
||||
);
|
||||
@@ -96,7 +108,7 @@ class _CustomField extends \IPS\CustomField
|
||||
/**
|
||||
* @brief [CustomField] Additional Field Toggles
|
||||
*/
|
||||
public static $additionalFieldToggles = array(
|
||||
public static array $additionalFieldToggles = array(
|
||||
'Checkbox' => array( 'f_filterable' ),
|
||||
'CheckboxSet' => array( 'f_filterable' ),
|
||||
'Radio' => array( 'f_filterable' ),
|
||||
@@ -107,38 +119,72 @@ class _CustomField extends \IPS\CustomField
|
||||
/**
|
||||
* @brief [CustomField] Editor Options
|
||||
*/
|
||||
public static $editorOptions = array( 'app' => 'core', 'key' => 'Clubs' );
|
||||
public static array $editorOptions = array( 'app' => 'core', 'key' => 'Clubs' );
|
||||
|
||||
/**
|
||||
* @brief [CustomField] Upload Storage Extension
|
||||
*/
|
||||
public static $uploadStorageExtension = 'core_ClubField';
|
||||
public static string $uploadStorageExtension = 'core_ClubField';
|
||||
|
||||
/**
|
||||
* @brief The map of permission columns
|
||||
*/
|
||||
public static array $permissionMap = array(
|
||||
'view' => 'view',
|
||||
'edit' => 2
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief [Node] App for permission index
|
||||
*/
|
||||
public static ?string $permApp = 'core';
|
||||
|
||||
/**
|
||||
* @brief [Node] Type for permission index
|
||||
*/
|
||||
public static ?string $permType = 'clubfields';
|
||||
|
||||
/**
|
||||
* @brief [Node] Prefix string that is automatically prepended to permission matrix language strings
|
||||
*/
|
||||
public static string $permissionLangPrefix = 'perm_club_field_';
|
||||
|
||||
/**
|
||||
*
|
||||
* [Node] Does the currently logged in user have permission to edit permissions for this node?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canManagePermissions(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fields
|
||||
*
|
||||
* @return array
|
||||
* @return array|ActiveRecordIterator
|
||||
*/
|
||||
public static function fields()
|
||||
public static function fields(): ActiveRecordIterator|array
|
||||
{
|
||||
if ( !isset( \IPS\Data\Store::i()->clubFields ) )
|
||||
if ( !isset( Store::i()->clubFields ) )
|
||||
{
|
||||
$fields = array();
|
||||
$filterable = FALSE;
|
||||
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_clubs_fields', NULL, 'f_position' ) as $row )
|
||||
foreach ( Db::i()->select( '*', 'core_clubs_fields', NULL, 'f_position' ) as $row )
|
||||
{
|
||||
$fields[ $row['f_id'] ] = $row;
|
||||
if ( $row['f_filterable'] and \in_array( $row['f_type'], array( 'Checkbox', 'CheckboxSet', 'Radio', 'Select', 'YesNo' ) ) )
|
||||
if ( $row['f_filterable'] and in_array( $row['f_type'], array( 'Checkbox', 'CheckboxSet', 'Radio', 'Select', 'YesNo' ) ) )
|
||||
{
|
||||
$filterable = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Data\Store::i()->clubFields = array( 'fields' => $fields, 'filterable' => $filterable );
|
||||
Store::i()->clubFields = array( 'fields' => $fields, 'filterable' => $filterable );
|
||||
}
|
||||
|
||||
return new \IPS\Patterns\ActiveRecordIterator( new \ArrayIterator( \IPS\Data\Store::i()->clubFields['fields'] ), 'IPS\Member\Club\CustomField' );
|
||||
return new ActiveRecordIterator( new ArrayIterator( Store::i()->clubFields['fields'] ), 'IPS\Member\Club\CustomField' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,26 +192,26 @@ class _CustomField extends \IPS\CustomField
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function areFilterableFields()
|
||||
public static function areFilterableFields(): bool
|
||||
{
|
||||
if ( !isset( \IPS\Data\Store::i()->clubFields ) )
|
||||
if ( !isset( Store::i()->clubFields ) )
|
||||
{
|
||||
static::fields();
|
||||
}
|
||||
return \IPS\Data\Store::i()->clubFields['filterable'];
|
||||
return Store::i()->clubFields['filterable'];
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Add/Edit Form
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The form
|
||||
* @param Form $form The form
|
||||
* @return void
|
||||
*/
|
||||
public function form( &$form )
|
||||
public function form( Form &$form ) : void
|
||||
{
|
||||
parent::form( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'f_filterable', (bool) $this->filterable, FALSE, array(), NULL, NULL, NULL, 'f_filterable' ) );
|
||||
$form->add( new YesNo( 'f_filterable', (bool) $this->filterable, FALSE, array(), NULL, NULL, NULL, 'f_filterable' ) );
|
||||
|
||||
unset( $form->elements[''][1] );
|
||||
unset( $form->elements['']['pf_max_input'] );
|
||||
@@ -179,7 +225,7 @@ class _CustomField extends \IPS\CustomField
|
||||
* @brief [ActiveRecord] Caches
|
||||
* @note Defined cache keys will be cleared automatically as needed
|
||||
*/
|
||||
protected $caches = array( 'clubFields' );
|
||||
protected array $caches = array( 'clubFields' );
|
||||
|
||||
/**
|
||||
* [Node] Format form values from add/edit form for save
|
||||
@@ -187,7 +233,7 @@ class _CustomField extends \IPS\CustomField
|
||||
* @param array $values Values from the form
|
||||
* @return array
|
||||
*/
|
||||
public function formatFormValues( $values )
|
||||
public function formatFormValues( array $values ): array
|
||||
{
|
||||
if( array_key_exists( 'pf_allow_attachments', $values ) )
|
||||
{
|
||||
|
||||
+79
-59
@@ -11,47 +11,67 @@
|
||||
namespace IPS\Member\Club;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\File;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\CheckboxSet;
|
||||
use IPS\Helpers\Form\Editor;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Http\Url\Friendly;
|
||||
use IPS\Http\Url\Internal;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Club;
|
||||
use IPS\Patterns\ActiveRecord;
|
||||
use IPS\Settings;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Club Page Model
|
||||
*/
|
||||
class _Page extends \IPS\Patterns\ActiveRecord
|
||||
class Page extends ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
protected static array $multitons;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'core_club_pages';
|
||||
public static ?string $databaseTable = 'core_club_pages';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'page_';
|
||||
public static string $databasePrefix = 'page_';
|
||||
|
||||
/**
|
||||
* @brief Club Store
|
||||
*/
|
||||
protected static $clubs = array();
|
||||
protected static array $clubs = array();
|
||||
|
||||
/**
|
||||
* Get Club
|
||||
*
|
||||
* @return \IPS\Member\Club
|
||||
* @return Club
|
||||
*/
|
||||
public function get_club(): \IPS\Member\Club
|
||||
public function get_club(): Club
|
||||
{
|
||||
if ( !isset( static::$clubs[ $this->_data['club'] ] ) )
|
||||
{
|
||||
static::$clubs[ $this->_data['club'] ] = \IPS\Member\Club::load( $this->_data['club'] );
|
||||
static::$clubs[ $this->_data['club'] ] = Club::load( $this->_data['club'] );
|
||||
}
|
||||
|
||||
return static::$clubs[ $this->_data['club'] ];
|
||||
@@ -60,10 +80,10 @@ class _Page extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Set Club
|
||||
*
|
||||
* @param \IPS\Member\Club $club The club
|
||||
* @param Club $club The club
|
||||
* @return void
|
||||
*/
|
||||
public function set_club( \IPS\Member\Club $club )
|
||||
public function set_club( Club $club ) : void
|
||||
{
|
||||
$this->_data['club'] = $club->id;
|
||||
unset( static::$clubs[ $club->id ] );
|
||||
@@ -78,7 +98,7 @@ class _Page extends \IPS\Patterns\ActiveRecord
|
||||
{
|
||||
if ( !$this->_data['seo_title'] )
|
||||
{
|
||||
$this->seo_title = \IPS\Http\Url\Friendly::seoTitle( $this->_data['title'] );
|
||||
$this->seo_title = Friendly::seoTitle( $this->_data['title'] );
|
||||
$this->save();
|
||||
}
|
||||
|
||||
@@ -91,10 +111,10 @@ class _Page extends \IPS\Patterns\ActiveRecord
|
||||
* @param string $title The page title
|
||||
* @return void
|
||||
*/
|
||||
public function set_title( string $title )
|
||||
public function set_title( string $title ) : void
|
||||
{
|
||||
$this->_data['title'] = $title;
|
||||
$this->_data['seo_title'] = \IPS\Http\Url\Friendly::seoTitle( $title );
|
||||
$this->_data['seo_title'] = Friendly::seoTitle( $title );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,9 +123,9 @@ class _Page extends \IPS\Patterns\ActiveRecord
|
||||
* @param array|NULL $value The value to set
|
||||
* @return void
|
||||
*/
|
||||
public function set_can_view( ?array $value )
|
||||
public function set_can_view( ?array $value ) : void
|
||||
{
|
||||
if ( \is_array( $value ) )
|
||||
if ( is_array( $value ) )
|
||||
{
|
||||
$this->_data['can_view'] = implode( ',', $value );
|
||||
}
|
||||
@@ -128,30 +148,30 @@ class _Page extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Form
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form Form Object
|
||||
* @param \IPS\Member\Club $club Club this page belongs too.
|
||||
* @param \IPS\Member\Club\Page|NULL $current If we are editing, the current page.
|
||||
* @param Form $form Form Object
|
||||
* @param Club $club Club this page belongs too.
|
||||
* @param Page|NULL $current If we are editing, the current page.
|
||||
* @return void
|
||||
*/
|
||||
public static function form( \IPS\Helpers\Form $form, \IPS\Member\Club $club, ?\IPS\Member\Club\Page $current = NULL )
|
||||
public static function form( Form $form, Club $club, ?Page $current = NULL ) : void
|
||||
{
|
||||
$form->hiddenValues['page_club'] = $club->id;
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'club_page_title', ( $current ) ? $current->title : NULL, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'club_page_content', ( $current ) ? $current->content : NULL, TRUE, array(
|
||||
$form->add( new Text( 'club_page_title', ( $current ) ? $current->title : NULL, TRUE ) );
|
||||
$form->add( new Editor( 'club_page_content', ( $current ) ? $current->content : NULL, TRUE, array(
|
||||
'app' => 'core',
|
||||
'key' => 'ClubPage',
|
||||
'autoSaveKey' => ( $current ) ? "club-page-{$current->id}" : "club-page-new",
|
||||
'attachIds' => ( $current ) ? array( $current->id, NULL, NULL ) : NULL
|
||||
) ) );
|
||||
|
||||
if ( $club->type !== \IPS\Member\Club::TYPE_PUBLIC )
|
||||
if ( $club->type !== Club::TYPE_PUBLIC )
|
||||
{
|
||||
$defaults = array( 'member', 'moderator' );
|
||||
if ( $club->type !== \IPS\Member\Club::TYPE_PRIVATE )
|
||||
if ( $club->type !== Club::TYPE_PRIVATE )
|
||||
{
|
||||
$defaults[] = 'nonmember';
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'page_can_view', ( $current AND $current->can_view ) ? $current->can_view : $defaults, FALSE, array( 'options' => array(
|
||||
$form->add( new CheckboxSet( 'page_can_view', ( $current AND $current->can_view ) ? $current->can_view : $defaults, FALSE, array( 'options' => array(
|
||||
'nonmember' => 'club_page_nonmembers',
|
||||
'member' => 'club_page_members',
|
||||
'moderator' => 'club_page_moderators'
|
||||
@@ -159,9 +179,9 @@ class _Page extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
|
||||
/* Add the index setting if this page is shown to guests */
|
||||
if ( $club->type !== \IPS\Member\Club::TYPE_PRIVATE AND \IPS\Member::loggedIn()->group['gbw_club_manage_indexing'] )
|
||||
if ( $club->type !== Club::TYPE_PRIVATE AND Member::loggedIn()->group['gbw_club_manage_indexing'] )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo('club_page_meta_index', ( $current ) ? $current->meta_index : TRUE, FALSE, [], NULL, NULL, NULL, 'club_page_meta_index' ) );
|
||||
$form->add( new YesNo('club_page_meta_index', ( $current ) ? $current->meta_index : TRUE, FALSE, [], NULL, NULL, NULL, 'club_page_meta_index' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,9 +191,9 @@ class _Page extends \IPS\Patterns\ActiveRecord
|
||||
* @param $values array Values
|
||||
* @return void
|
||||
*/
|
||||
public function formatFormValues( array $values )
|
||||
public function formatFormValues( array $values ) : void
|
||||
{
|
||||
$this->club = \IPS\Member\Club::load( $values['page_club'] );
|
||||
$this->club = Club::load( $values['page_club'] );
|
||||
$this->title = $values['club_page_title'];
|
||||
$this->content = $values['club_page_content'];
|
||||
if ( array_key_exists( 'page_can_view', $values ) )
|
||||
@@ -194,11 +214,11 @@ class _Page extends \IPS\Patterns\ActiveRecord
|
||||
* URL
|
||||
*
|
||||
* @param NULL|string $action Value for the "do" parameter, or NULL for no action.
|
||||
* @return \IPS\Http\Url\Friendly
|
||||
* @return Friendly
|
||||
*/
|
||||
public function url( ?string $action = NULL ): \IPS\Http\Url\Internal
|
||||
public function url( ?string $action = NULL ): Internal
|
||||
{
|
||||
$return = \IPS\Http\Url::internal( "app=core&module=clubs&controller=page&id={$this->id}", 'front', 'clubs_page', array( $this->seo_title ) );
|
||||
$return = Url::internal( "app=core&module=clubs&controller=page&id={$this->id}", 'front', 'clubs_page', array( $this->seo_title ) );
|
||||
|
||||
if ( $action )
|
||||
{
|
||||
@@ -212,17 +232,17 @@ class _Page extends \IPS\Patterns\ActiveRecord
|
||||
* Load and check permissions
|
||||
*
|
||||
* @param int $id ID of the page to load
|
||||
* @param \IPS\Member|NULL $member Optional member to check against
|
||||
* @return \IPS\Member\Club\Page
|
||||
* @throws \OutOfRangeException
|
||||
* @param Member|NULL $member Optional member to check against
|
||||
* @return Page
|
||||
* @throws OutOfRangeException
|
||||
*/
|
||||
public static function loadAndCheckPerms( int $id, ?\IPS\Member $member = NULL ): \IPS\Member\Club\Page
|
||||
public static function loadAndCheckPerms( int $id, ?Member $member = NULL ): Page
|
||||
{
|
||||
$page = static::load( $id );
|
||||
|
||||
if ( !$page->canView( $member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
return $page;
|
||||
@@ -231,12 +251,12 @@ class _Page extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Can view this page
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member trying to view the page.
|
||||
* @param Member|NULL $member The member trying to view the page.
|
||||
* @return bool
|
||||
*/
|
||||
public function canView( ?\IPS\Member $member = NULL ): bool
|
||||
public function canView( ?Member $member = NULL ): bool
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$member = $member ?: Member::loggedIn();
|
||||
|
||||
/* If NULL, everyone can view */
|
||||
if ( $this->can_view === NULL )
|
||||
@@ -251,30 +271,30 @@ class _Page extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
|
||||
/* If it's not approved, only moderators and the person who created it can see it */
|
||||
if ( \IPS\Settings::i()->clubs_require_approval and !$this->club->approved )
|
||||
if ( Settings::i()->clubs_require_approval and !$this->club->approved )
|
||||
{
|
||||
return ( $member->modPermission('can_access_all_clubs') or ( $this->club->owner AND $member->member_id == $this->club->owner->member_id ) );
|
||||
}
|
||||
|
||||
/* Owner or leader? */
|
||||
if ( $member->member_id === $this->club->owner->member_id OR $this->club->memberStatus( $member ) === \IPS\Member\Club::STATUS_LEADER )
|
||||
if ( $member->member_id === $this->club->owner->member_id OR $this->club->memberStatus( $member ) === Club::STATUS_LEADER )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Moderators? */
|
||||
if ( \in_array( 'moderator', $this->can_view ) AND $this->club->memberStatus( $member ) === \IPS\Member\Club::STATUS_MODERATOR )
|
||||
if ( in_array( 'moderator', $this->can_view ) AND $this->club->memberStatus( $member ) === Club::STATUS_MODERATOR )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Members */
|
||||
if ( \in_array( 'member', $this->can_view ) AND \in_array( $this->club->memberStatus( $member ), array( \IPS\Member\Club::STATUS_MEMBER, \IPS\Member\Club::STATUS_INVITED, \IPS\Member\Club::STATUS_INVITED_BYPASSING_PAYMENT, \IPS\Member\Club::STATUS_EXPIRED, \IPS\Member\Club::STATUS_EXPIRED_MODERATOR ) ) )
|
||||
if ( in_array( 'member', $this->can_view ) AND in_array( $this->club->memberStatus( $member ), array( Club::STATUS_MEMBER, Club::STATUS_INVITED, Club::STATUS_INVITED_BYPASSING_PAYMENT, Club::STATUS_EXPIRED, Club::STATUS_EXPIRED_MODERATOR ) ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( \in_array( 'nonmember', $this->can_view ) )
|
||||
if ( in_array( 'nonmember', $this->can_view ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -286,24 +306,24 @@ class _Page extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Can Add a page
|
||||
*
|
||||
* @param \IPS\Member\Club $club The club the page will be added too.
|
||||
* @param \IPS\Member|NULL $member The member adding the page.
|
||||
* @param Club $club The club the page will be added too.
|
||||
* @param Member|NULL $member The member adding the page.
|
||||
* @return bool
|
||||
*/
|
||||
public static function canAdd( \IPS\Member\Club $club, ?\IPS\Member $member = NULL ): bool
|
||||
public static function canAdd( Club $club, ?Member $member = NULL ): bool
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$member = $member ?: Member::loggedIn();
|
||||
return $club->owner->member_id === $member->member_id OR $club->isLeader( $member );
|
||||
}
|
||||
|
||||
/**
|
||||
* Can edit this page
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member editing the page.
|
||||
* @param Member|NULL $member The member editing the page.
|
||||
* @return bool
|
||||
* @note Functionally, this is no different from canAdd, however it's been abstracted out for third parties.
|
||||
*/
|
||||
public function canEdit( ?\IPS\Member $member = NULL ): bool
|
||||
public function canEdit( ?Member $member = NULL ): bool
|
||||
{
|
||||
return static::canAdd( $this->club, $member );
|
||||
}
|
||||
@@ -311,11 +331,11 @@ class _Page extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Can delete this page
|
||||
*
|
||||
* @param \IPS\Member|NULL
|
||||
* @param Member|NULL $member
|
||||
* @return bool
|
||||
* @note Functionally, this is no different from canAdd, however it's been abstracted out for third parties.
|
||||
*/
|
||||
public function canDelete( ?\IPS\Member $member = NULL ): bool
|
||||
public function canDelete( ?Member $member = NULL ): bool
|
||||
{
|
||||
return static::canAdd( $this->club, $member );
|
||||
}
|
||||
@@ -323,17 +343,17 @@ class _Page extends \IPS\Patterns\ActiveRecord
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* @param bool $updateClub Update club tabs
|
||||
* @return void
|
||||
* @param bool $updateClub Update club tabs
|
||||
* @return void
|
||||
*/
|
||||
public function delete( $updateClub=TRUE )
|
||||
public function delete( bool $updateClub=TRUE ): void
|
||||
{
|
||||
\IPS\File::unclaimAttachments( 'core_ClubPage', $this->id );
|
||||
File::unclaimAttachments( 'core_ClubPage', $this->id );
|
||||
|
||||
if( $updateClub === TRUE )
|
||||
{
|
||||
$tabs = @json_decode( $this->club->menu_tabs, TRUE );
|
||||
if ( is_countable( $tabs ) AND \count( $tabs ) )
|
||||
if ( is_countable( $tabs ) AND count( $tabs ) )
|
||||
{
|
||||
if ( isset( $tabs['page-' . $this->id] ) )
|
||||
{
|
||||
|
||||
@@ -11,31 +11,37 @@
|
||||
namespace IPS\Member\Club;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Member;
|
||||
use IPS\Member\Club;
|
||||
use IPS\Poll as SystemPoll;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Poll Model
|
||||
*/
|
||||
class _Poll extends \IPS\Poll
|
||||
class Poll extends SystemPoll
|
||||
{
|
||||
/**
|
||||
* @brief Club this poll exists within
|
||||
*/
|
||||
public $club = NULL;
|
||||
public ?Club $club = NULL;
|
||||
|
||||
/**
|
||||
* Member can vote?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member Member or NULL for currently logged in member
|
||||
* @return void
|
||||
* @param Member|NULL $member Member or NULL for currently logged in member
|
||||
* @return bool
|
||||
*/
|
||||
public function canVote( \IPS\Member $member = NULL )
|
||||
public function canVote( Member $member = NULL ) : bool
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$member = $member ?: Member::loggedIn();
|
||||
|
||||
if( !parent::canVote( $member ) )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user