// Check if we got a valid Ajax request. The request should contain at // least a "call" field in the Ajax arguments. if (empty($PHORUM['ajax_args']) || !isset($PHORUM['ajax_args']['call'])) { phorum_ajax_error('Illegal Ajax request'); } $ajax_call = basename($PHORUM['ajax_args']['call']); // try to get some session-id if there isn't already a user loaded through // the regular ways if (empty($PHORUM['user']['user_id'])) { // check if we got a session-id in the ajax args and if we got one // try to load a user with that data $ajax_session_id = phorum_ajax_getarg(PHORUM_SESSION_LONG_TERM, 'string', 0); if (!empty($ajax_session_id)) { $PHORUM['use_cookies'] = PHORUM_USE_COOKIES; $PHORUM['args'][PHORUM_SESSION_LONG_TERM] = $ajax_session_id; phorum_api_user_session_restore(PHORUM_FORUM_SESSION); } } /** * [hook] * ajax_<call> * * [availability] * Phorum 5 >= 5.2.8 * * [description] * This hook allows module writers to implement calls for the * Phorum Ajax layer.<sbr/> * <sbr/> * The "call" argument from the Ajax argument array is used to * construct the name of the hook that will be called. For example
unset($PHORUM['name']); } } // Stick some stuff from the settings into the template DATA. $PHORUM["DATA"]["NAME"] = isset($PHORUM["name"]) ? $PHORUM["name"] : ""; $PHORUM["DATA"]["HTML_DESCRIPTION"] = isset($PHORUM["description"]) ? preg_replace("!\\s+!", " ", $PHORUM["description"]) : ""; // Clean up for getting the description without html in it, so we // can use it inside the HTML meta description element. $PHORUM["DATA"]["DESCRIPTION"] = str_replace(array('\'', '"'), array('', ''), strip_tags($PHORUM["DATA"]["HTML_DESCRIPTION"])); $PHORUM["DATA"]["ENABLE_PM"] = isset($PHORUM["enable_pm"]) ? $PHORUM["enable_pm"] : ''; if (!empty($PHORUM["DATA"]["HTML_TITLE"]) && !empty($PHORUM["DATA"]["NAME"])) { $PHORUM["DATA"]["HTML_TITLE"] .= PHORUM_SEPARATOR; } $PHORUM["DATA"]["HTML_TITLE"] .= $PHORUM["DATA"]["NAME"]; // Try to restore a user session. if (!$skipsession && phorum_api_user_session_restore(PHORUM_FORUM_SESSION)) { // If the user has overridden thread settings, change them here. $modes = phorum_api_forums_get_display_modes($PHORUM); $PHORUM["threaded_list"] = $modes['list']; $PHORUM["threaded_read"] = $modes['read']; // Provide the number of new private messages for the user in the // "new_private_messages" field. if (!empty($PHORUM["enable_pm"])) { $PHORUM['user']['new_private_messages'] = $PHORUM['user']['pm_new_count']; } } /* * [hook] * common_post_user * * [description]
function testUserApiSessionRestore() { $user_id = phorum_api_user_search('username', 'testuser' . $this->sharedFixture, '='); $GLOBALS['PHORUM']['user']['user_id'] = $user_id; $GLOBALS['PHORUM']['user'] = phorum_api_user_get($user_id); $ret = phorum_api_user_session_restore(PHORUM_FORUM_SESSION); $this->assertTrue($ret, 'Restore user-session'); }