Example #1
0
function putTypeView()
{
    require_once 'classes/model/Configuration.php';
    $oConfiguration = new Configuration();
    $oCriteria = new Criteria('workflow');
    $oCriteria->add(ConfigurationPeer::CFG_UID, 'StartNewCase');
    $oCriteria->add(ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED']);
    if (ConfigurationPeer::doCount($oCriteria)) {
        $conf = ConfigurationPeer::doSelect($oCriteria);
        return $conf[0]->getCfgValue();
    } else {
        return 'dropdown';
    }
}
Example #2
0
$oCriteria = new Criteria ( 'workflow' );

$oCriteria->add(ConfigurationPeer::CFG_UID, 'getStarted');

$oCriteria->add(ConfigurationPeer::OBJ_UID, '');

$oCriteria->add(ConfigurationPeer::CFG_VALUE, '1');

$oCriteria->add(ConfigurationPeer::PRO_UID, '');

$oCriteria->add(ConfigurationPeer::USR_UID, '');

$oCriteria->add(ConfigurationPeer::APP_UID, '');

$flagGettingStarted =  ConfigurationPeer::doCount($oCriteria);

if ($flagGettingStarted == 0) {

    $oHeadPublisher->addScriptCode('var flagGettingStarted = 1;');

} else {

    $oHeadPublisher->addScriptCode('var flagGettingStarted = 0;');

}



$dummy = '';
            $aFields = get_object_vars($oProcesses->ws_processGetData($oData->pro_uid));

            $aFields['description'] = nl2br($aFields['description']);
            $aFields['installSteps'] = nl2br($aFields['installSteps']);
            switch ($aFields['privacy']) {
                case 'FREE':
                    $aFields['link_label'] = G::LoadTranslation('ID_DOWNLOAD');
                    $aFields['link_href'] = '../processes/downloadPML?id=' . $oData->pro_uid . '&s=' . $sessionId;
                    break;
                case 'PUBLIC':
                    require_once 'classes/model/Configuration.php';
                    $oCriteria = new Criteria('workflow');
                    $oCriteria->addSelectColumn(ConfigurationPeer::CFG_VALUE);
                    $oCriteria->add(ConfigurationPeer::CFG_UID, 'REGISTER_INFORMATION');
                    $oCriteria->add(ConfigurationPeer::USR_UID, $_SESSION['USER_LOGGED']);
                    if (ConfigurationPeer::doCount($oCriteria) > 0) {
                        $oDataset = ConfigurationPeer::doSelectRS($oCriteria);
                        $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                        $oDataset->next();
                        $aRow = $oDataset->getRow();
                        $aRI = unserialize($aRow['CFG_VALUE']);
                        try {
                            if ($oProcesses->ws_open($aRI['u'], $aRI['p']) == 1) {
                                $bExists = true;
                            } else {
                                $bExists = false;
                            }
                        } catch (Exception $oException) {
                            $bExists = false;
                        }
                        if ($bExists) {
Example #4
0
 public function sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients, $sFrom = "")
 {
     try {
         require_once 'classes/model/Configuration.php';
         $oConfiguration = new Configuration();
         $sDelimiter = DBAdapter::getStringDelimiter();
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails');
         $oCriteria->add(ConfigurationPeer::OBJ_UID, '');
         $oCriteria->add(ConfigurationPeer::PRO_UID, '');
         $oCriteria->add(ConfigurationPeer::USR_UID, '');
         $oCriteria->add(ConfigurationPeer::APP_UID, '');
         if (ConfigurationPeer::doCount($oCriteria) == 0) {
             $oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => ''));
             $aConfiguration = array();
         } else {
             $aConfiguration = $oConfiguration->load('Emails', '', '', '', '');
             if ($aConfiguration['CFG_VALUE'] != '') {
                 $aConfiguration = unserialize($aConfiguration['CFG_VALUE']);
                 $passwd = $aConfiguration['MESS_PASSWORD'];
                 $passwdDec = G::decrypt($passwd, 'EMAILENCRYPT');
                 $auxPass = explode('hash:', $passwdDec);
                 if (count($auxPass) > 1) {
                     if (count($auxPass) == 2) {
                         $passwd = $auxPass[1];
                     } else {
                         array_shift($auxPass);
                         $passwd = implode('', $auxPass);
                     }
                 }
                 $aConfiguration['MESS_PASSWORD'] = $passwd;
             } else {
                 $aConfiguration = array();
             }
         }
         if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') {
             return false;
         }
         $oUser = new Users();
         $aUser = $oUser->load($usrUid);
         $authorName = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>';
         G::LoadClass('case');
         $oCase = new Cases();
         $aFields = $oCase->loadCase($appUid);
         $configNoteNotification['subject'] = G::LoadTranslation('ID_MESSAGE_SUBJECT_NOTE_NOTIFICATION') . " @#APP_TITLE ";
         $configNoteNotification['body'] = G::LoadTranslation('ID_CASE') . ": @#APP_TITLE<br />" . G::LoadTranslation('ID_AUTHOR') . ": {$authorName}<br /><br />{$noteContent}";
         /*
         if ($sFrom == '') {
             $sFrom = '"ProcessMaker"';
         }
         */
         if (isset($aConfiguration['MESS_FROM_NAME']) && $aConfiguration['MESS_FROM_NAME'] != '') {
             $sFrom = $aConfiguration['MESS_FROM_NAME'];
         }
         $hasEmailFrom = preg_match('/(.+)@(.+)\\.(.+)/', $sFrom, $match);
         if (!$hasEmailFrom || strpos($sFrom, $aConfiguration['MESS_ACCOUNT']) === false) {
             if ($aConfiguration['MESS_ENGINE'] != 'MAIL' && $aConfiguration['MESS_ACCOUNT'] != '') {
                 $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>';
             } else {
                 if ($aConfiguration['MESS_ENGINE'] == 'MAIL') {
                     $sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>';
                 } else {
                     if ($aConfiguration['MESS_SERVER'] != '') {
                         if ($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER'])) {
                             $sFrom .= ' <info@' . $sAux . '>';
                         } else {
                             $sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>';
                         }
                     } else {
                         $sFrom .= ' <*****@*****.**>';
                     }
                 }
             }
         }
         $sSubject = G::replaceDataField($configNoteNotification['subject'], $aFields);
         $sBody = nl2br(G::replaceDataField($configNoteNotification['body'], $aFields));
         G::LoadClass('spool');
         $oUser = new Users();
         $recipientsArray = explode(",", $noteRecipients);
         foreach ($recipientsArray as $recipientUid) {
             $aUser = $oUser->load($recipientUid);
             $sTo = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>';
             $oSpool = new spoolRun();
             if ($aConfiguration['MESS_RAUTH'] == false || is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false') {
                 $aConfiguration['MESS_RAUTH'] = 0;
             } else {
                 $aConfiguration['MESS_RAUTH'] = 1;
             }
             $oSpool->setConfig(array('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'], 'MESS_SERVER' => $aConfiguration['MESS_SERVER'], 'MESS_PORT' => $aConfiguration['MESS_PORT'], 'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'], 'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'], 'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false, 'SMTPSecure' => isset($aConfiguration['SMTPSecure']) ? $aConfiguration['SMTPSecure'] : ''));
             $oSpool->create(array('msg_uid' => '', 'app_uid' => $appUid, 'del_index' => 0, 'app_msg_type' => 'DERIVATION', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $sTo, 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending'));
             if ($aConfiguration['MESS_BACKGROUND'] == '' || $aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1') {
                 $oSpool->sendMail();
             }
         }
         //Send derivation notification - End
     } catch (Exception $oException) {
         throw $oException;
     }
 }
Example #5
0
 public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom = "")
 {
     try {
         $applicationData = $this->loadCase($sApplicationUID);
         $aFields["APP_NUMBER"] = $applicationData["APP_NUMBER"];
         $oConfiguration = new Configuration();
         $sDelimiter = DBAdapter::getStringDelimiter();
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails');
         $oCriteria->add(ConfigurationPeer::OBJ_UID, '');
         $oCriteria->add(ConfigurationPeer::PRO_UID, '');
         $oCriteria->add(ConfigurationPeer::USR_UID, '');
         $oCriteria->add(ConfigurationPeer::APP_UID, '');
         if (ConfigurationPeer::doCount($oCriteria) == 0) {
             $oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => ''));
             $aConfiguration = array();
         } else {
             $aConfiguration = $oConfiguration->load('Emails', '', '', '', '');
             if ($aConfiguration['CFG_VALUE'] != '') {
                 $aConfiguration = unserialize($aConfiguration["CFG_VALUE"]);
                 $passwd = $aConfiguration["MESS_PASSWORD"];
                 $passwdDec = G::decrypt($passwd, "EMAILENCRYPT");
                 $auxPass = explode('hash:', $passwdDec);
                 if (count($auxPass) > 1) {
                     if (count($auxPass) == 2) {
                         $passwd = $auxPass[1];
                     } else {
                         array_shift($auxPass);
                         $passwd = implode('', $auxPass);
                     }
                 }
                 $aConfiguration["MESS_PASSWORD"] = $passwd;
             } else {
                 $aConfiguration = array();
             }
         }
         if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') {
             return false;
         }
         //Send derivation notification - Start
         $oTask = new Task();
         $aTaskInfo = $oTask->load($sCurrentTask);
         if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') {
             return false;
         }
         if ($sFrom == '') {
             $sFrom = '"ProcessMaker"';
         }
         $hasEmailFrom = preg_match('/(.+)@(.+)\\.(.+)/', $sFrom, $match);
         if (!$hasEmailFrom || strpos($sFrom, $aConfiguration['MESS_ACCOUNT']) === false) {
             if ($aConfiguration['MESS_ENGINE'] != 'MAIL' && $aConfiguration['MESS_ACCOUNT'] != '') {
                 $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>';
             } else {
                 if ($aConfiguration['MESS_ENGINE'] == 'MAIL') {
                     $sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>';
                 } else {
                     if ($aConfiguration['MESS_SERVER'] != '') {
                         if ($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER'])) {
                             $sFrom .= ' <info@' . $sAux . '>';
                         } else {
                             $sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>';
                         }
                     } else {
                         $sFrom .= ' <*****@*****.**>';
                     }
                 }
             }
         }
         if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') {
             $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $aFields);
         } else {
             $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION');
         }
         //erik: new behaviour for messages
         G::loadClass('configuration');
         $oConf = new Configurations();
         $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', '');
         $conf = $oConf->aConfig;
         $pathEmail = PATH_DATA_SITE . "mailTemplates" . PATH_SEP . $aTaskInfo["PRO_UID"] . PATH_SEP;
         $swtplDefault = 0;
         $sBody = null;
         if (isset($conf["TAS_DEF_MESSAGE_TYPE"]) && isset($conf["TAS_DEF_MESSAGE_TEMPLATE"]) && $conf["TAS_DEF_MESSAGE_TYPE"] == "template" && $conf["TAS_DEF_MESSAGE_TEMPLATE"] != "") {
             if ($conf["TAS_DEF_MESSAGE_TEMPLATE"] == "alert_message.html") {
                 $swtplDefault = 1;
             }
             $fileTemplate = $pathEmail . $conf["TAS_DEF_MESSAGE_TEMPLATE"];
             if (!file_exists($fileTemplate)) {
                 throw new Exception("Template file \"{$fileTemplate}\" does not exist.");
             }
             $sBody = G::replaceDataGridField(file_get_contents($fileTemplate), $aFields);
         } else {
             $sBody = nl2br(G::replaceDataGridField($aTaskInfo["TAS_DEF_MESSAGE"], $aFields));
         }
         G::LoadClass("tasks");
         G::LoadClass("groups");
         G::LoadClass("spool");
         $task = new Tasks();
         $group = new Groups();
         $oUser = new Users();
         foreach ($aTasks as $aTask) {
             $sTo = null;
             $sCc = null;
             switch ($aTask["TAS_ASSIGN_TYPE"]) {
                 case "SELF_SERVICE":
                     if ($swtplDefault == 1) {
                         G::verifyPath($pathEmail, true);
                         //Create if it does not exist
                         $fileTemplate = $pathEmail . "unassignedMessage.html";
                         if (!file_exists($fileTemplate)) {
                             @copy(PATH_TPL . "mails" . PATH_SEP . "unassignedMessage.html", $fileTemplate);
                         }
                         $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields);
                     }
                     if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) {
                         $arrayTaskUser = array();
                         $arrayAux1 = $task->getGroupsOfTask($aTask["TAS_UID"], 1);
                         foreach ($arrayAux1 as $arrayGroup) {
                             $arrayAux2 = $group->getUsersOfGroup($arrayGroup["GRP_UID"]);
                             foreach ($arrayAux2 as $arrayUser) {
                                 $arrayTaskUser[] = $arrayUser["USR_UID"];
                             }
                         }
                         $arrayAux1 = $task->getUsersOfTask($aTask["TAS_UID"], 1);
                         foreach ($arrayAux1 as $arrayUser) {
                             $arrayTaskUser[] = $arrayUser["USR_UID"];
                         }
                         $criteria = new Criteria("workflow");
                         $criteria->addSelectColumn(UsersPeer::USR_UID);
                         $criteria->addSelectColumn(UsersPeer::USR_USERNAME);
                         $criteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
                         $criteria->addSelectColumn(UsersPeer::USR_LASTNAME);
                         $criteria->addSelectColumn(UsersPeer::USR_EMAIL);
                         $criteria->add(UsersPeer::USR_UID, $arrayTaskUser, Criteria::IN);
                         $rsCriteria = UsersPeer::doSelectRs($criteria);
                         $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                         $to = null;
                         $cc = null;
                         $sw = 1;
                         while ($rsCriteria->next()) {
                             $row = $rsCriteria->getRow();
                             $toAux = ($row["USR_FIRSTNAME"] != "" || $row["USR_LASTNAME"] != "" ? $row["USR_FIRSTNAME"] . " " . $row["USR_LASTNAME"] . " " : "") . "<" . $row["USR_EMAIL"] . ">";
                             if ($sw == 1) {
                                 $to = $toAux;
                                 $sw = 0;
                             } else {
                                 $cc = $cc . ($cc != null ? "," : null) . $toAux;
                             }
                         }
                         $sTo = $to;
                         $sCc = $cc;
                     }
                     break;
                 default:
                     if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) {
                         $aUser = $oUser->load($aTask["USR_UID"]);
                         $sTo = ($aUser["USR_FIRSTNAME"] != "" || $aUser["USR_LASTNAME"] != "" ? $aUser["USR_FIRSTNAME"] . " " . $aUser["USR_LASTNAME"] . " " : "") . "<" . $aUser["USR_EMAIL"] . ">";
                     }
                     break;
             }
             if ($sTo != null) {
                 $oSpool = new spoolRun();
                 if ($aConfiguration['MESS_RAUTH'] == false || is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false') {
                     $aConfiguration['MESS_RAUTH'] = 0;
                 } else {
                     $aConfiguration['MESS_RAUTH'] = 1;
                 }
                 $oSpool->setConfig(array("MESS_ENGINE" => $aConfiguration["MESS_ENGINE"], "MESS_SERVER" => $aConfiguration["MESS_SERVER"], "MESS_PORT" => $aConfiguration["MESS_PORT"], "MESS_ACCOUNT" => $aConfiguration["MESS_ACCOUNT"], "MESS_PASSWORD" => $aConfiguration["MESS_PASSWORD"], "SMTPAuth" => $aConfiguration["MESS_RAUTH"] == "1" ? true : false, "SMTPSecure" => isset($aConfiguration["SMTPSecure"]) ? $aConfiguration["SMTPSecure"] : ""));
                 $oSpool->create(array("msg_uid" => "", "app_uid" => $sApplicationUID, "del_index" => $iDelegation, "app_msg_type" => "DERIVATION", "app_msg_subject" => $sSubject, "app_msg_from" => $sFrom, "app_msg_to" => $sTo, "app_msg_body" => $sBody, "app_msg_cc" => $sCc, "app_msg_bcc" => "", "app_msg_attach" => "", "app_msg_template" => "", "app_msg_status" => "pending"));
                 if ($aConfiguration["MESS_BACKGROUND"] == "" || $aConfiguration["MESS_TRY_SEND_INMEDIATLY"] == "1") {
                     $oSpool->sendMail();
                 }
             }
         }
         //Send derivation notification - End
     } catch (Exception $oException) {
         throw $oException;
     }
 }
    /**
     * 
     * @url POST /forwardMail
     */
    public function forwardMail($params)
    {
        if (!isset($_REQUEST['REQ_UID'])) {
            $_REQUEST['REQ_UID'] = '';
        }

        $criteria = new Criteria();
        $criteria->addSelectColumn(AbeConfigurationPeer::ABE_UID);
        $criteria->addSelectColumn(AbeConfigurationPeer::PRO_UID);
        $criteria->addSelectColumn(AbeConfigurationPeer::TAS_UID);

        $criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_UID);
        $criteria->addSelectColumn(AbeRequestsPeer::APP_UID);
        $criteria->addSelectColumn(AbeRequestsPeer::DEL_INDEX);
        $criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_SENT_TO);
        $criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_SUBJECT);
        $criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_BODY);
        $criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_ANSWERED);
        $criteria->addSelectColumn(AbeRequestsPeer::ABE_REQ_STATUS);

        $criteria->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);

        $criteria->add(AbeRequestsPeer::ABE_REQ_UID, $_REQUEST['REQ_UID']);
        $criteria->addJoin(AbeRequestsPeer::ABE_UID, AbeConfigurationPeer::ABE_UID);
        $criteria->addJoin(AppDelegationPeer::APP_UID, AbeRequestsPeer::APP_UID);
        $criteria->addJoin(AppDelegationPeer::DEL_INDEX, AbeRequestsPeer::DEL_INDEX);
        $resultRes = AbeRequestsPeer::doSelectRS($criteria);
        $resultRes->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        $resultRes->next();
        $dataRes = Array();

        if ($dataRes = $resultRes->getRow()) {
            if (is_null($dataRes['DEL_FINISH_DATE'])) {
                require_once 'classes/model/Configuration.php';
                G::LoadClass('spool');

                $configuration = new Configuration();
                $sDelimiter = DBAdapter::getStringDelimiter();
                $criteria = new Criteria('workflow');
                $criteria->add(ConfigurationPeer::CFG_UID, 'Emails');
                $criteria->add(ConfigurationPeer::OBJ_UID, '');
                $criteria->add(ConfigurationPeer::PRO_UID, '');
                $criteria->add(ConfigurationPeer::USR_UID, '');
                $criteria->add(ConfigurationPeer::APP_UID, '');

                if (ConfigurationPeer::doCount($criteria) == 0) {
                    $configuration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => ''));
                    $newConfiguration = array();
                } else {
                    $newConfiguration = $configuration->load('Emails', '', '', '', '');

                    if ($newConfiguration['CFG_VALUE'] != '') {
                        $newConfiguration = unserialize($newConfiguration['CFG_VALUE']);
                    } else {
                        $newConfiguration = array();
                    }
                }

                $spool = new spoolRun();
                $spool->setConfig(array(
                    'MESS_ENGINE' => $newConfiguration['MESS_ENGINE'],
                    'MESS_SERVER' => $newConfiguration['MESS_SERVER'],
                    'MESS_PORT' => $newConfiguration['MESS_PORT'],
                    'MESS_ACCOUNT' => $newConfiguration['MESS_ACCOUNT'],
                    'MESS_PASSWORD' => $newConfiguration['MESS_PASSWORD'],
                    'SMTPAuth' => $newConfiguration['MESS_RAUTH']
                ));

                $spool->create(array(
                    'msg_uid' => '',
                    'app_uid' => $dataRes['APP_UID'],
                    'del_index' => $dataRes['DEL_INDEX'],
                    'app_msg_type' => 'TEST',
                    'app_msg_subject' => $dataRes['ABE_REQ_SUBJECT'],
                    'app_msg_from' => $newConfiguration['MESS_ACCOUNT'],
                    'app_msg_to' => $dataRes['ABE_REQ_SENT_TO'],
                    'app_msg_body' => $dataRes['ABE_REQ_BODY'],
                    'app_msg_cc' => '',
                    'app_msg_bcc' => '',
                    'app_msg_attach' => '',
                    'app_msg_template' => '',
                    'app_msg_status' => 'pending'
                ));

                if ($spool->sendMail()) {
                    $dataRes['ABE_REQ_STATUS'] = 'SENT';

                    $message = 'The email was resend to: ' . $dataRes['ABE_REQ_SENT_TO'];
                } else {
                    $dataRes['ABE_REQ_STATUS'] = 'ERROR';
                    $message = 'There was a problem sending the email to: ' . $dataRes['ABE_REQ_SENT_TO'] . ', please try later.';
                }

                try {
                    $abeRequestsInstance = new AbeRequests();
                    $abeRequestsInstance->createOrUpdate($dataRes);
                } catch (Exception $error) {
                    throw $error;
                }
            } else {
                $message = 'Unable to send email, the task is closed.';
            }
        } else {
            $message = 'An unexpected error occurred please try again later.';
        }

        return $message;
    }
Example #7
0
 /**
  * Login
  */
 public function login()
 {
     require_once 'classes/model/LoginLog.php';
     G::LoadClass('system');
     G::loadClass('configuration');
     $this->conf = new Configurations();
     // getting posibles errors passed by GET method
     $this->getInUrlError();
     if (!isset($_SESSION['G_MESSAGE'])) {
         $_SESSION['G_MESSAGE'] = '';
     }
     if (!isset($_SESSION['G_MESSAGE_TYPE'])) {
         $_SESSION['G_MESSAGE_TYPE'] = '';
     }
     $msg = $_SESSION['G_MESSAGE'];
     $msgType = $_SESSION['G_MESSAGE_TYPE'];
     if (!isset($_SESSION['FAILED_LOGINS'])) {
         $_SESSION['FAILED_LOGINS'] = 0;
     }
     $sFailedLogins = $_SESSION['FAILED_LOGINS'];
     if (isset($_SESSION['USER_LOGGED'])) {
         //close the session, if the current session_id was used in PM.
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(LoginLogPeer::LOG_SID, session_id());
         $oCriteria->add(LoginLogPeer::USR_UID, isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '-');
         $oCriteria->add(LoginLogPeer::LOG_STATUS, 'ACTIVE');
         $oCriteria->add(LoginLogPeer::LOG_END_DATE, null, Criteria::ISNULL);
         $oDataset = LoginLogPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         $aRow = $oDataset->getRow();
         if ($aRow) {
             if ($aRow['LOG_STATUS'] != 'CLOSED' && $aRow['LOG_END_DATE'] == null) {
                 $weblog = new LoginLog();
                 $aLog['LOG_UID'] = $aRow['LOG_UID'];
                 $aLog['LOG_STATUS'] = 'CLOSED';
                 $aLog['LOG_IP'] = $aRow['LOG_IP'];
                 $aLog['LOG_SID'] = session_id();
                 $aLog['LOG_INIT_DATE'] = $aRow['LOG_INIT_DATE'];
                 $aLog['LOG_END_DATE'] = date('Y-m-d H:i:s');
                 $aLog['LOG_CLIENT_HOSTNAME'] = $aRow['LOG_CLIENT_HOSTNAME'];
                 $aLog['USR_UID'] = $aRow['USR_UID'];
                 $weblog->update($aLog);
             }
         }
         //remove memcached session
         $this->memcache->delete('rbacSession' . session_id());
     } else {
         // Execute SSO trigger
         $pluginRegistry =& PMPluginRegistry::getSingleton();
         if (defined('PM_SINGLE_SIGN_ON')) {
             if ($pluginRegistry->existsTrigger(PM_SINGLE_SIGN_ON)) {
                 if ($pluginRegistry->executeTriggers(PM_SINGLE_SIGN_ON, null)) {
                     // Start new session
                     @session_destroy();
                     session_start();
                     session_regenerate_id();
                     // Authenticate
                     $result = $this->authentication();
                     if ($result->success) {
                         // Redirect to landing page for the user
                         G::header('Location: ' . $result->url);
                         die;
                     }
                 }
             }
         }
     }
     //end log
     //start new session
     @session_destroy();
     session_start();
     session_regenerate_id();
     if (strlen($msg) > 0) {
         $_SESSION['G_MESSAGE'] = $msg;
     }
     if (strlen($msgType) > 0) {
         $_SESSION['G_MESSAGE_TYPE'] = $msgType;
     }
     $_SESSION['FAILED_LOGINS'] = $sFailedLogins;
     $availableLangArray = $this->getLanguagesList();
     G::LoadClass("serverConfiguration");
     $sflag = 0;
     if (($nextBeatDate = $this->memcache->get('nextBeatDate')) === false) {
         //get the serverconf singleton, and check if we can send the heartbeat
         $oServerConf =& serverConf::getSingleton();
         $sflag = $oServerConf->getHeartbeatProperty('HB_OPTION', 'HEART_BEAT_CONF');
         $sflag = trim($sflag) != '' ? $sflag : '1';
         //get date of next beat
         $nextBeatDate = $oServerConf->getHeartbeatProperty('HB_NEXT_BEAT_DATE', 'HEART_BEAT_CONF');
         $this->memcache->set('nextBeatDate', $nextBeatDate, 1 * 3600);
     } else {
         $sflag = '1';
     }
     if ($sflag == '1' && (strtotime("now") > $nextBeatDate || is_null($nextBeatDate))) {
         //To do: we need to change to ExtJs
         $this->setJSVar('flagHeartBeat', 1);
     } else {
         $this->setJSVar('flagHeartBeat', 0);
     }
     if (($flagGettingStarted = $this->memcache->get('flagGettingStarted')) === false) {
         require_once 'classes/model/Configuration.php';
         $oConfiguration = new Configuration();
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ConfigurationPeer::CFG_UID, 'getStarted');
         $oCriteria->add(ConfigurationPeer::OBJ_UID, '');
         $oCriteria->add(ConfigurationPeer::CFG_VALUE, '1');
         $oCriteria->add(ConfigurationPeer::PRO_UID, '');
         $oCriteria->add(ConfigurationPeer::USR_UID, '');
         $oCriteria->add(ConfigurationPeer::APP_UID, '');
         $flagGettingStarted = ConfigurationPeer::doCount($oCriteria);
         $this->memcache->set('flagGettingStarted', $flagGettingStarted, 8 * 3600);
     }
     $this->setJSVar('flagGettingStarted', $flagGettingStarted == 0);
     G::loadClass('configuration');
     $oConf = new Configurations();
     $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', '');
     $flagForgotPassword = isset($oConf->aConfig['login_enableForgotPassword']) ? $oConf->aConfig['login_enableForgotPassword'] : '******';
     $this->includeExtJSLib('ux/virtualkeyboard');
     $this->includeExtJS('main/login');
     $this->setView('main/login');
     $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', '');
     $forgotPasswd = isset($oConf->aConfig['login_enableForgotPassword']) ? $oConf->aConfig['login_enableForgotPassword'] : false;
     $virtualKeyboad = isset($oConf->aConfig['login_enableVirtualKeyboard']) ? $oConf->aConfig['login_enableVirtualKeyboard'] : false;
     $defaultLanguaje = isset($oConf->aConfig['login_defaultLanguage']) ? $oConf->aConfig['login_defaultLanguage'] : 'en';
     $this->setJSVar('forgotPasswd', $forgotPasswd);
     $this->setJSVar('virtualKeyboad', $virtualKeyboad);
     $this->setJSVar('languages', $availableLangArray);
     $this->setJSVar('defaultLang', $defaultLanguaje);
     //binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter()
     if (($flyNotify = $this->getFlyNotify()) !== false) {
         $this->setJSVar('flyNotify', $flyNotify);
     }
     //binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter()
     if (isset($_GET['u'])) {
         $this->setJSVar('urlRequested', urldecode($_GET['u']));
     }
     $this->setVar('logo_company', $this->getCompanyLogo());
     $this->setVar('pmos_version', System::getVersion());
     $footerText = 'Copyright &copy; 2003-' . date('Y') . ' Colosa, Inc. All rights reserved.';
     $adviseText = 'Supplied free of charge with no support, certification, warranty,
         maintenance nor indemnity by Colosa and its Certified Partners. ';
     $this->setVar('footer_text', $footerText);
     $this->setVar('advise_text', $adviseText);
     $loginScript = $this->getHeadPublisher()->getExtJsLibraries();
     $loginScript .= $this->getHeadPublisher()->getExtJsScripts();
     $this->setVar('login_script', $loginScript);
     $this->setVar('login_vars', $this->getHeadPublisher()->getExtJsVariablesScript());
     $this->setLayout('pm-modern-login');
     $this->render();
 }
Example #8
0
 public function sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients, $sFrom = "")
 {
     try {
         require_once 'classes/model/Configuration.php';
         $oConfiguration = new Configuration();
         $sDelimiter = DBAdapter::getStringDelimiter();
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails');
         $oCriteria->add(ConfigurationPeer::OBJ_UID, '');
         $oCriteria->add(ConfigurationPeer::PRO_UID, '');
         $oCriteria->add(ConfigurationPeer::USR_UID, '');
         $oCriteria->add(ConfigurationPeer::APP_UID, '');
         if (ConfigurationPeer::doCount($oCriteria) == 0) {
             $oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => ''));
             $aConfiguration = array();
         } else {
             $aConfiguration = $oConfiguration->load('Emails', '', '', '', '');
             if ($aConfiguration['CFG_VALUE'] != '') {
                 $aConfiguration = unserialize($aConfiguration['CFG_VALUE']);
                 $passwd = $aConfiguration['MESS_PASSWORD'];
                 $passwdDec = G::decrypt($passwd, 'EMAILENCRYPT');
                 if (strpos($passwdDec, 'hash:') !== false) {
                     list($hash, $pass) = explode(":", $passwdDec);
                     $aConfiguration['MESS_PASSWORD'] = $pass;
                 }
             } else {
                 $aConfiguration = array();
             }
         }
         if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') {
             return false;
         }
         $oUser = new Users();
         $aUser = $oUser->load($usrUid);
         $authorName = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>';
         G::LoadClass('case');
         $oCase = new Cases();
         $aFields = $oCase->loadCase($appUid);
         $configNoteNotification['subject'] = G::LoadTranslation('ID_MESSAGE_SUBJECT_NOTE_NOTIFICATION') . " @#APP_TITLE ";
         $configNoteNotification['body'] = G::LoadTranslation('ID_CASE') . ": @#APP_TITLE<br />" . G::LoadTranslation('ID_AUTHOR') . ": {$authorName}<br /><br />{$noteContent}";
         if ($sFrom == '') {
             $sFrom = '"ProcessMaker"';
         }
         if ($aConfiguration['MESS_ENGINE'] != 'MAIL' && $aConfiguration['MESS_ACCOUNT'] != '') {
             $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>';
         } else {
             if ($aConfiguration['MESS_ENGINE'] == 'MAIL') {
                 $sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>';
             } else {
                 if ($aConfiguration['MESS_SERVER'] != '') {
                     if ($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER'])) {
                         $sFrom .= ' <info@' . $sAux . '>';
                     } else {
                         $sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>';
                     }
                 } else {
                     $sFrom .= ' <*****@*****.**>';
                 }
             }
         }
         $sSubject = G::replaceDataField($configNoteNotification['subject'], $aFields);
         //erik: new behaviour for messages
         //G::loadClass('configuration');
         //$oConf = new Configurations;
         //$oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', '');
         //$conf = $oConf->aConfig;
         /*
               if( isset($conf['TAS_DEF_MESSAGE_TYPE']) && isset($conf['TAS_DEF_MESSAGE_TEMPLATE'])
                 && $conf['TAS_DEF_MESSAGE_TYPE'] == 'template' && $conf['TAS_DEF_MESSAGE_TEMPLATE'] != '') {
         
                 $pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $aTaskInfo['PRO_UID'] . PATH_SEP;
                 $fileTemplate = $pathEmail . $conf['TAS_DEF_MESSAGE_TEMPLATE'];
         
                 if ( ! file_exists ( $fileTemplate ) ) {
                   throw new Exception("Template file '$fileTemplate' does not exist.");
                 }
         
                 $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields);
               } else {*/
         $sBody = nl2br(G::replaceDataField($configNoteNotification['body'], $aFields));
         /*}*/
         G::LoadClass('spool');
         $oUser = new Users();
         $recipientsArray = explode(",", $noteRecipients);
         foreach ($recipientsArray as $recipientUid) {
             $aUser = $oUser->load($recipientUid);
             $sTo = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>';
             $oSpool = new spoolRun();
             $oSpool->setConfig(array('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'], 'MESS_SERVER' => $aConfiguration['MESS_SERVER'], 'MESS_PORT' => $aConfiguration['MESS_PORT'], 'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'], 'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'], 'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false, 'SMTPSecure' => isset($aConfiguration['SMTPSecure']) ? $aConfiguration['SMTPSecure'] : ''));
             $oSpool->create(array('msg_uid' => '', 'app_uid' => $appUid, 'del_index' => 1, 'app_msg_type' => 'DERIVATION', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $sTo, 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending'));
             if ($aConfiguration['MESS_BACKGROUND'] == '' || $aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1') {
                 $oSpool->sendMail();
             }
         }
         //Send derivation notification - End
     } catch (Exception $oException) {
         throw $oException;
     }
 }
Example #9
0
 public function sendNotifications($sCurrentTask, $aTasks, $aFields, $sApplicationUID, $iDelegation, $sFrom = '')
 {
     try {
         $oConfiguration = new Configuration();
         $sDelimiter = DBAdapter::getStringDelimiter();
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ConfigurationPeer::CFG_UID, 'Emails');
         $oCriteria->add(ConfigurationPeer::OBJ_UID, '');
         $oCriteria->add(ConfigurationPeer::PRO_UID, '');
         $oCriteria->add(ConfigurationPeer::USR_UID, '');
         $oCriteria->add(ConfigurationPeer::APP_UID, '');
         if (ConfigurationPeer::doCount($oCriteria) == 0) {
             $oConfiguration->create(array('CFG_UID' => 'Emails', 'OBJ_UID' => '', 'CFG_VALUE' => '', 'PRO_UID' => '', 'USR_UID' => '', 'APP_UID' => ''));
             $aConfiguration = array();
         } else {
             $aConfiguration = $oConfiguration->load('Emails', '', '', '', '');
             if ($aConfiguration['CFG_VALUE'] != '') {
                 $aConfiguration = unserialize($aConfiguration["CFG_VALUE"]);
                 $passwd = $aConfiguration["MESS_PASSWORD"];
                 $passwdDec = G::decrypt($passwd, "EMAILENCRYPT");
                 if (strpos($passwdDec, "hash:") !== false) {
                     list($hash, $pass) = explode(":", $passwdDec);
                     $passwd = $pass;
                 }
                 $aConfiguration["MESS_PASSWORD"] = $passwd;
             } else {
                 $aConfiguration = array();
             }
         }
         if (!isset($aConfiguration['MESS_ENABLED']) || $aConfiguration['MESS_ENABLED'] != '1') {
             return false;
         }
         //Send derivation notification - Start
         $oTask = new Task();
         $aTaskInfo = $oTask->load($sCurrentTask);
         if ($aTaskInfo['TAS_SEND_LAST_EMAIL'] != 'TRUE') {
             return false;
         }
         if ($sFrom == '') {
             $sFrom = '"ProcessMaker"';
         }
         if ($aConfiguration['MESS_ENGINE'] != 'MAIL' && $aConfiguration['MESS_ACCOUNT'] != '') {
             $sFrom .= ' <' . $aConfiguration['MESS_ACCOUNT'] . '>';
         } else {
             if ($aConfiguration['MESS_ENGINE'] == 'MAIL') {
                 $sFrom .= ' <info@' . gethostbyaddr('127.0.0.1') . '>';
             } else {
                 if ($aConfiguration['MESS_SERVER'] != '') {
                     if ($sAux = @gethostbyaddr($aConfiguration['MESS_SERVER'])) {
                         $sFrom .= ' <info@' . $sAux . '>';
                     } else {
                         $sFrom .= ' <info@' . $aConfiguration['MESS_SERVER'] . '>';
                     }
                 } else {
                     $sFrom .= ' <*****@*****.**>';
                 }
             }
         }
         if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') {
             $sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $aFields);
         } else {
             $sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION');
         }
         //erik: new behaviour for messages
         G::loadClass('configuration');
         $oConf = new Configurations();
         $oConf->loadConfig($x, 'TAS_EXTRA_PROPERTIES', $aTaskInfo['TAS_UID'], '', '');
         $conf = $oConf->aConfig;
         if (isset($conf['TAS_DEF_MESSAGE_TYPE']) && isset($conf['TAS_DEF_MESSAGE_TEMPLATE']) && $conf['TAS_DEF_MESSAGE_TYPE'] == 'template' && $conf['TAS_DEF_MESSAGE_TEMPLATE'] != '') {
             $pathEmail = PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $aTaskInfo['PRO_UID'] . PATH_SEP;
             $fileTemplate = $pathEmail . $conf['TAS_DEF_MESSAGE_TEMPLATE'];
             if (!file_exists($fileTemplate)) {
                 throw new Exception("Template file '{$fileTemplate}' does not exist.");
             }
             $sBody = G::replaceDataField(file_get_contents($fileTemplate), $aFields);
         } else {
             $sBody = nl2br(G::replaceDataField($aTaskInfo['TAS_DEF_MESSAGE'], $aFields));
         }
         G::LoadClass('spool');
         $oUser = new Users();
         foreach ($aTasks as $aTask) {
             if (isset($aTask['USR_UID'])) {
                 $aUser = $oUser->load($aTask['USR_UID']);
                 $sTo = ($aUser['USR_FIRSTNAME'] != '' || $aUser['USR_LASTNAME'] != '' ? $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' ' : '') . '<' . $aUser['USR_EMAIL'] . '>';
                 $oSpool = new spoolRun();
                 $oSpool->setConfig(array('MESS_ENGINE' => $aConfiguration['MESS_ENGINE'], 'MESS_SERVER' => $aConfiguration['MESS_SERVER'], 'MESS_PORT' => $aConfiguration['MESS_PORT'], 'MESS_ACCOUNT' => $aConfiguration['MESS_ACCOUNT'], 'MESS_PASSWORD' => $aConfiguration['MESS_PASSWORD'], 'SMTPAuth' => $aConfiguration['MESS_RAUTH'] == '1' ? true : false, 'SMTPSecure' => isset($aConfiguration['SMTPSecure']) ? $aConfiguration['SMTPSecure'] : ''));
                 $oSpool->create(array('msg_uid' => '', 'app_uid' => $sApplicationUID, 'del_index' => $iDelegation, 'app_msg_type' => 'DERIVATION', 'app_msg_subject' => $sSubject, 'app_msg_from' => $sFrom, 'app_msg_to' => $sTo, 'app_msg_body' => $sBody, 'app_msg_cc' => '', 'app_msg_bcc' => '', 'app_msg_attach' => '', 'app_msg_template' => '', 'app_msg_status' => 'pending'));
                 if ($aConfiguration['MESS_BACKGROUND'] == '' || $aConfiguration['MESS_TRY_SEND_INMEDIATLY'] == '1') {
                     $oSpool->sendMail();
                 }
             }
         }
         //Send derivation notification - End
     } catch (Exception $oException) {
         throw $oException;
     }
 }