Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
+56
-13
@@ -722,6 +722,15 @@ class _Club extends \IPS\Patterns\ActiveRecord implements \IPS\Content\Embeddabl
|
||||
$this->sendModeratorApprovalNotification();
|
||||
}
|
||||
|
||||
if( $new and $this->approved )
|
||||
{
|
||||
\IPS\Api\Webhook::fire( 'club_created', $this );
|
||||
}
|
||||
else if( !$new AND isset( $this->changed['approved'] ) )
|
||||
{
|
||||
\IPS\Api\Webhook::fire( 'club_created', $this );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -803,6 +812,8 @@ class _Club extends \IPS\Patterns\ActiveRecord implements \IPS\Content\Embeddabl
|
||||
public function coverPhoto( $getOverlay=TRUE, $position='full' )
|
||||
{
|
||||
$photo = new \IPS\Helpers\CoverPhoto;
|
||||
|
||||
$photo->maxSize = \IPS\Settings::i()->club_max_cover;
|
||||
if ( $this->cover_photo )
|
||||
{
|
||||
$photo->file = \IPS\File::get( 'core_Clubs', $this->cover_photo );
|
||||
@@ -1129,7 +1140,7 @@ class _Club extends \IPS\Patterns\ActiveRecord implements \IPS\Content\Embeddabl
|
||||
* Add a member
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param bool $status Status
|
||||
* @param string $status Status
|
||||
* @param bool $update Update membership if already a member?
|
||||
* @param \IPS\Member|NULL $addedBy The leader who added them, or NULL if joining themselves
|
||||
* @param \IPS\Member|NULL $invitedBy The member who invited them, or NULL if joining themselves
|
||||
@@ -1171,11 +1182,28 @@ class _Club extends \IPS\Patterns\ActiveRecord implements \IPS\Content\Embeddabl
|
||||
$save['added_by'] = $addedBy->member_id;
|
||||
}
|
||||
|
||||
if ( $invitedBy )
|
||||
{
|
||||
$save['invited_by'] = $invitedBy->member_id;
|
||||
}
|
||||
|
||||
if( $updateJoinedDate === TRUE )
|
||||
{
|
||||
$save['joined'] = time();
|
||||
}
|
||||
|
||||
|
||||
/* Log to Member History */
|
||||
if ( \in_array( $status, array( \IPS\Member\Club::STATUS_MEMBER, \IPS\Member\Club::STATUS_BANNED ) ) )
|
||||
{
|
||||
$memberStatus = $this->memberStatus( $member, 2 );
|
||||
|
||||
/* Joining by invite */
|
||||
if ( $memberStatus['status'] == \IPS\Member\Club::STATUS_INVITED )
|
||||
{
|
||||
$addedBy = \IPS\Member::load( $memberStatus['invited_by'] );
|
||||
}
|
||||
$member->logHistory( 'core', 'club_membership', array('club_id' => $this->id, 'type' => $status ), $addedBy );
|
||||
}
|
||||
\IPS\Db::i()->update( 'core_clubs_memberships', $save, array( 'club_id=? AND member_id=?', $this->id, $member->member_id ) );
|
||||
|
||||
$member->rebuildPermissionArray();
|
||||
@@ -1195,6 +1223,14 @@ class _Club extends \IPS\Patterns\ActiveRecord implements \IPS\Content\Embeddabl
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
$params = [
|
||||
'club' => $this,
|
||||
'member' => $member,
|
||||
'status' => $status
|
||||
];
|
||||
|
||||
\IPS\Api\Webhook::fire( 'club_member_added', $params );
|
||||
|
||||
/* Achievements */
|
||||
if( \in_array( $status, array( static::STATUS_MEMBER, static::STATUS_MODERATOR, static::STATUS_LEADER, static::STATUS_EXPIRED, static::STATUS_EXPIRED_MODERATOR ) ) )
|
||||
@@ -1236,6 +1272,9 @@ class _Club extends \IPS\Patterns\ActiveRecord implements \IPS\Content\Embeddabl
|
||||
public function removeMember( \IPS\Member $member )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_clubs_memberships', array( 'club_id=? AND member_id=?', $this->id, $member->member_id ) );
|
||||
|
||||
\IPS\Api\Webhook::fire( 'club_member_removed', ['club' => $this, 'member' => $member] );
|
||||
|
||||
|
||||
$member->rebuildPermissionArray();
|
||||
if ( \IPS\Settings::i()->club_nodes_in_apps )
|
||||
@@ -1252,7 +1291,7 @@ class _Club extends \IPS\Patterns\ActiveRecord implements \IPS\Content\Embeddabl
|
||||
*/
|
||||
public function recountMembers()
|
||||
{
|
||||
$this->members = \IPS\Db::i()->select( 'COUNT(*)', 'core_clubs_memberships', array( 'club_id=? AND ( status=? OR status=? OR status=? OR status=? OR status=? )', $this->id, static::STATUS_MEMBER, static::STATUS_MODERATOR, static::STATUS_LEADER, static::STATUS_EXPIRED, static::STATUS_EXPIRED_MODERATOR ) );
|
||||
$this->members = \IPS\Db::i()->select( 'COUNT(*)', 'core_clubs_memberships', array( 'club_id=? AND ( status=? OR status=? OR status=? OR status=? OR status=? )', $this->id, static::STATUS_MEMBER, static::STATUS_MODERATOR, static::STATUS_LEADER, static::STATUS_EXPIRED, static::STATUS_EXPIRED_MODERATOR ) )->first();
|
||||
$this->save();
|
||||
}
|
||||
|
||||
@@ -1331,6 +1370,7 @@ class _Club extends \IPS\Patterns\ActiveRecord implements \IPS\Content\Embeddabl
|
||||
'url' => \IPS\Http\Url::internal( $class::$urlBase . $row['node_id'], 'front', $class::$urlTemplate, array( \IPS\Http\Url\Friendly::seoTitle( $row['name'] ) ) ),
|
||||
'node_class' => $row['node_class'],
|
||||
'node_id' => $row['node_id'],
|
||||
'public' => $row['public']
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1663,12 +1703,14 @@ class _Club extends \IPS\Patterns\ActiveRecord implements \IPS\Content\Embeddabl
|
||||
{
|
||||
parent::delete();
|
||||
|
||||
\IPS\Api\Webhook::fire( 'club_deleted', $this );
|
||||
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_club_pages', array( 'page_club=?', $this->id ) ), 'IPS\Member\Club\Page' ) as $page )
|
||||
{
|
||||
$page->delete( FALSE );
|
||||
}
|
||||
|
||||
$this->coverPhoto()->delete();
|
||||
$this->coverPhoto( FALSE )->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1768,7 +1810,7 @@ class _Club extends \IPS\Patterns\ActiveRecord implements \IPS\Content\Embeddabl
|
||||
{
|
||||
if( isset( $fieldValues['field_' . $field->id ] ) )
|
||||
{
|
||||
$fieldObject = new \IPS\core\ProfileFields\Api\Field( \IPS\Lang::load( \IPS\Lang::defaultLanguage() )->get( 'core_pfield_' . $field->id ), $fieldValues[ 'field_' . $field->id ] );
|
||||
$fieldObject = new \IPS\core\ProfileFields\Api\Field( \IPS\Lang::load( \IPS\Lang::defaultLanguage() )->get( 'core_clubfield_' . $field->id ), $fieldValues[ 'field_' . $field->id ] );
|
||||
$customFields[] = $fieldObject->apiOutput( $authorizedMember );
|
||||
}
|
||||
}
|
||||
@@ -1800,6 +1842,7 @@ class _Club extends \IPS\Patterns\ActiveRecord implements \IPS\Content\Embeddabl
|
||||
$node['url'] = (string) $node['url'];
|
||||
$node['id'] = $node['node_id'];
|
||||
$node['class'] = $node['node_class'];
|
||||
$node['public'] = $node['public'];
|
||||
|
||||
unset( $node['node_id'], $node['node_class'] );
|
||||
|
||||
@@ -1860,19 +1903,19 @@ class _Club extends \IPS\Patterns\ActiveRecord implements \IPS\Content\Embeddabl
|
||||
$tabs['club_members'] = array( 'href' => $this->url()->setQueryString('do', 'members'), 'title' => \IPS\Member::loggedIn()->language()->addToStack( 'club_members' ), 'isActive' => ( \IPS\Request::i()->module == 'clubs' AND \IPS\Request::i()->do == 'members' ) ? TRUE : FALSE );
|
||||
}
|
||||
|
||||
if ( $this->canRead() )
|
||||
foreach( $this->nodes() as $nodeID => $node )
|
||||
{
|
||||
foreach( $this->nodes() as $nodeID => $node )
|
||||
if ( $this->canRead() or $node['public'] )
|
||||
{
|
||||
$tabs[$nodeID] = array( 'href' => $node['url'] , 'title' => $node['name'], 'isActive' => ( isset( $container ) AND \get_class( $container ) === $node['node_class'] and $container->_id == $node['node_id'] ) ? TRUE : FALSE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach( $this->pages() AS $pageId => $page )
|
||||
foreach( $this->pages() AS $pageId => $page )
|
||||
{
|
||||
if ( $page->canView() )
|
||||
{
|
||||
if ( $page->canView() )
|
||||
{
|
||||
$tabs[$pageId] = array( 'href' => $page->url(), 'title' => $page->title, 'isActive' => ( \IPS\Request::i()->module == 'clubs' AND \IPS\Request::i()->controller == 'page' AND \IPS\Request::i()->id == $page->id ) );
|
||||
}
|
||||
$tabs[$pageId] = array( 'href' => $page->url(), 'title' => $page->title, 'isActive' => ( \IPS\Request::i()->module == 'clubs' AND \IPS\Request::i()->controller == 'page' AND \IPS\Request::i()->id == $page->id ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user