コード例 #1
0
ファイル: crumbstorage.php プロジェクト: DarneoStudio/bitrix
 protected function calculateCrumb(BaseObject $object)
 {
     $parentId = $object->getParentId();
     if (!$parentId) {
         $this->crumbsByObjectId[$object->getId()] = array($object->getName());
         return $this->crumbsByObjectId[$object->getId()];
     }
     if (isset($this->crumbsByObjectId[$parentId])) {
         $this->crumbsByObjectId[$object->getId()] = $this->crumbsByObjectId[$parentId];
         $this->crumbsByObjectId[$object->getId()][] = $object->getName();
         return $this->crumbsByObjectId[$object->getId()];
     }
     $storage = $object->getStorage();
     $fake = Driver::getInstance()->getFakeSecurityContext();
     $this->crumbsByObjectId[$object->getId()] = array();
     foreach ($object->getParents($fake, array('select' => array('ID', 'NAME', 'TYPE')), SORT_DESC) as $parent) {
         if ($parent->getId() == $storage->getRootObjectId()) {
             continue;
         }
         $this->crumbsByObjectId[$object->getId()][] = $parent->getName();
     }
     unset($parent);
     $this->crumbsByObjectId[$parentId] = $this->crumbsByObjectId[$object->getId()];
     $this->crumbsByObjectId[$object->getId()][] = $object->getName();
     return $this->crumbsByObjectId[$object->getId()];
 }
コード例 #2
0
ファイル: viewer.php プロジェクト: DarneoStudio/bitrix
 /**
  * Gets data attributes by object (folder or file) to viewer.
  * @param File|Folder|BaseObject $object Target object.
  * @param array                  $additionalParams Additional parameters 'relativePath', 'externalId', 'canUpdate', 'showStorage'.
  * @return string
  */
 public static function getAttributesByObject(BaseObject $object, array $additionalParams = array())
 {
     $urlManager = Driver::getInstance()->getUrlManager();
     $name = $object->getName();
     $dateTime = $object->getUpdateTime();
     if ($object instanceof Folder) {
         $user = $object->getCreateUser();
         $dataAttributesForViewer = 'data-bx-viewer="folder" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-src="" ' . 'data-bx-owner="' . htmlspecialcharsbx($user ? $user->getFormattedName() : '') . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($dateTime) . '" ';
         return $dataAttributesForViewer;
     }
     if (!$object instanceof File) {
         return '';
     }
     if (DocumentHandler::isEditable($object->getExtension())) {
         $dataAttributesForViewer = 'data-bx-viewer="iframe" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-src="' . $urlManager->getUrlToShowFileByService($object->getId(), 'gvdrive') . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-askConvert="' . (DocumentHandler::isNeedConvertExtension($object->getExtension()) ? '1' : '') . '" ' . 'data-bx-download="' . $urlManager->getUrlForDownloadFile($object) . '" ' . 'data-bx-size="' . htmlspecialcharsbx(CFile::formatSize($object->getSize())) . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($dateTime) . '" ';
     } elseif (Viewer::isViewable($object->getExtension())) {
         $dataAttributesForViewer = 'data-bx-viewer="iframe" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-src="' . $urlManager->getUrlToShowFileByService($object->getId(), 'gvdrive') . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-askConvert="0" ' . 'data-bx-download="' . $urlManager->getUrlForDownloadFile($object) . '" ' . 'data-bx-size="' . htmlspecialcharsbx(CFile::formatSize($object->getSize())) . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($dateTime) . '" ';
     } elseif (TypeFile::isImage($object)) {
         $dataAttributesForViewer = 'data-bx-viewer="image" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-src="' . $urlManager->getUrlForDownloadFile($object) . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-download="' . $urlManager->getUrlForDownloadFile($object) . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($dateTime) . '" ';
     } else {
         $user = $object->getCreateUser();
         $dataAttributesForViewer = 'data-bx-viewer="unknown" ' . 'data-bx-src="' . $urlManager->getUrlForDownloadFile($object) . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-download="' . $urlManager->getUrlForDownloadFile($object) . '" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-owner="' . htmlspecialcharsbx($user ? $user->getFormattedName() : '') . '" ' . 'data-bx-size="' . htmlspecialcharsbx(CFile::formatSize($object->getSize())) . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($dateTime) . '" ';
     }
     $dataAttributesForViewer .= " bx-attach-file-id=\"{$object->getId()}\"" . " data-bx-version=\"\"" . " data-bx-history=\"\"" . " data-bx-historyPage=\"\"";
     if (!empty($additionalParams['relativePath'])) {
         $dataAttributesForViewer .= ' data-bx-relativePath="' . htmlspecialcharsbx($additionalParams['relativePath'] . '/' . $name) . '" ';
     }
     if (!empty($additionalParams['externalId'])) {
         $dataAttributesForViewer .= ' data-bx-externalId="' . htmlspecialcharsbx($additionalParams['externalId']) . '" ';
     }
     if (!empty($additionalParams['canUpdate'])) {
         $dataAttributesForViewer .= ' data-bx-edit="' . $urlManager->getUrlForStartEditFile($object->getId(), 'gdrive') . '" ';
     }
     if (!empty($additionalParams['showStorage'])) {
         $dataAttributesForViewer .= ' data-bx-storage="' . htmlspecialcharsbx($object->getParent()->getName()) . '" ';
     }
     return $dataAttributesForViewer;
 }
コード例 #3
0
ファイル: sharing.php プロジェクト: mrdeadmouse/u136006
 /**
  * Autoconnect, notify.
  * @param Sharing[]                 $successSharingByEntity
  * @param File|Folder|BaseObject $objectToSharing
  */
 protected static function processConnectAndNotify(array $successSharingByEntity, BaseObject $objectToSharing)
 {
     $isFolder = $objectToSharing instanceof Folder;
     if (Configuration::canAutoconnectSharedObjects()) {
         $urlManager = Driver::getInstance()->getUrlManager();
         foreach ($successSharingByEntity as $entity => $sharingModel) {
             /** @var \Bitrix\Disk\Sharing $sharingModel */
             if (!$sharingModel->approve()) {
                 unset($successSharingByEntity[$entity]);
             } else {
                 if (!$sharingModel->isToUser()) {
                     continue;
                 }
                 $pathInListing = $urlManager->getPathInListing($sharingModel->getLinkObject()) . "#hl-{$sharingModel->getLinkObjectId()}";
                 $uriToDisconnect = $pathInListing . "!detach";
                 $message = Loc::getMessage($isFolder ? 'DISK_SHARING_MODEL_AUTOCONNECT_NOTIFY' : 'DISK_SHARING_MODEL_AUTOCONNECT_NOTIFY_FILE', array('#NAME#' => '<a href="' . $pathInListing . '">' . $objectToSharing->getName() . '</a>', '#DESCRIPTION#' => $sharingModel->getDescription(), '#DISCONNECT_LINK#' => '<a href="' . $uriToDisconnect . '">' . Loc::getMessage('DISK_SHARING_MODEL_TEXT_DISCONNECT_LINK') . '</a>'));
                 list($subTag, $tag) = $sharingModel->getNotifyTags();
                 Driver::getInstance()->sendNotify(substr($sharingModel->getToEntity(), 1), array('FROM_USER_ID' => $sharingModel->getCreatedBy(), 'NOTIFY_EVENT' => 'sharing', 'NOTIFY_TAG' => $tag, 'NOTIFY_SUB_TAG' => $subTag, 'NOTIFY_MESSAGE' => $message, 'NOTIFY_MESSAGE_OUT' => strip_tags($message)));
             }
         }
     } else {
         $buttons = array(array('TITLE' => Loc::getMessage($isFolder ? 'DISK_SHARING_MODEL_APPROVE_Y' : 'DISK_SHARING_MODEL_APPROVE_Y_FILE'), 'VALUE' => 'Y', 'TYPE' => 'accept'), array('TITLE' => Loc::getMessage('DISK_SHARING_MODEL_APPROVE_N_2_DECLINE'), 'VALUE' => 'N', 'TYPE' => 'cancel'));
         $message = Loc::getMessage($isFolder ? 'DISK_SHARING_MODEL_TEXT_APPROVE_CONFIRM' : 'DISK_SHARING_MODEL_TEXT_APPROVE_CONFIRM_FILE', array('#NAME#' => $objectToSharing->getName()));
         foreach ($successSharingByEntity as $entity => $sharingModel) {
             if (!$sharingModel->isToUser()) {
                 continue;
             }
             list($subTag, $tag) = $sharingModel->getNotifyTags();
             Driver::getInstance()->sendNotify(substr($sharingModel->getToEntity(), 1), array('NOTIFY_BUTTONS' => $buttons, 'NOTIFY_TYPE' => 'IM_NOTIFY_CONFIRM', 'FROM_USER_ID' => $sharingModel->getCreatedBy(), 'NOTIFY_EVENT' => 'sharing', 'NOTIFY_TAG' => $tag, 'NOTIFY_SUB_TAG' => $subTag, 'NOTIFY_MESSAGE' => $message, 'NOTIFY_MESSAGE_OUT' => strip_tags($message)));
         }
     }
 }
コード例 #4
0
ファイル: diskstorage.php プロジェクト: DarneoStudio/bitrix
 private function getBreadcrumbs(BaseObject $object)
 {
     $parentId = $object->isLink() ? $object->getParentId() : $object->getRealObject()->getParentId();
     $realId = $object->isLink() ? $object->getId() : $object->getRealObject()->getId();
     if (isset($this->cacheBreadcrumbs[$parentId])) {
         if ($object instanceof File) {
             return $this->cacheBreadcrumbs[$parentId] . '/' . $object->getName();
         }
         $this->cacheBreadcrumbs[$realId] = $this->cacheBreadcrumbs[$parentId] . '/' . $object->getName();
         if ($object->isLink()) {
             $this->cacheBreadcrumbs[$object->getRealObject()->getId()] = $this->cacheBreadcrumbs[$realId];
         }
     } else {
         if ($parentId == $this->storage->getRootObjectId()) {
             $this->cacheBreadcrumbs[$realId] = '/' . $object->getName();
             if ($object->isLink()) {
                 if (!$object->getRealObject()) {
                     return null;
                 }
                 $this->cacheBreadcrumbs[$object->getRealObject()->getId()] = $this->cacheBreadcrumbs[$realId];
             }
             return $this->cacheBreadcrumbs[$realId];
         }
         $path = '';
         $parents = ObjectTable::getAncestors($realId, array('select' => array('ID', 'NAME', 'TYPE', 'CODE')));
         while ($parent = $parents->fetch()) {
             if ($parent['CODE'] == Folder::CODE_FOR_UPLOADED_FILES) {
                 //todo hack. CODE_FOR_UPLOADED_FILES
                 return null;
             }
             if ($this->storage->getRootObjectId() == $parent['ID']) {
                 continue;
             }
             $path .= '/' . $parent['NAME'];
             if (!isset($this->cacheBreadcrumbs[$parent['ID']])) {
                 $this->cacheBreadcrumbs[$parent['ID']] = $path;
             }
         }
         if (isset($this->cacheBreadcrumbs[$parentId])) {
             $this->cacheBreadcrumbs[$realId] = $this->cacheBreadcrumbs[$parentId];
             if ($object->isLink()) {
                 $this->cacheBreadcrumbs[$object->getRealObject()->getId()] = $this->cacheBreadcrumbs[$realId];
             }
         } else {
             $this->cacheBreadcrumbs[$realId] = null;
         }
     }
     return $this->cacheBreadcrumbs[$realId];
 }
コード例 #5
0
ファイル: folder.php プロジェクト: mrdeadmouse/u136006
 private function prepareDataForAddLink(BaseObject $object, array $data, $generateUniqueName = false)
 {
     if (empty($data['NAME'])) {
         $data['NAME'] = $object->getName();
     }
     $this->checkRequiredInputParams($data, array('NAME'));
     if ($generateUniqueName) {
         $data['NAME'] = $this->generateUniqueName($data['NAME'], $this->id);
     }
     if (!$this->isUniqueName($data['NAME'], $this->id)) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FOLDER_MODEL_ERROR_NON_UNIQUE_NAME'), self::ERROR_NON_UNIQUE_NAME)));
         return null;
     }
     $data['PARENT_ID'] = $this->id;
     $data['STORAGE_ID'] = $this->storageId;
     $data['REAL_OBJECT_ID'] = $object->getRealObject()->getId();
     return $data;
 }
コード例 #6
0
ファイル: webdavserver.php プロジェクト: DarneoStudio/bitrix
 /**
  * @param $path
  * @param File|Folder|Object $object
  * @return CDavResource
  */
 protected function getResourceByObject($path, BaseObject $object)
 {
     $isFolder = $object instanceof Folder;
     $resource = new CDavResource($path . ($isFolder && substr($path, -1, 1) != "/" ? "/" : ""));
     $resource->AddProperty('name', $object->getName());
     if ($object instanceof File) {
         $resource->AddProperty('getcontentlength', $object->getSize());
     }
     $resource->AddProperty('creationdate', $object->getCreateTime()->getTimestamp());
     $resource->AddProperty('getlastmodified', $object->getUpdateTime()->getTimestamp());
     $resource->AddProperty('iscollection', $isFolder ? '1' : '0');
     if ($isFolder) {
         $resource->AddProperty('resourcetype', array('collection', ''));
         $resource->AddProperty('getcontenttype', 'httpd/unix-directory');
     } else {
         $resource->AddProperty('getcontenttype', '');
         $resource->AddProperty('isreadonly', '');
         $resource->AddProperty('ishidden', '');
         $resource->AddProperty('resourcetype', '');
     }
     $resource->AddProperty("supportedlock", "<D:lockentry><D:lockscope><D:exclusive/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry><D:lockentry><D:lockscope><D:shared/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry>");
     return $resource;
 }
コード例 #7
0
ファイル: webdavserver.php プロジェクト: mrdeadmouse/u136006
 /**
  * @param $path
  * @param File|Folder|Object $object
  * @return CDavResource
  */
 protected function getResourceByObject($path, BaseObject $object)
 {
     $isFolder = $object instanceof Folder;
     $resource = new CDavResource($path . ($isFolder && substr($path, -1, 1) != "/" ? "/" : ""));
     $resource->AddProperty('name', $object->getName());
     if ($object instanceof File) {
         $resource->AddProperty('getcontentlength', $object->getSize());
     }
     $resource->AddProperty('creationdate', $object->getCreateTime()->getTimestamp());
     $resource->AddProperty('getlastmodified', $object->getUpdateTime()->getTimestamp());
     $resource->AddProperty('iscollection', $isFolder ? '1' : '0');
     $resource->AddProperty('Win32CreationTime', $object->getCreateTime()->getTimestamp(), "urn:schemas-microsoft-com:");
     $resource->AddProperty('Win32LastModifiedTime', $object->getUpdateTime()->getTimestamp(), "urn:schemas-microsoft-com:");
     if ($isFolder) {
         $resource->AddProperty('resourcetype', array('collection', ''));
         $resource->AddProperty('getcontenttype', 'httpd/unix-directory');
     } else {
         $resource->AddProperty('getcontenttype', '');
         $resource->AddProperty('isreadonly', '');
         $resource->AddProperty('ishidden', '');
         $resource->AddProperty('resourcetype', '');
     }
     $resource->AddProperty("supportedlock", "<D:lockentry><D:lockscope><D:exclusive/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry><D:lockentry><D:lockscope><D:shared/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry>");
     /*
       <D:response xmlns:ns0="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
      	<D:href>/docs/shared/%D0%97%D0%B0%D0%B3%D1%80%D1%83%D0%B7%D0%BA%D0%B8</D:href>
      	 <D:propstat>
      	  <D:prop>
      	   <D:resourcetype><D:collection/></D:resourcetype>
      	   <D:getcontenttype>httpd/unix-directory</D:getcontenttype>
      	   <D:creationdate ns0:dt="dateTime.tz">2014-05-12T08:37:25Z</D:creationdate>
      	   <D:getlastmodified ns0:dt="dateTime.rfc1123">Mon, 12 May 2014 08:37:25 GMT</D:getlastmodified>
      	   <D:iscollection/>
      	   <D:supportedlock><D:lockentry>
      						<D:lockscope><D:exclusive/></D:lockscope>
      						<D:locktype><D:write/></D:locktype>
      					</D:lockentry>
      					<D:lockentry>
      						<D:lockscope><D:shared/></D:lockscope>
      						<D:locktype><D:write/></D:locktype>
      					</D:lockentry></D:supportedlock>
      	 </D:prop>
      	 <D:status>HTTP/1.1 200 OK</D:status>
      	</D:propstat>
       </D:response>
     
     
       <D:response xmlns:ns0="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
      	<D:href>/docs/shared/%D0%90%D0%BD%D0%BA%D0%B5%D1%82%D0%B0.docx</D:href>
      	 <D:propstat>
      	  <D:prop>
      	   <D:creationdate ns0:dt="dateTime.tz">2014-05-12T08:26:30Z</D:creationdate>
      	   <D:getlastmodified ns0:dt="dateTime.rfc1123">Mon, 12 May 2014 08:26:31 GMT</D:getlastmodified>
      	   <D:creationdate ns0:dt="dateTime.tz">2014-05-12T08:26:30Z</D:creationdate>
      	   <D:getlastmodified ns0:dt="dateTime.rfc1123">Mon, 12 May 2014 08:26:31 GMT</D:getlastmodified>
      	   <D:getcontenttype/>
      	   <D:getcontentlength>86838</D:getcontentlength>
      	   <D:isreadonly>false</D:isreadonly>
      	   <D:ishidden>false</D:ishidden>
      	   <D:iscollection>0</D:iscollection>
      	   <D:resourcetype/>
      	   <D:supportedlock><D:lockentry>
      						<D:lockscope><D:exclusive/></D:lockscope>
      						<D:locktype><D:write/></D:locktype>
      					</D:lockentry>
      					<D:lockentry>
      						<D:lockscope><D:shared/></D:lockscope>
      						<D:locktype><D:write/></D:locktype>
      					</D:lockentry></D:supportedlock>
      	 </D:prop>
      	 <D:status>HTTP/1.1 200 OK</D:status>
      	</D:propstat>
       </D:response>
     */
     return $resource;
 }