Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -11,61 +11,73 @@
namespace IPS\core\StaffDirectory;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Db;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Radio;
use IPS\Helpers\Form\Translatable;
use IPS\Http\Url;
use IPS\Lang;
use IPS\Member;
use IPS\Node\Model;
use IPS\Theme;
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;
}
/**
* Staff Directory Group Node
*/
class _Group extends \IPS\Node\Model
class Group extends Model
{
/**
* @brief [ActiveRecord] Multiton Store
*/
protected static $multitons;
protected static array $multitons;
/**
* @brief [ActiveRecord] Database Table
*/
public static $databaseTable = 'core_leaders_groups';
public static ?string $databaseTable = 'core_leaders_groups';
/**
* @brief [ActiveRecord] Database Prefix
*/
public static $databasePrefix = 'group_';
public static string $databasePrefix = 'group_';
/**
* @brief [ActiveRecord] ID Database Column
*/
public static $databaseColumnId = 'id';
public static string $databaseColumnId = 'id';
/**
* @brief [Node] Order Database Column
*/
public static $databaseColumnOrder = 'position';
public static ?string $databaseColumnOrder = 'position';
/**
* @brief [Node] Node Title
*/
public static $nodeTitle = 'staff_directory';
public static string $nodeTitle = 'staff_directory';
/**
* @brief [Node] Subnode class
*/
public static $subnodeClass = 'IPS\core\StaffDirectory\User';
public static ?string $subnodeClass = 'IPS\core\StaffDirectory\User';
/**
* @brief [Node] Show forms modally?
*/
public static $modalForms = TRUE;
public static bool $modalForms = TRUE;
/**
* @brief [Node] ACP Restrictions
*/
protected static $restrictions = array(
protected static ?array $restrictions = array(
'app' => 'core',
'module' => 'staff',
'prefix' => 'leaders_',
@@ -74,30 +86,30 @@ class _Group extends \IPS\Node\Model
/**
* @brief [Node] Title prefix. If specified, will look for a language key with "{$key}_title" as the key
*/
public static $titleLangPrefix = 'core_staffgroups_';
public static ?string $titleLangPrefix = 'core_staffgroups_';
/**
* [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
{
/* Title field */
$form->add( new \IPS\Helpers\Form\Translatable( 'staff_group_title', NULL, TRUE, array( 'app' => 'core', 'key' => ( $this->id ? "core_staffgroups_{$this->id}" : NULL ) ) ) );
$form->add( new Translatable( 'staff_group_title', NULL, TRUE, array( 'app' => 'core', 'key' => ( $this->id ? "core_staffgroups_{$this->id}" : NULL ) ) ) );
/* Build the layout selection radios */
$templates = array();
foreach ( \IPS\Theme::load( \IPS\Theme::defaultTheme() )->getRawTemplates( 'core', 'front', 'staffdirectory', \IPS\Theme::RETURN_ARRAY_BIT_NAMES | \IPS\Theme::RETURN_NATIVE ) as $template )
foreach ( [ 'layout_blocks','layout_full','layout_half' ] as $template )
{
if ( mb_strpos( $template, 'layout_' ) === 0 && mb_strpos( $template, '_preview' ) === FALSE )
{
$realTemplate = $template . '_preview';
$templates[ $template ] = \IPS\Theme::i()->getTemplate( 'staffdirectory', 'core', 'front' )->$realTemplate( );
}
$templates[ $template ] = Theme::i()->getTemplate( 'staffdirectory', 'core', 'front' )->$realTemplate( );
}
$form->add( new \IPS\Helpers\Form\Radio( 'staff_group_template', $this->id ? $this->template : NULL, TRUE, array( 'options' => $templates, 'parse' => 'none' ) ) );
$form->add( new Radio( 'staff_group_template', $this->id ? $this->template : NULL, TRUE, array( 'options' => $templates, 'parse' => 'none' ) ) );
}
/**
@@ -106,7 +118,7 @@ class _Group extends \IPS\Node\Model
* @param array $values Values from the form
* @return array
*/
public function formatFormValues( $values )
public function formatFormValues( array $values ): array
{
if ( !$this->id )
{
@@ -115,7 +127,7 @@ class _Group extends \IPS\Node\Model
if( isset( $values['staff_group_title'] ) )
{
\IPS\Lang::saveCustom( 'core', "core_staffgroups_{$this->id}", $values['staff_group_title'] );
Lang::saveCustom( 'core', "core_staffgroups_{$this->id}", $values['staff_group_title'] );
unset( $values['staff_group_title'] );
}
@@ -133,21 +145,21 @@ class _Group extends \IPS\Node\Model
* Example code explains return value
*
* @code
array(
array(
'icon' => 'plus-circle', // Name of FontAwesome icon to use
'title' => 'foo', // Language key to use for button's title parameter
'link' => \IPS\Http\Url::internal( 'app=foo...' ) // URI to link to
'class' => 'modalLink' // CSS Class to use on link (Optional)
),
... // Additional buttons
);
* array(
* array(
* 'icon' => 'plus-circle', // Name of FontAwesome icon to use
* 'title' => 'foo', // Language key to use for button's title parameter
* 'link' => \IPS\Http\Url::internal( 'app=foo...' ) // URI to link to
* 'class' => 'modalLink' // CSS Class to use on link (Optional)
* ),
* ... // Additional buttons
* );
* @endcode
* @param string $url Base URL
* @param Url $url Base URL
* @param bool $subnode Is this a subnode?
* @return array
*/
public function getButtons( $url, $subnode=FALSE )
public function getButtons( Url $url, bool $subnode=FALSE ):array
{
$buttons = parent::getButtons( $url, $subnode );
@@ -164,7 +176,7 @@ class _Group extends \IPS\Node\Model
*
* @return bool
*/
public function canManagePermissions()
public function canManagePermissions(): bool
{
return false;
}
@@ -174,7 +186,7 @@ class _Group extends \IPS\Node\Model
*
* @return array
*/
public function members()
public function members() : array
{
$members = array();
foreach ( $this->children() as $child )
@@ -186,17 +198,17 @@ class _Group extends \IPS\Node\Model
else
{
$memberIds = array();
foreach ( \IPS\Db::i()->select( 'member_id', 'core_members', array( 'member_group_id=? OR FIND_IN_SET( ?, mgroup_others )', $child->type_id, $child->type_id ), 'name' ) as $memberId )
foreach ( Db::i()->select( 'member_id', 'core_members', array( 'member_group_id=? OR FIND_IN_SET( ?, mgroup_others )', $child->type_id, $child->type_id ), 'name' ) as $memberId )
{
$memberIds[] = $memberId;
}
foreach ( \IPS\Db::i()->select( '*', 'core_members', array( \IPS\Db::i()->in( 'member_id', $memberIds ) ) ) as $m )
foreach ( Db::i()->select( '*', 'core_members', array( Db::i()->in( 'member_id', $memberIds ) ) ) as $m )
{
if ( !isset( $members[ $m['member_id'] ] ) )
{
$member = new User;
$memberObj = \IPS\Member::constructFromData( $m );
$memberObj = Member::constructFromData( $m );
$member->member = $memberObj;
$members[ $memberObj->member_id ] = $member;
}