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
@@ -11,46 +11,81 @@
|
||||
namespace IPS\core\modules\admin\membersettings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Content\Reaction;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\File;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\CheckboxSet;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\Timezone;
|
||||
use IPS\Helpers\Form\Translatable;
|
||||
use IPS\Helpers\Form\Upload;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Helpers\Table\Db as TableDb;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Lang;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Group;
|
||||
use IPS\Node\Controller;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Output;
|
||||
use IPS\Platform\Bridge;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Task;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* reputation
|
||||
*/
|
||||
class _reputation extends \IPS\Node\Controller
|
||||
class reputation extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = '\IPS\Content\Reaction';
|
||||
protected string $nodeClass = '\IPS\Content\Reaction';
|
||||
|
||||
/**
|
||||
* Title can contain HTML?
|
||||
*/
|
||||
public $_titleHtml = TRUE;
|
||||
public bool $_titleHtml = TRUE;
|
||||
|
||||
/**
|
||||
* Show the "add" button in the page root rather than the table root
|
||||
*/
|
||||
protected $_addButtonInRoot = FALSE;
|
||||
protected bool $_addButtonInRoot = FALSE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'reps_manage' );
|
||||
return parent::execute();
|
||||
Dispatcher::i()->checkAcpPermission( 'reps_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,35 +93,35 @@ class _reputation extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('reputation_title');
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('reputation_title');
|
||||
|
||||
/* Init */
|
||||
$activeTab = \IPS\Request::i()->tab ?: NULL;
|
||||
$activeTab = Request::i()->tab ?: NULL;
|
||||
$activeTabContents = '';
|
||||
$tabs = array();
|
||||
|
||||
/* Settings */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'reps_settings' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'reps_settings' ) )
|
||||
{
|
||||
$tabs['settings'] = 'reputation_settings';
|
||||
}
|
||||
|
||||
/* Reactions */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'reactions_manage' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'reactions_manage' ) )
|
||||
{
|
||||
$tabs['reactions'] = 'reactions';
|
||||
}
|
||||
|
||||
/* Leaderboard */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'reps_settings' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'membersettings', 'reps_settings' ) )
|
||||
{
|
||||
$tabs['leaderboard'] = 'reputation_leaderboard';
|
||||
}
|
||||
|
||||
/* Levels */
|
||||
if ( \IPS\Settings::i()->reputation_enabled and \IPS\Settings::i()->reputation_show_profile )
|
||||
if ( Settings::i()->reputation_enabled and Settings::i()->reputation_show_profile )
|
||||
{
|
||||
$tabs['levels'] = 'reputation_levels';
|
||||
}
|
||||
@@ -94,27 +129,36 @@ class _reputation extends \IPS\Node\Controller
|
||||
/* Make sure we have a tab */
|
||||
if ( empty( $tabs ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission', '1C225/1', 403, '' );
|
||||
Output::i()->error( 'no_module_permission', '1C225/1', 403, '' );
|
||||
}
|
||||
elseif ( !$activeTab or !array_key_exists( $activeTab, $tabs ) )
|
||||
{
|
||||
$_tabs = array_keys( $tabs );
|
||||
$activeTab = array_shift( $_tabs );
|
||||
}
|
||||
|
||||
$blurbLangKey = $activeTab;
|
||||
|
||||
/* Do it */
|
||||
if ( $activeTab === 'reactions' )
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'reactions_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'reactions_manage' );
|
||||
parent::manage();
|
||||
$activeTabContents = \IPS\Theme::i()->getTemplate( 'global' )->paddedBlock( \IPS\Output::i()->output );
|
||||
$activeTabContents = Theme::i()->getTemplate( 'global' )->paddedBlock( Output::i()->output );
|
||||
if ( Bridge::i()->liveTopicsUnconverted() )
|
||||
{
|
||||
$blurbLangKey = 'reactions__locked__livetopics';
|
||||
$message = Theme::i()->getTemplate( 'global', 'cloud' )->reactionsDisabledLivetopicsMessage();
|
||||
Member::loggedIn()->language()->parseOutputForDisplay( $message );
|
||||
Member::loggedIn()->language()->words['rep_' . $blurbLangKey . '_blurb' ] = $message . Member::loggedIn()->language()->addToStack( 'rep_reactions_blurb' );
|
||||
}
|
||||
}
|
||||
else if ( $activeTab === 'settings' )
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'reps_settings' );
|
||||
Dispatcher::i()->checkAcpPermission( 'reps_settings' );
|
||||
|
||||
/* Random for the "like" preview */
|
||||
$maxMemberId = \IPS\Db::i()->select( 'MAX(member_id)', 'core_members' )->first();
|
||||
$maxMemberId = Db::i()->select( 'MAX(member_id)', 'core_members' )->first();
|
||||
$names = array();
|
||||
foreach ( range( 1, ( $maxMemberId > 3 ) ? 3 : $maxMemberId ) as $i )
|
||||
{
|
||||
@@ -129,20 +173,20 @@ class _reputation extends \IPS\Node\Controller
|
||||
$where = array( array( 'member_id>=?', $randomMemberId ) );
|
||||
if ( !empty( $names ) )
|
||||
{
|
||||
$where[] = \IPS\Db::i()->in( 'member_id', array_keys( $names ), TRUE );
|
||||
$where[] = Db::i()->in( 'member_id', array_keys( $names ), TRUE );
|
||||
}
|
||||
|
||||
$member = \IPS\Member::constructFromData( \IPS\Db::i()->select( '*', 'core_members', $where, 'member_id ASC', 1 )->first() );
|
||||
$member = Member::constructFromData( Db::i()->select( '*', 'core_members', $where, 'member_id ASC', 1 )->first() );
|
||||
$names[ $member->member_id ] = '<a>' . htmlentities( $member->name, ENT_DISALLOWED, 'UTF-8', FALSE ) . '</a>';
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( \count( $names ) == 3 )
|
||||
if ( count( $names ) == 3 )
|
||||
{
|
||||
$names[] = \IPS\Member::loggedIn()->language()->addToStack( 'like_blurb_others', FALSE, array( 'pluralize' => array( 2 ) ) );
|
||||
$names[] = Member::loggedIn()->language()->addToStack( 'like_blurb_others', FALSE, array( 'pluralize' => array( 2 ) ) );
|
||||
}
|
||||
if ( empty( $names ) )
|
||||
{
|
||||
@@ -150,26 +194,25 @@ class _reputation extends \IPS\Node\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
$blurb = \IPS\Member::loggedIn()->language()->addToStack( 'like_blurb', FALSE, array( 'htmlsprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $names ) ), 'pluralize' => array( \count( $names ) ) ) );
|
||||
$blurb = Member::loggedIn()->language()->addToStack( 'like_blurb', FALSE, array( 'htmlsprintf' => array( Member::loggedIn()->language()->formatList( $names ) ), 'pluralize' => array( count( $names ) ) ) );
|
||||
}
|
||||
|
||||
|
||||
/* Build Form */
|
||||
$form = new \IPS\Helpers\Form();
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'reputation_enabled', \IPS\Settings::i()->reputation_enabled, FALSE, array( 'togglesOn' => array( 'reputation_point_types', 'reputation_protected_groups', 'reputation_can_self_vote', 'reputation_highlight', 'reputation_show_profile', 'overall_reaction_count' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'reputation_protected_groups', explode( ',', \IPS\Settings::i()->reputation_protected_groups ), FALSE, array( 'options' => \IPS\Member\Group::groups( TRUE, FALSE ), 'parse' => 'normal', 'multiple' => TRUE ), NULL, NULL, NULL, 'reputation_protected_groups' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'reputation_can_self_vote', \IPS\Settings::i()->reputation_can_self_vote, FALSE, array(), NULL, NULL, NULL, 'reputation_can_self_vote' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'reputation_highlight', \IPS\Settings::i()->reputation_highlight, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('reputation_highlight_prefix'), \IPS\Member::loggedIn()->language()->addToStack('reputation_highlight_suffix'), 'reputation_highlight' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'reputation_show_profile', \IPS\Settings::i()->reputation_show_profile, FALSE, array(), NULL, NULL, NULL, 'reputation_show_profile' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'reaction_count_display', \IPS\Settings::i()->reaction_count_display, FALSE, array( 'options' => array( 'individual' => 'individual_reactions', 'count' => 'overall_reaction_count' ) ) ) );
|
||||
$form = new Form();
|
||||
$form->add( new YesNo( 'reputation_enabled', Settings::i()->reputation_enabled, FALSE, array( 'togglesOn' => array( 'reputation_point_types', 'reputation_protected_groups', 'reputation_can_self_vote', 'reputation_highlight', 'reputation_show_profile', 'overall_reaction_count' ) ) ) );
|
||||
$form->add( new CheckboxSet( 'reputation_protected_groups', explode( ',', Settings::i()->reputation_protected_groups ), FALSE, array( 'options' => Group::groups( TRUE, FALSE ), 'parse' => 'normal', 'multiple' => TRUE ), NULL, NULL, NULL, 'reputation_protected_groups' ) );
|
||||
$form->add( new YesNo( 'reputation_can_self_vote', Settings::i()->reputation_can_self_vote, FALSE, array(
|
||||
'disabled' => Bridge::i()->liveTopicsUnconverted()
|
||||
), NULL, NULL, NULL, 'reputation_can_self_vote' ) );
|
||||
$form->add( new Number( 'reputation_highlight', Settings::i()->reputation_highlight, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, Member::loggedIn()->language()->addToStack('reputation_highlight_prefix'), Member::loggedIn()->language()->addToStack('reputation_highlight_suffix'), 'reputation_highlight' ) );
|
||||
$form->add( new YesNo( 'reputation_show_profile', Settings::i()->reputation_show_profile, FALSE, array(), NULL, NULL, NULL, 'reputation_show_profile' ) );
|
||||
$form->add( new Radio( 'reaction_count_display', Settings::i()->reaction_count_display, FALSE, array( 'options' => array( 'individual' => 'individual_reactions', 'count' => 'overall_reaction_count' ) ) ) );
|
||||
|
||||
/* Save */
|
||||
if ( $form->saveAsSettings() )
|
||||
{
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__rep_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&tab=settings' ), 'saved' );
|
||||
Session::i()->log( 'acplogs__rep_settings' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=reputation&tab=settings' ), 'saved' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
@@ -177,24 +220,24 @@ class _reputation extends \IPS\Node\Controller
|
||||
}
|
||||
else if ( $activeTab === 'leaderboard' )
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'reps_settings' );
|
||||
Dispatcher::i()->checkAcpPermission( 'reps_settings' );
|
||||
|
||||
/* Get available filters */
|
||||
$topMemberFilters = \IPS\Member::topMembersOptions();
|
||||
$topMemberFilters = Member::topMembersOptions();
|
||||
|
||||
/* Build Form */
|
||||
$form = new \IPS\Helpers\Form();
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'reputation_leaderboard_on', \IPS\Settings::i()->reputation_leaderboard_on, FALSE, array( 'togglesOn' => array( 'reputation_leaderboard_default_tab', 'form_header_leaderboard_tabs_leaderboard', 'reputation_show_days_won_trophy', 'reputation_timezone', 'form_header_leaderboard_tabs_members', 'reputation_top_members_overview', 'reputation_overview_max_members', 'reputation_top_members_filters', 'reputation_max_members', 'leaderboard_excluded_groups' ) ), NULL, NULL, NULL, 'reputation_leaderboard_on' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'reputation_leaderboard_default_tab', \IPS\Settings::i()->reputation_leaderboard_default_tab, FALSE, array( 'options' => array( 'leaderboard' => 'leaderboard_tabs_leaderboard', 'history' => 'leaderboard_tabs_history', 'members' => 'leaderboard_tabs_members' ) ), NULL, NULL, NULL, 'reputation_leaderboard_default_tab' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'leaderboard_excluded_groups', explode( ',', \IPS\Settings::i()->leaderboard_excluded_groups ), FALSE, array( 'options' => \IPS\Member\Group::groups( TRUE, FALSE ), 'parse' => 'normal', 'multiple' => TRUE ), NULL, NULL, NULL, 'leaderboard_excluded_groups' ) );
|
||||
$form = new Form();
|
||||
$form->add( new YesNo( 'reputation_leaderboard_on', Settings::i()->reputation_leaderboard_on, FALSE, array( 'togglesOn' => array( 'reputation_leaderboard_default_tab', 'form_header_leaderboard_tabs_leaderboard', 'reputation_show_days_won_trophy', 'reputation_timezone', 'form_header_leaderboard_tabs_members', 'reputation_top_members_overview', 'reputation_overview_max_members', 'reputation_top_members_filters', 'reputation_max_members', 'leaderboard_excluded_groups' ) ), NULL, NULL, NULL, 'reputation_leaderboard_on' ) );
|
||||
$form->add( new Radio( 'reputation_leaderboard_default_tab', Settings::i()->reputation_leaderboard_default_tab, FALSE, array( 'options' => array( 'leaderboard' => 'leaderboard_tabs_leaderboard', 'history' => 'leaderboard_tabs_history', 'members' => 'leaderboard_tabs_members' ) ), NULL, NULL, NULL, 'reputation_leaderboard_default_tab' ) );
|
||||
$form->add( new CheckboxSet( 'leaderboard_excluded_groups', explode( ',', Settings::i()->leaderboard_excluded_groups ), FALSE, array( 'options' => Group::groups( TRUE, FALSE ), 'parse' => 'normal', 'multiple' => TRUE ), NULL, NULL, NULL, 'leaderboard_excluded_groups' ) );
|
||||
$form->addHeader('leaderboard_tabs_leaderboard');
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'reputation_show_days_won_trophy', \IPS\Settings::i()->reputation_show_days_won_trophy, FALSE, array( 'togglesOn' => array() ), NULL, NULL, NULL, 'reputation_show_days_won_trophy' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Timezone( 'reputation_timezone', \IPS\Settings::i()->reputation_timezone, FALSE, array(), NULL, NULL, NULL, 'reputation_timezone' ) );
|
||||
$form->add( new YesNo( 'reputation_show_days_won_trophy', Settings::i()->reputation_show_days_won_trophy, FALSE, array( 'togglesOn' => array() ), NULL, NULL, NULL, 'reputation_show_days_won_trophy' ) );
|
||||
$form->add( new Timezone( 'reputation_timezone', Settings::i()->reputation_timezone, FALSE, array(), NULL, NULL, NULL, 'reputation_timezone' ) );
|
||||
$form->addHeader('leaderboard_tabs_members');
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'reputation_top_members_overview', explode( ',', \IPS\Settings::i()->reputation_top_members_overview ), FALSE, array( 'options' => $topMemberFilters ), NULL, NULL, NULL, 'reputation_max_members' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'reputation_overview_max_members', \IPS\Settings::i()->reputation_overview_max_members, FALSE, array( 'min' => 3, 'max' => 100 ), NULL, NULL, NULL, 'reputation_overview_max_members' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'reputation_top_members_filters', \IPS\Settings::i()->reputation_top_members_filters == '*' ? array_keys( $topMemberFilters ) : explode( ',', \IPS\Settings::i()->reputation_top_members_filters ), FALSE, array( 'options' => $topMemberFilters ), NULL, NULL, NULL, 'reputation_top_members_filters' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'reputation_max_members', \IPS\Settings::i()->reputation_max_members, FALSE, array( 'min' => 3, 'max' => '100' ), NULL, NULL, NULL, 'reputation_max_members' ) );
|
||||
$form->add( new CheckboxSet( 'reputation_top_members_overview', explode( ',', Settings::i()->reputation_top_members_overview ), FALSE, array( 'options' => $topMemberFilters ), NULL, NULL, NULL, 'reputation_max_members' ) );
|
||||
$form->add( new Number( 'reputation_overview_max_members', Settings::i()->reputation_overview_max_members, FALSE, array( 'min' => 3, 'max' => 100 ), NULL, NULL, NULL, 'reputation_overview_max_members' ) );
|
||||
$form->add( new CheckboxSet( 'reputation_top_members_filters', Settings::i()->reputation_top_members_filters == '*' ? array_keys( $topMemberFilters ) : explode( ',', Settings::i()->reputation_top_members_filters ), FALSE, array( 'options' => $topMemberFilters ), NULL, NULL, NULL, 'reputation_top_members_filters' ) );
|
||||
$form->add( new Number( 'reputation_max_members', Settings::i()->reputation_max_members, FALSE, array( 'min' => 3, 'max' => '100' ), NULL, NULL, NULL, 'reputation_max_members' ) );
|
||||
|
||||
/* Save */
|
||||
if ( $values = $form->values() )
|
||||
@@ -204,12 +247,9 @@ class _reputation extends \IPS\Node\Controller
|
||||
$values['leaderboard_excluded_groups'] = implode( ',', $values['leaderboard_excluded_groups'] );
|
||||
$values['reputation_top_members_filters'] = $values['reputation_top_members_filters'] == array_keys( $topMemberFilters ) ? '*' : implode( ',', $values['reputation_top_members_filters'] );
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__rep_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&tab=leaderboard' ), 'saved' );
|
||||
Session::i()->log( 'acplogs__rep_settings' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=reputation&tab=leaderboard' ), 'saved' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
@@ -218,12 +258,12 @@ class _reputation extends \IPS\Node\Controller
|
||||
else
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_reputation_levels', \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&tab=levels' ) );
|
||||
$table = new TableDb( 'core_reputation_levels', Url::internal( 'app=core&module=membersettings&controller=reputation&tab=levels' ) );
|
||||
$table->langPrefix = 'rep_';
|
||||
|
||||
/* Columns */
|
||||
$table->joins = array(
|
||||
array( 'select' => 'w.word_custom', 'from' => array( 'core_sys_lang_words', 'w' ), 'where' => "w.word_key=CONCAT( 'core_reputation_level_', core_reputation_levels.level_id ) AND w.lang_id=" . \IPS\Member::loggedIn()->language()->id )
|
||||
array( 'select' => 'w.word_custom', 'from' => array( 'core_sys_lang_words', 'w' ), 'where' => "w.word_key=CONCAT( 'core_reputation_level_', core_reputation_levels.level_id ) AND w.lang_id=" . Member::loggedIn()->language()->id )
|
||||
);
|
||||
$table->include = array( 'word_custom', 'level_image', 'level_points' );
|
||||
$table->mainColumn = 'word_custom';
|
||||
@@ -240,7 +280,7 @@ class _reputation extends \IPS\Node\Controller
|
||||
{
|
||||
if ( $val )
|
||||
{
|
||||
return "<img src='" . \IPS\File::get( "core_Theme", $val )->url . "' alt=''>";
|
||||
return "<img src='" . File::get( "core_Theme", $val )->url . "' alt=''>";
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@@ -251,8 +291,8 @@ class _reputation extends \IPS\Node\Controller
|
||||
'add' => array(
|
||||
'title' => 'add',
|
||||
'icon' => 'plus',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&do=levelForm' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('add') )
|
||||
'link' => Url::internal( 'app=core&module=membersettings&controller=reputation&do=levelForm' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('add') )
|
||||
),
|
||||
);
|
||||
$table->rowButtons = function( $row )
|
||||
@@ -261,13 +301,13 @@ class _reputation extends \IPS\Node\Controller
|
||||
'edit' => array(
|
||||
'title' => 'edit',
|
||||
'icon' => 'pencil',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&do=levelForm&id=' ) . $row['level_id'],
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('edit') )
|
||||
'link' => Url::internal( 'app=core&module=membersettings&controller=reputation&do=levelForm&id=' ) . $row['level_id'],
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('edit') )
|
||||
),
|
||||
'delete' => array(
|
||||
'title' => 'delete',
|
||||
'icon' => 'times-circle',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&do=deleteLevel&id=' ) . $row['level_id'],
|
||||
'link' => Url::internal( 'app=core&module=membersettings&controller=reputation&do=deleteLevel&id=' ) . $row['level_id'],
|
||||
'data' => array( 'delete' => '' )
|
||||
),
|
||||
);
|
||||
@@ -277,16 +317,16 @@ class _reputation extends \IPS\Node\Controller
|
||||
$activeTabContents = (string) $table;
|
||||
}
|
||||
|
||||
$activeTabContents = \IPS\Theme::i()->getTemplate( 'forms' )->blurb( 'rep_' . $activeTab . '_blurb', TRUE, TRUE ) . $activeTabContents;
|
||||
$activeTabContents = Theme::i()->getTemplate( 'forms' )->blurb( 'rep_' . $blurbLangKey . '_blurb', TRUE, TRUE ) . $activeTabContents;
|
||||
|
||||
/* Display */
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $activeTabContents;
|
||||
Output::i()->output = $activeTabContents;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->tabs( $tabs, $activeTab, $activeTabContents, \IPS\Http\Url::internal( "app=core&module=membersettings&controller=reputation" ) );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->tabs( $tabs, $activeTab, $activeTabContents, Url::internal( "app=core&module=membersettings&controller=reputation" ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,19 +335,19 @@ class _reputation extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function levelForm()
|
||||
public function levelForm() : void
|
||||
{
|
||||
$current = NULL;
|
||||
if ( \IPS\Request::i()->id )
|
||||
if ( Request::i()->id )
|
||||
{
|
||||
$current = \IPS\Db::i()->select( '*', 'core_reputation_levels', array( 'level_id=?', \IPS\Request::i()->id ) )->first();
|
||||
$current = Db::i()->select( '*', 'core_reputation_levels', array( 'level_id=?', Request::i()->id ) )->first();
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form();
|
||||
$form = new Form();
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'rep_level_title', NULL, TRUE, array( 'app' => 'core', 'key' => ( $current ? "core_reputation_level_{$current['level_id']}" : NULL ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'rep_level_image', ( $current and $current['level_image'] ) ? \IPS\File::get( 'core_Theme', $current['level_image'] ) : NULL, FALSE, array( 'storageExtension' => 'core_Theme' ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'rep_level_points', $current ? $current['level_points'] : 0, TRUE, array( 'min' => NULL ) ) );
|
||||
$form->add( new Translatable( 'rep_level_title', NULL, TRUE, array( 'app' => 'core', 'key' => ( $current ? "core_reputation_level_{$current['level_id']}" : NULL ) ) ) );
|
||||
$form->add( new Upload( 'rep_level_image', ( $current and $current['level_image'] ) ? File::get( 'core_Theme', $current['level_image'] ) : NULL, FALSE, array( 'storageExtension' => 'core_Theme' ) ) );
|
||||
$form->add( new Number( 'rep_level_points', $current ? $current['level_points'] : 0, TRUE, array( 'min' => NULL ) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -318,27 +358,24 @@ class _reputation extends \IPS\Node\Controller
|
||||
|
||||
if ( $current )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_reputation_levels', $save, array( 'level_id=?', $current['level_id'] ) );
|
||||
Db::i()->update( 'core_reputation_levels', $save, array( 'level_id=?', $current['level_id'] ) );
|
||||
$id = $current['level_id'];
|
||||
\IPS\Session::i()->log( 'acplogs__rep_edited', array( $save['level_points'] => FALSE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = \IPS\Db::i()->insert( 'core_reputation_levels', $save );
|
||||
\IPS\Session::i()->log( 'acplogs__rep_edited', array( $save['level_points'] => FALSE ) );
|
||||
$id = Db::i()->insert( 'core_reputation_levels', $save );
|
||||
}
|
||||
|
||||
unset( \IPS\Data\Store::i()->reputationLevels );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Lang::saveCustom( 'core', "core_reputation_level_{$id}", $values['rep_level_title'] );
|
||||
Session::i()->log( 'acplogs__rep_edited', array( $save['level_points'] => FALSE ) );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&tab=levels' ), 'saved' );
|
||||
unset( Store::i()->reputationLevels );
|
||||
|
||||
Lang::saveCustom( 'core', "core_reputation_level_{$id}", $values['rep_level_title'] );
|
||||
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=reputation&tab=levels' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( $current ? "core_reputation_level_{$current['level_id']}" : 'add', $form, FALSE );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( $current ? "core_reputation_level_{$current['level_id']}" : 'add', $form, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,29 +383,26 @@ class _reputation extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteLevel()
|
||||
public function deleteLevel() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'reps_delete' );
|
||||
Dispatcher::i()->checkAcpPermission( 'reps_delete' );
|
||||
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
Request::i()->confirmedDelete();
|
||||
|
||||
try
|
||||
{
|
||||
$current = \IPS\Db::i()->select( '*', 'core_reputation_levels', array( 'level_id=?', \IPS\Request::i()->id ) )->first();
|
||||
$current = Db::i()->select( '*', 'core_reputation_levels', array( 'level_id=?', Request::i()->id ) )->first();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__rep_deleted', array( $current['level_points'] => FALSE ) );
|
||||
\IPS\Db::i()->delete( 'core_reputation_levels', array( 'level_id=?', \IPS\Request::i()->id ) );
|
||||
unset( \IPS\Data\Store::i()->reputationLevels );
|
||||
Session::i()->log( 'acplogs__rep_deleted', array( $current['level_points'] => FALSE ) );
|
||||
Db::i()->delete( 'core_reputation_levels', array( 'level_id=?', Request::i()->id ) );
|
||||
unset( Store::i()->reputationLevels );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Lang::deleteCustom( 'core', 'core_reputation_level_' . \IPS\Request::i()->id );
|
||||
Lang::deleteCustom( 'core', 'core_reputation_level_' . Request::i()->id );
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
catch ( UnderflowException $e ) { }
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&tab=levels' ) );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=reputation&tab=levels' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,59 +410,59 @@ class _reputation extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rebuildLeaderboard()
|
||||
public function rebuildLeaderboard() : void
|
||||
{
|
||||
if ( ! isset( \IPS\Request::i()->process ) )
|
||||
if ( ! isset( Request::i()->process ) )
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('reputation_leaderboard_rebuild_title');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'settings' )->reputationLeaderboardRebuild();
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('reputation_leaderboard_rebuild_title');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'settings' )->reputationLeaderboardRebuild();
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
|
||||
\IPS\Db::i()->delete('core_reputation_leaderboard_history');
|
||||
\IPS\Session::i()->log( 'acplog__rebuilt_leaderboard' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=membersettings&controller=reputation&tab=leaderboard' ), 'reputation_leaderboard_rebuilding' );
|
||||
Session::i()->csrfCheck();
|
||||
Task::queue( 'core', 'RebuildReputationLeaderboard', array(), 4 );
|
||||
Db::i()->delete('core_reputation_leaderboard_history');
|
||||
Session::i()->log( 'acplog__rebuilt_leaderboard' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=membersettings&controller=reputation&tab=leaderboard' ), 'reputation_leaderboard_rebuilding' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to execute after nodes are reordered. Do nothing by default but plugins can extend.
|
||||
* Function to execute after nodes are reordered. Do nothing by default but app can extend.
|
||||
*
|
||||
* @param array $order The new ordering that was saved
|
||||
* @return void
|
||||
*/
|
||||
protected function _afterReorder( $order )
|
||||
protected function _afterReorder( array $order ) : void
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->reactions );
|
||||
unset( Store::i()->reactions );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Redirect after save
|
||||
*
|
||||
* @param \IPS\Node\Model $old A clone of the node as it was before or NULL if this is a creation
|
||||
* @param \IPS\Node\Model $new The node now
|
||||
* @param string $lastUsedTab The tab last used in the form
|
||||
* @return void
|
||||
* @param Model|null $old A clone of the node as it was before or NULL if this is a creation
|
||||
* @param Model $new The node now
|
||||
* @param string $lastUsedTab The tab last used in the form
|
||||
* @return void
|
||||
*/
|
||||
protected function _afterSave( ?\IPS\Node\Model $old, \IPS\Node\Model $new, $lastUsedTab = FALSE )
|
||||
protected function _afterSave( ?Model $old, Model $new, mixed $lastUsedTab = FALSE ): void
|
||||
{
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( array() );
|
||||
Output::i()->json( array() );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( isset( \IPS\Request::i()->save_and_reload ) )
|
||||
if( isset( Request::i()->save_and_reload ) )
|
||||
{
|
||||
$buttons = $new->getButtons( $this->url, !( $new instanceof $this->nodeClass ) );
|
||||
$buttons = $new->getButtons($this->url, !($new instanceof $this->nodeClass));
|
||||
|
||||
\IPS\Output::i()->redirect( ( $lastUsedTab ? $buttons['edit']['link']->setQueryString('activeTab', $lastUsedTab ) : $buttons['edit']['link'] ), 'saved' );
|
||||
Output::i()->redirect( ( $lastUsedTab ? $buttons['edit']['link']->setQueryString('activeTab', $lastUsedTab ) : $buttons['edit']['link'] ), 'saved' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $new->parent() ? $new->parent()->_id : '' ), 'tab' => 'reactions' ) ), 'saved' );
|
||||
Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $new->parent() ? $new->parent()->_id : '' ), 'tab' => 'reactions' ) ), 'saved' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -438,34 +472,35 @@ class _reputation extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function delete()
|
||||
protected function delete() : void
|
||||
{
|
||||
/* Get node */
|
||||
/* @var Reaction $nodeClass */
|
||||
$nodeClass = $this->nodeClass;
|
||||
if ( \IPS\Request::i()->subnode )
|
||||
if ( Request::i()->subnode )
|
||||
{
|
||||
$nodeClass = $nodeClass::$subnodeClass;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$node = $nodeClass::load( \IPS\Request::i()->id );
|
||||
$node = $nodeClass::load( Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2S101/J', 404, '' );
|
||||
Output::i()->error( 'node_error', '2S101/J', 404, '' );
|
||||
}
|
||||
|
||||
/* Permission check */
|
||||
if( !$node->canDelete() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_noperm_delete', '2S101/H', 403, '' );
|
||||
Output::i()->error( 'node_noperm_delete', '2S101/H', 403, '' );
|
||||
}
|
||||
|
||||
/* Do we have any children or content? */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'existing_reactions', NULL, TRUE, array( 'options' => array( 'change' => 'change_new_reaction', 'delete' => 'delete' ), 'toggles' => array( 'change' => array( 'new_reaction' ) ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'new_reaction', NULL, TRUE, array( 'class' => 'IPS\Content\Reaction', 'permissionCheck' => function( $row ) use ( $node ) {
|
||||
$form = new Form;
|
||||
$form->add( new Radio( 'existing_reactions', NULL, TRUE, array( 'options' => array( 'change' => 'change_new_reaction', 'delete' => 'delete' ), 'toggles' => array( 'change' => array( 'new_reaction' ) ) ) ) );
|
||||
$form->add( new Node( 'new_reaction', NULL, TRUE, array( 'class' => 'IPS\Content\Reaction', 'permissionCheck' => function( $row ) use ( $node ) {
|
||||
if ( $row->_id == $node->_id )
|
||||
{
|
||||
return FALSE;
|
||||
@@ -478,28 +513,28 @@ class _reputation extends \IPS\Node\Controller
|
||||
{
|
||||
if ( $values['existing_reactions'] == 'change' AND array_key_exists( 'new_reaction', $values ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_reputation_index', array( 'reaction' => $values['new_reaction']->_id ), array( "reaction=?", $node->_id ) );
|
||||
Db::i()->update( 'core_reputation_index', array( 'reaction' => $values['new_reaction']->_id ), array( "reaction=?", $node->_id ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_reputation_index', array( "reaction=?", $node->_id ) );
|
||||
Db::i()->delete( 'core_reputation_index', array( "reaction=?", $node->_id ) );
|
||||
}
|
||||
|
||||
/* Delete it */
|
||||
\IPS\Session::i()->log( 'acplog__node_deleted', array( $this->title => TRUE, $node->titleForLog() => FALSE ) );
|
||||
Session::i()->log( 'acplog__node_deleted', array( $this->title => TRUE, $node->titleForLog() => FALSE ) );
|
||||
$node->delete();
|
||||
|
||||
/* Boink */
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( "OK" );
|
||||
Output::i()->json( "OK" );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->url->setQueryString( 'tab', 'reactions' )->setQueryString( array( 'root' => ( $node->parent() ? $node->parent()->_id : '' ) ) ), 'deleted' );
|
||||
Output::i()->redirect( $this->url->setQueryString( 'tab', 'reactions' )->setQueryString( array( 'root' => ( $node->parent() ? $node->parent()->_id : '' ) ) ), 'deleted' );
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user