public function unsubscribeAction($AData = null) { if (empty($AData)) { Redirect('/'); } // только залогинившиеся пользователи могут отписаться от рассылки if (!isset($_SESSION['auth']) || empty($_SESSION['auth']['email'])) { $_SESSION['login_redirect'] = '/email/unsubscribe/' . $AData; Redirect('/auth/login'); } $params = explode('||', Decrypt_Blowfish($AData, EMAIL_BLOWFISHGUID)); try { if (Emails_IsNotifyRecipientActive($params[0], $params[1], $_SESSION['auth']['email'])) { Emails_DeleteNotifyRecipient($params[0], $params[1], $_SESSION['auth']['email']); return AddAlertMessage('success', 'Подписка на рассылку уведомлений была отменена!', '/'); } else { return AddAlertMessage('info', 'Вы уже не подписаны на данную рассылку!', '/'); } } catch (Exception $exc) { return AddAlertMessage('danger', 'Ошибка при отмене подписки на рассылку уведомлений!', '/'); } }
$sql = "insert into ArticleComments(ArticleID, UnknownUserGUID, UserID, UserName, CommentDate, Comment) " . "values({$id}, '{$vUnknownUserGUID}', {$vUserID}, '{$UserName}', '" . GetLocalDateTimeAsSQLStr() . "', '{$Comment}');"; GetMainConnection()->exec($sql); /*$sql = "insert into CatalogRatings(CatalogItemID, UserID, UnknownUserGUID, Rating1, Rating2, Rating3) ". "select * from (select $id as C1, $vUserIDForIns as C2, $vUnknownUserGUIDForIns as C3, $Rating1 as C4, $Rating2 as C5, $Rating3 as C6) AS tmp ". "where not exists ( ". "select ID ". "from CatalogRatings ". "where (CatalogItemID = $id) ". "and (UserID $vUserID) ". "and (UnknownUserGUID $vUnknownUserGUID) ". ") limit 1;";*/ if (POSTBoolAsSQLStr('PriorNotifyStateEdt') != $IsNotifyRecipientActive) { if ($IsNotifyRecipientActive == '1') { Emails_AddNotifyRecipient(1, $id, $OwnerEmail); } else { Emails_DeleteNotifyRecipient(1, $id, $OwnerEmail); } } $sql = "select CategoryID, Name from Articles where (ID = {$id});"; $rec = GetMainConnection()->query($sql)->fetch(); $vBodyParam = array('[year]' => date("Y", time()), '[name]' => $UserName, '[msgbody]' => $Comment, '[doclink]' => URL . 'articles/c-' . $rec['CategoryID'] . '/a-' . $id, '[unsubscribe]' => URL . 'email/unsubscribe/' . Encrypt_Blowfish('1||' . $id, EMAIL_BLOWFISHGUID)); $vBody = Emails_PrepareBodyUseTemplate('article_comment', $vBodyParam); Emails_AddNotify(1, $id, 'Новый комментарий к статье: "' . $rec['Name'] . '"', $vBody, $OwnerEmail); /*$content = array( 'title' => 'Re: '.$rec['MessageSubject'], 'template' => 'answercontactus', 'data' => array('[year]' => date("Y",time()), '[name]' => $rec['UserName'], '[msgbody]' => $vAnswerText ) );