当前位置: 首页>>代码示例>>PHP>>正文


PHP qa_get_options函数代码示例

本文整理汇总了PHP中qa_get_options函数的典型用法代码示例。如果您正苦于以下问题:PHP qa_get_options函数的具体用法?PHP qa_get_options怎么用?PHP qa_get_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了qa_get_options函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: qa_question_validate

function qa_question_validate($title, $content, $format, $text, $tagstring, $notify, $email)
{
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    $options = qa_get_options(array('min_len_q_title', 'max_len_q_title', 'min_len_q_content', 'min_num_q_tags', 'max_num_q_tags'));
    $errors = array();
    $maxtitlelength = max($options['min_len_q_title'], min($options['max_len_q_title'], QA_DB_MAX_TITLE_LENGTH));
    qa_length_validate($errors, 'title', $title, $options['min_len_q_title'], $maxtitlelength);
    qa_length_validate($errors, 'content', $content, 0, QA_DB_MAX_CONTENT_LENGTH);
    // for storage
    qa_length_validate($errors, 'content', $text, $options['min_len_q_content'], null);
    // for display
    if (isset($tagstring)) {
        $counttags = count(qa_tagstring_to_tags($tagstring));
        $mintags = min($options['min_num_q_tags'], $options['max_num_q_tags']);
        // to deal with silly settings
        if ($counttags < $mintags) {
            $errors['tags'] = qa_lang_sub('question/min_tags_x', $mintags);
        } elseif ($counttags > $options['max_num_q_tags']) {
            $errors['tags'] = qa_lang_sub('question/max_tags_x', $options['max_num_q_tags']);
        } else {
            qa_length_validate($errors, 'tags', $tagstring, 0, QA_DB_MAX_TAGS_LENGTH);
        }
    }
    qa_notify_validate($errors, $notify, $email);
    return $errors;
}
开发者ID:TheProjecter,项目名称:microprobe,代码行数:26,代码来源:qa-app-post-create.php

示例2: qa_db_points_calculations

function qa_db_points_calculations()
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    require_once QA_INCLUDE_DIR . 'app/options.php';
    $options = qa_get_options(qa_db_points_option_names());
    return array('qposts' => array('multiple' => $options['points_multiple'] * $options['points_post_q'], 'formula' => "COUNT(*) AS qposts FROM ^posts AS userid_src WHERE userid~ AND type='Q'"), 'aposts' => array('multiple' => $options['points_multiple'] * $options['points_post_a'], 'formula' => "COUNT(*) AS aposts FROM ^posts AS userid_src WHERE userid~ AND type='A'"), 'cposts' => array('multiple' => 0, 'formula' => "COUNT(*) AS cposts FROM ^posts AS userid_src WHERE userid~ AND type='C'"), 'aselects' => array('multiple' => $options['points_multiple'] * $options['points_select_a'], 'formula' => "COUNT(*) AS aselects FROM ^posts AS userid_src WHERE userid~ AND type='Q' AND selchildid IS NOT NULL"), 'aselecteds' => array('multiple' => $options['points_multiple'] * $options['points_a_selected'], 'formula' => "COUNT(*) AS aselecteds FROM ^posts AS userid_src JOIN ^posts AS questions ON questions.selchildid=userid_src.postid WHERE userid_src.userid~ AND userid_src.type='A' AND NOT (questions.userid<=>userid_src.userid)"), 'qupvotes' => array('multiple' => $options['points_multiple'] * $options['points_vote_up_q'], 'formula' => "COUNT(*) AS qupvotes FROM ^uservotes AS userid_src JOIN ^posts ON userid_src.postid=^posts.postid WHERE userid_src.userid~ AND LEFT(^posts.type, 1)='Q' AND userid_src.vote>0"), 'qdownvotes' => array('multiple' => $options['points_multiple'] * $options['points_vote_down_q'], 'formula' => "COUNT(*) AS qdownvotes FROM ^uservotes AS userid_src JOIN ^posts ON userid_src.postid=^posts.postid WHERE userid_src.userid~ AND LEFT(^posts.type, 1)='Q' AND userid_src.vote<0"), 'aupvotes' => array('multiple' => $options['points_multiple'] * $options['points_vote_up_a'], 'formula' => "COUNT(*) AS aupvotes FROM ^uservotes AS userid_src JOIN ^posts ON userid_src.postid=^posts.postid WHERE userid_src.userid~ AND LEFT(^posts.type, 1)='A' AND userid_src.vote>0"), 'adownvotes' => array('multiple' => $options['points_multiple'] * $options['points_vote_down_a'], 'formula' => "COUNT(*) AS adownvotes FROM ^uservotes AS userid_src JOIN ^posts ON userid_src.postid=^posts.postid WHERE userid_src.userid~ AND LEFT(^posts.type, 1)='A' AND userid_src.vote<0"), 'qvoteds' => array('multiple' => $options['points_multiple'], 'formula' => "COALESCE(SUM(" . "LEAST(" . (int) $options['points_per_q_voted_up'] . "*upvotes," . (int) $options['points_q_voted_max_gain'] . ")" . "-" . "LEAST(" . (int) $options['points_per_q_voted_down'] . "*downvotes," . (int) $options['points_q_voted_max_loss'] . ")" . "), 0) AS qvoteds FROM ^posts AS userid_src WHERE LEFT(type, 1)='Q' AND userid~"), 'avoteds' => array('multiple' => $options['points_multiple'], 'formula' => "COALESCE(SUM(" . "LEAST(" . (int) $options['points_per_a_voted_up'] . "*upvotes," . (int) $options['points_a_voted_max_gain'] . ")" . "-" . "LEAST(" . (int) $options['points_per_a_voted_down'] . "*downvotes," . (int) $options['points_a_voted_max_loss'] . ")" . "), 0) AS avoteds FROM ^posts AS userid_src WHERE LEFT(type, 1)='A' AND userid~"), 'upvoteds' => array('multiple' => 0, 'formula' => "COALESCE(SUM(upvotes), 0) AS upvoteds FROM ^posts AS userid_src WHERE userid~"), 'downvoteds' => array('multiple' => 0, 'formula' => "COALESCE(SUM(downvotes), 0) AS downvoteds FROM ^posts AS userid_src WHERE userid~"));
}
开发者ID:kosmoluna,项目名称:question2answer,代码行数:10,代码来源:points.php

示例3: output_widget

 function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     $widget_opt = qa_get_options(array(q2a_breadcrumbs_admin::SHOW_HOME, q2a_breadcrumbs_admin::TRUNCATE_LENGTH));
     // breadcrumb start
     $themeobject->output('<ul class="breadcrumb clearfix">');
     if ($widget_opt[q2a_breadcrumbs_admin::SHOW_HOME]) {
         $themeobject->output($this->breadcrumb_part(array('type' => 'home')));
     }
     $themeobject->output($this->create_breadcrumbs($this->navigation(), $qa_content, $widget_opt, $template));
     $themeobject->output('</ul>');
 }
开发者ID:Alvarofg,项目名称:q2a-breadcrumbs,代码行数:11,代码来源:qa-breadcrumbs-widget.php

示例4: output_widget

 function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     require_once AMI_FB_LIKE_BOX_DIR . '/qa-facebook-like-box-admin.php';
     $has_error = false;
     $error_message = "";
     $widget_opt = qa_get_options(array('facebook_app_id', qa_facebook_like_box_admin::SHOW_FB_LIKE_BOX, qa_facebook_like_box_admin::SHOW_FB_LIKE_MODAL, qa_facebook_like_box_admin::FACEBOOK_PAGE_URL, qa_facebook_like_box_admin::LIKE_BOX_COLOR_SCHEME, qa_facebook_like_box_admin::LIKE_BOX_SHOW_HEADER, qa_facebook_like_box_admin::LIKE_BOX_SHOW_BORDER, qa_facebook_like_box_admin::LIKE_BOX_SHOW_FACES, qa_facebook_like_box_admin::LIKE_BOX_SHOW_DATA_STREAM, qa_facebook_like_box_admin::LIKE_BOX_HEIGHT, qa_facebook_like_box_admin::LIKE_BOX_WIDTH, qa_facebook_like_box_admin::MODAL_USE_CSS_FROM_THEME, qa_facebook_like_box_admin::MODAL_COLOR_SCHEME, qa_facebook_like_box_admin::MODAL_SHOW_HEADER, qa_facebook_like_box_admin::MODAL_SHOW_BORDER, qa_facebook_like_box_admin::MODAL_SHOW_FACES, qa_facebook_like_box_admin::MODAL_SHOW_DATA_STREAM, qa_facebook_like_box_admin::MODAL_HEIGHT, qa_facebook_like_box_admin::MODAL_WIDTH, qa_facebook_like_box_admin::MODAL_COOKIE_EXPIRE, qa_facebook_like_box_admin::MODAL_HEADER_MAIN_TEXT, qa_facebook_like_box_admin::MODAL_DISPLAY_EVERY_TIME, qa_facebook_like_box_admin::MODAL_FOOTER_TEXT, qa_facebook_like_box_admin::MODAL_COSTUM_CSS));
     $fb_page_url = $this->get_fb_settings($widget_opt, 'url');
     $show_fb_like_box = $this->get_fb_settings($widget_opt, 'show_fb_like_box');
     $show_fb_like_box_modal = $this->get_fb_settings($widget_opt, 'show_fb_like_modal');
     if (empty($fb_page_url)) {
         $has_error = true;
         $error_message = qa_lang('flb_like_box/plz_provide_fb_url');
     }
     if (!$has_error) {
         if ($show_fb_like_box) {
             $themeobject->output($this->get_facebook_like_box($widget_opt));
         }
         if ($show_fb_like_box_modal) {
             $themeobject->output($this->get_facebook_like_modal($widget_opt));
         }
     } else {
         $themeobject->output('<div class="qa-sidebar error" style="color:red;">' . $error_message . '</div>');
     }
 }
开发者ID:Amirdzvb,项目名称:q2a-facebook-like-box,代码行数:24,代码来源:qa-facebook-like-box.php

示例5: header

    header('Content-Type: image/jpeg');
    echo $content;
} else {
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    require_once QA_INCLUDE_DIR . 'qa-app-blobs.php';
    require_once QA_INCLUDE_DIR . 'qa-util-image.php';
    //	Otherwise retrieve the raw image and scale as appropriate
    $blob = qa_read_blob($blobid);
    if (isset($blob)) {
        if ($size > 0) {
            $content = qa_image_constrain_data($blob['content'], $width, $height, $size);
        } else {
            $content = $blob['content'];
        }
        if (isset($content)) {
            header('Content-Type: image/jpeg');
            echo $content;
            if (strlen($content) && $size > 0) {
                $cachesizes = qa_get_options(array('avatar_profile_size', 'avatar_users_size', 'avatar_q_page_q_size', 'avatar_q_page_a_size', 'avatar_q_page_c_size', 'avatar_q_list_size'));
                // to prevent cache being filled with inappropriate sizes
                if (array_search($size, $cachesizes)) {
                    qa_db_cache_set($cachetype, $blobid, $content);
                }
            }
        }
    }
}
qa_db_disconnect();
/*
	Omit PHP closing tag to help avoid accidental output
*/
开发者ID:gogupe,项目名称:question2answer-releases,代码行数:31,代码来源:qa-image.php

示例6: qa_opt

function qa_opt($name, $value = null)
{
    global $qa_options_cache;
    if (!isset($value) && isset($qa_options_cache[$name])) {
        return $qa_options_cache[$name];
    }
    // quick shortcut to reduce calls to qa_get_options()
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    if (isset($value)) {
        qa_set_option($name, $value);
    }
    $options = qa_get_options(array($name));
    return $options[$name];
}
开发者ID:netham91,项目名称:question2answer,代码行数:14,代码来源:qa-base.php

示例7: qa_mailing_stop

            }
            if (qa_clicked('domailingcancel')) {
                qa_mailing_stop();
            }
        }
    }
    $mailingprogress = qa_mailing_progress_message();
    if (isset($mailingprogress)) {
        $formokhtml = qa_html($mailingprogress);
        $checkboxtodisplay = array('mailing_enabled' => '0');
    } else {
        $checkboxtodisplay = array('mailing_from_name' => 'option_mailing_enabled', 'mailing_from_email' => 'option_mailing_enabled', 'mailing_subject' => 'option_mailing_enabled', 'mailing_body' => 'option_mailing_enabled', 'mailing_per_minute' => 'option_mailing_enabled', 'domailingtest' => 'option_mailing_enabled', 'domailingstart' => 'option_mailing_enabled');
    }
}
//	Get the actual options
$options = qa_get_options($getoptions);
//	Prepare content for theme
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html($subtitle);
$qa_content['error'] = $securityexpired ? qa_lang_html('admin/form_security_expired') : qa_admin_page_error();
$qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
$qa_content['form'] = array('ok' => $formokhtml, 'tags' => 'method="post" action="' . qa_self_html() . '" name="admin_form" onsubmit="document.forms.admin_form.has_js.value=1; return true;"', 'style' => $formstyle, 'fields' => array(), 'buttons' => array('save' => array('tags' => 'id="dosaveoptions"', 'label' => qa_lang_html('admin/save_options_button')), 'reset' => array('tags' => 'name="doresetoptions"', 'label' => qa_lang_html('admin/reset_options_button'))), 'hidden' => array('dosaveoptions' => '1', 'has_js' => '0', 'code' => qa_get_form_security_code('admin/' . $adminsection)));
if ($recalchotness) {
    $qa_content['form']['ok'] = '<span id="recalc_ok"></span>';
    $qa_content['form']['hidden']['code_recalc'] = qa_get_form_security_code('admin/recalc');
    $qa_content['script_var']['qa_warning_recalc'] = qa_lang('admin/stop_recalc_warning');
    $qa_content['script_onloads'][] = array("qa_recalc_click('dorecountposts', document.getElementById('dosaveoptions'), null, 'recalc_ok');");
} elseif ($startmailing) {
    if (qa_post_text('has_js')) {
        $qa_content['form']['ok'] = '<span id="mailing_ok">' . qa_html($mailingprogress) . '</span>';
        $qa_content['script_onloads'][] = array("qa_mailing_start('mailing_ok', 'domailingpause');");
开发者ID:mostafiz93,项目名称:PrintfScanf,代码行数:31,代码来源:qa-page-admin-default.php

示例8: filter_subs

    function filter_subs($text)
    {
        // text subs
        $subs = array('site_title' => qa_opt('site_title'), 'site_url' => qa_opt('site_url'));
        foreach ($subs as $i => $v) {
            $text = str_replace('^' . $i, $v, $text);
        }
        // function subs
        preg_match_all('/\\^qa_path\\(([^)]+)\\)/', $text, $qa_path, PREG_SET_ORDER);
        foreach ($qa_path as $match) {
            $text = str_replace($match[0], qa_path($match[1]), $text);
        }
        preg_match_all('/\\^qa_opt\\(([^)]+)\\)/', $text, $qa_opt, PREG_SET_ORDER);
        foreach ($qa_opt as $match) {
            // backwards compat
            if (in_array($match[1], array('points_per_q_voted_up', 'points_per_q_voted_down')) && !qa_opt('points_per_q_voted_up')) {
                $match[1] = 'points_per_q_voted';
            } else {
                if (in_array($match[1], array('points_per_a_voted_up', 'points_per_a_voted_down')) && !qa_opt('points_per_a_voted_up')) {
                    $match[1] = 'points_per_a_voted';
                }
            }
            $text = str_replace($match[0], qa_opt($match[1]), $text);
        }
        // if subs
        if (qa_get_logged_in_userid()) {
            $text = preg_replace('/\\^if_logged_in=`([^`]+)`/', '$1', $text);
            $text = preg_replace('/\\^if_not_logged_in=`[^`]+`/', '', $text);
            $handle = qa_get_logged_in_handle();
            $subs = array('profile_url' => qa_path('user/' . $handle), 'handle' => $handle);
            foreach ($subs as $i => $v) {
                $text = str_replace('^' . $i, $v, $text);
            }
        } else {
            global $qa_root_url_relative;
            $userlinks = qa_get_login_links($qa_root_url_relative, null);
            $subs = array('login' => $userlinks['login'], 'register' => $userlinks['register']);
            foreach ($subs as $i => $v) {
                $text = str_replace('^' . $i, $v, $text);
            }
            $text = preg_replace('/\\^if_not_logged_in=`([^`]+)`/', '$1', $text);
            $text = preg_replace('/\\^if_logged_in=`[^`]+`/', '', $text);
        }
        // table subs
        if (strpos($text, '^pointstable') !== false) {
            require_once QA_INCLUDE_DIR . 'qa-db-points.php';
            $optionnames = qa_db_points_option_names();
            $options = qa_get_options($optionnames);
            $table = '
<table class="qa-form-wide-table">
	<tbody>';
            $multi = (int) $options['points_multiple'];
            foreach ($optionnames as $optionname) {
                switch ($optionname) {
                    case 'points_multiple':
                        continue 2;
                    case 'points_per_q_voted_up':
                    case 'points_per_a_voted_up':
                        $prefix = '+';
                        break;
                    case 'points_per_q_voted_down':
                    case 'points_per_a_voted_down':
                        $prefix = '-';
                        break;
                    case 'points_per_q_voted':
                    case 'points_per_a_voted':
                        $prefix = '&#177;';
                        break;
                    case 'points_q_voted_max_gain':
                    case 'points_a_voted_max_gain':
                        $prefix = '+';
                        break;
                    case 'points_q_voted_max_loss':
                    case 'points_a_voted_max_loss':
                        $prefix = '&ndash;';
                        break;
                    case 'points_base':
                        $prefix = '+';
                        break;
                    default:
                        $prefix = '<SPAN STYLE="visibility:hidden;">+</SPAN>';
                        // for even alignment
                        break;
                }
                $points = $optionname != 'points_base' ? (int) $options[$optionname] * $multi : (int) $options[$optionname];
                if ($points != 0 && $points != -10000 && $points != 10000 && strpos($optionname, 'max') === false) {
                    $table .= '
		<tr>
			<td class="qa-form-wide-label">
				' . qa_lang_html('options/' . $optionname) . '
			</td>
			<td class="qa-form-wide-data" style="text-align:right">
				<span class="qa-form-wide-prefix"><span style="width: 1em; display: -moz-inline-stack;">' . $prefix . '</span></span>
				' . qa_html($points) . ($optionname == 'points_multiple' ? '' : '
				<span class="qa-form-wide-note">' . qa_lang_html('admin/points') . '</span>') . '
			</td>
		</tr>';
                }
            }
            $table .= '
//.........这里部分代码省略.........
开发者ID:ruuttt,项目名称:question2answer_sandbox,代码行数:101,代码来源:qa-faq-page.php

示例9: ra_opt

function ra_opt($name, $value = null)
{
    /*
    	Shortcut to get or set an option value without specifying database
    */
    global $qa_options_cache;
    if (!isset($value) && isset($qa_options_cache[$name])) {
        if (ra_is_serialized($qa_options_cache[$name])) {
            return unserialize($qa_options_cache[$name]);
        }
        return $qa_options_cache[$name];
        // quick shortcut to reduce calls to qa_get_options()
    }
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    if (isset($value)) {
        if (is_array($value)) {
            $value = serialize($value);
        }
        qa_set_option($name, $value);
    }
    $options = qa_get_options(array($name));
    if (ra_is_serialized($options[$name])) {
        return unserialize($options[$name]);
    }
    return $options[$name];
}
开发者ID:rahularyan,项目名称:dude-theme,代码行数:26,代码来源:qa-plugin.php

示例10: user_activity_form

    function user_activity_form()
    {
        $handle = $this->_user_handle();
        if (!$handle) {
            return;
        }
        $userid = $this->getuserfromhandle($handle);
        if (!$userid) {
            return;
        }
        // update last visit
        if ($userid == qa_get_logged_in_userid() && qa_opt('user_act_list_new')) {
            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');
            $last_visit = qa_db_read_one_value(qa_db_query_sub('SELECT UNIX_TIMESTAMP(meta_value) FROM ^usermeta WHERE user_id=# AND meta_key=$', qa_get_logged_in_userid(), 'visited_profile'), true);
            qa_db_query_sub('INSERT INTO ^usermeta (user_id,meta_key,meta_value) VALUES(#,$,NOW()) ON DUPLICATE KEY UPDATE meta_value=NOW()', $userid, 'visited_profile');
        } else {
            $last_visit = time();
        }
        $event_query = qa_db_query_sub("SELECT \n\t\t\t\te.event, \n\t\t\t\tBINARY e.params as params, \n\t\t\t\tUNIX_TIMESTAMP(e.datetime) AS datetime\n\t\t\tFROM \n\t\t\t\t^eventlog AS e\n\t\t\tWHERE\n\t\t\t\te.userid=#\n\t\t\t\tAND\n\t\t\t\tDATE_SUB(CURDATE(),INTERVAL # DAY) <= datetime\n\t\t\tORDER BY datetime DESC" . (qa_opt('user_act_list_max') ? " LIMIT " . (int) qa_opt('user_act_list_max') : ""), $userid, qa_opt('user_act_list_age'));
        // no post
        $nopost = array('u_password', 'u_reset', 'u_save', 'u_confirmed', 'u_edit', 'u_level', 'u_block', 'u_unblock', 'u_register', 'in_u_edit', 'in_u_level', 'in_u_block', 'in_u_unblock', 'feedback', 'search');
        // points
        require_once QA_INCLUDE_DIR . 'qa-db-points.php';
        $optionnames = qa_db_points_option_names();
        $options = qa_get_options($optionnames);
        $multi = (int) $options['points_multiple'];
        // compat fudge
        $upvote = '';
        $downvote = '';
        if (@$options['points_per_q_voted_up']) {
            $upvote = '_up';
            $downvote = '_down';
        }
        $option_events['in_q_vote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi;
        $option_events['in_q_vote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi * -1;
        $option_events['in_q_unvote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi * -1;
        $option_events['in_q_unvote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi;
        $option_events['in_a_vote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi;
        $option_events['in_a_vote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi * -1;
        $option_events['in_a_unvote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi * -1;
        $option_events['in_a_unvote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi;
        $option_events['in_a_select'] = (int) $options['points_a_selected'] * $multi;
        $option_events['in_a_unselect'] = (int) $options['points_a_selected'] * $multi * -1;
        $option_events['q_post'] = (int) $options['points_post_q'] * $multi;
        $option_events['a_post'] = (int) $options['points_post_a'] * $multi;
        $option_events['a_select'] = (int) $options['points_select_a'] * $multi;
        $option_events['q_vote_up'] = (int) $options['points_vote_up_q'] * $multi;
        $option_events['q_vote_down'] = (int) $options['points_vote_down_q'] * $multi;
        $option_events['a_vote_up'] = (int) $options['points_vote_up_a'] * $multi;
        $option_events['a_vote_down'] = (int) $options['points_vote_down_a'] * $multi;
        $fields = array();
        $events = array();
        $postids = array();
        $count = 0;
        while (($event = qa_db_read_one_assoc($event_query, true)) !== null) {
            if (preg_match('/postid=([0-9]+)/', $event['params'], $m) === 1) {
                $event['postid'] = (int) $m[1];
                $postids[] = (int) $m[1];
                $events[$m[1] . '_' . $count++] = $event;
            } else {
                $events['nopost_' . $count++] = $event;
            }
        }
        // get post info, also makes sure post exists
        $posts = null;
        if (!empty($postids)) {
            $post_query = qa_db_read_all_assoc(qa_db_query_sub('SELECT postid, type, parentid, BINARY title as title FROM ^posts WHERE postid IN (' . implode(',', $postids) . ')'));
            foreach ($post_query as $post) {
                $posts[(string) $post['postid']] = $post;
            }
        }
        foreach ($events as $postid_string => $event) {
            $type = $event['event'];
            $postid = preg_replace('/_.*/', '', $postid_string);
            $post = null;
            $post = @$posts[$postid];
            // these calls allow you to deal with deleted events;
            // uncomment the first one to skip them
            // uncomment the second one to build your own routine based on whether they are deleted.
            if (!in_array($type, $nopost) && $post == null) {
                continue;
            }
            // $deleted = (!in_array($type, $nopost) && $post == null);
            // hide / show exceptions
            if (qa_get_logged_in_level() < QA_USER_LEVEL_ADMIN) {
                if ($userid != qa_get_logged_in_userid()) {
                    // show public
                    $types = explode("\n", qa_opt('user_act_list_show'));
                    if (!in_array($type, $types)) {
                        continue;
                    }
                } else {
                    // hide from owner
//.........这里部分代码省略.........
开发者ID:ruuttt,项目名称:question2answer_sandbox,代码行数:101,代码来源:qa-history-layer.php

示例11: privilege_check

 function privilege_check($event, $userid, $params)
 {
     // points
     require_once QA_INCLUDE_DIR . 'qa-db-points.php';
     $optionnames = qa_db_points_option_names();
     $options = qa_get_options($optionnames);
     $multi = (int) $options['points_multiple'];
     switch ($event) {
         case 'q_post':
             $event_points = (int) $options['points_post_q'] * $multi;
             break;
         case 'a_post':
             $event_points = (int) $options['points_post_a'] * $multi;
             break;
         case 'a_select':
             $event_points = (int) $options['points_select_a'] * $multi;
             break;
         case 'q_vote_up':
             $event_points = (int) $options['points_vote_up_q'] * $multi;
             break;
         case 'a_vote_up':
             $event_points = (int) $options['points_vote_up_a'] * $multi;
             break;
         default:
             return;
     }
     $this->check_privileges($userid, $event_points);
     // other user
     if (in_array($event, array('a_select', 'q_vote_up', 'a_vote_up'))) {
         $uid2 = qa_db_read_one_value(qa_db_query_sub('SELECT userid FROM ^posts WHERE postid=#', $params['postid']), true);
         if ($uid2 && $uid2 != $userid) {
             if (isset($options['points_per_q_voted'])) {
                 // 1.4
                 switch ($event) {
                     case 'a_select':
                         $event_points = (int) $options['points_a_selected'] * $multi;
                         break;
                     case 'q_vote_up':
                         $event_points = (int) $params['vote'] <= (int) $options['points_q_voted_max_gain'] / (int) $options['points_per_q_voted'] ? (int) $options['points_per_q_voted'] * $multi : (int) $options['points_q_voted_max_gain'];
                         break;
                     case 'a_vote_up':
                         $event_points = (int) $params['vote'] <= (int) $options['points_a_voted_max_gain'] / (int) $options['points_per_a_voted'] ? (int) $options['points_per_a_voted'] * $multi : (int) $options['points_a_voted_max_gain'];
                         break;
                     default:
                         return;
                 }
             } else {
                 // 1.5
                 switch ($event) {
                     case 'a_select':
                         $event_points = (int) $options['points_a_selected'] * $multi;
                         break;
                     case 'q_vote_up':
                         $event_points = (int) $params['vote'] <= (int) $options['points_q_voted_max_gain'] / (int) $options['points_per_q_voted_up'] ? (int) $options['points_per_q_voted'] * $multi : (int) $options['points_q_voted_max_gain'];
                         break;
                     case 'a_vote_up':
                         $event_points = (int) $params['vote'] <= (int) $options['points_a_voted_max_gain'] / (int) $options['points_per_a_voted_up'] ? (int) $options['points_per_a_voted'] * $multi : (int) $options['points_a_voted_max_gain'];
                         break;
                     default:
                         return;
                 }
             }
             $this->check_privileges($uid2, $event_points);
         }
     }
 }
开发者ID:ruuttt,项目名称:question2answer_sandbox,代码行数:66,代码来源:qa-priv-check.php

示例12: qa_opt

function qa_opt($name, $value = null)
{
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    if (isset($value)) {
        qa_set_option($name, $value);
    }
    $options = qa_get_options(array($name));
    return $options[$name];
}
开发者ID:TheProjecter,项目名称:microprobe,代码行数:9,代码来源:qa-base.php

示例13: activitylist

    function activitylist()
    {
        // get points for each activity
        require_once QA_INCLUDE_DIR . 'qa-db-points.php';
        require_once QA_INCLUDE_DIR . 'qa-db-users.php';
        $optionnames = qa_db_points_option_names();
        $options = qa_get_options($optionnames);
        $multi = (int) $options['points_multiple'];
        $upvote = '';
        $downvote = '';
        if (@$options['points_per_q_voted_up']) {
            $upvote = '_up';
            $downvote = '_down';
        }
        $event_point['in_q_vote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi;
        $event_point['in_q_vote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi * -1;
        $event_point['in_q_unvote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi * -1;
        $event_point['in_q_unvote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi;
        $event_point['in_a_vote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi;
        $event_point['in_a_vote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi * -1;
        $event_point['in_a_unvote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi * -1;
        $event_point['in_a_unvote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi;
        $event_point['in_a_select'] = (int) $options['points_a_selected'] * $multi;
        $event_point['in_a_unselect'] = (int) $options['points_a_selected'] * $multi * -1;
        $event_point['q_post'] = (int) $options['points_post_q'] * $multi;
        $event_point['a_post'] = (int) $options['points_post_a'] * $multi;
        $event_point['a_select'] = (int) $options['points_select_a'] * $multi;
        $event_point['q_vote_up'] = (int) $options['points_vote_up_q'] * $multi;
        $event_point['q_vote_down'] = (int) $options['points_vote_down_q'] * $multi;
        $event_point['a_vote_up'] = (int) $options['points_vote_up_a'] * $multi;
        $event_point['a_vote_down'] = (int) $options['points_vote_down_a'] * $multi;
        /*
        // Exclude Activities
        $exclude = array(
        	'u_login',
        	'u_logout',
        	'u_password',
        	'u_reset',
        	'u_save',
        	'u_edit',
        	'u_block',
        	'u_unblock',
        	'feedback',
        	'search',
        	'badge_awarded',
        );
        $excludes = "'".implode("','",$exclude)."'";
        $eventslist = qa_db_read_all_assoc(
        	qa_db_query_sub( 
        		'SELECT UNIX_TIMESTAMP(datetime) AS datetime, userid, postid, effecteduserid, event, params FROM ^userlog WHERE userid=# AND 
        		DATE_SUB(CURDATE(),INTERVAL # DAY) <= datetime
        		AND event NOT IN (' . $excludes .') ORDER BY datetime DESC'.(qa_opt('qat_activity_number')?' LIMIT '.(int)qa_opt('qat_activity_number'):''),
        		$userid, qa_opt('qat_activity_age')
        	)
        );
        */
        // Get Events
        $userid = qa_get_logged_in_userid();
        $eventslist = qa_db_read_all_assoc(qa_db_query_sub('SELECT UNIX_TIMESTAMP(datetime) AS datetime, userid, postid, effecteduserid, event, params FROM ^userlog WHERE effecteduserid=# AND 
				DATE_SUB(CURDATE(),INTERVAL # DAY) <= datetime
				ORDER BY datetime DESC' . (qa_opt('qat_activity_number') ? ' LIMIT ' . (int) qa_opt('qat_activity_number') : ''), $userid, qa_opt('qat_activity_age')));
        $event = array();
        $output = '';
        $i = 0;
        //
        $userids = array();
        foreach ($eventslist as $event) {
            $userids[$event['userid']] = $event['userid'];
            $userids[$event['effecteduserid']] = $event['effecteduserid'];
        }
        $handles = qa_db_user_get_userid_handles($userids);
        // get event's: time, type, parameters
        // get post id of questions
        foreach ($eventslist as $event) {
            $title = '';
            $link = '';
            $vote_status = '';
            $handle = $handles[$event['userid']];
            $user_link = qa_path('user/' . $handle);
            $datetime = $event['datetime'];
            $event['date'] = qa_html(qa_time_to_string(qa_opt('db_time') - $datetime));
            $event['params'] = json_decode($event['params'], true);
            $output .= '<li>';
            switch ($event['event']) {
                case 'related':
                    // related question to an answer
                    $url = qa_path_html(qa_q_request($event['postid'], $event['params']['title']), null, qa_opt('site_url'), null, null);
                    $output .= '<div class="event-icon pull-left icon-chat"></div>
								<div class="event-content">
									<p class="title"><strong class="avatar"><a href="' . $user_link . '">' . $handle . '</a></strong>
									<span class="what">Asked a question related to your answer</span>
									</p>
									<a class="title" href="' . $url . '">' . $event['params']['title'] . '</a>
									<span class="date"> ' . $event['date'] . '</span>
								</div>';
                    break;
                case 'a_post':
                    // user's question had been answered
                    $anchor = qa_anchor('A', $event['postid']);
                    $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), null, qa_opt('site_url'), null, $anchor);
//.........这里部分代码省略.........
开发者ID:swuit,项目名称:swuit-q2a,代码行数:101,代码来源:qa-layer-ajax.php

示例14: qa_create_new_user

function qa_create_new_user($email, $password, $handle, $level = QA_USER_LEVEL_BASIC, $confirmed = false)
{
    require_once QA_INCLUDE_DIR . 'qa-db-users.php';
    require_once QA_INCLUDE_DIR . 'qa-db-points.php';
    require_once QA_INCLUDE_DIR . 'qa-app-options.php';
    require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
    require_once QA_INCLUDE_DIR . 'qa-app-cookies.php';
    $userid = qa_db_user_create($email, $password, $handle, $level, qa_remote_ip_address());
    qa_db_points_update_ifuser($userid, null);
    if ($confirmed) {
        qa_db_user_set_flag($userid, QA_USER_FLAGS_EMAIL_CONFIRMED, true);
    }
    $options = qa_get_options(array('custom_welcome', 'site_url', 'confirm_user_emails'));
    $custom = trim($options['custom_welcome']);
    if ($options['confirm_user_emails'] && $level < QA_USER_LEVEL_EXPERT && !$confirmed) {
        $confirm = strtr(qa_lang('emails/welcome_confirm'), array('^url' => qa_get_new_confirm_url($userid, $handle)));
    } else {
        $confirm = '';
    }
    qa_send_notification($userid, $email, $handle, qa_lang('emails/welcome_subject'), qa_lang('emails/welcome_body'), array('^password' => isset($password) ? $password : qa_lang('users/password_to_set'), '^url' => $options['site_url'], '^custom' => empty($custom) ? '' : $custom . "\n\n", '^confirm' => $confirm));
    qa_report_event('u_register', $userid, $handle, qa_cookie_get(), array('email' => $email, 'level' => $level));
    return $userid;
}
开发者ID:TheProjecter,项目名称:microprobe,代码行数:23,代码来源:qa-app-users-edit.php

示例15: activitylist

    public function activitylist()
    {
        $offset = (int) qa_get('offset');
        $offset = isset($offset) ? $offset * 15 : 0;
        // get points for each activity
        require_once QA_INCLUDE_DIR . 'qa-db-points.php';
        require_once QA_INCLUDE_DIR . 'qa-db-users.php';
        $optionnames = qa_db_points_option_names();
        $options = qa_get_options($optionnames);
        $multi = (int) $options['points_multiple'];
        $upvote = '';
        $downvote = '';
        if (@$options['points_per_q_voted_up']) {
            $upvote = '_up';
            $downvote = '_down';
        }
        $event_point['in_q_vote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi;
        $event_point['in_q_vote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi * -1;
        $event_point['in_q_unvote_up'] = (int) $options['points_per_q_voted' . $upvote] * $multi * -1;
        $event_point['in_q_unvote_down'] = (int) $options['points_per_q_voted' . $downvote] * $multi;
        $event_point['a_vote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi;
        $event_point['in_a_vote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi * -1;
        $event_point['in_a_unvote_up'] = (int) $options['points_per_a_voted' . $upvote] * $multi * -1;
        $event_point['in_a_unvote_down'] = (int) $options['points_per_a_voted' . $downvote] * $multi;
        $event_point['in_a_select'] = (int) $options['points_a_selected'] * $multi;
        $event_point['in_a_unselect'] = (int) $options['points_a_selected'] * $multi * -1;
        $event_point['q_post'] = (int) $options['points_post_q'] * $multi;
        $event_point['a_post'] = (int) $options['points_post_a'] * $multi;
        $event_point['a_select'] = (int) $options['points_select_a'] * $multi;
        $event_point['q_vote_up'] = (int) $options['points_vote_up_q'] * $multi;
        $event_point['q_vote_down'] = (int) $options['points_vote_down_q'] * $multi;
        $event_point['a_vote_up'] = (int) $options['points_vote_up_a'] * $multi;
        $event_point['a_vote_down'] = (int) $options['points_vote_down_a'] * $multi;
        // Get Events
        $userid = qa_get_logged_in_userid();
        $eventslist = qa_db_read_all_assoc(qa_db_query_sub('SELECT id, UNIX_TIMESTAMP(datetime) AS datetime, userid, postid, effecteduserid, event, params, `read` FROM ^ra_userevent WHERE effecteduserid=# AND `read`=0 AND event NOT IN ("u_wall_post", "u_message") ORDER BY datetime DESC LIMIT 15 OFFSET #', $userid, $offset));
        if (count($eventslist) > 0) {
            $event = array();
            $output = '';
            $i = 0;
            //
            $userids = array();
            foreach ($eventslist as $event) {
                $userids[$event['userid']] = $event['userid'];
                $userids[$event['effecteduserid']] = $event['effecteduserid'];
            }
            if (QA_FINAL_EXTERNAL_USERS) {
                $handles = qa_get_public_from_userids($userids);
            } else {
                $handles = qa_db_user_get_userid_handles($userids);
            }
            // get event's: time, type, parameters
            // get post id of questions
            foreach ($eventslist as $event) {
                $title = '';
                $link = '';
                $vote_status = '';
                $handle = isset($handles[$event['userid']]) ? $handles[$event['userid']] : qa_lang('main/anonymous');
                $datetime = $event['datetime'];
                $event['date'] = qa_html(qa_time_to_string(qa_opt('db_time') - $datetime));
                $event['params'] = json_decode($event['params'], true);
                $id = ' data-id="' . $event['id'] . '"';
                $read = $event['read'] ? ' read' : ' unread';
                $url_param = array('ra_notification' => $event['id']);
                $user_link = qa_path_html('user/' . $handle, $url_param, QW_BASE_URL);
                switch ($event['event']) {
                    case 'related':
                        // related question to an answer
                        $url = qa_path_html(qa_q_request($event['postid'], $event['params']['title']), $url_param, QW_BASE_URL, null, null);
                        echo '<div class="event-content clearfix' . $read . '' . $read . '"' . $id . '>
								<div class="avatar"><a href="' . $user_link . '">' . ra_get_avatar($handle, 32, true) . '</a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/asked_question_related_to_your') . '</span>
											<strong class="where">' . qa_lang_html('dude/answer') . '</strong>
										</div>
										<div class="footer">
											<span class="event-icon icon-link"></span>
											<span class="date">' . qa_lang_sub('dude/x_ago', $event['date']) . '</span>
										</div>
									</a>
								</div>
							</div>';
                        break;
                    case 'a_post':
                        // user's question had been answered
                        $anchor = qa_anchor('A', $event['postid']);
                        $url = qa_path_html(qa_q_request($event['params']['qid'], $event['params']['qtitle']), $url_param, QW_BASE_URL, null, $anchor);
                        $title = qw_truncate($event['params']['qtitle'], 60);
                        echo '<div class="event-content clearfix' . $read . '"' . $id . '>
								<div class="avatar"><a href="' . $user_link . '">' . ra_get_avatar($handle, 32, true) . '</a></div>
								<div class="event-right">
									<a href="' . $url . '">
										<div class="head">
											<strong class="user">' . $handle . '</strong>
											<span class="what">' . qa_lang_html('dude/answered_your') . '</span>
											<strong class="where">' . qa_lang_html('dude/question') . '</strong>
										</div>
//.........这里部分代码省略.........
开发者ID:rahularyan,项目名称:dude-theme,代码行数:101,代码来源:addon.php


注:本文中的qa_get_options函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。