2014-09-26 20:28:35 +00:00
|
|
|
<?php
|
2011-08-10 08:19:27 +00:00
|
|
|
/**
|
2014-09-26 20:28:35 +00:00
|
|
|
* @file include/config.php
|
|
|
|
* @brief Arbitrary configuration storage.
|
2011-08-10 08:19:27 +00:00
|
|
|
*
|
2016-05-30 23:42:29 +00:00
|
|
|
* Arrays get stored as serialized strings.
|
|
|
|
* Booleans are stored as integer 0/1.
|
2014-09-26 20:28:35 +00:00
|
|
|
*
|
|
|
|
* - <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.
|
2015-03-21 23:06:08 +00:00
|
|
|
* @code{.php} $var = get_pconfig(local_channel(), 'category', 'key');@endcode
|
2014-09-26 20:28:35 +00:00
|
|
|
* - <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.
|
2015-03-21 23:06:08 +00:00
|
|
|
* @code{.php}
|
2016-03-31 23:06:03 +00:00
|
|
|
* $observer = App::get_observer_hash();
|
2014-09-26 20:28:35 +00:00
|
|
|
* if ($observer) {
|
|
|
|
* $var = get_xconfig($observer, 'category', 'key');
|
|
|
|
* }@endcode
|
|
|
|
*
|
|
|
|
* - get_config() and set_config() can also be done through the command line tool
|
2015-03-21 23:06:08 +00:00
|
|
|
* @ref util/config.md "util/config"
|
2014-09-26 20:28:35 +00:00
|
|
|
* - get_pconfig() and set_pconfig() can also be done through the command line tool
|
2016-10-01 22:41:25 +00:00
|
|
|
* @ref util/pconfig.md "util/pconfig" and takes a channel_id as first argument.
|
2014-09-26 20:28:35 +00:00
|
|
|
*
|
2011-08-10 08:19:27 +00:00
|
|
|
*/
|
|
|
|
|
2013-06-18 03:16:50 +00:00
|
|
|
|
2016-05-30 23:42:29 +00:00
|
|
|
use Zotlabs\Lib as Zlib;
|
2011-08-01 23:51:01 +00:00
|
|
|
|
2016-05-30 23:42:29 +00:00
|
|
|
function load_config($family) {
|
|
|
|
Zlib\Config::Load($family);
|
2013-02-26 23:49:37 +00:00
|
|
|
}
|
2011-08-01 23:51:01 +00:00
|
|
|
|
2016-12-05 22:50:34 +00:00
|
|
|
function get_config($family, $key, $default = false) {
|
|
|
|
return Zlib\Config::Get($family,$key,$default);
|
2013-06-22 04:36:48 +00:00
|
|
|
}
|
|
|
|
|
2014-09-26 20:28:35 +00:00
|
|
|
function set_config($family, $key, $value) {
|
2016-05-30 23:42:29 +00:00
|
|
|
return Zlib\Config::Set($family,$key,$value);
|
2013-02-26 23:49:37 +00:00
|
|
|
}
|
|
|
|
|
2014-09-26 20:28:35 +00:00
|
|
|
function del_config($family, $key) {
|
2016-05-30 23:42:29 +00:00
|
|
|
return Zlib\Config::Delete($family,$key);
|
2013-03-15 22:36:58 +00:00
|
|
|
}
|
|
|
|
|
2014-09-26 20:28:35 +00:00
|
|
|
function load_pconfig($uid) {
|
2016-06-06 05:18:17 +00:00
|
|
|
Zlib\PConfig::Load($uid);
|
2013-02-26 23:49:37 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 22:50:34 +00:00
|
|
|
function get_pconfig($uid, $family, $key, $default = false) {
|
|
|
|
return Zlib\PConfig::Get($uid,$family,$key,$default);
|
2013-02-26 23:49:37 +00:00
|
|
|
}
|
|
|
|
|
2016-06-06 05:18:17 +00:00
|
|
|
function set_pconfig($uid, $family, $key, $value) {
|
|
|
|
return Zlib\PConfig::Set($uid,$family,$key,$value);
|
2013-02-26 23:49:37 +00:00
|
|
|
}
|
|
|
|
|
2014-09-26 20:28:35 +00:00
|
|
|
function del_pconfig($uid, $family, $key) {
|
2016-06-06 05:18:17 +00:00
|
|
|
return Zlib\PConfig::Delete($uid,$family,$key);
|
2013-02-26 23:49:37 +00:00
|
|
|
}
|
2013-03-15 22:36:58 +00:00
|
|
|
|
2014-09-26 20:28:35 +00:00
|
|
|
function load_xconfig($xchan) {
|
2016-06-08 01:17:39 +00:00
|
|
|
Zlib\XConfig::Load($xchan);
|
2013-03-15 22:36:58 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 22:50:34 +00:00
|
|
|
function get_xconfig($xchan, $family, $key, $default = false) {
|
|
|
|
return Zlib\XConfig::Get($xchan,$family,$key, $default);
|
2013-03-15 22:36:58 +00:00
|
|
|
}
|
|
|
|
|
2014-09-26 20:28:35 +00:00
|
|
|
function set_xconfig($xchan, $family, $key, $value) {
|
2016-06-08 01:17:39 +00:00
|
|
|
return Zlib\XConfig::Set($xchan,$family,$key,$value);
|
2013-03-15 22:36:58 +00:00
|
|
|
}
|
|
|
|
|
2014-09-26 20:28:35 +00:00
|
|
|
function del_xconfig($xchan, $family, $key) {
|
2016-06-08 01:17:39 +00:00
|
|
|
return Zlib\XConfig::Delete($xchan,$family,$key);
|
2013-03-15 22:36:58 +00:00
|
|
|
}
|
2016-01-12 07:54:53 +00:00
|
|
|
|
|
|
|
function load_aconfig($account_id) {
|
2016-06-08 01:17:39 +00:00
|
|
|
Zlib\AConfig::Load($account_id);
|
2016-01-12 07:54:53 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 22:50:34 +00:00
|
|
|
function get_aconfig($account_id, $family, $key, $default = false) {
|
|
|
|
return Zlib\AConfig::Get($account_id, $family, $key, $default);
|
2016-01-12 07:54:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function set_aconfig($account_id, $family, $key, $value) {
|
2016-06-08 01:17:39 +00:00
|
|
|
return Zlib\AConfig::Set($account_id, $family, $key, $value);
|
2016-01-12 07:54:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function del_aconfig($account_id, $family, $key) {
|
2016-06-08 01:17:39 +00:00
|
|
|
return Zlib\AConfig::Delete($account_id, $family, $key);
|
2016-03-01 03:31:52 +00:00
|
|
|
}
|
|
|
|
|
2016-07-14 03:17:40 +00:00
|
|
|
function load_abconfig($chan, $xhash, $family = '') {
|
|
|
|
return Zlib\AbConfig::Load($chan,$xhash,$family);
|
2016-03-01 03:31:52 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 22:50:34 +00:00
|
|
|
function get_abconfig($chan,$xhash,$family,$key, $default = false) {
|
|
|
|
return Zlib\AbConfig::Get($chan,$xhash,$family,$key, $default);
|
2016-03-01 03:31:52 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 01:12:26 +00:00
|
|
|
function set_abconfig($chan,$xhash,$family,$key,$value) {
|
|
|
|
return Zlib\AbConfig::Set($chan,$xhash,$family,$key,$value);
|
2016-03-01 03:31:52 +00:00
|
|
|
}
|
|
|
|
|
2016-06-24 01:12:26 +00:00
|
|
|
function del_abconfig($chan,$xhash,$family,$key) {
|
|
|
|
return Zlib\AbConfig::Delete($chan,$xhash,$family,$key);
|
2016-03-01 03:31:52 +00:00
|
|
|
}
|
2016-04-26 23:12:31 +00:00
|
|
|
|
2016-06-08 01:17:39 +00:00
|
|
|
function load_iconfig(&$item) {
|
|
|
|
Zlib\IConfig::Load($item);
|
|
|
|
}
|
2016-04-26 23:12:31 +00:00
|
|
|
|
2016-12-05 22:50:34 +00:00
|
|
|
function get_iconfig(&$item, $family, $key, $default = false) {
|
|
|
|
return Zlib\IConfig::Get($item, $family, $key, $default);
|
2016-04-26 23:12:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function set_iconfig(&$item, $family, $key, $value, $sharing = false) {
|
2016-06-11 05:41:58 +00:00
|
|
|
return Zlib\IConfig::Set($item, $family, $key, $value, $sharing);
|
2016-04-26 23:12:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function del_iconfig(&$item, $family, $key) {
|
2016-06-08 01:17:39 +00:00
|
|
|
return Zlib\IConfig::Delete($item, $family, $key);
|
2016-04-26 23:12:31 +00:00
|
|
|
}
|