1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
blog_user_group_perms.php
См. документацию.
1<?php
2
4
5$GLOBALS["BLOG_USER_GROUP_PERMS"] = Array();
6
8{
9 /*************** ADD, UPDATE, DELETE *****************/
10 public static function CheckFields($ACTION, &$arFields, $ID = 0)
11 {
12 if ((is_set($arFields, "BLOG_ID") || $ACTION=="ADD") && intval($arFields["BLOG_ID"]) <= 0)
13 {
14 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GUGP_EMPTY_BLOG_ID"), "EMPTY_BLOG_ID");
15 return false;
16 }
17 elseif (is_set($arFields, "BLOG_ID"))
18 {
20 if (!$arResult)
21 {
22 $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["BLOG_ID"], GetMessage("BLG_GUGP_ERROR_NO_BLOG")), "ERROR_NO_BLOG");
23 return false;
24 }
25 }
26
27 if ((is_set($arFields, "USER_GROUP_ID") || $ACTION=="ADD") && intval($arFields["USER_GROUP_ID"]) <= 0)
28 {
29 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GUGP_EMPTY_USER_GROUP_ID"), "EMPTY_USER_GROUP_ID");
30 return false;
31 }
32 elseif (is_set($arFields, "USER_GROUP_ID"))
33 {
35 if (!$arResult)
36 {
37 $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["USER_GROUP_ID"], GetMessage("BLG_GUGP_ERROR_NO_USER_GROUP")), "ERROR_NO_USER_GROUP");
38 return false;
39 }
40 }
41
42 if ((is_set($arFields, "PERMS_TYPE") || $ACTION=="ADD") && $arFields["PERMS_TYPE"] != BLOG_PERMS_POST && $arFields["PERMS_TYPE"] != BLOG_PERMS_COMMENT)
43 {
44 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GUGP_EMPTY_PERMS_TYPE"), "EMPTY_PERMS_TYPE");
45 return false;
46 }
47
48 if ((is_set($arFields, "PERMS") || $ACTION=="ADD") && $arFields["PERMS"] == '')
49 {
50 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GUGP_EMPTY_PERMS"), "EMPTY_PERMS");
51 return false;
52 }
53 elseif (is_set($arFields, "PERMS"))
54 {
55 $arAvailPerms = array_keys($GLOBALS["AR_BLOG_PERMS"]);
56 if (!in_array($arFields["PERMS"], $arAvailPerms))
57 {
58 $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["PERMS"], GetMessage("BLG_GUGP_ERROR_NO_PERMS")), "ERROR_NO_PERMS");
59 return false;
60 }
61 }
62
63 if ((is_set($arFields, "AUTOSET") || $ACTION=="ADD") && $arFields["AUTOSET"] != "Y" && $arFields["AUTOSET"] != "N")
64 $arFields["AUTOSET"] = "N";
65
66 return True;
67 }
68
69 public static function __AutoSetPerms($ID)
70 {
71 $ID = intval($ID);
72
73 $arGroupPerms = CBlogUserGroupPerms::GetByID($ID);
74 if (intval($arGroupPerms["POST_ID"]) == 0)
75 {
76 $dbBlogPosts = CBlogPost::GetList(
77 array(),
78 array("BLOG_ID" => $arGroupPerms["BLOG_ID"]),
79 false,
80 false,
81 array("ID")
82 );
83 while ($arBlogPosts = $dbBlogPosts->Fetch())
84 {
85 $dbGroupPerms1 = CBlogUserGroupPerms::GetList(
86 array(),
87 array(
88 "BLOG_ID" => $arGroupPerms["BLOG_ID"],
89 "USER_GROUP_ID" => $arGroupPerms["USER_GROUP_ID"],
90 "PERMS_TYPE" => $arGroupPerms["PERMS_TYPE"],
91 "POST_ID" => $arBlogPosts["ID"]
92 ),
93 false,
94 false,
95 array("ID", "AUTOSET", "PERMS")
96 );
97 if ($arGroupPerms1 = $dbGroupPerms1->Fetch())
98 {
99 if ($arGroupPerms1["AUTOSET"] == "Y"
100 && $arGroupPerms["PERMS"] != $arGroupPerms1["PERMS"])
101 {
103 $arGroupPerms1["ID"],
104 array("PERMS" => $arGroupPerms["PERMS"])
105 );
106 }
107 }
108 else
109 {
111 array(
112 "BLOG_ID" => $arGroupPerms["BLOG_ID"],
113 "USER_GROUP_ID" => $arGroupPerms["USER_GROUP_ID"],
114 "PERMS_TYPE" => $arGroupPerms["PERMS_TYPE"],
115 "POST_ID" => $arBlogPosts["ID"],
116 "PERMS" => $arGroupPerms["PERMS"],
117 "AUTOSET" => "Y"
118 )
119 );
120 }
121 }
122 }
123 }
124
125 public static function Delete($ID)
126 {
127 global $DB;
128
129 $ID = intval($ID);
130
131 $arGroupPerms = CBlogUserGroupPerms::GetByID($ID);
132 if (intval($arGroupPerms["POST_ID"]) == 0)
133 {
135 array(),
136 array(
137 "BLOG_ID" => $arGroupPerms["BLOG_ID"],
138 "USER_GROUP_ID" => $arGroupPerms["USER_GROUP_ID"],
139 "PERMS_TYPE" => $arGroupPerms["PERMS_TYPE"],
140 "!POST_ID" => 0,
141 "AUTOSET" => "Y"
142 ),
143 false,
144 false,
145 array("ID")
146 );
147 while ($arResult = $dbResult->Fetch())
149 }
150
151 unset($GLOBALS["BLOG_USER_GROUP_PERMS"]["BLOG_USER_GROUP_PERMS_CACHE_".$ID]);
152
153 return $DB->Query("DELETE FROM b_blog_user_group_perms WHERE ID = ".$ID."", true);
154 }
155
156 //*************** SELECT *********************/
157 public static function GetByID($ID)
158 {
159 global $DB;
160
161 $ID = intval($ID);
162
163 if (isset($GLOBALS["BLOG_USER_GROUP_PERMS"]["BLOG_USER_GROUP_PERMS_CACHE_".$ID]) && is_array($GLOBALS["BLOG_USER_GROUP_PERMS"]["BLOG_USER_GROUP_PERMS_CACHE_".$ID]) && is_set($GLOBALS["BLOG_USER_GROUP_PERMS"]["BLOG_USER_GROUP_PERMS_CACHE_".$ID], "ID"))
164 {
165 return $GLOBALS["BLOG_USER_GROUP_PERMS"]["BLOG_USER_GROUP_PERMS_CACHE_".$ID];
166 }
167 else
168 {
169 $strSql =
170 "SELECT GP.ID, GP.BLOG_ID, GP.USER_GROUP_ID, GP.PERMS_TYPE, GP.POST_ID, ".
171 " GP.PERMS, GP.AUTOSET ".
172 "FROM b_blog_user_group_perms GP ".
173 "WHERE GP.ID = ".$ID."";
174 $dbResult = $DB->Query($strSql);
175 if ($arResult = $dbResult->Fetch())
176 {
177 $GLOBALS["BLOG_USER_GROUP_PERMS"]["BLOG_USER_GROUP_PERMS_CACHE_".$ID] = $arResult;
178 return $arResult;
179 }
180 }
181
182 return False;
183 }
184}
const BLOG_PERMS_COMMENT
Определения include.php:43
const BLOG_PERMS_POST
Определения include.php:42
$arResult
Определения generate_coupon.php:16
static GetByID($ID)
Определения blog.php:931
static GetByID($ID)
Определения blog_user_group.php:182
static Delete($ID)
Определения blog_user_group_perms.php:125
static __AutoSetPerms($ID)
Определения blog_user_group_perms.php:69
static GetByID($ID)
Определения blog_user_group_perms.php:157
static CheckFields($ACTION, &$arFields, $ID=0)
Определения blog_user_group_perms.php:10
static GetList( $arOrder=["ID"=> "DESC"], $arFilter=[], $arGroupBy=false, $arNavStartParams=false, $arSelectFields=[])
Определения blog_post.php:554
static Add($arFields)
Определения blog_user_group_perms.php:8
static GetList($arOrder=Array("ID"=> "DESC"), $arFilter=Array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения blog_user_group_perms.php:104
static Update($ID, $arFields)
Определения blog_user_group_perms.php:54
$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
$GLOBALS["BLOG_USER_GROUP_PERMS"]
Определения blog_user_group_perms.php:5
if($ajaxMode) $ID
Определения get_user.php:27
global $DB
Определения cron_frame.php:29
$ACTION
Определения csv_new_setup.php:27
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
$GLOBALS['_____370096793']
Определения update_client.php:1
$dbResult
Определения updtr957.php:3