streams/include/config.php

173 lines
4.3 KiB
PHP
Raw Permalink Normal View History

2022-11-20 06:44:13 +00:00
<?php /** @noinspection PhpUnused */
2021-12-03 03:01:39 +00:00
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
*/
2022-02-16 04:08:28 +00:00
use Code\Lib as Zlib;
2021-12-03 03:01:39 +00:00
function load_config($family)
{
Zlib\Config::Load($family);
2013-02-26 23:49:37 +00:00
}
2021-12-03 03:01:39 +00:00
function get_config($family, $key, $default = false)
{
return Zlib\Config::Get($family, $key, $default);
2013-06-22 04:36:48 +00:00
}
2021-12-03 03:01:39 +00:00
function set_config($family, $key, $value)
{
return Zlib\Config::Set($family, $key, $value);
2013-02-26 23:49:37 +00:00
}
2021-12-03 03:01:39 +00:00
function del_config($family, $key)
{
return Zlib\Config::Delete($family, $key);
}
2021-12-03 03:01:39 +00:00
function load_pconfig($uid)
{
Zlib\PConfig::Load($uid);
2013-02-26 23:49:37 +00:00
}
2021-12-03 03:01:39 +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
}
2021-12-03 03:01:39 +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
}
2021-12-03 03:01:39 +00:00
function del_pconfig($uid, $family, $key)
{
return Zlib\PConfig::Delete($uid, $family, $key);
2013-02-26 23:49:37 +00:00
}
2021-12-03 03:01:39 +00:00
function load_xconfig($xchan)
{
Zlib\XConfig::Load($xchan);
}
2021-12-03 03:01:39 +00:00
function get_xconfig($xchan, $family, $key, $default = false)
{
return Zlib\XConfig::Get($xchan, $family, $key, $default);
}
2021-12-03 03:01:39 +00:00
function set_xconfig($xchan, $family, $key, $value)
{
return Zlib\XConfig::Set($xchan, $family, $key, $value);
}
2021-12-03 03:01:39 +00:00
function del_xconfig($xchan, $family, $key)
{
return Zlib\XConfig::Delete($xchan, $family, $key);
}
2021-12-03 03:01:39 +00:00
function load_aconfig($account_id)
{
Zlib\AConfig::Load($account_id);
}
2021-12-03 03:01:39 +00:00
function get_aconfig($account_id, $family, $key, $default = false)
{
return Zlib\AConfig::Get($account_id, $family, $key, $default);
}
2021-12-03 03:01:39 +00:00
function set_aconfig($account_id, $family, $key, $value)
{
return Zlib\AConfig::Set($account_id, $family, $key, $value);
}
2021-12-03 03:01:39 +00:00
function del_aconfig($account_id, $family, $key)
{
return Zlib\AConfig::Delete($account_id, $family, $key);
2016-03-01 03:31:52 +00:00
}
2021-12-03 03:01:39 +00:00
function load_abconfig($chan, $xhash, $family = '')
{
return Zlib\AbConfig::Load($chan, $xhash, $family);
2016-03-01 03:31:52 +00:00
}
2021-12-03 03:01:39 +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
}
2021-12-03 03:01:39 +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
}
2021-12-03 03:01:39 +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
}
2021-12-03 03:01:39 +00:00
function load_iconfig(&$item)
{
Zlib\IConfig::Load($item);
2016-06-08 01:17:39 +00:00
}
2021-12-03 03:01:39 +00:00
function get_iconfig(&$item, $family, $key, $default = false)
{
return Zlib\IConfig::Get($item, $family, $key, $default);
}
2021-12-03 03:01:39 +00:00
function set_iconfig(&$item, $family, $key, $value, $sharing = false)
{
return Zlib\IConfig::Set($item, $family, $key, $value, $sharing);
}
2021-12-03 03:01:39 +00:00
function del_iconfig(&$item, $family, $key)
{
return Zlib\IConfig::Delete($item, $family, $key);
}
2017-09-25 04:20:50 +00:00
2021-12-03 03:01:39 +00:00
function load_sconfig($server_id)
{
Zlib\SConfig::Load($server_id);
2017-09-25 04:20:50 +00:00
}
2021-12-03 03:01:39 +00:00
function get_sconfig($server_id, $family, $key, $default = false)
{
return Zlib\SConfig::Get($server_id, $family, $key, $default);
2017-09-25 04:20:50 +00:00
}
2021-12-03 03:01:39 +00:00
function set_sconfig($server_id, $family, $key, $value)
{
return Zlib\SConfig::Set($server_id, $family, $key, $value);
2017-09-25 04:20:50 +00:00
}
2021-12-03 03:01:39 +00:00
function del_sconfig($server_id, $family, $key)
{
return Zlib\SConfig::Delete($server_id, $family, $key);
2017-09-25 04:20:50 +00:00
}