Adding more rest end points and finishing the save load configuration feature.
This commit is contained in:
@@ -345,7 +345,7 @@ class WebApplication
|
||||
foreach ($featureApiClassList as $classFile) {
|
||||
if (pathinfo($classFile, PATHINFO_EXTENSION) === 'php') {
|
||||
$relClassPath = str_replace('.php', '', str_replace($servicesDir, '', $classFile));
|
||||
$namespace = '\\ProcessMaker\\Services\\Api\\'.basename($classFile, '.php');
|
||||
$namespace = '\\ProcessMaker\\Services\\Api\\' . basename($classFile, '.php');
|
||||
$namespace = strpos($namespace, "//") === false? $namespace: str_replace("//", '', $namespace);
|
||||
require_once $classFile;
|
||||
$this->rest->addAPIClass($namespace);
|
||||
|
||||
@@ -12,10 +12,42 @@ class ActionsByEmailService
|
||||
case 'configuration':
|
||||
require_once 'classes/model/AbeConfiguration.php';
|
||||
$abeConfigurationInstance = new \AbeConfiguration();
|
||||
$noteValues = json_decode($params['fields']['ABE_CASE_NOTE_IN_RESPONSE']);
|
||||
foreach ($noteValues as $value) {
|
||||
$params['fields']['ABE_CASE_NOTE_IN_RESPONSE'] = $value;
|
||||
}
|
||||
$abeConfigurationInstance->createOrUpdate($params['fields']);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function loadConfiguration($params)
|
||||
{
|
||||
if ($params['type'] != 'activity') {
|
||||
return NULL;
|
||||
}
|
||||
set_include_path(PATH_FEATURES . 'ActionsByEmail' . PATH_SEPARATOR . get_include_path());
|
||||
require_once 'classes/model/AbeConfiguration.php';
|
||||
|
||||
$criteria = new \Criteria();
|
||||
$criteria->add(\AbeConfigurationPeer::PRO_UID, $params['PRO_UID']);
|
||||
$criteria->add(\AbeConfigurationPeer::TAS_UID, $params['TAS_UID']);
|
||||
$result = \AbeConfigurationPeer::doSelectRS($criteria);
|
||||
$result->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$result->next();
|
||||
$configuration = array();
|
||||
if ($configuration = $result->getRow()) {
|
||||
$configuration['ABE_EMAIL_FIELD_VALUE'] = $configuration['ABE_EMAIL_FIELD'];
|
||||
$configuration['ABE_ACTION_FIELD_VALUE'] = $configuration['ABE_ACTION_FIELD'];
|
||||
$configuration['ABE_CASE_NOTE_IN_RESPONSE'] = $configuration['ABE_CASE_NOTE_IN_RESPONSE'] ? '["1"]' : '[]';
|
||||
}
|
||||
$configuration['feature'] = 'ActionsByEmail';
|
||||
$configuration['prefix'] = 'abe';
|
||||
$configuration['PRO_UID'] = $params['PRO_UID'];
|
||||
$configuration['TAS_UID'] = $params['TAS_UID'];
|
||||
$configuration['SYS_LANG'] = SYS_LANG;
|
||||
return $configuration;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
namespace Features\ActionsByEmail\Services;
|
||||
namespace ProcessMaker\Services\Api;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
@@ -13,12 +13,12 @@ require_once 'classes/model/Application.php';
|
||||
require_once 'classes/model/Users.php';
|
||||
|
||||
/**
|
||||
* Class ActionsByEmailApi
|
||||
* Class ActionsByEmail
|
||||
*
|
||||
* @author gustavo cruz <gustavo.cruz@colosa.com>
|
||||
* @protected
|
||||
*/
|
||||
class ActionsByEmailApi extends Api
|
||||
class ActionsByEmail extends Api
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -516,4 +516,34 @@ class ActionsByEmailApi extends Api
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @url GET /Templates/:proId
|
||||
*/
|
||||
public function getTemplates($proId)
|
||||
{
|
||||
$templates = array();
|
||||
$path = PATH_DATA_MAILTEMPLATES . $proId . PATH_SEP;
|
||||
|
||||
\G::verifyPath($path, true);
|
||||
|
||||
if (defined('PARTNER_FLAG')) {
|
||||
if (!file_exists($path . 'actionsByEmailPartner.html')) {
|
||||
@copy(PATH_FEATURES . 'ActionsByEmail' . PATH_SEP . 'data' . PATH_SEP . 'actionsByEmailPartner.html', $path . 'actionsByEmail.html');
|
||||
}
|
||||
} else {
|
||||
if (!file_exists($path . 'actionsByEmail.html')) {
|
||||
@copy(PATH_FEATURES . 'ActionsByEmail' . PATH_SEP . 'data' . PATH_SEP . 'actionsByEmail.html', $path . 'actionsByEmail.html');
|
||||
}
|
||||
}
|
||||
|
||||
$directory = dir($path);
|
||||
|
||||
while ($object = $directory->read()) {
|
||||
if (($object !== '.') && ($object !== '..') && ($object !== 'alert_message.html')) {
|
||||
$templates[] = array('FILE' => $object, 'NAME' => $object);
|
||||
}
|
||||
}
|
||||
return $templates;
|
||||
}
|
||||
}
|
||||
@@ -13,14 +13,17 @@ class FeaturesHandler
|
||||
}
|
||||
}
|
||||
|
||||
public function retrieveConfiguration($params)
|
||||
public function loadConfiguration($params)
|
||||
{
|
||||
foreach ($this->getFeatureList() as $feature) {
|
||||
|
||||
$features = $this->getFeatureList();
|
||||
foreach ($features as $feature) {
|
||||
$service = $this->getFeatureService(array('name' => $feature->name));
|
||||
$configurations[] = $service->loadConfiguration($params);
|
||||
}
|
||||
return array_filter($configurations);
|
||||
}
|
||||
|
||||
public function saveConfiguration($type, $configurationForms)
|
||||
public function saveConfiguration($configurationForms)
|
||||
{
|
||||
foreach ($configurationForms as $feature => $form) {
|
||||
$service = $this->getFeatureService(array('name' => $feature));
|
||||
|
||||
@@ -61,25 +61,25 @@ class Activity extends Api
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prj_uid {@min 32} {@max 32}
|
||||
* @param string $act_uid {@min 32} {@max 32}
|
||||
* @param string $pro_uid {@min 32} {@max 32}
|
||||
* @param string $tas_uid {@min 32} {@max 32}
|
||||
* @param string $filter {@choice definition,,properties}
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @author Gustavo Cruz <gustavo.cruz@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return array
|
||||
*
|
||||
* @url GET /:prj_uid/activity/:act_uid/feature-configuration
|
||||
* @url GET /:pro_uid/activity/:tas_uid/feature-configuration
|
||||
*/
|
||||
public function doGetProjectActivityFeatureConfiguration($prj_uid, $act_uid, $filter = '')
|
||||
public function doGetProjectActivityFeatureConfiguration($pro_uid, $tas_uid, $filter = '')
|
||||
{
|
||||
try {
|
||||
$featureServices = new \Features\FeatureServices();
|
||||
$configuration = $featureServices->retrieveView(array(
|
||||
$featureHandler = new \Features\FeaturesHandler();
|
||||
$configuration = $featureHandler->loadConfiguration(array(
|
||||
'type' => 'activity',
|
||||
'view' => 'configuration',
|
||||
'prj_uid' => $prj_uid,
|
||||
'act_uid' => $act_uid
|
||||
'form' => 'configuration',
|
||||
'PRO_UID' => $pro_uid,
|
||||
'TAS_UID' => $tas_uid
|
||||
));
|
||||
return $configuration;
|
||||
} catch (\Exception $e) {
|
||||
@@ -108,7 +108,7 @@ class Activity extends Api
|
||||
$properties = $task->updateProperties($prj_uid, $act_uid, $request_data);
|
||||
/** features */
|
||||
$featureHandler = new \Features\FeaturesHandler();
|
||||
$featureHandler->saveConfiguration('activity', $request_data['properties']['_features']);
|
||||
$featureHandler->saveConfiguration($request_data['properties']['_features']);
|
||||
/** features */
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user