| [ PHPXref.com ] | [ Generated: Tue Jul 29 09:36:16 2008 ] | [ Phorum 5.2.8 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Source view] [Print]
This script implements the Phorum user API. The user API is used for managing users and user related data. The API does also implement the Phorum session system, which is used for remembering authenticated users. See the documentation for the function {@link phorum_api_user_session_create()} for more information on Phorum user sessions.
| Copyright: | 2007, Phorum Development Team |
| License: | Phorum License, http://www.phorum.org/license.txt |
| File Size: | 3225 lines (119 kb) |
| Included or required: | 8 times |
| Referenced: | 0 times |
| Includes or requires: | 2 files include/api/file_storage.php include/api/custom_profile_fields.php |
| phorum_api_user_save($user, $flags = 0) X-Ref |
| Create or update Phorum users. This function can be used for both creating and updating Phorum users. If no user_id is provided in the user data, a new user will be created. If a user_id is provided, then the existing user will be updated or a new user with that user_id is created. Often when calling this function yourself, you will be doing that for synchronizing a user from some external system with the Phorum database. For those cases, the most basic use of this API function can be found in the examples below. <code> $user = array( "user_id" => 1234, "username" => 'johndoe', "password" => '#barbar#', "email" => 'john.doe@example.com', "admin" => 0, "active" => PHORUM_USER_ACTIVE ); phorum_api_user_save($user); </code> If you do not have the plain text password available, but only an MD5 hash for the password, then you can use the following code instead. <code> $user = array( "user_id" => 1234, "username" => 'johndoe', "password" => '5d61ed116ffdecf2d29cd1ed9bd9d4cb', "email" => 'john.doe@example.com', "admin" => 0, "active" => PHORUM_USER_ACTIVE ); phorum_api_user_save($user, PHORUM_FLAG_RAW_PASSWORD); </code> param: array $user param: int $flags return: int |
| phorum_api_user_save_raw($user) X-Ref |
| This function quickly updates the Phorum users table, using all fields in the user data as real user table fields. This is the quickest way to update the user table. Care has to be taken by the calling function though, to provide the information exactly as the Phorum users table expects it. Only use this function if speed is really an issue. param: array $user |
| phorum_api_user_save_settings($settings) X-Ref |
| Create or update user settings for the active Phorum user. This function can be used to store arbitrairy settings for the active Phorum user in the database. The main goal for this function is to store user settings which are not available as a Phorum user table field in the database. These are settings which do not really belong to the Phorum core, but which are for example used for remembering some kind of state in a user interface (templates). Since each user interface might require different settings, a dynamic settings storage like this is required. If you are writing modules that need to store data for a user, then please do not use this function. Instead, use custom profile fields. The data that is stored using this function can be best looked at as if it were session data. param: array $settings |
| phorum_api_user_get($user_id, $detailed = FALSE, $use_write_server = FALSE) X-Ref |
| Retrieve data for Phorum users. param: mixed $user_id param: boolean $detailed param: boolean $use_write_server return: mixed |
| phorum_api_user_get_setting($name) X-Ref |
| This function can be used to retrieve the value for a user setting that was stored by the {@link phorum_api_user_save_settings()} function for the active Phorum user. param: string $name return: mixed |
| phorum_api_user_get_display_name($user_id = NULL, $fallback = NULL, $flags = PHORUM_FLAG_HTML) X-Ref |
| Retrieve the display name to use for one or more users. The name to use depends on the "display_name_source" setting. This one points to either the username or the real_name field of the user. If the display_name is requested for an unknown user, then a fallback name will be used. param: mixed $user_id param: mixed $fallback param: mixed $flags return: mixed |
| phorum_api_user_search($field, $value, $operator = '=', $return_array = FALSE, $type = 'AND', $sort = NULL, $offset = 0, $length = 0) X-Ref |
| Search for users, based on simple search conditions, which act on fields in the user table. The parameters $field, $value and $operator (which are used for defining the search condition) can be arrays or single values. If arrays are used, then all three parameter arrays must contain the same number of elements and the keys in the arrays must be the same. param: mixed $field param: mixed $value param: mixed $operator param: boolean $return_array param: string $type param: mixed $sort param: integer $offset param: integer $length return: mixed |
| phorum_api_user_search_custom_profile_field($field_id, $value, $operator = '=', $return_array = FALSE, $type = 'AND', $offset = 0, $length = 0) X-Ref |
| Search for users, based on a simple search condition, which can be used to search on custom profile fields. The parameters $field_id, $value and $operator (which are used for defining the search condition) can be arrays or single values. If arrays are used, then all three parameter arrays must contain the same number of elements and the keys in the arrays must be the same. param: mixed $field_id param: mixed $value param: mixed $operator param: boolean $return_array param: string $type param: integer $offset param: integer $length return: mixed |
| phorum_api_user_list($type = PHORUM_GET_ALL) X-Ref |
| Retrieve a list of Phorum users. param: int $flags return: array |
| phorum_api_user_increment_posts($user_id = NULL) X-Ref |
| Increment the posts counter for a user. param: mixed $user_id |
| phorum_api_user_delete($user_id) X-Ref |
| Delete a Phorum user. param: integer $user_id |
| phorum_api_user_format($users) X-Ref |
| No description |
| phorum_api_user_authenticate($type, $username, $password) X-Ref |
| Check the authentication credentials for a user. param: string $type param: string $username param: string $password return: mixed |
| phorum_api_user_set_active_user($type, $user = NULL, $flags = 0) X-Ref |
| Set the active Phorum user. This function can be used to setup the Phorum data to indicate which user is logged in or to setup the anonymous user. Calling this function is all that is needed to tell Phorum which user is logged in (or to tell that no user is logged in by setting up the anonymous user). Next to setting up the user data, the function will handle user activity tracking (based on the "track_user_activity" setting) and setup some special (template) variables: The variabe $PHORUM["DATA"]["ADMINISTRATOR"] will be set to TRUE if the active user is an administrator, FALSE otherwise. For type {@link PHORUM_FORUM_SESSION}, the following extra variables will be filled: - $PHORUM["DATA"]["LOGGEDIN"]: TRUE if the user is logged in, FALSE otherwise. - $PHORUM["DATA"]["FULLY_LOGGEDIN"]: TRUE if a short term session is active (by setting the {@link PHORUM_FLAG_SESSION_ST} flag for the $flags parameter), FALSE otherwise. param: string $type param: mixed $user param: integer $flags return: boolean |
| phorum_api_user_session_create($type, $reset = 0) X-Ref |
| Create a Phorum user session. Before calling this function, the variable $PHORUM['use_cookies'] should be set to one of {@link PHORUM_NO_COOKIES}, {@link PHORUM_USE_COOKIES} or {@link PHORUM_REQUIRE_COOKIES}. Phorum does not use PHP sessions. Instead, it uses its own session management system for remembering logged in users. There are multiple reasons for that, amongst which are: - the lack of session support (on some PHP installs); - missing out of the box load balancing support (sessions are normally written to local session state files, so multiple machines would not work well together); - file I/O problems (both performance and file system permissions can be a problem); - the amount of unneeded overhead that is caused by the PHP session system; - the fact that Phorum also supports URI based sessions (without cookie). This function can be used to create or maintain a login session for a Phorum user. A prerequisite is that an active Phorum user is set through the {@link phorum_api_user_set_active_user()} function, before calling this function. There are two session types available: {@link PHORUM_FORUM_SESSION} (used for the front end application) and {@link PHORUM_ADMIN_SESSION} (used for the administrative back end). Admin sessions are used for the administrative back end system. For security reasons, the back end does not share the front end session, but uses a fully separate session instead. This session does not have a timeout restriction, but it does not survive closing the browser. It is always tracked using a cookie, never using URI authentication (for security reasons). The forum sessions can be split up into long term and short term sessions: - Long term session: The standard Phorum user session. This session is long lasting and will survive after closing the browser (unless the long term session timeout is set to zero). If tighter security is not enabled, then this session is all a user needs to fully use all forum options. This session is tracked using either a cookie or URI authentication. - Short term session: This session has a limited life time and will not survive closing the browser. If tighter security is enabled, then the user will not be able to use all forum functions, unless there is a short term session active (e.g. posting forum messages and reading/writing private messages are restricted). This session is tracked using a cookie. If URI authentication is in use (because of admin config or cookie-less browsers) Phorum will only look at the long term session (even in tighter security mode), since URI authentication can be considered to be short term by nature. param: string $type param: integer $reset return: boolean |
| phorum_api_user_session_restore($type) X-Ref |
| Restore a Phorum user session. This function will check for a valid user session for either the forum or the admin interface (based on the $type parameter). If a valid session is found, then the user session will be restored. Before calling this function, the variable $PHORUM['use_cookies'] should be set to one of {@link PHORUM_NO_COOKIES}, {@link PHORUM_USE_COOKIES} or {@link PHORUM_REQUIRE_COOKIES}. param: string $type return: boolean |
| phorum_api_user_session_destroy($type) X-Ref |
| Destroy a Phorum user session. This will destroy a Phorum user session and set the active Phorum user to the anonymous user. param: string $type |
| phorum_api_user_get_groups($user_id) X-Ref |
| Retrieve the groups and their subscription statuses for a user. param: integer $user_id return: array |
| phorum_api_user_save_groups($user_id, $groups) X-Ref |
| Save the groups and group permissions for a user. param: integer $user_id param: array $groups |
| phorum_api_user_check_access($permission, $forum_id = 0, $user = 0) X-Ref |
| Check if a user has certain access right for forum(s). param: integer $permission param: mixed $forum_id param: mixed $user return: mixed |
| phorum_api_user_check_group_access($permission, $group_id, $user = 0) X-Ref |
param: integer $permission param: mixed $group_id param: mixed $user return: mixed |
| phorum_api_user_list_moderators($forum_id = 0, $exclude_admin = FALSE, $for_mail = FALSE) X-Ref |
| Retrieve a list of moderators. param: integer $forum_id param: boolean $exclude_admin param: boolean $for_mail return: array |
| phorum_api_user_subscribe($user_id, $thread, $forum_id, $type) X-Ref |
| Subscribe a user to a thread. Remark: Currently, there is no active support for subscribing to forums using subscription type PHORUM_SUBSCRIPTION_DIGEST in the Phorum core. param: integer $user_id param: integer $thread param: integer $forum_id param: integer $type |
| phorum_api_user_unsubscribe($user_id, $thread, $forum_id = 0) X-Ref |
| Unsubscribe a user from a thread. param: integer $user_id param: integer $thread param: integer $forum_id |
| phorum_api_user_get_subscription($user_id, $forum_id, $thread) X-Ref |
| Retrieve the type of a single subscription. param: integer $user_id param: integer $thread param: integer $forum_id return: mixed |
| phorum_api_user_list_subscriptions($user_id, $days=0, $forum_ids=NULL) X-Ref |
| Retrieve a list of threads to which a user is subscribed. The list can be limited to those threads which did receive contributions recently. param: integer $user_id param: integer $days param: integer $forum_ids return: array $threads |
| phorum_api_user_list_subscribers($forum_id, $thread, $type, $ignore_active_user = TRUE) X-Ref |
| Retrieve the email addresses of the users that are subscribed to a forum/thread, grouped by the preferred language for these users. param: integer $forum_id param: integer $thread param: integer $type param: boolean $ignore_active_user return: array $addresses |
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |