Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Q2A & Drupal 6 integration
in drupal open "\sites\default\setting.php" and add:
$cookie_domain = '.example.com';
// Database (for login/stats integration)
define('EXT_WEBADDRESS', 'http://www.cengolio.com/');
//define('DRUPAL_ROOT', dirname(getcwd() ).'\\');
define('DRUPAL_ROOT', '/home/beknikci/public_html/cengolio.com//');
//$current_path = getcwd();
//define('DRUPAL_ROOT', dirname(getcwd() ).'\\');
chdir(DRUPAL_ROOT);
require_once DRUPAL_ROOT . 'includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
//chdir($current_path);
<?php
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../');
exit;
}
function qa_get_mysql_user_column_type()
{
//users > uid > int(10)
return 'INT';
}
function qa_get_login_links($relative_url_prefix, $redirect_back_to_url)
{
return array(
'login' => EXT_WEBADDRESS.'user/',
'register' => EXT_WEBADDRESS.'user/register',
'logout' => EXT_WEBADDRESS.'user/logout'
);
}
function qa_get_logged_in_user()
{
global $user;
foreach($user -> roles as $key => $value)
if ($value=='administrator')
$user_is_admin=true;
if ($user -> uid==0)
return null;
else {
if ($user_is_admin)
$level=QA_USER_LEVEL_ADMIN;
else
$level=QA_USER_LEVEL_BASIC;
/*
elseif (current_user_can('editor'))
$level=QA_USER_LEVEL_EDITOR;
elseif (current_user_can('contributor'))
$level=QA_USER_LEVEL_EXPERT;
else
$level=QA_USER_LEVEL_BASIC;
*/
return array(
'userid' => $user->uid,
'publicusername' => $user->name,
'email' => $user->mail,
'level' => $level,
);
}
}
function qa_get_user_email($userid)
{
$thisUser = user_load(array('uid' => $userid));
return $thisUser->mail;
}
function qa_get_userids_from_public($publicusernames)
{
if (count($publicusernames))
return qa_db_read_all_assoc(qa_db_query_sub(
'SELECT name, uid FROM users WHERE name IN ($)',
$publicusernames
), 'name', 'uid');
else
return array();
}
function qa_get_public_from_userids($userids)
{
if (count($userids)) {
$useridtopublic=array();
$qa_user_emails=array();
$userfields=qa_db_read_all_assoc(qa_db_query_sub(
'SELECT uid, name, mail FROM users WHERE uid IN (#)',
$userids
), 'uid');
foreach ($userfields as $id => $fields) {
$useridtopublic[$id]=$fields['name'];
$qa_user_emails[$id]=$fields['mail'];
}
return $useridtopublic;
} else
return array();
}
function qa_get_logged_in_user_html($logged_in_user, $relative_url_prefix)
{
$publicusername=$logged_in_user['publicusername'];
return '<A HREF="'.htmlspecialchars($relative_url_prefix.'user/'.urlencode($publicusername)).
'" CLASS="qa-user-link">'.htmlspecialchars($publicusername).'</A>';
}
function qa_get_users_html($userids, $should_include_link, $relative_url_prefix)
{
$useridtopublic=qa_get_public_from_userids($userids);
$usershtml=array();
foreach ($userids as $userid) {
$publicusername=$useridtopublic[$userid];
$usershtml[$userid]=htmlspecialchars($publicusername);
if ($should_include_link)
$usershtml[$userid]='<A HREF="'.htmlspecialchars($relative_url_prefix.'user/'.urlencode($publicusername)).
'" CLASS="qa-user-link">'.$usershtml[$userid].'</A>';
}
return $usershtml;
}
function qa_avatar_html_from_userid($userid, $size, $padding)
{
return null; // show no avatars by default
}
function qa_user_report_action($userid, $action)
{
}
/*
Omit PHP closing tag to help avoid accidental output
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment