Example #1
0
 protected function processActionShowShareInfoSmallView()
 {
     $this->checkRequiredPostParams(array('objectId'));
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     /** @var File|Folder $object */
     $object = \Bitrix\Disk\BaseObject::loadById((int) $this->request->getPost('objectId'), array('REAL_OBJECT.STORAGE'));
     if (!$object || !$object->getRealObject() || !$object->getRealObject()->getStorage()) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FOLDER_LIST_ERROR_COULD_NOT_FIND_OBJECT'), self::ERROR_COULD_NOT_FIND_OBJECT)));
         $this->sendJsonErrorResponse();
     }
     $storage = $object->getRealObject()->getStorage();
     $proxyType = $storage->getProxyType();
     $securityContext = $storage->getCurrentUserSecurityContext();
     if (!$object->canRead($securityContext)) {
         $this->sendJsonAccessDeniedResponse();
     }
     //user has only read right. And he can't see on another sharing
     if (!$object->canShare($securityContext) && !$object->canChangeRights($securityContext)) {
         /** @var User $user */
         $user = User::getById($this->getUser()->getId());
         $entityList = array(array('entityId' => Sharing::CODE_USER . $this->getUser()->getId(), 'name' => $user->getFormattedName(), 'right' => \Bitrix\Disk\RightsManager::TASK_READ, 'avatar' => $user->getAvatarSrc(), 'type' => 'users'));
     } else {
         $entityList = $object->getMembersOfSharing();
     }
     $this->sendJsonSuccessResponse(array('owner' => array('name' => $proxyType->getEntityTitle(), 'url' => $proxyType->getEntityUrl(), 'avatar' => $proxyType->getEntityImageSrc(21, 21)), 'members' => $entityList));
 }