First take to migration of classes into the ProcessMaker Core
This commit is contained in:
118
workflow/engine/classes/class.ActionsByEmailFeature.php
Normal file
118
workflow/engine/classes/class.ActionsByEmailFeature.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* Description of ActionsByEmailFeature
|
||||
*
|
||||
*/
|
||||
|
||||
if (!class_exists('enterprisePlugin')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Load dependences
|
||||
G::LoadClass('feature');
|
||||
|
||||
class ActionsByEmailFeature extends PMFeature
|
||||
{
|
||||
protected $triggers;
|
||||
protected $classInstance;
|
||||
|
||||
public function __construct($namespace, $filename = null)
|
||||
{
|
||||
$result = parent::__construct($namespace, $filename);
|
||||
$this->sFriendlyName = 'Actions By Email';
|
||||
$this->sDescription = 'Actions by Email using variables as multiple choice actions delivered by email';
|
||||
$this->sFeatureFolder = 'ActionsByEmail';
|
||||
$this->classInstance = array('filename' => 'class.actionsByEmail.php', 'classname' => 'actionsByEmailClass');
|
||||
$this->sSetupPage = '';
|
||||
$this->iVersion = self::getFeatureVersion($namespace);
|
||||
$this->aWorkspaces = null;
|
||||
$this->aDependences = array(array('sClassName' => 'enterprise'), array('sClassName' => 'pmLicenseManager'));
|
||||
$this->triggers = array();
|
||||
// $this->bPrivate = parent::registerEE($this->sFeatureFolder, $this->iVersion);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function setup()
|
||||
{
|
||||
try {
|
||||
if (!defined('PM_CREATE_NEW_DELEGATION')) {
|
||||
throw new Exception('It might be using a version of ProcessMaker which is not totally compatible with this plugin, the minimun required version is 2.0.37');
|
||||
}
|
||||
$this->registerTrigger(PM_CREATE_NEW_DELEGATION, 'sendActionsByEmail');
|
||||
} catch (Exception $error) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function executeTriggers($triggerId, $data)
|
||||
{
|
||||
if (PMLicensedFeatures
|
||||
::getSingleton()
|
||||
->verifyfeature('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=')) {
|
||||
$method = $this->triggers[$triggerId];
|
||||
require_once PATH_FEATURES . $this->sFeatureFolder . DS . $this->classInstance['filename'];
|
||||
$actionsByEmail = new $this->classInstance['classname']();
|
||||
$actionsByEmail->$method($data);
|
||||
}
|
||||
}
|
||||
|
||||
public function registerTrigger($triggerId, $method)
|
||||
{
|
||||
$this->triggers[$triggerId] = $method;
|
||||
}
|
||||
|
||||
|
||||
public function install()
|
||||
{
|
||||
$this->checkTables();
|
||||
}
|
||||
|
||||
public function enable()
|
||||
{
|
||||
$this->checkTables();
|
||||
}
|
||||
|
||||
public function disable()
|
||||
{
|
||||
// Nothing to do for now
|
||||
}
|
||||
|
||||
/**
|
||||
* This method get the version of this plugin, when the plugin is packaged in the tar.gz
|
||||
* the file "version" in the plugin folder has this information for development purposes,
|
||||
* we calculate the version using git commands, because the repository is in GIT
|
||||
*
|
||||
* @param String $namespace The namespace of the plugin
|
||||
* @return String $version
|
||||
*/
|
||||
private static function getFeatureVersion($namespace)
|
||||
{
|
||||
return "2.0.20";
|
||||
}
|
||||
|
||||
public function checkTables()
|
||||
{
|
||||
$con = Propel::getConnection('workflow');
|
||||
$stmt = $con->createStatement();
|
||||
// setting the path of the sql schema files
|
||||
$filenameSql = PATH_PLUGINS . 'actionsByEmail/data/schema.sql';
|
||||
|
||||
// checking the existence of the schema file
|
||||
if (!file_exists($filenameSql)) {
|
||||
throw new Exception("File data/schema.sql doesn't exists");
|
||||
}
|
||||
|
||||
// exploding the sql query in an array
|
||||
$sql = explode(';', file_get_contents($filenameSql));
|
||||
|
||||
$stmt->executeQuery('SET FOREIGN_KEY_CHECKS = 0;');
|
||||
|
||||
// executing each query stored in the array
|
||||
foreach ($sql as $sentence) {
|
||||
if (trim($sentence) != '') {
|
||||
$stmt->executeQuery($sentence);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
239
workflow/engine/classes/class.actionsByEmail.php
Normal file
239
workflow/engine/classes/class.actionsByEmail.php
Normal file
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
|
||||
|
||||
class actionsByEmailClass extends PMPlugin
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
set_include_path(PATH_FEATURES . 'ActionsByEmail' . PATH_SEPARATOR . get_include_path());
|
||||
}
|
||||
|
||||
public function setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getFieldsForPageSetup()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function updateFieldsForPageSetup()
|
||||
{
|
||||
}
|
||||
|
||||
public function sendActionsByEmail($data)
|
||||
{
|
||||
try {
|
||||
// Validations
|
||||
if (!is_object($data)) {
|
||||
throw new Exception('The parameter $data is null.');
|
||||
}
|
||||
|
||||
if (!isset($data->TAS_UID)) {
|
||||
throw new Exception('The parameter $data->TAS_UID is null.');
|
||||
}
|
||||
|
||||
if (!isset($data->APP_UID)) {
|
||||
throw new Exception('The parameter $data->APP_UID is null.');
|
||||
}
|
||||
|
||||
if (!isset($data->DEL_INDEX)) {
|
||||
throw new Exception('The parameter $data->DEL_INDEX is null.');
|
||||
}
|
||||
|
||||
if ($data->TAS_UID == '') {
|
||||
throw new Exception('The parameter $data->TAS_UID is empty.');
|
||||
}
|
||||
|
||||
if ($data->APP_UID == '') {
|
||||
throw new Exception('The parameter $data->APP_UID is empty.');
|
||||
}
|
||||
|
||||
if ($data->DEL_INDEX == '') {
|
||||
throw new Exception('The parameter $data->DEL_INDEX is empty.');
|
||||
}
|
||||
|
||||
G::LoadClass('pmFunctions');
|
||||
|
||||
$emailSetup = getEmailConfiguration();
|
||||
|
||||
if (!empty($emailSetup)) {
|
||||
require_once 'classes/model/AbeConfiguration.php';
|
||||
G::LoadClass('case');
|
||||
|
||||
$cases = new Cases();
|
||||
$caseFields = $cases->loadCase($data->APP_UID);
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(AbeConfigurationPeer::PRO_UID, $caseFields['PRO_UID']);
|
||||
$criteria->add(AbeConfigurationPeer::TAS_UID, $data->TAS_UID);
|
||||
$result = AbeConfigurationPeer::doSelectRS($criteria);
|
||||
$result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$result->next();
|
||||
if ($configuration = $result->getRow()) {
|
||||
$configuration['ABE_EMAIL_FIELD'] = str_replace('@@', '', $configuration['ABE_EMAIL_FIELD']);
|
||||
if ($configuration['ABE_EMAIL_FIELD'] != '' && isset($caseFields['APP_DATA'][$configuration['ABE_EMAIL_FIELD']])) {
|
||||
$email = trim($caseFields['APP_DATA'][$configuration['ABE_EMAIL_FIELD']]);
|
||||
} else {
|
||||
require_once 'classes/model/Users.php';
|
||||
|
||||
$userInstance = new Users();
|
||||
$userInfo = $userInstance->getAllInformation($data->USR_UID);
|
||||
$email = $userInfo['mail'];
|
||||
}
|
||||
|
||||
if ($email != '') {
|
||||
$subject = $caseFields['APP_TITLE'];
|
||||
|
||||
// Create
|
||||
require_once 'classes/model/AbeRequests.php';
|
||||
|
||||
$abeRequest = array();
|
||||
$abeRequest['ABE_REQ_UID'] = '';
|
||||
$abeRequest['ABE_UID'] = $configuration['ABE_UID'];
|
||||
$abeRequest['APP_UID'] = $data->APP_UID;
|
||||
$abeRequest['DEL_INDEX'] = $data->DEL_INDEX;
|
||||
$abeRequest['ABE_REQ_SENT_TO'] = $email;
|
||||
$abeRequest['ABE_REQ_SUBJECT'] = $subject;
|
||||
$abeRequest['ABE_REQ_BODY'] = '';
|
||||
$abeRequest['ABE_REQ_ANSWERED'] = 0;
|
||||
$abeRequest['ABE_REQ_STATUS'] = 'PENDING';
|
||||
|
||||
try {
|
||||
$abeRequestsInstance = new AbeRequests();
|
||||
$abeRequest['ABE_REQ_UID'] = $abeRequestsInstance->createOrUpdate($abeRequest);
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
|
||||
if ($configuration['ABE_TYPE'] != '') {
|
||||
// Email
|
||||
$_SESSION['CURRENT_DYN_UID'] = $configuration['DYN_UID'];
|
||||
|
||||
$scriptCode = '';
|
||||
// foreach ($dynaform->fields as $fieldName => $field) {
|
||||
// if ($field->type == 'submit') {
|
||||
// unset($dynaform->fields[$fieldName]);
|
||||
// }
|
||||
// }
|
||||
|
||||
$__ABE__ = '';
|
||||
$link = (G::is_https() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/ActionsByEmail';
|
||||
|
||||
switch ($configuration['ABE_TYPE']) {
|
||||
case 'LINK':
|
||||
// $__ABE__ .= $dynaform->render(PATH_FEATURES . 'actionsByEmail/xmlform.html', $scriptCode) . '<br />';
|
||||
$__ABE__ .= '<a href="' . $link . 'dataForm?APP_UID=' . G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY) . '&DYN_UID=' . G::encrypt($configuration['DYN_UID'], URL_KEY) . '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank">Please complete this form</a>';
|
||||
break;
|
||||
// coment
|
||||
case 'FIELD':
|
||||
$variableService = new \ProcessMaker\Services\Api\Project\Variable();
|
||||
$variables = $variableService->doGetVariables($caseFields['PRO_UID']);
|
||||
$field = new stdClass();
|
||||
$field->label = 'Test';
|
||||
$field->type = 'dropdown';
|
||||
$field->options = array();
|
||||
$actionField = str_replace('@@', '', $configuration['ABE_ACTION_FIELD']);
|
||||
foreach ($variables as $variable) {
|
||||
if ($variable['var_name'] == $actionField) {
|
||||
$field->label = $variable['var_name'];
|
||||
$field->type = 'dropdown';
|
||||
$values = json_decode($variable['var_accepted_values']);
|
||||
foreach ($values as $value) {
|
||||
$field->options[$value->keyValue] = $value->value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$__ABE__ .= '<strong>' . $field->label . '</strong><br /><table align="left" border="0"><tr>';
|
||||
|
||||
switch ($field->type) {
|
||||
case 'dropdown':
|
||||
case 'radiogroup':
|
||||
$index = 1;
|
||||
$__ABE__.='<br /><td><table align="left" cellpadding="2"><tr>';
|
||||
foreach ($field->options as $optValue => $optName) {
|
||||
$__ABE__ .= '<td align="center"><a style="text-decoration: none; color: #000; background-color: #E5E5E5; ';
|
||||
$__ABE__ .= 'filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#EFEFEF, endColorstr=#BCBCBC); ';
|
||||
$__ABE__ .= 'background-image: -webkit-gradient(linear, left top, left bottom, from(#EFEFEF), #BCBCBC); ';
|
||||
$__ABE__ .= 'background-image: -webkit-linear-gradient(top, #EFEFEF, #BCBCBC); ';
|
||||
$__ABE__ .= 'background-image: -moz-linear-gradient(top, #EFEFEF, #BCBCBC); background-image: -ms-linear-gradient(top, #EFEFEF, #BCBCBC); ';
|
||||
$__ABE__ .= 'background-image: -o-linear-gradient(top, #EFEFEF, #BCBCBC); border: 1px solid #AAAAAA; ';
|
||||
$__ABE__ .= 'border-radius: 4px; -moz-border-radius: 4px; -webkit-border-radius: 4px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); ';
|
||||
$__ABE__ .= 'font-family: Arial,serif; font-size: 9pt; font-weight: 400; line-height: 14px; margin: 2px 0; padding: 2px 7px; ';
|
||||
$__ABE__ .= 'text-decoration: none; text-transform: capitalize;" href="' .urldecode(urlencode($link)). '?action=processABE&APP_UID=';
|
||||
$__ABE__ .= G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY);
|
||||
$__ABE__ .= '&FIELD=' . G::encrypt($configuration['ABE_ACTION_FIELD'], URL_KEY) . '&VALUE=' . G::encrypt($optValue, URL_KEY);
|
||||
$__ABE__ .= '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank" >' . $optName;
|
||||
$__ABE__ .= '</a></td>' . (($index % 5 == 0) ? '</tr><tr>' : ' ');
|
||||
$index++;
|
||||
}
|
||||
|
||||
$__ABE__.='</tr></table></td>';
|
||||
break;
|
||||
case 'yesno':
|
||||
$__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . urlencode(G::encrypt($data->APP_UID, URL_KEY)) . '&DEL_INDEX=' . urlencode(G::encrypt($data->DEL_INDEX, URL_KEY)). '&FIELD=' . urlencode(G::encrypt($configuration['ABE_ACTION_FIELD'], URL_KEY)) . '&VALUE=' . urlencode(G::encrypt(1, URL_KEY)) . '&ABER=' . urlencode(G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY)) . '" target="_blank">' . G::LoadTranslation('ID_YES_VALUE') . '</a></td>';
|
||||
$__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . urlencode(G::encrypt($data->APP_UID, URL_KEY)) . '&DEL_INDEX=' . urlencode(G::encrypt($data->DEL_INDEX, URL_KEY)) . '&FIELD=' . urlencode(G::encrypt($configuration['ABE_ACTION_FIELD'], URL_KEY)) . '&VALUE=' . urlencode(G::encrypt(0, URL_KEY)) . '&ABER=' . urlencode(G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY)) . '" target="_blank">' . G::LoadTranslation('ID_NO_VALUE') . '</a></td>';
|
||||
break;
|
||||
case 'checkbox':
|
||||
$__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY) . '&FIELD=' . G::encrypt($configuration['ABE_ACTION_FIELD'], URL_KEY) . '&VALUE=' . G::encrypt($field->value, URL_KEY) . '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank">Check</a></td>';
|
||||
$__ABE__ .= '<td align="center"><a href="' . $link . 'dataField?APP_UID=' . G::encrypt($data->APP_UID, URL_KEY) . '&DEL_INDEX=' . G::encrypt($data->DEL_INDEX, URL_KEY) . '&FIELD=' . G::encrypt($configuration['ABE_ACTION_FIELD'], URL_KEY) . '&VALUE=' . G::encrypt($field->value, URL_KEY) . '&ABER=' . G::encrypt($abeRequest['ABE_REQ_UID'], URL_KEY) . '" target="_blank">Uncheck</a></td>';
|
||||
break;
|
||||
}
|
||||
$__ABE__ .= '</tr></table>';
|
||||
break;
|
||||
}
|
||||
|
||||
$__ABE__ = preg_replace('/\<img src=\"\/js\/maborak\/core\/images\/(.+?)\>/', '' , $__ABE__);
|
||||
$__ABE__ = preg_replace('/\<input\b[^>]*\/>/', '' , $__ABE__);
|
||||
$__ABE__ = preg_replace('/<select\b[^>]*>(.*?)<\/select>/is', "", $__ABE__);
|
||||
$__ABE__ = preg_replace('/align=\"center\"/', '' , $__ABE__);
|
||||
$__ABE__ = preg_replace('/class="tableGrid_view" /', 'class="tableGrid_view" width="100%" ', $__ABE__);
|
||||
$caseFields['APP_DATA']['__ABE__'] = $__ABE__;
|
||||
|
||||
G::LoadClass("Users");
|
||||
|
||||
$user = new Users();
|
||||
$userDetails = $user->loadDetails($data->USR_UID);
|
||||
$emailFrom = $userDetails["USR_EMAIL"];
|
||||
|
||||
G::LoadClass('wsBase');
|
||||
|
||||
$wsBaseInstance = new wsBase();
|
||||
$result = $wsBaseInstance->sendMessage($data->APP_UID,
|
||||
$emailFrom,
|
||||
$email,
|
||||
'',
|
||||
'',
|
||||
$subject,
|
||||
$configuration['ABE_TEMPLATE'],
|
||||
$caseFields['APP_DATA'],
|
||||
'');
|
||||
$abeRequest['ABE_REQ_STATUS'] = ($result->status_code == 0 ? 'SENT' : 'ERROR');
|
||||
|
||||
$body = '';
|
||||
$messageSent = executeQuery('SELECT `APP_MSG_BODY` FROM `APP_MESSAGE` ORDER BY `APP_MSG_SEND_DATE` DESC LIMIT 1');
|
||||
|
||||
if (!empty($messageSent) && is_array($messageSent)) {
|
||||
$body = $messageSent[1]['APP_MSG_BODY'];
|
||||
}
|
||||
|
||||
$abeRequest['ABE_REQ_BODY'] = $body;
|
||||
|
||||
// Update
|
||||
try {
|
||||
$abeRequestsInstance = new AbeRequests();
|
||||
$abeRequestsInstance->createOrUpdate($abeRequest);
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception $error) {
|
||||
throw $error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/*----------------------------------********---------------------------------*/
|
||||
/*----------------------------------********---------------------------------*/
|
||||
/**
|
||||
* class.featureRegistry.php
|
||||
*
|
||||
|
||||
@@ -174,9 +174,18 @@ class AppDelegation extends BaseAppDelegation
|
||||
$data->DEL_INDEX = $delIndex;
|
||||
$data->USR_UID = $sUsrUid;
|
||||
$oPluginRegistry = &PMPluginRegistry::getSingleton();
|
||||
$featureRegistry = &PMFeatureRegistry::getSingleton();
|
||||
$oPluginRegistry->executeTriggers( PM_CREATE_NEW_DELEGATION, $data );
|
||||
$featureRegistry->executeTriggers( PM_CREATE_NEW_DELEGATION, $data );
|
||||
$oPluginRegistry->executeTriggers(PM_CREATE_NEW_DELEGATION, $data);
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
// this section evaluates the actions by email trigger execution
|
||||
if (PMLicensedFeatures
|
||||
::getSingleton()
|
||||
->verifyfeature('zLhSk5TeEQrNFI2RXFEVktyUGpnczV1WEJNWVp6cjYxbTU3R29mVXVZNWhZQT0=')) {
|
||||
G::LoadClass('ActionsByEmailFeature');
|
||||
$actionsByEmail = new ActionsByEmailFeature('actionsByEmail');
|
||||
$actionsByEmail->executeTriggers(PM_CREATE_NEW_DELEGATION, $data);
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
}
|
||||
|
||||
return $delIndex;
|
||||
|
||||
@@ -196,9 +196,6 @@ define( 'PATH_METHODS', PATH_CORE . 'methods' . PATH_SEP );
|
||||
define( 'PATH_XMLFORM', PATH_CORE . 'xmlform' . PATH_SEP );
|
||||
define( 'PATH_CONFIG', PATH_CORE . 'config' . PATH_SEP );
|
||||
define( 'PATH_PLUGINS', PATH_CORE . 'plugins' . PATH_SEP );
|
||||
/*----------------------------------********---------------------------------*/
|
||||
define( 'PATH_FEATURES', PATH_CORE . 'Features' . PATH_SEP );
|
||||
/*----------------------------------********---------------------------------*/
|
||||
define( 'PATH_HTMLMAIL', PATH_CORE . 'html_templates' . PATH_SEP );
|
||||
define( 'PATH_TPL', PATH_CORE . 'templates' . PATH_SEP );
|
||||
define( 'PATH_TEST', PATH_CORE . 'test' . PATH_SEP );
|
||||
@@ -630,9 +627,6 @@ if (file_exists( $sSerializedFile )) {
|
||||
} else{
|
||||
$oPluginRegistry = PMPluginRegistry::getSingleton();
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$featureRegistry =& PMFeatureRegistry::getSingleton();
|
||||
/*----------------------------------********---------------------------------*/
|
||||
// setup propel definitions and logging
|
||||
//changed to autoloader
|
||||
//require_once ("propel/Propel.php");
|
||||
@@ -697,9 +691,6 @@ if (SYS_LANG != 'en' && ! is_file( PATH_LANGUAGECONT . 'translation.' . SYS_LANG
|
||||
|
||||
// Setup plugins
|
||||
$oPluginRegistry->setupPlugins(); //get and setup enabled plugins
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$featureRegistry->setupFeatures(); //get and setup enabled features
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$avoidChangedWorkspaceValidation = false;
|
||||
|
||||
// Load custom Classes and Model from Plugins.
|
||||
|
||||
Reference in New Issue
Block a user