2014-01-29 17:46:28 -04:00
|
|
|
<?php
|
2014-04-02 17:02:02 -04:00
|
|
|
namespace ProcessMaker\Services\Api;
|
2014-01-29 17:46:28 -04:00
|
|
|
|
|
|
|
|
use \ProcessMaker\Services\Api;
|
|
|
|
|
use \Luracast\Restler\RestException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Group Api Controller
|
|
|
|
|
*
|
|
|
|
|
* @protected
|
|
|
|
|
*/
|
|
|
|
|
class Group extends Api
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @url GET
|
|
|
|
|
*/
|
|
|
|
|
public function index($filter = null, $start = null, $limit = null)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
2014-01-30 14:30:18 -04:00
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
2014-01-29 17:46:28 -04:00
|
|
|
|
|
|
|
|
$response = $group->getGroups(array("filter" => $filter), null, null, $start, $limit);
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url GET /:grp_uid
|
|
|
|
|
*
|
|
|
|
|
* @param string $grp_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doGet($grp_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
2014-01-30 14:30:18 -04:00
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
2014-01-29 17:46:28 -04:00
|
|
|
|
|
|
|
|
$response = $group->getGroup($grp_uid);
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url POST
|
|
|
|
|
*
|
2014-02-10 17:16:44 -04:00
|
|
|
* @param array $request_data
|
2014-01-29 17:46:28 -04:00
|
|
|
*
|
|
|
|
|
* @status 201
|
|
|
|
|
*/
|
2014-02-10 17:16:44 -04:00
|
|
|
public function doPost($request_data)
|
|
|
|
|
{
|
2014-01-29 17:46:28 -04:00
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
2014-01-30 14:30:18 -04:00
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
2014-01-29 17:46:28 -04:00
|
|
|
|
|
|
|
|
$arrayData = $group->create($request_data);
|
|
|
|
|
|
|
|
|
|
$response = $arrayData;
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url PUT /:grp_uid
|
|
|
|
|
*
|
|
|
|
|
* @param string $grp_uid {@min 32}{@max 32}
|
|
|
|
|
* @param array $request_data
|
|
|
|
|
*/
|
2014-02-10 17:16:44 -04:00
|
|
|
public function doPut($grp_uid, $request_data)
|
|
|
|
|
{
|
2014-01-29 17:46:28 -04:00
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
2014-01-30 14:30:18 -04:00
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
2014-01-29 17:46:28 -04:00
|
|
|
|
|
|
|
|
$arrayData = $group->update($grp_uid, $request_data);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url DELETE /:grp_uid
|
|
|
|
|
*
|
|
|
|
|
* @param string $grp_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doDelete($grp_uid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
2014-01-30 14:30:18 -04:00
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
2014-01-29 17:46:28 -04:00
|
|
|
|
|
|
|
|
$group->delete($grp_uid);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-10 17:16:44 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url GET /:grp_uid/users
|
|
|
|
|
*
|
|
|
|
|
* @param string $grp_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doGetUsers($grp_uid, $filter = null, $start = null, $limit = null)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
2014-02-10 17:16:44 -04:00
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
|
|
|
|
|
|
|
|
|
$response = $group->getUsers("USERS", $grp_uid, array("filter" => $filter), null, null, $start, $limit);
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url GET /:grp_uid/available-users
|
|
|
|
|
*
|
|
|
|
|
* @param string $grp_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doGetAvailableUsers($grp_uid, $filter = null, $start = null, $limit = null)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2014-04-02 17:02:02 -04:00
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
2014-02-10 17:16:44 -04:00
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
|
|
|
|
|
|
|
|
|
$response = $group->getUsers("AVAILABLE-USERS", $grp_uid, array("filter" => $filter), null, null, $start, $limit);
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-12 09:18:47 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @url GET /:grp_uid/supervisor-users
|
|
|
|
|
*
|
|
|
|
|
* @param string $grp_uid {@min 32}{@max 32}
|
|
|
|
|
*/
|
|
|
|
|
public function doGetSupervisorUsers($grp_uid, $filter = null, $start = null, $limit = null)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$group = new \ProcessMaker\BusinessModel\Group();
|
|
|
|
|
$group->setFormatFieldNameInUppercase(false);
|
|
|
|
|
|
|
|
|
|
$response = $group->getUsers("SUPERVISOR", $grp_uid, array("filter" => $filter), null, null, $start, $limit);
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-29 17:46:28 -04:00
|
|
|
}
|
|
|
|
|
|