The Red Matrix
 All Classes Namespaces Files Functions Variables Pages
config.php File Reference

Arbitrary configuration storage. More...

Functions

 load_config ($family)
 Loads the hub's configuration from database to a cached storage. More...
 
 get_config ($family, $key)
 Get a particular config variable given the category name ($family) and a key. More...
 
 get_config_from_storage ($family, $key)
 Returns a value directly from the database configuration storage. More...
 
 set_config ($family, $key, $value)
 Sets a configuration value for the hub. More...
 
 del_config ($family, $key)
 Deletes the given key from the hub's configuration database. More...
 
 load_pconfig ($uid)
 Loads all configuration values of a channel into a cached storage. More...
 
 get_pconfig ($uid, $family, $key, $instore=false)
 Get a particular channel's config variable given the category name ($family) and a key. More...
 
 set_pconfig ($uid, $family, $key, $value)
 Sets a configuration value for a channel. More...
 
 del_pconfig ($uid, $family, $key)
 Deletes the given key from the channel's configuration. More...
 
 load_xconfig ($xchan)
 Loads a full xchan's configuration into a cached storage. More...
 
 get_xconfig ($xchan, $family, $key)
 Get a particular observer's config variable given the category name ($family) and a key. More...
 
 set_xconfig ($xchan, $family, $key, $value)
 Sets a configuration value for an observer. More...
 
 del_xconfig ($xchan, $family, $key)
 Deletes the given key from the observer's config. More...
 

Detailed Description

Arbitrary configuration storage.

Note: Please do not store booleans - convert to 0/1 integer values The get_?config() functions return boolean false for keys that are unset, and this could lead to subtle bugs.

Arrays get stored as serialize strings.

Todo:
There are a few places in the code (such as the admin panel) where boolean configurations need to be fixed as of 10/08/2011.
  • config is used for hub specific configurations. It overrides the configurations from .htconfig file. The storage is of size TEXT.
  • pconfig is used for channel specific configurations and takes a channel_id as identifier. It stores for example which features are enabled per channel. The storage is of size MEDIUMTEXT.
    $var = get_pconfig(local_user(), 'category', 'key');
  • xconfig is the same as pconfig, except that it uses xchan as an identifier. This is for example for people who do not have a local account. The storage is of size MEDIUMTEXT.
    $observer = $a->get_observer_hash();
    if ($observer) {
    $var = get_xconfig($observer, 'category', 'key');
    }

Function Documentation

del_config (   $family,
  $key 
)

Deletes the given key from the hub's configuration database.

Removes the configured value from the stored cache in $a->config[$family] and removes it from the database.

Parameters
string$familyThe category of the configuration value
string$keyThe configuration key to delete
Returns
mixed

Referenced by admin_page_site_post(), and FKOAuthDataStore\new_access_token().

del_pconfig (   $uid,
  $family,
  $key 
)

Deletes the given key from the channel's configuration.

Removes the configured value from the stored cache in $a->config[$uid] and removes it from the database.

Parameters
string$uidThe channel_id
string$familyThe category of the configuration value
string$keyThe configuration key to delete
Returns
mixed

Referenced by pdledit_post().

del_xconfig (   $xchan,
  $family,
  $key 
)

Deletes the given key from the observer's config.

Removes the configured value from the stored cache in $a->config[$xchan] and removes it from the database.

Parameters
string$xchanThe observer's hash
string$familyThe category of the configuration value
string$keyThe configuration key to delete
Returns
mixed
get_config (   $family,
  $key 
)

Get a particular config variable given the category name ($family) and a key.

Get a particular config variable from the given category ($family) and the $key from a cached storage in $a->config[$family]. If a key is found in the DB but does not exist in local config cache, pull it into the cache so we do not have to hit the DB again for this item.

Returns false if not set.

Parameters
string$familyThe category of the configuration value
string$keyThe configuration key to query
Returns
mixed Return value or false on error or if not set

Referenced by account_service_class_fetch(), account_verify_password(), acl_init(), admin_page_dbsync(), admin_page_logs(), admin_page_site(), admin_page_summary(), admin_page_themes(), allowed_email(), allowed_url(), api_statuses_mentions(), api_statusnet_config(), attach_store(), bb2diaspora_itembody(), bbcode(), build_sync_packet(), channel_content(), check_account_admin(), check_account_invite(), check_config(), check_upstream_directory(), cli_startup(), create_account(), create_identity(), create_sys_channel(), RedMatrix\RedDAV\RedDirectory\createFile(), detect_language(), diaspora_comment(), diaspora_conversation(), diaspora_dispatch(), diaspora_dispatch_public(), diaspora_is_blacklisted(), diaspora_like(), diaspora_message(), diaspora_process_outbound(), diaspora_send_followup(), diaspora_send_mail(), diaspora_send_relay(), diaspora_transmit(), directory_content(), directory_run(), dirprofile_init(), dirsearch_content(), display_content(), dlogger(), dob(), downgrade_accounts(), editblock_content(), editpost_content(), editwebpage_content(), encode_item(), encode_mail(), events_content(), expire_run(), externals_run(), feature_enabled(), feed_init(), filter_insecure(), find_upstream_directory(), findpeople_widget(), get_all_perms(), Item\get_comment_box(), get_default_profile_photo(), get_directory_realm(), get_item_elements(), get_mail_elements(), get_max_import_size(), get_online_status(), get_profile_fields_advanced(), get_profile_fields_basic(), get_role_perms(), RedMatrix\RedDAV\RedDirectory\getChild(), RedMatrix\RedDAV\RedDirectory\getChildren(), group_content(), guess_image_type(), home_content(), home_init(), identity_basic_export(), photo_gd\imageString(), import_post(), import_xchan(), invite_content(), invite_post(), is_public_profile(), item_post(), item_store(), item_store_update(), photo_imagick\load(), localize_item(), logger(), login(), lostpass_content(), lostpass_post(), mark_orphan_hubsxchans(), nav(), navbar_complete(), network_content(), FKOAuthDataStore\new_access_token(), new_channel_post(), new_contact(), new_keypair(), notification(), notifier_run(), oembed_bbcode2html(), openid_content(), parse_url_content(), perm_is_allowed(), photo_factory(), photo_upload(), photos_content(), photos_init(), poco_init(), poller_run(), post_activity_item(), post_post(), private_messages_fetch_conversation(), private_messages_fetch_message(), private_messages_list(), profile_content(), profile_create_sidebar(), profile_photo_post(), profiles_content(), profperm_content(), pubsites_content(), RedMatrix\RedDAV\RedFile\put(), receive_post(), register_content(), register_post(), reload_plugins(), remove_all_xchan_resources(), remove_obsolete_hublocs(), scale_external_images(), search_content(), send_message(), send_reg_approval_email(), send_verification_email(), service_class_allows(), service_class_fetch(), service_limits_content(), set_config(), settings_post(), site_default_perms(), siteinfo_content(), siteinfo_init(), smilies(), start_delivery_chain(), store_diaspora_comment_sig(), tag_deliver(), theme_admin(), unobscure(), update_modtime(), update_suggestions(), upgrade_link(), user_allow(), valid_email(), validate_email(), verify_email_address(), viewconnections_content(), viewconnections_init(), viewsrc_content(), widget_fullprofile(), widget_profile(), z_fetch_url(), z_post_url(), zfinger_init(), zot_fetch(), zot_gethub(), zot_import(), and zotfeed_init().

get_config_from_storage (   $family,
  $key 
)

Returns a value directly from the database configuration storage.

This function queries directly the database and bypasses the chached storage from get_config($family, $key).

Parameters
string$familyThe category of the configuration value
string$keyThe configuration key to query
Returns
mixed

Referenced by set_config().

get_pconfig (   $uid,
  $family,
  $key,
  $instore = false 
)

Get a particular channel's config variable given the category name ($family) and a key.

Get a particular channel's config value from the given category ($family) and the $key from a cached storage in $a->config[$uid].

Returns false if not set.

Parameters
string$uidThe channel_id
string$familyThe category of the configuration value
string$keyThe configuration key to query
boolean$instore(deprecated, without function)
Returns
mixed Stored value or false if it does not exist

Referenced by Conversation\__construct(), acl_init(), bb2diaspora_itembody(), App\build_pagehead(), change_channel(), channel_content(), connect_content(), connedit_content(), connedit_post(), contact_block(), contact_remove(), conversation(), current_theme(), display_content(), editpost_content(), feature_enabled(), findpeople_widget(), fix_attached_file_permissions(), fix_attached_photo_permissions(), Item\get_comment_box(), get_online_status(), Item\get_template_data(), get_theme_uid(), group_content(), home_init(), invite_content(), invite_post(), item_post(), item_store(), item_store_update(), items_fetch(), load_pdl(), FKOAuth1\loginUser(), mail_content(), message_content(), nav(), network_content(), new_contact(), notification(), pdledit_content(), post_post(), profile_activity(), profile_load(), profile_sidebar(), profperm_content(), remove_community_tag(), rpost_content(), search_content(), set_pconfig(), settings_post(), smilies(), tag_deliver(), theme_content(), webpages_content(), widget_notes(), and widget_settings_menu().

get_xconfig (   $xchan,
  $family,
  $key 
)

Get a particular observer's config variable given the category name ($family) and a key.

Get a particular observer's config value from the given category ($family) and the $key from a cached storage in $a->config[$xchan].

Returns false if not set.

Parameters
string$xchanThe observer's hash
string$familyThe category of the configuration value
string$keyThe configuration key to query
Returns
mixed Stored $value or false if it does not exist

Referenced by dir_safe_mode(), directory_content(), set_xconfig(), and toggle_safesearch_init().

load_config (   $family)

Loads the hub's configuration from database to a cached storage.

Retrieve a category ($family) of config variables from database to a cached storage in the global $a->config[$family].

Parameters
string$familyThe category of the configuration value

Referenced by api_statusnet_config(), check_config(), cli_startup(), and get_config().

load_pconfig (   $uid)

Loads all configuration values of a channel into a cached storage.

All configuration values of the given channel are stored in global cache which is available under the global variable $a->config[$uid].

Parameters
string$uidThe channel_id
Returns
void|false Nothing or false if $uid is false

Referenced by conversation(), and get_pconfig().

load_xconfig (   $xchan)

Loads a full xchan's configuration into a cached storage.

All configuration values of the given observer hash are stored in global cache which is available under the global variable $a->config[$xchan].

Parameters
string$xchanThe observer's hash
Returns
void|false Returns false if xchan is not set

Referenced by get_xconfig().

set_config (   $family,
  $key,
  $value 
)

Sets a configuration value for the hub.

Stores a config value ($value) in the category ($family) under the key ($key).

Please do not store booleans - convert to 0/1 integer values!

Parameters
string$familyThe category of the configuration value
string$keyThe configuration key to set
mixed$valueThe value to store in the configuration
Returns
mixed Return the set value, or false if the database update failed

Referenced by admin_page_dbsync(), admin_page_logs_post(), admin_page_plugins(), admin_page_site_post(), admin_page_themes(), api_content(), check_config(), check_upstream_directory(), create_account(), create_sys_channel(), find_upstream_directory(), poller_run(), theme_admin_post(), update_channels_active_halfyear_stat(), update_channels_active_monthly_stat(), update_channels_total_stat(), update_local_posts_stat(), and what_next().

set_pconfig (   $uid,
  $family,
  $key,
  $value 
)

Sets a configuration value for a channel.

Stores a config value ($value) in the category ($family) under the key ($key) for the channel_id $uid.

Please do not store booleans - convert to 0/1 integer values!

Parameters
string$uidThe channel_id
string$familyThe category of the configuration value
string$keyThe configuration key to query
Returns
mixed Stored $value or false

Referenced by connect_post(), create_identity(), invite_post(), notes_init(), pdledit_post(), process_channel_sync_delivery(), register_post(), settings_post(), and theme_post().

set_xconfig (   $xchan,
  $family,
  $key,
  $value 
)

Sets a configuration value for an observer.

Stores a config value ($value) in the category ($family) under the key ($key) for the observer's $xchan hash.

Please do not store booleans - convert to 0/1 integer values!

Parameters
string$xchanThe observer's hash
string$familyThe category of the configuration value
string$keyThe configuration key to set
Returns
mixed Stored $value or false

Referenced by openid_content(), and toggle_safesearch_init().