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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
<?php
class MASK {
var $id; // MaskID
var $ids; // List of items
var $reader_mark;
function __construct(&$props = NULL, READER $reader = NULL, LOGGROUP $grp = NULL, $flags = 0) {
if ($flags&REQUEST::CONTROL) $prop_name = "control_mask";
else $prop_name = "db_mask";
if (is_array($props)) {
if (isset($props[$prop_name])) $mask = $props[$prop_name];
else $mask=true;
} else {
$mask = $props;
}
if ($mask === true) {
$this->ids = false;
$this->id = "all";
} else if (($mask===false)||(!strcmp($mask,"none"))) {
$this->ids = array();
$this->id = "none";
} else if ((!strcmp($mask,"all"))||(strlen($mask)==0)) {
$this->ids = false;
$this->id = "all";
} else {
$this->ids = preg_split("/,/", $mask);
if (count($this->ids)) {
$this->id = "custom";
} else {
$this->ids = false;
$this->id = "all";
}
}
$this->reader_mark = false;
}
function SetIDs($ids, $id = "custom") {
$this->ids = $ids;
$this->id = $id;
}
function Check($id) {
if (($this->ids===false)||(in_array("$id", $this->ids))) return true;
return false;
}
function CheckStandard($id) {
if ($this->ids===false) {
if (is_numeric($id)) return true;
} else {
if (in_array("$id", $this->ids)) return true;
}
return false;
}
function Get($id) {
if ($this->ids===false) return $id;
return $this->ids[$id];
}
function GetIDs() {
return $this->ids;
}
function GetProp() {
if ($this->ids) return implode(",", $this->ids);
else if ($this->ids === false) return "all";
else return "";
}
function SetReaderMark($mark) {
$this->reader_mark = $mark;
}
function GetReaderMark() {
return $this->reader_mark;
}
function IsFull() {
if ($this->ids === false) return true;
return false;
}
function IsEmpty() {
if ((is_array($this->ids))&&(!$this->ids)) return true;
return false;
}
function IsCustom() {
if (is_array($this->ids)) {
foreach ($this->ids as $id) {
if (!is_numeric($id)) return true;
}
}
return false;
}
function Superpose(MASK $mask = NULL) {
if ((!$mask)||($mask->IsFull())) return $this;
else if ($this->IsFull()) return $mask;
$res = array();
foreach ($mask->ids as $id) {
if (isset($this->ids[$id])) {
array_push($res, $this->ids[$id]);
} else {
throw new ADEIException(translate("Invalid mask (%s) is passed for supperposing. The base mask is (%s)", $mask->GetProp(), $this->GetProp()));
}
}
$mask = new MASK();
$mask->SetIDs($res);
return $mask;
}
}
?>
|