Esempio n. 1
0
 /**
  * Implementation for 'GET' method for Rest API
  *
  * @param  mixed $appMsgUid Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function get($appMsgUid = null)
 {
     $result = array();
     try {
         $noArguments = true;
         $argumentList = func_get_args();
         foreach ($argumentList as $arg) {
             if (!is_null($arg)) {
                 $noArguments = false;
             }
         }
         if ($noArguments) {
             $criteria = new Criteria('workflow');
             $criteria->addSelectColumn(AppMessagePeer::APP_MSG_UID);
             $criteria->addSelectColumn(AppMessagePeer::MSG_UID);
             $criteria->addSelectColumn(AppMessagePeer::APP_UID);
             $criteria->addSelectColumn(AppMessagePeer::DEL_INDEX);
             $criteria->addSelectColumn(AppMessagePeer::APP_MSG_TYPE);
             $criteria->addSelectColumn(AppMessagePeer::APP_MSG_SUBJECT);
             $criteria->addSelectColumn(AppMessagePeer::APP_MSG_FROM);
             $criteria->addSelectColumn(AppMessagePeer::APP_MSG_TO);
             $criteria->addSelectColumn(AppMessagePeer::APP_MSG_BODY);
             $criteria->addSelectColumn(AppMessagePeer::APP_MSG_DATE);
             $criteria->addSelectColumn(AppMessagePeer::APP_MSG_CC);
             $criteria->addSelectColumn(AppMessagePeer::APP_MSG_BCC);
             $criteria->addSelectColumn(AppMessagePeer::APP_MSG_TEMPLATE);
             $criteria->addSelectColumn(AppMessagePeer::APP_MSG_STATUS);
             $criteria->addSelectColumn(AppMessagePeer::APP_MSG_ATTACH);
             $criteria->addSelectColumn(AppMessagePeer::APP_MSG_SEND_DATE);
             $dataset = AppEventPeer::doSelectRS($criteria);
             $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             while ($dataset->next()) {
                 $result[] = $dataset->getRow();
             }
         } else {
             $record = AppMessagePeer::retrieveByPK($appMsgUid);
             if ($record) {
                 $result = $record->toArray(BasePeer::TYPE_FIELDNAME);
             } else {
                 $paramValues = "";
                 foreach ($argumentList as $arg) {
                     $paramValues .= strlen($paramValues) ? ', ' : '';
                     if (!is_null($arg)) {
                         $paramValues .= "{$arg}";
                     } else {
                         $paramValues .= "NULL";
                     }
                 }
                 throw new RestException(417, "table AppMessage ({$paramValues})");
             }
         }
     } catch (RestException $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
     return $result;
 }
Esempio n. 2
0
    public function getHistoryMessagesTrackerView($sApplicationUID, $Msg_UID)

    {

        $oAppDocument = new AppDocument();

        $oCriteria = new Criteria('workflow');

        $oCriteria->add(AppMessagePeer::APP_UID, $sApplicationUID);

        $oCriteria->add(AppMessagePeer::APP_MSG_UID, $Msg_UID);

        $oCriteria->addAscendingOrderByColumn(AppMessagePeer::APP_MSG_DATE);

        $oDataset = AppMessagePeer::doSelectRS($oCriteria);

        $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        $oDataset->next();

        $aRow = $oDataset->getRow();

        return $aRow;

    }
Esempio n. 3
0
    /**
     * try resend the emails from spool
     *
     * @param string $dateResend
     * @return none or exception
     */
    public function resendEmails ($dateResend = null, $cron = 0)
    {
        if (!class_exists('System')) {
            G::LoadClass('system');
        }
        $aConfiguration = System::getEmailConfiguration();

        if (!isset($aConfiguration["MESS_ENABLED"])) {
            $aConfiguration["MESS_ENABLED"] = '0';
        }

        if ($aConfiguration["MESS_ENABLED"] == "1") {
            require_once ("classes/model/AppMessage.php");

            $this->setConfig($aConfiguration);

            $criteria = new Criteria( "workflow" );
            $criteria->add( AppMessagePeer::APP_MSG_STATUS, "sent", Criteria::NOT_EQUAL );

            if ($dateResend != null) {
                $criteria->add( AppMessagePeer::APP_MSG_DATE, $dateResend, Criteria::GREATER_EQUAL );
            }

            $rsCriteria = AppMessagePeer::doSelectRS( $criteria );
            $rsCriteria->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            while ($rsCriteria->next()) {
                if ($cron == 1) {
                    $arrayCron = unserialize( trim( @file_get_contents( PATH_DATA . "cron" ) ) );
                    $arrayCron["processcTimeStart"] = time();
                    @file_put_contents( PATH_DATA . "cron", serialize( $arrayCron ) );
                }

                $row = $rsCriteria->getRow();

                try {
                    $sFrom = G::buildFrom($aConfiguration, $row["APP_MSG_FROM"]);

                    $this->setData( $row["APP_MSG_UID"], $row["APP_MSG_SUBJECT"], $sFrom, $row["APP_MSG_TO"], $row["APP_MSG_BODY"], date( "Y-m-d H:i:s" ), $row["APP_MSG_CC"], $row["APP_MSG_BCC"], $row["APP_MSG_TEMPLATE"], $row["APP_MSG_ATTACH"] );

                    $this->sendMail();
                } catch (Exception $e) {
                    $strAux = "Spool::resendEmails(): Using " . $aConfiguration["MESS_ENGINE"] . " for APP_MGS_UID=" . $row["APP_MSG_UID"] . " -> With message: " . $e->getMessage();

                    if ($e->getCode() == $this->ExceptionCode["WARNING"]) {
                        array_push( $this->aWarnings, $strAux );
                        continue;
                    } else {
                        throw $e;
                    }
                }
            }
        }
    }
Esempio n. 4
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      Connection $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *       rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(AppMessagePeer::APP_MSG_UID, $pks, Criteria::IN);
         $objs = AppMessagePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Esempio n. 5
0
         $criteria->addDescendingOrderByColumn($sort);
     }
 } else {
     $oCriteria->addDescendingOrderByColumn(AppMessagePeer::APP_MSG_SEND_DATE);
 }
 if ($limit != '') {
     $criteria->setLimit($limit);
     $criteria->setOffset($start);
 }
 $criteria->addJoin(AppMessagePeer::APP_UID, ApplicationPeer::APP_UID);
 $conditions = array();
 $conditions[] = array(ApplicationPeer::PRO_UID, 'C2.CON_ID');
 $conditions[] = array('C2.CON_CATEGORY', DBAdapter::getStringDelimiter() . 'PRO_TITLE' . DBAdapter::getStringDelimiter());
 $conditions[] = array('C2.CON_LANG', DBAdapter::getStringDelimiter() . SYS_LANG . DBAdapter::getStringDelimiter());
 $criteria->addJoinMC($conditions, Criteria::LEFT_JOIN);
 $result = AppMessagePeer::doSelectRS($criteria);
 $result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
 $data = array();
 $dataPro = array();
 $index = 1;
 $content = new Content();
 $tasTitleDefault = G::LoadTranslation('ID_TASK_NOT_RELATED');
 while ($result->next()) {
     $row = $result->getRow();
     $row['APP_MSG_FROM'] = htmlentities($row['APP_MSG_FROM'], ENT_QUOTES, "UTF-8");
     $row['APP_MSG_STATUS'] = ucfirst($row['APP_MSG_STATUS']);
     if ($row['DEL_INDEX'] != 0) {
         $index = $row['DEL_INDEX'];
     }
     $criteria = new Criteria();
     $criteria->addSelectColumn(AppCacheViewPeer::APP_TITLE);
Esempio n. 6
0
 public function updateStatus($msgUid, $msgStatus)
 {
     $message = AppMessagePeer::retrieveByPk($msgUid);
     $message->fromArray($message, BasePeer::TYPE_FIELDNAME);
     $message->setAppMsgStatus($msgStatus);
     $message->save();
 }
Esempio n. 7
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = AppMessagePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setAppMsgUid($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setMsgUid($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setAppUid($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setDelIndex($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setAppMsgType($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setAppMsgSubject($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setAppMsgFrom($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setAppMsgTo($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setAppMsgBody($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setAppMsgDate($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setAppMsgCc($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setAppMsgBcc($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setAppMsgTemplate($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setAppMsgStatus($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setAppMsgAttach($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setAppMsgSendDate($arr[$keys[15]]);
     }
 }
Esempio n. 8
0
 /**
  * try resend the emails from spool
  *
  * @param string $dateResend
  * @return none or exception
  */
 public function resendEmails($dateResend = null, $cron = 0)
 {
     require_once "classes/model/Configuration.php";
     $oConfiguration = new Configuration();
     $aConfiguration = $oConfiguration->load("Emails", "", "", "", "");
     $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;
     if ($aConfiguration["MESS_ENABLED"] == "1") {
         require_once "classes/model/AppMessage.php";
         if ($aConfiguration['MESS_RAUTH'] == false || is_string($aConfiguration['MESS_RAUTH']) && $aConfiguration['MESS_RAUTH'] == 'false') {
             $aConfiguration['MESS_RAUTH'] = 0;
         } else {
             $aConfiguration['MESS_RAUTH'] = 1;
         }
         $this->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"], "SMTPSecure" => $aConfiguration["SMTPSecure"]));
         $criteria = new Criteria("workflow");
         $criteria->add(AppMessagePeer::APP_MSG_STATUS, "sent", Criteria::NOT_EQUAL);
         if ($dateResend != null) {
             $criteria->add(AppMessagePeer::APP_MSG_DATE, $dateResend, Criteria::GREATER_EQUAL);
         }
         $rsCriteria = AppMessagePeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             if ($cron == 1) {
                 $arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
                 $arrayCron["processcTimeStart"] = time();
                 @file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
             }
             $row = $rsCriteria->getRow();
             try {
                 $sFrom = $row["APP_MSG_FROM"];
                 $hasEmailFrom = preg_match('/(.+)@(.+)\\.(.+)/', $row["APP_MSG_FROM"], $match);
                 if (!$hasEmailFrom || strpos($row["APP_MSG_FROM"], $aConfiguration['MESS_ACCOUNT']) === false) {
                     $sFrom = '"' . stripslashes($row["APP_MSG_FROM"]) . '" <' . $aConfiguration['MESS_ACCOUNT'] . ">";
                 }
                 $this->setData($row["APP_MSG_UID"], $row["APP_MSG_SUBJECT"], $sFrom, $row["APP_MSG_TO"], $row["APP_MSG_BODY"], date("Y-m-d H:i:s"), $row["APP_MSG_CC"], $row["APP_MSG_BCC"], $row["APP_MSG_TEMPLATE"], $row["APP_MSG_ATTACH"]);
                 $this->sendMail();
             } catch (Exception $e) {
                 $strAux = "Spool::resendEmails(): Using " . $aConfiguration["MESS_ENGINE"] . " for APP_MGS_UID=" . $row["APP_MSG_UID"] . " -> With message: " . $e->getMessage();
                 if ($e->getCode() == $this->ExceptionCode["WARNING"]) {
                     array_push($this->aWarnings, $strAux);
                     continue;
                 } else {
                     throw $e;
                 }
             }
         }
     }
 }
Esempio n. 9
0
 /**
  * try resend the emails from spool
  * @param none
  * @return none or exception
  */
 function resendEmails()
 {
     require_once "classes/model/Configuration.php";
     $oConfiguration = new Configuration();
     $aConfiguration = $oConfiguration->load("Emails", "", "", "", "");
     $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;
     }
     if ($aConfiguration["MESS_ENABLED"] == "1") {
         $this->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"], "SMTPSecure" => $aConfiguration["SMTPSecure"]));
         ///////
         require_once "classes/model/AppMessage.php";
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(AppMessagePeer::APP_MSG_STATUS, 'sent', Criteria::NOT_EQUAL);
         $oDataset = AppMessagePeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         while ($oDataset->next()) {
             $aRow = $oDataset->getRow();
             try {
                 $this->setData($aRow['APP_MSG_UID'], $aRow['APP_MSG_SUBJECT'], $aRow['APP_MSG_FROM'], $aRow['APP_MSG_TO'], $aRow['APP_MSG_BODY'], date('Y-m-d H:i:s'), $aRow['APP_MSG_CC'], $aRow['APP_MSG_BCC'], $aRow['APP_MSG_TEMPLATE'], $aRow['APP_MSG_ATTACH']);
                 $this->sendMail();
             } catch (Exception $oException) {
                 if ($oException->getCode() == $this->ExceptionCode['WARNING']) {
                     array_push($this->aWarnings, 'Spool::resendEmails(): Using ' . $aConfiguration['MESS_ENGINE'] . ' for APP_MGS_UID=' . $aRow['APP_MSG_UID'] . ' -> With message: ' . $oException->getMessage());
                     continue;
                 } else {
                     throw $oException;
                 }
             }
         }
     }
 }