Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
userstepper.php
1<?
2namespace Bitrix\Main\Update;
3
6
7Loc::loadMessages(__FILE__);
8
9final class UserStepper extends Stepper
10{
11 const OPTION_NAME = "main_index_user";
12 protected static $moduleId = "main";
13
17 public function execute(array &$result)
18 {
19 $return = false;
20
21 $params = Option::get(self::$moduleId, self::OPTION_NAME, "");
22 $params = ($params !== "" ? @unserialize($params, ['allowed_classes' => false]) : array());
23 $params = (is_array($params) ? $params : array());
24 if (empty($params))
25 {
26 $params = array(
27 "lastId" => 0,
28 "number" => 0,
29 "count" => \Bitrix\Main\UserTable::getCount(),
30 );
31 }
32
33 if ($params["count"] > 0)
34 {
35 $result["title"] = Loc::getMessage("MAIN_UPDATE_USER_INDEX");
36 $result["progress"] = 1;
37 $result["steps"] = "";
38 $result["count"] = $params["count"];
39
40 $cursor = \Bitrix\Main\UserTable::getList(array(
41 'order' => array('ID' => 'ASC'),
42 'filter' => array(
43 '>ID' => $params["lastId"],
44 ),
45 'select' => array('ID'),
46 'offset' => 0,
47 'limit' => 100
48 ));
49
50 $found = false;
51 while ($row = $cursor->fetch())
52 {
53 \Bitrix\Main\UserTable::indexRecord($row['ID']);
54
55 $params["lastId"] = $row['ID'];
56 $params["number"]++;
57 $found = true;
58 }
59
60 if ($found)
61 {
62 Option::set(self::$moduleId, self::OPTION_NAME, serialize($params));
63 $return = true;
64 }
65
66 $result["progress"] = intval($params["number"] * 100/ $params["count"]);
67 $result["steps"] = $params["number"];
68
69 if ($found === false)
70 {
71 Option::delete(self::$moduleId, array("name" => self::OPTION_NAME));
72 }
73 }
74 return $return;
75 }
76}
77?>
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getCount($filter=array(), array $cache=array())