streams/include/config.php

129 lines
3.7 KiB
PHP
Raw Normal View History

<?php
2011-08-10 08:19:27 +00:00
/**
* @file include/config.php
* @brief Arbitrary configuration storage.
2011-08-10 08:19:27 +00:00
*
* 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}
2016-03-31 23:06:03 +00:00
* $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.
*
2011-08-10 08:19:27 +00:00
*/
use Zotlabs\Lib as Zlib;
function load_config($family) {
Zlib\Config::Load($family);
2013-02-26 23:49:37 +00:00
}
function get_config($family, $key, $default = false) {
return Zlib\Config::Get($family,$key,$default);
2013-06-22 04:36:48 +00:00
}
function set_config($family, $key, $value) {
return Zlib\Config::Set($family,$key,$value);
2013-02-26 23:49:37 +00:00
}
function del_config($family, $key) {
return Zlib\Config::Delete($family,$key);
}
function load_pconfig($uid) {
2016-06-06 05:18:17 +00:00
Zlib\PConfig::Load($uid);
2013-02-26 23:49:37 +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
}
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
}
function load_xconfig($xchan) {
2016-06-08 01:17:39 +00:00
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) {
2016-06-08 01:17:39 +00:00
return Zlib\XConfig::Set($xchan,$family,$key,$value);
}
function del_xconfig($xchan, $family, $key) {
2016-06-08 01:17:39 +00:00
return Zlib\XConfig::Delete($xchan,$family,$key);
}
function load_aconfig($account_id) {
2016-06-08 01:17:39 +00:00
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) {
2016-06-08 01:17:39 +00:00
return Zlib\AConfig::Set($account_id, $family, $key, $value);
}
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
}
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
}
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
}
function del_abconfig($chan,$xhash,$family,$key) {
return Zlib\AbConfig::Delete($chan,$xhash,$family,$key);
2016-03-01 03:31:52 +00:00
}
2016-06-08 01:17:39 +00:00
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) {
2016-06-11 05:41:58 +00:00
return Zlib\IConfig::Set($item, $family, $key, $value, $sharing);
}
function del_iconfig(&$item, $family, $key) {
2016-06-08 01:17:39 +00:00
return Zlib\IConfig::Delete($item, $family, $key);
}