Esempio n. 1
0
 public function executeComponent()
 {
     if (!CModule::IncludeModule('webdav')) {
         return false;
     }
     $isVisual = isset($this->arParams['VISUAL']) ? (bool) $this->arParams['VISUAL'] : true;
     $pathToAjax = isset($this->arParams['AJAX_PATH']) ? $this->arParams['AJAX_PATH'] : '/bitrix/components/bitrix/webdav.disk/ajax.php';
     try {
         if ($isVisual) {
             $diskEnabled = \Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::includeModule('disk');
             $quota = CDiskQuota::GetDiskQuota();
             $this->arResult['showDiskQuota'] = false;
             //$quota !== true; //now without quota
             $this->arResult['diskSpace'] = (double) COption::GetOptionInt('main', 'disk_space') * 1024 * 1024;
             $this->arResult['quota'] = $quota;
             $this->arResult['ajaxIndex'] = $pathToAjax;
             $this->arResult['ajaxStorageIndex'] = '/desktop_app/storage.php';
             if ($diskEnabled) {
                 $this->arResult['isInstalledDisk'] = \Bitrix\Disk\Desktop::isDesktopDiskInstall();
                 $this->arResult['personalLibIndex'] = '/company/personal/user/' . $this->getUser()->getId() . '/disk/path/';
             } else {
                 $this->arResult['isInstalledDisk'] = (bool) CWebDavTools::isDesktopDiskInstall();
                 $this->arResult['personalLibIndex'] = '/company/personal/user/' . $this->getUser()->getId() . '/files/lib/';
             }
             $this->arResult['isInstalledPull'] = (bool) IsModuleInstalled('pull');
             $this->arResult['currentUser'] = array('id' => $this->getUser()->getId(), 'formattedName' => $this->getUser()->getFormattedName());
             $this->getApplication()->addHeadScript('/bitrix/components/bitrix/webdav.disk/disk.js');
             $this->includeComponentTemplate();
             return;
         }
         CTimeZone::Disable();
         //decode from utf-8 to site LANG_CHARSET
         CUtil::decodeURIComponent($_POST);
         $this->checkUser()->runAction();
         CTimeZone::Enable();
     } catch (CWebDavBadStorageAfterMigrateException $e) {
         CTimeZone::Enable();
         $this->sendJsonResponse(array('status' => CWebDavDiskDispatcher::STATUS_ERROR, 'message' => 'Could not get Disk\\Storage. Perhaps, it is old client, which does not reconnect. '), 500);
     } catch (CWebDavSymlinkMoveFakeErrorException $e) {
         CTimeZone::Enable();
         $this->sendJsonResponse(array('status' => CWebDavDiskDispatcher::STATUS_ERROR, 'message' => 'This is not really error. Move symlink folders.'));
     } catch (CWebDavAccessDeniedException $e) {
         CTimeZone::Enable();
         $this->sendJsonResponse(array('status' => CWebDavDiskDispatcher::STATUS_ACCESS_DENIED, 'message' => $e->getMessage()));
     } catch (Exception $e) {
         CTimeZone::Enable();
         $response = array('status' => 'error', 'message' => $e->getMessage());
         if ($this->dispatcher) {
             $errors = $this->dispatcher->getErrors();
             if ($errors) {
                 $response['detail'] = $errors;
             }
         }
         $this->sendJsonResponse($response);
     }
     return;
 }
 public function RecoverDocumentFromHistory($documentId, $arDocument)
 {
     if (parent::RecoverDocumentFromHistory($documentId, $arDocument)) {
         CWebDavDiskDispatcher::sendEventToOwners($arDocument['FIELDS'], null, 'recover from history');
         return true;
     }
 }
Esempio n. 3
0
 protected function generateTimestamp($date)
 {
     return CWebDavDiskDispatcher::convertToExternalVersion($date);
 }
Esempio n. 4
0
 public function processActionShare(array $params)
 {
     $this->params = $params;
     $attachSectionData = $this->getSectionDataByAttachObject($params['attachObject']);
     \CWebDavSymlinkHelper::setPathPattern('user', $params['pathToUser']);
     \CWebDavSymlinkHelper::setPathPattern('group', $params['pathToGroup']);
     $result = array();
     foreach ($params['attachToUserIds'] as $userIdToShare) {
         if ($userIdToShare == $params['inviteFromUserId']) {
             //to owner we don't create really symlink. Already there section.
             $result[] = array('userId' => $attachSectionData['SECTION_ID']);
             continue;
         }
         $targetSectionData = $this->getSectionDataByUserId($userIdToShare);
         $targetSectionData['IBLOCK_SECTION_ID'] = $targetSectionData['SECTION_ID'];
         $linkData = array('ID' => $attachSectionData['SECTION_ID'], 'IBLOCK_ID' => $attachSectionData['IBLOCK_ID'], 'NAME' => $this->generateNameForSymLinkSection($targetSectionData, $params['attachObject']), 'CREATED_BY' => $params['inviteFromUserId'], 'INVITE_USER_ID' => $userIdToShare, 'CAN_EDIT' => $params['canEdit'], 'CAN_FORWARD' => 0);
         $symlinkSectionId = \CWebDavSymlinkHelper::createSymLinkSection($targetSectionData, $linkData, $params['attachObject']['type']);
         if ($symlinkSectionId) {
             $result[] = array('userId' => $symlinkSectionId);
         }
     }
     if ($result) {
         \CWebDavDiskDispatcher::sendChangeStatus($params['inviteFromUserId'], 'share_section');
         global $DB;
         //update timestamp_x for incremental snapshot from disk.
         $section = new \CIBlockSection();
         $section->update($attachSectionData['SECTION_ID'], array('~TIMESTAMP_X' => $DB->getNowFunction()), false, false);
         return $this->sendJsonResponse(array('status' => self::STATUS_SUCCESS, 'sections' => $result));
     }
     return $this->sendJsonResponse(array('status' => self::STATUS_ERROR));
 }
Esempio n. 5
0
 function _ib_elm_add($arFields, $bWorkFlow = false, $bUpdateSearch = true, $bResizePictures = false)
 {
     global $USER_FIELD_MANAGER;
     global $APPLICATION;
     $bUF = isset($arFields['USER_FIELDS']);
     if ($bUF) {
         $UF_ENTITY = $this->GetUfEntity();
         if (!$USER_FIELD_MANAGER->CheckFields($UF_ENTITY, 0, $arFields['USER_FIELDS'])) {
             if (is_object($APPLICATION) && $APPLICATION->GetException()) {
                 $e = $APPLICATION->GetException();
                 $this->LAST_ERROR .= $e->GetString();
                 return false;
             }
         }
         $handlerID = AddEventHandler('search', 'BeforeIndex', array($this, 'IndexUfValues'));
     }
     if ($bUpdateSearch && $bUF) {
         $bUpdateSearch = false;
     }
     $el = new CIBlockElement();
     $result = $el->Add($arFields, $bWorkFlow, $bUpdateSearch, $bResizePictures);
     $ID = intval($result);
     if ($ID <= 0) {
         $this->LAST_ERROR = $el->LAST_ERROR;
         return false;
     } else {
         if (isset($arFields['PROPERTY_VALUES']) && !$this->ValidatePropertyValues($ID, $arFields['PROPERTY_VALUES'], $arFields['IBLOCK_ID'])) {
             $this->LAST_ERROR = GetMessage("WD_FILE_ERROR111");
             $el->Delete($ID);
             return false;
         }
         if ($bUF) {
             $USER_FIELD_MANAGER->Update($UF_ENTITY, $ID, $arFields['USER_FIELDS']);
             $el->UpdateSearch($ID, true);
         }
         $this->_onEvent('Add', $ID);
     }
     if ($bUF) {
         RemoveEventHandler('search', 'BeforeIndex', $handlerID);
     }
     CWebDavDiskDispatcher::sendEventToOwners(null, array('IBLOCK_ID' => (int) $arFields['IBLOCK_ID'], 'ID' => (int) $arFields['IBLOCK_SECTION_ID']), 'add');
     return (int) $result;
 }
Esempio n. 6
0
 /**
  * User by user
  *        array(
  *        'IBLOCK_ID' => 16,
  *        'IBLOCK_SECTION_ID' => 162,
  *    );
  *    array(
  *        'NAME' => 'link on folder',
  *        'IBLOCK_ID' => 15,
  *        'ID' => 3574,
  *        'CREATED_BY' => 1,
  *        'CAN_FORWARD' => 1,
  *        'INVITE_USER_ID' => 480,
  *    );
  *
  * @param array  $sectionTargetData
  * @param array  $sectionLinkData
  * @param string $typeLibrary - user, group, shared
  * @return bool|int
  */
 public static function createSymLinkSection(array $sectionTargetData, array $sectionLinkData, $typeLibrary = self::ENTITY_TYPE_USER)
 {
     if (empty($sectionLinkData['IBLOCK_ID']) || empty($sectionLinkData['ID']) || empty($sectionLinkData['NAME']) || empty($sectionLinkData['CREATED_BY'])) {
         return false;
     }
     if (empty($sectionTargetData['IBLOCK_ID']) || empty($sectionTargetData['IBLOCK_SECTION_ID'])) {
         return false;
     }
     $typeLibrary = strtolower($typeLibrary);
     if ($typeLibrary != self::ENTITY_TYPE_USER && $typeLibrary != self::ENTITY_TYPE_GROUP && $typeLibrary != self::ENTITY_TYPE_SHARED) {
         return false;
     }
     if (!CWebDavTools::isIntranetUser($sectionLinkData['INVITE_USER_ID'])) {
         return false;
     }
     $sectionTargetData = array_intersect_key($sectionTargetData, array('IBLOCK_ID' => true, 'IBLOCK_SECTION_ID' => true));
     $additionalData = array(CWebDavIblock::UF_LINK_IBLOCK_ID => $sectionLinkData['IBLOCK_ID'], CWebDavIblock::UF_LINK_SECTION_ID => $sectionLinkData['ID'], CWebDavIblock::UF_LINK_ROOT_SECTION_ID => self::getRootSectionId($sectionLinkData['IBLOCK_ID'], $sectionLinkData['ID'], $typeLibrary), CWebDavIblock::UF_LINK_CAN_FORWARD => $sectionLinkData['CAN_FORWARD'], 'CREATED_BY' => $sectionLinkData['CREATED_BY'], 'MODIFIED_BY' => $sectionLinkData['CREATED_BY'], 'NAME' => $sectionLinkData['NAME']);
     $exists = \Bitrix\Webdav\FolderInviteTable::getRow(array('filter' => array('INVITE_USER_ID' => $sectionLinkData['INVITE_USER_ID'], 'IBLOCK_ID' => $sectionLinkData['IBLOCK_ID'], 'SECTION_ID' => $sectionLinkData['ID']), 'select' => array('ID', 'LINK_SECTION_ID', 'IS_DELETED', 'IS_APPROVED')));
     //rewrite old self-deleted by user invite
     if ($exists && !$exists['IS_DELETED'] && $exists['IS_APPROVED']) {
         return $exists['LINK_SECTION_ID'];
     }
     $section = new CIBlockSection();
     $sectionId = $section->add(array_merge($sectionTargetData, $additionalData));
     if ($typeLibrary == self::ENTITY_TYPE_GROUP) {
         $inviteUserId = $sectionLinkData['CREATED_BY'];
         \Bitrix\Webdav\FolderInviteTable::addIfNonExists(array('INVITE_USER_ID' => $sectionLinkData['CREATED_BY'], 'USER_ID' => $sectionLinkData['CREATED_BY'], 'IBLOCK_ID' => $sectionLinkData['IBLOCK_ID'], 'SECTION_ID' => $sectionLinkData['ID'], 'LINK_SECTION_ID' => $sectionId, 'IS_APPROVED' => true, 'IS_DELETED' => false, 'CAN_FORWARD' => false));
     } elseif ($typeLibrary == self::ENTITY_TYPE_USER) {
         if ($sectionId) {
             $inviteUserId = $sectionLinkData['INVITE_USER_ID'];
             \Bitrix\Webdav\FolderInviteTable::addIfNonExists(array('INVITE_USER_ID' => $sectionLinkData['INVITE_USER_ID'], 'USER_ID' => $sectionLinkData['CREATED_BY'], 'IBLOCK_ID' => $sectionLinkData['IBLOCK_ID'], 'SECTION_ID' => $sectionLinkData['ID'], 'LINK_SECTION_ID' => $sectionId, 'IS_APPROVED' => true, 'IS_DELETED' => false, 'CAN_FORWARD' => false, 'CAN_EDIT' => $sectionLinkData['CAN_EDIT']));
             $rightsLetter = $sectionLinkData['CAN_EDIT'] ? 'W' : 'R';
             CWebDavIblock::appendRightsOnSections(array($sectionLinkData), array($rightsLetter => 'U' . $sectionLinkData['INVITE_USER_ID']));
         }
     }
     if ($sectionId && $inviteUserId) {
         CWebDavDiskDispatcher::sendChangeStatus($inviteUserId, 'symlink');
     }
     return $sectionId;
 }
Esempio n. 7
0
 private static function removeNotifyToUser(array $folderInvite)
 {
     if (\Bitrix\Main\Loader::includeModule('im')) {
         \CIMNotify::deleteByTag(self::getNotifyTag($folderInvite));
     }
     \CWebDavDiskDispatcher::sendChangeStatus($folderInvite['INVITE_USER_ID'], 'delete_symlink');
 }