1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
dbtools.php
См. документацию.
1<?
4{
5 /*
6 * RegisterModuleDependences('forum', 'CollectDBUpdater', 'forum', '', '');
7 */
8
9 static function GetDBUpdaters()
10 {
11 $rsHandlers = GetModuleEvents("forum", "CollectDBUpdater");
12 while($arHandler = $rsHandlers->Fetch())
13 {
14 ExecuteModuleEventEx($arHandler, array());
15 }
16 }
17
18 static function Unregister($caller)
19 {
20 if (is_array($caller) && isset($caller['module']) && isset($caller['class']) && isset($caller['method']))
21 {
23 'forum',
24 'CollectDBUpdater',
25 $caller['module'],
26 $caller['class'],
27 $caller['method']
28 );
29 }
30 }
31
32 static function ShowOffer($TRIGGER, $message)
33 {
34?>
35 <div style='background-color:#ffffcc; border: 1px solid #ff8888; padding: 10px; margin: 5px 0; font-size:80%; '>
36 <div style='float: right; width: 150px; margin-top:-5px;'>
37 <form action="<?=POST_FORM_ACTION_URI?>" method="POST">
38 <input type="hidden" name="<?=htmlspecialcharsbx($TRIGGER)?>" value="Y" />
40 <input type="submit" value="<?=GetMessage('F_DB_GO')?>" />
41 </form>
42 </div>
44 </div>
45<?
46 }
47
48 static function ShowMessage($message, $error = false)
49 {
50 $background = ($error ? '#ffcccc' : '#ccffcc');
51?>
52 <div style='background-color:<?=$background?>; border: 1px solid #ff8888; padding: 10px; margin: 5px 0; font-size:80%;'>
54 </div>
55<?
56 }
57
58 static function Alter($arParams)
59 {
60 global $APPLICATION, $DB;
61 $TRIGGER = $arParams['TRIGGER'];
62
63 if (in_array($DB->type, array('MSSQL', 'ORACLE'))) // uppercase
64 {
65 $arUpperCaseFields = array('TABLE', 'FIELDS', 'INDEX', 'COMMAND');
66 foreach($arUpperCaseFields as $fn)
67 {
68 if (isset($arParams[$fn]))
69 {
70 if (!is_array($arParams[$fn]))
71 $arParams[$fn] = mb_strtoupper($arParams[$fn]);
72 else
73 $arParams[$fn] = array_map('strtoupper', $arParams[$fn]);
74 }
75 }
76 }
77
78 $arMsgParams = array();
79 foreach($arParams as $paramName => $paramValue)
80 {
81 if (is_array($paramValue))
82 {
83 $arMsgParams["#$paramName#"] = htmlspecialcharsbx(implode(', ', $paramValue));
84 }
85 else
86 {
87 $arMsgParams["#$paramName#"] = htmlspecialcharsbx($paramValue);
88 }
89 }
90
91 $msg_success = GetMessage('F_DB_'.$arParams['mode'].'_SUCCESS', $arMsgParams);
92 $msg_fail = GetMessage('F_DB_'.$arParams['mode'].'_FAIL', $arMsgParams);
93 $msg_offer = GetMessage('F_DB_'.$arParams['mode'].'_OFFER', $arMsgParams);
94
95 if (
96 (
97 ($arParams['mode'] == 'DROPINDEX') &&
98 $DB->TableExists($arParams['TABLE']) &&
99 ($DB->GetIndexName($arParams['TABLE'], $arParams['FIELDS'], true) !== '')
100 ) || (
101 ($arParams['mode'] == 'CREATEINDEX') &&
102 $DB->TableExists($arParams['TABLE']) &&
103 ($DB->GetIndexName($arParams['TABLE'], $arParams['FIELDS'], true) === '')
104 )
105 )
106 {
107 if (isset($_REQUEST[$TRIGGER]) && check_bitrix_sessid())
108 {
109 if ($arParams['mode'] == 'DROPINDEX')
110 {
111 $indexName = $DB->GetIndexName($arParams['TABLE'], $arParams['FIELDS'], true);
112 $arParams['COMMAND'] = str_replace($arParams['INDEX'], $indexName, $arParams['COMMAND']);
113 if ($DB->type == 'ORACLE')
114 {
115 $arCommand = array_filter(explode(' ',$arParams['COMMAND']));
116 $arOraCommand = array_slice($arCommand, 0, 3);
117 $arParams['COMMAND'] = implode(' ', $arOraCommand);
118 }
119 }
120 // semafor ?
121 $result = $DB->Query($arParams['COMMAND'], true);
122 if ($result !== false)
123 {
124 self::Unregister($arParams['caller']);
125 self::ShowMessage($msg_success);
126 }
127 else
128 {
129 self::Unregister($arParams['caller']);
130 self::ShowMessage($msg_fail, true);
131 }
132 }
133 else
134 {
135 self::ShowOffer($TRIGGER, $msg_offer);
136 }
137 }
138 else
139 {
140 // local setup differs from expected
141 self::Unregister($arParams['caller']);
142 }
143 return;
144 }
145
146 static function DropIndex_message_TA()
147 {
148 global $DB;
149
150 $TRIGGER = 'drop_mTA';
151 $caller = array('module'=> 'forum', 'class'=>__CLASS__, 'method'=>__FUNCTION__);
152
153 if ($DB->type == 'MYSQL')
154 {
156 'TRIGGER' => $TRIGGER,
157 'mode' => 'DROPINDEX',
158 'caller' => $caller,
159 'INDEX' => 'IX_FORUM_MESSAGE_TOPIC',
160 'TABLE' => 'b_forum_message',
161 'FIELDS' => array('TOPIC_ID', 'APPROVED'),
162 'COMMAND' => "drop index IX_FORUM_MESSAGE_TOPIC on b_forum_message"
163 );
165 }
166 else
167 {
168 self::Unregister($caller);
169 }
170 }
171
172 static function CreateIndex_message_TAI()
173 {
174 global $DB;
175
176 $caller = array('module'=> 'forum', 'class'=>__CLASS__, 'method'=>__FUNCTION__);
177 $TRIGGER = 'create_mTAI';
178
179 if ($DB->type == 'MYSQL')
180 {
182 'TRIGGER' => $TRIGGER,
183 'mode' => 'CREATEINDEX',
184 'caller' => $caller,
185 'INDEX' => 'IX_FORUM_MESSAGE_TOPIC_AI',
186 'TABLE' => 'b_forum_message',
187 'FIELDS' => array('TOPIC_ID', 'APPROVED', 'ID'),
188 'COMMAND' => "create index IX_FORUM_MESSAGE_TOPIC_AI on b_forum_message(TOPIC_ID, APPROVED, ID)"
189 );
191 }
192 else
193 {
194 self::Unregister($caller);
195 }
196 }
197
198 static function DropIndex_message_AAF()
199 {
200 global $DB;
201
202 $TRIGGER = 'drop_mAAF';
203 $caller = array('module'=> 'forum', 'class'=>__CLASS__, 'method'=>__FUNCTION__);
204
205 if ($DB->type == 'MYSQL')
206 {
208 'TRIGGER' => $TRIGGER,
209 'mode' => 'DROPINDEX',
210 'caller' => $caller,
211 'INDEX' => 'IX_FORUM_MESSAGE_AUTHOR',
212 'TABLE' => 'b_forum_message',
213 'FIELDS' => array('AUTHOR_ID', 'APPROVED', 'FORUM_ID'),
214 'COMMAND' => "drop index IX_FORUM_MESSAGE_AUTHOR on b_forum_message"
215 );
217 }
218 else
219 {
220 self::Unregister($caller);
221 }
222 }
223
224 static function CreateIndex_message_AAFI()
225 {
226 global $DB;
227
228 $caller = array('module'=> 'forum', 'class'=>__CLASS__, 'method'=>__FUNCTION__);
229 $TRIGGER = 'create_mAAFI';
230
231 if ($DB->type == 'MYSQL')
232 {
234 'TRIGGER' => $TRIGGER,
235 'mode' => 'CREATEINDEX',
236 'caller' => $caller,
237 'INDEX' => 'IX_FORUM_MESSAGE_AUTHOR2',
238 'TABLE' => 'b_forum_message',
239 'FIELDS' => array('AUTHOR_ID', 'APPROVED', 'FORUM_ID', 'ID'),
240 'COMMAND' => "create index IX_FORUM_MESSAGE_AUTHOR2 on b_forum_message(AUTHOR_ID, APPROVED, FORUM_ID, ID)"
241 );
243 }
244 else
245 {
246 self::Unregister($caller);
247 }
248 }
249
250 static function CreateIndex_message_ATI()
251 {
252 global $DB;
253
254 $caller = array('module'=> 'forum', 'class'=>__CLASS__, 'method'=>__FUNCTION__);
255 $TRIGGER = 'create_mATI';
256
257 if (in_array($DB->type, array('MYSQL', 'MSSQL', 'ORACLE')))
258 {
260 'TRIGGER' => $TRIGGER,
261 'mode' => 'CREATEINDEX',
262 'caller' => $caller,
263 'INDEX' => 'IX_FORUM_MESSAGE_AUTH_TOPIC_ID',
264 'TABLE' => 'b_forum_message',
265 'FIELDS' => array('AUTHOR_ID', 'TOPIC_ID', 'ID'),
266 'COMMAND' => "create index IX_FORUM_MESSAGE_AUTH_TOPIC_ID on b_forum_message(AUTHOR_ID, TOPIC_ID, ID)"
267 );
269 }
270 else
271 {
272 self::Unregister($caller);
273 }
274 }
275
277 {
278 global $DB;
279
280 $caller = array('module'=> 'forum', 'class'=>__CLASS__, 'method'=>__FUNCTION__);
281 $TRIGGER = 'create_mAFIAT';
282
283 if (in_array($DB->type, array('MYSQL', 'MSSQL', 'ORACLE')))
284 {
286 'TRIGGER' => $TRIGGER,
287 'mode' => 'CREATEINDEX',
288 'caller' => $caller,
289 'INDEX' => 'IX_FORUM_MESSAGE_AUTH_FORUM_ID',
290 'TABLE' => 'b_forum_message',
291 'FIELDS' => array('AUTHOR_ID', 'FORUM_ID', 'ID', 'APPROVED', 'TOPIC_ID'),
292 'COMMAND' => "create index IX_FORUM_MESSAGE_AUTH_FORUM_ID on b_forum_message(AUTHOR_ID, FORUM_ID, ID, APPROVED, TOPIC_ID)"
293 );
295 }
296 else
297 {
298 self::Unregister($caller);
299 }
300 }
301}
302?>
$arParams
Определения access_dialog.php:21
global $APPLICATION
Определения include.php:80
Определения dbtools.php:4
static CreateIndex_message_TAI()
Определения dbtools.php:172
static ShowOffer($TRIGGER, $message)
Определения dbtools.php:32
static CreateIndex_message_AAFI()
Определения dbtools.php:224
static DropIndex_message_TA()
Определения dbtools.php:146
static Unregister($caller)
Определения dbtools.php:18
static CreateIndex_message_AFIAT()
Определения dbtools.php:276
static ShowMessage($message, $error=false)
Определения dbtools.php:48
static DropIndex_message_AAF()
Определения dbtools.php:198
static GetDBUpdaters()
Определения dbtools.php:9
static CreateIndex_message_ATI()
Определения dbtools.php:250
static Alter($arParams)
Определения dbtools.php:58
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$_REQUEST["admin_mnu_menu_id"]
Определения get_menu.php:8
$result
Определения get_property_values.php:14
ShowMessage()
Определения idea_sonet_notify.php:443
global $DB
Определения cron_frame.php:29
bitrix_sessid_post($varname='sessid', $returnInvocations=false)
Определения tools.php:4700
check_bitrix_sessid($varname='sessid')
Определения tools.php:4686
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
UnRegisterModuleDependences($FROM_MODULE_ID, $MESSAGE_ID, $TO_MODULE_ID, $TO_CLASS="", $TO_METHOD="", $TO_PATH="", $TO_METHOD_ARG=[])
Определения tools.php:5289
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$message
Определения payment.php:8
font style
Определения invoice.php:442
$background
Определения html.php:27
$error
Определения subscription_card_product.php:20