1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
idea_idea.php
См. документацию.
1<?
3{
4 private $IdeaId = false;
5 private $CacheStorage = array();
6 private static $CategoryIB = false;
7 private static $instance = null;
8
9 function __construct($IdeaId = false)
10 {
11 $this->SetId($IdeaId);
12 }
13
14 public static function GetInstance($IdeaId)
15 {
16 if (self::$instance === null || is_object(self::$instance) && self::$instance->IdeaId !== $IdeaId)
17 {
18 $c = __CLASS__;
19 self::$instance = new $c($IdeaId);
20 }
21
22 return self::$instance;
23 }
24
25 public function IsAvailable()
26 {
27 return $this->IdeaId>0;
28 }
29
30 public function SetID($IdeaId)
31 {
32 $this->IdeaId = $IdeaId;
33 return $this;
34 }
35
36 public function SetCategoryListID($ID)
37 {
38 if(intval($ID)>0)
39 self::$CategoryIB = intval($ID);
40
41 return $this;
42 }
43
44 public function GetCategoryListID()
45 {
46 return (int)self::$CategoryIB;
47 }
48 /*
49 * Not for USE Can be changed
50 */
51 public function GetSubCategoryList($CategoryCode)
52 {
53 if(self::$CategoryIB <= 0)
54 return array();
55
56 $arCategoryList = $this->GetCategoryList();
57 $arSubCategoryList = array($CategoryCode);
58 $arSubCategoryListId = array();
59
60 if(is_array($arCategoryList[$CategoryCode]) && $arCategoryList[$CategoryCode]["ID"]>0)
61 $arSubCategoryListId[] = $arCategoryList[$CategoryCode]["ID"];
62
63 if($arCategoryList && !empty($arSubCategoryListId))
64 {
65 foreach($arCategoryList as $key=>$arCategory)
66 {
67 if(in_array($arCategory["IBLOCK_SECTION_ID"], $arSubCategoryListId))
68 {
69 $arSubCategoryList[] = $key;
70 $arSubCategoryListId[] = $arCategory["ID"];
71 }
72 }
73 }
74
75 return array("CODE" => $arSubCategoryList, "ID" => $arSubCategoryListId);
76 }
77 /*
78 * Not for USE Can be changed
79 */
80 public function GetCategorySequence($CODE)
81 {
82 if(self::$CategoryIB <= 0 || !$CODE)
83 return array();
84
85 $arCategoryListXML = $this->GetCategoryList();
86 $arCategoryList = array();
87 foreach($arCategoryListXML as $arCategory)
88 $arCategoryList[$arCategory["ID"]] = $arCategory;
89
90 $arSequnce = array("CATEGORY_1" => false, "CATEGORY_2" => false);
91 $CODE = mb_strtoupper($CODE);
92
93 $arFullSequence = array();
94 while(array_key_exists($CODE, $arCategoryListXML))
95 {
96 array_unshift($arFullSequence, mb_strtolower($CODE));
97 if($arCategoryListXML[$CODE]["IBLOCK_SECTION_ID"]>0 && $arCategoryList[$arCategoryListXML[$CODE]["IBLOCK_SECTION_ID"]])
98 $CODE = mb_strtoupper($arCategoryList[$arCategoryListXML[$CODE]["IBLOCK_SECTION_ID"]]["CODE"]);
99 else
100 break;
101 }
102
103 if(array_key_exists(0, $arFullSequence))
104 $arSequnce["CATEGORY_1"] = $arFullSequence[0];
105 if(count($arFullSequence)>1)
106 $arSequnce["CATEGORY_2"] = end($arFullSequence);
107
108 $arSequnce["FULL"] = $arFullSequence;
109
110 return $arSequnce;
111 }
112
113 public function GetCategoryList($CategoryIB = false)
114 {
115 if(self::$CategoryIB <= 0)
116 return array();
117
118 $arCategory = array();
119 //Return an empty array if IB isn't set
120 if($CategoryIB <= 0)
121 if(($CategoryIB = self::$CategoryIB) === false)
122 return $arCategory;
123
124 if(is_array($this->CacheStorage["CATEGORY_LIST"]) && array_key_exists($CategoryIB, $this->CacheStorage["CATEGORY_LIST"]))
125 return $this->CacheStorage["CATEGORY_LIST"][$CategoryIB];
126
127 $obCache = new CPHPCache;
128 $life_time = 60*60*24*30; //over 1 month
129 $cache_id = 'idea_category_list_'.$CategoryIB; //no need to keep unique all time, just caching for 1 day if no changes
130 $cache_path = '/'.SITE_ID.'/idea/category_list/'.$CategoryIB.'/';
131
132 global $CACHE_MANAGER;
133
134 if($obCache->StartDataCache($life_time, $cache_id, $cache_path))
135 {
136 if(defined("BX_COMP_MANAGED_CACHE")) //Tag Cache
137 {
138 $CACHE_MANAGER->StartTagCache($cache_path);
139 $CACHE_MANAGER->RegisterTag("iblock_id_".$CategoryIB);
140 }
141
142 $obSec = CIBlockSection::GetList(array("left_margin"=>"ASC"), array("IBLOCK_ID" => $CategoryIB, "ACTIVE" => "Y"));
143 while($r = $obSec->GetNext())
144 if($r["CODE"] <> '')
145 $arCategory[mb_strtoupper($r["CODE"])] = $r;
146 //else
147 // $arCategory[$r["ID"]] = $r;
148
149 if(!empty($arCategory))
150 {
151 if(defined("BX_COMP_MANAGED_CACHE")) //Tag Cache
152 $CACHE_MANAGER->EndTagCache();
153
154 $obCache->EndDataCache($arCategory);
155 }
156 else
157 $obCache->AbortDataCache();
158 }
159 else
160 $arCategory = $obCache->GetVars();
161
162 return $this->CacheStorage["CATEGORY_LIST"][$CategoryIB] = $arCategory;
163 }
164 /*
165 * Not for USE Can be changed
166 */
167 public function GetDefaultStatus($arStatusPriority = array())
168 {
169 if(!is_array($arStatusPriority))
170 $arStatusPriority = array();
171
172 $arDefaultStatus = array();
173 $arStatusPriority = array_unique($arStatusPriority);
174 $arStatusList = $this->GetStatusList();
175
176 foreach ($arStatusPriority as $StatusId)
177 {
178 if(array_key_exists($StatusId, $arStatusList))
179 {
180 $arDefaultStatus = $arStatusList[$StatusId];
181 break;
182 }
183 }
184 //Not found in priority
185 if(!$arDefaultStatus)
186 {
187 foreach($arStatusList as $arStatus)
188 {
189 if(!$arDefaultStatus)
190 $arDefaultStatus = $arStatus;
191
192 if($arStatus["DEF"] == "Y")
193 {
194 $arDefaultStatus = $arStatus;
195 break;
196 }
197 }
198 }
199
200 return $arDefaultStatus;
201 }
202
203 public function GetStatusList($XML_ID = false)
204 {
205 if(is_array($this->CacheStorage["STATUS_LIST"]) && array_key_exists(intval($XML_ID), $this->CacheStorage["STATUS_LIST"]))
206 return $this->CacheStorage["STATUS_LIST"][intval($XML_ID)];
207
208 $obCache = new CPHPCache;
209 $life_time = 60*60*24*30; //over 1 month
210 $cache_id = 'idea_status_list'; //no need to keep unique all time, just caching for 1 day if no changes
211 $cache_path = '/'.SITE_ID.'/idea/status_list/';
212
213 $arStatus = array();
214 if($obCache->StartDataCache($life_time, $cache_id, $cache_path))
215 {
216 $arStatusField = CUserTypeEntity::GetList(
217 array(),
218 array(
219 "ENTITY_ID" => "BLOG_POST",
220 "FIELD_NAME" => CIdeaManagment::UFStatusField
221 )
222 )->Fetch();
223 if($arStatusField)
224 {
225 $oStatus = CUserFieldEnum::GetList(array(), array("USER_FIELD_ID" => $arStatusField["ID"]));
226 while($r = $oStatus->Fetch())
227 $arStatus[$r["ID"]] = $r;
228
229 $obCache->EndDataCache($arStatus);
230 }
231 else
232 $obCache->AbortDataCache();
233 }
234 else
235 $arStatus = $obCache->GetVars();
236
237 if($XML_ID)
238 {
239 $arStatusXML = array();
240 foreach($arStatus as $Status)
241 $arStatusXML[$Status["XML_ID"]] = $Status;
242 $arStatus = $arStatusXML;
243 }
244
245 return $this->CacheStorage["STATUS_LIST"][intval($XML_ID)] = $arStatus;
246 }
247
248 public function SetStatus($StatusId)
249 {
250 if(!$this->IsAvailable())
251 return false;
252
253 $arStatusList = $this->GetStatusList();
254 $arStatusListXML = $this->GetStatusList(true);
255
256 $arPost = CBlogPost::GetList(
257 array(),
258 array("ID" => $this->IdeaId),
259 false,
260 false,
261 array("ID", CIdeaManagment::UFStatusField)
262 )->Fetch();
263
264 $bUpdate = false;
265 //Get Status ID from XML List
266 if(array_key_exists($StatusId, $arStatusListXML))
267 $StatusId = $arStatusListXML[$StatusId]["ID"];
268 //Status Exists and not current
269 if(array_key_exists($StatusId, $arStatusList))
270 $bUpdate = $arPost[CIdeaManagment::UFStatusField] != $StatusId;
271
272 if($arPost && $bUpdate)
273 return CBlogPost::Update(
274 $this->IdeaId,
275 array(
276 CIdeaManagment::UFStatusField => $StatusId,
277 )
278 );
279
280 return false;
281 }
282
283 //%TODO%
284 public function BindDuplicate(){}
285 //%TODO%
286 public function UnBindDuplicate(){}
287}
288?>
static Update($ID, $arFields, $bSearchIndex=true)
Определения blog_post.php:224
static GetList( $arOrder=["ID"=> "DESC"], $arFilter=[], $arGroupBy=false, $arNavStartParams=false, $arSelectFields=[])
Определения blog_post.php:554
global $CACHE_MANAGER
Определения clear_component_cache.php:7
</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
GetStatusList()
Определения idea.php:317
GetCategoryListID()
Определения idea_idea.php:44
GetSubCategoryList($CategoryCode)
Определения idea_idea.php:51
GetDefaultStatus($arStatusPriority=array())
Определения idea_idea.php:167
BindDuplicate()
Определения idea_idea.php:284
GetCategoryList($CategoryIB=false)
Определения idea_idea.php:113
Class CIdeaManagmentIdea
Определения idea_idea.php:3
SetCategoryListID($ID)
Определения idea_idea.php:36
UnBindDuplicate()
Определения idea_idea.php:286
GetCategorySequence($CODE)
Определения idea_idea.php:80
SetID($IdeaId)
Определения idea_idea.php:30
IsAvailable()
Определения idea_idea.php:25
SetStatus($StatusId)
Определения idea_idea.php:248
__construct($IdeaId=false)
Определения idea_idea.php:9
$instance
Определения ps_b24_final.php:14
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