Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+28 votes
175 views
in Q2A Core by

I'm struggling to integrate Q2A with Chyrp-Lite (a lightweight open source blog program) through SSO. Following is the part of my "qa-external-users.php" file I modified before creating database. Please help. Thank you.  

function qa_get_mysql_user_column_type()

{

return 'INT';

}

function qa_get_login_links($relative_url_prefix, $redirect_back_to_url)

{

return array(

'login' => $relative_url_prefix.'blog/?action=login',

'register' => $relative_url_prefix.'blog/?action=register',

'logout' => $relative_url_prefix.'blog/'

);

}

function qa_get_logged_in_user()

{

session_start(); /*I tried with and without this line*/

if (!empty($_SESSION['user_id']))  { /*I tried replacing !empty with isset*/

$userid = $_SESSION['user_id'];

$result = qa_db_read_one_assoc(qa_db_query_sub(

'SELECT id, login, email, group_id FROM chy_users WHERE id=$',                                                                                       /*I tried id=# also tried id=$userid*/

$userid

));

if (is_array($result)) {

return array(

'userid' => $result['id'],

'publicusername' => $result['login'],

'email' => $result['email'],

'level' => ($result['group_id'] == 1) ? QA_USER_LEVEL_ADMIN : QA_USER_LEVEL_BASIC

); /*I tried ($result['group_id'] == '1')*/

}

}

return null;

}

function qa_get_user_email($userid)

{

$result = qa_db_read_one_assoc(qa_db_query_sub(

'SELECT email FROM chy_users WHERE id=#',

$userid

));

if (is_array($result))

return $result['email'];

return null;

}

function qa_get_userids_from_public($publicusernames)

{

$publictouserid = array();

if (count($publicusernames)) {

$escapedusernames = array();

foreach ($publicusernames as $publicusername)

$escapedusernames[] = "'" . qa_db_escape_string($publicusername) . "'";

$results = qa_db_read_all_assoc(qa_db_query_raw(

'SELECT login, id FROM chy_users WHERE login IN (' . implode(',', $escapedusernames) . ')'

));

foreach ($results as $result)

$publictouserid[$result['login']] = $result['id'];

}

return $publictouserid;

}

function qa_get_public_from_userids($userids)

{

$useridtopublic = array();

if (count($userids)) {

$escapeduserids = array();

foreach ($userids as $userid)

$escapeduserids[] = "'" . qa_db_escape_string($userid) . "'";

$results = qa_db_read_all_assoc(qa_db_query_raw(

'SELECT login, id FROM chy_users WHERE id IN (' . implode(',', $escapeduserids) . ')'

));

foreach ($results as $result)

$useridtopublic[$result['id']] = $result['login'];

}

return $useridtopublic;

}

Q2A version: Version 1.8.6

Please log in or register to answer this question.

...