Ejemplo n.º 1
0
 /**
  * @param $arData
  * @return array
  * @throws \Bitrix\Main\ArgumentException
  */
 public static function getList($arData)
 {
     $arMailing = array();
     if (isset($arData['TEST']) && $arData['TEST'] == 'Y') {
         $mailing = MailingTable::getRowById(array('ID' => $arData['MAILING_ID']));
         if ($mailing) {
             $arMailing[] = array('ID' => $mailing['ID'], 'NAME' => $mailing['NAME'], 'SELECTED' => true);
         }
         return $arMailing;
     }
     $mailingUnsub = array();
     $recipientUnsubDb = PostingUnsubTable::getList(array('select' => array('MAILING_ID' => 'POSTING.MAILING_ID'), 'filter' => array('=POSTING_RECIPIENT.EMAIL' => trim(strtolower($arData['EMAIL'])))));
     while ($recipientUnsub = $recipientUnsubDb->fetch()) {
         $mailingUnsub[] = $recipientUnsub['MAILING_ID'];
     }
     $mailingDb = PostingRecipientTable::getList(array('select' => array('MAILING_ID' => 'POSTING.MAILING.ID', 'MAILING_NAME' => 'POSTING.MAILING.NAME'), 'filter' => array('=EMAIL' => trim(strtolower($arData['EMAIL'])), 'POSTING.MAILING.ACTIVE' => 'Y'), 'group' => array('MAILING_ID', 'MAILING_NAME')));
     while ($mailing = $mailingDb->fetch()) {
         if (!in_array($mailing['MAILING_ID'], $mailingUnsub)) {
             $arMailing[] = array('ID' => $mailing['MAILING_ID'], 'NAME' => $mailing['MAILING_NAME'], 'SELECTED' => in_array($mailing['MAILING_ID'], array($arData['MAILING_ID'])));
         }
     }
     return $arMailing;
 }
Ejemplo n.º 2
0
            unset($arFilter[$k]);
        }
    }
}
if (isset($order)) {
    $order = $order == 'asc' ? 'ASC' : 'DESC';
}
if ($lAdmin->EditAction() && $POST_RIGHT == "W") {
    foreach ($FIELDS as $ID => $arFields) {
        if (!$lAdmin->IsUpdated($ID)) {
            continue;
        }
        $DB->StartTransaction();
        $ID = IntVal($ID);
        $dataPrimary = array('ID' => $ID);
        $arData = \Bitrix\Sender\MailingTable::getRowById($dataPrimary);
        if ($arData) {
            foreach ($arFields as $key => $value) {
                $arData[$key] = $value;
            }
            unset($arData['ID']);
            $dataUpdateDb = \Bitrix\Sender\MailingTable::update($dataPrimary, $arData);
            if (!$dataUpdateDb->isSuccess()) {
                $LAST_ERROR = $dataUpdateDb->getErrorMessages();
                $LAST_ERROR = $LAST_ERROR[0];
                $lAdmin->AddGroupError(GetMessage("rub_save_error") . " " . $LAST_ERROR, $ID);
                $DB->Rollback();
            }
        } else {
            $lAdmin->AddGroupError(GetMessage("rub_save_error") . " " . GetMessage("rub_no_rubric"), $ID);
            $DB->Rollback();
Ejemplo n.º 3
0
    $ACTIVE = 'N';
}
if ($step == 'mailing') {
    IncludeModuleLangFile(dirname(__FILE__) . "/mailing_edit.php");
    if ($REQUEST_METHOD == "POST" && !$isPostedFormProcessed && check_bitrix_sessid()) {
        $NAME = trim($NAME);
        if ($MAILING_TYPE == 'NEW') {
            $arFields = array("ACTIVE" => $ACTIVE != "Y" ? "N" : "Y", "TRACK_CLICK" => $TRACK_CLICK != "Y" ? "N" : "Y", "SORT" => $SORT, "IS_PUBLIC" => $IS_PUBLIC != "Y" ? "N" : "Y", "NAME" => $NAME, "DESCRIPTION" => $DESCRIPTION, "SITE_ID" => $SITE_ID);
            $mailingAddDb = \Bitrix\Sender\MailingTable::add($arFields);
            if ($mailingAddDb->isSuccess()) {
                $MAILING_ID = $mailingAddDb->getId();
            } else {
                $arError = $mailingAddDb->getErrorMessages();
            }
        } else {
            $mailing = \Bitrix\Sender\MailingTable::getRowById($MAILING_ID);
            if (!$mailing) {
                $arError[] = GetMessage("sender_wizard_step_mailing_existed_not_selected");
            }
        }
        if (empty($arError)) {
            if ($MAILING_TYPE == 'NEW') {
                $step = 'mailing_group';
            } else {
                $step = 'chain';
            }
            $isPostedFormProcessed = true;
            LocalRedirect('sender_mailing_wizard.php?step=' . $step . '&MAILING_ID=' . $MAILING_ID . "&lang=" . LANGUAGE_ID);
        } else {
            $DB->InitTableVarsForEdit("b_sender_mailing", "", "str_");
        }
Ejemplo n.º 4
0
 /**
  * @param $arData
  * @return array
  * @throws \Bitrix\Main\ArgumentException
  */
 public static function getList($arData)
 {
     $arMailing = array();
     if (isset($arData['TEST']) && $arData['TEST'] == 'Y') {
         $mailing = MailingTable::getRowById(array('ID' => $arData['MAILING_ID']));
         if ($mailing) {
             $arMailing[] = array('ID' => $mailing['ID'], 'NAME' => $mailing['NAME'], 'DESC' => $mailing['DESCRIPTION'], 'SELECTED' => true);
         }
         return $arMailing;
     }
     $mailingUnsub = array();
     $recipientUnsubDb = PostingUnsubTable::getList(array('select' => array('MAILING_ID' => 'POSTING.MAILING_ID'), 'filter' => array('=POSTING_RECIPIENT.EMAIL' => trim(strtolower($arData['EMAIL'])))));
     while ($recipientUnsub = $recipientUnsubDb->fetch()) {
         $mailingUnsub[] = $recipientUnsub['MAILING_ID'];
     }
     $mailingList = array();
     // all receives mailings
     $mailingDb = PostingRecipientTable::getList(array('select' => array('MAILING_ID' => 'POSTING.MAILING.ID'), 'filter' => array('=EMAIL' => trim(strtolower($arData['EMAIL'])), '=POSTING.MAILING.ACTIVE' => 'Y'), 'group' => array('MAILING_ID')));
     while ($mailing = $mailingDb->fetch()) {
         $mailingList[] = $mailing['MAILING_ID'];
     }
     // all subscribed mailings
     $mailingDb = MailingSubscriptionTable::getList(array('select' => array('MAILING_ID'), 'filter' => array('=CONTACT.EMAIL' => trim(strtolower($arData['EMAIL'])), '=MAILING.ACTIVE' => 'Y')));
     while ($mailing = $mailingDb->fetch()) {
         $mailingList[] = $mailing['MAILING_ID'];
     }
     $mailingList = array_unique($mailingList);
     foreach ($mailingList as $mailingId) {
         if (!in_array($mailingId, $mailingUnsub)) {
             $mailingDesc = MailingTable::getRowById($mailingId);
             if ($mailingDesc) {
                 $arMailing[] = array('ID' => $mailingDesc['ID'], 'NAME' => $mailingDesc['NAME'], 'DESC' => $mailingDesc['DESCRIPTION'], 'SELECTED' => in_array($mailingDesc['ID'], array($arData['MAILING_ID'])));
             }
         }
     }
     return $arMailing;
 }