Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Members API
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 3 Dec 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\core\api;
|
||||
@@ -36,11 +35,11 @@ class _members extends \IPS\Api\Controller
|
||||
{
|
||||
/* Where clause */
|
||||
$where = array();
|
||||
|
||||
|
||||
/* Sort */
|
||||
$sortBy = ( isset( \IPS\Request::i()->sortBy ) and in_array( \IPS\Request::i()->sortBy, array( 'name', 'joined' ) ) ) ? \IPS\Request::i()->sortBy : 'member_id';
|
||||
$sortDir = ( isset( \IPS\Request::i()->sortDir ) and in_array( mb_strtolower( \IPS\Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? \IPS\Request::i()->sortDir : 'asc';
|
||||
|
||||
|
||||
/* Return */
|
||||
return new \IPS\Api\PaginatedResponse(
|
||||
200,
|
||||
@@ -76,7 +75,7 @@ class _members extends \IPS\Api\Controller
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '1C292/2', 404 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create or update member
|
||||
*
|
||||
@@ -101,20 +100,21 @@ class _members extends \IPS\Api\Controller
|
||||
throw new \IPS\Api\Exception( 'USERNAME_EXISTS', '1C292/4', 403 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( isset( \IPS\Request::i()->email ) and \IPS\Request::i()->email != $member->email )
|
||||
{
|
||||
$existingEmail = \IPS\Member::load( \IPS\Request::i()->email, 'email' );
|
||||
if ( !$existingEmail->member_id )
|
||||
{
|
||||
$member->email = \IPS\Request::i()->email;
|
||||
$member->invalidateSessionsAndLogins();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'EMAIL_EXISTS', '1C292/5', 403 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( isset( \IPS\Request::i()->group ) )
|
||||
{
|
||||
try
|
||||
@@ -127,7 +127,7 @@ class _members extends \IPS\Api\Controller
|
||||
throw new \IPS\Api\Exception( 'INVALID_GROUP', '1C292/6', 403 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( isset( \IPS\Request::i()->password ) )
|
||||
{
|
||||
foreach ( \IPS\Login::handlers( TRUE ) as $handler )
|
||||
@@ -138,6 +138,7 @@ class _members extends \IPS\Api\Controller
|
||||
}
|
||||
catch( \BadMethodCallException $e ){}
|
||||
}
|
||||
$member->invalidateSessionsAndLogins();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -156,13 +157,13 @@ class _members extends \IPS\Api\Controller
|
||||
{
|
||||
$profileFields = array();
|
||||
}
|
||||
|
||||
|
||||
/* If \IPS\Db::i()->select()->first() has only one column, then the contents of that column is returned. We do not want this here. */
|
||||
if ( !is_array( $profileFields ) )
|
||||
{
|
||||
$profileFields = array();
|
||||
}
|
||||
|
||||
|
||||
$profileFields['member_id'] = $member->member_id;
|
||||
|
||||
foreach ( \IPS\Request::i()->customFields as $k => $v )
|
||||
@@ -171,13 +172,14 @@ class _members extends \IPS\Api\Controller
|
||||
}
|
||||
|
||||
\IPS\Db::i()->replace( 'core_pfields_content', $profileFields );
|
||||
|
||||
|
||||
$member->changedCustomFields = $profileFields;
|
||||
$member->save();
|
||||
}
|
||||
|
||||
|
||||
return $member;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /core/members
|
||||
* Create a member
|
||||
@@ -201,7 +203,7 @@ class _members extends \IPS\Api\Controller
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'NO_USERNAME_OR_EMAIL', '1C292/8', 403 );
|
||||
}
|
||||
|
||||
|
||||
/* This is required as there is no other way to allow the account to be authenticated when it is created via the API */
|
||||
if ( !isset( \IPS\Request::i()->password ) )
|
||||
{
|
||||
@@ -210,12 +212,12 @@ class _members extends \IPS\Api\Controller
|
||||
|
||||
$member = new \IPS\Member;
|
||||
$member->member_group_id = \IPS\Settings::i()->member_group;
|
||||
|
||||
$member = $this->_createOrUpdate( $member );
|
||||
|
||||
|
||||
$member = $this->_createOrUpdate( $member );
|
||||
|
||||
return new \IPS\Api\Response( 201, $member->apiOutput() );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /core/members/{id}
|
||||
* Edit a member
|
||||
@@ -240,9 +242,9 @@ class _members extends \IPS\Api\Controller
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
|
||||
$member = $this->_createOrUpdate( $member );
|
||||
|
||||
|
||||
return new \IPS\Api\Response( 200, $member->apiOutput() );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
@@ -256,7 +258,7 @@ class _members extends \IPS\Api\Controller
|
||||
* Deletes a member
|
||||
*
|
||||
* @param int $id ID Number
|
||||
* @throws 1C292/3 INVALID_ID The member ID does not exist
|
||||
* @throws 1C292/2 INVALID_ID The member ID does not exist
|
||||
* @return void
|
||||
*/
|
||||
public function DELETEitem( $id )
|
||||
|
||||
Reference in new issue
Block a user