29 $listGrid = Option::get(self::$moduleId,
"listGridToConvert",
"");
32 $listGrid = unserialize($listGrid, [
'allowed_classes' =>
false]);
34 $listGrid = is_array($listGrid) ? $listGrid : [];
36 if (!array_key_exists($tableId, $listGrid))
38 $listGrid[$tableId] = [
42 Option::set(self::$moduleId,
"listGridToConvert", serialize($listGrid));
48 $listGrid = Option::get(self::$moduleId,
"listGridToConvert",
"");
49 if ($listGrid !==
"" )
51 $listGrid = unserialize($listGrid, [
'allowed_classes' =>
false]);
53 $listGrid = is_array($listGrid) ? $listGrid : [];
56 Option::delete(self::$moduleId, [
"name" =>
"listGridToConvert"]);
57 $GLOBALS[
"CACHE_MANAGER"]->cleanDir(
"user_option");
62 $sqlHelper = $connection->getSqlHelper();
64 foreach ($listGrid as $tableId => $table)
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())
71 $oldGridData = (!empty($optionOldGrid[
"VALUE"]) ? unserialize($optionOldGrid[
"VALUE"], [
'allowed_classes' =>
false]) : []);
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())
83 if (!array_diff_key(array_flip([
"page_size",
"by",
"order",
"columns"]), $oldGridData))
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"]);
96 if ($selectedRowsCount < $this->limit)
98 unset($listGrid[$tableId]);
102 $listGrid[$tableId][
"offset"] = $listGrid[$tableId][
"offset"] + $selectedRowsCount;
106 $GLOBALS[
"CACHE_MANAGER"]->cleanDir(
"user_option");
108 if (!empty($listGrid))
110 Option::set(self::$moduleId,
"listGridToConvert", serialize($listGrid));
115 Option::delete(self::$moduleId, [
"name" =>
"listGridToConvert"]);