Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
admingridoption.php
1<?
2namespace Bitrix\Main\Update;
3
6
16{
17 protected static $moduleId = "main";
18
19 protected $limit = 100;
20
27 public static function setGridToConvert($tableId)
28 {
29 $listGrid = Option::get(self::$moduleId, "listGridToConvert", "");
30 if ($listGrid !== "")
31 {
32 $listGrid = unserialize($listGrid, ['allowed_classes' => false]);
33 }
34 $listGrid = is_array($listGrid) ? $listGrid : [];
35
36 if (!array_key_exists($tableId, $listGrid))
37 {
38 $listGrid[$tableId] = [
39 "offset" => 0,
40 "tableId"=> $tableId,
41 ];
42 Option::set(self::$moduleId, "listGridToConvert", serialize($listGrid));
43 }
44 }
45
46 public function execute(array &$option)
47 {
48 $listGrid = Option::get(self::$moduleId, "listGridToConvert", "");
49 if ($listGrid !== "" )
50 {
51 $listGrid = unserialize($listGrid, ['allowed_classes' => false]);
52 }
53 $listGrid = is_array($listGrid) ? $listGrid : [];
54 if (empty($listGrid))
55 {
56 Option::delete(self::$moduleId, ["name" => "listGridToConvert"]);
57 $GLOBALS["CACHE_MANAGER"]->cleanDir("user_option");
58 return false;
59 }
60
61 $connection = Application::getInstance()->getConnection();
62 $sqlHelper = $connection->getSqlHelper();
63
64 foreach ($listGrid as $tableId => $table)
65 {
66 $queryObject = $connection->query("SELECT * FROM b_user_option WHERE CATEGORY = 'list' AND NAME = '".
67 $sqlHelper->forSql($table["tableId"])."' ORDER BY ID ASC LIMIT ".$this->limit." OFFSET ".$table["offset"]);
68 $selectedRowsCount = $queryObject->getSelectedRowsCount();
69 while ($optionOldGrid = $queryObject->fetch())
70 {
71 $oldGridData = (!empty($optionOldGrid["VALUE"]) ? unserialize($optionOldGrid["VALUE"], ['allowed_classes' => false]) : []);
72
73 if (!$oldGridData)
74 {
75 continue;
76 }
77
78 $queryResultObject = $connection->query(
79 "SELECT ID FROM b_user_option WHERE CATEGORY = 'main.interface.grid' AND NAME = '".
80 $sqlHelper->forSql($table["tableId"])."' AND USER_ID = '".$optionOldGrid["USER_ID"]."'");
81 if (!$queryResultObject->fetch())
82 {
83 if (!array_diff_key(array_flip(["page_size", "by", "order", "columns"]), $oldGridData))
84 {
85 $gridOptions = new \CGridOptions($tableId);
86 $gridOptions->setSorting($oldGridData["by"], $oldGridData["order"]);
87 $gridOptions->setColumns($oldGridData["columns"]);
88 $options = $gridOptions->getOptions();
89 $options["views"]["default"]["page_size"] = intval($oldGridData["page_size"]);
90 \CUserOptions::setOption(
91 "main.interface.grid", $tableId, $options, false, $optionOldGrid["USER_ID"]);
92 }
93 }
94 }
95
96 if ($selectedRowsCount < $this->limit)
97 {
98 unset($listGrid[$tableId]);
99 }
100 else
101 {
102 $listGrid[$tableId]["offset"] = $listGrid[$tableId]["offset"] + $selectedRowsCount;
103 }
104 }
105
106 $GLOBALS["CACHE_MANAGER"]->cleanDir("user_option");
107
108 if (!empty($listGrid))
109 {
110 Option::set(self::$moduleId, "listGridToConvert", serialize($listGrid));
111 return true;
112 }
113 else
114 {
115 Option::delete(self::$moduleId, ["name" => "listGridToConvert"]);
116 return false;
117 }
118 }
119}
$GLOBALS['____1444769544']
Definition license.php:1