403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/bizproc/lib/Api/Service/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/bizproc/lib/Api/Service/UserService.php
<?php

namespace Bitrix\Bizproc\Api\Service;

use Bitrix\Bizproc\Api\Data\UserService\UsersToGet;
use Bitrix\Bizproc\Api\Response\UserService\GetCurrentUserResponse;
use Bitrix\Bizproc\Api\Response\UserService\GetUsersViewResponse;
use Bitrix\Bizproc\UI\UserView;
use Bitrix\Main\Engine\CurrentUser;
use Bitrix\Main\Loader;
use Bitrix\Main\UserTable;

class UserService
{
	public function getUsersView(UsersToGet $request): GetUsersViewResponse
	{
		$currentUserResponse = $this->getCurrentUser();
		if (!$currentUserResponse->isSuccess())
		{
			$response = new GetUsersViewResponse();
			$response->addErrors($currentUserResponse->getErrors());

			return $response;
		}

		$ids = $request->getUserIds();

		if (!$ids)
		{
			return new GetUsersViewResponse();
		}

		$userIterator = UserTable::query()
			->setSelect(['ID', 'NAME', 'LAST_NAME', 'SECOND_NAME', 'LOGIN', 'PERSONAL_PHOTO', 'WORK_POSITION'])
			->setFilter(['ID' => $ids])
			->exec()
		;

		$response = new GetUsersViewResponse();
		while ($user = $userIterator->fetchObject())
		{
			$response->addUserView(new UserView($user));
		}

		return $response;
	}

	public function getCurrentUser(): GetCurrentUserResponse
	{
		$currentUser = CurrentUser::get();

		if (!$this->isAuthorised((int)$currentUser->getId()))
		{
			return GetCurrentUserResponse::createUnauthorizedError();
		}

		return GetCurrentUserResponse::createOk(['user' => $currentUser]);
	}

	public function isAuthorised(int $userId): bool
	{
		return $userId > 0;
	}

	public function isCurrentUserPortalAdmin(): bool
	{
		$result = $this->getCurrentUser();

		return (
			$result->isSuccess()
			&& (
				$result->getUser()?->isAdmin()
				|| (
					Loader::includeModule('bitrix24')
					&& \CBitrix24::IsPortalAdmin($result->getUser()?->getId())
				)
			)
		);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit