Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
workgroupindex.php
1<?
3
4use \Bitrix\Main\Update\Stepper;
5use \Bitrix\Main\Localization\Loc;
6use \Bitrix\Main\Config\Option;
7use \Bitrix\Main\Loader;
8use \Bitrix\Socialnetwork\WorkgroupTable;
9use \Bitrix\Socialnetwork\Item\Workgroup;
10
11Loc::loadMessages(__FILE__);
12
13final class WorkgroupIndex extends Stepper
14{
15 protected static $moduleId = "socialnetwork";
16
17 public function execute(array &$result)
18 {
19 if (!(
20 Loader::includeModule("socialnetwork")
21 && Option::get('socialnetwork', 'needWorkgroupIndex', 'Y') == 'Y'
22 ))
23 {
24 return false;
25 }
26
27 $return = false;
28
29 $params = Option::get("socialnetwork", "workgroupindex", "");
30 $params = ($params !== "" ? @unserialize($params, [ 'allowed_classes' => false ]) : array());
31 $params = (is_array($params) ? $params : array());
32 if (empty($params))
33 {
34 $params = array(
35 "lastId" => 0,
36 "number" => 0,
37 "count" => WorkgroupTable::getCount()
38 );
39 }
40
41 if ($params["count"] > 0)
42 {
43 $result["title"] = Loc::getMessage("FUPD_WORKGROUP_INDEX_TITLE");
44 $result["progress"] = 1;
45 $result["steps"] = "";
46 $result["count"] = $params["count"];
47
48 $res = WorkgroupTable::getList(array(
49 'order' => array('ID' => 'ASC'),
50 'filter' => array(
51 '>ID' => $params["lastId"]
52 ),
53 'select' => array_merge(array('ID'), Workgroup::getContentFieldsList()),
54 'offset' => 0,
55 'limit' => 100
56 ));
57
58 $found = false;
59 while ($record = $res->fetch())
60 {
62 'fields' => $record
63 ));
64
65 $params["lastId"] = $record['ID'];
66 $params["number"]++;
67 $found = true;
68 }
69
70 if ($found)
71 {
72 Option::set("socialnetwork", "workgroupindex", serialize($params));
73 $return = true;
74 }
75
76 $result["progress"] = intval($params["number"] * 100/ $params["count"]);
77 $result["steps"] = $params["number"];
78
79 if ($found === false)
80 {
81 Option::delete("socialnetwork", array("name" => "workgroupindex"));
82 Option::set('socialnetwork', 'needWorkgroupIndex', 'N');
83 }
84 }
85 return $return;
86 }
87}
88?>
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static setIndex($params=array())