Adding the feature license validations
This commit is contained in:
@@ -1,31 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Features\ActionsByEmail;
|
||||
|
||||
/**
|
||||
* Description of ActionsByEmailService
|
||||
*
|
||||
*/
|
||||
class ActionsByEmailService
|
||||
{
|
||||
|
||||
public function saveConfiguration($params)
|
||||
{
|
||||
switch ($params['type']) {
|
||||
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;
|
||||
if (\PMLicensedFeatures
|
||||
::getSingleton()
|
||||
->verifyfeature('zCeazVrMjVTQVVLcTdwSHNaSzMwTGNCdXRqTm9aYlEzVnI=')) {
|
||||
switch ($params['type']) {
|
||||
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') {
|
||||
if ($params['type'] != 'activity'
|
||||
|| (\PMLicensedFeatures
|
||||
::getSingleton()
|
||||
->verifyfeature('zCeazVrMjVTQVVLcTdwSHNaSzMwTGNCdXRqTm9aYlEzVnI=')))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
set_include_path(PATH_FEATURES . 'ActionsByEmail' . PATH_SEPARATOR . get_include_path());
|
||||
@@ -50,4 +61,5 @@ class ActionsByEmailService
|
||||
$configuration['SYS_LANG'] = SYS_LANG;
|
||||
return $configuration;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
class PMFeatureRegistry
|
||||
{
|
||||
private $features = array ();
|
||||
private $triggers = array ();
|
||||
private $keys = array ('ActionsByEmail' => 'zCeazVrMjVTQVVLcTdwSHNaSzMwTGNCdXRqTm9aYlEzVnI=');
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
@@ -65,6 +65,9 @@ class PMFeatureRegistry
|
||||
*/
|
||||
public function registerFeature ($featureName, $filename = null)
|
||||
{
|
||||
if (!$this->validateFeatureLicense($featureName)) {
|
||||
return false;
|
||||
}
|
||||
$className = $featureName . "Feature";
|
||||
$feature = new $className( $featureName, $filename );
|
||||
if (isset( $this->features[$featureName] )) {
|
||||
@@ -98,7 +101,7 @@ class PMFeatureRegistry
|
||||
{
|
||||
$feature = $this->retrieveFeature($featureName);
|
||||
if ($feature) {
|
||||
$feature->enable();
|
||||
$feature->disable();
|
||||
}
|
||||
throw new Exception( "Unable to disable feature '$featureName' (feature not found)" );
|
||||
}
|
||||
@@ -167,6 +170,19 @@ class PMFeatureRegistry
|
||||
$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
|
||||
/*----------------------------------********---------------------------------*/
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'processABE' :
|
||||
$G_PUBLISH = new Publisher();
|
||||
try {
|
||||
// Validations
|
||||
if (!isset($_REQUEST['APP_UID'])) {
|
||||
$_REQUEST['APP_UID'] = '';
|
||||
}
|
||||
|
||||
if (!isset($_REQUEST['DEL_INDEX'])) {
|
||||
$_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;
|
||||
if (PMLicensedFeatures
|
||||
::getSingleton()
|
||||
->verifyfeature('zCeazVrMjVTQVVLcTdwSHNaSzMwTGNCdXRqTm9aYlEzVnI=')) {
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'processABE' :
|
||||
$G_PUBLISH = new Publisher();
|
||||
try {
|
||||
// Validations
|
||||
if (!isset($_REQUEST['APP_UID'])) {
|
||||
$_REQUEST['APP_UID'] = '';
|
||||
}
|
||||
|
||||
$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);
|
||||
$code = (is_array($result) ? $result['status_code'] : $result->status_code);
|
||||
$_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);
|
||||
|
||||
if ($code != 0) {
|
||||
throw new Exception('An error occurred while the application was being processed.<br /><br />
|
||||
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);
|
||||
|
||||
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 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
|
||||
$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>';
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showInfo', '', array('MESSAGE' => $message));
|
||||
} catch (Exception $error) {
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', array('MESSAGE' => $error->getMessage() . 'Please contact to your system administrator.'));
|
||||
}
|
||||
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showInfo', '', array('MESSAGE' => $message));
|
||||
} catch (Exception $error) {
|
||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', array('MESSAGE' => $error->getMessage() . 'Please contact to your system administrator.'));
|
||||
}
|
||||
|
||||
G::RenderPage('publish', 'blank');
|
||||
G::RenderPage('publish', 'blank');
|
||||
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
Reference in New Issue
Block a user