Commit 41f86fe8 by Scott

Controller: Admin pages

parent 9bb4effd
......@@ -421,9 +421,7 @@ function qa_page_routing()
'admin/moderate' => 'pages/admin/admin-moderate.php',
'admin/pages' => 'pages/admin/admin-pages.php',
'admin/plugins' => 'pages/admin/admin-plugins.php',
'admin/points' => 'pages/admin/admin-points.php',
'admin/recalc' => 'pages/admin/admin-recalc.php',
'admin/stats' => 'pages/admin/admin-stats.php',
'admin/userfields' => 'pages/admin/admin-userfields.php',
'admin/usertitles' => 'pages/admin/admin-usertitles.php',
'answers/' => 'pages/answers.php',
......@@ -476,6 +474,10 @@ function qa_routing_config()
$router->addRoute('ip', 'get', '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 @@
Question2Answer by Gideon Greenspan and contributors
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
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
......@@ -19,166 +16,174 @@
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
header('Location: ../../../');
exit;
}
namespace Q2A\Controllers\Admin;
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';
use Q2A\Auth\NoPermissionException;
use Q2A\Middleware\Auth\MinimumUserLevel;
/**
* 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
if (!qa_admin_check_privileges($qa_content)) {
return $qa_content;
}
parent::__construct();
$this->addMiddleware(new MinimumUserLevel(QA_USER_LEVEL_ADMIN));
}
// Process user actions
public function index()
{
// Process user actions
$securityexpired = false;
$recalculate = false;
$optionnames = qa_db_points_option_names();
$securityexpired = false;
$recalculate = false;
$optionnames = qa_db_points_option_names();
if (qa_clicked('doshowdefaults')) {
$options = array();
if (qa_clicked('doshowdefaults')) {
$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) {
qa_set_option($optionname, (int)qa_post_text('option_' . $optionname));
$options[$optionname] = qa_default_option($optionname);
}
if (!qa_post_text('has_js')) {
qa_redirect('admin/recalc', array('dorecalcpoints' => 1));
} else {
$recalculate = true;
} else {
if (qa_clicked('dosaverecalc')) {
if (!qa_check_form_security_code('admin/points', qa_post_text('code'))) {
$securityexpired = 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['error'] = $securityexpired ? qa_lang_html('admin/form_security_expired') : qa_admin_page_error();
$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['form'] = array(
'tags' => 'method="post" action="' . qa_self_html() . '" name="points_form" onsubmit="document.forms.points_form.has_js.value=1; return true;"',
$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;"',
'style' => 'wide',
'style' => 'wide',
'buttons' => array(
'saverecalc' => array(
'tags' => 'id="dosaverecalc"',
'label' => qa_lang_html('admin/save_recalc_button'),
),
),
'buttons' => array(
'saverecalc' => array(
'tags' => 'id="dosaverecalc"',
'label' => qa_lang_html('admin/save_recalc_button'),
),
),
'hidden' => array(
'dosaverecalc' => '1',
'has_js' => '0',
'code' => qa_get_form_security_code('admin/points'),
),
);
'hidden' => array(
'dosaverecalc' => '1',
'has_js' => '0',
'code' => qa_get_form_security_code('admin/points'),
),
);
if (qa_clicked('doshowdefaults')) {
$qa_content['form']['ok'] = qa_lang_html('admin/points_defaults_shown');
if (qa_clicked('doshowdefaults')) {
$qa_content['form']['ok'] = qa_lang_html('admin/points_defaults_shown');
$qa_content['form']['buttons']['cancel'] = array(
'tags' => 'name="docancel"',
'label' => qa_lang_html('main/cancel_button'),
);
} else {
if ($recalculate) {
$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']['buttons']['cancel'] = array(
'tags' => 'name="docancel"',
'label' => qa_lang_html('main/cancel_button'),
);
} else {
if ($recalculate) {
$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_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
$qa_content['script_var']['qa_warning_recalc'] = qa_lang('admin/stop_recalc_warning');
$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_recalc_click('dorecalcpoints', document.getElementById('dosaverecalc'), null, 'recalc_ok');"
);
}
$qa_content['script_onloads'][] = array(
"qa_recalc_click('dorecalcpoints', document.getElementById('dosaverecalc'), null, 'recalc_ok');"
);
}
$qa_content['form']['buttons']['showdefaults'] = array(
'tags' => 'name="doshowdefaults"',
'label' => qa_lang_html('admin/show_defaults_button'),
);
}
$qa_content['form']['buttons']['showdefaults'] = array(
'tags' => 'name="doshowdefaults"',
'label' => qa_lang_html('admin/show_defaults_button'),
);
}
foreach ($optionnames as $optionname) {
$optionfield = array(
'label' => qa_lang_html('options/' . $optionname),
'tags' => 'name="option_' . $optionname . '"',
'value' => qa_html($options[$optionname]),
'type' => 'number',
'note' => qa_lang_html('admin/points'),
);
switch ($optionname) {
case 'points_multiple':
$prefix = '&#215;';
unset($optionfield['note']);
break;
case 'points_per_q_voted_up':
case 'points_per_a_voted_up':
case 'points_per_c_voted_up':
case 'points_q_voted_max_gain':
case 'points_a_voted_max_gain':
case 'points_c_voted_max_gain':
$prefix = '+';
break;
case 'points_per_q_voted_down':
case 'points_per_a_voted_down':
case 'points_per_c_voted_down':
case 'points_q_voted_max_loss':
case 'points_a_voted_max_loss':
case 'points_c_voted_max_loss':
$prefix = '&ndash;';
break;
case 'points_base':
$prefix = '+';
break;
default:
$prefix = '<span style="visibility:hidden;">+</span>'; // for even alignment
break;
}
foreach ($optionnames as $optionname) {
$optionfield = array(
'label' => qa_lang_html('options/' . $optionname),
'tags' => 'name="option_' . $optionname . '"',
'value' => qa_html($options[$optionname]),
'type' => 'number',
'note' => qa_lang_html('admin/points'),
);
switch ($optionname) {
case 'points_multiple':
$prefix = '&#215;';
unset($optionfield['note']);
break;
case 'points_per_q_voted_up':
case 'points_per_a_voted_up':
case 'points_per_c_voted_up':
case 'points_q_voted_max_gain':
case 'points_a_voted_max_gain':
case 'points_c_voted_max_gain':
$prefix = '+';
break;
case 'points_per_q_voted_down':
case 'points_per_a_voted_down':
case 'points_per_c_voted_down':
case 'points_q_voted_max_loss':
case 'points_a_voted_max_loss':
case 'points_c_voted_max_loss':
$prefix = '&ndash;';
break;
case 'points_base':
$prefix = '+';
break;
default:
$prefix = '<span style="visibility:hidden;">+</span>'; // for even alignment
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_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_multiple', array('blank3' => 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_vote_up_q', array('blank2' => 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 @@
Question2Answer by Gideon Greenspan and contributors
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
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
......@@ -19,270 +16,279 @@
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
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
namespace Q2A\Controllers\Admin;
$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(
'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',
),
$this->addMiddleware(new MinimumUserLevel(QA_USER_LEVEL_ADMIN));
}
'db_version' => array(
'label' => qa_lang_html('admin/q2a_db_version'),
'value' => qa_html(qa_opt('db_version')),
),
public function index()
{
// Get the information to display
'db_size' => array(
'label' => qa_lang_html('admin/q2a_db_size'),
'value' => qa_html(qa_format_number(qa_db_table_size() / 1048576, 1) . ' MB'),
),
$qcount = (int)qa_opt('cache_qcount');
$qcount_anon = qa_db_count_posts('Q', false);
$qcount_unans = (int)qa_opt('cache_unaqcount');
'break1' => array(
'type' => 'blank',
),
$acount = (int)qa_opt('cache_acount');
$acount_anon = qa_db_count_posts('A', false);
'php_version' => array(
'label' => qa_lang_html('admin/php_version'),
'value' => qa_html(phpversion()),
),
$ccount = (int)qa_opt('cache_ccount');
$ccount_anon = qa_db_count_posts('C', false);
'mysql_version' => array(
'label' => qa_lang_html('admin/mysql_version'),
'value' => qa_html(qa_db_mysql_version()),
),
'break2' => array(
'type' => 'blank',
),
// Prepare content for theme
'qcount' => array(
'label' => qa_lang_html('admin/total_qs'),
'value' => qa_html(qa_format_number($qcount)),
),
$qa_content = qa_content_prepare();
'qcount_unans' => array(
'label' => qa_lang_html('admin/total_qs_unans'),
'value' => qa_html(qa_format_number($qcount_unans)),
),
$qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/stats_title');
'qcount_users' => array(
'label' => qa_lang_html('admin/from_users'),
'value' => qa_html(qa_format_number($qcount - $qcount_anon)),
),
$qa_content['error'] = qa_admin_page_error();
'qcount_anon' => array(
'label' => qa_lang_html('admin/from_anon'),
'value' => qa_html(qa_format_number($qcount_anon)),
),
$qa_content['form'] = array(
'style' => 'wide',
'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_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';
}
'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),
),
$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'),
),
);
if (!qa_using_categories())
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>',
'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(
'label' => qa_lang_html('admin/q2a_db_version'),
'value' => qa_html(qa_opt('db_version')),
),
'db_size' => array(
'label' => qa_lang_html('admin/q2a_db_size'),
'value' => qa_html(qa_format_number(qa_db_table_size() / 1048576, 1) . ' MB'),
),
'break1' => array(
'type' => 'blank',
),
'php_version' => array(
'label' => qa_lang_html('admin/php_version'),
'value' => qa_html(phpversion()),
),
'mysql_version' => array(
'label' => qa_lang_html('admin/mysql_version'),
'value' => qa_html(qa_db_mysql_version()),
),
'break2' => array(
'type' => 'blank',
),
'qcount' => array(
'label' => qa_lang_html('admin/total_qs'),
'value' => qa_html(qa_format_number($qcount)),
),
'qcount_unans' => array(
'label' => qa_lang_html('admin/total_qs_unans'),
'value' => qa_html(qa_format_number($qcount_unans)),
),
'qcount_users' => array(
'label' => qa_lang_html('admin/from_users'),
'value' => qa_html(qa_format_number($qcount - $qcount_anon)),
),
'qcount_anon' => array(
'label' => qa_lang_html('admin/from_anon'),
'value' => qa_html(qa_format_number($qcount_anon)),
),
'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()) {
$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>',
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(
'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(
"qa_version_check('https://raw.githubusercontent.com/q2a/question2answer/master/VERSION.txt', " . qa_js(qa_html(QA_VERSION), true) . ", 'q2a-version', true);"
);
if (!qa_using_categories())
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