PM 940 "ProcessMaker-MA "Email Server (endpoints)"" SOLVED

> ProcessMaker-MA "Email Server (endpoints)"
  - Se han implementado los siguientes Endpoints:
       GET    /api/1.0/{workspace}/email/paged?filter={filter}&start={start}&limit={limit}
       GET    /api/1.0/{workspace}/emails?filter={filter}&start={start}&limit={limit}
       GET    /api/1.0/{workspace}/email/{mess_uid}
       POST   /api/1.0/{workspace}/email
       POST   /api/1.0/{workspace}/email/test-connection
       PUT    /api/1.0/{workspace}/email/{mess_uid}
       DELETE /api/1.0/{workspace}/email/{mess_uid}

  - Se esta creando un 1er registro en la tabla EMAIL_SERVER, esto al ejecutar el comando "./processmaker upgrade".
  - El metodo "System::getEmailConfiguration()" recupera el EMAIL_SERVER por default, caso contrario trabajara como lo
    hacia anteriormente.
This commit is contained in:
Luis Fernando Saisa Lopez
2014-12-09 17:25:39 -04:00
parent 45a722fe4c
commit 018c963d60
12 changed files with 3336 additions and 5 deletions

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,39 @@ 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) {
//Return
return $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" => ""
);
} 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

@@ -4176,5 +4176,33 @@
<column name="TYPE" type="VARCHAR" size="255" required="true" primaryKey="true" default=""/>
<column name="TYP_UID" type="VARCHAR" size="32" required="true" 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

@@ -2383,3 +2383,26 @@ CREATE TABLE `LIST_UNASSIGNED_GROUP`
# 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

@@ -86,4 +86,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"