if ($PHORUM["user"]["threaded_list"] == PHORUM_THREADED_ON) { $PHORUM["threaded_list"] = true; } elseif ($PHORUM["user"]["threaded_list"] == PHORUM_THREADED_OFF) { $PHORUM["threaded_list"] = false; } if ($PHORUM["user"]["threaded_read"] == PHORUM_THREADED_ON) { $PHORUM["threaded_read"] = 1; } elseif ($PHORUM["user"]["threaded_read"] == PHORUM_THREADED_OFF) { $PHORUM["threaded_read"] = 0; } elseif ($PHORUM["user"]["threaded_read"] == PHORUM_THREADED_HYBRID) { $PHORUM["threaded_read"] = 2; } } // check if the user has new private messages if (!empty($PHORUM["enable_new_pm_count"]) && !empty($PHORUM["enable_pm"])) { $PHORUM['user']['new_private_messages'] = phorum_db_pm_checknew($PHORUM['user']['user_id']); } } /* * [hook] * common_post_user * * [description] * This hook gives modules a chance to override Phorum variables * and settings, after the active user has been loaded. The settings * for the active forum are also loaded before this hook is called, * therefore this hook can be used for overriding general settings, * forum settings and user settings. * * [category] * Request initialization
/** * This function retrieves a user from the database, given the user id. * If $user_id is an array of user ids, it will retrieve all of the users * in the array. If $detailed is set to true, the function gets the users * full information. Setting this to false omits permission data, pm counts, * and group membership. $detailed is true by default and may be omitted. * @param user_id - can be a single user id, or an array of user ids. * @param detailed - get detailed user information (defaults to true). * @param checknewpm - check for new private messages for the user (defaults to false). * @return array - either an array representing a single user's information, * or an array of users */ function phorum_user_get( $user_id, $detailed = true, $checkpm = false ) { $PHORUM = $GLOBALS["PHORUM"]; if ( !is_array( $user_id ) ) { $user_ids = array( $user_id ); } else { $user_ids = $user_id; } if ( count( $user_ids ) ) { $cache_users=array(); $tmp_users=array(); $cachecnt=0; // get users from cache if enabled if(isset($PHORUM['cache_users']) && $PHORUM['cache_users']) { foreach($user_ids as $id => $cur_user_id) { $data=phorum_cache_get('user',$cur_user_id); if($data != null) { // null if no key found $cache_users[$cur_user_id]=$data; unset($user_ids[$id]); $cachecnt++; } } unset($data); // we need to get the dynamic data too! // only selecting date_last_active, forum_last_active, // posts ... any more? if($cachecnt > 0) { $dynamic_data=phorum_db_user_get_fields(array_keys($cache_users),array('date_last_active','last_active_forum','posts')); foreach($dynamic_data as $d_uid => $d_data) { $cache_users[$d_uid]=array_merge($cache_users[$d_uid],$d_data); } } } if(count($user_ids)) { $tmp_users = phorum_db_user_get( $user_ids, $detailed ); foreach( $tmp_users as $uid => $user ) { if ( !$user["admin"] ) { if ( isset( $user["group_permissions"] ) ) { foreach( $user["group_permissions"] as $forum_id => $perm ) { if(!isset($user["permissions"][$forum_id])) $user["permissions"][$forum_id]=0; $user["permissions"][$forum_id] = $user["permissions"][$forum_id] | $perm; } } if ( isset( $user["forum_permissions"] ) ) { foreach( $user["forum_permissions"] as $forum_id => $perm ) { $user["permissions"][$forum_id] = $perm; } } } // check if the user has new private messages if ( ($checkpm || (isset($PHORUM['cache_users']) && $PHORUM['cache_users'])) && $PHORUM["enable_pm"] && $PHORUM["enable_new_pm_count"] ) { $user["new_private_messages"] = phorum_db_pm_checknew( $uid ); } // store users in cache if enabled if( $detailed && isset($PHORUM['cache_users']) && $PHORUM['cache_users']) { phorum_cache_put('user',$uid,$user); } $tmp_users[$uid] = $user; } } } // merging cached and retrieved users $ret = $tmp_users + $cache_users; if ( !is_array( $user_id ) ) { if (isset($ret[$user_id])) $ret = $ret[$user_id]; else $ret = NULL; } return $ret; }
FUNCTION checkpm - check for availability of new unread private messages. ARGUMENTS [user_id] The user_id of the user to check for. If this user_id is not provided, the user_id of the logged in user will be used instead. If no user is logged in, the call will return zero by default. EXAMPLE JSON REQUESTS { "call": "checkpm" } { "call": "checkpm", "user_id": 1234 } RETURN VALUE The call will return zero if there are no unread private messages or if no user_id is known. The call will return one if there are unread private messages. ERRORS The call will return an error if the user_id is not in the right format. AUTHOR Maurice Makaay <*****@*****.**> */ if (!defined('PHORUM')) { return; } $user_id = phorum_ajax_getarg('user_id', 'int>0', 0); if ($user_id == 0 && isset($PHORUM["user"]["user_id"])) { $user_id = $PHORUM["user"]["user_id"]; } $hasnew = $user_id == 0 ? 0 : phorum_db_pm_checknew($user_id) ? 1 : 0; phorum_ajax_return($hasnew);