/** * @param string $email * @param array $mailingList * @param string $siteId * @return void * //send email with url to confirmation of subscription */ public static function sendEventConfirm($email, array $mailingIdList, $siteId) { $mailingNameList = array(); $mailingDb = MailingTable::getList(array('select' => array('NAME'), 'filter' => array('ID' => $mailingIdList))); while ($mailing = $mailingDb->fetch()) { $mailingNameList[] = $mailing['NAME']; } $subscription = array('EMAIL' => $email, 'SITE_ID' => $siteId, 'MAILING_LIST' => $mailingIdList); $confirmUrl = static::getLinkSub($subscription); $date = new \Bitrix\Main\Type\DateTime(); $eventSendFields = array("EVENT_NAME" => "SENDER_SUBSCRIBE_CONFIRM", "C_FIELDS" => array("EMAIL" => $email, "DATE" => $date->toString(), "CONFIRM_URL" => $confirmUrl, "MAILING_LIST" => implode("\r\n", $mailingNameList)), "LID" => is_array($siteId) ? implode(",", $siteId) : $siteId); \Bitrix\Main\Mail\Event::send($eventSendFields); }
public static function actualizeHandlers($chainId, array $fieldsNew = null, array $fieldsOld = null) { $settingsNew = null; $settingsOld = null; if ($fieldsNew) { $settingsNew = new TriggerSettings($fieldsNew); } if ($fieldsOld) { $settingsOld = new TriggerSettings($fieldsOld); } // if old item was closed trigger if ($settingsOld && $settingsOld->isClosedTrigger()) { // delete agent $agentName = TriggerManager::getClosedEventAgentName($settingsOld->getEventModuleId(), $settingsOld->getEventType(), $chainId); $agent = new \CAgent(); $agentListDb = $agent->GetList(array(), array('MODULE_ID' => 'sender', 'NAME' => $agentName)); while ($agentItem = $agentListDb->Fetch()) { $agent->Delete($agentItem['ID']); } } // if new item is closed trigger if ($settingsNew && $settingsNew->isClosedTrigger()) { // check active state of mailing $chainDb = MailingChainTable::getList(array('select' => array('ID'), 'filter' => array('=ID' => $chainId, '=MAILING.ACTIVE' => 'Y'))); if (!$chainDb->fetch()) { return; } // add new agent $agentName = TriggerManager::getClosedEventAgentName($settingsNew->getEventModuleId(), $settingsNew->getEventType(), $chainId); // set date of next exec $agentTime = $settingsNew->getClosedTriggerTime(); $agentInterval = $settingsNew->getClosedTriggerInterval(); if ($agentInterval <= 0) { $agentInterval = 1440; } $agentTimeArray = explode(":", $agentTime); $agentDate = new \Bitrix\Main\Type\DateTime(); $agentDate->setTime((int) $agentTimeArray[0], (int) $agentTimeArray[1]); // set next exec on next day if exec was today if ($agentDate->getTimestamp() < time()) { $agentDate->add("1 days"); } // add agent $agent = new \CAgent(); $agent->AddAgent($agentName, 'sender', 'N', $agentInterval * 60, '', 'Y', $agentDate->toString()); return; } // actualize deleted/changed event if ($settingsOld && !$settingsOld->isClosedTrigger() && $settingsOld->getFullEventType()) { // if delete operation(no the NEW) // or change operation(the NEW is not equal to the OLD) if (!$settingsNew || $settingsOld->getFullEventType() != $settingsNew->getFullEventType()) { TriggerManager::actualizeHandler(array('MODULE_ID' => $settingsOld->getEventModuleId(), 'EVENT_TYPE' => $settingsOld->getEventType(), 'CALLED_BEFORE_CHANGE' => true)); } } // actualize new event if ($settingsNew && $settingsNew->getFullEventType()) { $calledBeforeChange = $fieldsOld ? false : true; TriggerManager::actualizeHandler(array('MODULE_ID' => $settingsNew->getEventModuleId(), 'EVENT_TYPE' => $settingsNew->getEventType(), 'CALLED_BEFORE_CHANGE' => $calledBeforeChange)); } }
protected function changeResponsibleUserAction() { if (!isset($this->request['user_id']) || intval($this->request['user_id']) <= 0) { throw new ArgumentNullException("user_id"); } global $USER; $dateResponsible = new \Bitrix\Main\Type\DateTime(); $userInformation = $USER->GetByID($this->request['user_id'])->Fetch(); $this->addResultData("RESPONSIBLE", array(htmlspecialcharsbx($userInformation['NAME']), htmlspecialcharsbx($userInformation['LAST_NAME']))); $this->addResultData("EMP_RESPONSIBLE", array(htmlspecialcharsbx($USER->GetFirstName()), htmlspecialcharsbx($USER->GetLastName()))); $this->addResultData("DATE_RESPONSIBLE", $dateResponsible->toString()); }