Exemplo n.º 1
0
 function __wd_get_root_section($IBLOCK_ID, $object, $object_id)
 {
     $result = CIBlockWebdavSocnet::GetSectionID($IBLOCK_ID, $object, $object_id);
     if (intval($result) > 0) {
         return $result;
     } else {
         __wd_check_uf_use_bp_property($arParams["IBLOCK_ID"]);
         $arFields = array("IBLOCK_ID" => $IBLOCK_ID, "ACTIVE" => "Y", "SOCNET_GROUP_ID" => false, "IBLOCK_SECTION_ID" => 0, "UF_USE_BP" => "N");
         if ($object == "user") {
             $dbUser = CUser::GetByID($object_id);
             $arUser = $dbUser->Fetch();
             $arFields["NAME"] = trim($arUser['LAST_NAME'] . " " . $arUser['FIRST_NAME']);
             $arFields["NAME"] = trim(!empty($arFields["NAME"]) ? $arFields["NAME"] : $arUser['LOGIN']);
             $arFields['CREATED_BY'] = $arUser['ID'];
             $arFields['MODIFIED_BY'] = $arUser['ID'];
             if (CIBlock::GetArrayByID($IBLOCK_ID, "RIGHTS_MODE") === "E") {
                 $arTasks = CWebDavIblock::GetTasks();
                 $arFields['RIGHTS'] = array('n0' => array('GROUP_CODE' => 'U' . $object_id, 'TASK_ID' => $arTasks['X']));
             }
         } else {
             /*		$res = CSocNetGroup::GetByID($arResult["VARIABLES"]["group_id"]);
             				if (!$res)
             				{
             					$arParams["ERROR_MESSAGE"] = GetMessage("SONET_GROUP_NOT_EXISTS");
             					return 0;
             				} */
             $arFields["SOCNET_GROUP_ID"] = $object_id;
             //$arGroup = CSocNetGroup::GetByID($object_id);
             $arFields["NAME"] = GetMessage("SONET_GROUP_PREFIX") . $object_id;
             $dbGroup = CSocNetGroup::GetList(array(), array("ID" => (int) $object_id), false, false, array("ID", "SITE_ID", "NAME"));
             if ($arGroup = $dbGroup->Fetch()) {
                 $arFields["NAME"] = GetMessage("SONET_GROUP_PREFIX") . $arGroup["NAME"];
             }
             if (CIBlock::GetArrayByID($IBLOCK_ID, "RIGHTS_MODE") === "E") {
                 $arTasks = CWebDavIblock::GetTasks();
                 $arFields['RIGHTS'] = array('n0' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_A', 'TASK_ID' => $arTasks['X']), 'n1' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_E', 'TASK_ID' => $arTasks['W']), 'n2' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_K', 'TASK_ID' => $arTasks['W']));
             }
         }
         if (\Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::includeModule('disk')) {
             \Bitrix\Disk\Driver::getInstance()->addGroupStorage($arFields["SOCNET_GROUP_ID"]);
         }
         $GLOBALS["UF_USE_BP"] = $arFields["UF_USE_BP"];
         $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("IBLOCK_" . $IBLOCK_ID . "_SECTION", $arFields);
         $bs = new CIBlockSection();
         $sectionID = $bs->Add($arFields);
         if (!$sectionID) {
             $arParams["ERROR_MESSAGE"] = $bs->LAST_ERROR;
             return 0;
         }
         WDClearComponentCache(array("webdav.element.edit", "webdav.element.hist", "webdav.element.upload", "webdav.element.view", "webdav.menu", "webdav.section.edit", "webdav.section.list"));
         return true;
         /*
         	if ($ob->workflow == 'bizproc')
         	{
         		__wd_create_default_bp_user_and_groups($arBizProcParameters);
         	}
         */
     }
 }
Exemplo n.º 2
0
    true;
}
$multi = isset($_REQUEST['MULTI']) && $_REQUEST['MULTI'] == 'Y' ? 'true' : 'false';
$userID = $GLOBALS['USER']->GetID();
$bFakemove = isset($_REQUEST['ACTION']) && $_REQUEST['ACTION'] == 'FAKEMOVE';
$mode = "{'onlyFiles' : true}";
if ($bFakemove) {
    $mode = "{'folder' : true}";
}
$typeItems = "{\n";
if (isset($ob->attributes['user_id'])) {
    $typeItems .= str_replace(array("#GROUP_ID#", "#GROUP_NAME#", "#LINK#", "#IBLOCK_ID#", "#SECTION_ID#"), array($userID, CUtil::JSEscape(GetMessage('WD_MY_DOCUMENTS')), CUtil::JSEscape($ob->base_url), intval($ob->IBLOCK_ID), intval($ob->arRootSection['ID'])), "'U#GROUP_ID#' : {'id' : 'U#GROUP_ID#', 'name' : '#GROUP_NAME#', 'type' : 'user', 'link' : '#LINK#', 'iblock_id': '#IBLOCK_ID#', 'section_id': '#SECTION_ID#'},\n");
} else {
    $userLib = CWebDavIblock::LibOptions('user_files', false, SITE_ID);
    if ($userLib && isset($userLib['id']) && ($iblockID = intval($userLib['id']))) {
        $sectionID = CIBlockWebdavSocnet::GetSectionID($iblockID, 'user', $userID);
        $libPath = CWebDavIblock::LibOptions('lib_paths', true, $iblockID);
        if ($libPath) {
            $tplUser = '******';
            if ($tplPos = strpos($libPath, $tplUser)) {
                $libPath = substr($libPath, 0, $tplPos + strlen($tplUser)) . '/files/lib/';
            }
            $libPath = str_replace('#user_id#', $userID, $libPath);
        }
    }
    if ($sectionID && $libPath) {
        $typeItems .= str_replace(array("#GROUP_ID#", "#GROUP_NAME#", "#LINK#", "#IBLOCK_ID#", "#SECTION_ID#"), array($userID, CUtil::JSEscape(GetMessage('WD_MY_DOCUMENTS')), CUtil::JSEscape($libPath), $iblockID, $sectionID), "'U#GROUP_ID#' : {'id' : 'U#GROUP_ID#', 'name' : '#GROUP_NAME#', 'type' : 'user', 'link' : '#LINK#', 'iblock_id': '#IBLOCK_ID#', 'section_id': '#SECTION_ID#'},\n");
    }
}
$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) {
Exemplo n.º 3
0
 protected static function groupSectionCreate($groupId)
 {
     $groupLib = CWebDavIblock::LibOptions('group_files', false, SITE_ID);
     if (!$groupLib || !isset($groupLib['id']) || !($iblockId = intval($groupLib['id']))) {
         return false;
     }
     $result = CIBlockWebdavSocnet::GetSectionID($iblockId, 'group', $groupId);
     if (intval($result) > 0) {
         return $result;
     }
     $dbRes = CUserTypeEntity::GetList(array($by => $order), array("ENTITY_ID" => "IBLOCK_" . $iblockId . "_SECTION", "FIELD_NAME" => "UF_USE_BP"));
     if (!$dbRes || !($res = $dbRes->GetNext())) {
         $arFields = array("ENTITY_ID" => "IBLOCK_" . $iblockId . "_SECTION", "FIELD_NAME" => "UF_USE_BP", "USER_TYPE_ID" => "string", "MULTIPLE" => "N", "MANDATORY" => "N", "SETTINGS" => array("DEFAULT_VALUE" => "Y"));
         $arFieldName = array();
         $rsLanguage = CLanguage::GetList($by, $order, array());
         while ($arLanguage = $rsLanguage->Fetch()) {
             $dir = str_replace(array("\\", "//"), "/", dirname(__FILE__));
             $dirs = explode("/", $dir);
             array_pop($dirs);
             $file = trim(implode("/", $dirs) . "/lang/" . $arLanguage["LID"] . "/include/webdav_settings.php");
             $tmp_mess = __IncludeLang($file, true);
             $arFieldName[$arLanguage["LID"]] = empty($tmp_mess["SONET_UF_USE_BP"]) ? "Use Business Process" : $tmp_mess["SONET_UF_USE_BP"];
         }
         $arFields["EDIT_FORM_LABEL"] = $arFieldName;
         $obUserField = new CUserTypeEntity();
         $obUserField->Add($arFields);
         $GLOBALS["USER_FIELD_MANAGER"]->arFieldsCache = array();
     }
     $arFields = array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "SOCNET_GROUP_ID" => false, "IBLOCK_SECTION_ID" => 0, "UF_USE_BP" => "N");
     $arFields["SOCNET_GROUP_ID"] = $groupId;
     $arFields["NAME"] = GetMessage("SONET_GROUP_PREFIX") . $groupId;
     $dbGroup = CSocNetGroup::GetList(array(), array("ID" => (int) $groupId), false, false, array("ID", "SITE_ID", "NAME"));
     if ($arGroup = $dbGroup->Fetch()) {
         $arFields["NAME"] = GetMessage("SONET_GROUP_PREFIX") . $arGroup["NAME"];
     }
     if (CIBlock::GetarrayByID($iblockId, "RIGHTS_MODE") === "E") {
         $arTasks = CWebDavIblock::GetTasks();
         $arFields['RIGHTS'] = array('n0' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_A', 'TASK_ID' => $arTasks['X']), 'n1' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_E', 'TASK_ID' => $arTasks['W']), 'n2' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_K', 'TASK_ID' => $arTasks['W']));
     }
     $GLOBALS["UF_USE_BP"] = $arFields["UF_USE_BP"];
     $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("IBLOCK_" . $iblockId . "_SECTION", $arFields);
     $bs = new CIBlockSection();
     $sectionId = $bs->Add($arFields);
     if (!$sectionId) {
         return false;
     }
     return $sectionId;
 }
Exemplo n.º 4
0
        }
        $APPLICATION->RestartBuffer();
        echo json_encode(array("data" => $arResFiles, "TABLE_SETTINGS" => GetTableSettings($foldersNum, 0)));
        die;
    }
} elseif ($requestTupe == "user") {
    $user_files = COption::GetOptionString("webdav", "user_files", null);
    if ($user_files == null) {
        $APPLICATION->RestartBuffer();
        exit(json_encode(array('status' => 'failed')));
    }
    $user_files = unserialize($user_files);
    $arParams["IBLOCK_ID"] = $user_files[$sID]["id"];
    $filesOwnerUserID = array_shift($arURL);
    $arParams["BASE_URL"] = $arParams["SEF_FOLDER"] . "/" . $requestTupe . "/" . $filesOwnerUserID . "/";
    $rootSectionID = CIBlockWebdavSocnet::GetSectionID($arParams["IBLOCK_ID"], "user", $filesOwnerUserID);
    if (intval($rootSectionID) <= 0) {
        $APPLICATION->RestartBuffer();
        echo json_encode(array("data" => array(), "TABLE_SETTINGS" => GetTableSettings(0, 0)));
        die;
    }
    $arParams["ROOT_SECTION_ID"] = $rootSectionID;
} else {
    $APPLICATION->RestartBuffer();
    exit(json_encode(array('status' => 'failed')));
}
$action = array_key_exists("action", $_REQUEST) ? $_REQUEST['action'] : "";
$lng = isset($_REQUEST['lang']) ? trim($_REQUEST['lang']) : '';
$lng = substr(preg_replace('/[^a-z0-9_]/i', '', $lng), 0, 2);
if (!defined('LANGUAGE_ID')) {
    $rsSite = CSite::GetByID(SITE_ID);