aboutsummaryrefslogtreecommitdiffstats
path: root/include/config.php
blob: ec3547a8293de14d40fb13be06b88026e6af30d5 (plain) (blame)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
 * @file include/config.php
 * @brief Arbitrary configuration storage.
 *
 * Arrays get stored as serialized strings.
 * Booleans are stored as integer 0/1.
 *
 * - <b>config</b> is used for hub specific configurations. It overrides the
 * configurations from .htconfig file. The storage is of size TEXT.
 * - <b>pconfig</b> is used for channel specific configurations and takes a
 * <i>channel_id</i> as identifier. It stores for example which features are
 * enabled per channel. The storage is of size MEDIUMTEXT.
 * @code{.php} $var = get_pconfig(local_channel(), 'category', 'key');@endcode
 * - <b>xconfig</b> is the same as pconfig, except that it uses <i>xchan</i> as
 * an identifier. This is for example for people who do not have a local account.
 * The storage is of size MEDIUMTEXT.
 * @code{.php}
 * $observer = App::get_observer_hash();
 * if ($observer) {
 *     $var = get_xconfig($observer, 'category', 'key');
 * }@endcode
 *
 * - get_config() and set_config() can also be done through the command line tool
 * @ref util/config.md "util/config"
 * - get_pconfig() and set_pconfig() can also be done through the command line tool
 * @ref util/pconfig.md "util/pconfig" and takes a channel_id as first argument.
 *
 */


use Zotlabs\Lib as Zlib;

function load_config($family) {
	Zlib\Config::Load($family);
}

function get_config($family, $key, $default = false) {
	return Zlib\Config::Get($family,$key,$default);
}

function set_config($family, $key, $value) {
	return Zlib\Config::Set($family,$key,$value);
}

function del_config($family, $key) {
	return Zlib\Config::Delete($family,$key);
}

function load_pconfig($uid) {
	Zlib\PConfig::Load($uid);
}

function get_pconfig($uid, $family, $key, $default = false) {
	return Zlib\PConfig::Get($uid,$family,$key,$default);
}

function set_pconfig($uid, $family, $key, $value) {
	return Zlib\PConfig::Set($uid,$family,$key,$value);
}

function del_pconfig($uid, $family, $key, $updated = NULL) {
	return Zlib\PConfig::Delete($uid,$family,$key,$updated);
}

function load_xconfig($xchan) {
	Zlib\XConfig::Load($xchan);
}

function get_xconfig($xchan, $family, $key, $default = false) {
	return Zlib\XConfig::Get($xchan,$family,$key, $default);
}

function set_xconfig($xchan, $family, $key, $value) {
	return Zlib\XConfig::Set($xchan,$family,$key,$value);
}

function del_xconfig($xchan, $family, $key) {
	return Zlib\XConfig::Delete($xchan,$family,$key);
}

function load_aconfig($account_id) {
	Zlib\AConfig::Load($account_id);
}

function get_aconfig($account_id, $family, $key, $default = false) {
	return Zlib\AConfig::Get($account_id, $family, $key, $default);
}

function set_aconfig($account_id, $family, $key, $value) {
	return Zlib\AConfig::Set($account_id, $family, $key, $value);
}

function del_aconfig($account_id, $family, $key) {
	return Zlib\AConfig::Delete($account_id, $family, $key);
}

function load_abconfig($chan, $xhash, $family = '') {
	return Zlib\AbConfig::Load($chan,$xhash,$family);
}

function get_abconfig($chan,$xhash,$family,$key, $default = false) {
	return Zlib\AbConfig::Get($chan,$xhash,$family,$key, $default);
}

function set_abconfig($chan,$xhash,$family,$key,$value) {
	return Zlib\AbConfig::Set($chan,$xhash,$family,$key,$value);
}

function del_abconfig($chan,$xhash,$family,$key) {
	return Zlib\AbConfig::Delete($chan,$xhash,$family,$key);
}

function load_iconfig(&$item) {
	Zlib\IConfig::Load($item);
}

function get_iconfig(&$item, $family, $key, $default = false) {
	return Zlib\IConfig::Get($item, $family, $key, $default);
}

function set_iconfig(&$item, $family, $key, $value, $sharing = false) {
	return Zlib\IConfig::Set($item, $family, $key, $value, $sharing);
}

function del_iconfig(&$item, $family, $key) {
	return Zlib\IConfig::Delete($item, $family, $key);
}

function load_sconfig($server_id) {
	Zlib\SConfig::Load($server_id);
}

function get_sconfig($server_id, $family, $key, $default = false) {
	return Zlib\SConfig::Get($server_id, $family, $key, $default);
}

function set_sconfig($server_id, $family, $key, $value) {
	return Zlib\SConfig::Set($server_id, $family, $key, $value);
}

function del_sconfig($server_id, $family, $key) {
	return Zlib\SConfig::Delete($server_id, $family, $key);
}