Example #1
0
    //	{
    $bNeedButton = $arParams["OBJECT"]->workflow == "bizproc";
    if ($arParams["OBJECT"]->workflow == "bizproc_limited") {
        $bNeedButton = CIBlock::GetArrayByID($arParams["OBJECT"]->IBLOCK_ID, "BIZPROC") != "N";
    }
    if ($bNeedButton) {
        $component->arResult["arButtons"] = is_array($component->arResult["arButtons"]) ? $component->arResult["arButtons"] : array();
        $component->arResult["arButtons"][] = array("TEXT" => GetMessage("SOCNET_SETTINGS"), "TITLE" => GetMessage("SOCNET_SETTINGS_ALT"), "LINK" => "javascript:" . $APPLICATION->GetPopupLink(array("URL" => $component->__path . "/include/webdav_settings.php?DOCUMENT_ID=" . $arParams["OBJECT"]->wfParams['DOCUMENT_TYPE'][2] . "&back_url=" . urlencode($APPLICATION->GetCurPage()), "PARAMS" => array("min_width" => 300, "min_height" => 150))), "ICON" => "btn-list settings");
    }
    //	}
}
$result = $APPLICATION->IncludeComponent("bitrix:webdav.menu", ".default", array("OBJECT" => $arParams["OBJECT"], "SECTION_ID" => $arResult["VARIABLES"]["SECTION_ID"], "ELEMENT_ID" => $arResult["VARIABLES"]["ELEMENT_ID"], "PAGE_NAME" => $arResult["VARIABLES"]["PAGE_NAME"], "ACTION" => $arResult["VARIABLES"]["ACTION"], "BASE_URL" => $arResult["VARIABLES"]["BASE_URL"], "SECTIONS_URL" => $arResult["~PATH_TO_USER_FILES"], "SECTION_EDIT_URL" => $arResult["~PATH_TO_USER_FILES_SECTION_EDIT"], "ELEMENT_URL" => $arResult["~PATH_TO_USER_FILES_ELEMENT"], "ELEMENT_EDIT_URL" => $arResult["~PATH_TO_USER_FILES_ELEMENT_EDIT"], "ELEMENT_FILE_URL" => $arResult["~PATH_TO_USER_FILES_ELEMENT_FILE"], "ELEMENT_HISTORY_URL" => $arResult["~PATH_TO_USER_FILES_ELEMENT_HISTORY"], "ELEMENT_HISTORY_GET_URL" => $arResult["~PATH_TO_USER_FILES_ELEMENT_HISTORY_GET"], "ELEMENT_VERSION_URL" => $arResult["~PATH_TO_USER_FILES_ELEMENT_VERSION"], "ELEMENT_VERSIONS_URL" => $arResult["~PATH_TO_USER_FILES_ELEMENT_VERSIONS"], "ELEMENT_UPLOAD_URL" => $arResult["~PATH_TO_USER_FILES_ELEMENT_UPLOAD"], "HELP_URL" => $arResult["~PATH_TO_USER_FILES_HELP"], "USER_VIEW_URL" => $arResult["~PATH_TO_USER"], "WEBDAV_BIZPROC_HISTORY_URL" => $arResult["~PATH_TO_USER_FILES_WEBDAV_BIZPROC_HISTORY"], "WEBDAV_BIZPROC_HISTORY_GET_URL" => $arResult["~PATH_TO_USER_FILES_WEBDAV_BIZPROC_HISTORY_GET"], "WEBDAV_BIZPROC_LOG_URL" => $arResult["~PATH_TO_USER_FILES_WEBDAV_BIZPROC_LOG"], "WEBDAV_BIZPROC_VIEW_URL" => $arResult["~PATH_TO_USER_FILES_WEBDAV_BIZPROC_VIEW"], "WEBDAV_BIZPROC_WORKFLOW_ADMIN_URL" => $arResult["~PATH_TO_USER_FILES_WEBDAV_BIZPROC_WORKFLOW_ADMIN"], "WEBDAV_BIZPROC_WORKFLOW_EDIT_URL" => $arResult["~PATH_TO_USER_FILES_WEBDAV_BIZPROC_WORKFLOW_EDIT"], "WEBDAV_START_BIZPROC_URL" => $arResult["~PATH_TO_USER_FILES_WEBDAV_START_BIZPROC"], "WEBDAV_TASK_LIST_URL" => $arResult["~PATH_TO_BIZPROC_TASK_LIST"], "WEBDAV_TASK_URL" => $arResult["~PATH_TO_BIZPROC_TASK"], "BIZPROC" => $arResult["VARIABLES"]["BIZPROC"], "USE_COMMENTS" => "N", "FORUM_ID" => false, "STR_TITLE" => $arResult["VARIABLES"]["STR_TITLE"], "SHOW_WEBDAV" => $arResult["VARIABLES"]["SHOW_WEBDAV"]), $component, array("HIDE_ICONS" => "Y"));
$this->__component->__menu_values = $result;
if ($arParams["SHOW_NAVIGATION"] != "N") {
    // text from main
    CMain::InitPathVars($site, $path);
    $DOC_ROOT = CSite::GetSiteDocRoot($site);
    $path = $GLOBALS["APPLICATION"]->GetCurDir();
    $arChain = array();
    while (true) {
        $path = rtrim($path, "/");
        $chain_file_name = $DOC_ROOT . $path . "/.section.php";
        if (file_exists($chain_file_name)) {
            $sSectionName = "";
            include $chain_file_name;
            if (strlen($sSectionName) > 0) {
                $arChain[] = array("TITLE" => $sSectionName, "LINK" => $path . "/");
            }
        }
        if ($path . '/' == SITE_DIR) {
            break;
Example #2
0
 function FetchFileAccessPerm($path)
 {
     CMain::InitPathVars($site, $path);
     $DOC_ROOT = CSite::GetSiteDocRoot($site);
     $result = false;
     if (($p = bxstrrpos($path, "/")) === false) {
         return $result;
     }
     $path_file = substr($path, $p + 1);
     $path_dir = substr($path, 0, $p);
     $io = CBXVirtualIo::GetInstance();
     if (!$io->FileExists($DOC_ROOT . $path_dir . "/.access.php")) {
         return $result;
     }
     include $io->GetPhysicalName($DOC_ROOT . $path_dir . "/.access.php");
     $result = array();
     foreach ($PERM as $file => $arPerm) {
         if ($file == $path_file) {
             foreach ($arPerm as $group => $perm) {
                 $result[] = array('permFile' => $DOC_ROOT . $path_dir . "/.access.php", 'file' => $file, 'group' => $group, 'perm' => $perm);
             }
         }
     }
     return $result;
 }
Example #3
0
 function ReindexFile($path, $SEARCH_SESS_ID = "", $max_file_size = 0)
 {
     global $APPLICATION;
     CMain::InitPathVars($site, $path);
     $DOC_ROOT = CSite::GetSiteDocRoot($site);
     if (!CUrlRewriter::CheckPath($path)) {
         return 0;
     }
     if ($max_file_size > 0 && filesize($DOC_ROOT . "/" . $path) > $max_file_size * 1024) {
         return 0;
     }
     $filesrc = $APPLICATION->GetFileContent($DOC_ROOT . "/" . $path);
     if (!$filesrc || $filesrc == "") {
         return 0;
     }
     $arComponents = PHPParser::ParseScript($filesrc);
     for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) {
         if ($arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y") {
             $arFields = array("SITE_ID" => $site, "CONDITION" => "#^" . $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] . "#", "RULE" => "", "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path);
             CUrlRewriter::Add($arFields);
         }
     }
     return true;
 }
Example #4
0
	function OnChangeFilePermissions($path, $permission = array(), $old_permission = array(), $arGroups = false)
	{

		global $APPLICATION;
		$DB = CDatabase::GetModuleConnection('search');

		$site = false;
		CMain::InitPathVars($site, $path);
		$DOC_ROOT = CSite::GetSiteDocRoot($site);
		$path = rtrim($path, "/");

		if(!is_array($arGroups))
		{
			$arGroups = CSearch::GetGroupCached();
			//Check if anonymous permission was changed
			if(!array_key_exists(2, $permission) && array_key_exists("*", $permission))
				$permission[2] = $permission["*"];
			if(!is_array($old_permission))
				$old_permission = array();
			if(!array_key_exists(2, $old_permission) && array_key_exists("*", $old_permission))
				$old_permission[2] = $old_permission["*"];
			//And if not when will do nothing
			if(
				(array_key_exists(2, $permission)
				&& $permission[2] >= "R")
				&& array_key_exists(2, $old_permission)
				&& $old_permission[2] >= "R"
			)
			{
				return;
			}
		}

		if(file_exists($DOC_ROOT.$path))
		{
			@set_time_limit(300);
			if(is_dir($DOC_ROOT.$path))
			{
				$handle = @opendir($DOC_ROOT.$path);
				while(false !== ($file = @readdir($handle)))
				{
					if($file == "." || $file == "..")
						continue;

					$full_file = $path."/".$file;
					if($full_file == "/bitrix")
						continue;

					if(is_dir($DOC_ROOT.$full_file) || CSearch::CheckPath($full_file))
						CSearch::OnChangeFilePermissions(array($site, $full_file), array(), array(), $arGroups);
				}
			}
			else//if(is_dir($DOC_ROOT.$path))
			{
				$rs = $DB->Query("
					SELECT SC.ID
					FROM b_search_content SC
					WHERE MODULE_ID='main'
					AND ITEM_ID='".$DB->ForSql($site."|".$path)."'
				", false, "File: ".__FILE__."<br>Line: ".__LINE__);
				if($ar = $rs->Fetch())
				{
					$arNewGroups = array();
					foreach($arGroups as $group_id)
					{
						$p = $APPLICATION->GetFileAccessPermission(array($site, $path), array($group_id));
						if($p >= "R")
						{
							$arNewGroups[$group_id] = 'G'.$group_id;
							if($group_id == 2)
								break;
						}
					}
					CAllSearch::SetContentItemGroups($ar["ID"], $arNewGroups);
				}
			} //if(is_dir($DOC_ROOT.$path))
		}//if(file_exists($DOC_ROOT.$path))
	}
Example #5
0
 function GetFileAccessPermissionByUser($intUserID, $path, $groups = false, $task_mode = false)
 {
     $intUserIDTmp = intval($intUserID);
     if ($intUserIDTmp . '|' != $intUserID . '|') {
         return !$task_mode ? 'D' : array(CTask::GetIdByLetter('D', 'main', 'file'));
     }
     $intUserID = $intUserIDTmp;
     if ($groups === false) {
         $groups = CUser::GetUserGroup($intUserID);
         foreach ($groups as $key => $val) {
             $groups[$key] = "G" . $val;
         }
     } elseif (is_array($groups) && !empty($groups)) {
         $bNumbers = preg_match('/^[0-9]+$/', $groups[0]);
         if ($bNumbers) {
             foreach ($groups as $key => $val) {
                 $groups[$key] = "G" . $val;
             }
         }
     }
     CMain::InitPathVars($site, $path);
     $DOC_ROOT = CSite::GetSiteDocRoot($site);
     $bWin = strncasecmp(PHP_OS, "WIN", 3) == 0;
     if ($bWin) {
         $path = strtolower($path);
     }
     if (trim($path, "/") != "") {
         $path = Rel2Abs("/", $path);
         if ($path == "") {
             return !$task_mode ? 'D' : array(CTask::GetIdByLetter('D', 'main', 'file'));
         }
     }
     $bAdminM = in_array("G1", $groups);
     if ($bAdminM) {
         return !$task_mode ? 'X' : array(CTask::GetIdByLetter('X', 'main', 'file'));
     }
     if (substr($path, -12) == "/.access.php" && !$bAdminM) {
         return !$task_mode ? 'D' : array(CTask::GetIdByLetter('D', 'main', 'file'));
     }
     if (substr($path, -10) == "/.htaccess" && !$bAdminM) {
         return !$task_mode ? 'D' : array(CTask::GetIdByLetter('D', 'main', 'file'));
     }
     $max_perm = "D";
     $arGroupTask = array();
     $io = CBXVirtualIo::GetInstance();
     $groups[] = "*";
     while (true) {
         $path = rtrim($path, "");
         $path = rtrim($path, "/");
         if ($path == '') {
             $access_file_name = "/.access.php";
             $Dir = "/";
         } else {
             $pos = strrpos($path, "/");
             if ($pos === false) {
                 break;
             }
             $Dir = substr($path, $pos + 1);
             $Dir = TrimUnsafe($Dir);
             $path = substr($path, 0, $pos + 1);
             $access_file_name = $path . ".access.php";
         }
         if (array_key_exists($site . "|" . $access_file_name, $this->FILE_PERMISSION_CACHE)) {
             $PERM = $this->FILE_PERMISSION_CACHE[$site . "|" . $access_file_name];
         } else {
             $PERM = array();
             if ($io->FileExists($DOC_ROOT . $access_file_name)) {
                 include $io->GetPhysicalName($DOC_ROOT . $access_file_name);
             }
             if ($bWin && !empty($PERM)) {
                 $PERM_TMP = array();
                 foreach ($PERM as $key => $val) {
                     $PERM_TMP[strtolower($key)] = $val;
                 }
                 $PERM = $PERM_TMP;
             }
             $this->FILE_PERMISSION_CACHE[$site . "|" . $access_file_name] = $PERM;
         }
         if ($PERM[$Dir] && is_array($PERM[$Dir])) {
             $dir_perm = $PERM[$Dir];
             foreach ($groups as $key => $group_id) {
                 if (isset($dir_perm[$group_id])) {
                     $perm = $dir_perm[$group_id];
                 } elseif (preg_match('/^G[0-9]+$/', $group_id)) {
                     //compatibility with group id
                     $perm = $dir_perm[substr($group_id, 1)];
                 } else {
                     continue;
                 }
                 if ($task_mode) {
                     if (substr($perm, 0, 2) == 'T_') {
                         $tid = intval(substr($perm, 2));
                     } elseif (($tid = CTask::GetIdByLetter($perm, 'main', 'file')) === false) {
                         continue;
                     }
                     $arGroupTask[$group_id] = $tid;
                 } else {
                     if (substr($perm, 0, 2) == 'T_') {
                         $tid = intval(substr($perm, 2));
                         $perm = CTask::GetLetter($tid);
                         if (strlen($perm) == 0) {
                             $perm = 'D';
                         }
                     }
                     if ($max_perm == "" || $perm > $max_perm) {
                         $max_perm = $perm;
                         if ($perm == "W") {
                             break 2;
                         }
                     }
                 }
                 if ($group_id == "*") {
                     break 2;
                 }
                 unset($groups[$key]);
                 if (count($groups) == 1 && in_array("*", $groups)) {
                     break 2;
                 }
             }
             if (count($groups) <= 1) {
                 break;
             }
         }
         if ($path == '') {
             break;
         }
     }
     if ($task_mode) {
         $arTasks = array_unique(array_values($arGroupTask));
         if (empty($arTasks)) {
             return array(CTask::GetIdByLetter('D', 'main', 'file'));
         }
         sort($arTasks);
         return $arTasks;
     } else {
         return $max_perm;
     }
 }
Example #6
0
 function SetFilePermission($path, $permissions)
 {
     $originalPath = $path;
     CMain::InitPathVars($site, $path);
     $documentRoot = CSite::GetSiteDocRoot($site);
     $path = rtrim($path, "/");
     if (strlen($path) <= 0) {
         $path = "/";
     }
     if (($position = strrpos($path, "/")) !== false) {
         $pathFile = substr($path, $position + 1);
         $pathDir = substr($path, 0, $position);
     } else {
         return false;
     }
     if ($pathFile == "" && $pathDir == "") {
         $pathFile = "/";
     }
     $PERM = array();
     if (file_exists($documentRoot . $pathDir . "/.access.php")) {
         //include replaced with eval in order to honor of ZendServer
         eval("?>" . file_get_contents($documentRoot . $pathDir . "/.access.php"));
     }
     if (!isset($PERM[$pathFile]) || !is_array($PERM[$pathFile])) {
         $arPermisson = $permissions;
     } else {
         $arPermisson = $permissions + $PERM[$pathFile];
     }
     return $GLOBALS["APPLICATION"]->SetFileAccessPermission($originalPath, $arPermisson);
 }
Example #7
0
	function SetFilePermission($path, $permissions)
	{
		$originalPath = $path;

		CMain::InitPathVars($site, $path);
		$documentRoot = CSite::GetSiteDocRoot($site);

		$path = rtrim($path, "/");

		if (strlen($path) <= 0)
			$path = "/";

		if( ($position = strrpos($path, "/")) !== false)
		{
			$pathFile = substr($path, $position+1);
			$pathDir = substr($path, 0, $position);
		}
		else
			return false;

		if ($pathFile == "" && $pathDir == "")
			$pathFile = "/";

		$PERM = Array();
		if(file_exists($documentRoot.$pathDir."/.access.php"))
			@include($documentRoot.$pathDir."/.access.php");

		if (!isset($PERM[$pathFile]) || !is_array($PERM[$pathFile]))
			$arPermisson = $permissions;
		else
			$arPermisson = $permissions + $PERM[$pathFile];

		return $GLOBALS["APPLICATION"]->SetFileAccessPermission($originalPath, $arPermisson);
	}
Example #8
0
 public static function ReindexFile($path, $SEARCH_SESS_ID = "", $max_file_size = 0)
 {
     global $APPLICATION;
     CMain::InitPathVars($site, $path);
     $DOC_ROOT = CSite::GetSiteDocRoot($site);
     if (!CUrlRewriter::CheckPath($path)) {
         return 0;
     }
     if ($max_file_size > 0 && filesize($DOC_ROOT . "/" . $path) > $max_file_size * 1024) {
         return 0;
     }
     $filesrc = $APPLICATION->GetFileContent($DOC_ROOT . "/" . $path);
     if (!$filesrc || $filesrc == "") {
         return 0;
     }
     $arComponents = PHPParser::ParseScript($filesrc);
     for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++) {
         if ($arComponents[$i]["DATA"]["PARAMS"]["SEF_MODE"] == "Y") {
             if (array_key_exists("SEF_RULE", $arComponents[$i]["DATA"]["PARAMS"])) {
                 $ruleMaker = new \Bitrix\Main\UrlRewriterRuleMaker();
                 $ruleMaker->process($arComponents[$i]["DATA"]["PARAMS"]["SEF_RULE"]);
                 CUrlRewriter::Add(array("SITE_ID" => $site, "CONDITION" => $ruleMaker->getCondition(), "RULE" => $ruleMaker->getRule(), "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path));
             } else {
                 CUrlRewriter::Add(array("SITE_ID" => $site, "CONDITION" => "#^" . $arComponents[$i]["DATA"]["PARAMS"]["SEF_FOLDER"] . "#", "RULE" => "", "ID" => $arComponents[$i]["DATA"]["COMPONENT_NAME"], "PATH" => $path));
             }
         }
     }
     return true;
 }
Example #9
0
function GetDirList($path, &$arDirs, &$arFiles, $arFilter = array(), $sort = array(), $type = "DF", $bLogical = false, $task_mode = false)
{
    global $USER, $APPLICATION;
    CMain::InitPathVars($site, $path);
    $DOC_ROOT = CSite::GetSiteDocRoot($site);
    $arDirs = array();
    $arFiles = array();
    $exts = strtolower($arFilter["EXTENSIONS"]);
    $arexts = explode(",", $exts);
    if (isset($arFilter["TYPE"])) {
        $type = strtoupper($arFilter["TYPE"]);
    }
    $io = CBXVirtualIo::GetInstance();
    $path = $io->CombinePath("/", $path);
    $abs_path = $io->CombinePath($DOC_ROOT, $path);
    if (!$io->DirectoryExists($abs_path)) {
        return false;
    }
    $date_format = CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL"));
    $tzOffset = CTimeZone::GetOffset();
    $dir = $io->GetDirectory($abs_path);
    $arChildren = $dir->GetChildren();
    foreach ($arChildren as $child) {
        $arFile = array();
        if (($type == "F" || $type == "") && $child->IsDirectory()) {
            continue;
        }
        if (($type == "D" || $type == "") && !$child->IsDirectory()) {
            continue;
        }
        $file = $child->GetName();
        if ($bLogical) {
            if ($child->IsDirectory()) {
                $sSectionName = "";
                $fsn = $io->CombinePath($abs_path, $file, ".section.php");
                if (!$io->FileExists($fsn)) {
                    continue;
                }
                include $io->GetPhysicalName($fsn);
                $arFile["LOGIC_NAME"] = $sSectionName;
            } else {
                if (CFileMan::GetFileTypeEx($file) != "php") {
                    continue;
                }
                if ($file == '.section.php') {
                    continue;
                }
                if (!preg_match('/^\\.(.*)?\\.menu\\.(php|html|php3|php4|php5|php6|phtml)$/', $file, $regs)) {
                    $f = $io->GetFile($abs_path . "/" . $file);
                    $filesrc = $f->GetContents();
                    $title = PHPParser::getPageTitle($filesrc);
                    if ($title === false) {
                        continue;
                    }
                    $arFile["LOGIC_NAME"] = $title;
                }
            }
        }
        $arFile["PATH"] = $abs_path . "/" . $file;
        $arFile["ABS_PATH"] = $path . "/" . $file;
        $arFile["NAME"] = $file;
        $arPerm = $APPLICATION->GetFileAccessPermission(array($site, $path . "/" . $file), $USER->GetUserGroupArray(), $task_mode);
        if ($task_mode) {
            $arFile["PERMISSION"] = $arPerm[0];
            if (count($arPerm[1]) > 0) {
                $arFile["PERMISSION_EX"] = $arPerm[1];
            }
        } else {
            $arFile["PERMISSION"] = $arPerm;
        }
        $arFile["TIMESTAMP"] = $child->GetModificationTime() + $tzOffset;
        $arFile["DATE"] = date($date_format, $arFile["TIMESTAMP"]);
        if (isset($arFilter["TIMESTAMP_1"]) && strtotime($arFile["DATE"]) < strtotime($arFilter["TIMESTAMP_1"])) {
            continue;
        }
        if (isset($arFilter["TIMESTAMP_2"]) && strtotime($arFile["DATE"]) > strtotime($arFilter["TIMESTAMP_2"])) {
            continue;
        }
        if (is_set($arFilter, "MIN_PERMISSION") && $arFile["PERMISSION"] < $arFilter["MIN_PERMISSION"] && !$task_mode) {
            continue;
        }
        if (!$child->IsDirectory() && $arFile["PERMISSION"] <= "R" && !$task_mode) {
            continue;
        }
        if ($bLogical) {
            if (strlen($arFilter["NAME"]) > 0 && strpos($arFile["LOGIC_NAME"], $arFilter["NAME"]) === false) {
                continue;
            }
        } else {
            if (strlen($arFilter["NAME"]) > 0 && strpos($arFile["NAME"], $arFilter["NAME"]) === false) {
                continue;
            }
        }
        //if(strlen($arFilter["NAME"])>0 && strpos($arFile["NAME"], $arFilter["NAME"])===false)
        //	continue;
        if (substr($arFile["ABS_PATH"], 0, strlen(BX_ROOT . "/modules")) == BX_ROOT . "/modules" && !$USER->CanDoOperation('edit_php') && !$task_mode) {
            continue;
        }
        if ($arFile["PERMISSION"] == "U" && !$task_mode) {
            $ftype = GetFileType($arFile["NAME"]);
            if ($ftype != "SOURCE" && $ftype != "IMAGE" && $ftype != "UNKNOWN") {
                continue;
            }
            if (substr($arFile["NAME"], 0, 1) == ".") {
                continue;
            }
        }
        if ($child->IsDirectory()) {
            $arFile["SIZE"] = 0;
            $arFile["TYPE"] = "D";
            $arDirs[] = $arFile;
        } else {
            if ($exts != "") {
                if (!in_array(strtolower(substr($file, bxstrrpos($file, ".") + 1)), $arexts)) {
                    continue;
                }
            }
            $arFile["TYPE"] = "F";
            $arFile["SIZE"] = $child->GetFileSize();
            $arFiles[] = $arFile;
        }
    }
    if (is_array($sort) && count($sort) > 0) {
        $by = key($sort);
        $order = strtolower($sort[$by]);
        $by = strtolower($by);
        if ($order != "desc") {
            $order = "asc";
        }
        if ($by != "size" && $by != "timestamp") {
            $by = "name";
        }
        usort($arDirs, array("_FilesCmp", "cmp_" . $by . "_" . $order));
        usort($arFiles, array("_FilesCmp", "cmp_" . $by . "_" . $order));
    }
    return null;
}
Example #10
0
 public static function GetEditLink($FILENAME, &$status_id, &$status_title, $template = "", $lang = LANGUAGE_ID, $return_url = "")
 {
     $err_mess = CAllWorkflow::err_mess() . "<br>Function: GetEditLink<br>Line: ";
     global $DB, $APPLICATION, $USER;
     $link = '';
     CMain::InitPathVars($SITE_ID, $FILENAME);
     if ($USER->CanDoFileOperation('fm_edit_in_workflow', array($SITE_ID, $FILENAME))) {
         //Check if user have access at least to one status
         if (!CWorkflow::IsAdmin()) {
             $arGroups = $USER->GetUserGroupArray();
             if (!is_array($arGroups)) {
                 $arGroups = array(2);
             }
             $arFilter = array("GROUP_ID" => $arGroups, "PERMISSION_TYPE_1" => 1);
             $rsStatuses = CWorkflowStatus::GetList($by = "s_c_sort", $strOrder, $arFilter, $is_filtered, array("ID"));
             if (!$rsStatuses->Fetch()) {
                 return "";
             }
         }
         $link = "/bitrix/admin/workflow_edit.php?lang=" . $lang . "&site=" . $SITE_ID . "&fname=" . $FILENAME;
         if (strlen($template) > 0) {
             $link .= "&template=" . urlencode($template);
         }
         if (strlen($return_url) > 0) {
             $link .= "&return_url=" . urlencode($return_url);
         }
         $z = CWorkflow::GetByFilename($FILENAME, $SITE_ID);
         if ($zr = $z->Fetch()) {
             $status_id = $zr["STATUS_ID"];
             $status_title = $zr["STATUS_TITLE"];
             if ($status_id != 1) {
                 $DOCUMENT_ID = $zr["ID"];
                 if (CWorkflow::IsHaveEditRights($DOCUMENT_ID)) {
                     $link .= "&ID=" . $DOCUMENT_ID;
                 } else {
                     return "";
                 }
             }
         }
     }
     return $link;
 }