[ Index ]
 

Code source de Serendipity 1.2

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/include/ -> functions_config.inc.php (sommaire)

(pas de description)

Poids: 2039 lignes (77 kb)
Inclus ou requis: 2 fois
Référencé: 0 fois
Nécessite: 1 fichier
 include/functions_entries_admin.inc.php

Définit 54 fonctions

  serendipity_addAuthor()
  serendipity_deleteAuthor()
  serendipity_remove_config_var()
  serendipity_set_config_var()
  serendipity_get_config_var()
  serendipity_get_user_config_var()
  serendipity_get_user_var()
  serendipity_set_user_var()
  serendipity_getTemplateFile()
  serendipity_load_configuration()
  serendipity_logout()
  serendipity_session_destroy()
  serendipity_login()
  serendipity_issueAutologin()
  serendipity_checkAutologin()
  serendipity_setAuthorToken()
  serendipity_authenticate_author()
  serendipity_userLoggedIn()
  serendipity_restoreVar()
  serendipity_JSsetCookie()
  serendipity_setCookie()
  serendipity_deleteCookie()
  serendipity_is_iframe()
  serendipity_iframe()
  serendipity_iframe_create()
  serendipity_probeInstallation()
  serendipity_header()
  serendipity_getSessionLanguage()
  serendipity_getPostAuthSessionLanguage()
  serendipity_getPermissions()
  serendipity_getPermissionNames()
  serendipity_checkPermission()
  serendipity_updateGroups()
  serendipity_getAllGroups()
  serendipity_fetchGroup()
  serendipity_getGroups()
  serendipity_getGroupUsers()
  serendipity_deleteGroup()
  serendipity_addGroup()
  serendipity_getDBPermissionNames()
  serendipity_getAllPermissionNames()
  serendipity_intersectGroup()
  serendipity_updateGroupConfig()
  serendipity_addDefaultGroup()
  serendipity_ACLGrant()
  serendipity_ACLGet()
  serendipity_ACLCheck()
  serendipity_ACL_SQL()
  serendipity_checkXSRF()
  serendipity_reportXSRF()
  serendipity_checkFormToken()
  serendipity_setFormToken()
  serendipity_loadThemeOptions()
  serendipity_hasPluginPermissions()

Fonctions
Fonctions qui ne font pas partie d'une Classe:

serendipity_addAuthor($username, $password, $realname, $email, $userlevel=0)   X-Ref
Adds a new author account

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

serendipity_deleteAuthor($authorid)   X-Ref
Delete an author account

(Note, this function does not delete entries by an author)

param: int     The author ID to delete
return: boolean     True on success, false on error or unsufficient privileges

serendipity_remove_config_var($name, $authorid = 0)   X-Ref
Removes a configuration value from the Serendipity Configuration

Global config items have the authorid 0, author-specific configuration items have the corresponding authorid.

param: string      The name of the configuration value
param: int         The ID of the owner of the config value (0: global)
return: null

serendipity_set_config_var($name, $val, $authorid = 0)   X-Ref
Sets a configuration value for the Serendipity Configuration

Global config items have the authorid 0, author-specific configuration items have the corresponding authorid.

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

serendipity_get_config_var($name, $defval = false, $empty = false)   X-Ref
Retrieve a global configuration value for a specific item of the current Serendipity Configuration

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

serendipity_get_user_config_var($name, $authorid, $default = '')   X-Ref
Retrieve an author-specific configuration value for an item of the Serendipity Configuration stored in the DB

Despite the serendipity_get_config_var() function, this will retrieve author-specific values straight from the Database.

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

serendipity_get_user_var($name, $authorid, $default)   X-Ref
Retrieves an author-specific account value

This retrieves specific account data from the user configuration, not from the serendipity configuration.

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

serendipity_set_user_var($name, $val, $authorid, $copy_to_s9y = true)   X-Ref
Updates data from the author-specific account

This sets the personal account data of a serendipity user within the 'authors' DB table

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

serendipity_getTemplateFile($file, $key = 'serendipityHTTPPath')   X-Ref
Gets the full filename and path of a template/style/theme file

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.

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

serendipity_load_configuration($author = null)   X-Ref
Loads all configuration values and imports them to the $serendipity array

This function may be called twice - once for the global config and once for
user-specific config

param: int     The Authorid to fetch the configuration from (0: global)
return: null

serendipity_logout()   X-Ref
Perform logout functions (destroys session data)

return: null

serendipity_session_destroy()   X-Ref
Destroys a session, keeps important stuff intact.

return: null

serendipity_login($use_external = true)   X-Ref
Perform login to Serendipity

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.

serendipity_issueAutologin($array)   X-Ref
Issue a new auto login cookie

param: array The input data

serendipity_checkAutologin($ident, $iv)   X-Ref
Checks a new auto login cookie

param: array The input data

serendipity_setAuthorToken()   X-Ref
Set a session cookie which can identify a user accross http/https boundaries


serendipity_authenticate_author($username = '', $password = '', $is_md5 = false, $use_external = true)   X-Ref
Perform user authentication routine

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.

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

serendipity_userLoggedIn()   X-Ref
Check if a user is logged in

return: boolean  TRUE when logged in, FALSE when not.

serendipity_restoreVar(&$source, &$target)   X-Ref
A clone of an ifsetor() function to set a variable conditional on if the target already exists

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

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.

serendipity_JSsetCookie($name, $value)   X-Ref
Echo Javascript code to set a cookie variable

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.

param: string      The name of the cookie variable
param: string      The contents of the cookie variable
return: null

serendipity_setCookie($name, $value, $securebyprot = true)   X-Ref
Set a Cookie via HTTP calls, and update $_COOKIE plus $serendipity['COOKIE'] array.

param: string      The name of the cookie variable
param: string      The contents of the cookie variable
return: null

serendipity_deleteCookie($name)   X-Ref
Deletes an existing cookie value

LONG

param: string      Name of the cookie to delete
return:

serendipity_is_iframe()   X-Ref
Performs a check whether an iframe for the admin section shall be emitted

The iframe is used for previewing an entry with the stylesheet of the frontend.
It fetches its data from the session input data.

return: boolean  True, if iframe was requested, false if not.

serendipity_iframe(&$entry, $mode = null, $use_smarty = true)   X-Ref
Prints the content of the iframe.

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.

param: mixed   The entry array (comes from session variable)
param: string  Indicates whether an entry is previewed or saved. Save performs XML-RPC calls.
param: boolean Use smarty templating?
return: boolean Indicates whether iframe data was printed

serendipity_iframe_create($mode, &$entry)   X-Ref
Creates the necessary session data to be used by later iframe calls

This function emits the actual <iframe> call.

param: string  Indicates whether an entry is previewed or saved. Save performs XML-RPC calls.
param: mixed   The entry array (comes from HTTP POST request)
return: boolean Indicates whether iframe data was stored

serendipity_probeInstallation($item)   X-Ref
Pre-Checks certain server environments to indicate available options when installing Serendipity

param: string      The name of the configuration option that needs to be checked for environmental data.
return: array       Returns the array of available options for the requested config option

serendipity_header($header)   X-Ref
Sets a HTTP header

param: string      The HTTP headre to set
return: null

serendipity_getSessionLanguage()   X-Ref
Gets the currently selected language. Either from the browser, or the personal configuration, or the global configuration.

This function also sets HTTP Headers and cookies to contain the language for follow-up requests
TODO:
This previously was handled inside a plugin with an event hook, but caching
the event plugins that early in sequence created trouble with plugins not
having loaded the right language.
Find a way to let plugins hook into that sequence :-)

return: string      Returns the name of the selected language.

serendipity_getPostAuthSessionLanguage()   X-Ref
Gets the selected language from personal configuration if needed

This function also sets HTTP Headers and cookies to contain the language for follow-up requests

return: string      Returns the name of the selected language.

serendipity_getPermissions($authorid)   X-Ref
Retrieves an array of applying permissions to an author

The privileges of each group an author is a member of are aggreated
and stored in a larger array. So both memberships and all aplying
privileges are returned.

param: int     The ID of the author to fetch permissions/group memberships for
return: array   Multi-dimensional associative array which holds a 'membership' and permission name data

serendipity_getPermissionNames()   X-Ref
Returns the list of available internal Serendipity permission field names

This function also mapps which function was available to which userleves in older
Serendipity versions. Thus if an author does not have a certain privilege he should
have because of his userlevel, this can be reverse-mapped.

return: array   Multi-dimensional associative array which the list of all permission items plus their userlevel associations

serendipity_checkPermission($permName, $authorid = null, $returnMyGroups = false)   X-Ref
Checks if a permission is granted to a specific author

This function caches all permission chacks in static function variables to not
fetch all permissions time and again.
The permission checks are performed agains the values of each group. If a privilege
is set in one of the groups the author is a user of, the function returns true.
If a privilege is not set, the userlevel of an author is checked to act for backwards-compatibility.

param: string      The name of the permission to check
param: int         The authorid for which the permission check should be performed
param: boolean     If set to true, all groups that the requested author is a user of will be returned. This bypasses the permission check and mainly acts as a mean to return cached permissions, since those variables are only available within this function.
return: mixed       Either returns true if a permission check is performed, or return an array of group memberships. Depends on the $returnMyGroups variable.

serendipity_updateGroups($groups, $authorid, $apply_acl = true)   X-Ref
Update author group membership(s)

param: array       The array of groups the author should be a member of. All memberships that were present before and not contained in this array will be removed.
param: int         The ID of the author to update
param: boolean     If set to true, the groups can only be updated if the user has the adminUsersMaintainOthers privilege. If set to false, group memberships will be changable for any user.
return:

serendipity_getAllGroups($apply_ACL_user = false)   X-Ref
Returns all authorgroups that are available

If a groupname is prefixed with "USERLEVEL_" then the constant of that name is used to
return the name of the group. This allows inserting the special groups Chief Editor, Editor
and admin and still being able to use multilingual names for these groups.

param: int     If set to an author ID value, only groups are fetched that this author is a member of. If set to false, all groups are returned, also those that the current user has no access to.
return: array   An associative array of group names.

serendipity_fetchGroup($groupid)   X-Ref
Fetch the permissions of a certain group

param: int     The ID of the group that the permissions are fetched for
return: array   The associative array of permissions of a group.

serendipity_getGroups($authorid, $sequence = false)   X-Ref
Gets all groups a user is a member of

param: int         The authorid to fetch groups for
param: boolean     Indicate whether the original multi-dimensional DB result array shall be returned (FALSE) or if the array shall be flattened to be 1-dimensional (TRUE).
return:

serendipity_getGroupUsers($groupid)   X-Ref
Gets all author IDs of a specific group

param: int     The ID of the group to fetch the authors of
return: array   The assotiative array of author IDs and names

serendipity_deleteGroup($groupid)   X-Ref
Deletes a specific author group by ID

param: int     The group ID to delete
return: boolean Return true if group could be deleted, false if unsufficient privileges.

serendipity_addGroup($name)   X-Ref
Creates a new author group

param: string      The name of the new group
return: int         The id of the created group

serendipity_getDBPermissionNames()   X-Ref
Returns a list of all existing permission names.

Additional plugins might insert specific properties into the groupconfig database to
handle their own privileges. This call returns an array of all available permission names
so that it can be intersected with the list of internal permission names (serendipity_getPermissionNames())
and the be distincted.

return: array   associative array of all available permission names

serendipity_getAllPermissionNames()   X-Ref
Gets the list of all Permissions and merges the two arrays

The first call will fetch all existing permission names of the database. Then it will
fetch the list of defined internal permission names, which has an array with extra information
(like userlevel). This array will be merged with those permission names only found in the
database. The returned array will then hold as much information about permission names as is
available.
TODO Might need further pushing and/or an event hook so that external plugins using the
permission system can inject specific information into the array

return: array   Returns the array with all information about all permission names

serendipity_intersectGroup($checkuser = null, $myself = null)   X-Ref
Checks if two users are members of the same group

This function will retrieve all group memeberships of a
foreign user ($checkuser) and yourself ($myself). Then it
will check if there is any group membership that those
two users have in common.
It can be used for detecting if a different author should
be allowed to access your entries, because he's in the same
group, for example.

param: int     ID of the first author to check group memberships
param: int     ID of the second author to check group memberships
return: boolea  True if a membership intersects, false if not

serendipity_updateGroupConfig($groupid, &$perms, &$values, $isNewPriv = false, $forbidden_plugins = null, $forbidden_hooks = null)   X-Ref
Updates the configuration of permissions of a specific group

This function ensures that a group can only be updated from users that have permissions to do so.
param: int     The ID of the group to update
param: array   The associative array of permission names
param: array   The associative array of new values for the permissions. Needs the same associative keys like the $perms array.
param: bool    Indicates if an all new privilege should be inserted (true) or if an existing privilege is going to be checked
param: array   The associative array of plugin permission names
param: array   The associative array of plugin permission hooks
return: true

serendipity_addDefaultGroup($name, $level)   X-Ref
Adds a default internal group (Editor, Chief Editor, Admin)

param: string  The name of the group to insert
param: int     The userlevel that represents this group (0|1|255 for Editor/Chief/Admin).
return: true

serendipity_ACLGrant($artifact_id, $artifact_type, $artifact_mode, $groups, $artifact_index = '')   X-Ref
Allow access to a specific item (category or entry) for a specific usergroup

ACL are Access Control Lists. They indicate which read/write permissions a
specific item has for specific usergroups.
An artifact in terms of Serendipity can be either a category or an entry, or
anything beyond that for future compatibility.
This function sets up the ACLs.

param: int     The ID of the artifact to set the access
param: string  The type of an artifact (category|entry)
param: string  The type of access to grant (read|write)
param: array   The ID of the group to grant access to
param: string  A variable option for an artifact
return: boolean True if ACL was applied, false if not.

serendipity_ACLGet($artifact_id, $artifact_type, $artifact_mode, $artifact_index = '')   X-Ref
Checks if a specific item (category or entry) can be accessed by a specific usergroup

ACL are Access Control Lists. They indicate which read/write permissions a
specific item has for specific usergroups.
An artifact in terms of Serendipity can be either a category or an entry, or
anything beyond that for future compatibility.
This function retrieves the ACLs.

param: int     The ID of the artifact to set the access
param: string  The type of an artifact (category|entry)
param: string  The type of access to check for (read|write)
param: string  A variable option for an artifact
return: array   Returns an array of all groups that are allowed for this kind of access. You can then check if you are the member of any of the groups returned here.

serendipity_ACLCheck($authorid, $artifact_id, $artifact_type, $artifact_mode)   X-Ref
Checks if a specific item (category or entry) can be accessed by a specific Author

ACL are Access Control Lists. They indicate which read/write permissions a
specific item has for specific usergroups.
An artifact in terms of Serendipity can be either a category or an entry, or
anything beyond that for future compatibility.
This function retrieves the ACLs for a specific user.

param: int     The ID of the author to check against.
param: int     The ID of the artifact to set the access
param: string  The type of an artifact ('category', more to come)
param: string  The type of access to check for (read|write)
return: boolean Returns true, if the author has access to this artifact. False if not.

serendipity_ACL_SQL(&$cond, $append_category = false, $type = 'category', $mode = 'read')   X-Ref
Prepares a SQL statement to be used in queries that should be ACL restricted.

ACL are Access Control Lists. They indicate which read/write permissions a
specific item has for specific usergroups.
An artifact in terms of Serendipity can be either a category or an entry, or
anything beyond that for future compatibility.
This function evaluates and applies the SQL statements required.
It is currently only written for retrieving Category ACLs.
All of the SQL code that will be used in serendipity_fetchEntries will be stored
within the referenced $cond array.

param: array       Associative array that holds the SQL part array to be used in other functions like serendipity_fetchEntries()
param: boolean     Some queries do not need to joins categories. When ACLs need to be applied, this column is required, so if $append_category is set to true it will perform this missing JOIN.
param: string      The ACL type ('category', 'directory')
param: string      ACL mode
return: true        True if ACLs were applied, false if not.

serendipity_checkXSRF()   X-Ref
Check for Cross-Site-Request-Forgery attacks because of missing HTTP Referer

http://de.wikipedia.org/wiki/XSRF
This function checks the HTTP referer, and if it is part of the current Admin panel.

return: Returns true if XSRF was detected, false if not. The script should abort, if TRUE is returned.

serendipity_reportXSRF($type = 0, $reset = true, $use_config = false)   X-Ref
Report a XSRF attempt to the Serendipity Interface

http://de.wikipedia.org/wiki/XSRF

LONG

param: string      The type of XSRF check that got hit. Used for CSS formatting.
param: boolean     If true, the XSRF error should be fatal
param: boolean     If true, tell Serendipity to check the $serendipity['referrerXSRF'] config option to decide if an error should be reported or not.
return: string      Returns the HTML error report

serendipity_checkFormToken($output = true)   X-Ref
Prevent XSRF attacks by checking for a form token

http://de.wikipedia.org/wiki/XSRF

This function checks, if a valid Form token was posted to the site.

return: boolean     Returns true, if XSRF attempt was found and the token was missing

serendipity_setFormToken($type = 'form')   X-Ref
Prevent XSRF attacks by setting a form token within HTTP Forms

http://de.wikipedia.org/wiki/XSRF

By inserting a unique Form token that holds the session id, all requests
to serendipity HTTP forms can only be processed if the token is present.
This effectively makes XSRF attacks impossible. Only bundled with XSS
attacks it can be bypassed.

'form' type tokens can be embedded within the <form> script.
'url' type token can be embedded within HTTP GET calls.

param: string      The type of token to return (form|url|plain)
return: string      Returns the form token to be used in your functions

serendipity_loadThemeOptions(&$template_config, $okey = '')   X-Ref
Load available/configured options for a specific theme (through config.inc.php of a template directory)
into an array.

param: array   Referenced variable coming from the config.inc.php file, where the config values will be stored in
return: array   Final return array with default values

serendipity_hasPluginPermissions($plugin, $groupid = null)   X-Ref
Check if a member of a group has permissions to execute a plugin

param: string    Pluginname
param: int       ID of the group of which the members should be checked
return: boolean



Généré le : Sat Nov 24 09:00:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics