Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
element.php
1<?
3
4use Bitrix\Iblock\Copy\Implement\Element as ElementImplementer;
13
14class Element extends Entity
15{
16 public function copyAction()
17 {
18 $param = $this->getParamFromRequest();
19 $params = $param->getParams();
20
21 $this->checkPermission($param, ElementRight::EDIT);
22 if ($this->getErrors())
23 {
24 return null;
25 }
26
27 $containerCollection = new ContainerCollection();
28 $containerCollection[] = new Container($params["ELEMENT_ID"]);
29
30 $elementImplementer = new ElementImplementer();
31 $elementCopier = new EntityCopier($elementImplementer);
32 $result = $elementCopier->copy($containerCollection);
33
34 if ($result->getErrors())
35 {
36 $this->addErrors($result->getErrors());
37 return null;
38
39 }
40 else
41 {
42 $resultData = $result->getData();
43 return $resultData[$params["ELEMENT_ID"]];
44 }
45 }
46
47 protected function checkPermission(Param $param, $permission)
48 {
49 global $USER;
50 $rightParam = new RightParam($param);
51 $rightParam->setUser($USER);
52 $rightParam->setEntityId(Utils::getElementId($param->getParams()));
53
54 $right = new Right($rightParam, new ElementRight($rightParam));
55 $right->checkPermission($permission);
56 if ($right->hasErrors())
57 {
58 $this->addErrors($right->getErrors());
59 }
60 }
61}
checkPermission(Param $param, $permission)
Definition element.php:47
static getElementId(array $params)
Definition utils.php:41