Exemplo n.º 1
0
 $groupCache = new CPHPCache();
 if ($groupCache->InitCache($arParams["CACHE_TIME"], $CACHE_ID, $cachePath)) {
     $vars = $groupCache->GetVars();
     $arGroupSectionIDs = $vars['GROUP_SECTION_IDS'];
     $currentUserGroups = $vars['CURRENT_USER_GROUPS'];
 } else {
     $arFilter = array("IBLOCK_ID" => $arParams["IBLOCK_GROUP_ID"], "SECTION_ID" => 0, "CHECK_PERMISSIONS" => "N");
     $arGroupSections = array();
     $arGroupSectionIDs = array();
     $dbSection = CIBlockSection::GetList(array(), $arFilter, false, array('ID', 'NAME', 'SOCNET_GROUP_ID'));
     while ($arGroupSection = $dbSection->Fetch()) {
         $arGroupSections[$arGroupSection['ID']] = $arGroupSection;
         $arGroupSectionIDs[$arGroupSection['ID']] = $arGroupSection['SOCNET_GROUP_ID'];
     }
     // get all user workgroups
     $currentUserGroups = CIBlockWebdavSocnet::GetUserGroups($currentUserID);
     $userGroupIDs = array_keys($currentUserGroups);
     // intersect result - user groups which has files
     $arGroupSectionIDs = array_intersect($arGroupSectionIDs, $userGroupIDs);
     if ($groupCache->StartDataCache()) {
         global $CACHE_MANAGER;
         $CACHE_MANAGER->StartTagCache($cachePath);
         $CACHE_MANAGER->RegisterTag("webdav_aggregator");
         $CACHE_MANAGER->EndTagCache();
         $groupCache->EndDataCache(array('GROUP_SECTION_IDS' => $arGroupSectionIDs, 'CURRENT_USER_GROUPS' => $currentUserGroups));
     }
 }
 unset($groupCache);
 $arLocalPath = _wdCleanUpForbiddenSymbols(explode('/', trim($localPath, '/')));
 if (empty($arLocalPath[0])) {
     unset($arLocalPath[0]);
Exemplo n.º 2
0
function WDUFUserFieldEdit(&$arParams, &$arResult)
{
    global $APPLICATION;
    static $userIblockID = false;
    static $groupIblockID = false;
    static $iblockOptionTypes = array("group_files", "shared_files", "user_files");
    static $iblockOptions = array();
    static $arIBlock = array();
    static $DROPPED = null;
    $arResult['ELEMENTS'] = array();
    $arResult['JSON'] = array();
    if (!CModule::IncludeModule('webdav')) {
        return false;
    }
    if ($DROPPED === null) {
        $DROPPED = CWebDavIblock::getDroppedMetaData();
        $DROPPED = $DROPPED['name'];
    }
    $arResult['controlName'] = $arParams['arUserField']['FIELD_NAME'];
    $arValue = $arParams['arUserField']['VALUE'];
    if (is_array($arValue) && sizeof($arValue) > 0) {
        if (empty($iblockOptions)) {
            foreach ($iblockOptionTypes as $type) {
                $arOpt = CWebDavIblock::LibOptions($type, false, SITE_ID);
                if (is_set($arOpt, 'id') && intval($arOpt['id']) > 0) {
                    $iblockOptions[$type] = $arOpt['id'];
                }
            }
        }
        foreach ($arValue as $elementID) {
            $elementID = intval($elementID);
            if ($elementID <= 0) {
                continue;
            }
            $title = '';
            $dropped = false;
            $dbElement = CIBlockElement::GetList(array(), array('ID' => $elementID), false, false, array('ID', 'NAME', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'SOCNET_GROUP_ID', 'CREATED_BY'));
            if ($dbElement && ($arElement = $dbElement->Fetch())) {
                $arSectionTree = WDUGetNavChainSections($arElement['IBLOCK_ID'], $arElement['IBLOCK_SECTION_ID'], false);
                $dropped = false;
                if (sizeof($arSectionTree) > 0 && $arSectionTree[0]['NAME'] == $DROPPED) {
                    $title = GetMessage('WD_LOCAL_COPY_ONLY');
                    $dropped = true;
                } else {
                    $type = array_search($arElement['IBLOCK_ID'], $iblockOptions);
                    if ($type == 'group_files') {
                        if (sizeof($arSectionTree) > 0) {
                            $title = $arSectionTree[0]['NAME'];
                        }
                    } elseif ($type == 'user_files') {
                        if (sizeof($arSectionTree) > 1 && $arSectionTree[1]['NAME'] == $DROPPED) {
                            $title = GetMessage('WD_LOCAL_COPY_ONLY');
                            $dropped = true;
                        } elseif (sizeof($arSectionTree) > 0) {
                            $title = GetMessage('WD_MY_LIBRARY');
                            /*$l = sizeof($arSectionTree);
                            		for($i = 1; $i < $l; $i++)
                            		{
                            			$title .= " / " .  $arSectionTree[$i]['NAME'];
                            		}*/
                        }
                    } else {
                        if (!isset($arIBlock[$arElement['IBLOCK_ID']])) {
                            $dbIB = CIBlock::GetList(array(), array('ID' => $arElement['IBLOCK_ID']));
                            if ($dbIB && ($arIB = $dbIB->Fetch())) {
                                $arIBlock[$arElement['IBLOCK_ID']] = $arIB;
                            }
                        }
                        if (isset($arIBlock[$arElement['IBLOCK_ID']])) {
                            $title = $arIBlock[$arElement['IBLOCK_ID']]['NAME'];
                        }
                    }
                }
                $arElement['FILE_SIZE'] = '';
                $dbSize = CIBlockElement::GetProperty($arElement['IBLOCK_ID'], $arElement['ID'], array(), array('CODE' => 'WEBDAV_SIZE'));
                if ($dbSize && ($arSize = $dbSize->Fetch())) {
                    $arElement['FILE_SIZE'] = CFile::FormatSize(intval($arSize['VALUE']), 0);
                }
                $arElement['FILE'] = array();
                $dbSize = CIBlockElement::GetProperty($arElement['IBLOCK_ID'], $arElement['ID'], array(), array('CODE' => 'FILE'));
                if ($dbSize && ($arSize = $dbSize->Fetch())) {
                    $arElement['FILE'] = CFile::GetFileArray($arSize['VALUE']);
                }
                $arSection =& $arSectionTree[0];
                $detailPath = CWebDavIblock::LibOptions('lib_paths', true, $arElement['IBLOCK_ID']);
                $arPaths = WDUFGetPathOptions($detailPath, $arElement['IBLOCK_ID'], $arSection, $arElement);
                $arElement["URL_VIEW"] = $arPaths["path"];
                $arElement["URL_EDIT"] = $arPaths["edit"];
                $arElement["URL_DELETE_DROPPED"] = $arPaths["delete_dropped"];
                $arElement["URL_GET"] = $arPaths["history_get"];
                $arElement['DROPPED'] = $dropped;
                $arElement['TITLE'] = $title;
                $arResult['ELEMENTS'][] = $arElement;
            }
        }
    }
    // need to load Options for ajax dialogs
    $extDir = WDUFGetExtranetDir();
    if ($extDir !== '') {
        $groupIBlockID = CWebDavIblock::LibOptions('group_files', false, SITE_ID);
        if (!($groupIBlockID && isset($groupIBlockID['id']) && intval($groupIBlockID['id']) > 0)) {
            $arGroups = CIBlockWebdavSocnet::GetUserGroups(0, false);
            if (sizeof($arGroups) > 0) {
                $arGroup = array_pop($arGroups);
                $groupFilesUrl = str_replace(array("///", "//"), "/", "/" . $extDir . '/workgroups/group/' . $arGroup['GROUP_ID'] . '/files/');
                $arResult['JSON'][] = $groupFilesUrl;
            }
        }
    } else {
        $sharedLibID = CWebDavIblock::LibOptions('shared_files', false, SITE_ID);
        if (!($sharedLibID && isset($sharedLibID['id']) && intval($sharedLibID['id']) > 0 && isset($sharedLibID['base_url']) && strlen($sharedLibID['base_url']) > 0)) {
            if (!(CModule::IncludeModule('extranet') && strlen(CExtranet::GetExtranetSiteID()) > 0 && SITE_ID == CExtranet::GetExtranetSiteID())) {
                $arResult['JSON'][] = '/docs/';
                $arResult['JSON'][] = '/docs/shared/';
            }
        }
        $userIBlockID = CWebDavIblock::LibOptions('user_files', false, SITE_ID);
        if (!($userIBlockID && isset($userIBlockID['id']) && intval($userIBlockID['id']) > 0)) {
            $arResult['JSON'][] = '/company/personal/user/' . $GLOBALS['USER']->GetID() . '/files/lib/';
        }
        $groupIBlockID = CWebDavIblock::LibOptions('group_files', false, SITE_ID);
        if (!($groupIBlockID && isset($groupIBlockID['id']) && intval($groupIBlockID['id']) > 0)) {
            $arGroups = CIBlockWebdavSocnet::GetUserGroups(0, false);
            if (sizeof($arGroups) > 0) {
                $arGroup = array_pop($arGroups);
                $arResult['JSON'][] = '/workgroups/group/' . $arGroup['GROUP_ID'] . '/files/';
            }
        }
    }
}