Version 4.7.6
This commit is contained in:
1 parent
8ba7d43898
commit
7b7404e741
1085 files changed
+30590
-7837
No files matched your search
@@ -782,7 +782,7 @@ class _members extends \IPS\Api\Controller
|
||||
200,
|
||||
\IPS\Db::i()->select( '*', 'core_notifications', array( "`member`=? AND notification_app IN('" . implode( "','", array_keys( \IPS\Application::enabledApplications() ) ) . "')", $member->member_id ), "updated_time DESC" ),
|
||||
isset( \IPS\Request::i()->page ) ? \IPS\Request::i()->page : 1,
|
||||
'IPS\Notification\Inline',
|
||||
'IPS\Notification\RestApi',
|
||||
\IPS\Db::i()->select( 'COUNT(*)', 'core_notifications', array( "`member`=? AND notification_app IN('" . implode( "','", array_keys( \IPS\Application::enabledApplications() ) ) . "')", $member->member_id ) )->first(),
|
||||
$this->member,
|
||||
isset( \IPS\Request::i()->perPage ) ? \IPS\Request::i()->perPage : NULL
|
||||
@@ -1230,4 +1230,80 @@ class _members extends \IPS\Api\Controller
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '2C292/14', 404 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /core/members/{id}/secgroup/{groupId}
|
||||
* Adds a secondary group to the member
|
||||
*
|
||||
* @param int $id ID Number
|
||||
* @reqapiparam int $groupId Group To Add
|
||||
* @return \IPS\Member
|
||||
* @throws 2C292/15 INVALID_GROUP The group could not be found
|
||||
* @throws 2C292/16 INVALID_MEMBER The member could not be found
|
||||
*/
|
||||
public function POSTitem_secgroup( int $id, int $groupId ): \IPS\Api\Response
|
||||
{
|
||||
/* Load member */
|
||||
$member = \IPS\Member::load( $id );
|
||||
if( !$member->member_id )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_MEMBER', '2C292/16', 404 );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$group = \IPS\Member\Group::load( $groupId );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_GROUP', '2C292/15', 404 );
|
||||
}
|
||||
|
||||
$mgroup_others = array_filter( explode( ',', $member->mgroup_others ) );
|
||||
|
||||
$newSecondaryGroups = array_unique( array_merge( [$group->g_id], $mgroup_others ) );
|
||||
|
||||
$member->mgroup_others = implode( ',', $newSecondaryGroups );
|
||||
$member->save();
|
||||
|
||||
return new \IPS\Api\Response( 201, $member->apiOutput( $this->member ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE /core/members/{id}/secgroup/{groupId}
|
||||
* Removes a secondary group
|
||||
*
|
||||
* @param int $id ID Number
|
||||
* @reqapiparam int $groupId Group To Add
|
||||
* @return \IPS\Member
|
||||
* @throws 2C292/17 INVALID_GROUP The group could not be found
|
||||
* @throws 2C292/18 INVALID_MEMBER The member could not be found
|
||||
*/
|
||||
public function DELETEitem_secgroup( int $id, int $groupId ): \IPS\Api\Response
|
||||
{
|
||||
/* Load member */
|
||||
$member = \IPS\Member::load( $id );
|
||||
if( !$member->member_id )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_MEMBER', '2C292/18', 404 );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$group = \IPS\Member\Group::load( $groupId );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_GROUP', '2C292/17', 404 );
|
||||
}
|
||||
|
||||
$secondaryGroups = array_filter( explode( ',', $member->mgroup_others ) );
|
||||
$key = array_search( $group->g_id, $secondaryGroups );
|
||||
unset( $secondaryGroups[ $key ] );
|
||||
|
||||
$member->mgroup_others = implode( ',', array_unique( $secondaryGroups ) );
|
||||
$member->save();
|
||||
|
||||
return new \IPS\Api\Response( 201, $member->apiOutput( $this->member ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user