Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -49,6 +49,10 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
$table->include = array( 'name', 'type', 'members', 'owner', 'created' );
|
||||
$table->langPrefix = 'club_';
|
||||
$table->parsers = array(
|
||||
'name' => function( $value, $row )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('clubs')->name( $value, $row );
|
||||
},
|
||||
'type' => function( $value ) {
|
||||
return \IPS\Theme::i()->getTemplate('clubs')->privacy( $value );
|
||||
},
|
||||
@@ -56,22 +60,26 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
return \IPS\DateTime::ts( $value );
|
||||
},
|
||||
'members' => function( $value, $row ) {
|
||||
|
||||
$link = \IPS\Http\Url::internal( "app=core&module=clubs&controller=view&id={$row['id']}&do=members", 'front', 'clubs_view', array( \IPS\Http\Url\Friendly::seoTitle( $row['name'] ) ) );
|
||||
return \IPS\Theme::i()->getTemplate('clubs')->members( $value, $link );
|
||||
if ( $row['type'] !== \IPS\Member\Club::TYPE_PUBLIC )
|
||||
{
|
||||
$link = \IPS\Http\Url::internal( "app=core&module=clubs&controller=view&id={$row['id']}&do=members", 'front', 'clubs_view', array( \IPS\Http\Url\Friendly::seoTitle( $row['name'] ) ) );
|
||||
return \IPS\Theme::i()->getTemplate('clubs')->members( $value, $link );
|
||||
}
|
||||
return '';
|
||||
},
|
||||
'owner' => function( $value ) {
|
||||
return \IPS\Theme::i()->getTemplate('clubs')->owner( \IPS\Member::load( $value ) );
|
||||
},
|
||||
'_highlight' => function( $row ) {
|
||||
if ( !$row['approved'] )
|
||||
{
|
||||
return 'ipsModerated';
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
);
|
||||
$table->noSort = array( 'privacy', 'owner' );
|
||||
$table->sortBy = $table->sortBy ?: 'members';
|
||||
$table->filters = array(
|
||||
'club_type_' . \IPS\Member\Club::TYPE_PUBLIC => array( 'type=?', \IPS\Member\Club::TYPE_PUBLIC ),
|
||||
'club_type_' . \IPS\Member\Club::TYPE_OPEN => array( 'type=?', \IPS\Member\Club::TYPE_OPEN ),
|
||||
'club_type_' . \IPS\Member\Club::TYPE_CLOSED => array( 'type=?', \IPS\Member\Club::TYPE_CLOSED ),
|
||||
'club_type_' . \IPS\Member\Club::TYPE_PRIVATE => array( 'type=?', \IPS\Member\Club::TYPE_PRIVATE )
|
||||
);
|
||||
$table->quickSearch = 'name';
|
||||
$table->advancedSearch = array(
|
||||
'name' => \IPS\Helpers\Table\SEARCH_QUERY_TEXT,
|
||||
@@ -79,14 +87,56 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
'owner' => \IPS\Helpers\Table\SEARCH_MEMBER,
|
||||
'created' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
|
||||
);
|
||||
if ( \IPS\Settings::i()->clubs_require_approval )
|
||||
{
|
||||
$table->filters = array(
|
||||
'pending_approval' => 'approved=0'
|
||||
);
|
||||
$table->advancedSearch['type'] = array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => array(
|
||||
\IPS\Member\Club::TYPE_PUBLIC => 'club_type_' . \IPS\Member\Club::TYPE_PUBLIC,
|
||||
\IPS\Member\Club::TYPE_OPEN => 'club_type_' . \IPS\Member\Club::TYPE_OPEN,
|
||||
\IPS\Member\Club::TYPE_CLOSED => 'club_type_' . \IPS\Member\Club::TYPE_CLOSED,
|
||||
\IPS\Member\Club::TYPE_PRIVATE => 'club_type_' . \IPS\Member\Club::TYPE_PRIVATE,
|
||||
\IPS\Member\Club::TYPE_READONLY => 'club_type_' . \IPS\Member\Club::TYPE_READONLY,
|
||||
), 'multiple' => TRUE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->filters = array(
|
||||
'club_type_' . \IPS\Member\Club::TYPE_PUBLIC => array( 'type=?', \IPS\Member\Club::TYPE_PUBLIC ),
|
||||
'club_type_' . \IPS\Member\Club::TYPE_OPEN => array( 'type=?', \IPS\Member\Club::TYPE_OPEN ),
|
||||
'club_type_' . \IPS\Member\Club::TYPE_CLOSED => array( 'type=?', \IPS\Member\Club::TYPE_CLOSED ),
|
||||
'club_type_' . \IPS\Member\Club::TYPE_PRIVATE => array( 'type=?', \IPS\Member\Club::TYPE_PRIVATE ),
|
||||
'club_type_' . \IPS\Member\Club::TYPE_READONLY => array( 'type=?', \IPS\Member\Club::TYPE_READONLY )
|
||||
);
|
||||
}
|
||||
$table->rowButtons = function( $row ) {
|
||||
$return = array(
|
||||
'open' => array(
|
||||
'title' => 'view',
|
||||
'icon' => 'search',
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=clubs&controller=view&id={$row['id']}", 'front', 'clubs_view', array( \IPS\Http\Url\Friendly::seoTitle( $row['name'] ) ) ),
|
||||
'target'=> '_blank'
|
||||
)
|
||||
$return = array();
|
||||
if ( !$row['approved'] )
|
||||
{
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_edit' ) )
|
||||
{
|
||||
$return['approve'] = array(
|
||||
'title' => 'approve',
|
||||
'icon' => 'check',
|
||||
'link' => \IPS\Http\Url::internal("app=core&module=clubs&controller=clubs&do=approve&id={$row['id']}")
|
||||
);
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_delete' ) )
|
||||
{
|
||||
$return['delete'] = array(
|
||||
'title' => 'delete',
|
||||
'icon' => 'times',
|
||||
'link' => \IPS\Http\Url::internal("app=core&module=clubs&controller=clubs&do=delete&id={$row['id']}"),
|
||||
'data' => \IPS\Db::i()->select( 'COUNT(*)', 'core_clubs_node_map', array( 'club_id=?', $row['id'] ) )->first() ? array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('delete') ) : array( 'delete' => '' )
|
||||
);
|
||||
}
|
||||
}
|
||||
$return['open'] = array(
|
||||
'title' => 'view',
|
||||
'icon' => 'search',
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=clubs&controller=view&id={$row['id']}", 'front', 'clubs_view', array( \IPS\Http\Url\Friendly::seoTitle( $row['name'] ) ) ),
|
||||
'target'=> '_blank'
|
||||
);
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_edit' ) )
|
||||
{
|
||||
@@ -96,7 +146,7 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
'link' => \IPS\Http\Url::internal("app=core&module=clubs&controller=clubs&do=edit&id={$row['id']}")
|
||||
);
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_delete' ) )
|
||||
if ( !isset( $return['delete'] ) and \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_delete' ) )
|
||||
{
|
||||
$return['delete'] = array(
|
||||
'title' => 'delete',
|
||||
@@ -107,25 +157,7 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
return $return;
|
||||
};
|
||||
|
||||
/* Settings Button */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'fields_manage' ) )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions']['settings'] = array(
|
||||
'icon' => 'cog',
|
||||
'title' => 'clubs_custom_fields',
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=clubs&controller=clubs&controller=fields" ),
|
||||
);
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_settings_manage' ) )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions']['fields'] = array(
|
||||
'icon' => 'cog',
|
||||
'title' => 'settings',
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=clubs&controller=clubs&controller=settings" ),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output = (string) $table;
|
||||
}
|
||||
@@ -244,6 +276,38 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function approve()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'clubs_edit' );
|
||||
|
||||
/* Load Club */
|
||||
try
|
||||
{
|
||||
$club = \IPS\Member\Club::load( \IPS\Request::i()->id );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C352/8', 404, '' );
|
||||
}
|
||||
|
||||
/* Approve */
|
||||
$club->approved = TRUE;
|
||||
$club->save();
|
||||
|
||||
/* Redirect */
|
||||
$target = \IPS\Http\Url::internal("app=core&module=clubs&controller=clubs");
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'core_clubs', array( 'approved=0 AND id!=?', $club->id ) )->first() )
|
||||
{
|
||||
$target = $target->setQueryString( 'filter', 'pending_approval' );
|
||||
}
|
||||
\IPS\Output::i()->redirect( $target, "approved" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
@@ -277,7 +341,7 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
return array_key_exists( 'add', $node->permissionTypes() );
|
||||
}, 'clubs' => TRUE ) );
|
||||
$field->label = $data['name'];
|
||||
$field->label = htmlspecialchars( $data['name'] );
|
||||
$form->add( $field );
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
|
||||
@@ -41,7 +41,25 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
protected function manage()
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'clubs_enabled_setting', \IPS\Settings::i()->clubs, FALSE, array( 'togglesOn' => array( 'clubs_default_sort', 'clubs_header', 'clubs_locations', 'clubs_modperms', 'clubs_require_approval' ) ) ) );
|
||||
$form->addHeader( 'club_settings' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'clubs_enabled_setting', \IPS\Settings::i()->clubs, FALSE, array( 'togglesOn' => array( 'clubs_default_sort', 'clubs_header', 'clubs_locations', 'clubs_modperms', 'clubs_require_approval', 'form_header_club_display_settings', 'form_header_club_moderation', 'clubs_default_view', 'clubs_allow_view_change', 'club_nodes_in_apps', 'form_header_clubs_paid_settings', 'clubs_paid_on' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'clubs_require_approval', \IPS\Settings::i()->clubs_require_approval, FALSE, array(), NULL, NULL, NULL, 'clubs_require_approval' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'clubs_locations', \IPS\Settings::i()->clubs_locations, FALSE, array(), NULL, NULL, NULL, 'clubs_locations' ) );
|
||||
if ( \IPS\Application::appIsEnabled( 'nexus' ) )
|
||||
{
|
||||
$form->addHeader( 'clubs_paid_settings' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'clubs_paid_on', \IPS\Settings::i()->clubs_paid_on, FALSE, array( 'togglesOn' => array( 'clubs_paid_tax', 'clubs_paid_commission', 'clubs_paid_transfee', 'clubs_paid_gateways' ) ), NULL, NULL, NULL, 'clubs_paid_on' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'clubs_paid_tax', \IPS\Settings::i()->clubs_paid_tax ?:0, FALSE, array( 'class' => '\IPS\nexus\Tax', 'zeroVal' => 'do_not_tax' ), NULL, NULL, NULL, 'clubs_paid_tax' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'clubs_paid_commission', \IPS\Settings::i()->clubs_paid_commission, FALSE, array( 'min' => 0, 'max' => 100 ), NULL, NULL, '%', 'clubs_paid_commission' ) );
|
||||
$form->add( new \IPS\nexus\Form\Money( 'clubs_paid_transfee', \IPS\Settings::i()->clubs_paid_transfee, FALSE, array(), NULL, NULL, NULL, 'clubs_paid_transfee' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'clubs_paid_gateways', \IPS\Settings::i()->clubs_paid_gateways, FALSE, array( 'class' => '\IPS\nexus\Gateway', 'zeroVal' => 'no_restriction', 'multiple' => TRUE ), NULL, NULL, NULL, 'clubs_paid_gateways' ) );
|
||||
}
|
||||
$form->addHeader( 'club_display_settings' );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'clubs_default_view', \IPS\Settings::i()->clubs_default_view, FALSE, array( 'options' => array(
|
||||
'grid' => 'club_view_grid',
|
||||
'list' => 'club_view_list',
|
||||
) ), NULL, NULL, NULL, 'clubs_default_view' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'clubs_allow_view_change', \IPS\Settings::i()->clubs_allow_view_change, FALSE, array(), NULL, NULL, NULL, 'clubs_allow_view_change' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'clubs_default_sort', \IPS\Settings::i()->clubs_default_sort, FALSE, array( 'options' => array(
|
||||
'last_activity' => 'clubs_sort_last_activity',
|
||||
'members' => 'clubs_sort_members',
|
||||
@@ -53,7 +71,11 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
'full' => 'clubs_header_full',
|
||||
'sidebar' => 'clubs_header_sidebar',
|
||||
) ), NULL, NULL, NULL, 'clubs_header' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'clubs_locations', \IPS\Settings::i()->clubs_locations, FALSE, array(), NULL, NULL, NULL, 'clubs_locations' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'club_nodes_in_apps', \IPS\Settings::i()->club_nodes_in_apps, FALSE, array( 'options' => array(
|
||||
'0' => 'club_nodes_in_apps_off',
|
||||
'1' => 'club_nodes_in_apps_on',
|
||||
) ), NULL, NULL, NULL, 'club_nodes_in_apps' ) );
|
||||
$form->addHeader( 'club_moderation' );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'clubs_modperms', explode( ',', \IPS\Settings::i()->clubs_modperms ), FALSE, array( 'options' => array(
|
||||
'pin' => 'club_modperm_pin',
|
||||
'unpin' => 'club_modperm_unpin',
|
||||
@@ -70,17 +92,21 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
'delete' => 'club_modperm_delete',
|
||||
'split_merge' => 'club_modperm_split_merge',
|
||||
) ), NULL, NULL, NULL, 'clubs_modperms' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'clubs_require_approval', \IPS\Settings::i()->clubs_require_approval, FALSE, array(), NULL, NULL, NULL, 'clubs_require_approval' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
{
|
||||
$values['clubs'] = $values['clubs_enabled_setting'];
|
||||
unset( $values['clubs_enabled_setting'] );
|
||||
$values['clubs_modperms'] = implode( ',', $values['clubs_modperms'] );
|
||||
$values['clubs_modperms'] = implode( ',', $values['clubs_modperms'] );
|
||||
if ( \IPS\Application::appIsEnabled( 'nexus' ) )
|
||||
{
|
||||
$values['clubs_paid_tax'] = $values['clubs_paid_tax'] ? $values['clubs_paid_tax']->id : 0;
|
||||
$values['clubs_paid_gateways'] = is_array( $values['clubs_paid_gateways'] ) ? implode( ',', array_keys( $values['clubs_paid_gateways'] ) ) : $values['clubs_paid_gateways'];
|
||||
}
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__club_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=clubs&controller=clubs') );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=clubs&controller=settings') );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_clubs_settings');
|
||||
|
||||
Reference in new issue
Block a user