1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
idea_email_notify.php
См. документацию.
1<?
2//System, not for use
4use Bitrix\Main\Entity\ExpressionField;
5
7{
8 const SUBSCRIBE_ALL = 'A';
9 const SUBSCRIBE_ALL_IDEA = 'AI';
10 //const SUBSCRIBE_ALL_IDEA_COMMENT = 'AIC';
12
13 private $Notify = NULL;
14 private static $Enable = true;
15
16 public function __construct($parent)
17 {
18 $this->Notify = $parent;
19 }
20
21 public function IsAvailable()
22 {
23 return CModule::IncludeModule('blog') && NULL!=$this->Notify && self::$Enable;
24 }
25
26 public static function Add($Entity)
27 {
28 $notifyEmail = new \Bitrix\Idea\NotifyEmail();
29 $db_res = $notifyEmail->addIdea($Entity);
30 return (is_object($db_res) || is_array($db_res) && !empty($db_res));
31 }
32
33 public static function Delete($Entity)
34 {
35 $notifyEmail = new \Bitrix\Idea\NotifyEmail();
36 if ($Entity == 'AI' || $Entity == 'A')
37 $notifyEmail->deleteCategory('');
38 else if (mb_substr($Entity, 0, mb_strlen(self::SUBSCRIBE_IDEA_COMMENT)) == self::SUBSCRIBE_IDEA_COMMENT)
39 $notifyEmail->deleteIdea(mb_substr($Entity, mb_strlen(self::SUBSCRIBE_IDEA_COMMENT)));
40 else if (mb_strlen(intval($Entity)) == mb_strlen($Entity))
41 $notifyEmail->deleteIdea($Entity);
42 return true;
43 }
44
45 public static function GetList($order = Array(), $arFilter = Array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
46 {
47 $filter = array(
48 "LOGIC" => "AND"
49 );
50 if (is_array($arFilter))
51 {
52 foreach($arFilter as $dkey => $val)
53 {
55 if ($key["FIELD"] == "ID" && is_array($val))
56 {
57 $res = array(
58 "LOGIC" => "OR"
59 );
60 foreach ($val as $v)
61 {
62 if ($v == self::SUBSCRIBE_ALL)
63 {
64 $res[] = array("=SUBSCRIBE_TYPE" => \Bitrix\Idea\NotifyEmailTable::SUBSCRIBE_TYPE_ALL);
65 }
66 else if (mb_strpos($v, self::SUBSCRIBE_IDEA_COMMENT) === 0)
67 {
68 $res[] = array(
69 "=ENTITY_TYPE" => \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_IDEA,
70 "=ENTITY_CODE" => str_replace(self::SUBSCRIBE_IDEA_COMMENT, "", $v)
71 );
72 }
73 }
74 $filter[] = $res;
75 }
76 else if ($key["FIELD"] == "USER_ID" || $key["FIELD"] == "USER_EMAIL")
77 $filter[] = array($dkey => $val);
78 }
79 }
80 $select = array();
81 $runtime = array();
82 if (is_array($arSelectFields))
83 {
84 $select = array_intersect($arSelectFields, array_keys(\Bitrix\Idea\NotifyEmailTable::getMap()));
85 if (in_array("USER_EMAIL", $arSelectFields))
86 $select["USER_EMAIL"] = "USER.EMAIL";
87 if (in_array("ID", $arSelectFields))
88 {
89 $select["ID"] = 'RUNTIME_ID';
90 $runtime[] = new ExpressionField(
91 'RUNTIME_ID',
92 Application::getConnection()->getSqlHelper()->getConcatFunction(
93 "CASE ".
94 "WHEN %s='".\Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_IDEA."' AND %s='' THEN '".self::SUBSCRIBE_ALL."' ".
95 "WHEN %s='".\Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_IDEA."' THEN '".self::SUBSCRIBE_IDEA_COMMENT."' ".
96 "WHEN %s='".\Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_CATEGORY."' AND %s='' THEN '".self::SUBSCRIBE_ALL_IDEA."' ".
97 "WHEN %s='".\Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_CATEGORY."' THEN '".\Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_CATEGORY."' ".
98 "ELSE 'UNK' END",
99 "%s"),
100 array(
101 "ENTITY_TYPE", "ENTITY_CODE", "ENTITY_TYPE", "ENTITY_TYPE", "ENTITY_CODE", "ENTITY_TYPE", "ENTITY_CODE")
102 );
103 }
104 }
105 $db_res = \Bitrix\Idea\NotifyEmailTable::getList(
106 array(
107 'filter' => $filter,
108 'select' => $select,
109 'order' => $order,
110 'runtime' => $runtime
111 )
112 );
113 return new CDBResult($db_res);
114 }
115
116 public function Send()
117 {
118 if(!$this->IsAvailable())
119 return false;
120
121 $arNotification = $this->Notify->getNotification();
122
123 //No need to send about updates;
124 if($arNotification["ACTION"] == "UPDATE")
125 return 0;
126 $category = mb_strtoupper($arNotification["CATEGORY"]);
127 $arEmailSubscribe = array();
128 if (!array_key_exists("CATEGORIES", $arNotification))
129 $arNotification["CATEGORIES"] = \CIdeaManagment::getInstance()->Idea()->GetCategoryList();
130 if (array_key_exists($category, $arNotification["CATEGORIES"]) && \CIdeaManagment::getInstance()->Idea()->GetCategoryListID() > 0)
131 $category = $arNotification["CATEGORIES"][$category];
132 else
133 $category = null;
134
135 if ($arNotification["TYPE"] == "IDEA") // (COMMENT, IDEA)
136 {
137 $filter = array(
138 "LOGIC" => "OR",
139 array(
140 "=ENTITY_TYPE" => \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_CATEGORY,
141 "=ENTITY_CODE" => '',
142 )
143 );
144 if (!is_null($category))
145 {
146 $filter[] = array(
147 "=ENTITY_TYPE" => \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_CATEGORY,
148 "=ASCENDED_CATEGORIES.IBLOCK_ID" => \CIdeaManagment::getInstance()->Idea()->GetCategoryListID(),
149 "<=ASCENDED_CATEGORIES.DEPTH_LEVEL" => $category["DEPTH_LEVEL"],
150 "<=ASCENDED_CATEGORIES.LEFT_MARGIN" => $category["LEFT_MARGIN"],
151 ">=ASCENDED_CATEGORIES.RIGHT_MARGIN" => $category["RIGHT_MARGIN"]
152 );
153 }
154 }
155 else
156 {
157 $filter = array(
158 "LOGIC" => "OR",
159 array(
160 "=ENTITY_TYPE" => \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_IDEA,
161 "=ENTITY_CODE" => $arNotification["POST_ID"],
162 ),
163 array(
164 "=SUBSCRIBE_TYPE" => \Bitrix\Idea\NotifyEmailTable::SUBSCRIBE_TYPE_ALL,
165 "=ENTITY_TYPE" => \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_CATEGORY,
166 "=ENTITY_CODE" => ''
167 )
168 );
169 if (!is_null($category))
170 {
171 $filter[] = array(
172 "=SUBSCRIBE_TYPE" => \Bitrix\Idea\NotifyEmailTable::SUBSCRIBE_TYPE_ALL,
173 "=ENTITY_TYPE" => \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_CATEGORY,
174 "=ASCENDED_CATEGORIES.IBLOCK_ID" => \CIdeaManagment::getInstance()->Idea()->GetCategoryListID(),
175 "<=ASCENDED_CATEGORIES.DEPTH_LEVEL" => $category["DEPTH_LEVEL"],
176 "<=ASCENDED_CATEGORIES.LEFT_MARGIN" => $category["LEFT_MARGIN"],
177 ">=ASCENDED_CATEGORIES.RIGHT_MARGIN" => $category["RIGHT_MARGIN"]
178 );
179 }
180 }
181
182 $db_res = \Bitrix\Idea\NotifyEmailTable::getList(
183 array(
184 'filter' => $filter,
185 'select' => array("USER_ID", "USER_EMAIL" => "USER.EMAIL")
186 )
187 );
188
189 if (!is_null($category))
190 $arNotification["CATEGORY"] = $category["NAME"];
191 unset($arNotification["CATEGORIES"]);
192 if (!array_key_exists("IDEA_TITLE", $arNotification))
193 $arNotification["IDEA_TITLE"] = $arNotification["TITLE"];
194
195 while($r = $db_res->Fetch())
196 {
197 if($r["USER_ID"] != $arNotification["AUTHOR_ID"] && !array_key_exists($r["USER_ID"], $arEmailSubscribe) && check_email($r["USER_EMAIL"]))
198 {
199 $arEmailSubscribe[$r["USER_ID"]] = $r["USER_EMAIL"];
200
201 $arNotification["EMIAL_TO"] = $r["USER_EMAIL"]; //This is for backward compatibility
202 $arNotification["EMAIL_TO"] = $r["USER_EMAIL"];
203 //ADD_IDEA_COMMENT, ADD_IDEA
204 CEvent::Send($arNotification["ACTION"].'_'.$arNotification["TYPE"], SITE_ID, $arNotification);
205 }
206 }
207 return count($arEmailSubscribe) > 0;
208 }
209
210 public function Disable()
211 {
212 self::$Enable = false;
213 }
214
215 public function Enable()
216 {
217 self::$Enable = true;
218 }
219}
220?>
$db_res
Определения options_user_settings.php:8
static GetFilterOperation($key)
Определения sql_util.php:45
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$select
Определения iblock_catalog_list.php:194
$filter
Определения iblock_catalog_list.php:54
Idea($IdeaId=false)
Определения idea.php:41
Disable()
Определения idea_email_notify.php:210
const SUBSCRIBE_IDEA_COMMENT
Определения idea_email_notify.php:11
Class CIdeaManagmentEmailNotify
Определения idea_email_notify.php:7
const SUBSCRIBE_ALL_IDEA
Определения idea_email_notify.php:9
__construct($parent)
Определения idea_email_notify.php:16
IsAvailable()
Определения idea_email_notify.php:21
Send()
Определения idea_email_notify.php:116
Enable()
Определения idea_email_notify.php:215
GetCategoryListID()
Определения idea_idea.php:44
check_email($email, $strict=false, $domainCheck=false)
Определения tools.php:4571
$order
Определения payment.php:8
if(empty($signedUserToken)) $key
Определения quickway.php:257
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$val
Определения options.php:1793
const SITE_ID
Определения sonet_set_content_view.php:12
$arFilter
Определения user_search.php:106