Skip to content

Commit

Permalink
first part of "Make Ajax calls without enabled cookies work". Server-…
Browse files Browse the repository at this point in the history
…side work is done with this commit. Now only the JS-part in the phorum ajax lib is missing (related to #816)
  • Loading branch information
mysnip committed Jul 8, 2011
1 parent b961b5a commit 261c332
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,19 @@

$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>
Expand Down Expand Up @@ -198,8 +211,6 @@ function phorum_ajax_error($message)
*/
function phorum_ajax_return($data)
{
global $PHORUM;

header("Content-Type: text/plain; charset=UTF-8");
print phorum_api_json_encode($data);
exit(0);
Expand Down

0 comments on commit 261c332

Please sign in to comment.