From: garvinhicking Date: Fri, 25 Nov 2005 17:07:00 +0000 (+0000) Subject: Document code. Uff. X-Git-Tag: 1.0~271 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=6498f679aec534e0f5551a979041d13b500059e1;p=s9y.git Document code. Uff. --- diff --git a/include/functions_config.inc.php b/include/functions_config.inc.php index 3b1306e..aadec57 100644 --- a/include/functions_config.inc.php +++ b/include/functions_config.inc.php @@ -3,13 +3,15 @@ # All rights reserved. See LICENSE file for licensing details /** - * SHORT - * - * LONG + * Adds a new author account * * @access public - * @param - * @return + * @param string New username + * @param string New password + * @param string The realname of the user + * @param string The email address of the user + * @param int The userlevel of a user + * @return int The new user ID of the added author */ function serendipity_addAuthor($username, $password, $realname, $email, $userlevel=0) { global $serendipity; @@ -35,13 +37,13 @@ function serendipity_addAuthor($username, $password, $realname, $email, $userlev } /** - * SHORT + * Delete an author account * - * LONG + * (Note, this function does not delete entries by an author) * * @access public - * @param - * @return + * @param int The author ID to delete + * @return boolean True on success, false on error or unsufficient privileges */ function serendipity_deleteAuthor($authorid) { global $serendipity; @@ -57,13 +59,14 @@ function serendipity_deleteAuthor($authorid) { } /** - * SHORT + * Removes a configuration value from the Serendipity Configuration * - * LONG + * Global config items have the authorid 0, author-specific configuration items have the corresponding authorid. * * @access public - * @param - * @return + * @param string The name of the configuration value + * @param int The ID of the owner of the config value (0: global) + * @return null */ function serendipity_remove_config_var($name, $authorid = 0) { global $serendipity; @@ -71,13 +74,15 @@ function serendipity_remove_config_var($name, $authorid = 0) { } /** - * SHORT + * Sets a configuration value for the Serendipity Configuration * - * LONG + * Global config items have the authorid 0, author-specific configuration items have the corresponding authorid. * * @access public - * @param - * @return + * @param string The name of the configuration value + * @param string The value of the configuration item + * @param int The ID of the owner of the config value (0: global) + * @return null */ function serendipity_set_config_var($name, $val, $authorid = 0) { global $serendipity; @@ -99,13 +104,13 @@ function serendipity_set_config_var($name, $val, $authorid = 0) { } /** - * SHORT - * - * LONG + * Retrieve a global configuration value for a specific item of the current Serendipity Configuration * * @access public - * @param - * @return + * @param string The name of the configuration value + * @param string The default value of a configuration item, if not found in the Database + * @param boolean If set to true, the default value of a configuration item will be returned if the item is set, but empty. If false, an empty configuration value will be returned empty. This is required for getting default values if you do not want to store/allow empty config values. + * @return string The configuration value content */ function serendipity_get_config_var($name, $defval = false, $empty = false) { global $serendipity; @@ -121,13 +126,15 @@ function serendipity_get_config_var($name, $defval = false, $empty = false) { } /** - * SHORT + * Retrieve an author-specific configuration value for an item of the Serendipity Configuration stored in the DB * - * LONG + * Despite the serendipity_get_config_var() function, this will retrieve author-specific values straight from the Database. * * @access public - * @param - * @return + * @param string The name of the configuration value + * @param int The ID of the owner of the config value (0: global) + * @param string The default value of a configuration option, if not set in the DB + * @return string The configuration value content */ function serendipity_get_user_config_var($name, $authorid, $default = '') { global $serendipity; @@ -147,13 +154,15 @@ function serendipity_get_user_config_var($name, $authorid, $default = '') { } /** - * SHORT + * Retrieves an author-specific account value * - * LONG + * This retrieves specific account data from the user configuration, not from the serendipity configuration. * * @access public - * @param - * @return + * @param string The name of the configuration value + * @param int The ID of the author to fetch the configuration for + * @param string The default value of a configuration option, if not set in the DB + * @return string The configuration value content */ function serendipity_get_user_var($name, $authorid, $default) { global $serendipity; @@ -168,13 +177,16 @@ function serendipity_get_user_var($name, $authorid, $default) { } /** - * SHORT + * Updates data from the author-specific account * - * LONG + * This sets the personal account data of a serendipity user within the 'authors' DB table * * @access public - * @param - * @return + * @param string The name of the configuration value + * @param string The content of the configuration value + * @param int The ID of the author to set the configuration for + * @param boolean If set to true, the stored config value will be imported to the Session/current config of the user. This is applied for example when you change your own user's preferences and want it to be immediately reflected in the interface. + * @return null */ function serendipity_set_user_var($name, $val, $authorid, $copy_to_s9y = true) { global $serendipity; @@ -221,13 +233,15 @@ function serendipity_set_user_var($name, $val, $authorid, $copy_to_s9y = true) { } /** - * SHORT + * Gets the full filename and path of a template/style/theme file * - * LONG + * The returned full path is depending on the second parameter, where you can either fetch a HTTP path, or a realpath. + * The file is searched in the current template, and if it is not found there, it is returned from the default template. * * @access public - * @param - * @return + * @param string The filename to search for in the selected template + * @param string The path selector that tells whether to return a HTTP or realpath + * @return string The full path+filename to the requested file */ function serendipity_getTemplateFile($file, $key = 'serendipityHTTPPath') { global $serendipity; @@ -252,13 +266,14 @@ function serendipity_getTemplateFile($file, $key = 'serendipityHTTPPath') { } /** - * SHORT + * Loads all configuration values and imports them to the $serendipity array * - * LONG + * This function may be called twice - once for the global config and once for + * user-specific config * * @access public - * @param - * @return + * @param int The Authorid to fetch the configuration from (0: global) + * @return null */ function serendipity_load_configuration($author = null) { global $serendipity; @@ -284,13 +299,10 @@ function serendipity_load_configuration($author = null) { } /** - * SHORT - * - * LONG + * Perform logout functions (destroys session data) * * @access public - * @param - * @return + * @return null */ function serendipity_logout() { $_SESSION['serendipityAuthedUser'] = false; @@ -299,13 +311,11 @@ function serendipity_logout() { } /** - * SHORT - * - * LONG + * Perform login to Serendipity * * @access public - * @param - * @return + * @param boolean If set to true, external plugins will be queried for getting a login + * @return boolean Return true, if the user is logged in. False if not. */ function serendipity_login($use_external = true) { global $serendipity; @@ -318,6 +328,7 @@ function serendipity_login($use_external = true) { return true; } + // First try login via POST data. If true, the userinformation will be stored in a cookie (optionally) if (serendipity_authenticate_author($serendipity['POST']['user'], $serendipity['POST']['pass'], false, $use_external)) { if (empty($serendipity['POST']['auto'])) { serendipity_deleteCookie('author_information'); @@ -328,6 +339,7 @@ function serendipity_login($use_external = true) { serendipity_setCookie('author_information', base64_encode($package)); return true; } + // Now try login via COOKIE data } elseif ( isset($serendipity['COOKIE']['author_information']) ) { $cookie = unserialize(base64_decode($serendipity['COOKIE']['author_information'])); if (serendipity_authenticate_author($cookie['username'], $cookie['password'], false, $use_external)) { @@ -340,13 +352,10 @@ function serendipity_login($use_external = true) { } /** - * SHORT - * - * LONG + * Check if a user is logged in * * @access public - * @param - * @return + * @return boolean TRUE when logged in, FALSE when not. */ function serendipity_userLoggedIn() { if ($_SESSION['serendipityAuthedUser'] === true && IS_installed) { @@ -357,13 +366,14 @@ function serendipity_userLoggedIn() { } /** - * SHORT + * A clone of an ifsetor() function to set a variable conditional on if the target already exists * - * LONG + * The function sets the contents of $source into the $target variable, but only if $target is not yet set. Eases up some if...else logic or multiple ternary operators * * @access public - * @param - * @return + * @param mixed Source variable that should be set into the target variable (reference call!) + * @param mixed Target variable, that should get the contents of the source variable (reference call!) + * @return boolean True, when $target was not yet set and has been altered. False when no changes where made. */ function serendipity_restoreVar(&$source, &$target) { global $serendipity; @@ -377,13 +387,15 @@ function serendipity_restoreVar(&$source, &$target) { } /** - * SHORT + * Echo Javascript code to set a cookie variable * - * LONG + * This function is useful if your HTTP headers were already sent, but you still want to set a cookie + * Note that contents are echo'd, not return'd. * * @access public - * @param - * @return + * @param string The name of the cookie variable + * @param string The contents of the cookie variable + * @return null */ function serendipity_JSsetCookie($name, $value) { $name = str_replace('"', '\"', $name); @@ -393,13 +405,12 @@ function serendipity_JSsetCookie($name, $value) { } /** - * SHORT - * - * LONG + * Set a Cookie via HTTP calls, and update $_COOKIE plus $serendipity['COOKIE'] array. * * @access public - * @param - * @return + * @param string The name of the cookie variable + * @param string The contents of the cookie variable + * @return null */ function serendipity_setCookie($name,$value) { global $serendipity; @@ -410,12 +421,12 @@ function serendipity_setCookie($name,$value) { } /** - * SHORT + * Deletes an existing cookie value * * LONG * * @access public - * @param + * @param string Name of the cookie to delete * @return */ function serendipity_deleteCookie($name) { @@ -427,13 +438,18 @@ function serendipity_deleteCookie($name) { } /** - * SHORT + * Perform user authentication routine * - * LONG + * If a user is already authenticated via session data, this bypasses some routines. + * After a user has ben authenticated, several SESSION variables ar set. + * If the authentication fails, the session is destroyed. * * @access public - * @param - * @return + * @param string The username to check + * @param string The password to check (may contain plaintext or MD5 hash) + * @param boolean Indicates whether the input password is already in MD5 format (TRUE) or not (FALSE). + * @param boolean Indicates whether to query external plugins for authentication + * @return boolean True on success, False on error */ function serendipity_authenticate_author($username = '', $password = '', $is_md5 = false, $use_external = true) { global $serendipity; @@ -484,13 +500,13 @@ function serendipity_authenticate_author($username = '', $password = '', $is_md5 } /** - * SHORT + * Performs a check whether an iframe for the admin section shall be emitted * - * LONG + * The iframe is used for previewing an entry with the stylesheet of the frontend. + * It fetches its data from the session input data. * - * @access public - * @param - * @return + * @access private + * @return boolean True, if iframe was requested, false if not. */ function serendipity_is_iframe() { global $serendipity; @@ -538,13 +554,17 @@ function serendipity_is_iframe() { } /** - * SHORT + * Prints the content of the iframe. * - * LONG + * Called by serendipity_is_iframe, when preview is requested. Fetches data from session. + * An iframe is used so that a single s9y page must not timeout on intensive operations, + * and so that the frontend stylesheet can be embedded without screwing up the backend. * - * @access public - * @param - * @return + * @access private + * @see serendipity_is_iframe() + * @param mixed The entry array (comes from session variable) + * @param string Indicates whether an entry is previewed or saved. Save performs XML-RPC calls. + * @return boolean Indicates whether iframe data was printed */ function serendipity_iframe(&$entry, $mode = null) { global $serendipity; @@ -590,13 +610,15 @@ function serendipity_iframe(&$entry, $mode = null) { } /** - * SHORT + * Creates the necessary session data to be used by later iframe calls * - * LONG + * This function emits the actual