PMCORE-1128
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace ProcessMaker\Services\Api;
|
namespace ProcessMaker\Services\Api;
|
||||||
|
|
||||||
use \ProcessMaker\Services\Api;
|
use Exception;
|
||||||
use \Luracast\Restler\RestException;
|
use Luracast\Restler\RestException;
|
||||||
|
use ProcessMaker\BusinessModel\User as BmUser;
|
||||||
|
use ProcessMaker\Services\Api;
|
||||||
|
use ProcessMaker\Util\DateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User Api Controller
|
* User Api Controller
|
||||||
@@ -21,21 +24,21 @@ class User extends Api
|
|||||||
* @class AccessControl {@permission PM_USERS,PM_FACTORY}
|
* @class AccessControl {@permission PM_USERS,PM_FACTORY}
|
||||||
* @url GET
|
* @url GET
|
||||||
*/
|
*/
|
||||||
public function index($filter = null, $lfilter = null, $rfilter = null, $start = null, $limit = null, $status = null)
|
public function index($filter = null, $lfilter = null, $rfilter = null, $start = null, $limit = null, $status = null, $sort = null, $dir = null)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$user = new \ProcessMaker\BusinessModel\User();
|
$user = new BmUser();
|
||||||
$user->setFormatFieldNameInUppercase(false);
|
$user->setFormatFieldNameInUppercase(false);
|
||||||
|
|
||||||
$arrayFilterData = array(
|
$arrayFilterData = [
|
||||||
"filter" => (!is_null($filter))? $filter : ((!is_null($lfilter))? $lfilter : ((!is_null($rfilter))? $rfilter : null)),
|
"filter" => (!is_null($filter))? $filter : ((!is_null($lfilter))? $lfilter : ((!is_null($rfilter))? $rfilter : null)),
|
||||||
"filterOption" => (!is_null($filter))? "" : ((!is_null($lfilter))? "LEFT" : ((!is_null($rfilter))? "RIGHT" : ""))
|
"filterOption" => (!is_null($filter))? "" : ((!is_null($lfilter))? "LEFT" : ((!is_null($rfilter))? "RIGHT" : ""))
|
||||||
);
|
];
|
||||||
|
|
||||||
$response = $user->getUsers($arrayFilterData, null, null, $start, $limit, false, true, $status);
|
$response = $user->getUsers($arrayFilterData, $sort, $dir, $start, $limit, false, true, $status);
|
||||||
|
|
||||||
return \ProcessMaker\Util\DateTime::convertUtcToIso8601($response['data'], $this->arrayFieldIso8601);
|
return DateTime::convertUtcToIso8601($response['data'], $this->arrayFieldIso8601);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,13 +53,12 @@ class User extends Api
|
|||||||
public function doGetUser($usr_uid)
|
public function doGetUser($usr_uid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$user = new \ProcessMaker\BusinessModel\User();
|
$user = new BmUser();
|
||||||
$user->setFormatFieldNameInUppercase(false);
|
$user->setFormatFieldNameInUppercase(false);
|
||||||
|
|
||||||
$response = $user->getUser($usr_uid);
|
$response = $user->getUser($usr_uid);
|
||||||
|
|
||||||
return \ProcessMaker\Util\DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
|
return DateTime::convertUtcToIso8601($response, $this->arrayFieldIso8601);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,12 +75,13 @@ class User extends Api
|
|||||||
public function doPostUser($request_data)
|
public function doPostUser($request_data)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$user = new \ProcessMaker\BusinessModel\User();
|
$user = new BmUser();
|
||||||
$arrayData = $user->create($request_data);
|
$arrayData = $user->create($request_data);
|
||||||
$response = $arrayData;
|
$response = $arrayData;
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,10 +102,10 @@ class User extends Api
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$userLoggedUid = $this->getUserId();
|
$userLoggedUid = $this->getUserId();
|
||||||
$user = new \ProcessMaker\BusinessModel\User();
|
$user = new BmUser();
|
||||||
$arrayData = $user->update($usr_uid, $request_data, $userLoggedUid);
|
$arrayData = $user->update($usr_uid, $request_data, $userLoggedUid);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,10 +119,10 @@ class User extends Api
|
|||||||
public function doDeleteUser($usr_uid)
|
public function doDeleteUser($usr_uid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$user = new \ProcessMaker\BusinessModel\User();
|
$user = new BmUser();
|
||||||
$user->delete($usr_uid);
|
$user->delete($usr_uid);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,10 +136,9 @@ class User extends Api
|
|||||||
public function doPostUserImageUpload($usr_uid)
|
public function doPostUserImageUpload($usr_uid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$user = new \ProcessMaker\BusinessModel\User();
|
$user = new BmUser();
|
||||||
$user->uploadImage($usr_uid);
|
$user->uploadImage($usr_uid);
|
||||||
} catch (\Exception $e) {
|
} catch (Exception $e) {
|
||||||
//response
|
|
||||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user