1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
group_subject.php
См. документацию.
1<?php
2
4
6{
7 /***************************************/
8 /******** DATA MODIFICATION **********/
9 /***************************************/
10 public static function CheckFields($ACTION, &$arFields, $ID = 0)
11 {
12 global $APPLICATION;
13
14 if ($ACTION != "ADD" && intval($ID) <= 0)
15 {
16 $APPLICATION->ThrowException("System error 870164", "ERROR");
17 return false;
18 }
19
20 if ((is_set($arFields, "SITE_ID") || $ACTION=="ADD")
21 && (
22 (is_array($arFields["SITE_ID"]) && count($arFields["SITE_ID"]) <= 0)
23 ||
24 (!is_array($arFields["SITE_ID"]) && $arFields["SITE_ID"] == '')
25 )
26 )
27 {
28 $APPLICATION->ThrowException(GetMessage("SONET_GS_EMPTY_SITE_ID"), "EMPTY_SITE_ID");
29 return false;
30 }
31 elseif (is_set($arFields, "SITE_ID"))
32 {
33 if(!is_array($arFields["SITE_ID"]))
34 $arFields["SITE_ID"] = array($arFields["SITE_ID"]);
35
36 foreach($arFields["SITE_ID"] as $v)
37 {
38 $dbResult = CSite::GetByID($v);
39 if (!$dbResult->Fetch())
40 {
41 $APPLICATION->ThrowException(str_replace("#ID#", $v, GetMessage("SONET_GS_ERROR_NO_SITE")), "ERROR_NO_SITE");
42 return false;
43 }
44 }
45 }
46
47 if ((is_set($arFields, "NAME") || $ACTION=="ADD") && $arFields["NAME"] == '')
48 {
49 $APPLICATION->ThrowException(GetMessage("SONET_GS_EMPTY_NAME"), "EMPTY_NAME");
50 return false;
51 }
52
53 if (is_set($arFields, "SORT") || $ACTION=="ADD")
54 $arFields["SORT"] = (intval($arFields["SORT"]) > 0 ? intval($arFields["SORT"]) : 100);
55
56 return True;
57 }
58
59 public static function Delete($ID)
60 {
62
63 if (!CSocNetGroup::__ValidateID($ID))
64 return false;
65
66 $ID = intval($ID);
67
68 $bCanDelete = true;
69 $dbResult = CSocNetGroup::GetList(
70 array(),
71 array("SUBJECT_ID" => $ID)
72 );
73 if ($arResult = $dbResult->Fetch())
74 $bCanDelete = false;
75
76 if (!$bCanDelete)
77 {
78 $APPLICATION->ThrowException(GetMessage("SONET_GS_NOT_EMPTY_SUBJECT"), "NOT_EMPTY_SUBJECT");
79 return false;
80 }
81
82 $events = GetModuleEvents("socialnetwork", "OnSocNetGroupSubjectDelete");
83 while ($arEvent = $events->Fetch())
84 {
85 ExecuteModuleEventEx($arEvent, array($ID));
86 }
87
88 $bSuccess = $DB->Query("DELETE FROM b_sonet_group_subject_site WHERE SUBJECT_ID = ".$ID."", true);
89
90 if ($bSuccess)
91 $bSuccess = $DB->Query("DELETE FROM b_sonet_group_subject WHERE ID = ".$ID."", true);
92
93 if (CACHED_b_sonet_group_subjects != false)
94 $CACHE_MANAGER->CleanDir("b_sonet_group_subjects");
95
96 return $bSuccess;
97 }
98
99 public static function Update($ID, $arFields)
100 {
101 global $DB, $CACHE_MANAGER;
102
103 if (!CSocNetGroup::__ValidateID($ID))
104 return false;
105
106 $ID = intval($ID);
107
109
111 return false;
112 else
113 {
114 $arSiteID = Array();
115 if(is_set($arFields, "SITE_ID"))
116 {
117 if(is_array($arFields["SITE_ID"]))
118 $arSiteID = $arFields["SITE_ID"];
119 else
120 $arSiteID[] = $arFields["SITE_ID"];
121
122 $arFields["SITE_ID"] = false;
123 $str_SiteID = "''";
124 foreach($arSiteID as $v)
125 {
126 $arFields["SITE_ID"] = $v;
127 $str_SiteID .= ", '".$DB->ForSql($v)."'";
128 }
129 }
130 }
131
132 $strUpdate = $DB->PrepareUpdate("b_sonet_group_subject", $arFields);
134
135 if ($strUpdate <> '')
136 {
137 $strSql =
138 "UPDATE b_sonet_group_subject SET ".
139 " ".$strUpdate." ".
140 "WHERE ID = ".$ID." ";
141 $DB->Query($strSql);
142
143 if(count($arSiteID)>0)
144 {
145 $strSql = "DELETE FROM b_sonet_group_subject_site WHERE SUBJECT_ID=".$ID;
146 $DB->Query($strSql);
147
148 $strSql =
149 "INSERT INTO b_sonet_group_subject_site(SUBJECT_ID, SITE_ID) ".
150 "SELECT ".$ID.", LID ".
151 "FROM b_lang ".
152 "WHERE LID IN (".$str_SiteID.") ";
153 $DB->Query($strSql);
154 }
155
156 $events = GetModuleEvents("socialnetwork", "OnSocNetGroupSubjectUpdate");
157 while ($arEvent = $events->Fetch())
158 {
160 }
161
162 if (CACHED_b_sonet_group_subjects != false)
163 $CACHE_MANAGER->CleanDir("b_sonet_group_subjects");
164 }
165 else
166 $ID = False;
167
168 return $ID;
169 }
170
171 /***************************************/
172 /********** DATA SELECTION ***********/
173 /***************************************/
174 public static function GetByID($ID)
175 {
176 if (!CSocNetGroup::__ValidateID($ID))
177 return false;
178
179 $ID = intval($ID);
180
181 $dbResult = CSocNetGroupSubject::GetList(Array(), Array("ID" => $ID));
182 if ($arResult = $dbResult->GetNext())
183 return $arResult;
184
185 return False;
186 }
187
188 public static function GetSite($subject_id)
189 {
190 global $DB;
191 $strSql = "SELECT L.*, SGSS.* FROM b_sonet_group_subject_site SGSS, b_lang L WHERE L.LID=SGSS.SITE_ID AND SGSS.SUBJECT_ID=".intval($subject_id);
192 return $DB->Query($strSql);
193 }
194}
global $APPLICATION
Определения include.php:80
$arResult
Определения generate_coupon.php:16
static processEqualityFieldsToUpdate($fields1, &$update)
Определения util.php:239
static getEqualityFields(&$fields)
Определения util.php:207
static Delete($ID)
Определения group_subject.php:59
static GetByID($ID)
Определения group_subject.php:174
static CheckFields($ACTION, &$arFields, $ID=0)
Определения group_subject.php:10
static Update($ID, $arFields)
Определения group_subject.php:99
static GetSite($subject_id)
Определения group_subject.php:188
global $CACHE_MANAGER
Определения clear_component_cache.php:7
$arFields
Определения dblapprove.php:5
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if($ajaxMode) $ID
Определения get_user.php:27
global $DB
Определения cron_frame.php:29
$ACTION
Определения csv_new_setup.php:27
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
is_set($a, $k=false)
Определения tools.php:2133
GetMessage($name, $aReplace=null)
Определения tools.php:3397
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
</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
$dbResult
Определения updtr957.php:3