Exemplo n.º 1
0
    public function getEmailConfiguration ()
    {
        $emailServer = new \ProcessMaker\BusinessModel\EmailServer();

        $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;
        }
    }
Exemplo n.º 2
0
    /**

     * Upgrade this workspace database to the latest system schema

     *

     * @param bool $checkOnly only check if the upgrade is needed if true

     * @return array bool upgradeSchema for more information

     */

    public function upgradeDatabase ($onedb = false, $checkOnly = false)

    {

        G::LoadClass("patch");

        $this->initPropel( true );

        p11835::$dbAdapter = $this->dbAdapter;

        p11835::isApplicable();

        $systemSchema = System::getSystemSchema($this->dbAdapter);

        $systemSchemaRbac = System::getSystemSchemaRbac($this->dbAdapter);// get the Rbac Schema

        $this->upgradeSchema( $systemSchema );

        $this->upgradeSchema( $systemSchemaRbac, false, true, $onedb ); // perform Upgrade to Rbac

        $this->upgradeData();



        //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

            $arrayData = array();



            $emailSever = new \ProcessMaker\BusinessModel\EmailServer();



            $emailConfiguration = System::getEmailConfiguration();



            if (!empty($emailConfiguration)) {

                $arrayData["MESS_ENGINE"] = $emailConfiguration["MESS_ENGINE"];



                switch ($emailConfiguration["MESS_ENGINE"]) {

                    case "PHPMAILER":

                        $arrayData["MESS_SERVER"]              = $emailConfiguration["MESS_SERVER"];

                        $arrayData["MESS_PORT"]                = (int)($emailConfiguration["MESS_PORT"]);

                        $arrayData["MESS_RAUTH"]               = (is_numeric($emailConfiguration["MESS_RAUTH"]))? (int)($emailConfiguration["MESS_RAUTH"]) : (($emailConfiguration["MESS_RAUTH"] . "" == "true")? 1 : 0);

                        $arrayData["MESS_ACCOUNT"]             = $emailConfiguration["MESS_ACCOUNT"];

                        $arrayData["MESS_PASSWORD"]            = $emailConfiguration["MESS_PASSWORD"];

                        $arrayData["MESS_FROM_MAIL"]           = (isset($emailConfiguration["MESS_FROM_MAIL"]))? $emailConfiguration["MESS_FROM_MAIL"] : "";

                        $arrayData["MESS_FROM_NAME"]           = (isset($emailConfiguration["MESS_FROM_NAME"]))? $emailConfiguration["MESS_FROM_NAME"] : "";

                        $arrayData["SMTPSECURE"]               = $emailConfiguration["SMTPSecure"];

                        $arrayData["MESS_TRY_SEND_INMEDIATLY"] = (isset($emailConfiguration["MESS_TRY_SEND_INMEDIATLY"]) && ($emailConfiguration["MESS_TRY_SEND_INMEDIATLY"] . "" == "true" || $emailConfiguration["MESS_TRY_SEND_INMEDIATLY"] . "" == "1"))? 1 : 0;

                        $arrayData["MAIL_TO"]                  = isset($emailConfiguration["MAIL_TO"]) ? $emailConfiguration["MAIL_TO"] : '';

                        $arrayData["MESS_DEFAULT"]             = (isset($emailConfiguration["MESS_ENABLED"]) && $emailConfiguration["MESS_ENABLED"] . "" == "1")? 1 : 0;

                        break;

                    case "MAIL":

                        $arrayData["MESS_SERVER"]              = "";

                        $arrayData["MESS_FROM_MAIL"]           = (isset($emailConfiguration["MESS_FROM_MAIL"]))? $emailConfiguration["MESS_FROM_MAIL"] : "";

                        $arrayData["MESS_FROM_NAME"]           = (isset($emailConfiguration["MESS_FROM_NAME"]))? $emailConfiguration["MESS_FROM_NAME"] : "";

                        $arrayData["MESS_TRY_SEND_INMEDIATLY"] = (isset($emailConfiguration["MESS_TRY_SEND_INMEDIATLY"]) && ($emailConfiguration["MESS_TRY_SEND_INMEDIATLY"] . "" == "true" || $emailConfiguration["MESS_TRY_SEND_INMEDIATLY"] . "" == "1"))? 1 : 0;

                        $arrayData["MESS_ACCOUNT"]             = "";

                        $arrayData["MESS_PASSWORD"]            = "";

                        $arrayData["MAIL_TO"]                  = (isset($emailConfiguration["MAIL_TO"]))? $emailConfiguration["MAIL_TO"] : "";

                        $arrayData["MESS_DEFAULT"]             = (isset($emailConfiguration["MESS_ENABLED"]) && $emailConfiguration["MESS_ENABLED"] . "" == "1")? 1 : 0;

                        break;

                }



                $arrayData = $emailSever->create($arrayData);

            } else {

                /*----------------------------------********---------------------------------*/

                    $arrayData["MESS_ENGINE"]   = "MAIL";

                    $arrayData["MESS_SERVER"]   = "";

                    $arrayData["MESS_ACCOUNT"]  = "";

                    $arrayData["MESS_PASSWORD"] = "";

                    $arrayData["MAIL_TO"]       = "";

                    $arrayData["MESS_DEFAULT"]  = 1;



                    $arrayData = $emailSever->create2($arrayData);

                /*----------------------------------********---------------------------------*/

            }

        }



        p11835::execute();



        return true;

    }
Exemplo n.º 3
0
        $server = "";
        $port = "";
        $reqAuthentication = 0;
        $password = "";
        $smtpSecure = "";
        $cboEmailEngine = $_POST["cboEmailEngine"];
        $accountFrom = isset($_POST["accountFrom"]) ? $_POST["accountFrom"] : "";
        $fromName = $_POST["fromName"];
        $fromMail = $_POST["fromMail"];
        $sendTestMail = (int) $_POST["sendTestMail"];
        $mailTo = $sendTestMail == 1 ? $_POST["mailTo"] : "";
        $emailServerDefault = (int) $_POST["emailServerDefault"];
        if ($cboEmailEngine == "PHPMAILER") {
            $server = $_POST["server"];
            $port = (int) $_POST["port"];
            $reqAuthentication = (int) $_POST["reqAuthentication"];
            $password = $reqAuthentication == 1 ? $_POST["password"] : "";
            $smtpSecure = $_POST["smtpSecure"];
        }
        try {
            $arrayData = array("MESS_ENGINE" => $cboEmailEngine, "MESS_SERVER" => $server, "MESS_PORT" => $port, "MESS_RAUTH" => $reqAuthentication, "MESS_ACCOUNT" => $accountFrom, "MESS_PASSWORD" => $password, "MESS_FROM_MAIL" => $fromMail, "MESS_FROM_NAME" => $fromName, "SMTPSECURE" => $smtpSecure, "MESS_TRY_SEND_INMEDIATLY" => $sendTestMail, "MAIL_TO" => $mailTo, "MESS_DEFAULT" => $emailServerDefault);
            $emailSever = new \ProcessMaker\BusinessModel\EmailServer();
            $arrayEmailServerData = $emailSever->testConnection($arrayData);
            $response["data"] = $arrayEmailServerData;
        } catch (Exception $e) {
            $response["status"] = "ERROR";
            $response["message"] = $e->getMessage();
        }
        break;
}
echo G::json_encode($response);