Merge branch 'master' of bitbucket.org:colosa/processmaker into master-core

This commit is contained in:
Freddy Daniel Rojas Valda
2014-12-13 16:17:12 -04:00
13 changed files with 3419 additions and 52 deletions

View File

@@ -738,53 +738,53 @@ class XmlForm_Field
$aValues = explode( '|', $oOwner->fields[$this->pmconnection]->keys );
$i = 0;
if($aData == "" || count($aData['FIELDS']) < 1){
$message = G::LoadTranslation( 'ID_PMTABLE_NOT_FOUND' );
$message = G::LoadTranslation( 'ID_PMTABLE_NOT_FOUND' );
G::SendMessageText( $message, "WARNING" );
$sValue = "";
} else {
foreach ($aData['FIELDS'] as $aField) {
if ($aField['FLD_KEY'] == '1') {
// note added by gustavo cruz gustavo[at]colosa[dot]com
// this additional [if] checks if a case variable has been set
// in the keys attribute, so it can be parsed and replaced for
// their respective value.
if (preg_match( "/@#/", $aValues[$i] )) {
// check if a case are running in order to prevent that preview is
// erroneous rendered.
if (isset( $_SESSION['APPLICATION'] )) {
G::LoadClass( 'case' );
$oApp = new Cases();
if ($oApp->loadCase( $_SESSION['APPLICATION'] ) != null) {
$aFields = $oApp->loadCase( $_SESSION['APPLICATION'] );
$formVariable = substr( $aValues[$i], 2 );
if (isset( $aFields['APP_DATA'][$formVariable] )) {
$formVariableValue = $aFields['APP_DATA'][$formVariable];
$aKeys[$aField['FLD_NAME']] = (isset( $formVariableValue ) ? G::replaceDataField( $formVariableValue, $oOwner->values ) : '');
} else {
$aKeys[$aField['FLD_NAME']] = '';
}
} else {
$aKeys[$aField['FLD_NAME']] = '';
}
} else {
$aKeys[$aField['FLD_NAME']] = '';
}
} else {
$aKeys[$aField['FLD_NAME']] = (isset( $aValues[$i] ) ? G::replaceDataField( $aValues[$i], $oOwner->values ) : '');
}
$i ++;
}
foreach ($aData['FIELDS'] as $aField) {
if ($aField['FLD_KEY'] == '1') {
// note added by gustavo cruz gustavo[at]colosa[dot]com
// this additional [if] checks if a case variable has been set
// in the keys attribute, so it can be parsed and replaced for
// their respective value.
if (preg_match( "/@#/", $aValues[$i] )) {
// check if a case are running in order to prevent that preview is
// erroneous rendered.
if (isset( $_SESSION['APPLICATION'] )) {
G::LoadClass( 'case' );
$oApp = new Cases();
if ($oApp->loadCase( $_SESSION['APPLICATION'] ) != null) {
$aFields = $oApp->loadCase( $_SESSION['APPLICATION'] );
$formVariable = substr( $aValues[$i], 2 );
if (isset( $aFields['APP_DATA'][$formVariable] )) {
$formVariableValue = $aFields['APP_DATA'][$formVariable];
$aKeys[$aField['FLD_NAME']] = (isset( $formVariableValue ) ? G::replaceDataField( $formVariableValue, $oOwner->values ) : '');
} else {
$aKeys[$aField['FLD_NAME']] = '';
}
} else {
$aKeys[$aField['FLD_NAME']] = '';
}
} else {
$aKeys[$aField['FLD_NAME']] = '';
}
} else {
$aKeys[$aField['FLD_NAME']] = (isset( $aValues[$i] ) ? G::replaceDataField( $aValues[$i], $oOwner->values ) : '');
}
$i ++;
}
}
try {
$aData = $oAdditionalTables->getDataTable( $oOwner->fields[$this->pmconnection]->pmtable, $aKeys );
} catch (Exception $oError) {
$aData = array ();
}
if (isset( $aData[$this->pmfield] )) {
$sValue = $aData[$this->pmfield];
try {
$aData = $oAdditionalTables->getDataTable( $oOwner->fields[$this->pmconnection]->pmtable, $aKeys );
} catch (Exception $oError) {
$aData = array ();
}
if (isset( $aData[$this->pmfield] )) {
$sValue = $aData[$this->pmfield];
}
}
}
}
}
@@ -4493,17 +4493,50 @@ class XmlForm_Field_Date extends XmlForm_Field_SimpleText
{
$part1 = $sign * substr( $date, 0, strlen( $date ) - 1 );
$part2 = substr( $date, strlen( $date ) - 1 );
$year = (int)(date("Y"));
$month = (int)(date("m"));
$day = (int)(date("d"));
$osIsLinux = strtoupper(substr(PHP_OS, 0, 3)) != "WIN";
$checkYear = false;
switch ($part2) {
case 'd':
$res = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ), date( 'd' ) + $part1, date( 'Y' ) ) );
case "y":
$year = $year + $part1;
$res = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year));
$checkYear = true;
break;
case 'm':
$res = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ) + $part1, date( 'd' ), date( 'Y' ) ) );
case "m":
$month = $month + $part1;
$res = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year));
if ($month > 12) {
$year = $year + (int)($month / 12);
$checkYear = true;
}
break;
case 'y':
$res = date( 'Y-m-d', mktime( 0, 0, 0, date( 'm' ), date( 'd' ), date( 'Y' ) + $part1 ) );
case "d":
$res = date("Y-m-d", mktime(0, 0, 0, $month, $day + $part1, $year));
$dayAux = ($month * 31) - (31 - $day) + $part1;
if ($dayAux > 365) {
$year = $year + (int)($dayAux / 365);
$checkYear = true;
}
break;
}
if (!$osIsLinux && $checkYear && !preg_match("/^$year\-\d{2}\-\d{2}$/", $res)) {
$res = preg_replace("/^\d{4}(\-\d{2}\-\d{2})$/", "$year$1", $res);
}
return $res;
}

View File

@@ -311,6 +311,41 @@ function database_upgrade($command, $args) {
echo "> Error: ".CLI::error($e->getMessage()) . "\n";
}
}
//There records in table "EMAIL_SERVER"
$criteria = new Criteria("workflow");
$criteria->addSelectColumn(EmailServerPeer::MESS_UID);
$criteria->setOffset(0);
$criteria->setLimit(1);
$rsCriteria = EmailServerPeer::doSelectRS($criteria);
if (!$rsCriteria->next()) {
//Insert the first record
$emailConfiguration = System::getEmailConfiguration();
if (count($emailConfiguration) > 0) {
$arrayData = array();
$arrayData["MESS_ENGINE"] = $emailConfiguration["MESS_ENGINE"];
$arrayData["MESS_SERVER"] = $emailConfiguration["MESS_SERVER"];
$arrayData["MESS_PORT"] = (int)($emailConfiguration["MESS_PORT"]);
$arrayData["MESS_RAUTH"] = (int)($emailConfiguration["MESS_RAUTH"]);
$arrayData["MESS_ACCOUNT"] = $emailConfiguration["MESS_ACCOUNT"];
$arrayData["MESS_PASSWORD"] = $emailConfiguration["MESS_PASSWORD"];
$arrayData["MESS_FROM_MAIL"] = $emailConfiguration["MESS_FROM_MAIL"];
$arrayData["MESS_FROM_NAME"] = $emailConfiguration["MESS_FROM_NAME"];
$arrayData["SMTPSECURE"] = $emailConfiguration["SMTPSecure"];
$arrayData["MESS_TRY_SEND_INMEDIATLY"] = (int)($emailConfiguration["MESS_TRY_SEND_INMEDIATLY"]);
$arrayData["MAIL_TO"] = $emailConfiguration["MAIL_TO"];
$arrayData["MESS_DEFAULT"] = (isset($emailConfiguration["MESS_ENABLED"]) && $emailConfiguration["MESS_ENABLED"] . "" == "1")? 1 : 0;
$emailSever = new ProcessMaker\BusinessModel\EmailServer();
$emailSever->create($arrayData);
}
}
}
function delete_app_from_table($con, $tableName, $appUid, $col="APP_UID") {

View File

@@ -968,11 +968,41 @@ class System
public function getEmailConfiguration ()
{
G::LoadClass( 'configuration' );
$conf = new Configurations();
$config = $conf->load( 'Emails' );
$emailServer = new ProcessMaker\BusinessModel\EmailServer();
return $config;
$arrayEmailServerDefault = $emailServer->getEmailServerDefault();
if (count($arrayEmailServerDefault) > 0) {
$arrayDataEmailServerConfig = array(
"MESS_ENGINE" => $arrayEmailServerDefault["MESS_ENGINE"],
"MESS_SERVER" => $arrayEmailServerDefault["MESS_SERVER"],
"MESS_PORT" => (int)($arrayEmailServerDefault["MESS_PORT"]),
"MESS_RAUTH" => (int)($arrayEmailServerDefault["MESS_RAUTH"]),
"MESS_ACCOUNT" => $arrayEmailServerDefault["MESS_ACCOUNT"],
"MESS_PASSWORD" => $arrayEmailServerDefault["MESS_PASSWORD"],
"MESS_FROM_MAIL" => $arrayEmailServerDefault["MESS_FROM_MAIL"],
"MESS_FROM_NAME" => $arrayEmailServerDefault["MESS_FROM_NAME"],
"SMTPSecure" => $arrayEmailServerDefault["SMTPSECURE"],
"MESS_TRY_SEND_INMEDIATLY" => (int)($arrayEmailServerDefault["MESS_TRY_SEND_INMEDIATLY"]),
"MAIL_TO" => $arrayEmailServerDefault["MAIL_TO"],
"MESS_DEFAULT" => (int)($arrayEmailServerDefault["MESS_DEFAULT"]),
"MESS_ENABLED" => 1,
"MESS_BACKGROUND" => "",
"MESS_PASSWORD_HIDDEN" => "",
"MESS_EXECUTE_EVERY" => "",
"MESS_SEND_MAX" => ""
);
//Return
return $arrayDataEmailServerConfig;
} else {
G::LoadClass("configuration");
$conf = new Configurations();
$config = $conf->load("Emails");
return $config;
}
}
public function getSkingList ()

View File

@@ -0,0 +1,5 @@
<?php
class EmailServer extends BaseEmailServer
{
}

View File

@@ -0,0 +1,5 @@
<?php
class EmailServerPeer extends BaseEmailServerPeer
{
}

View File

@@ -0,0 +1,96 @@
<?php
require_once 'propel/map/MapBuilder.php';
include_once 'creole/CreoleTypes.php';
/**
* This class adds structure of 'EMAIL_SERVER' table to 'workflow' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package workflow.classes.model.map
*/
class EmailServerMapBuilder
{
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'classes.model.map.EmailServerMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('workflow');
$tMap = $this->dbMap->addTable('EMAIL_SERVER');
$tMap->setPhpName('EmailServer');
$tMap->setUseIdGenerator(false);
$tMap->addPrimaryKey('MESS_UID', 'MessUid', 'string', CreoleTypes::VARCHAR, true, 32);
$tMap->addColumn('MESS_ENGINE', 'MessEngine', 'string', CreoleTypes::VARCHAR, true, 256);
$tMap->addColumn('MESS_SERVER', 'MessServer', 'string', CreoleTypes::VARCHAR, true, 256);
$tMap->addColumn('MESS_PORT', 'MessPort', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addColumn('MESS_RAUTH', 'MessRauth', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addColumn('MESS_ACCOUNT', 'MessAccount', 'string', CreoleTypes::VARCHAR, true, 256);
$tMap->addColumn('MESS_PASSWORD', 'MessPassword', 'string', CreoleTypes::VARCHAR, true, 256);
$tMap->addColumn('MESS_FROM_MAIL', 'MessFromMail', 'string', CreoleTypes::VARCHAR, true, 256);
$tMap->addColumn('MESS_FROM_NAME', 'MessFromName', 'string', CreoleTypes::VARCHAR, true, 256);
$tMap->addColumn('SMTPSECURE', 'Smtpsecure', 'string', CreoleTypes::VARCHAR, true, 3);
$tMap->addColumn('MESS_TRY_SEND_INMEDIATLY', 'MessTrySendInmediatly', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addColumn('MAIL_TO', 'MailTo', 'string', CreoleTypes::VARCHAR, true, 256);
$tMap->addColumn('MESS_DEFAULT', 'MessDefault', 'int', CreoleTypes::INTEGER, true, null);
} // doBuild()
} // EmailServerMapBuilder

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -4188,5 +4188,32 @@
<column name="MD_TYPE" type="VARCHAR" size="32" default=""/>
<column name="MD_NAME" type="VARCHAR" size="255" default=""/>
</table>
<table name="EMAIL_SERVER">
<vendor type="mysql">
<parameter name="Name" value="EMAIL_SERVER" />
<parameter name="Engine" value="InnoDB" />
<parameter name="Version" value="10" />
<parameter name="Row_format" value="Dynamic" />
<parameter name="Data_free" value="0" />
<parameter name="Auto_increment" value="" />
<parameter name="Check_time" value="" />
<parameter name="Collation" value="utf8_general_ci" />
<parameter name="Checksum" value="" />
<parameter name="Create_options" value="" />
</vendor>
<column name="MESS_UID" type="VARCHAR" size="32" required="true" primaryKey="true" default="" />
<column name="MESS_ENGINE" type="VARCHAR" size="256" required="true" default="" />
<column name="MESS_SERVER" type="VARCHAR" size="256" required="true" default="" />
<column name="MESS_PORT" type="INTEGER" required="true" default="0" />
<column name="MESS_RAUTH" type="INTEGER" required="true" default="0" />
<column name="MESS_ACCOUNT" type="VARCHAR" size="256" required="true" default="" />
<column name="MESS_PASSWORD" type="VARCHAR" size="256" required="true" default="" />
<column name="MESS_FROM_MAIL" type="VARCHAR" size="256" required="true" default="" />
<column name="MESS_FROM_NAME" type="VARCHAR" size="256" required="true" default="" />
<column name="SMTPSECURE" type="VARCHAR" size="3" required="true" default="" />
<column name="MESS_TRY_SEND_INMEDIATLY" type="INTEGER" required="true" default="0" />
<column name="MAIL_TO" type="VARCHAR" size="256" required="true" default="" />
<column name="MESS_DEFAULT" type="INTEGER" required="true" default="0" />
</table>
</database>

View File

@@ -2412,3 +2412,28 @@ CREATE TABLE `MESSAGE_DETAIL`
)ENGINE=InnoDB ;
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;
#-----------------------------------------------------------------------------
#-- TABLE: EMAIL_SERVER
#-----------------------------------------------------------------------------
DROP TABLE IF EXISTS `EMAIL_SERVER`;
CREATE TABLE `EMAIL_SERVER`
(
`MESS_UID` VARCHAR(32) default '' NOT NULL,
`MESS_ENGINE` VARCHAR(256) default '' NOT NULL,
`MESS_SERVER` VARCHAR(256) default '' NOT NULL,
`MESS_PORT` INTEGER default 0 NOT NULL,
`MESS_RAUTH` INTEGER default 0 NOT NULL,
`MESS_ACCOUNT` VARCHAR(256) default '' NOT NULL,
`MESS_PASSWORD` VARCHAR(256) default '' NOT NULL,
`MESS_FROM_MAIL` VARCHAR(256) default '' NOT NULL,
`MESS_FROM_NAME` VARCHAR(256) default '' NOT NULL,
`SMTPSECURE` VARCHAR(3) default 'NO' NOT NULL,
`MESS_TRY_SEND_INMEDIATLY` INTEGER default 0 NOT NULL,
`MAIL_TO` VARCHAR(256) default '' NOT NULL,
`MESS_DEFAULT` INTEGER default 0 NOT NULL,
PRIMARY KEY (`MESS_UID`)
)ENGINE=InnoDB DEFAULT CHARSET='utf8';

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,158 @@
<?php
namespace ProcessMaker\Services\Api;
use \ProcessMaker\Services\Api;
use \Luracast\Restler\RestException;
/**
* EmailServer Api Controller
*
* @protected
*/
class EmailServer extends Api
{
private $emailServer;
/**
* Constructor of the class
*
* return void
*/
public function __construct()
{
try {
$this->emailServer = new \ProcessMaker\BusinessModel\EmailServer();
$this->emailServer->setFormatFieldNameInUppercase(false);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url GET
*
* @param string $filter
* @param int $start
* @param int $limit
*
*/
public function index($filter = null, $start = null, $limit = null)
{
try {
$arrayAux = $this->emailServer->getEmailServers(array("filter" => $filter), null, null, $start, $limit);
$response = $arrayAux["data"];
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url GET /:mess_uid
*
* @param string $mess_uid {@min 32}{@max 32}
*/
public function doGet($mess_uid)
{
try {
$response = $this->emailServer->getEmailServer($mess_uid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url GET /paged
*
* @param string $filter
* @param int $start
* @param int $limit
*/
public function doGetPaged($filter = null, $start = null, $limit = null)
{
try {
$response = $this->emailServer->getEmailServers(array("filter" => $filter), null, null, $start, $limit);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url POST /test-connection
*
* @param array $request_data
*/
public function doPostTestConnection(array $request_data)
{
try {
$arrayData = $this->emailServer->testConnection($request_data);
$response = $arrayData;
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url POST
*
* @param array $request_data
*
* @status 201
*/
public function doPost(array $request_data)
{
try {
$arrayData = $this->emailServer->create($request_data);
$response = $arrayData;
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url PUT /:mess_uid
*
* @param string $mess_uid {@min 32}{@max 32}
* @param array $request_data
*
* @status 200
*/
public function doPut($mess_uid, array $request_data)
{
try {
$arrayData = $this->emailServer->update($mess_uid, $request_data);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @url DELETE /:mess_uid
*
* @param string $mess_uid {@min 32}{@max 32}
*
* @status 200
*/
public function doDelete($mess_uid)
{
try {
$this->emailServer->delete($mess_uid);
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
}

View File

@@ -87,4 +87,10 @@ debug = 1
file = "ProcessMaker\Services\Api\File"
[alias: files]
file = "ProcessMaker\Services\Api\Files"
file = "ProcessMaker\Services\Api\Files"
[alias: email]
email = "ProcessMaker\Services\Api\EmailServer"
[alias: emails]
email = "ProcessMaker\Services\Api\EmailServer"