-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule_helper.php
77 lines (69 loc) · 1.96 KB
/
module_helper.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
<?php
//disable html errors in modules
ini_set("html_errors", "0");
/**
* @class T2DModule
*
* IPS Module Helper Class
* combines often used functions and constants
*
*/
class KoHelpDModule extends IPSModule
{
protected function GetParent($id = 0)
{
$parent = 0;
if ($id == 0) $id = $this->InstanceID;
if (IPS_InstanceExists($id)) {
$instance = IPS_GetInstance($id);
$parent = $instance['ConnectionID'];
} else {
$this->debug(__FUNCTION__, "Instance #$id doesn't exists");
}
return $parent;
}
private function SetValueBoolean($Ident, $value)
{
$id = $this->GetIDForIdent($Ident);
if (GetValueBoolean($id) <> $value)
{
SetValueBoolean($id, $value);
return true;
}
return false;
}
private function SetValueInteger($Ident, $value)
{
$id = $this->GetIDForIdent($Ident);
if (GetValueInteger($id) <> $value)
{
SetValueInteger($id, $value);
return true;
}
return false;
}
private function SetValueString($Ident, $value)
{
$id = $this->GetIDForIdent($Ident);
if (GetValueString($id) <> $value)
{
SetValueString($id, $value);
return true;
}
return false;
}
private function SetParentName ($GetName, $SetName) {
$pid = $this->GetParent();
if ($pid) {
$name = IPS_GetName($pid);
if ($name == $GetName) {
IPS_SetName($pid, __CLASS__ . " " . $SetName);
}
}
}
protected function SetStatus($InstanceStatus)
{
if ($InstanceStatus <> IPS_GetInstance($this->InstanceID)['InstanceStatus'])
parent::SetStatus($InstanceStatus);
}
}