Adding the feature license validations
This commit is contained in:
@@ -1,31 +1,42 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Features\ActionsByEmail;
|
namespace Features\ActionsByEmail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of ActionsByEmailService
|
* Description of ActionsByEmailService
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class ActionsByEmailService
|
class ActionsByEmailService
|
||||||
{
|
{
|
||||||
|
|
||||||
public function saveConfiguration($params)
|
public function saveConfiguration($params)
|
||||||
{
|
{
|
||||||
switch ($params['type']) {
|
if (\PMLicensedFeatures
|
||||||
case 'configuration':
|
::getSingleton()
|
||||||
require_once 'classes/model/AbeConfiguration.php';
|
->verifyfeature('zCeazVrMjVTQVVLcTdwSHNaSzMwTGNCdXRqTm9aYlEzVnI=')) {
|
||||||
$abeConfigurationInstance = new \AbeConfiguration();
|
switch ($params['type']) {
|
||||||
$noteValues = json_decode($params['fields']['ABE_CASE_NOTE_IN_RESPONSE']);
|
case 'configuration':
|
||||||
foreach ($noteValues as $value) {
|
require_once 'classes/model/AbeConfiguration.php';
|
||||||
$params['fields']['ABE_CASE_NOTE_IN_RESPONSE'] = $value;
|
$abeConfigurationInstance = new \AbeConfiguration();
|
||||||
}
|
$noteValues = json_decode($params['fields']['ABE_CASE_NOTE_IN_RESPONSE']);
|
||||||
$abeConfigurationInstance->createOrUpdate($params['fields']);
|
foreach ($noteValues as $value) {
|
||||||
break;
|
$params['fields']['ABE_CASE_NOTE_IN_RESPONSE'] = $value;
|
||||||
default:
|
}
|
||||||
break;
|
$abeConfigurationInstance->createOrUpdate($params['fields']);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadConfiguration($params)
|
public function loadConfiguration($params)
|
||||||
{
|
{
|
||||||
if ($params['type'] != 'activity') {
|
if ($params['type'] != 'activity'
|
||||||
|
|| (\PMLicensedFeatures
|
||||||
|
::getSingleton()
|
||||||
|
->verifyfeature('zCeazVrMjVTQVVLcTdwSHNaSzMwTGNCdXRqTm9aYlEzVnI=')))
|
||||||
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
set_include_path(PATH_FEATURES . 'ActionsByEmail' . PATH_SEPARATOR . get_include_path());
|
set_include_path(PATH_FEATURES . 'ActionsByEmail' . PATH_SEPARATOR . get_include_path());
|
||||||
@@ -50,4 +61,5 @@ class ActionsByEmailService
|
|||||||
$configuration['SYS_LANG'] = SYS_LANG;
|
$configuration['SYS_LANG'] = SYS_LANG;
|
||||||
return $configuration;
|
return $configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
class PMFeatureRegistry
|
class PMFeatureRegistry
|
||||||
{
|
{
|
||||||
private $features = array ();
|
private $features = array ();
|
||||||
private $triggers = array ();
|
private $keys = array ('ActionsByEmail' => 'zCeazVrMjVTQVVLcTdwSHNaSzMwTGNCdXRqTm9aYlEzVnI=');
|
||||||
private static $instance = null;
|
private static $instance = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,6 +65,9 @@ class PMFeatureRegistry
|
|||||||
*/
|
*/
|
||||||
public function registerFeature ($featureName, $filename = null)
|
public function registerFeature ($featureName, $filename = null)
|
||||||
{
|
{
|
||||||
|
if (!$this->validateFeatureLicense($featureName)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$className = $featureName . "Feature";
|
$className = $featureName . "Feature";
|
||||||
$feature = new $className( $featureName, $filename );
|
$feature = new $className( $featureName, $filename );
|
||||||
if (isset( $this->features[$featureName] )) {
|
if (isset( $this->features[$featureName] )) {
|
||||||
@@ -98,7 +101,7 @@ class PMFeatureRegistry
|
|||||||
{
|
{
|
||||||
$feature = $this->retrieveFeature($featureName);
|
$feature = $this->retrieveFeature($featureName);
|
||||||
if ($feature) {
|
if ($feature) {
|
||||||
$feature->enable();
|
$feature->disable();
|
||||||
}
|
}
|
||||||
throw new Exception( "Unable to disable feature '$featureName' (feature not found)" );
|
throw new Exception( "Unable to disable feature '$featureName' (feature not found)" );
|
||||||
}
|
}
|
||||||
@@ -167,6 +170,19 @@ class PMFeatureRegistry
|
|||||||
$this->features[$name] = $feature;
|
$this->features[$name] = $feature;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function validateFeatureLicense($featureName)
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
isset($this->keys[$featureName])
|
||||||
|
&& PMLicensedFeatures
|
||||||
|
::getSingleton()
|
||||||
|
->verifyfeature($this->keys[$featureName])
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
|||||||
@@ -1,115 +1,119 @@
|
|||||||
<?php
|
<?php
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
switch ($_REQUEST['action']) {
|
if (PMLicensedFeatures
|
||||||
case 'processABE' :
|
::getSingleton()
|
||||||
$G_PUBLISH = new Publisher();
|
->verifyfeature('zCeazVrMjVTQVVLcTdwSHNaSzMwTGNCdXRqTm9aYlEzVnI=')) {
|
||||||
try {
|
switch ($_REQUEST['action']) {
|
||||||
// Validations
|
case 'processABE' :
|
||||||
if (!isset($_REQUEST['APP_UID'])) {
|
$G_PUBLISH = new Publisher();
|
||||||
$_REQUEST['APP_UID'] = '';
|
try {
|
||||||
}
|
// Validations
|
||||||
|
if (!isset($_REQUEST['APP_UID'])) {
|
||||||
if (!isset($_REQUEST['DEL_INDEX'])) {
|
$_REQUEST['APP_UID'] = '';
|
||||||
$_REQUEST['DEL_INDEX'] = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_REQUEST['APP_UID'] == '') {
|
|
||||||
throw new Exception('The parameter APP_UID is empty.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_REQUEST['DEL_INDEX'] == '') {
|
|
||||||
throw new Exception('The parameter DEL_INDEX is empty.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$_REQUEST['APP_UID'] = G::decrypt(urldecode(utf8_encode($_REQUEST['APP_UID'])), URL_KEY);
|
|
||||||
$_REQUEST['DEL_INDEX'] = G::decrypt(urldecode(utf8_encode($_REQUEST['DEL_INDEX'])), URL_KEY);
|
|
||||||
$_REQUEST['FIELD'] = G::decrypt(urldecode(utf8_encode($_REQUEST['FIELD'])), URL_KEY);
|
|
||||||
$_REQUEST['VALUE'] = G::decrypt(urldecode(utf8_encode($_REQUEST['VALUE'])), URL_KEY);
|
|
||||||
$_REQUEST['ABER'] = G::decrypt(urldecode(utf8_encode($_REQUEST['ABER'])), URL_KEY);
|
|
||||||
|
|
||||||
G::LoadClass('case');
|
|
||||||
|
|
||||||
$cases = new Cases();
|
|
||||||
$caseFieldsABE = $cases->loadCase($_REQUEST['APP_UID'], $_REQUEST['DEL_INDEX']);
|
|
||||||
|
|
||||||
if (is_null($caseFieldsABE['DEL_FINISH_DATE'])) {
|
|
||||||
$dataField = array();
|
|
||||||
$dataField[$_REQUEST['FIELD']] = $_REQUEST['VALUE'];
|
|
||||||
$caseFieldsABE ['APP_DATA'] = array_merge($caseFieldsABE ['APP_DATA'], $dataField);
|
|
||||||
|
|
||||||
$dataResponses = array();
|
|
||||||
$dataResponses['ABE_REQ_UID'] = $_REQUEST['ABER'];
|
|
||||||
$dataResponses['ABE_RES_CLIENT_IP'] = $_SERVER['REMOTE_ADDR'];
|
|
||||||
$dataResponses['ABE_RES_DATA'] = serialize($_REQUEST['VALUE']);
|
|
||||||
$dataResponses['ABE_RES_STATUS'] = 'PENDING';
|
|
||||||
$dataResponses['ABE_RES_MESSAGE'] = '';
|
|
||||||
|
|
||||||
try {
|
|
||||||
set_include_path(PATH_FEATURES . 'ActionsByEmail' . PATH_SEPARATOR . get_include_path());
|
|
||||||
require_once 'classes/model/AbeResponses.php';
|
|
||||||
$abeAbeResponsesInstance = new AbeResponses();
|
|
||||||
$dataResponses['ABE_RES_UID'] = $abeAbeResponsesInstance->createOrUpdate($dataResponses);
|
|
||||||
} catch (Exception $error) {
|
|
||||||
throw $error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$cases->updateCase($_REQUEST['APP_UID'], $caseFieldsABE);
|
if (!isset($_REQUEST['DEL_INDEX'])) {
|
||||||
|
$_REQUEST['DEL_INDEX'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
G::LoadClass('wsBase');
|
if ($_REQUEST['APP_UID'] == '') {
|
||||||
|
throw new Exception('The parameter APP_UID is empty.');
|
||||||
|
}
|
||||||
|
|
||||||
$ws = new wsBase();
|
if ($_REQUEST['DEL_INDEX'] == '') {
|
||||||
|
throw new Exception('The parameter DEL_INDEX is empty.');
|
||||||
|
}
|
||||||
|
|
||||||
$result = $ws->derivateCase($caseFieldsABE['CURRENT_USER_UID'], $_REQUEST['APP_UID'], $_REQUEST['DEL_INDEX'], true);
|
$_REQUEST['APP_UID'] = G::decrypt(urldecode(utf8_encode($_REQUEST['APP_UID'])), URL_KEY);
|
||||||
$code = (is_array($result) ? $result['status_code'] : $result->status_code);
|
$_REQUEST['DEL_INDEX'] = G::decrypt(urldecode(utf8_encode($_REQUEST['DEL_INDEX'])), URL_KEY);
|
||||||
|
$_REQUEST['FIELD'] = G::decrypt(urldecode(utf8_encode($_REQUEST['FIELD'])), URL_KEY);
|
||||||
|
$_REQUEST['VALUE'] = G::decrypt(urldecode(utf8_encode($_REQUEST['VALUE'])), URL_KEY);
|
||||||
|
$_REQUEST['ABER'] = G::decrypt(urldecode(utf8_encode($_REQUEST['ABER'])), URL_KEY);
|
||||||
|
|
||||||
if ($code != 0) {
|
G::LoadClass('case');
|
||||||
throw new Exception('An error occurred while the application was being processed.<br /><br />
|
|
||||||
|
$cases = new Cases();
|
||||||
|
$caseFieldsABE = $cases->loadCase($_REQUEST['APP_UID'], $_REQUEST['DEL_INDEX']);
|
||||||
|
|
||||||
|
if (is_null($caseFieldsABE['DEL_FINISH_DATE'])) {
|
||||||
|
$dataField = array();
|
||||||
|
$dataField[$_REQUEST['FIELD']] = $_REQUEST['VALUE'];
|
||||||
|
$caseFieldsABE ['APP_DATA'] = array_merge($caseFieldsABE ['APP_DATA'], $dataField);
|
||||||
|
|
||||||
|
$dataResponses = array();
|
||||||
|
$dataResponses['ABE_REQ_UID'] = $_REQUEST['ABER'];
|
||||||
|
$dataResponses['ABE_RES_CLIENT_IP'] = $_SERVER['REMOTE_ADDR'];
|
||||||
|
$dataResponses['ABE_RES_DATA'] = serialize($_REQUEST['VALUE']);
|
||||||
|
$dataResponses['ABE_RES_STATUS'] = 'PENDING';
|
||||||
|
$dataResponses['ABE_RES_MESSAGE'] = '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
set_include_path(PATH_FEATURES . 'ActionsByEmail' . PATH_SEPARATOR . get_include_path());
|
||||||
|
require_once 'classes/model/AbeResponses.php';
|
||||||
|
$abeAbeResponsesInstance = new AbeResponses();
|
||||||
|
$dataResponses['ABE_RES_UID'] = $abeAbeResponsesInstance->createOrUpdate($dataResponses);
|
||||||
|
} catch (Exception $error) {
|
||||||
|
throw $error;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cases->updateCase($_REQUEST['APP_UID'], $caseFieldsABE);
|
||||||
|
|
||||||
|
G::LoadClass('wsBase');
|
||||||
|
|
||||||
|
$ws = new wsBase();
|
||||||
|
|
||||||
|
$result = $ws->derivateCase($caseFieldsABE['CURRENT_USER_UID'], $_REQUEST['APP_UID'], $_REQUEST['DEL_INDEX'], true);
|
||||||
|
$code = (is_array($result) ? $result['status_code'] : $result->status_code);
|
||||||
|
|
||||||
|
if ($code != 0) {
|
||||||
|
throw new Exception('An error occurred while the application was being processed.<br /><br />
|
||||||
Error code: ' . $result->status_code . '<br />
|
Error code: ' . $result->status_code . '<br />
|
||||||
Error message: ' . $result->message . '<br /><br />');
|
Error message: ' . $result->message . '<br /><br />');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update
|
||||||
|
$dataResponses['ABE_RES_STATUS'] = ($code == 0 ? 'SENT' : 'ERROR');
|
||||||
|
$dataResponses['ABE_RES_MESSAGE'] = ($code == 0 ? '-' : $result->message);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$abeAbeResponsesInstance = new AbeResponses();
|
||||||
|
$abeAbeResponsesInstance->createOrUpdate($dataResponses);
|
||||||
|
} catch (Exception $error) {
|
||||||
|
throw $error;
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = '<strong>The answer has been submited. Thank you</strong>';
|
||||||
|
|
||||||
|
//Save Cases Notes
|
||||||
|
include_once PATH_FEATURES . 'ActionsByEmail' . DS . 'Services' . DS . 'utils.php';
|
||||||
|
|
||||||
|
$dataAbeRequests = loadAbeRequest($_REQUEST['ABER']);
|
||||||
|
$dataAbeConfiguration = loadAbeConfiguration($dataAbeRequests['ABE_UID']);
|
||||||
|
|
||||||
|
if ($dataAbeConfiguration['ABE_CASE_NOTE_IN_RESPONSE'] == 1) {
|
||||||
|
$response = new stdclass();
|
||||||
|
$response->usrUid = $caseFieldsABE['APP_DATA']['USER_LOGGED'];
|
||||||
|
$response->appUid = $_REQUEST['APP_UID'];
|
||||||
|
$response->noteText = "Check the information that was sent for the receiver: " . $dataAbeRequests['ABE_REQ_SENT_TO'];
|
||||||
|
|
||||||
|
postNote($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
$dataAbeRequests['ABE_REQ_ANSWERED'] = 1;
|
||||||
|
$code == 0 ? uploadAbeRequest($dataAbeRequests) : '';
|
||||||
|
} else {
|
||||||
|
$message = '<strong>The response has already been sent.</strong>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showInfo', '', array('MESSAGE' => $message));
|
||||||
$dataResponses['ABE_RES_STATUS'] = ($code == 0 ? 'SENT' : 'ERROR');
|
} catch (Exception $error) {
|
||||||
$dataResponses['ABE_RES_MESSAGE'] = ($code == 0 ? '-' : $result->message);
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', array('MESSAGE' => $error->getMessage() . 'Please contact to your system administrator.'));
|
||||||
|
|
||||||
try {
|
|
||||||
$abeAbeResponsesInstance = new AbeResponses();
|
|
||||||
$abeAbeResponsesInstance->createOrUpdate($dataResponses);
|
|
||||||
} catch (Exception $error) {
|
|
||||||
throw $error;
|
|
||||||
}
|
|
||||||
|
|
||||||
$message = '<strong>The answer has been submited. Thank you</strong>';
|
|
||||||
|
|
||||||
//Save Cases Notes
|
|
||||||
include_once PATH_FEATURES.'ActionsByEmail'.DS.'Services'.DS.'utils.php';
|
|
||||||
|
|
||||||
$dataAbeRequests = loadAbeRequest($_REQUEST['ABER']);
|
|
||||||
$dataAbeConfiguration = loadAbeConfiguration($dataAbeRequests['ABE_UID']);
|
|
||||||
|
|
||||||
if ($dataAbeConfiguration['ABE_CASE_NOTE_IN_RESPONSE'] == 1) {
|
|
||||||
$response = new stdclass();
|
|
||||||
$response->usrUid = $caseFieldsABE['APP_DATA']['USER_LOGGED'];
|
|
||||||
$response->appUid = $_REQUEST['APP_UID'];
|
|
||||||
$response->noteText = "Check the information that was sent for the receiver: " . $dataAbeRequests['ABE_REQ_SENT_TO'];
|
|
||||||
|
|
||||||
postNote($response);
|
|
||||||
}
|
|
||||||
|
|
||||||
$dataAbeRequests['ABE_REQ_ANSWERED'] = 1;
|
|
||||||
$code == 0 ? uploadAbeRequest($dataAbeRequests) : '';
|
|
||||||
} else {
|
|
||||||
$message = '<strong>The response has already been sent.</strong>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showInfo', '', array('MESSAGE' => $message));
|
G::RenderPage('publish', 'blank');
|
||||||
} catch (Exception $error) {
|
|
||||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', array('MESSAGE' => $error->getMessage() . 'Please contact to your system administrator.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
G::RenderPage('publish', 'blank');
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
Reference in New Issue
Block a user