예제 #1
0
파일: options.php 프로젝트: ASDAFF/open_bx
	COption::SetOptionString($module_id, "GROUP_DEFAULT_RIGHT", $letter, "Right for groups by default");

	$nID = COperation::GetIDByName('edit_subordinate_users');
	$arTasksInModule = Array();
	foreach($arGROUPS as $value)
	{
		$tid = ${"TASKS_".$value["ID"]};
		$arTasksInModule[$value["ID"]] = Array('ID' => $tid);

		$subOrdGr = false;
		if (strlen($tid) > 0 && in_array($nID,CTask::GetOperations($tid)) && isset($_POST['subordinate_groups_'.$value["ID"]]))
			$subOrdGr = $_POST['subordinate_groups_'.$value["ID"]];

		CGroup::SetSubordinateGroups($value["ID"], $subOrdGr);

		$rt = ($tid) ? CTask::GetLetter($tid) : '';
		if (strlen($rt) > 0 && $rt != "NOT_REF")
			$APPLICATION->SetGroupRight($module_id, $value["ID"], $rt);
		else
			$APPLICATION->DelGroupRight($module_id, array($value["ID"]));
	}

	CGroup::SetTasksForModule($module_id, $arTasksInModule);

	if($_REQUEST["back_url_settings"] <> "" && $_REQUEST["Apply"] == "")
		LocalRedirect($_REQUEST["back_url_settings"]);
	else
		LocalRedirect("/freetrix/admin/settings.php?lang=".LANGUAGE_ID."&mid=".urlencode($mid)."&tabControl_active_tab=".urlencode($_REQUEST["tabControl_active_tab"])."&back_url_settings=".urlencode($_REQUEST["back_url_settings"]));
}

if($SET_LICENSE_KEY == "")
예제 #2
0
 function SetModulePermission($group_id, $module_id, $permission)
 {
     global $DB, $APPLICATION;
     if (intval($permission) <= 0 && $permission != false) {
         $strSql = "SELECT T.ID FROM b_task T WHERE T.MODULE_ID='" . $DB->ForSql($module_id) . "' AND NAME='" . $DB->ForSql($permission) . "'";
         $db_task = $DB->Query($strSql);
         if ($ar_task = $db_task->Fetch()) {
             $permission = $ar_task['ID'];
         }
     }
     if (intval($permission) > 0 || $permission === false) {
         $strSql = "SELECT T.ID FROM b_task T WHERE T.MODULE_ID='" . $DB->ForSql($module_id) . "'";
         $dbr_tasks = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $arIds = array();
         while ($arTask = $dbr_tasks->Fetch()) {
             $arIds[] = $arTask['ID'];
         }
         if (count($arIds) > 0) {
             $strSql = "DELETE FROM b_group_task WHERE GROUP_ID=" . IntVal($group_id) . " AND TASK_ID IN (" . implode(",", $arIds) . ")";
             $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         }
         if (intval($permission) > 0) {
             $DB->Query("INSERT INTO b_group_task (GROUP_ID, TASK_ID, EXTERNAL_ID) " . "SELECT G.ID, T.ID, '' " . "FROM b_group G, b_task T " . "WHERE G.ID = " . intval($group_id) . " AND T.ID = " . intval($permission), false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
             $permission_letter = CTask::GetLetter($permission);
         }
     } else {
         $permission_letter = $permission;
     }
     if (strlen($permission_letter) > 0) {
         $APPLICATION->SetGroupRight($module_id, $group_id, $permission_letter);
     } else {
         $APPLICATION->DelGroupRight($module_id, array($group_id));
     }
 }
예제 #3
0
파일: options.php 프로젝트: rasuldev/torino
    }
    $module_id = "main";
    COption::SetOptionString($module_id, "GROUP_DEFAULT_TASK", $GROUP_DEFAULT_TASK, "Task for groups by default");
    $letter = ($l = CTask::GetLetter($GROUP_DEFAULT_TASK)) ? $l : 'D';
    COption::SetOptionString($module_id, "GROUP_DEFAULT_RIGHT", $letter, "Right for groups by default");
    $nID = COperation::GetIDByName('edit_subordinate_users');
    $arTasksInModule = array();
    foreach ($arGROUPS as $value) {
        $tid = ${"TASKS_" . $value["ID"]};
        $arTasksInModule[$value["ID"]] = array('ID' => $tid);
        $subOrdGr = false;
        if (strlen($tid) > 0 && in_array($nID, CTask::GetOperations($tid)) && isset($_POST['subordinate_groups_' . $value["ID"]])) {
            $subOrdGr = $_POST['subordinate_groups_' . $value["ID"]];
        }
        CGroup::SetSubordinateGroups($value["ID"], $subOrdGr);
        $rt = $tid ? CTask::GetLetter($tid) : '';
        if (strlen($rt) > 0 && $rt != "NOT_REF") {
            $APPLICATION->SetGroupRight($module_id, $value["ID"], $rt);
        } else {
            $APPLICATION->DelGroupRight($module_id, array($value["ID"]));
        }
    }
    CGroup::SetTasksForModule($module_id, $arTasksInModule);
    if ($_REQUEST["back_url_settings"] != "" && $_REQUEST["Apply"] == "") {
        LocalRedirect($_REQUEST["back_url_settings"]);
    } else {
        LocalRedirect("/bitrix/admin/settings.php?lang=" . LANGUAGE_ID . "&mid=" . urlencode($mid) . "&tabControl_active_tab=" . urlencode($_REQUEST["tabControl_active_tab"]) . "&back_url_settings=" . urlencode($_REQUEST["back_url_settings"]));
    }
}
if ($SET_LICENSE_KEY == "") {
    $SET_LICENSE_KEY = LICENSE_KEY;
예제 #4
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;
     }
 }
예제 #5
0
     $res = $group->Update($ID, $arFields);
 } else {
     $ID = $group->Add($arFields);
     $res = $ID > 0;
     $new = "Y";
 }
 $strError .= $group->LAST_ERROR;
 if (strlen($strError) <= 0) {
     if (intval($ID) != 1 || COption::GetOptionString("main", "controller_member", "N") == "Y" && COption::GetOptionString("main", "~controller_limited_admin", "N") == "Y") {
         // set per module rights
         $arTasks = array();
         foreach ($arModules as $MID) {
             $moduleName = str_replace(".", "_", $MID);
             if (isset(${"TASKS_" . $moduleName})) {
                 $arTasks[$MID] = ${"TASKS_" . $moduleName};
                 $rt = CTask::GetLetter($arTasks[$MID]);
             } else {
                 $rt = array();
                 if (isset(${"RIGHTS_" . $moduleName})) {
                     $rt = ${"RIGHTS_" . $moduleName};
                 }
                 $st = array();
                 if (isset(${"SITES_" . $moduleName})) {
                     $st = ${"SITES_" . $moduleName};
                 }
                 // echo "Delete group rights for all sites<br>";
                 $APPLICATION->DelGroupRight($MID, array($ID), false);
                 foreach ($arSites["reference_id"] as $site_id_tmp) {
                     // echo "Delete group rights for site ".$site_id_tmp."<br>";
                     $APPLICATION->DelGroupRight($MID, array($ID), $site_id_tmp);
                 }