Commit 41f86fe8 by Scott

Controller: Admin pages

parent 9bb4effd
...@@ -421,9 +421,7 @@ function qa_page_routing() ...@@ -421,9 +421,7 @@ function qa_page_routing()
'admin/moderate' => 'pages/admin/admin-moderate.php', 'admin/moderate' => 'pages/admin/admin-moderate.php',
'admin/pages' => 'pages/admin/admin-pages.php', 'admin/pages' => 'pages/admin/admin-pages.php',
'admin/plugins' => 'pages/admin/admin-plugins.php', 'admin/plugins' => 'pages/admin/admin-plugins.php',
'admin/points' => 'pages/admin/admin-points.php',
'admin/recalc' => 'pages/admin/admin-recalc.php', 'admin/recalc' => 'pages/admin/admin-recalc.php',
'admin/stats' => 'pages/admin/admin-stats.php',
'admin/userfields' => 'pages/admin/admin-userfields.php', 'admin/userfields' => 'pages/admin/admin-userfields.php',
'admin/usertitles' => 'pages/admin/admin-usertitles.php', 'admin/usertitles' => 'pages/admin/admin-usertitles.php',
'answers/' => 'pages/answers.php', 'answers/' => 'pages/answers.php',
...@@ -476,6 +474,10 @@ function qa_routing_config() ...@@ -476,6 +474,10 @@ function qa_routing_config()
$router->addRoute('ip', 'get', 'ip/{str}', '\Q2A\Controllers\User\Ip', 'address'); $router->addRoute('ip', 'get', 'ip/{str}', '\Q2A\Controllers\User\Ip', 'address');
$router->addRoute('ip', 'post', 'ip/{str}', '\Q2A\Controllers\User\Ip', 'address'); $router->addRoute('ip', 'post', 'ip/{str}', '\Q2A\Controllers\User\Ip', 'address');
$router->addRoute('admin-stats', 'get', 'admin/stats', '\Q2A\Controllers\Admin\Stats', 'index');
$router->addRoute('admin-points', 'get', 'admin/points', '\Q2A\Controllers\Admin\Points', 'index');
$router->addRoute('admin-points', 'post', 'admin/points', '\Q2A\Controllers\Admin\Points', 'index');
} }
......
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ http://www.question2answer.org/
Description: Controller for admin page for settings about user points
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -19,166 +16,174 @@ ...@@ -19,166 +16,174 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser namespace Q2A\Controllers\Admin;
header('Location: ../../../');
exit;
}
require_once QA_INCLUDE_DIR . 'db/recalc.php'; use Q2A\Auth\NoPermissionException;
require_once QA_INCLUDE_DIR . 'db/points.php'; use Q2A\Middleware\Auth\MinimumUserLevel;
require_once QA_INCLUDE_DIR . 'app/options.php';
require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR . 'util/sort.php';
/**
* Controller for admin page for settings about user points
*/
class Points extends \Q2A\Controllers\BaseController
{
public function __construct()
{
require_once QA_INCLUDE_DIR . 'db/recalc.php';
require_once QA_INCLUDE_DIR . 'db/points.php';
require_once QA_INCLUDE_DIR . 'app/options.php';
require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR . 'util/sort.php';
// Check admin privileges parent::__construct();
if (!qa_admin_check_privileges($qa_content)) {
return $qa_content;
}
$this->addMiddleware(new MinimumUserLevel(QA_USER_LEVEL_ADMIN));
}
// Process user actions public function index()
{
// Process user actions
$securityexpired = false; $securityexpired = false;
$recalculate = false; $recalculate = false;
$optionnames = qa_db_points_option_names(); $optionnames = qa_db_points_option_names();
if (qa_clicked('doshowdefaults')) { if (qa_clicked('doshowdefaults')) {
$options = array(); $options = array();
foreach ($optionnames as $optionname) {
$options[$optionname] = qa_default_option($optionname);
}
} else {
if (qa_clicked('dosaverecalc')) {
if (!qa_check_form_security_code('admin/points', qa_post_text('code'))) {
$securityexpired = true;
} else {
foreach ($optionnames as $optionname) { foreach ($optionnames as $optionname) {
qa_set_option($optionname, (int)qa_post_text('option_' . $optionname)); $options[$optionname] = qa_default_option($optionname);
} }
} else {
if (!qa_post_text('has_js')) { if (qa_clicked('dosaverecalc')) {
qa_redirect('admin/recalc', array('dorecalcpoints' => 1)); if (!qa_check_form_security_code('admin/points', qa_post_text('code'))) {
} else { $securityexpired = true;
$recalculate = true; } else {
foreach ($optionnames as $optionname) {
qa_set_option($optionname, (int)qa_post_text('option_' . $optionname));
}
if (!qa_post_text('has_js')) {
qa_redirect('admin/recalc', array('dorecalcpoints' => 1));
} else {
$recalculate = true;
}
}
} }
}
}
$options = qa_get_options($optionnames); $options = qa_get_options($optionnames);
} }
// Prepare content for theme // Prepare content for theme
$qa_content = qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/points_title'); $qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/points_title');
$qa_content['error'] = $securityexpired ? qa_lang_html('admin/form_security_expired') : qa_admin_page_error(); $qa_content['error'] = $securityexpired ? qa_lang_html('admin/form_security_expired') : qa_admin_page_error();
$qa_content['form'] = array( $qa_content['form'] = array(
'tags' => 'method="post" action="' . qa_self_html() . '" name="points_form" onsubmit="document.forms.points_form.has_js.value=1; return true;"', 'tags' => 'method="post" action="' . qa_self_html() . '" name="points_form" onsubmit="document.forms.points_form.has_js.value=1; return true;"',
'style' => 'wide', 'style' => 'wide',
'buttons' => array( 'buttons' => array(
'saverecalc' => array( 'saverecalc' => array(
'tags' => 'id="dosaverecalc"', 'tags' => 'id="dosaverecalc"',
'label' => qa_lang_html('admin/save_recalc_button'), 'label' => qa_lang_html('admin/save_recalc_button'),
), ),
), ),
'hidden' => array( 'hidden' => array(
'dosaverecalc' => '1', 'dosaverecalc' => '1',
'has_js' => '0', 'has_js' => '0',
'code' => qa_get_form_security_code('admin/points'), 'code' => qa_get_form_security_code('admin/points'),
), ),
); );
if (qa_clicked('doshowdefaults')) { if (qa_clicked('doshowdefaults')) {
$qa_content['form']['ok'] = qa_lang_html('admin/points_defaults_shown'); $qa_content['form']['ok'] = qa_lang_html('admin/points_defaults_shown');
$qa_content['form']['buttons']['cancel'] = array( $qa_content['form']['buttons']['cancel'] = array(
'tags' => 'name="docancel"', 'tags' => 'name="docancel"',
'label' => qa_lang_html('main/cancel_button'), 'label' => qa_lang_html('main/cancel_button'),
); );
} else { } else {
if ($recalculate) { if ($recalculate) {
$qa_content['form']['ok'] = '<span id="recalc_ok"></span>'; $qa_content['form']['ok'] = '<span id="recalc_ok"></span>';
$qa_content['form']['hidden']['code_recalc'] = qa_get_form_security_code('admin/recalc'); $qa_content['form']['hidden']['code_recalc'] = qa_get_form_security_code('admin/recalc');
$qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION; $qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
$qa_content['script_var']['qa_warning_recalc'] = qa_lang('admin/stop_recalc_warning'); $qa_content['script_var']['qa_warning_recalc'] = qa_lang('admin/stop_recalc_warning');
$qa_content['script_onloads'][] = array( $qa_content['script_onloads'][] = array(
"qa_recalc_click('dorecalcpoints', document.getElementById('dosaverecalc'), null, 'recalc_ok');" "qa_recalc_click('dorecalcpoints', document.getElementById('dosaverecalc'), null, 'recalc_ok');"
); );
} }
$qa_content['form']['buttons']['showdefaults'] = array( $qa_content['form']['buttons']['showdefaults'] = array(
'tags' => 'name="doshowdefaults"', 'tags' => 'name="doshowdefaults"',
'label' => qa_lang_html('admin/show_defaults_button'), 'label' => qa_lang_html('admin/show_defaults_button'),
); );
} }
foreach ($optionnames as $optionname) { foreach ($optionnames as $optionname) {
$optionfield = array( $optionfield = array(
'label' => qa_lang_html('options/' . $optionname), 'label' => qa_lang_html('options/' . $optionname),
'tags' => 'name="option_' . $optionname . '"', 'tags' => 'name="option_' . $optionname . '"',
'value' => qa_html($options[$optionname]), 'value' => qa_html($options[$optionname]),
'type' => 'number', 'type' => 'number',
'note' => qa_lang_html('admin/points'), 'note' => qa_lang_html('admin/points'),
); );
switch ($optionname) { switch ($optionname) {
case 'points_multiple': case 'points_multiple':
$prefix = '&#215;'; $prefix = '&#215;';
unset($optionfield['note']); unset($optionfield['note']);
break; break;
case 'points_per_q_voted_up': case 'points_per_q_voted_up':
case 'points_per_a_voted_up': case 'points_per_a_voted_up':
case 'points_per_c_voted_up': case 'points_per_c_voted_up':
case 'points_q_voted_max_gain': case 'points_q_voted_max_gain':
case 'points_a_voted_max_gain': case 'points_a_voted_max_gain':
case 'points_c_voted_max_gain': case 'points_c_voted_max_gain':
$prefix = '+'; $prefix = '+';
break; break;
case 'points_per_q_voted_down': case 'points_per_q_voted_down':
case 'points_per_a_voted_down': case 'points_per_a_voted_down':
case 'points_per_c_voted_down': case 'points_per_c_voted_down':
case 'points_q_voted_max_loss': case 'points_q_voted_max_loss':
case 'points_a_voted_max_loss': case 'points_a_voted_max_loss':
case 'points_c_voted_max_loss': case 'points_c_voted_max_loss':
$prefix = '&ndash;'; $prefix = '&ndash;';
break; break;
case 'points_base': case 'points_base':
$prefix = '+'; $prefix = '+';
break; break;
default: default:
$prefix = '<span style="visibility:hidden;">+</span>'; // for even alignment $prefix = '<span style="visibility:hidden;">+</span>'; // for even alignment
break; break;
} }
$optionfield['prefix'] = '<span style="width:1em; display:inline-block; display:-moz-inline-stack;">' . $prefix . '</span>'; $optionfield['prefix'] = '<span style="width:1em; display:inline-block; display:-moz-inline-stack;">' . $prefix . '</span>';
$qa_content['form']['fields'][$optionname] = $optionfield; $qa_content['form']['fields'][$optionname] = $optionfield;
} }
qa_array_insert($qa_content['form']['fields'], 'points_post_a', array('blank0' => array('type' => 'blank'))); qa_array_insert($qa_content['form']['fields'], 'points_post_a', array('blank0' => array('type' => 'blank')));
qa_array_insert($qa_content['form']['fields'], 'points_per_c_voted_up', array('blank1' => array('type' => 'blank'))); qa_array_insert($qa_content['form']['fields'], 'points_per_c_voted_up', array('blank1' => array('type' => 'blank')));
qa_array_insert($qa_content['form']['fields'], 'points_vote_up_q', array('blank2' => array('type' => 'blank'))); qa_array_insert($qa_content['form']['fields'], 'points_vote_up_q', array('blank2' => array('type' => 'blank')));
qa_array_insert($qa_content['form']['fields'], 'points_multiple', array('blank3' => array('type' => 'blank'))); qa_array_insert($qa_content['form']['fields'], 'points_multiple', array('blank3' => array('type' => 'blank')));
$qa_content['navigation']['sub'] = qa_admin_sub_navigation(); $qa_content['navigation']['sub'] = qa_admin_sub_navigation();
return $qa_content; return $qa_content;
}
}
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
Question2Answer by Gideon Greenspan and contributors Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/ http://www.question2answer.org/
Description: Controller for admin page showing usage statistics and clean-up buttons
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
...@@ -19,270 +16,279 @@ ...@@ -19,270 +16,279 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser namespace Q2A\Controllers\Admin;
header('Location: ../../../');
exit;
}
require_once QA_INCLUDE_DIR . 'db/recalc.php';
require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR . 'db/admin.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
// Check admin privileges (do late to allow one DB query)
if (!qa_admin_check_privileges($qa_content))
return $qa_content;
// Get the information to display
$qcount = (int)qa_opt('cache_qcount');
$qcount_anon = qa_db_count_posts('Q', false);
$qcount_unans = (int)qa_opt('cache_unaqcount');
$acount = (int)qa_opt('cache_acount');
$acount_anon = qa_db_count_posts('A', false);
$ccount = (int)qa_opt('cache_ccount');
$ccount_anon = qa_db_count_posts('C', false);
// Prepare content for theme
$qa_content = qa_content_prepare(); use Q2A\Auth\NoPermissionException;
use Q2A\Middleware\Auth\MinimumUserLevel;
$qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/stats_title'); /**
* Controller for admin page showing usage statistics and clean-up buttons
*/
class Stats extends \Q2A\Controllers\BaseController
{
public function __construct()
{
require_once QA_INCLUDE_DIR . 'db/recalc.php';
require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR . 'db/admin.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
$qa_content['error'] = qa_admin_page_error(); parent::__construct();
$qa_content['form'] = array( $this->addMiddleware(new MinimumUserLevel(QA_USER_LEVEL_ADMIN));
'style' => 'wide', }
'fields' => array(
'q2a_version' => array(
'label' => qa_lang_html('admin/q2a_version'),
'value' => qa_html(QA_VERSION),
),
'q2a_date' => array(
'label' => qa_lang_html('admin/q2a_build_date'),
'value' => qa_html(QA_BUILD_DATE),
),
'q2a_latest' => array(
'label' => qa_lang_html('admin/q2a_latest_version'),
'type' => 'custom',
'html' => '<span id="q2a-version">...</span>',
),
'break0' => array(
'type' => 'blank',
),
'db_version' => array( public function index()
'label' => qa_lang_html('admin/q2a_db_version'), {
'value' => qa_html(qa_opt('db_version')), // Get the information to display
),
'db_size' => array( $qcount = (int)qa_opt('cache_qcount');
'label' => qa_lang_html('admin/q2a_db_size'), $qcount_anon = qa_db_count_posts('Q', false);
'value' => qa_html(qa_format_number(qa_db_table_size() / 1048576, 1) . ' MB'), $qcount_unans = (int)qa_opt('cache_unaqcount');
),
'break1' => array( $acount = (int)qa_opt('cache_acount');
'type' => 'blank', $acount_anon = qa_db_count_posts('A', false);
),
'php_version' => array( $ccount = (int)qa_opt('cache_ccount');
'label' => qa_lang_html('admin/php_version'), $ccount_anon = qa_db_count_posts('C', false);
'value' => qa_html(phpversion()),
),
'mysql_version' => array(
'label' => qa_lang_html('admin/mysql_version'),
'value' => qa_html(qa_db_mysql_version()),
),
'break2' => array( // Prepare content for theme
'type' => 'blank',
),
'qcount' => array( $qa_content = qa_content_prepare();
'label' => qa_lang_html('admin/total_qs'),
'value' => qa_html(qa_format_number($qcount)),
),
'qcount_unans' => array( $qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/stats_title');
'label' => qa_lang_html('admin/total_qs_unans'),
'value' => qa_html(qa_format_number($qcount_unans)),
),
'qcount_users' => array( $qa_content['error'] = qa_admin_page_error();
'label' => qa_lang_html('admin/from_users'),
'value' => qa_html(qa_format_number($qcount - $qcount_anon)),
),
'qcount_anon' => array( $qa_content['form'] = array(
'label' => qa_lang_html('admin/from_anon'), 'style' => 'wide',
'value' => qa_html(qa_format_number($qcount_anon)),
),
'break3' => array( 'fields' => array(
'type' => 'blank', 'q2a_version' => array(
), 'label' => qa_lang_html('admin/q2a_version'),
'value' => qa_html(QA_VERSION),
'acount' => array( ),
'label' => qa_lang_html('admin/total_as'),
'value' => qa_html(qa_format_number($acount)), 'q2a_date' => array(
), 'label' => qa_lang_html('admin/q2a_build_date'),
'value' => qa_html(QA_BUILD_DATE),
'acount_users' => array( ),
'label' => qa_lang_html('admin/from_users'),
'value' => qa_html(qa_format_number($acount - $acount_anon)),
),
'acount_anon' => array(
'label' => qa_lang_html('admin/from_anon'),
'value' => qa_html(qa_format_number($acount_anon)),
),
'break4' => array(
'type' => 'blank',
),
'ccount' => array(
'label' => qa_lang_html('admin/total_cs'),
'value' => qa_html(qa_format_number($ccount)),
),
'ccount_users' => array(
'label' => qa_lang_html('admin/from_users'),
'value' => qa_html(qa_format_number($ccount - $ccount_anon)),
),
'ccount_anon' => array(
'label' => qa_lang_html('admin/from_anon'),
'value' => qa_html(qa_format_number($ccount_anon)),
),
'break5' => array(
'type' => 'blank',
),
'users' => array(
'label' => qa_lang_html('admin/users_registered'),
'value' => QA_FINAL_EXTERNAL_USERS ? '' : qa_html(qa_format_number(qa_db_count_users())),
),
'users_active' => array(
'label' => qa_lang_html('admin/users_active'),
'value' => qa_html(qa_format_number((int)qa_opt('cache_userpointscount'))),
),
'users_posted' => array(
'label' => qa_lang_html('admin/users_posted'),
'value' => qa_html(qa_format_number(qa_db_count_active_users('posts'))),
),
'users_voted' => array(
'label' => qa_lang_html('admin/users_voted'),
'value' => qa_html(qa_format_number(qa_db_count_active_users('uservotes'))),
),
),
);
if (QA_FINAL_EXTERNAL_USERS)
unset($qa_content['form']['fields']['users']);
else
unset($qa_content['form']['fields']['users_active']);
foreach ($qa_content['form']['fields'] as $index => $field) {
if (empty($field['type']))
$qa_content['form']['fields'][$index]['type'] = 'static';
}
$qa_content['form_2'] = array( 'q2a_latest' => array(
'tags' => 'method="post" action="' . qa_path_html('admin/recalc') . '"', 'label' => qa_lang_html('admin/q2a_latest_version'),
'type' => 'custom',
'title' => qa_lang_html('admin/database_cleanup'), 'html' => '<span id="q2a-version">...</span>',
),
'style' => 'basic',
'break0' => array(
'buttons' => array( 'type' => 'blank',
'recount_posts' => array( ),
'label' => qa_lang_html('admin/recount_posts'),
'tags' => 'name="dorecountposts" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recount_posts_stop')) . ', \'recount_posts_note\');"', 'db_version' => array(
'note' => '<span id="recount_posts_note">' . qa_lang_html('admin/recount_posts_note') . '</span>', 'label' => qa_lang_html('admin/q2a_db_version'),
), 'value' => qa_html(qa_opt('db_version')),
),
'reindex_content' => array(
'label' => qa_lang_html('admin/reindex_content'), 'db_size' => array(
'tags' => 'name="doreindexcontent" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/reindex_content_stop')) . ', \'reindex_content_note\');"', 'label' => qa_lang_html('admin/q2a_db_size'),
'note' => '<span id="reindex_content_note">' . qa_lang_html('admin/reindex_content_note') . '</span>', 'value' => qa_html(qa_format_number(qa_db_table_size() / 1048576, 1) . ' MB'),
), ),
'recalc_points' => array( 'break1' => array(
'label' => qa_lang_html('admin/recalc_points'), 'type' => 'blank',
'tags' => 'name="dorecalcpoints" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recalc_stop')) . ', \'recalc_points_note\');"', ),
'note' => '<span id="recalc_points_note">' . qa_lang_html('admin/recalc_points_note') . '</span>',
), 'php_version' => array(
'label' => qa_lang_html('admin/php_version'),
'refill_events' => array( 'value' => qa_html(phpversion()),
'label' => qa_lang_html('admin/refill_events'), ),
'tags' => 'name="dorefillevents" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recalc_stop')) . ', \'refill_events_note\');"',
'note' => '<span id="refill_events_note">' . qa_lang_html('admin/refill_events_note') . '</span>', 'mysql_version' => array(
), 'label' => qa_lang_html('admin/mysql_version'),
'value' => qa_html(qa_db_mysql_version()),
'recalc_categories' => array( ),
'label' => qa_lang_html('admin/recalc_categories'),
'tags' => 'name="dorecalccategories" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recalc_stop')) . ', \'recalc_categories_note\');"', 'break2' => array(
'note' => '<span id="recalc_categories_note">' . qa_lang_html('admin/recalc_categories_note') . '</span>', 'type' => 'blank',
), ),
'delete_hidden' => array( 'qcount' => array(
'label' => qa_lang_html('admin/delete_hidden'), 'label' => qa_lang_html('admin/total_qs'),
'tags' => 'name="dodeletehidden" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/delete_stop')) . ', \'delete_hidden_note\');"', 'value' => qa_html(qa_format_number($qcount)),
'note' => '<span id="delete_hidden_note">' . qa_lang_html('admin/delete_hidden_note') . '</span>', ),
),
), 'qcount_unans' => array(
'label' => qa_lang_html('admin/total_qs_unans'),
'hidden' => array( 'value' => qa_html(qa_format_number($qcount_unans)),
'code' => qa_get_form_security_code('admin/recalc'), ),
),
); 'qcount_users' => array(
'label' => qa_lang_html('admin/from_users'),
if (!qa_using_categories()) 'value' => qa_html(qa_format_number($qcount - $qcount_anon)),
unset($qa_content['form_2']['buttons']['recalc_categories']); ),
if (defined('QA_BLOBS_DIRECTORY')) { 'qcount_anon' => array(
if (qa_db_has_blobs_in_db()) { 'label' => qa_lang_html('admin/from_anon'),
$qa_content['form_2']['buttons']['blobs_to_disk'] = array( 'value' => qa_html(qa_format_number($qcount_anon)),
'label' => qa_lang_html('admin/blobs_to_disk'), ),
'tags' => 'name="doblobstodisk" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/blobs_stop')) . ', \'blobs_to_disk_note\');"',
'note' => '<span id="blobs_to_disk_note">' . qa_lang_html('admin/blobs_to_disk_note') . '</span>', 'break3' => array(
'type' => 'blank',
),
'acount' => array(
'label' => qa_lang_html('admin/total_as'),
'value' => qa_html(qa_format_number($acount)),
),
'acount_users' => array(
'label' => qa_lang_html('admin/from_users'),
'value' => qa_html(qa_format_number($acount - $acount_anon)),
),
'acount_anon' => array(
'label' => qa_lang_html('admin/from_anon'),
'value' => qa_html(qa_format_number($acount_anon)),
),
'break4' => array(
'type' => 'blank',
),
'ccount' => array(
'label' => qa_lang_html('admin/total_cs'),
'value' => qa_html(qa_format_number($ccount)),
),
'ccount_users' => array(
'label' => qa_lang_html('admin/from_users'),
'value' => qa_html(qa_format_number($ccount - $ccount_anon)),
),
'ccount_anon' => array(
'label' => qa_lang_html('admin/from_anon'),
'value' => qa_html(qa_format_number($ccount_anon)),
),
'break5' => array(
'type' => 'blank',
),
'users' => array(
'label' => qa_lang_html('admin/users_registered'),
'value' => QA_FINAL_EXTERNAL_USERS ? '' : qa_html(qa_format_number(qa_db_count_users())),
),
'users_active' => array(
'label' => qa_lang_html('admin/users_active'),
'value' => qa_html(qa_format_number((int)qa_opt('cache_userpointscount'))),
),
'users_posted' => array(
'label' => qa_lang_html('admin/users_posted'),
'value' => qa_html(qa_format_number(qa_db_count_active_users('posts'))),
),
'users_voted' => array(
'label' => qa_lang_html('admin/users_voted'),
'value' => qa_html(qa_format_number(qa_db_count_active_users('uservotes'))),
),
),
); );
}
if (qa_db_has_blobs_on_disk()) { if (QA_FINAL_EXTERNAL_USERS)
$qa_content['form_2']['buttons']['blobs_to_db'] = array( unset($qa_content['form']['fields']['users']);
'label' => qa_lang_html('admin/blobs_to_db'), else
'tags' => 'name="doblobstodb" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/blobs_stop')) . ', \'blobs_to_db_note\');"', unset($qa_content['form']['fields']['users_active']);
'note' => '<span id="blobs_to_db_note">' . qa_lang_html('admin/blobs_to_db_note') . '</span>',
foreach ($qa_content['form']['fields'] as $index => $field) {
if (empty($field['type']))
$qa_content['form']['fields'][$index]['type'] = 'static';
}
$qa_content['form_2'] = array(
'tags' => 'method="post" action="' . qa_path_html('admin/recalc') . '"',
'title' => qa_lang_html('admin/database_cleanup'),
'style' => 'basic',
'buttons' => array(
'recount_posts' => array(
'label' => qa_lang_html('admin/recount_posts'),
'tags' => 'name="dorecountposts" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recount_posts_stop')) . ', \'recount_posts_note\');"',
'note' => '<span id="recount_posts_note">' . qa_lang_html('admin/recount_posts_note') . '</span>',
),
'reindex_content' => array(
'label' => qa_lang_html('admin/reindex_content'),
'tags' => 'name="doreindexcontent" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/reindex_content_stop')) . ', \'reindex_content_note\');"',
'note' => '<span id="reindex_content_note">' . qa_lang_html('admin/reindex_content_note') . '</span>',
),
'recalc_points' => array(
'label' => qa_lang_html('admin/recalc_points'),
'tags' => 'name="dorecalcpoints" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recalc_stop')) . ', \'recalc_points_note\');"',
'note' => '<span id="recalc_points_note">' . qa_lang_html('admin/recalc_points_note') . '</span>',
),
'refill_events' => array(
'label' => qa_lang_html('admin/refill_events'),
'tags' => 'name="dorefillevents" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recalc_stop')) . ', \'refill_events_note\');"',
'note' => '<span id="refill_events_note">' . qa_lang_html('admin/refill_events_note') . '</span>',
),
'recalc_categories' => array(
'label' => qa_lang_html('admin/recalc_categories'),
'tags' => 'name="dorecalccategories" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/recalc_stop')) . ', \'recalc_categories_note\');"',
'note' => '<span id="recalc_categories_note">' . qa_lang_html('admin/recalc_categories_note') . '</span>',
),
'delete_hidden' => array(
'label' => qa_lang_html('admin/delete_hidden'),
'tags' => 'name="dodeletehidden" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/delete_stop')) . ', \'delete_hidden_note\');"',
'note' => '<span id="delete_hidden_note">' . qa_lang_html('admin/delete_hidden_note') . '</span>',
),
),
'hidden' => array(
'code' => qa_get_form_security_code('admin/recalc'),
),
); );
}
}
$qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
$qa_content['script_var']['qa_warning_recalc'] = qa_lang('admin/stop_recalc_warning');
$qa_content['script_onloads'][] = array( if (!qa_using_categories())
"qa_version_check('https://raw.githubusercontent.com/q2a/question2answer/master/VERSION.txt', " . qa_js(qa_html(QA_VERSION), true) . ", 'q2a-version', true);" unset($qa_content['form_2']['buttons']['recalc_categories']);
);
if (defined('QA_BLOBS_DIRECTORY')) {
if (qa_db_has_blobs_in_db()) {
$qa_content['form_2']['buttons']['blobs_to_disk'] = array(
'label' => qa_lang_html('admin/blobs_to_disk'),
'tags' => 'name="doblobstodisk" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/blobs_stop')) . ', \'blobs_to_disk_note\');"',
'note' => '<span id="blobs_to_disk_note">' . qa_lang_html('admin/blobs_to_disk_note') . '</span>',
);
}
if (qa_db_has_blobs_on_disk()) {
$qa_content['form_2']['buttons']['blobs_to_db'] = array(
'label' => qa_lang_html('admin/blobs_to_db'),
'tags' => 'name="doblobstodb" onclick="return qa_recalc_click(this.name, this, ' . qa_js(qa_lang_html('admin/blobs_stop')) . ', \'blobs_to_db_note\');"',
'note' => '<span id="blobs_to_db_note">' . qa_lang_html('admin/blobs_to_db_note') . '</span>',
);
}
}
$qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
$qa_content['script_var']['qa_warning_recalc'] = qa_lang('admin/stop_recalc_warning');
$qa_content['script_onloads'][] = array(
"qa_version_check('https://raw.githubusercontent.com/q2a/question2answer/master/VERSION.txt', " . qa_js(qa_html(QA_VERSION), true) . ", 'q2a-version', true);"
);
$qa_content['navigation']['sub'] = qa_admin_sub_navigation(); $qa_content['navigation']['sub'] = qa_admin_sub_navigation();
return $qa_content; return $qa_content;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment