2014-01-31 13:09:16 -04:00
|
|
|
<?php
|
2014-04-02 17:02:02 -04:00
|
|
|
namespace ProcessMaker\Services\Api;
|
2014-01-31 13:09:16 -04:00
|
|
|
|
|
|
|
|
use \ProcessMaker\Services\Api;
|
|
|
|
|
use \Luracast\Restler\RestException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* User Api Controller
|
|
|
|
|
*
|
|
|
|
|
* @protected
|
|
|
|
|
*/
|
|
|
|
|
class User extends Api
|
|
|
|
|
{
|
2015-09-04 16:51:19 -04:00
|
|
|
/**
|
|
|
|
|
* Constructor of the class
|
|
|
|
|
*
|
|
|
|
|
* return void
|
|
|
|
|
*/
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$user = new \ProcessMaker\BusinessModel\User();
|
|
|
|
|
|
|
|
|
|
$usrUid = $this->getUserId();
|
|
|
|
|
|
|
|
|
|
if (!$user->checkPermission($usrUid, "PM_USERS")) {
|
|
|
|
|
throw new \Exception(\G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION", array($usrUid)));
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-31 13:09:16 -04:00
|
|
|
/**
|
|
|
|
|
* @url GET
|
|
|
|
|
*/
|
PM-3659 "Uso de interface lenta (assignment rules) cuando..." SOLVED
Issue:
Uso de interface lenta (assignment rules) cuando se tienen varios usuarios (40000)
Cause:
No se realizo de manera correcta el paginado de registros
Solution:
> Se a implementado los siguientes end-points:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/available-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-available-assignee/paged
Estos end-points aceptan los siguientes parametros:
/paged?filter={filter}&start={start}&limit={limit}&type={type}
/paged?lfilter={lfilter}&start={start}&limit={limit}&type={type}
/paged?rfilter={rfilter}&start={start}&limit={limit}&type={type}
Donde:
filter: Representa la busqueda de registros que contienen este valor
lfilter: Representa la busqueda de registros que empiezan con este valor
rfilter: Representa la busqueda de registros que terminan con este valor
type: Acepta los siguentes valores: "user", "group"
Ejemplo:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged?start=0&limit=3
<<<<< 200
{
"total": 15,
"start": 0,
"limit": 3,
"filter": "",
"data": [
{
"aas_uid": "60593768854492f8fa43aa2064326562",
"aas_name": "GROUP1 (2 Users)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "11886228656016c9329c898096916123",
"aas_name": "GROUP2 (1 User)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "52242914255f202805bd552031573543",
"aas_name": "user1",
"aas_lastname": "user1",
"aas_username": "user1",
"aas_type": "user"
}
]
}
> Se a mejorado los siguientes end-points:
GET /api/1.0/{workspace}/users?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?rfilter={rfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?rfilter={rfilter}&start={start}&limit={limit}
2015-09-25 15:11:42 -04:00
|
|
|
public function index($filter = null, $lfilter = null, $rfilter = null, $start = null, $limit = null)
|
2014-01-31 13:09:16 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$user = new \ProcessMaker\BusinessModel\User();
|
PM-3659 "Uso de interface lenta (assignment rules) cuando..." SOLVED
Issue:
Uso de interface lenta (assignment rules) cuando se tienen varios usuarios (40000)
Cause:
No se realizo de manera correcta el paginado de registros
Solution:
> Se a implementado los siguientes end-points:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/available-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-available-assignee/paged
Estos end-points aceptan los siguientes parametros:
/paged?filter={filter}&start={start}&limit={limit}&type={type}
/paged?lfilter={lfilter}&start={start}&limit={limit}&type={type}
/paged?rfilter={rfilter}&start={start}&limit={limit}&type={type}
Donde:
filter: Representa la busqueda de registros que contienen este valor
lfilter: Representa la busqueda de registros que empiezan con este valor
rfilter: Representa la busqueda de registros que terminan con este valor
type: Acepta los siguentes valores: "user", "group"
Ejemplo:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged?start=0&limit=3
<<<<< 200
{
"total": 15,
"start": 0,
"limit": 3,
"filter": "",
"data": [
{
"aas_uid": "60593768854492f8fa43aa2064326562",
"aas_name": "GROUP1 (2 Users)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "11886228656016c9329c898096916123",
"aas_name": "GROUP2 (1 User)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "52242914255f202805bd552031573543",
"aas_name": "user1",
"aas_lastname": "user1",
"aas_username": "user1",
"aas_type": "user"
}
]
}
> Se a mejorado los siguientes end-points:
GET /api/1.0/{workspace}/users?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?rfilter={rfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?rfilter={rfilter}&start={start}&limit={limit}
2015-09-25 15:11:42 -04:00
|
|
|
$user->setFormatFieldNameInUppercase(false);
|
|
|
|
|
|
|
|
|
|
$arrayFilterData = array(
|
|
|
|
|
"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" : ""))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$response = $user->getUsers($arrayFilterData, null, null, $start, $limit);
|
|
|
|
|
|
|
|
|
|
return $response["data"];
|
2014-01-31 13:09:16 -04:00
|
|
|
} catch (\Exception $e) {
|
PM-3659 "Uso de interface lenta (assignment rules) cuando..." SOLVED
Issue:
Uso de interface lenta (assignment rules) cuando se tienen varios usuarios (40000)
Cause:
No se realizo de manera correcta el paginado de registros
Solution:
> Se a implementado los siguientes end-points:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/available-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-available-assignee/paged
Estos end-points aceptan los siguientes parametros:
/paged?filter={filter}&start={start}&limit={limit}&type={type}
/paged?lfilter={lfilter}&start={start}&limit={limit}&type={type}
/paged?rfilter={rfilter}&start={start}&limit={limit}&type={type}
Donde:
filter: Representa la busqueda de registros que contienen este valor
lfilter: Representa la busqueda de registros que empiezan con este valor
rfilter: Representa la busqueda de registros que terminan con este valor
type: Acepta los siguentes valores: "user", "group"
Ejemplo:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged?start=0&limit=3
<<<<< 200
{
"total": 15,
"start": 0,
"limit": 3,
"filter": "",
"data": [
{
"aas_uid": "60593768854492f8fa43aa2064326562",
"aas_name": "GROUP1 (2 Users)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "11886228656016c9329c898096916123",
"aas_name": "GROUP2 (1 User)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "52242914255f202805bd552031573543",
"aas_name": "user1",
"aas_lastname": "user1",
"aas_username": "user1",
"aas_type": "user"
}
]
}
> Se a mejorado los siguientes end-points:
GET /api/1.0/{workspace}/users?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?rfilter={rfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?rfilter={rfilter}&start={start}&limit={limit}
2015-09-25 15:11:42 -04:00
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
2014-01-31 13:09:16 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url GET /:usr_uid
|
|
|
|
|
*
|
|
|
|
|
* @param string $usr_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
2014-02-07 15:29:23 -04:00
|
|
|
public function doGetUser($usr_uid)
|
2014-01-31 13:09:16 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$user = new \ProcessMaker\BusinessModel\User();
|
PM-3659 "Uso de interface lenta (assignment rules) cuando..." SOLVED
Issue:
Uso de interface lenta (assignment rules) cuando se tienen varios usuarios (40000)
Cause:
No se realizo de manera correcta el paginado de registros
Solution:
> Se a implementado los siguientes end-points:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/available-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-available-assignee/paged
Estos end-points aceptan los siguientes parametros:
/paged?filter={filter}&start={start}&limit={limit}&type={type}
/paged?lfilter={lfilter}&start={start}&limit={limit}&type={type}
/paged?rfilter={rfilter}&start={start}&limit={limit}&type={type}
Donde:
filter: Representa la busqueda de registros que contienen este valor
lfilter: Representa la busqueda de registros que empiezan con este valor
rfilter: Representa la busqueda de registros que terminan con este valor
type: Acepta los siguentes valores: "user", "group"
Ejemplo:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged?start=0&limit=3
<<<<< 200
{
"total": 15,
"start": 0,
"limit": 3,
"filter": "",
"data": [
{
"aas_uid": "60593768854492f8fa43aa2064326562",
"aas_name": "GROUP1 (2 Users)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "11886228656016c9329c898096916123",
"aas_name": "GROUP2 (1 User)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "52242914255f202805bd552031573543",
"aas_name": "user1",
"aas_lastname": "user1",
"aas_username": "user1",
"aas_type": "user"
}
]
}
> Se a mejorado los siguientes end-points:
GET /api/1.0/{workspace}/users?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?rfilter={rfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?rfilter={rfilter}&start={start}&limit={limit}
2015-09-25 15:11:42 -04:00
|
|
|
$user->setFormatFieldNameInUppercase(false);
|
|
|
|
|
|
2014-01-31 13:09:16 -04:00
|
|
|
$response = $user->getUser($usr_uid);
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url POST
|
|
|
|
|
*
|
2014-02-04 16:25:34 -04:00
|
|
|
* @param array $request_data
|
2014-01-31 13:09:16 -04:00
|
|
|
*
|
|
|
|
|
* @status 201
|
|
|
|
|
*/
|
2014-02-14 09:39:24 -04:00
|
|
|
public function doPostUser($request_data)
|
|
|
|
|
{
|
2014-01-31 13:09:16 -04:00
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$user = new \ProcessMaker\BusinessModel\User();
|
2014-02-04 16:25:34 -04:00
|
|
|
$arrayData = $user->create($request_data);
|
2014-01-31 13:09:16 -04:00
|
|
|
$response = $arrayData;
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-02-04 16:25:34 -04:00
|
|
|
* @url PUT /:usr_uid
|
2014-01-31 13:09:16 -04:00
|
|
|
*
|
2014-02-04 16:25:34 -04:00
|
|
|
* @param string $usr_uid {@min 32}{@max 32}
|
2014-01-31 13:09:16 -04:00
|
|
|
* @param array $request_data
|
|
|
|
|
*/
|
2014-02-14 09:39:24 -04:00
|
|
|
public function doPutUser($usr_uid, $request_data)
|
|
|
|
|
{
|
2014-01-31 13:09:16 -04:00
|
|
|
try {
|
2014-02-05 17:03:53 -04:00
|
|
|
$userLoggedUid = $this->getUserId();
|
2014-04-02 17:02:02 -04:00
|
|
|
$user = new \ProcessMaker\BusinessModel\User();
|
2014-02-05 17:03:53 -04:00
|
|
|
$arrayData = $user->update($usr_uid, $request_data, $userLoggedUid);
|
2014-01-31 13:09:16 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-02-04 16:25:34 -04:00
|
|
|
* @url DELETE /:usr_uid
|
2014-01-31 13:09:16 -04:00
|
|
|
*
|
2014-02-04 16:25:34 -04:00
|
|
|
* @param string $usr_uid {@min 32}{@max 32}
|
2014-01-31 13:09:16 -04:00
|
|
|
*/
|
2014-02-07 15:29:23 -04:00
|
|
|
public function doDeleteUser($usr_uid)
|
2014-01-31 13:09:16 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$user = new \ProcessMaker\BusinessModel\User();
|
2014-02-04 16:25:34 -04:00
|
|
|
$user->delete($usr_uid);
|
2014-01-31 13:09:16 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-18 16:13:57 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $usr_uid {@min 32} {@max 32}
|
|
|
|
|
*
|
2014-02-20 12:36:01 -04:00
|
|
|
* @url POST /:usr_uid/image-upload
|
2014-02-18 16:13:57 -04:00
|
|
|
*/
|
|
|
|
|
public function doPostUserImageUpload($usr_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$user = new \ProcessMaker\BusinessModel\User();
|
2014-02-18 16:13:57 -04:00
|
|
|
$user->uploadImage($usr_uid);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
//response
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-11-05 14:56:45 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Save Bookmark start case
|
|
|
|
|
* @url POST /bookmark/:tas_uid
|
|
|
|
|
*
|
|
|
|
|
* @param string $tas_uid {@min 32}{@max 32}
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function doPostBookmarkStartCase($tas_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userLoggedUid = $this->getUserId();
|
|
|
|
|
$user = new \ProcessMaker\BusinessModel\User();
|
|
|
|
|
$user->updateBookmark($userLoggedUid, $tas_uid, 'INSERT');
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete Bookmark start case
|
|
|
|
|
* @url DELETE /bookmark/:tas_uid
|
|
|
|
|
*
|
|
|
|
|
* @param string $tas_uid {@min 32}{@max 32}
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public function doDeleteBookmarkStartCase($tas_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userLoggedUid = $this->getUserId();
|
|
|
|
|
$user = new \ProcessMaker\BusinessModel\User();
|
|
|
|
|
$user->updateBookmark($userLoggedUid, $tas_uid, 'DELETE');
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-31 13:09:16 -04:00
|
|
|
}
|
PM-3659 "Uso de interface lenta (assignment rules) cuando..." SOLVED
Issue:
Uso de interface lenta (assignment rules) cuando se tienen varios usuarios (40000)
Cause:
No se realizo de manera correcta el paginado de registros
Solution:
> Se a implementado los siguientes end-points:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/available-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-assignee/paged
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/adhoc-available-assignee/paged
Estos end-points aceptan los siguientes parametros:
/paged?filter={filter}&start={start}&limit={limit}&type={type}
/paged?lfilter={lfilter}&start={start}&limit={limit}&type={type}
/paged?rfilter={rfilter}&start={start}&limit={limit}&type={type}
Donde:
filter: Representa la busqueda de registros que contienen este valor
lfilter: Representa la busqueda de registros que empiezan con este valor
rfilter: Representa la busqueda de registros que terminan con este valor
type: Acepta los siguentes valores: "user", "group"
Ejemplo:
GET /api/1.0/{workspace}/project/{prj_uid}/activity/{act_uid}/assignee/paged?start=0&limit=3
<<<<< 200
{
"total": 15,
"start": 0,
"limit": 3,
"filter": "",
"data": [
{
"aas_uid": "60593768854492f8fa43aa2064326562",
"aas_name": "GROUP1 (2 Users)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "11886228656016c9329c898096916123",
"aas_name": "GROUP2 (1 User)",
"aas_lastname": "",
"aas_username": "",
"aas_type": "group"
},
{
"aas_uid": "52242914255f202805bd552031573543",
"aas_name": "user1",
"aas_lastname": "user1",
"aas_username": "user1",
"aas_type": "user"
}
]
}
> Se a mejorado los siguientes end-points:
GET /api/1.0/{workspace}/users?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/users?rfilter={rfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?filter={filter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?lfilter={lfilter}&start={start}&limit={limit}
GET /api/1.0/{workspace}/groups?rfilter={rfilter}&start={start}&limit={limit}
2015-09-25 15:11:42 -04:00
|
|
|
|