Пример #1
0
     if (!$isUserHavePhpAccess) {
         $MESSAGE_OLD = false;
         if ($ID > 0) {
             $mailingChainOld = \Bitrix\Sender\MailingChainTable::getRowById(array('ID' => $ID));
             if ($mailingChainOld) {
                 $MESSAGE_OLD = $mailingChainOld['MESSAGE'];
             }
         }
         $MESSAGE = CMain::ProcessLPA($MESSAGE, $MESSAGE_OLD);
     }
     $arFields = array("MAILING_ID" => $MAILING_ID, "SUBJECT" => $SUBJECT, "EMAIL_FROM" => $EMAIL_FROM, "MESSAGE" => $MESSAGE, "CREATED_BY" => $USER->GetID(), "REITERATE" => "N", "AUTO_SEND_TIME" => "", "DAYS_OF_WEEK" => "", "DAYS_OF_MONTH" => "", "TIMES_OF_DAY" => "");
     if (empty($MESSAGE) && isset($IS_TEMPLATE_LIST_SHOWN) && $IS_TEMPLATE_LIST_SHOWN == 'Y') {
         $arError[] = GetMessage("sender_chain_edit_error_select_template");
     }
     if (empty($arError)) {
         $mailingAddDb = \Bitrix\Sender\MailingChainTable::add($arFields);
         if ($mailingAddDb->isSuccess()) {
             $ID = $mailingAddDb->getId();
             \Bitrix\Sender\MailingChainTable::initPosting($ID);
             $res = $ID > 0;
             $MAILING_CHAIN_ID = $ID;
         } else {
             $arError = $mailingAddDb->getErrorMessages();
         }
     }
 }
 if (empty($arError)) {
     if ($MAILING_CHAIN_ID > 0) {
         //add or delete files
         //Delete checked
         if (is_array($FILES_del)) {
Пример #2
0
 public static function updateChain($id, array $fields)
 {
     $result = new \Bitrix\Main\Entity\Result();
     static::checkFieldsChain($result, $id, $fields);
     if (!$result->isSuccess(true)) {
         return $result;
     }
     $parentChainId = null;
     $existChildIdList = array();
     foreach ($fields as $chainFields) {
         $chainId = $chainFields['ID'];
         unset($chainFields['ID']);
         $chainFields['MAILING_ID'] = $id;
         $chainFields['IS_TRIGGER'] = 'Y';
         $chainFields['REITERATE'] = 'Y';
         $chainFields['PARENT_ID'] = $parentChainId;
         // default status
         if ($chainId > 0) {
             $chain = \Bitrix\Sender\MailingChainTable::getRowById(array('ID' => $chainId));
             if ($chain && $chain['STATUS'] != \Bitrix\Sender\MailingChainTable::STATUS_WAIT) {
                 $chainFields['STATUS'] = $chain['STATUS'];
                 unset($chainFields['CREATED_BY']);
             }
         }
         if (empty($chainFields['STATUS'])) {
             $chainFields['STATUS'] = \Bitrix\Sender\MailingChainTable::STATUS_WAIT;
         }
         // add or update
         if ($chainId > 0) {
             $existChildIdList[] = $chainId;
             $chainUpdateDb = MailingChainTable::update(array('ID' => $chainId), $chainFields);
             if ($chainUpdateDb->isSuccess()) {
             } else {
                 $result->addErrors($chainUpdateDb->getErrors());
             }
         } else {
             $chainAddDb = MailingChainTable::add($chainFields);
             if ($chainAddDb->isSuccess()) {
                 $chainId = $chainAddDb->getId();
                 $existChildIdList[] = $chainId;
             } else {
                 $result->addErrors($chainAddDb->getErrors());
             }
         }
         if (!empty($errorList)) {
             break;
         }
         $parentChainId = null;
         if ($chainId !== null) {
             $parentChainId = $chainId;
         }
     }
     $deleteChainDb = MailingChainTable::getList(array('select' => array('ID'), 'filter' => array('MAILING_ID' => $id, '!ID' => $existChildIdList)));
     while ($deleteChain = $deleteChainDb->fetch()) {
         MailingChainTable::delete(array('ID' => $deleteChain['ID']));
     }
     static::updateChainTrigger($id);
     return $result;
 }