This repository has been archived by the owner on Jul 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathclass.srWebAccessChecker.php
94 lines (75 loc) · 1.73 KB
/
class.srWebAccessChecker.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* srWebAccessChecker
*
* @author Fabian Schmid <fs@studer-raimann.ch>
*
* @version 2.0.7
*/
class srWebAccessChecker {
public function __construct() {
}
public function checkAccess() {
}
/**
* @return string
*/
private static function getLinkRoot() {
return ILIAS_HTTP_PATH . strstr(__FILE__, '/Customizing');
}
/**
* @param $obj_type
* @param $ref_id
* @param $sub_type
* @param $sub_id
* @param $version
*
* @return string
*/
public static function getLink($obj_type, $ref_id, $sub_type, $sub_id, $version = NULL) {
$arr_append = array(
'obj_type' => $obj_type,
'ref_id' => $ref_id,
'sub_type' => $sub_type,
'sub_id' => $sub_id
);
$str_append = array();
foreach ($arr_append as $k => $v) {
$str_append[] = $k . '=' . $v;
}
return self::getLinkRoot() . '?' . implode('&', $str_append);
}
/**
* @param $class
* @param $id
* @param null $ref_id
*
* @return string
*/
public static function getLinkByClass($class, $id, $ref_id = NULL) {
$ref_id = $ref_id ? $ref_id : $_GET['ref_id'];
$obj_type = ilObject2::_lookupType($ref_id, true);
return self::getLink($obj_type, $ref_id, $class, $id);
}
/**
* @param $obj
* @param null $ref_id
*
* @return string
*/
public static function getLinkForObject($obj, $ref_id = NULL) {
$ref_id = $ref_id ? $ref_id : $_GET['ref_id'];
return self::getLinkByClass(self::_fromCamelCase(get_class($obj)), $obj->getId(), $ref_id);
}
/**
* @param string $str
*
* @return string
*/
private static function _fromCamelCase($str) {
$str[0] = strtolower($str[0]);
$func = create_function('$c', 'return "_" . strtolower($c[1]);');
return preg_replace_callback('/([A-Z])/', $func, $str);
}
}
?>