18 private $executiveUserId;
19 private $features = [];
21 public function __construct($executiveUserId = 0, array $features = [])
23 $this->executiveUserId = $executiveUserId;
24 $this->features = $features;
27 public function copy($groupId, $copiedGroupId)
29 if (!Loader::includeModule(
"iblock") || !Loader::includeModule(
"socialnetwork"))
34 $this->addToQueue($copiedGroupId);
36 Option::set(self::MODULE_ID, self::CHECKER_OPTION.$copiedGroupId,
"Y");
38 $sectionName = $this->getSectionName($groupId);
39 $parentSectionId = $this->getParentSectionId($groupId, $sectionName);
40 $newSectionName = $this->getNewSectionName($copiedGroupId);
41 if (!$parentSectionId)
47 "copiedGroupId" => $copiedGroupId,
48 "parentSectionId" => $parentSectionId,
49 "newSectionName" => $newSectionName,
51 Option::set(self::MODULE_ID, self::STEPPER_OPTION.$copiedGroupId, serialize($queueOption));
53 $agent = \CAgent::getList([], [
54 "MODULE_ID" => self::MODULE_ID,
55 "NAME" => GroupStepper::class.
"::execAgent();"
59 GroupStepper::bind(1);
63 private function getParentSectionId($groupId, $sectionName)
67 $res = \CIBlockSection::getList([], [
"NAME" => $sectionName,
"SOCNET_GROUP_ID" => $groupId],
false, [
"ID"]);
68 if ($section = $res->fetch())
70 $parentSectionId = $section[
"ID"];
73 return $parentSectionId;
76 private function getSectionName($groupId)
78 $fields = \CSocNetGroup::getByID($groupId);
79 return Loc::getMessage(
"GROUP_FEATURE_SECTION_NAME_PREFIX").$fields[
"NAME"];
82 private function getNewSectionName($copiedGroupId)
84 $fields = \CSocNetGroup::getByID($copiedGroupId);
85 return Loc::getMessage(
"GROUP_FEATURE_SECTION_NAME_PREFIX").$fields[
"NAME"];
88 private function addToQueue(
int $copiedGroupId)
90 $option = Option::get(self::MODULE_ID, self::QUEUE_OPTION,
"");
91 $option = ($option !==
"" ? unserialize($option, [
'allowed_classes' =>
false]) : []);
92 $option = (is_array($option) ? $option : []);
94 $option[] = $copiedGroupId;
95 Option::set(self::MODULE_ID, self::QUEUE_OPTION, serialize($option));
static getMessage($code, $replace=null, $language=null)