HOR-4601
This commit is contained in:
73
workflow/engine/src/ProcessMaker/Services/Api/FileLogs.php
Normal file
73
workflow/engine/src/ProcessMaker/Services/Api/FileLogs.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Services\Api;
|
||||
|
||||
use Exception;
|
||||
use G;
|
||||
use ProcessMaker\BusinessModel\Files\FilesLogs;
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
* Log Files Api Controller
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
class FileLogs extends Api
|
||||
{
|
||||
/**
|
||||
* Get the list of the log files
|
||||
*
|
||||
* @url GET /list
|
||||
*
|
||||
* @param int $start {@from path}
|
||||
* @param int $limit {@from path}
|
||||
* @param string $sort {@from path}
|
||||
* @param string $dir {@from path}
|
||||
* @param string $filter {@from path}
|
||||
*
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_LOG_FILES}
|
||||
*/
|
||||
public function doGetListFileLogs(
|
||||
$start = 0,
|
||||
$limit = 0,
|
||||
$sort = 'fileCreated',
|
||||
$dir = 'DESC',
|
||||
$filter = ''
|
||||
)
|
||||
{
|
||||
try {
|
||||
$file = new FilesLogs();
|
||||
return $file->getAllFiles($filter, $sort, $start, $limit, $dir);
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download file.
|
||||
*
|
||||
* @url POST /download
|
||||
*
|
||||
* @param array $request_data name of the files
|
||||
*
|
||||
* @throws RestException
|
||||
*
|
||||
* @access protected
|
||||
* @class AccessControl {@permission PM_SETUP_LOG_FILES}
|
||||
*/
|
||||
public function doPostDownload($request_data)
|
||||
{
|
||||
try {
|
||||
$file = new FilesLogs();
|
||||
$file->download(G::json_decode($request_data['files']));
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Services\Api\Project;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
use Exception;
|
||||
use Luracast\Restler\RestException;
|
||||
use ProcessMaker\BusinessModel\ProcessPermissions as BmProcessPermissions;
|
||||
use ProcessMaker\Services\Api;
|
||||
|
||||
/**
|
||||
* Project\ProcessPermissions Api Controller
|
||||
@@ -17,20 +19,18 @@ class ProcessPermissions extends Api
|
||||
/**
|
||||
* @param string $prj_uid {@min 1} {@max 32}
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @url GET /:prj_uid/process-permissions
|
||||
*/
|
||||
public function doGetProcessPermissions($prj_uid)
|
||||
{
|
||||
try {
|
||||
$processPermissions = new \ProcessMaker\BusinessModel\ProcessPermissions();
|
||||
$processPermissions = new BmProcessPermissions();
|
||||
$response = $processPermissions->getProcessPermissions($prj_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -39,20 +39,18 @@ class ProcessPermissions extends Api
|
||||
* @param string $prj_uid {@min 1} {@max 32}
|
||||
* @param string $ob_uid {@min 1} {@max 32}
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @return array
|
||||
* @throws RestException
|
||||
*
|
||||
* @url GET /:prj_uid/process-permission/:ob_uid
|
||||
*/
|
||||
public function doGetProcessPermission($prj_uid, $ob_uid)
|
||||
{
|
||||
try {
|
||||
$processPermissions = new \ProcessMaker\BusinessModel\ProcessPermissions();
|
||||
$processPermissions = new BmProcessPermissions();
|
||||
$response = $processPermissions->getProcessPermissions($prj_uid, $ob_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -75,11 +73,11 @@ class ProcessPermissions extends Api
|
||||
public function doPostProcessPermission($prj_uid, $request_data)
|
||||
{
|
||||
try {
|
||||
$hiddenFields = array('task_target', 'group_user', 'task_source',
|
||||
$hiddenFields = ['task_target', 'group_user', 'task_source',
|
||||
'object_type', 'object', 'participated', 'action'
|
||||
);
|
||||
];
|
||||
$request_data['pro_uid'] = $prj_uid;
|
||||
$processPermissions = new \ProcessMaker\BusinessModel\ProcessPermissions();
|
||||
$processPermissions = new BmProcessPermissions();
|
||||
$response = $processPermissions->saveProcessPermission($request_data);
|
||||
foreach ($response as $key => $eventData) {
|
||||
if (in_array($key, $hiddenFields)) {
|
||||
@@ -87,13 +85,13 @@ class ProcessPermissions extends Api
|
||||
}
|
||||
}
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update process permisson.
|
||||
* Update process permission.
|
||||
*
|
||||
* @url PUT /:prj_uid/process-permission/:ob_uid
|
||||
*
|
||||
@@ -104,7 +102,7 @@ class ProcessPermissions extends Api
|
||||
* @param string $op_user_relation {@from body} {@choice 1,2}
|
||||
* @param string $op_case_status {@from body} {@choice ALL,DRAFT,TO_DO,PAUSED,COMPLETED}
|
||||
* @param string $op_participate {@from body} {@choice 0,1}
|
||||
* @param string $op_obj_type {@from body} {@choice ANY,DYNAFORM,ATTACHMENT,INPUT,OUTPUT,CASES_NOTES,MSGS_HISTORY,SUMMARY_FORM}
|
||||
* @param string $op_obj_type {@from body} {@choice ANY,DYNAFORM,ATTACHMENT,INPUT,OUTPUT,CASES_NOTES,MSGS_HISTORY,SUMMARY_FORM,REASSIGN_MY_CASES}
|
||||
* @param string $op_action {@from body} {@choice VIEW,BLOCK,DELETE,RESEND}
|
||||
* @param string $tas_uid {@from body}
|
||||
* @param string $op_task_source {@from body}
|
||||
@@ -124,10 +122,10 @@ class ProcessPermissions extends Api
|
||||
$request_data,
|
||||
$usr_uid,
|
||||
$op_user_relation,
|
||||
$op_case_status,
|
||||
$op_participate,
|
||||
$op_case_status = 'ALL',
|
||||
$op_participate = '0',
|
||||
$op_obj_type,
|
||||
$op_action,
|
||||
$op_action = 'VIEW',
|
||||
$tas_uid = '',
|
||||
$op_task_source = '',
|
||||
$dynaforms = '',
|
||||
@@ -136,10 +134,11 @@ class ProcessPermissions extends Api
|
||||
) {
|
||||
try {
|
||||
$request_data['pro_uid'] = $prj_uid;
|
||||
$processPermissions = new \ProcessMaker\BusinessModel\ProcessPermissions();
|
||||
$request_data['op_action'] = $op_action;
|
||||
$processPermissions = new BmProcessPermissions();
|
||||
$response = $processPermissions->saveProcessPermission($request_data, $ob_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
@@ -153,14 +152,14 @@ class ProcessPermissions extends Api
|
||||
* @param string $ob_uid {@min 1} {@max 32}
|
||||
*
|
||||
* @return void
|
||||
* @throws RestException
|
||||
*/
|
||||
public function doDeleteProcessPermission($prj_uid, $ob_uid)
|
||||
{
|
||||
try {
|
||||
$processPermissions = new \ProcessMaker\BusinessModel\ProcessPermissions();
|
||||
$response = $processPermissions->deleteProcessPermission($ob_uid, $prj_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
$processPermissions = new BmProcessPermissions();
|
||||
$processPermissions->deleteProcessPermission($ob_uid, $prj_uid);
|
||||
} catch (Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,27 +2,29 @@
|
||||
|
||||
namespace ProcessMaker\Services\OAuth2;
|
||||
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Simple PmPDO storage for all storage types
|
||||
* based on \OAuth2\Storage\Pdo
|
||||
*
|
||||
* @author Erik Amaru Ortiz <aortiz.erik at gmail dot com>
|
||||
*/
|
||||
class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
|
||||
class PmPdo implements
|
||||
\OAuth2\Storage\AuthorizationCodeInterface,
|
||||
\OAuth2\Storage\AccessTokenInterface,
|
||||
\OAuth2\Storage\ClientCredentialsInterface,
|
||||
\OAuth2\Storage\UserCredentialsInterface,
|
||||
\OAuth2\Storage\RefreshTokenInterface,
|
||||
\OAuth2\Storage\JwtBearerInterface
|
||||
{
|
||||
|
||||
protected $db;
|
||||
protected $dbRBAC;
|
||||
protected $config;
|
||||
|
||||
public function __construct($connection, $config = array(), $connectionRBAC = null)
|
||||
{
|
||||
if (!$connection instanceof \PDO) {
|
||||
if (!$connection instanceof PDO) {
|
||||
if (!is_array($connection)) {
|
||||
throw new \InvalidArgumentException('First argument to OAuth2\Storage\Pdo must be an instance of PDO or a configuration array');
|
||||
}
|
||||
@@ -34,12 +36,12 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
|
||||
'username' => null,
|
||||
'password' => null,
|
||||
), $connection);
|
||||
$connection = new \PDO($connection['dsn'], $connection['username'], $connection['password']);
|
||||
$connection = new PDO($connection['dsn'], $connection['username'], $connection['password']);
|
||||
}
|
||||
$this->db = $connection;
|
||||
|
||||
// it's for Pm < 3
|
||||
if (!is_null($connectionRBAC) &&(!$connectionRBAC instanceof \PDO)) {
|
||||
if (!is_null($connectionRBAC) &&(!$connectionRBAC instanceof PDO)) {
|
||||
if (!is_array($connectionRBAC)) {
|
||||
throw new \InvalidArgumentException('First argument to OAuth2\Storage\Pdo must be an instance of PDO or a configuration array');
|
||||
}
|
||||
@@ -51,12 +53,12 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
|
||||
'username' => null,
|
||||
'password' => null,
|
||||
), $connectionRBAC);
|
||||
$connectionRBAC = new \PDO($connectionRBAC['dsn'], $connectionRBAC['username'], $connectionRBAC['password']);
|
||||
$connectionRBAC = new PDO($connectionRBAC['dsn'], $connectionRBAC['username'], $connectionRBAC['password']);
|
||||
}
|
||||
$this->dbRBAC = $connectionRBAC;
|
||||
|
||||
// debugging
|
||||
$connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$this->config = array_merge(array(
|
||||
'client_table' => 'OAUTH_CLIENTS',
|
||||
@@ -173,7 +175,7 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
|
||||
{
|
||||
$access_token = new \OauthAccessTokens();
|
||||
$access_token->load($token);
|
||||
$stmt = $this->db->prepare(sprintf('UPDATE %s SET EXPIRES=%s WHERE ACCESS_TOKEN=:token', $this->config['access_token_table'], "'".Date('Y-m-d H:i:s',strtotime("-1 minute"))."'"));
|
||||
$stmt = $this->db->prepare(sprintf('UPDATE %s SET EXPIRES=%s WHERE ACCESS_TOKEN=:token', $this->config['access_token_table'], "'".Date('Y-m-d H:i:s', strtotime("-1 minute"))."'"));
|
||||
return $stmt->execute(compact('token'));
|
||||
}
|
||||
|
||||
@@ -192,12 +194,12 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
|
||||
{
|
||||
$RBAC = \RBAC::getSingleton();
|
||||
$RBAC->initRBAC();
|
||||
$uid = $RBAC->VerifyLogin($username , $password);
|
||||
if($uid < 0){
|
||||
return false;
|
||||
$uid = $RBAC->VerifyLogin($username, $password);
|
||||
if ($uid < 0) {
|
||||
return false;
|
||||
}
|
||||
if($uid != ''){
|
||||
return true;
|
||||
if ($uid != '') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -295,6 +297,4 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
|
||||
|
||||
return array_merge($a, array_change_key_case($a, $case));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -121,8 +121,11 @@ debug = 1
|
||||
authentication = "ProcessMaker\Services\Api\Google\Authentication"
|
||||
|
||||
[alias: gmailIntegration]
|
||||
gmailIntegration = "ProcessMaker\Services\Api\GmailIntegration"
|
||||
token = "ProcessMaker\Services\Api\GmailToken"
|
||||
gmailIntegration = "ProcessMaker\Services\Api\GmailIntegration"
|
||||
token = "ProcessMaker\Services\Api\GmailToken"
|
||||
|
||||
[alias: reportingIndicators]
|
||||
reportingIndicators = "ProcessMaker\Services\Api\ReportingIndicators"
|
||||
reportingIndicators = "ProcessMaker\Services\Api\ReportingIndicators"
|
||||
|
||||
[alias: logs]
|
||||
log = "ProcessMaker\Services\Api\FileLogs"
|
||||
Reference in New Issue
Block a user