本文整理汇总了PHP中qa_db_read_one_value函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_db_read_one_value函数的具体用法?PHP qa_db_read_one_value怎么用?PHP qa_db_read_one_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qa_db_read_one_value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mp_get_activity_points_by_userid
function mp_get_activity_points_by_userid($userid, $categoryid)
{
return qa_db_read_one_value(qa_db_query_sub('SELECT COALESCE(SUM(U.points), 0) points FROM `mp_userpoints` U RIGHT JOIN mp_user_category_map M ON U.userid = M.userid AND U.categoryid = M.categoryid, qa_users QU
WHERE M.userid = QU.userid AND M.categoryid = # AND M.userid = #
GROUP BY M.userid
ORDER BY points DESC, QU.handle ASC', $categoryid, $userid), true);
}
示例2: check_privileges
function check_privileges($userid, $event_points)
{
$user = qa_db_select_with_pending(qa_db_user_points_selectspec($userid, true));
$upoints = (int) $user['points'];
$before_points = (int) $user['points'] - $event_points;
$permr = qa_db_read_one_value(qa_db_query_sub('SELECT meta_value FROM ^usermeta WHERE user_id=# AND meta_key=$ ', $userid, 'priv_notify'), true);
// stale perms
$stale = array();
if ($permr) {
$perms = explode('^', $permr);
$stale = explode(',', $perms[0]);
}
$p_options = qa_get_permit_options();
$notices = '';
foreach ($p_options as $option) {
if (qa_opt($option) == QA_PERMIT_POINTS) {
$opoints = (int) qa_opt($option . '_points');
if ($opoints < $upoints && $opoints > $before_points && !in_array($option, $stale)) {
$notices = ($notices ? $notices . ',' : '') . $option;
}
}
}
if ($notices) {
qa_db_query_sub('INSERT INTO ^usermeta (user_id,meta_key,meta_value) VALUES (#,$,$) ON DUPLICATE KEY UPDATE meta_value=$', $userid, 'priv_notify', '^' . $notices, $permr . ($perms[1] ? ',' : '') . $notices);
if (qa_opt('priv_email_notify_on')) {
$this->notify($userid, $notices);
}
}
}
示例3: qa_share_buttons
function qa_share_buttons($q_view)
{
if (qa_opt('expert_question_enable')) {
$qid = $q_view['raw']['postid'];
$expert = qa_db_read_one_value(qa_db_query_sub("SELECT meta_value FROM ^postmeta WHERE meta_key='is_expert_question' AND post_id=#", $qid), true);
if ($expert) {
return;
}
}
$url = qa_path_html(qa_q_request($q_view['raw']['postid'], $q_view['raw']['title']), null, qa_opt('site_url'));
$code = array('facebook' => '<iframe src="//www.facebook.com/plugins/like.php?href=' . qa_path_html(qa_q_request($this->content['q_view']['raw']['postid'], $this->content['q_view']['raw']['title']), null, qa_opt('site_url')) . '&send=false&layout=standard&width=53&layout=button_count&show_faces=false&action=like&colorscheme=light&font&height=20&appId=170382616390886" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:53px; height:20px;" allowTransparency="true"></iframe>', 'twitter' => '<a href="http://twitter.com/share" class="twitter-share-button" data-count="none">Tweet</a>', 'google' => '<g:plusone size="medium" count="false"></g:plusone>', 'linkedin' => '<script type="text/javascript" src="http://platform.linkedin.com/in.js"></script><script type="in/share"></script>', 'email' => '<a title="Share this question via email" id="share-button-email" href="mailto:?subject=' . rawurlencode('[' . qa_opt('site_title') . '] ' . $q_view['raw']['title']) . '&body=' . rawurlencode($url) . '"><img height="24" src="' . QA_HTML_THEME_LAYER_URLTOROOT . 'qa-share-mail.png' . '"/></a>');
// sort by weight
$weight = array('facebook' => qa_opt('share_plugin_facebook_weight'), 'twitter' => qa_opt('share_plugin_twitter_weight'), 'google' => qa_opt('share_plugin_google_weight'), 'linkedin' => qa_opt('share_plugin_linkedin_weight'), 'email' => qa_opt('share_plugin_email_weight'));
asort($weight);
// output
foreach ($weight as $key => $val) {
if (qa_opt('share_plugin_' . $key)) {
$shares[] = $code[$key];
}
}
if (empty($shares)) {
return null;
}
$output = implode(' ', $shares);
return $output;
}
示例4: qa_db_blob_exists
function qa_db_blob_exists($blobid)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
return qa_db_read_one_value(qa_db_query_sub('SELECT COUNT(*) FROM ^blobs WHERE blobid=#', $blobid)) > 0;
}
示例5: qa_db_cache_get
function qa_db_cache_get($type, $cacheid)
{
$content = qa_db_read_one_value(qa_db_query_sub('SELECT content FROM ^cache WHERE type=$ AND cacheid=#', $type, $cacheid), true);
if (isset($content)) {
qa_db_query_sub('UPDATE ^cache SET lastread=NOW() WHERE type=$ AND cacheid=#', $type, $cacheid);
}
return $content;
}
示例6: ra_db_builder
function ra_db_builder($name, $value = null)
{
if (isset($value)) {
ra_set_builder_content($name, $value);
} else {
$content = qa_db_read_one_value(qa_db_query_sub('SELECT BINARY content as content FROM ^builder WHERE name=#', $name), true);
return str_replace('\\', '', $content);
}
}
示例7: getuserfromhandle
function getuserfromhandle($handle)
{
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
if (QA_FINAL_EXTERNAL_USERS) {
$publictouserid = qa_get_userids_from_public(array($handle));
$userid = @$publictouserid[$handle];
} else {
$userid = qa_db_read_one_value(qa_db_query_sub('SELECT userid FROM ^users WHERE handle = $', $handle), true);
}
return $userid;
}
示例8: qa_db_cache_get
function qa_db_cache_get($type, $cacheid)
{
if (qa_to_override(__FUNCTION__)) {
$args = func_get_args();
return qa_call_override(__FUNCTION__, $args);
}
$content = qa_db_read_one_value(qa_db_query_sub('SELECT content FROM ^cache WHERE type=$ AND cacheid=#', $type, $cacheid), true);
if (isset($content)) {
qa_db_query_sub('UPDATE ^cache SET lastread=NOW() WHERE type=$ AND cacheid=#', $type, $cacheid);
}
return $content;
}
示例9: a_count
function a_count($post)
{
if (qa_opt('ccount') && isset($post['answers'])) {
$this->output('<div class="qa-ac-count">');
qa_html_theme_base::a_count($post);
$comments = qa_db_read_one_value(qa_db_query_sub("SELECT COUNT(postid) FROM ^posts WHERE (parentid=# OR parentid IN (SELECT postid FROM ^posts WHERE parentid=#)) AND type='C'", $post['raw']['postid'], $post['raw']['postid']));
$this->output_split(array('prefix' => '', 'data' => $comments, 'suffix' => ' comments'), 'qa-c-count', 'SPAN', 'SPAN');
$this->output('</div>');
} else {
qa_html_theme_base::a_count($post);
}
}
示例10: q_view_clear
function q_view_clear()
{
// call default method output
qa_html_theme_base::q_view_clear();
// return if not admin!
if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) {
return;
}
// check if question is duplicate
$closed = @$this->content['q_view']['raw']['closedbyid'] !== null;
if ($closed) {
// check if duplicate
$duplicate = qa_db_read_one_value(qa_db_query_sub('SELECT postid FROM `^posts`
WHERE `postid` = #
AND `type` = "Q"
;', $this->content['q_view']['raw']['closedbyid']), true);
if ($duplicate) {
$this->output('<div id="mergeDup" style="margin:10px 0 0 120px;padding:5px 10px;background:#FCC;border:1px solid #AAA;"><h3>Merge Duplicate:</h3>');
// form output
$this->output('
<FORM METHOD="POST">
<TABLE>
<TR>
<TD CLASS="qa-form-tall-label">
From:
<INPUT NAME="merge_from" id="merge_from" TYPE="text" VALUE="' . $this->content['q_view']['raw']['postid'] . '" CLASS="qa-form-tall-number">
To:
<INPUT NAME="merge_to" id="merge_to" TYPE="text" VALUE="' . $this->content['q_view']['raw']['closedbyid'] . '" CLASS="qa-form-tall-number">
</TD>
</TR>
<TR>
<TD CLASS="qa-form-tall-label">
Text to show when redirecting from merged question:
</TD>
</TR>
<TR>
<TD CLASS="qa-form-tall-label">
<INPUT NAME="merge_question_merged" id="merge_question_merged" TYPE="text" VALUE="' . qa_opt('merge_question_merged') . '" CLASS="qa-form-tall-text">
</TD>
</TR>
<TR>
<TD style="text-align:right;">
<INPUT NAME="merge_question_process" VALUE="Merge" TITLE="" TYPE="submit" CLASS="qa-form-tall-button qa-form-tall-button-0">
</TD>
</TR>
</TABLE>
</FORM> ');
$this->output('</div>');
}
}
}
示例11: qa_page_q_post_rules
function qa_page_q_post_rules($post, $parentpost = null, $siblingposts = null, $childposts = null)
{
$rules = qa_page_q_post_rules_base($post, $parentpost, $siblingposts, $childposts);
qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^postmeta (
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
post_id bigint(20) unsigned NOT NULL,
meta_key varchar(255) DEFAULT \'\',
meta_value longtext,
PRIMARY KEY (meta_id),
KEY post_id (post_id),
KEY meta_key (meta_key)
) ENGINE=MyISAM DEFAULT CHARSET=utf8');
$expert = qa_db_read_one_value(qa_db_query_sub("SELECT meta_value FROM ^postmeta WHERE meta_key='is_expert_question' AND post_id=#", $post['postid']), true);
if ($expert) {
if (!qa_permit_value_error(qa_opt('expert_question_roles'), qa_get_logged_in_userid(), qa_get_logged_in_level(), qa_get_logged_in_flags())) {
$is_expert = true;
}
$users = qa_opt('expert_question_users');
$users = explode("\n", $users);
$handle = qa_get_logged_in_handle();
foreach ($users as $idx => $user) {
if ($user == $handle) {
$is_expert = true;
break;
}
if (strpos($user, '=')) {
$user = explode('=', $user);
if ($user[0] == $handle) {
$catnames = explode(',', $user[1]);
$cats = qa_db_read_all_values(qa_db_query_sub('SELECT categoryid FROM ^categories WHERE title IN ($)', $catnames));
$is_expert = $cats;
}
}
}
if (isset($is_expert) && !$rules['viewable']) {
// experts that aren't allowed to change hidden questions
if (is_array($is_expert)) {
$in_cats = qa_db_read_one_value(qa_db_query_sub("SELECT COUNT(postid) FROM ^posts WHERE categoryid IN (#) AND postid=#", $is_expert, $post['postid']), true);
if ($in_cats) {
$rules['viewable'] = true;
}
} else {
$rules['viewable'] = true;
}
}
$rules['reshowable'] = false;
$rules['answerbutton'] = true;
$rules['commentbutton'] = true;
$rules['commentable'] = true;
}
return $rules;
}
示例12: process_event
function process_event($event, $userid, $handle, $cookieid, $params)
{
if (!qa_opt('close_auto_close')) {
return;
}
$special = array('a_post', 'c_post');
if ($event == 'a_post') {
$count = qa_db_read_one_value(qa_db_query_sub('SELECT COUNT(postid) FROM ^posts WHERE type=$ AND parentid=#', 'A', $params['parentid']), true);
if ($count >= qa_opt('close_auto_close')) {
qa_db_query_sub('INSERT INTO ^postmeta (post_id,meta_key,meta_value) VALUES (#,$,$) ON DUPLICATE KEY UPDATE meta_value=meta_value', $params['parentid'], 'is_closed', $userid . '^' . qa_opt('close_auto_close_reason'));
}
}
}
示例13: process_event
function process_event($event, $userid, $handle, $cookieid, $params)
{
if (qa_opt('buddypress_integration_enable') && $userid) {
switch ($event) {
// when a new question, answer or comment is created. The $params array contains full information about the new post, including its ID in $params['postid'] and textual content in $params['text'].
case 'q_post':
if (qa_post_text('is_expert_question') == 'yes' || !qa_opt('buddypress_integration_post_q')) {
return;
}
// don't broadcast expert questions
$this->post($event, $userid, $handle, $params, 'Q');
break;
case 'a_post':
if (qa_post_text('is_expert_question') == 'yes' || !qa_opt('buddypress_integration_post_a')) {
return;
}
if (qa_opt('expert_question_enable')) {
$pid = $params['parentid'];
$parent = qa_db_read_one_assoc(qa_db_query_sub("SELECT type, parentid FROM ^posts WHERE postid=#", $pid), true);
if (strpos($parent['type'], 'A') === 0) {
$pid = $parent['parentid'];
}
$expert = qa_db_read_one_value(qa_db_query_sub("SELECT meta_value FROM ^postmeta WHERE post_id=# AND meta_key='is_expert_question'", $pid), true);
if ($expert) {
return;
}
}
$this->post($event, $userid, $handle, $params, 'A');
break;
case 'c_post':
if (!qa_opt('buddypress_integration_post_c')) {
return;
}
if (qa_opt('expert_question_enable')) {
$pid = $params['parentid'];
$parent = qa_db_read_one_assoc(qa_db_query_sub("SELECT type, parentid FROM ^posts WHERE postid=#", $pid), true);
if (strpos($parent['type'], 'A') === 0) {
$pid = $parent['parentid'];
}
$expert = qa_db_read_one_value(qa_db_query_sub("SELECT meta_value FROM ^postmeta WHERE post_id=# AND meta_key='is_expert_question'", $pid), true);
if ($expert) {
return;
}
}
$this->post($event, $userid, $handle, $params, 'C');
break;
default:
break;
}
}
}
示例14: admin_form
function admin_form(&$qa_content)
{
// Process form input
$ok = null;
if (qa_clicked('priv_save_settings')) {
$table_exists = qa_db_read_one_value(qa_db_query_sub("SHOW TABLES LIKE '^usermeta'"), true);
if (!$table_exists) {
qa_db_query_sub('CREATE TABLE IF NOT EXISTS ^usermeta (
meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
user_id bigint(20) unsigned NOT NULL,
meta_key varchar(255) DEFAULT NULL,
meta_value longtext,
PRIMARY KEY (meta_id),
UNIQUE (user_id,meta_key)
) ENGINE=MyISAM DEFAULT CHARSET=utf8');
}
// options
qa_opt('priv_active', (bool) qa_post_text('priv_active'));
qa_opt('priv_user_field', (bool) qa_post_text('priv_user_field'));
qa_opt('priv_title', qa_post_text('priv_title'));
qa_opt('priv_hover', qa_post_text('priv_hover'));
qa_opt('priv_shading', (int) qa_post_text('priv_shading'));
qa_opt('priv_hover_earned', qa_post_text('priv_hover_earned'));
qa_opt('priv_css', qa_post_text('priv_css'));
qa_opt('priv_check', (bool) qa_post_text('priv_check'));
qa_opt('priv_notify_text', qa_post_text('priv_notify_text'));
qa_opt('priv_notify_text_multi', qa_post_text('priv_notify_text_multi'));
qa_opt('priv_email_notify_on', (bool) qa_post_text('priv_email_notify_on'));
qa_opt('priv_email_subject', qa_post_text('priv_email_subject'));
qa_opt('priv_email_body', qa_post_text('priv_email_body'));
$ok = qa_lang_html('admin/options_saved');
}
// Create the form for display
$fields = array();
$fields[] = array('label' => 'Activate Privilege Management', 'tags' => 'NAME="priv_active"', 'value' => qa_opt('priv_active'), 'type' => 'checkbox');
$fields[] = array('label' => 'Show privileges in user profile', 'tags' => 'NAME="priv_user_field"', 'value' => qa_opt('priv_user_field'), 'type' => 'checkbox');
$shading = array('color', 'grey');
$fields[] = array('label' => 'Privilege shading style', 'tags' => 'NAME="priv_shading"', 'type' => 'select', 'options' => $shading, 'value' => @$shading[qa_opt('priv_shading')]);
$fields[] = array('label' => 'Title of user privilege box', 'tags' => 'NAME="priv_title"', 'value' => qa_opt('priv_title'));
$fields[] = array('label' => 'Hover text on unearned privilege name', 'note' => '# is replaced by required points, % by percentage user already has', 'tags' => 'NAME="priv_hover"', 'value' => qa_opt('priv_hover'));
$fields[] = array('label' => 'Hover text on earned privilege name', 'note' => '# is replaced by required points', 'tags' => 'NAME="priv_hover_earned"', 'value' => qa_opt('priv_hover_earned'));
$fields[] = array('type' => 'blank');
$fields[] = array('label' => 'enable new privilege notification popup', 'tags' => 'NAME="priv_check"', 'value' => (bool) qa_opt('priv_check'), 'type' => 'checkbox');
$fields[] = array('label' => 'privilege popup text (single privilege)', 'tags' => 'NAME="priv_notify_text"', 'value' => qa_html(qa_opt('priv_notify_text')), 'note' => 'substitutes ^profile for profile url, ^privilege for privilege name');
$fields[] = array('label' => 'privilege popup text (multiple privileges)', 'tags' => 'NAME="priv_notify_text_multi"', 'value' => qa_html(qa_opt('priv_notify_text_multi')), 'note' => 'substitutes ^profile for profile url, # for number of privileges');
$fields[] = array('label' => 'enable email notification', 'tags' => 'NAME="priv_email_notify_on"', 'value' => (bool) qa_opt('priv_email_notify_on'), 'type' => 'checkbox');
$fields[] = array('label' => 'email subject', 'tags' => 'NAME="priv_email_subject"', 'value' => qa_html(qa_opt('priv_email_subject')));
$fields[] = array('label' => 'email body', 'tags' => 'name="priv_email_body"', 'value' => qa_html(qa_opt('priv_email_body')), 'type' => 'textarea', 'rows' => 20, 'note' => 'Available replacement text:<br/><br/><i>^site_title<br/>^handle<br/>^email<br/>^open<br/>^close<br/>^profile_url<br/>^site_url<br/>^single=`text`^multi=`text`</i>');
return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => 'Save', 'tags' => 'NAME="priv_save_settings"')));
}
示例15: qa_theme_chooser
function qa_theme_chooser()
{
$userid = qa_get_logged_in_userid();
if (function_exists('qa_register_plugin_overrides')) {
// 1.5
return qa_db_read_one_value(qa_db_query_sub('SELECT meta_value FROM ^usermeta WHERE user_id=# AND meta_key=$', $userid, 'custom_theme'), true);
}
require_once QA_INCLUDE_DIR . 'qa-app-users.php';
if (!$userid) {
$theme = @$_COOKIE['qa_theme_switch'];
if (qa_opt('theme_switch_enable_mobile')) {
$theme_choice_mobile = qa_theme_chooser_detect_mobile() ? qa_opt('theme_switch_mobile') : false;
}
if ($theme) {
global $qa_theme_switch_is_mobile;
$qa_theme_switch_is_mobile = $theme_choice_mobile;
// it's mobile, but they have a preferred theme
return $theme;
}
return $theme_choice_mobile;
}
if (qa_opt('theme_switch_enable_mobile')) {
$theme_choice_mobile = @$_COOKIE['qa_theme_switch'] == qa_opt('theme_switch_mobile') ? qa_opt('theme_switch_mobile') : false;
$theme_mobile = qa_theme_chooser_detect_mobile() ? qa_opt('theme_switch_mobile') : false;
global $qa_theme_switch_is_mobile;
$qa_theme_switch_is_mobile = $theme_mobile;
// it's mobile, but they have a preferred theme
if ($theme_choice && (!$theme_choice_mobile || !$theme_mobile)) {
// have theme choice, and 1) it's not mobile, 2) it's mobile and they don't have a cookie, 3) they have a cookie but it's not mobile, 4) they have a cookie, it's mobile, but the cookie isn't mobile
// do nothing
} else {
if (!$theme_choice_mobile && $theme_mobile) {
// no cookie, is mobile, give mobile
return $theme_mobile;
} else {
if ($theme_choice_mobile && $theme_mobile) {
// cookie, is mobile, give cookie
return $theme_choice_mobile;
}
}
}
}
if ($theme_choice) {
global $qa_theme_switch_is_mobile;
return $theme_choice;
}
return $theme_choice_mobile;
}