function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
     global $qa_login_userid, $questionid, $relatedcount, $question, $relatedquestions, $qa_cookieid, $usershtml;
     list($question, $relatedquestions) = qa_db_select_with_pending(qa_db_full_post_selectspec($qa_login_userid, $questionid), qa_db_related_qs_selectspec($qa_login_userid, $questionid));
     if ($relatedcount > 1 && !$question['hidden']) {
         $minscore = qa_match_to_min_score(qa_opt('match_related_qs'));
         foreach ($relatedquestions as $key => $related) {
             if ($related['postid'] == $questionid || $related['score'] < $minscore) {
                 unset($relatedquestions[$key]);
             }
         }
         if (count($relatedquestions)) {
             $themeobject->output('<h2>' . qa_lang('main/related_qs_title') . '</h2>');
         } else {
             $themeobject->output('<h2>' . qa_lang('main/no_related_qs_title') . '</h2>');
         }
         $upper = qa_opt('related_qs_num') < count($relatedquestions) ? qa_opt('related_qs_num') : count($relatedquestions);
         foreach ($relatedquestions as $related) {
             if ($upper <= 0) {
                 break;
             }
             $themeobject->output('<p style="margin:0 0 10px 0; font-weight:bold;"><a href="' . qa_path_html(qa_q_request($related['postid'], $related['title'])) . '">' . $related['title'] . '</a></p>');
             $upper--;
         }
     }
 }
 function admin_form(&$qa_content)
 {
     // process the admin form if admin hits Save-Changes-button
     $ok = null;
     if (qa_clicked('q2apro_popularqu_save')) {
         qa_opt('q2apro_popularqu_enabled', (bool) qa_post_text('q2apro_popularqu_enabled'));
         // empty or 1
         qa_opt('q2apro_popularqu_maxqu', (int) qa_post_text('q2apro_popularqu_maxqu'));
         qa_opt('q2apro_popularqu_lastdays', (int) qa_post_text('q2apro_popularqu_lastdays'));
         qa_opt('q2apro_popularqu_checkhours', (int) qa_post_text('q2apro_popularqu_checkhours'));
         qa_opt('q2apro_popularqu_answercount', (bool) qa_post_text('q2apro_popularqu_answercount'));
         $ok = qa_lang('admin/options_saved');
         // in case the options have been changed, update the widget
         q2apro_save_most_viewed_questions();
     }
     // form fields to display frontend for admin
     $fields = array();
     $fields[] = array('type' => 'checkbox', 'label' => qa_lang('q2apro_popularqu_lang/enable_plugin'), 'tags' => 'name="q2apro_popularqu_enabled"', 'value' => qa_opt('q2apro_popularqu_enabled'));
     $fields[] = array('type' => 'input', 'label' => qa_lang('q2apro_popularqu_lang/admin_maxqu'), 'tags' => 'name="q2apro_popularqu_maxqu"', 'value' => qa_opt('q2apro_popularqu_maxqu'));
     $fields[] = array('type' => 'checkbox', 'label' => qa_lang('q2apro_popularqu_lang/admin_answercount'), 'tags' => 'name="q2apro_popularqu_answercount"', 'value' => qa_opt('q2apro_popularqu_answercount'));
     $fields[] = array('type' => 'input', 'label' => qa_lang('q2apro_popularqu_lang/admin_lastdays'), 'tags' => 'name="q2apro_popularqu_lastdays"', 'value' => qa_opt('q2apro_popularqu_lastdays'));
     $fields[] = array('type' => 'input', 'label' => qa_lang('q2apro_popularqu_lang/admin_checkhours'), 'tags' => 'name="q2apro_popularqu_checkhours"', 'value' => qa_opt('q2apro_popularqu_checkhours'));
     $fields[] = array('type' => 'static', 'note' => qa_lang('q2apro_popularqu_lang/admin_lastcache') . ' ' . date('Y-m-d H:i:s', (double) qa_opt('q2apro_popularqu_checktime')));
     $fields[] = array('type' => 'static', 'note' => qa_lang('q2apro_popularqu_lang/admin_remember') . ' <a href="' . qa_path('admin/layout') . '">/admin/layout</a>');
     $fields[] = array('type' => 'static', 'note' => '<span style="font-size:75%;color:#789;">' . strtr(qa_lang('q2apro_popularqu_lang/contact'), array('^1' => '<a target="_blank" href="http://www.q2apro.com/forum/">', '^2' => '</a>')) . '</span>');
     return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => qa_lang('main/save_button'), 'tags' => 'name="q2apro_popularqu_save"')));
 }
    function admin_form(&$qa_content)
    {
        // Process form input
        $ok = null;
        if (qa_clicked('cp_save')) {
            // Save
            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');
            qa_opt('cp_enable', (bool) qa_post_text('cp_enable'));
            $ok = qa_lang('admin/options_saved');
        } else {
            if (qa_clicked('cp_reset')) {
                // Reset
                foreach ($_POST as $i => $v) {
                    $def = $this->option_default($i);
                    if ($def !== null) {
                        qa_opt($i, $def);
                    }
                }
                qa_opt('cp_enable', true);
                $ok = qa_lang('admin/options_reset');
            }
        }
        // Create the form for display
        $fields = array();
        $fields[] = array('label' => qa_lang('cp/enable_community_posts'), 'tags' => 'NAME="cp_enable"', 'value' => qa_opt('cp_enable'), 'type' => 'checkbox');
        return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="cp_save"'), array('label' => qa_lang_html('admin/reset_options_button'), 'tags' => 'NAME="cp_reset"')));
    }
Example #4
0
 function admin_form(&$qa_content)
 {
     //	Process form input
     $ok = null;
     if (qa_clicked('prevnav_save_button')) {
         qa_opt('prevnav_plugin_css', qa_post_text('prevnav_plugin_css'));
         qa_opt('prevnav_plugin_widget_only', (bool) qa_post_text('prevnav_plugin_widget_only'));
         qa_opt('prevnav_plugin_widget_title', qa_post_text('prevnav_plugin_widget_title'));
         $ok = qa_lang('admin/options_saved');
     } else {
         if (qa_clicked('prevnav_reset_button')) {
             foreach ($_POST as $i => $v) {
                 $def = $this->option_default($i);
                 if ($def !== null) {
                     qa_opt($i, $def);
                 }
             }
             $ok = qa_lang('admin/options_reset');
         }
     }
     //	Create the form for display
     $fields = array();
     $fields[] = array('type' => 'blank');
     $fields[] = array('label' => 'PrevNav buttons custom css', 'tags' => 'NAME="prevnav_plugin_css"', 'value' => qa_opt('prevnav_plugin_css'), 'type' => 'textarea', 'rows' => 20);
     $fields[] = array('label' => 'Widget Title', 'tags' => 'NAME="prevnav_plugin_widget_title"', 'value' => qa_opt('prevnav_plugin_widget_title'));
     $fields[] = array('type' => 'blank');
     $fields[] = array('type' => 'blank');
     return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="prevnav_save_button"'), array('label' => qa_lang_html('admin/reset_options_button'), 'tags' => 'NAME="prevnav_reset_button"')));
 }
Example #5
0
 function admin_form(&$qa_content)
 {
     //	Process form input
     $ok = null;
     if (qa_clicked('adchat_save_button')) {
         qa_opt('adchat_plugin_css', qa_post_text('adchat_plugin_css'));
         if (qa_post_text('adchat-expand-categories') == 1) {
             qa_opt('adchat-expand-categories', "1");
         } else {
             qa_opt('adchat-expand-categories', "0");
         }
         $ok = qa_lang('admin/options_saved');
     } else {
         if (qa_clicked('adchat_reset_button')) {
             foreach ($_POST as $i => $v) {
                 $def = $this->option_default($i);
                 if ($def !== null) {
                     qa_opt($i, $def);
                 }
             }
             $ok = qa_lang('admin/options_reset');
         }
     }
     //	Create the form for display
     $fields = array();
     $fields[] = array('type' => 'blank');
     $fields[] = array('label' => 'Adchat custom css', 'tags' => 'NAME="adchat_plugin_css"', 'value' => qa_opt('adchat_plugin_css'), 'type' => 'textarea', 'rows' => 20);
     $fields[] = array('label' => 'Make all categories into chat room', 'note' => 'Otherwise only top level categories are made to chat room', 'tags' => 'NAME="adchat-expand-categories"', 'value' => qa_opt('adchat-expand-categories'), 'type' => 'checkbox');
     return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="adchat_save_button"'), array('label' => qa_lang_html('admin/reset_options_button'), 'tags' => 'NAME="adchat_reset_button"')));
 }
function q2apro_save_most_viewed_questions()
{
    // save checktime of cache
    qa_opt('q2apro_popularqu_checktime', time());
    $maxquestions = qa_opt('q2apro_popularqu_maxqu');
    $lastdays = qa_opt('q2apro_popularqu_lastdays');
    $ourTopQuestions = qa_db_read_all_assoc(qa_db_query_sub('SELECT postid, title, acount FROM `^posts` 
											WHERE `created` > NOW() - INTERVAL # DAY
											AND `type` = "Q"
											AND `closedbyid` IS NULL
											ORDER BY views DESC
											LIMIT #;', $lastdays, $maxquestions));
    $saveoutput = '';
    foreach ($ourTopQuestions as $qu) {
        $activity_url = qa_path_html(qa_q_request($qu['postid'], $qu['title']), null, qa_opt('site_url'), null, null);
        $questionlink = '<a href="' . $activity_url . '">' . htmlspecialchars($qu['title']) . '</a>';
        $answercnt = '';
        if (qa_opt('q2apro_popularqu_answercount')) {
            $acnttitle = $qu['acount'] == 1 ? qa_lang('q2apro_popularqu_lang/answer_one') : $qu['acount'] . ' ' . qa_lang('q2apro_popularqu_lang/answers');
            $answercnt = ' <span title="' . $acnttitle . '">(' . $qu['acount'] . ')</span>';
        }
        $saveoutput .= '<li>
							' . $questionlink . $answercnt . '
						</li>
						';
    }
    // save into cache
    qa_opt('q2apro_popularqu_cached', $saveoutput);
}
function qa_question_set_selchildid($userid, $handle, $cookieid, $oldquestion, $selchildid, $answers)
{
    $oldselchildid = $oldquestion['selchildid'];
    qa_db_post_set_selchildid($oldquestion['postid'], isset($selchildid) ? $selchildid : null);
    qa_db_points_update_ifuser($oldquestion['userid'], 'aselects');
    if (isset($oldselchildid)) {
        if (isset($answers[$oldselchildid])) {
            qa_db_points_update_ifuser($answers[$oldselchildid]['userid'], 'aselecteds');
            qa_report_event('a_unselect', $userid, $handle, $cookieid, array('parentid' => $oldquestion['postid'], 'postid' => $oldselchildid));
        }
    }
    if (isset($selchildid)) {
        $answer = $answers[$selchildid];
        qa_db_points_update_ifuser($answer['userid'], 'aselecteds');
        if (isset($answer['notify']) && !qa_post_is_by_user($answer, $userid, $cookieid)) {
            require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
            require_once QA_INCLUDE_DIR . 'qa-app-options.php';
            require_once QA_INCLUDE_DIR . 'qa-util-string.php';
            require_once QA_INCLUDE_DIR . 'qa-app-format.php';
            $blockwordspreg = qa_get_block_words_preg();
            $sendtitle = qa_block_words_replace($oldquestion['title'], $blockwordspreg);
            $sendcontent = qa_viewer_text($answer['content'], $answer['format'], array('blockwordspreg' => $blockwordspreg));
            qa_send_notification($answer['userid'], $answer['notify'], @$answer['handle'], qa_lang('emails/a_selected_subject'), qa_lang('emails/a_selected_body'), array('^s_handle' => isset($handle) ? $handle : qa_lang('main/anonymous'), '^q_title' => $sendtitle, '^a_content' => $sendcontent, '^url' => qa_path(qa_q_request($oldquestion['postid'], $sendtitle), null, qa_opt('site_url'), null, qa_anchor('A', $selchildid))));
        }
        qa_report_event('a_select', $userid, $handle, $cookieid, array('parentid' => $oldquestion['postid'], 'postid' => $selchildid));
    }
}
 function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     $widget_opt = @$themeobject->current_widget['param']['options'];
     require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
     require_once QA_INCLUDE_DIR . 'qa-app-format.php';
     require_once QA_INCLUDE_DIR . 'qa-app-q-list.php';
     $categoryslugs = '';
     $userid = qa_get_logged_in_userid();
     //	Get lists of recent activity in all its forms, plus category information
     list($questions1, $questions2, $questions3, $questions4) = qa_db_select_with_pending(qa_db_qs_selectspec($userid, 'created', 0, $categoryslugs, null, false, false, $qcount), qa_db_recent_a_qs_selectspec($userid, 0, $categoryslugs), qa_db_recent_c_qs_selectspec($userid, 0, $categoryslugs), qa_db_recent_edit_qs_selectspec($userid, 0, $categoryslugs));
     //	Prepare and return content for theme
     $content = qa_q_list_page_content(qa_any_sort_and_dedupe(array_merge($questions1, $questions2, $questions3, $questions4)), $qcount, 0, null, null, null, null, null, true, 'activity/', null, null, null, null);
     $content = $content['q_list']['qs'];
     if (@$themeobject->current_widget['param']['locations']['show_title']) {
         $themeobject->output('<h3 class="widget-title">' . qa_lang('cleanstrap/recent_activities') . ' <a href="' . qa_path_html('activity') . '">' . qa_lang('cleanstrap/view_all') . '</a></h3>');
     }
     $themeobject->output('<div class="ra-question-activity-widget">');
     $q_list = $content;
     $themeobject->output('<ul class="activity-list">');
     foreach ($q_list as $list) {
         $themeobject->output('<li class="clearfix ' . (is_featured($list['raw']['postid']) ? ' featured' : '') . '"><span class="fav-star icon-heart' . (@$list['raw']['userfavoriteq'] ? ' active' : '') . '"></span><span class="post-status-c">' . cs_post_status($list) . '</span><a href="' . $list['url'] . '">' . $list['title'] . '<span class="time">' . implode(' ', $list['when']) . '</span><span class="ans-count total-' . $list['raw']['acount'] . '">' . $list['raw']['acount'] . '</span></a></li>');
     }
     $themeobject->output('</ul>');
     $themeobject->output('</div>');
 }
Example #9
0
 function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     if (!qa_opt('event_logger_to_database')) {
         return;
     }
     $badges = qa_db_read_all_assoc(qa_db_query_sub('SELECT event,handle,params, UNIX_TIMESTAMP(datetime) AS datetime FROM ^eventlog WHERE event=$' . (qa_opt('badge_widget_date_max') ? ' AND DATE_SUB(CURDATE(),INTERVAL ' . (int) qa_opt('badge_widget_date_max') . ' DAY) <= datetime' : '') . ' ORDER BY datetime DESC' . (qa_opt('badge_widget_list_max') ? ' LIMIT ' . (int) qa_opt('badge_widget_list_max') : ''), 'badge_awarded'));
     if (empty($badges)) {
         return;
     }
     $themeobject->output('<h2>' . qa_lang('badges/badge_widget_title') . '</h2>');
     foreach ($badges as $badge) {
         $params = array();
         $paramsa = explode("\t", $badge['params']);
         foreach ($paramsa as $param) {
             $parama = explode('=', $param);
             $params[$parama[0]] = $parama[1];
         }
         $slug = $params['badge_slug'];
         $typea = qa_get_badge_type_by_slug($slug);
         $types = $typea['slug'];
         $typed = $typea['name'];
         $badge_name = qa_lang('badges/' . $slug);
         if (!qa_opt('badge_' . $slug . '_name')) {
             qa_opt('badge_' . $slug . '_name', $badge_name);
         }
         $var = qa_opt('badge_' . $slug . '_var');
         $name = qa_opt('badge_' . $slug . '_name');
         $desc = qa_badge_desc_replace($slug, $var, $name);
         $string = '<span class="badge-' . $types . '" title="' . $desc . ' (' . $typed . ')">' . qa_html($name) . '<br/>- ' . $badge['handle'] . ' -</span>';
         $themeobject->output('<div class="badge-widget-entry" style="padding-top:8px;">', $string, '</div>');
     }
 }
 function admin_form(&$qa_content)
 {
     // process the admin form if admin hit Save-Changes-button
     $ok = null;
     if (qa_clicked('qa_blog_save')) {
         qa_opt('qa_blog_enabled', (bool) qa_post_text('qa_blog_enabled'));
         qa_opt('qa_blog_title', qa_post_text('qa_blog_title'));
         qa_opt('qa_blog_tagline', qa_post_text('qa_blog_tagline'));
         qa_opt('qa_blog_cat_1', qa_post_text('qa_blog_cat_1'));
         qa_opt('qa_blog_cat_2', qa_post_text('qa_blog_cat_2'));
         qa_opt('qa_blog_cat_3', qa_post_text('qa_blog_cat_3'));
         qa_opt('qa_blog_cat_4', qa_post_text('qa_blog_cat_4'));
         qa_opt('qa_blog_cat_5', qa_post_text('qa_blog_cat_5'));
         qa_opt('qa_blog_rules', qa_post_text('qa_blog_rules'));
         qa_opt('qa_blog_content_max', (int) qa_post_text('qa_blog_content_max_field'));
         $ok = qa_lang('qa_blog_lang/blog_save');
     }
     qa_set_display_rules($qa_content, array('field_2' => 'field_1', 'field_3' => 'field_1', 'field_5' => 'field_1', 'field_6' => 'field_1', 'field_7' => 'field_1', 'field_8' => 'field_1', 'field_9' => 'field_1', 'field_10' => 'field_1', 'field_11' => 'field_1'));
     // form fields to display frontend for admin
     $fields = array();
     $fields[] = array('label' => qa_lang('qa_blog_lang/enable_plugin'), 'type' => 'checkbox', 'value' => qa_opt('qa_blog_enabled'), 'tags' => 'name="qa_blog_enabled" id="field_1"');
     $fields[] = array('id' => 'field_2', 'type' => 'input', 'label' => qa_lang('qa_blog_lang/blog_title'), 'value' => qa_opt('qa_blog_title'), 'tags' => 'name="qa_blog_title"');
     $fields[] = array('id' => 'field_3', 'type' => 'textarea', 'label' => qa_lang('qa_blog_lang/blog_tagline'), 'value' => qa_opt('qa_blog_tagline'), 'rows' => 4, 'tags' => 'name="qa_blog_tagline"');
     $fields[] = array('id' => 'field_5', 'type' => 'input', 'label' => qa_lang('qa_blog_lang/cat_1'), 'value' => qa_opt('qa_blog_cat_1'), 'tags' => 'name="qa_blog_cat_1"');
     $fields[] = array('id' => 'field_6', 'type' => 'input', 'label' => qa_lang('qa_blog_lang/cat_2'), 'value' => qa_opt('qa_blog_cat_2'), 'tags' => 'name="qa_blog_cat_2"');
     $fields[] = array('id' => 'field_7', 'type' => 'input', 'label' => qa_lang('qa_blog_lang/cat_3'), 'value' => qa_opt('qa_blog_cat_3'), 'tags' => 'name="qa_blog_cat_3"');
     $fields[] = array('id' => 'field_8', 'type' => 'input', 'label' => qa_lang('qa_blog_lang/cat_4'), 'value' => qa_opt('qa_blog_cat_4'), 'tags' => 'name="qa_blog_cat_4"');
     $fields[] = array('id' => 'field_9', 'type' => 'input', 'label' => qa_lang('qa_blog_lang/cat_5'), 'value' => qa_opt('qa_blog_cat_5'), 'tags' => 'name="qa_blog_cat_5"');
     $fields[] = array('id' => 'field_10', 'type' => 'textarea', 'label' => qa_lang('qa_blog_lang/blog_rules'), 'value' => qa_opt('qa_blog_rules'), 'tags' => 'name="qa_blog_rules"', 'rows' => 4);
     $fields[] = array('id' => 'field_11', 'label' => qa_lang('qa_blog_lang/content_max'), 'suffix' => qa_lang('qa_blog_lang/suffix'), 'type' => 'number', 'value' => (int) qa_opt('qa_blog_content_max'), 'tags' => 'name="qa_blog_content_max_field"');
     return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'name="qa_blog_save"')));
 }
Example #11
0
function mp_announcement_create($userid, $handle, $cookieid, $title, $content, $format, $text, $notify, $categoryid)
{
    /* 
     * Proceeds to create an announcement
     *
     */
    require_once QA_INCLUDE_DIR . 'qa-db-post-create.php';
    require_once QA_INCLUDE_DIR . 'qa-app-emails.php';
    require_once QA_INCLUDE_DIR . 'mp-app-users.php';
    // persist data to database
    $postid = qa_db_post_create('AN', null, $userid, $cookieid, qa_remote_ip_address(), $title, $content, $format, null, $notify, $categoryid);
    qa_user_report_action(qa_get_logged_in_userid(), null, null, null, null);
    // update new post with category path hierarchy
    qa_db_posts_calc_category_path($postid);
    // send notifications
    if ($notify && isset($postid)) {
        $category = mp_get_categoryinfo($categoryid);
        $recipients = mp_get_category_userids($categoryid);
        foreach ($recipients as $recipient) {
            // retrieve the user flags
            $userflags = mp_get_user_flags($recipient['userid']);
            // check user flags to determine whether user should be notified or not
            // of the new answer post
            if (!($userflags & QA_USER_FLAGS_NOTIFY_ANNOUNCEMENTS)) {
                qa_send_notification($recipient['userid'], null, null, qa_lang('emails/an_posted_subject'), qa_lang('emails/an_posted_body'), array('^an_handle' => $handle, '^category_title' => $category['title'], '^an_title' => $title, '^an_url' => qa_path('mp-announcements-page', null, qa_opt('site_url'), null, null)));
            }
        }
    }
    // report announcement create event
    qa_report_event('an_post', $userid, $handle, $cookieid, array('postid' => $postid, 'title' => $title, 'content' => $content, 'format' => $format, 'text' => $text, 'categoryid' => $categoryid, 'notify' => $notify));
    return $postid;
}
 function admin_form(&$qa_content)
 {
     $ok = null;
     if (qa_clicked('short_url_save_button')) {
         qa_opt('short_url_content_on', (bool) qa_post_text('short_url_content_on'));
         qa_opt('short_url_bitly_username', (string) qa_post_text('short_url_bitly_username'));
         qa_opt('short_url_bitly_api_key', (string) qa_post_text('short_url_bitly_api_key'));
         $ok = qa_lang('admin/options_saved');
     } else {
         if (qa_clicked('short_url_reset_button')) {
             foreach ($_POST as $i => $v) {
                 $def = $this->option_default($i);
                 if ($def !== null) {
                     qa_opt($i, $def);
                 }
             }
             $ok = qa_lang('admin/options_reset');
         }
     }
     $fields = array();
     $ready = strlen(qa_opt('short_url_bitly_username')) && strlen(qa_opt('short_url_bitly_api_key'));
     if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') {
         $fields[] = array('label' => 'You cannot enable when in localhost', 'tags' => 'NAME="short_url_content_on"', 'value' => qa_opt('short_url_content_on'), 'type' => 'checkbox', 'disabled' => 'disabled');
     } else {
         $fields[] = array('label' => 'Enable Short Url', 'tags' => 'NAME="short_url_content_on"', 'value' => qa_opt('short_url_content_on'), 'type' => 'checkbox');
     }
     $fields[] = array('label' => 'Your Bitly username', 'tags' => 'NAME="short_url_bitly_username"', 'value' => qa_opt('short_url_bitly_username'), 'type' => 'string');
     $fields[] = array('label' => 'Your Bitly api key', 'tags' => 'NAME="short_url_bitly_api_key"', 'value' => qa_opt('short_url_bitly_api_key'), 'type' => 'string', 'error' => $ready ? null : 'You can find your api key <a href="https://bitly.com/a/your_api_key">here</a>');
     return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="short_url_save_button"'), array('label' => qa_lang_html('admin/reset_options_button'), 'tags' => 'NAME="short_url_reset_button"')));
 }
 function admin_form(&$qa_content)
 {
     $ok = null;
     if (qa_clicked('obvious_save_button')) {
         qa_opt('obvious_content_on', (bool) qa_post_text('obvious_content_on'));
         qa_opt('obvious_content_color', (string) qa_post_text('obvious_content_color'));
         qa_opt('obvious_max_tags', (int) qa_post_text('obvious_max_tags'));
         qa_opt('obvious_content_category_on', (bool) qa_post_text('obvious_content_category_on'));
         qa_opt('obvious_content_category_color', (string) qa_post_text('obvious_content_category_color'));
         $ok = qa_lang('admin/options_saved');
     } else {
         if (qa_clicked('obvious_reset_button')) {
             foreach ($_POST as $i => $v) {
                 $def = $this->option_default($i);
                 if ($def !== null) {
                     qa_opt($i, $def);
                 }
             }
             $ok = qa_lang('admin/options_reset');
         }
     }
     $fields = array();
     $fields[] = array('label' => 'Enable Obvious Favorite Tags', 'tags' => 'NAME="obvious_content_on"', 'value' => qa_opt('obvious_content_on'), 'type' => 'checkbox');
     $fields[] = array('label' => 'Your color in Hex', 'tags' => 'NAME="obvious_content_color"', 'value' => qa_opt('obvious_content_color'), 'type' => 'string');
     $fields[] = array('label' => 'Enable Obvious Favorite Category', 'tags' => 'NAME="obvious_content_category_on"', 'value' => qa_opt('obvious_content_category_on'), 'type' => 'checkbox');
     $fields[] = array('label' => 'Your color in Hex', 'tags' => 'NAME="obvious_content_category_color"', 'value' => qa_opt('obvious_content_category_color'), 'type' => 'string');
     $fields[] = array('type' => 'blank');
     $fields[] = array('label' => 'Maximum tags for the Widget', 'tags' => 'NAME="obvious_max_tags"', 'value' => qa_opt('obvious_max_tags'), 'type' => 'int');
     return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="obvious_save_button"'), array('label' => qa_lang_html('admin/reset_options_button'), 'tags' => 'NAME="obvious_reset_button"')));
 }
Example #14
0
 function cs_events($limit = 10, $events_type = false)
 {
     if (!$events_type) {
         $events_type = array('q_post', 'a_post', 'c_post', 'a_select', 'badge_awarded');
     }
     // query last 3 events
     $posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT datetime,ipaddress,handle,event,params FROM ^eventlog WHERE event IN ("q_post", "a_post", "c_post") ORDER BY datetime DESC LIMIT #', $limit));
     if (empty($posts)) {
         return;
     }
     $postids = '';
     $i = 1;
     foreach ($posts as $post) {
         $params = preg_replace('/\\s+/', '&', $post['params']);
         parse_str($params, $data);
         $postids .= ($i != 1 ? ', ' : '') . $data['postid'];
         $i++;
     }
     $posts = qa_db_read_all_assoc(qa_db_query_sub('SELECT ^posts.* , ^users.handle FROM ^posts, ^users WHERE (^posts.userid=^users.userid AND ^posts.postid IN (' . $postids . ')) AND ^posts.type IN ("Q", "A", "C") ORDER BY ^posts.created DESC'));
     $o = '<ul class="ra-activity">';
     foreach ($posts as $p) {
         $event_name = '';
         $event_icon = '';
         if ($p['type'] == 'Q') {
             $event_name = qa_lang('cleanstrap/asked');
             $event_icon = 'icon-question';
         } else {
             if ($p['type'] == 'A') {
                 $event_name = qa_lang('cleanstrap/answered');
                 $event_icon = 'icon-answer';
             } else {
                 $event_name = qa_lang('cleanstrap/commented');
                 $event_icon = 'icon-chat';
             }
         }
         $username = is_null($p['handle']) ? qa_lang('cleanstrap/anonymous') : htmlspecialchars($p['handle']);
         $usernameLink = is_null($p['handle']) ? qa_lang('cleanstrap/anonymous') : '<a href="' . qa_path_html('user/' . $p['handle']) . '">' . $p['handle'] . '</a>';
         $timeCode = qa_when_to_html(strtotime($p['created']), 7);
         $time = @$timeCode['prefix'] . @$timeCode['data'] . @$timeCode['suffix'];
         $o .= '<li class="event-item">';
         $o .= '<div class="event-inner">';
         $o .= '<div class="event-icon pull-left ' . $event_icon . '"></div>';
         $o .= '<div class="event-content">';
         $o .= '<p class="title"><strong class="avatar" data-handle="' . $p['handle'] . '" data-id="' . $p['userid'] . '">' . @$usernameLink . '</strong> <span class="what">' . $event_name . '</span></p>';
         if ($p['type'] == 'Q') {
             $o .= '<a class="event-title" href="' . qa_q_path_html($p['postid'], $p['title']) . '" title="' . $p['title'] . '">' . cs_truncate($p['title'], 100) . '</a>';
         } elseif ($p['type'] == 'A') {
             $o .= '<a class="event-title" href="' . cs_post_link($p['parentid']) . '#a' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 100) . '</a>';
         } else {
             $o .= '<a class="event-title" href="' . cs_post_link($p['parentid']) . '#c' . $p['postid'] . '">' . cs_truncate(strip_tags($p['content']), 100) . '</a>';
         }
         $o .= '<span class="time">' . $time . '</span>';
         $o .= '</div>';
         $o .= '</div>';
         $o .= '</li>';
     }
     $o .= '</ul>';
     return $o;
 }
Example #15
0
/**
 * Returns the language value as defined in lang/donut-options-lang-*.php
 *
 * @param      $indentifier
 * @param null $subs
 *
 * @return mixed|string
 */
function donut_options_lang($indentifier, $subs = null)
{
    if (!is_array($subs)) {
        return empty($subs) ? qa_lang('donut_options/' . $indentifier) : qa_lang_sub('donut_options/' . $indentifier, $subs);
    } else {
        return strtr(qa_lang('donut_options/' . $indentifier), $subs);
    }
}
Example #16
0
 function admin_form(&$qa_content)
 {
     //	Process form input
     $ok = null;
     if (qa_clicked('share_save_button')) {
         qa_opt('share_plugin_facebook', (bool) qa_post_text('share_plugin_facebook'));
         qa_opt('share_plugin_twitter', (bool) qa_post_text('share_plugin_twitter'));
         qa_opt('share_plugin_google', (bool) qa_post_text('share_plugin_google'));
         qa_opt('share_plugin_linkedin', (bool) qa_post_text('share_plugin_linkedin'));
         qa_opt('share_plugin_email', (bool) qa_post_text('share_plugin_email'));
         qa_opt('share_plugin_facebook_weight', (int) qa_post_text('share_plugin_facebook_weight'));
         qa_opt('share_plugin_twitter_weight', (int) qa_post_text('share_plugin_twitter_weight'));
         qa_opt('share_plugin_google_weight', (int) qa_post_text('share_plugin_google_weight'));
         qa_opt('share_plugin_linkedin_weight', (int) qa_post_text('share_plugin_linkedin_weight'));
         qa_opt('share_plugin_email_weight', (int) qa_post_text('share_plugin_email_weight'));
         qa_opt('share_plugin_css', qa_post_text('share_plugin_css'));
         qa_opt('share_plugin_widget_only', (bool) qa_post_text('share_plugin_widget_only'));
         qa_opt('share_plugin_widget_title', qa_post_text('share_plugin_widget_title'));
         qa_opt('share_plugin_suggest', (int) qa_post_text('share_plugin_suggest'));
         qa_opt('share_plugin_suggest_text', qa_post_text('share_plugin_suggest_text'));
         $ok = qa_lang('admin/options_saved');
     } else {
         if (qa_clicked('share_reset_button')) {
             foreach ($_POST as $i => $v) {
                 $def = $this->option_default($i);
                 if ($def !== null) {
                     qa_opt($i, $def);
                 }
             }
             $ok = qa_lang('admin/options_reset');
         }
     }
     //	Create the form for display
     $fields = array();
     $fields[] = array('label' => 'Show Facebook button', 'tags' => 'NAME="share_plugin_facebook"', 'value' => qa_opt('share_plugin_facebook'), 'type' => 'checkbox');
     $fields[] = array('label' => 'Show Twitter button', 'tags' => 'NAME="share_plugin_twitter"', 'value' => qa_opt('share_plugin_twitter'), 'type' => 'checkbox');
     $fields[] = array('label' => 'Show Google+ button', 'tags' => 'NAME="share_plugin_google"', 'value' => qa_opt('share_plugin_google'), 'type' => 'checkbox');
     $fields[] = array('label' => 'Show LinkedIn button', 'tags' => 'NAME="share_plugin_linkedin"', 'value' => qa_opt('share_plugin_linkedin'), 'type' => 'checkbox');
     $fields[] = array('label' => 'Show email button', 'tags' => 'NAME="share_plugin_email"', 'value' => qa_opt('share_plugin_email'), 'type' => 'checkbox');
     $fields[] = array('type' => 'blank');
     $fields[] = array('label' => 'Facebook button weight:', 'tags' => 'NAME="share_plugin_facebook_weight" title="smaller values come before larger values in the DOM"', 'value' => qa_opt('share_plugin_facebook_weight'), 'type' => 'number');
     $fields[] = array('label' => 'Twitter button weight:', 'tags' => 'NAME="share_plugin_twitter_weight" title="smaller values come before larger values in the DOM"', 'value' => qa_opt('share_plugin_twitter_weight'), 'type' => 'number');
     $fields[] = array('label' => 'Google+ button weight:', 'tags' => 'NAME="share_plugin_google_weight" title="smaller values come before larger values in the DOM"', 'value' => qa_opt('share_plugin_google_weight'), 'type' => 'number');
     $fields[] = array('label' => 'LinkedIn button weight:', 'tags' => 'NAME="share_plugin_linkedin_weight" title="smaller values come before larger values in the DOM"', 'value' => qa_opt('share_plugin_linkedin_weight'), 'type' => 'number');
     $fields[] = array('label' => 'Email button weight:', 'tags' => 'NAME="share_plugin_email_weight" title="smaller values come before larger values in the DOM"', 'value' => qa_opt('share_plugin_email_weight'), 'type' => 'number');
     $fields[] = array('type' => 'blank');
     $fields[] = array('label' => 'Share buttons custom css', 'tags' => 'NAME="share_plugin_css"', 'value' => qa_opt('share_plugin_css'), 'type' => 'textarea', 'rows' => 20);
     $fields[] = array('label' => 'Widget only', 'tags' => 'NAME="share_plugin_widget_only"', 'value' => qa_opt('share_plugin_widget_only'), 'type' => 'checkbox', 'note' => 'disables inline buttons - widget must be enabled via admin/layout');
     $fields[] = array('label' => 'Widget Title', 'tags' => 'NAME="share_plugin_widget_title"', 'value' => qa_opt('share_plugin_widget_title'));
     $fields[] = array('type' => 'blank');
     $fields[] = array('label' => 'Show notification text while there are still no answers to a question', 'tags' => 'NAME="share_plugin_suggest" onclick="if(this.checked) jQuery(\'#share_options_container\').fadeIn(); else jQuery(\'#share_options_container\').fadeOut();"', 'value' => qa_opt('share_plugin_suggest'), 'type' => 'checkbox', 'note' => '<table id="share_options_container" style="display:' . (qa_opt('share_plugin_suggest') ? 'block' : 'none') . '"><tr><td>');
     $fields[] = array('tags' => 'NAME="share_plugin_suggest_text"', 'value' => qa_opt('share_plugin_suggest_text'), 'type' => 'text', 'note' => '<i style="font-size:10px;">(use <b>#</b> to specify button location)</i></td></tr></table>');
     $fields[] = array('type' => 'blank');
     return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="share_save_button"'), array('label' => qa_lang_html('admin/reset_options_button'), 'tags' => 'NAME="share_reset_button"')));
 }
function qa_get_request_content()
{
    $qa_content = qa_get_request_content_base();
    if (isset($qa_content['form_profile']['fields']['permits'])) {
        $ov = $qa_content['form_profile']['fields']['permits']['value'];
        $ov = str_replace('[profile/permit_create_cp]', qa_lang('cp/permit_create_community_posts'), $ov);
        $ov = str_replace('[profile/permit_edit_cp]', qa_lang('cp/permit_edit_community_posts'), $ov);
        $qa_content['form_profile']['fields']['permits']['value'] = $ov;
    }
    return $qa_content;
}
Example #18
0
function qa_get_request_content()
{
    $qa_content = qa_get_request_content_base();
    // permissions
    if (isset($qa_content['form_profile']['fields']['permits'])) {
        $ov = $qa_content['form_profile']['fields']['permits']['value'];
        $ov = str_replace('[profile/permit_vote_c]', qa_lang('comment_voting/permit_vote_c'), $ov);
        $qa_content['form_profile']['fields']['permits']['value'] = $ov;
    }
    return $qa_content;
}
    function admin_form(&$qa_content)
    {
        // Prepare errors
        $pagelength_error = '';
        // Process form input
        $ok = null;
        if (qa_clicked('qa_eql_save')) {
            // Save options
            qa_opt('qa_eql_enabled', (bool) qa_post_text('qa_eql_enabled'));
            qa_opt('qa_eql_homepage', (bool) qa_post_text('qa_eql_homepage'));
            qa_opt('qa_eql_button', (bool) qa_post_text('qa_eql_button'));
            qa_opt('qa_eql_include', (bool) qa_post_text('qa_eql_include'));
            qa_opt('qa_homepage_url', qa_post_text('qa_homepage_url'));
            qa_opt('qa_homepage_separate', (bool) qa_post_text('qa_homepage_separate'));
            $ok = qa_lang('admin/options_saved');
        } else {
            if (qa_clicked('qa_eql_reset')) {
                // Reset options
                qa_opt('qa_eql_enabled', $this->option_default('qa_eql_enabled'));
                qa_opt('qa_eql_homepage', $this->option_default('qa_eql_homepage'));
                qa_opt('qa_eql_button', $this->option_default('qa_eql_button'));
                qa_opt('qa_eql_include', $this->option_default('qa_eql_include'));
                qa_opt('qa_homepage_url', $this->option_default('qa_homepage_url'));
                qa_opt('qa_homepage_separate', $this->option_default('qa_homepage_separate'));
                $ok = qa_lang('admin/options_reset');
            }
        }
        // Sync database (if admin wants so or if it is appropriate given the new settings)
        if (qa_clicked('qa_eql_calchomepage')) {
            $this->sync();
            $ok = 'Database sync\'d!';
        }
        // Create the form for display
        $fields = array();
        $fields[] = array('label' => 'Make question links expandable', 'tags' => 'name="qa_eql_enabled" onchange="if (this.checked) $(\'.eql-checks\').show();else $(\'.eql-checks\').hide();"', 'value' => qa_opt('qa_eql_enabled'), 'type' => 'checkbox');
        $fields[] = array('type' => 'custom', 'label' => '<span class="qa-form-tall-label eql-checks"' . (qa_opt('qa_eql_enabled') ? '' : ' style="display:none;"') . '>
											<h3>Additional options</h3>
											<label><input name="qa_eql_include" type="checkbox" class="qa-form-tall-checkbox"' . (qa_opt('qa_eql_include') ? ' checked=""' : '') . '>Include jquery.ias.min.js</label>
											<small>(Uncheck this if you already use Infinite AJAX Scroll on this website).</small>
											<br><br><br>
											<label><input name="qa_eql_homepage" type="checkbox" onchange="if (this.checked) $(\'.eql-hchecks\').show();else $(\'.eql-hchecks\').hide();"
													class="qa-form-tall-checkbox"' . (qa_opt('qa_eql_homepage') ? ' checked=""' : '') . '>Make the homepage expandable too</label>
											<br><br>
											<span class="qa-form-tall-label eql-hchecks"' . (qa_opt('qa_eql_enabled') && qa_opt('qa_eql_homepage') ? '' : ' style="display:none;"') . '>
												<h3>Homepage options</h3>
												<small>Use the button below to keep the homepage in sync (this may take a while on large fora). 
												If this is  the first time you make the homepage expandable, you\'ll have to sync first.</small><br><br>
												<label><input name="qa_homepage_separate" type="checkbox" class="qa-form-tall-checkbox"' . (qa_opt('qa_homepage_separate') ? ' checked=""' : '') . '>Use a custom homepage</label>
												<br><br>
												Custom homepage URL : <input name="qa_homepage_url" type="text" class="qa-form-tall-text" value="' . qa_opt('qa_homepage_url') . '" onclick="this.select();">
											</span>
										</span>');
        return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => 'Save', 'tags' => 'NAME="qa_eql_save"'), array('label' => 'Sync homepage', 'tags' => 'NAME="qa_eql_calchomepage"'), array('label' => 'Reset', 'tags' => 'NAME="qa_eql_reset"')));
    }
Example #20
0
function qa_feed_load_ifcategory($categoryslugs, $allkey, $catkey, &$title, $questionselectspec1 = null, $questionselectspec2 = null, $questionselectspec3 = null, $questionselectspec4 = null)
{
    $countslugs = @count($categoryslugs);
    list($questions1, $questions2, $questions3, $questions4, $categories, $categoryid) = qa_db_select_with_pending($questionselectspec1, $questionselectspec2, $questionselectspec3, $questionselectspec4, $countslugs ? qa_db_category_nav_selectspec($categoryslugs, false) : null, $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null);
    if ($countslugs && !isset($categoryid)) {
        qa_feed_not_found();
    }
    if (isset($allkey)) {
        $title = isset($categoryid) && isset($catkey) ? qa_lang_sub($catkey, $categories[$categoryid]['title']) : qa_lang($allkey);
    }
    return array_merge(is_array($questions1) ? $questions1 : array(), is_array($questions2) ? $questions2 : array(), is_array($questions3) ? $questions3 : array(), is_array($questions4) ? $questions4 : array());
}
 function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     if (!qa_opt('book_plugin_active')) {
         return;
     }
     $themeobject->output('<h2>' . qa_lang('book/widget_title') . '</h2>');
     $out = '<li><a href="' . qa_path_html(qa_opt('book_plugin_request')) . '">&lt;/&gt; ' . qa_lang('book/widget_html') . '</a></li>';
     if (qa_opt('book_plugin_pdf')) {
         $out .= '<li><a href="' . qa_path_html(qa_opt('book_plugin_request_pdf')) . '"><img src="http://www.adobe.com/images/pdficon_small.png"> ' . qa_lang('book/widget_pdf') . '</a>';
     }
     $themeobject->output('<ul class="book-widget" style="padding-top:8px;">', $out, '</ul>');
 }
 public function process_event($event, $userid, $handle, $cookieid, $params)
 {
     switch ($event) {
         case 'q_post':
             $this->send_hipchat_notification($this->build_new_question_message(isset($handle) ? $handle : qa_lang('main/anonymous'), $params['title'], qa_q_path($params['postid'], $params['title'], true)));
             break;
         case 'a_post':
             $parentpost = qa_post_get_full($params['parentid']);
             $this->send_hipchat_notification($this->build_new_answer_message(isset($handle) ? $handle : qa_lang('main/anonymous'), $parentpost['title'], qa_path(qa_q_request($params['parentid'], $parentpost['title']), null, qa_opt('site_url'), null, qa_anchor('A', $params['postid']))));
             break;
     }
 }
function qa_get_request_content()
{
    $qa_content = qa_get_request_content_base();
    // permissions
    if (isset($qa_content['form_profile']['fields']['permits'])) {
        $ov = $qa_content['form_profile']['fields']['permits']['value'];
        $ov = str_replace('[profile/expert_question_roles]', qa_lang('expert_question/expert_question_roles'), $ov);
        $ov = str_replace('[profile/expert_question_ask]', qa_lang('expert_question/expert_question_ask'), $ov);
        $qa_content['form_profile']['fields']['permits']['value'] = $ov;
    }
    return $qa_content;
}
    function qw_notification_btn()
    {
        //if (true){ // check options
        $userid = qa_get_logged_in_userid();
        if (isset($userid)) {
            $handle = qa_get_logged_in_handle();
            $this->output('
					<div class="user-actions pull-right">
						<div class="activity-bar">
							<div class="button dropdown">
								<a href="' . qa_path_html('user/' . $handle . '/activity') . '" class=" icon-bullhorn dropdown-toggle activitylist" data-toggle="dropdown" id="activitylist"></a>
								<div class="dropdown-menu activity-dropdown-list pull-right" id="activity-dropdown-list">
									<div class="bar">
										<span>' . qa_lang_html('dude/notifications') . '</span>
										<a class="mark-activity" href="#" data-id="' . qa_get_logged_in_userid() . '">' . qa_lang('dude/mark_all_as_read') . '</a>
									</div>
									<div class="append">
										<div class="ajax-list"></div>
										<span class="loading"></span>
										<div class="no-activity icon-chart-bar">' . qa_lang('dude/no-activity') . '</div>
									</div>
									
									<a class="event-footer" href="' . qa_path_html('notifications', null, QW_BASE_URL) . '">' . qa_lang('dude/see_all') . '</a>
									
								</div>
							</div>
						</div>
						
						<div class="message-bar">
							<div class="button dropdown">
								<a href="' . qa_path_html('user/' . $handle . '/message') . '" class=" icon-envelope-alt dropdown-toggle messagelist" data-toggle="dropdown" id="messagelist"></a>
								<div class="dropdown-menu message-dropdown-list pull-right" id="message-dropdown-list">
									<div class="bar">
										<span>' . qa_lang_html('dude/messages') . '</span>
										<a class="mark-messages" href="#">' . qa_lang('dude/mark_all_as_read') . '</a>
									</div>
									<div class="append">
										<div class="ajax-list"></div>
										<span class="loading"></span>
										<div class="no-activity icon-chart-bar">' . qa_lang('dude/no-activity') . '</div>
									</div>
									
									<a class="event-footer" href="' . qa_path_html('user/' . $handle . '/wall', null, QW_BASE_URL) . '">' . qa_lang('dude/see_all') . '</a>
									
								</div>
							</div>
						</div>
					</div>
				');
        }
        //}
    }
Example #25
0
 function admin_form(&$qa_content)
 {
     // Process form input
     $ok = null;
     if (qa_clicked('xml_rpc_save')) {
         qa_opt('xml_rpc_bool_active', (bool) @$_POST['xml_rpc_bool_active']);
         $ok = qa_lang('admin/options_saved');
     }
     // Create the form for display
     $fields = array();
     $fields[] = array('label' => 'Enable XML-RPC server', 'tags' => 'NAME="xml_rpc_bool_active"', 'value' => qa_opt('xml_rpc_bool_active'), 'type' => 'checkbox');
     return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => qa_lang_html('main/save_button'), 'tags' => 'NAME="xml_rpc_save"')));
 }
Example #26
0
function qa_qs_sub_navigation($sort)
{
    $navigation = array('recent' => array('label' => qa_lang('main/nav_most_recent'), 'url' => qa_path_html('questions')), 'hot' => array('label' => qa_lang('main/nav_hot'), 'url' => qa_path_html('questions', array('sort' => 'hot'))), 'votes' => array('label' => qa_lang('main/nav_most_votes'), 'url' => qa_path_html('questions', array('sort' => 'votes'))), 'answers' => array('label' => qa_lang('main/nav_most_answers'), 'url' => qa_path_html('questions', array('sort' => 'answers'))), 'views' => array('label' => qa_lang('main/nav_most_views'), 'url' => qa_path_html('questions', array('sort' => 'views'))));
    if (isset($navigation[$sort])) {
        $navigation[$sort]['selected'] = true;
    } else {
        $navigation['recent']['selected'] = true;
    }
    if (!qa_opt('do_count_q_views')) {
        unset($navigation['views']);
    }
    return $navigation;
}
 function admin_form(&$qa_content)
 {
     // Process form input
     $ok = null;
     if (qa_clicked('confirm_plugin_save')) {
         qa_opt('confirm_close_plugin', (bool) qa_post_text('confirm_close_plugin'));
         $ok = qa_lang('admin/options_saved');
     }
     // Create the form for display
     $fields = array();
     $fields[] = array('label' => 'Enable confirmation dialogue', 'tags' => 'NAME="confirm_close_plugin"', 'value' => qa_opt('confirm_close_plugin'), 'type' => 'checkbox');
     return array('ok' => $ok && !isset($error) ? $ok : null, 'fields' => $fields, 'buttons' => array(array('label' => 'Save', 'tags' => 'NAME="confirm_plugin_save"')));
 }
 function output_widget($region, $place, $themeobject, $template, $request, $qa_content)
 {
     $temp = qa_db_query_sub('SELECT BINARY title as title, postid, netvotes, acount FROM ^posts WHERE type=$', 'Q');
     $max = mysqli_num_rows($temp);
     if (!$max) {
         return;
     }
     $themeobject->output('<h2>' . qa_opt('random_question_title') . '</h2>');
     for ($i = 0; $i < qa_opt('random_question_number'); $i++) {
         $rand = rand() / getrandmax() * $max;
         $check = mysqli_data_seek($temp, $rand);
         if (!$check) {
             $i--;
         } else {
             $random_question = qa_db_read_one_assoc($temp, true);
         }
         if (is_array($random_question)) {
             $votes = (int) $random_question['netvotes'];
             if ($votes > 0) {
                 if ($votes > 1) {
                     $votes = str_replace('^', '+' . $votes, qa_lang('main/x_votes'));
                 } else {
                     $votes = str_replace('1', '+1', qa_lang('main/1_vote'));
                 }
             } else {
                 if ($votes < 0) {
                     if ($votes < -1) {
                         $votes = str_replace('^', $votes, qa_lang('main/x_votes'));
                     } else {
                         $votes = str_replace('1', '-1', qa_lang('main/1_vote'));
                     }
                 } else {
                     $votes = '';
                 }
             }
             $answers = (int) $random_question['acount'];
             if ($answers > 0) {
                 if ($answers > 1) {
                     $answers = str_replace('^', '+' . $answers, qa_lang('main/x_answers'));
                 } else {
                     $answers = qa_lang('main/1_answer');
                 }
             } else {
                 $answers = '';
             }
             $themeobject->output('<div class="random-question" style="padding-bottom:4px;"><a href="' . qa_path_html(qa_q_request($random_question['postid'], $random_question['title'])) . '">' . $random_question['title'] . '</a></div><div class="random-question-meta" style="padding-bottom:4px; border-bottom:1px solid; margin-bottom:2px;">' . $votes . ($votes && $answers ? ', ' : '') . $answers . '</div>');
         }
     }
 }
 function admin_form(&$qa_content)
 {
     $saved = false;
     if (qa_clicked(self::SAVE_BUTTON)) {
         qa_opt(self::SHOW_HOME, (bool) qa_post_text(self::SHOW_HOME));
         qa_opt(self::NO_LINK_AT_LAST_ELEM, (bool) qa_post_text(self::NO_LINK_AT_LAST_ELEM));
         qa_opt(self::DONT_USE_ICONS, (bool) qa_post_text(self::DONT_USE_ICONS));
         qa_opt(self::USE_FA_CDN, (bool) qa_post_text(self::USE_FA_CDN));
         qa_opt(self::FA_CDN, qa_post_text(self::FA_CDN));
         qa_opt(self::TRUNCATE_LENGTH, qa_post_text(self::TRUNCATE_LENGTH));
         qa_opt(self::CUSTOM_CSS, qa_post_text(self::CUSTOM_CSS));
         $saved = true;
     }
     return array('ok' => $saved ? qa_lang('breadcrumbs/settings_saved') : null, 'fields' => array(self::SHOW_HOME => array('label' => 'Show the home link ', 'type' => 'checkbox', 'tags' => 'name="' . self::SHOW_HOME . '"', 'value' => qa_opt(self::SHOW_HOME)), self::TRUNCATE_LENGTH => array('label' => qa_lang('breadcrumbs/opt_truncate'), 'type' => 'text', 'tags' => 'name="' . self::TRUNCATE_LENGTH . '"', 'value' => qa_opt(self::TRUNCATE_LENGTH)), self::NO_LINK_AT_LAST_ELEM => array('label' => qa_lang('breadcrumbs/dont_use_link_for_last_elem'), 'type' => 'checkbox', 'tags' => 'name="' . self::NO_LINK_AT_LAST_ELEM . '"', 'value' => qa_opt(self::NO_LINK_AT_LAST_ELEM)), self::DONT_USE_ICONS => array('label' => qa_lang('breadcrumbs/dont_use_icons'), 'type' => 'checkbox', 'tags' => 'name="' . self::DONT_USE_ICONS . '"', 'value' => qa_opt(self::DONT_USE_ICONS)), self::USE_FA_CDN => array('label' => qa_lang('breadcrumbs/use_fa_cdn'), 'type' => 'checkbox', 'tags' => 'name="' . self::USE_FA_CDN . '"', 'value' => qa_opt(self::USE_FA_CDN)), self::FA_CDN => array('label' => qa_lang('breadcrumbs/fa_cdn_link'), 'type' => 'text', 'tags' => 'name="' . self::FA_CDN . '"', 'value' => qa_opt(self::FA_CDN)), self::CUSTOM_CSS => array('label' => qa_lang('breadcrumbs/custom_css'), 'type' => 'textarea', 'rows' => 10, 'tags' => 'name="' . self::CUSTOM_CSS . '"', 'value' => qa_opt(self::CUSTOM_CSS))), 'buttons' => array(array('label' => qa_lang('breadcrumbs/save_changes'), 'tags' => 'name="' . self::SAVE_BUTTON . '"')));
 }
 function process_request($request)
 {
     $message = '';
     $url = '';
     if (is_array($_FILES) && count($_FILES)) {
         if (!qa_opt('wysiwyg_editor_upload_images')) {
             $message = qa_lang('users/no_permission');
         }
         require_once QA_INCLUDE_DIR . 'qa-app-upload.php';
         $upload = qa_upload_file_one(qa_opt('wysiwyg_editor_upload_max_size'), qa_get('qa_only_image') || !qa_opt('wysiwyg_editor_upload_all'), qa_get('qa_only_image') ? 600 : null, null);
         $message = @$upload['error'];
         $url = @$upload['bloburl'];
     }
     echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction(" . qa_js(qa_get('CKEditorFuncNum')) . ", " . qa_js($url) . ", " . qa_js($message) . ");</script>";
     return null;
 }