Commit 14d54fd4 by Scott

Coding style (admin pages)

parent 2be2b6bb
...@@ -20,53 +20,53 @@ ...@@ -20,53 +20,53 @@
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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'app/admin.php'; require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR.'db/admin.php'; require_once QA_INCLUDE_DIR . 'db/admin.php';
// Check we're not using single-sign on integration // Check we're not using single-sign on integration
if (QA_FINAL_EXTERNAL_USERS) if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User accounts are handled by external code'); qa_fatal_error('User accounts are handled by external code');
// Find most flagged questions, answers, comments // Find most flagged questions, answers, comments
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
$users=qa_db_get_unapproved_users(qa_opt('page_size_users')); $users = qa_db_get_unapproved_users(qa_opt('page_size_users'));
$userfields=qa_db_select_with_pending(qa_db_userfields_selectspec()); $userfields = qa_db_select_with_pending(qa_db_userfields_selectspec());
// Check admin privileges (do late to allow one DB query) // Check admin privileges (do late to allow one DB query)
if (qa_get_logged_in_level()<QA_USER_LEVEL_MODERATOR) { if (qa_get_logged_in_level() < QA_USER_LEVEL_MODERATOR) {
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['error']=qa_lang_html('users/no_permission'); $qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content; return $qa_content;
} }
// Check to see if any were approved or blocked here // Check to see if any were approved or blocked here
$pageerror=qa_admin_check_clicks(); $pageerror = qa_admin_check_clicks();
// 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/approve_users_title'); $qa_content['title'] = qa_lang_html('admin/approve_users_title');
$qa_content['error']=isset($pageerror) ? $pageerror : qa_admin_page_error(); $qa_content['error'] = isset($pageerror) ? $pageerror : qa_admin_page_error();
$qa_content['message_list']=array( $qa_content['message_list'] = array(
'form' => array( 'form' => array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'hidden' => array( 'hidden' => array(
'code' => qa_get_form_security_code('admin/click'), 'code' => qa_get_form_security_code('admin/click'),
...@@ -74,67 +74,64 @@ ...@@ -74,67 +74,64 @@
), ),
'messages' => array(), 'messages' => array(),
); );
if (count($users)) { if (count($users)) {
foreach ($users as $user) { foreach ($users as $user) {
$message=array(); $message = array();
$message['tags']='id="p'.qa_html($user['userid']).'"'; // use p prefix for qa_admin_click() in qa-admin.js $message['tags'] = 'id="p' . qa_html($user['userid']) . '"'; // use p prefix for qa_admin_click() in qa-admin.js
$message['content']=qa_lang_html('users/registered_label').' '. $message['content'] = qa_lang_html('users/registered_label') . ' ' .
strtr(qa_lang_html('users/x_ago_from_y'), array( strtr(qa_lang_html('users/x_ago_from_y'), array(
'^1' => qa_time_to_string(qa_opt('db_time')-$user['created']), '^1' => qa_time_to_string(qa_opt('db_time') - $user['created']),
'^2' => qa_ip_anchor_html(@inet_ntop($user['createip'])), '^2' => qa_ip_anchor_html(@inet_ntop($user['createip'])),
)).'<br/>'; )) . '<br/>';
$htmlemail=qa_html($user['email']); $htmlemail = qa_html($user['email']);
$message['content'].=qa_lang_html('users/email_label').' <a href="mailto:'.$htmlemail.'">'.$htmlemail.'</a>'; $message['content'] .= qa_lang_html('users/email_label') . ' <a href="mailto:' . $htmlemail . '">' . $htmlemail . '</a>';
if (qa_opt('confirm_user_emails')) if (qa_opt('confirm_user_emails')) {
$message['content'].='<small> - '.qa_lang_html(($user['flags'] & QA_USER_FLAGS_EMAIL_CONFIRMED) ? 'users/email_confirmed' : 'users/email_not_confirmed').'</small>'; $message['content'] .= '<small> - ' . qa_lang_html(($user['flags'] & QA_USER_FLAGS_EMAIL_CONFIRMED) ? 'users/email_confirmed' : 'users/email_not_confirmed') . '</small>';
}
foreach ($userfields as $userfield) foreach ($userfields as $userfield) {
if (strlen(@$user['profile'][$userfield['title']])) if (strlen(@$user['profile'][$userfield['title']]))
$message['content'].='<br/>'.qa_html($userfield['content'].': '.$user['profile'][$userfield['title']]); $message['content'] .= '<br/>' . qa_html($userfield['content'] . ': ' . $user['profile'][$userfield['title']]);
}
$message['meta_order']=qa_lang_html('main/meta_order'); $message['meta_order'] = qa_lang_html('main/meta_order');
$message['who']['data']=qa_get_one_user_html($user['handle']); $message['who']['data'] = qa_get_one_user_html($user['handle']);
$message['form']=array( $message['form'] = array(
'style' => 'light', 'style' => 'light',
'buttons' => array( 'buttons' => array(
'approve' => array( 'approve' => array(
'tags' => 'name="admin_'.$user['userid'].'_userapprove" onclick="return qa_admin_click(this);"', 'tags' => 'name="admin_' . $user['userid'] . '_userapprove" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/approve_button'), 'label' => qa_lang_html('question/approve_button'),
'popup' => qa_lang_html('admin/approve_user_popup'), 'popup' => qa_lang_html('admin/approve_user_popup'),
), ),
'block' => array( 'block' => array(
'tags' => 'name="admin_'.$user['userid'].'_userblock" onclick="return qa_admin_click(this);"', 'tags' => 'name="admin_' . $user['userid'] . '_userblock" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('admin/block_button'), 'label' => qa_lang_html('admin/block_button'),
'popup' => qa_lang_html('admin/block_user_popup'), 'popup' => qa_lang_html('admin/block_user_popup'),
), ),
), ),
); );
$qa_content['message_list']['messages'][]=$message; $qa_content['message_list']['messages'][] = $message;
} }
} else } else
$qa_content['title']=qa_lang_html('admin/no_unapproved_found'); $qa_content['title'] = qa_lang_html('admin/no_unapproved_found');
$qa_content['navigation']['sub']=qa_admin_sub_navigation(); $qa_content['navigation']['sub'] = qa_admin_sub_navigation();
$qa_content['script_rel'][]='qa-content/qa-admin.js?'.QA_VERSION; $qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
...@@ -20,62 +20,65 @@ ...@@ -20,62 +20,65 @@
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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'app/admin.php'; require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
// Find most flagged questions, answers, comments // Find most flagged questions, answers, comments
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
$questions=qa_db_select_with_pending( $questions = qa_db_select_with_pending(
qa_db_flagged_post_qs_selectspec($userid, 0, true) qa_db_flagged_post_qs_selectspec($userid, 0, true)
); );
// Check admin privileges (do late to allow one DB query) // Check admin privileges (do late to allow one DB query)
if (qa_user_maximum_permit_error('permit_hide_show')) { if (qa_user_maximum_permit_error('permit_hide_show')) {
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['error']=qa_lang_html('users/no_permission'); $qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content; return $qa_content;
} }
// Check to see if any were cleared or hidden here // Check to see if any were cleared or hidden here
$pageerror=qa_admin_check_clicks(); $pageerror = qa_admin_check_clicks();
// Remove questions the user has no permission to hide/show // Remove questions the user has no permission to hide/show
if (qa_user_permit_error('permit_hide_show')) // if user not allowed to show/hide all posts if (qa_user_permit_error('permit_hide_show')) { // if user not allowed to show/hide all posts
foreach ($questions as $index => $question) foreach ($questions as $index => $question) {
if (qa_user_post_permit_error('permit_hide_show', $question)) if (qa_user_post_permit_error('permit_hide_show', $question)) {
unset($questions[$index]); unset($questions[$index]);
}
}
}
// Get information for users // Get information for users
$usershtml=qa_userids_handles_html(qa_any_get_userids_handles($questions)); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
// 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/most_flagged_title'); $qa_content['title'] = qa_lang_html('admin/most_flagged_title');
$qa_content['error']=isset($pageerror) ? $pageerror : qa_admin_page_error(); $qa_content['error'] = isset($pageerror) ? $pageerror : qa_admin_page_error();
$qa_content['q_list']=array( $qa_content['q_list'] = array(
'form' => array( 'form' => array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'hidden' => array( 'hidden' => array(
'code' => qa_get_form_security_code('admin/click'), 'code' => qa_get_form_security_code('admin/click'),
...@@ -83,58 +86,53 @@ ...@@ -83,58 +86,53 @@
), ),
'qs' => array(), 'qs' => array(),
); );
if (count($questions)) { if (count($questions)) {
foreach ($questions as $question) { foreach ($questions as $question) {
$postid=qa_html(isset($question['opostid']) ? $question['opostid'] : $question['postid']); $postid = qa_html(isset($question['opostid']) ? $question['opostid'] : $question['postid']);
$elementid='p'.$postid; $elementid = 'p' . $postid;
$htmloptions=qa_post_html_options($question); $htmloptions = qa_post_html_options($question);
$htmloptions['voteview']=false; $htmloptions['voteview'] = false;
$htmloptions['tagsview']=($question['obasetype']=='Q'); $htmloptions['tagsview'] = ($question['obasetype'] == 'Q');
$htmloptions['answersview']=false; $htmloptions['answersview'] = false;
$htmloptions['viewsview']=false; $htmloptions['viewsview'] = false;
$htmloptions['contentview']=true; $htmloptions['contentview'] = true;
$htmloptions['flagsview']=true; $htmloptions['flagsview'] = true;
$htmloptions['elementid']=$elementid; $htmloptions['elementid'] = $elementid;
$htmlfields=qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions); $htmlfields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions);
if (isset($htmlfields['what_url'])) // link directly to relevant content if (isset($htmlfields['what_url'])) // link directly to relevant content
$htmlfields['url']=$htmlfields['what_url']; $htmlfields['url'] = $htmlfields['what_url'];
$htmlfields['form']=array( $htmlfields['form'] = array(
'style' => 'light', 'style' => 'light',
'buttons' => array( 'buttons' => array(
'clearflags' => array( 'clearflags' => array(
'tags' => 'name="admin_'.$postid.'_clearflags" onclick="return qa_admin_click(this);"', 'tags' => 'name="admin_' . $postid . '_clearflags" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/clear_flags_button'), 'label' => qa_lang_html('question/clear_flags_button'),
), ),
'hide' => array( 'hide' => array(
'tags' => 'name="admin_'.$postid.'_hide" onclick="return qa_admin_click(this);"', 'tags' => 'name="admin_' . $postid . '_hide" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/hide_button'), 'label' => qa_lang_html('question/hide_button'),
), ),
), ),
); );
$qa_content['q_list']['qs'][]=$htmlfields; $qa_content['q_list']['qs'][] = $htmlfields;
} }
} else } else
$qa_content['title']=qa_lang_html('admin/no_flagged_found'); $qa_content['title'] = qa_lang_html('admin/no_flagged_found');
$qa_content['navigation']['sub']=qa_admin_sub_navigation(); $qa_content['navigation']['sub'] = qa_admin_sub_navigation();
$qa_content['script_rel'][]='qa-content/qa-admin.js?'.QA_VERSION; $qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,76 +20,79 @@ ...@@ -20,76 +20,79 @@
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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'app/admin.php'; require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR.'db/admin.php'; require_once QA_INCLUDE_DIR . 'db/admin.php';
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
// Find recently hidden questions, answers, comments // Find recently hidden questions, answers, comments
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
list($hiddenquestions, $hiddenanswers, $hiddencomments)=qa_db_select_with_pending( list($hiddenquestions, $hiddenanswers, $hiddencomments) = qa_db_select_with_pending(
qa_db_qs_selectspec($userid, 'created', 0, null, null, 'Q_HIDDEN', true), qa_db_qs_selectspec($userid, 'created', 0, null, null, 'Q_HIDDEN', true),
qa_db_recent_a_qs_selectspec($userid, 0, null, null, 'A_HIDDEN', true), qa_db_recent_a_qs_selectspec($userid, 0, null, null, 'A_HIDDEN', true),
qa_db_recent_c_qs_selectspec($userid, 0, null, null, 'C_HIDDEN', true) qa_db_recent_c_qs_selectspec($userid, 0, null, null, 'C_HIDDEN', true)
); );
// Check admin privileges (do late to allow one DB query) // Check admin privileges (do late to allow one DB query)
if (qa_user_maximum_permit_error('permit_hide_show') && qa_user_maximum_permit_error('permit_delete_hidden')) { if (qa_user_maximum_permit_error('permit_hide_show') && qa_user_maximum_permit_error('permit_delete_hidden')) {
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['error']=qa_lang_html('users/no_permission'); $qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content; return $qa_content;
} }
// Check to see if any have been reshown or deleted // Check to see if any have been reshown or deleted
$pageerror=qa_admin_check_clicks(); $pageerror = qa_admin_check_clicks();
// Combine sets of questions and remove those this user has no permissions for // Combine sets of questions and remove those this user has no permissions for
$questions=qa_any_sort_by_date(array_merge($hiddenquestions, $hiddenanswers, $hiddencomments)); $questions = qa_any_sort_by_date(array_merge($hiddenquestions, $hiddenanswers, $hiddencomments));
if (qa_user_permit_error('permit_hide_show') && qa_user_permit_error('permit_delete_hidden')) // not allowed to see all hidden posts if (qa_user_permit_error('permit_hide_show') && qa_user_permit_error('permit_delete_hidden')) { // not allowed to see all hidden posts
foreach ($questions as $index => $question) foreach ($questions as $index => $question) {
if (qa_user_post_permit_error('permit_hide_show', $question) && qa_user_post_permit_error('permit_delete_hidden', $question)) if (qa_user_post_permit_error('permit_hide_show', $question) && qa_user_post_permit_error('permit_delete_hidden', $question)) {
unset($questions[$index]); unset($questions[$index]);
}
}
}
// Get information for users // Get information for users
$usershtml=qa_userids_handles_html(qa_any_get_userids_handles($questions)); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
// Create list of actual hidden postids and see which ones have dependents // Create list of actual hidden postids and see which ones have dependents
$qhiddenpostid=array(); $qhiddenpostid = array();
foreach ($questions as $key => $question) foreach ($questions as $key => $question)
$qhiddenpostid[$key]=isset($question['opostid']) ? $question['opostid'] : $question['postid']; $qhiddenpostid[$key] = isset($question['opostid']) ? $question['opostid'] : $question['postid'];
$dependcounts=qa_db_postids_count_dependents($qhiddenpostid); $dependcounts = qa_db_postids_count_dependents($qhiddenpostid);
// 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/recent_hidden_title'); $qa_content['title'] = qa_lang_html('admin/recent_hidden_title');
$qa_content['error']=isset($pageerror) ? $pageerror : qa_admin_page_error(); $qa_content['error'] = isset($pageerror) ? $pageerror : qa_admin_page_error();
$qa_content['q_list']=array( $qa_content['q_list'] = array(
'form' => array( 'form' => array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'hidden' => array( 'hidden' => array(
'code' => qa_get_form_security_code('admin/click'), 'code' => qa_get_form_security_code('admin/click'),
...@@ -97,75 +100,73 @@ ...@@ -97,75 +100,73 @@
), ),
'qs' => array(), 'qs' => array(),
); );
if (count($questions)) { if (count($questions)) {
foreach ($questions as $key => $question) { foreach ($questions as $key => $question) {
$elementid='p'.$qhiddenpostid[$key]; $elementid = 'p' . $qhiddenpostid[$key];
$htmloptions=qa_post_html_options($question); $htmloptions = qa_post_html_options($question);
$htmloptions['voteview']=false; $htmloptions['voteview'] = false;
$htmloptions['tagsview']=!isset($question['opostid']); $htmloptions['tagsview'] = !isset($question['opostid']);
$htmloptions['answersview']=false; $htmloptions['answersview'] = false;
$htmloptions['viewsview']=false; $htmloptions['viewsview'] = false;
$htmloptions['updateview']=false; $htmloptions['updateview'] = false;
$htmloptions['contentview']=true; $htmloptions['contentview'] = true;
$htmloptions['flagsview']=true; $htmloptions['flagsview'] = true;
$htmloptions['elementid']=$elementid; $htmloptions['elementid'] = $elementid;
$htmlfields=qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions); $htmlfields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions);
if (isset($htmlfields['what_url'])) // link directly to relevant content if (isset($htmlfields['what_url'])) // link directly to relevant content
$htmlfields['url']=$htmlfields['what_url']; $htmlfields['url'] = $htmlfields['what_url'];
$htmlfields['what_2']=qa_lang_html('main/hidden'); $htmlfields['what_2'] = qa_lang_html('main/hidden');
if (@$htmloptions['whenview']) { if (@$htmloptions['whenview']) {
$updated=@$question[isset($question['opostid']) ? 'oupdated' : 'updated']; $updated = @$question[isset($question['opostid']) ? 'oupdated' : 'updated'];
if (isset($updated)) if (isset($updated))
$htmlfields['when_2']=qa_when_to_html($updated, @$htmloptions['fulldatedays']); $htmlfields['when_2'] = qa_when_to_html($updated, @$htmloptions['fulldatedays']);
} }
$buttons=array(); $buttons = array();
$posttype = qa_strtolower(isset($question['obasetype']) ? $question['obasetype'] : $question['basetype']); $posttype = qa_strtolower(isset($question['obasetype']) ? $question['obasetype'] : $question['basetype']);
if (!qa_user_post_permit_error('permit_hide_show', $question)) if (!qa_user_post_permit_error('permit_hide_show', $question)) {
// Possible values for popup: reshow_q_popup, reshow_a_popup, reshow_c_popup // Possible values for popup: reshow_q_popup, reshow_a_popup, reshow_c_popup
$buttons['reshow']=array( $buttons['reshow'] = array(
'tags' => 'name="admin_'.qa_html($qhiddenpostid[$key]).'_reshow" onclick="return qa_admin_click(this);"', 'tags' => 'name="admin_' . qa_html($qhiddenpostid[$key]) . '_reshow" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/reshow_button'), 'label' => qa_lang_html('question/reshow_button'),
'popup' => qa_lang_html(sprintf('question/reshow_%s_popup', $posttype)), 'popup' => qa_lang_html(sprintf('question/reshow_%s_popup', $posttype)),
); );
}
if ((!qa_user_post_permit_error('permit_delete_hidden', $question)) && !$dependcounts[$qhiddenpostid[$key]]) if ((!qa_user_post_permit_error('permit_delete_hidden', $question)) && !$dependcounts[$qhiddenpostid[$key]]) {
// Possible values for popup: delete_q_popup, delete_a_popup, delete_c_popup // Possible values for popup: delete_q_popup, delete_a_popup, delete_c_popup
$buttons['delete']=array( $buttons['delete'] = array(
'tags' => 'name="admin_'.qa_html($qhiddenpostid[$key]).'_delete" onclick="return qa_admin_click(this);"', 'tags' => 'name="admin_' . qa_html($qhiddenpostid[$key]) . '_delete" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/delete_button'), 'label' => qa_lang_html('question/delete_button'),
'popup' => qa_lang_html(sprintf('question/delete_%s_popup', $posttype)), 'popup' => qa_lang_html(sprintf('question/delete_%s_popup', $posttype)),
); );
}
if (count($buttons)) if (count($buttons)) {
$htmlfields['form']=array( $htmlfields['form'] = array(
'style' => 'light', 'style' => 'light',
'buttons' => $buttons, 'buttons' => $buttons,
); );
$qa_content['q_list']['qs'][]=$htmlfields;
} }
} else $qa_content['q_list']['qs'][] = $htmlfields;
$qa_content['title']=qa_lang_html('admin/no_hidden_found'); }
} else
$qa_content['title'] = qa_lang_html('admin/no_hidden_found');
$qa_content['navigation']['sub']=qa_admin_sub_navigation();
$qa_content['script_rel'][]='qa-content/qa-admin.js?'.QA_VERSION;
$qa_content['navigation']['sub'] = qa_admin_sub_navigation();
$qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
return $qa_content;
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,66 +20,68 @@ ...@@ -20,66 +20,68 @@
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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'app/admin.php'; require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
// Find queued questions, answers, comments // Find queued questions, answers, comments
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
list($queuedquestions, $queuedanswers, $queuedcomments)=qa_db_select_with_pending( list($queuedquestions, $queuedanswers, $queuedcomments) = qa_db_select_with_pending(
qa_db_qs_selectspec($userid, 'created', 0, null, null, 'Q_QUEUED', true), qa_db_qs_selectspec($userid, 'created', 0, null, null, 'Q_QUEUED', true),
qa_db_recent_a_qs_selectspec($userid, 0, null, null, 'A_QUEUED', true), qa_db_recent_a_qs_selectspec($userid, 0, null, null, 'A_QUEUED', true),
qa_db_recent_c_qs_selectspec($userid, 0, null, null, 'C_QUEUED', true) qa_db_recent_c_qs_selectspec($userid, 0, null, null, 'C_QUEUED', true)
); );
// Check admin privileges (do late to allow one DB query) // Check admin privileges (do late to allow one DB query)
if (qa_user_maximum_permit_error('permit_moderate')) { if (qa_user_maximum_permit_error('permit_moderate')) {
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['error']=qa_lang_html('users/no_permission'); $qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content; return $qa_content;
} }
// Check to see if any were approved/rejected here // Check to see if any were approved/rejected here
$pageerror=qa_admin_check_clicks(); $pageerror = qa_admin_check_clicks();
// Combine sets of questions and remove those this user has no permission to moderate // Combine sets of questions and remove those this user has no permission to moderate
$questions=qa_any_sort_by_date(array_merge($queuedquestions, $queuedanswers, $queuedcomments)); $questions = qa_any_sort_by_date(array_merge($queuedquestions, $queuedanswers, $queuedcomments));
if (qa_user_permit_error('permit_moderate')) // if user not allowed to moderate all posts if (qa_user_permit_error('permit_moderate')) { // if user not allowed to moderate all posts
foreach ($questions as $index => $question) foreach ($questions as $index => $question) {
if (qa_user_post_permit_error('permit_moderate', $question)) if (qa_user_post_permit_error('permit_moderate', $question))
unset($questions[$index]); unset($questions[$index]);
}
}
// Get information for users // Get information for users
$usershtml=qa_userids_handles_html(qa_any_get_userids_handles($questions)); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
// 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/recent_approve_title'); $qa_content['title'] = qa_lang_html('admin/recent_approve_title');
$qa_content['error']=isset($pageerror) ? $pageerror : qa_admin_page_error(); $qa_content['error'] = isset($pageerror) ? $pageerror : qa_admin_page_error();
$qa_content['q_list']=array( $qa_content['q_list'] = array(
'form' => array( 'form' => array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'hidden' => array( 'hidden' => array(
'code' => qa_get_form_security_code('admin/click'), 'code' => qa_get_form_security_code('admin/click'),
...@@ -87,25 +89,25 @@ ...@@ -87,25 +89,25 @@
), ),
'qs' => array(), 'qs' => array(),
); );
if (count($questions)) { if (count($questions)) {
foreach ($questions as $question) { foreach ($questions as $question) {
$postid=qa_html(isset($question['opostid']) ? $question['opostid'] : $question['postid']); $postid = qa_html(isset($question['opostid']) ? $question['opostid'] : $question['postid']);
$elementid='p'.$postid; $elementid = 'p' . $postid;
$htmloptions=qa_post_html_options($question); $htmloptions = qa_post_html_options($question);
$htmloptions['voteview']=false; $htmloptions['voteview'] = false;
$htmloptions['tagsview']=!isset($question['opostid']); $htmloptions['tagsview'] = !isset($question['opostid']);
$htmloptions['answersview']=false; $htmloptions['answersview'] = false;
$htmloptions['viewsview']=false; $htmloptions['viewsview'] = false;
$htmloptions['contentview']=true; $htmloptions['contentview'] = true;
$htmloptions['elementid']=$elementid; $htmloptions['elementid'] = $elementid;
$htmlfields=qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions); $htmlfields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions);
if (isset($htmlfields['what_url'])) // link directly to relevant content if (isset($htmlfields['what_url'])) // link directly to relevant content
$htmlfields['url']=$htmlfields['what_url']; $htmlfields['url'] = $htmlfields['what_url'];
$posttype = qa_strtolower(isset($question['obasetype']) ? $question['obasetype'] : $question['basetype']); $posttype = qa_strtolower(isset($question['obasetype']) ? $question['obasetype'] : $question['basetype']);
switch ($posttype) { switch ($posttype) {
...@@ -124,40 +126,35 @@ ...@@ -124,40 +126,35 @@
break; break;
} }
$htmlfields['form']=array( $htmlfields['form'] = array(
'style' => 'light', 'style' => 'light',
'buttons' => array( 'buttons' => array(
// Possible values for popup: approve_q_popup, approve_a_popup, approve_c_popup // Possible values for popup: approve_q_popup, approve_a_popup, approve_c_popup
'approve' => array( 'approve' => array(
'tags' => 'name="admin_'.$postid.'_approve" onclick="return qa_admin_click(this);"', 'tags' => 'name="admin_' . $postid . '_approve" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/approve_button'), 'label' => qa_lang_html('question/approve_button'),
'popup' => qa_lang_html($approveKey), 'popup' => qa_lang_html($approveKey),
), ),
// Possible values for popup: reject_q_popup, reject_a_popup, reject_c_popup // Possible values for popup: reject_q_popup, reject_a_popup, reject_c_popup
'reject' => array( 'reject' => array(
'tags' => 'name="admin_'.$postid.'_reject" onclick="return qa_admin_click(this);"', 'tags' => 'name="admin_' . $postid . '_reject" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/reject_button'), 'label' => qa_lang_html('question/reject_button'),
'popup' => qa_lang_html($rejectKey), 'popup' => qa_lang_html($rejectKey),
), ),
), ),
); );
$qa_content['q_list']['qs'][]=$htmlfields; $qa_content['q_list']['qs'][] = $htmlfields;
} }
} else } else
$qa_content['title']=qa_lang_html('admin/no_approve_found'); $qa_content['title'] = qa_lang_html('admin/no_approve_found');
$qa_content['navigation']['sub']=qa_admin_sub_navigation(); $qa_content['navigation']['sub'] = qa_admin_sub_navigation();
$qa_content['script_rel'][]='qa-content/qa-admin.js?'.QA_VERSION; $qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,28 +20,28 @@ ...@@ -20,28 +20,28 @@
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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'app/admin.php'; require_once QA_INCLUDE_DIR . 'app/admin.php';
// Check admin privileges // Check admin privileges
if (!qa_admin_check_privileges($qa_content)) if (!qa_admin_check_privileges($qa_content))
return $qa_content; return $qa_content;
// Map modules with options to their containing plugins // Map modules with options to their containing plugins
$pluginoptionmodules = array(); $pluginoptionmodules = array();
$tables = qa_db_list_tables(); $tables = qa_db_list_tables();
$moduletypes = qa_list_module_types(); $moduletypes = qa_list_module_types();
foreach ($moduletypes as $type) { foreach ($moduletypes as $type) {
$modules = qa_list_modules($type); $modules = qa_list_modules($type);
foreach ($modules as $name) { foreach ($modules as $name) {
...@@ -56,22 +56,22 @@ ...@@ -56,22 +56,22 @@
); );
} }
} }
} }
// 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/plugins_title'); $qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/plugins_title');
$qa_content['error'] = qa_admin_page_error(); $qa_content['error'] = qa_admin_page_error();
$qa_content['script_rel'][] = 'qa-content/qa-admin.js?'.QA_VERSION; $qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
$pluginfiles = glob(QA_PLUGIN_DIR.'*/qa-plugin.php'); $pluginfiles = glob(QA_PLUGIN_DIR . '*/qa-plugin.php');
foreach ($moduletypes as $type) { foreach ($moduletypes as $type) {
$modules = qa_load_modules_with($type, 'init_queries'); $modules = qa_load_modules_with($type, 'init_queries');
foreach ($modules as $name => $module) { foreach ($modules as $name => $module) {
...@@ -85,22 +85,21 @@ ...@@ -85,22 +85,21 @@
$qa_content['error'] = strtr(qa_lang_html('admin/module_x_database_init'), array( $qa_content['error'] = strtr(qa_lang_html('admin/module_x_database_init'), array(
'^1' => qa_html($name), '^1' => qa_html($name),
'^2' => qa_html($type), '^2' => qa_html($type),
'^3' => '<a href="'.qa_path_html('install').'">', '^3' => '<a href="' . qa_path_html('install') . '">',
'^4' => '</a>', '^4' => '</a>',
)); ));
} }
} }
} }
} }
if ( qa_is_http_post() && !qa_check_form_security_code('admin/plugins', qa_post_text('qa_form_security_code')) ) { if (qa_is_http_post() && !qa_check_form_security_code('admin/plugins', qa_post_text('qa_form_security_code'))) {
$qa_content['error'] = qa_lang_html('misc/form_security_reload'); $qa_content['error'] = qa_lang_html('misc/form_security_reload');
$showpluginforms = false; $showpluginforms = false;
} } else
else
$showpluginforms = true; $showpluginforms = true;
if (!empty($pluginfiles)) { if (!empty($pluginfiles)) {
$metadataUtil = new Q2A_Util_Metadata(); $metadataUtil = new Q2A_Util_Metadata();
$sortedPluginFiles = array(); $sortedPluginFiles = array();
...@@ -113,8 +112,7 @@ ...@@ -113,8 +112,7 @@
} }
$metadata['name'] = isset($metadata['name']) && !empty($metadata['name']) $metadata['name'] = isset($metadata['name']) && !empty($metadata['name'])
? qa_html($metadata['name']) ? qa_html($metadata['name'])
: qa_lang_html('admin/unnamed_plugin') : qa_lang_html('admin/unnamed_plugin');
;
$sortedPluginFiles[$pluginFile] = $metadata; $sortedPluginFiles[$pluginFile] = $metadata;
} }
...@@ -130,37 +128,35 @@ ...@@ -130,37 +128,35 @@
$namehtml = $metadata['name']; $namehtml = $metadata['name'];
if (isset($metadata['uri']) && strlen($metadata['uri'])) if (isset($metadata['uri']) && strlen($metadata['uri']))
$namehtml = '<a href="'.qa_html($metadata['uri']).'">'.$namehtml.'</a>'; $namehtml = '<a href="' . qa_html($metadata['uri']) . '">' . $namehtml . '</a>';
$namehtml = '<b>'.$namehtml.'</b>'; $namehtml = '<b>' . $namehtml . '</b>';
$metaver = isset($metadata['version']) && strlen($metadata['version']); $metaver = isset($metadata['version']) && strlen($metadata['version']);
if ($metaver) if ($metaver)
$namehtml .= ' v'.qa_html($metadata['version']); $namehtml .= ' v' . qa_html($metadata['version']);
if (isset($metadata['author']) && strlen($metadata['author'])) { if (isset($metadata['author']) && strlen($metadata['author'])) {
$authorhtml = qa_html($metadata['author']); $authorhtml = qa_html($metadata['author']);
if (isset($metadata['author_uri']) && strlen($metadata['author_uri'])) if (isset($metadata['author_uri']) && strlen($metadata['author_uri']))
$authorhtml = '<a href="'.qa_html($metadata['author_uri']).'">'.$authorhtml.'</a>'; $authorhtml = '<a href="' . qa_html($metadata['author_uri']) . '">' . $authorhtml . '</a>';
$authorhtml = qa_lang_html_sub('main/by_x', $authorhtml); $authorhtml = qa_lang_html_sub('main/by_x', $authorhtml);
} } else
else
$authorhtml = ''; $authorhtml = '';
if ($metaver && isset($metadata['update_uri']) && strlen($metadata['update_uri'])) { if ($metaver && isset($metadata['update_uri']) && strlen($metadata['update_uri'])) {
$elementid = 'version_check_'.md5($plugindirectory); $elementid = 'version_check_' . md5($plugindirectory);
$updatehtml = '(<span id="'.$elementid.'">...</span>)'; $updatehtml = '(<span id="' . $elementid . '">...</span>)';
$qa_content['script_onloads'][] = array( $qa_content['script_onloads'][] = array(
"qa_version_check(".qa_js($metadata['update_uri']).", ".qa_js($metadata['version'], true).", ".qa_js($elementid).");" "qa_version_check(" . qa_js($metadata['update_uri']) . ", " . qa_js($metadata['version'], true) . ", " . qa_js($elementid) . ");"
); );
} } else
else
$updatehtml = ''; $updatehtml = '';
if (isset($metadata['description'])) if (isset($metadata['description']))
...@@ -168,23 +164,25 @@ ...@@ -168,23 +164,25 @@
else else
$deschtml = ''; $deschtml = '';
if (isset($pluginoptionmodules[$plugindirectory]) && !$showthisform) if (isset($pluginoptionmodules[$plugindirectory]) && !$showthisform) {
$deschtml .= (strlen($deschtml) ? ' - ' : '').'<a href="'. $deschtml .= (strlen($deschtml) ? ' - ' : '') . '<a href="' .
qa_admin_plugin_options_path($plugindirectory).'">'.qa_lang_html('admin/options').'</a>'; qa_admin_plugin_options_path($plugindirectory) . '">' . qa_lang_html('admin/options') . '</a>';
}
$pluginhtml = $namehtml.' '.$authorhtml.' '.$updatehtml.'<br>'.$deschtml.(strlen($deschtml) ? '<br>' : ''). $pluginhtml = $namehtml . ' ' . $authorhtml . ' ' . $updatehtml . '<br>' . $deschtml . (strlen($deschtml) ? '<br>' : '') .
'<small style="color:#666">'.qa_html($plugindirectory).'/</small>'; '<small style="color:#666">' . qa_html($plugindirectory) . '/</small>';
if (qa_qa_version_below(@$metadata['min_q2a'])) if (qa_qa_version_below(@$metadata['min_q2a'])) {
$pluginhtml = '<strike style="color:#999">'.$pluginhtml.'</strike><br><span style="color:#f00">'. $pluginhtml = '<strike style="color:#999">' . $pluginhtml . '</strike><br><span style="color:#f00">' .
qa_lang_html_sub('admin/requires_q2a_version', qa_html($metadata['min_q2a'])).'</span>'; qa_lang_html_sub('admin/requires_q2a_version', qa_html($metadata['min_q2a'])) . '</span>';
elseif (qa_php_version_below(@$metadata['min_php'])) } elseif (qa_php_version_below(@$metadata['min_php'])) {
$pluginhtml = '<strike style="color:#999">'.$pluginhtml.'</strike><br><span style="color:#f00">'. $pluginhtml = '<strike style="color:#999">' . $pluginhtml . '</strike><br><span style="color:#f00">' .
qa_lang_html_sub('admin/requires_php_version', qa_html($metadata['min_php'])).'</span>'; qa_lang_html_sub('admin/requires_php_version', qa_html($metadata['min_php'])) . '</span>';
}
$qa_content['form_plugin_'.$pluginIndex] = array( $qa_content['form_plugin_' . $pluginIndex] = array(
'tags' => 'id="'.qa_html($hash).'"', 'tags' => 'id="' . qa_html($hash) . '"',
'style' => 'tall', 'style' => 'tall',
'fields' => array( 'fields' => array(
array( array(
...@@ -194,7 +192,7 @@ ...@@ -194,7 +192,7 @@
), ),
); );
if ($showthisform && isset($pluginoptionmodules[$plugindirectory])) if ($showthisform && isset($pluginoptionmodules[$plugindirectory])) {
foreach ($pluginoptionmodules[$plugindirectory] as $pluginoptionmodule) { foreach ($pluginoptionmodules[$plugindirectory] as $pluginoptionmodule) {
$type = $pluginoptionmodule['type']; $type = $pluginoptionmodule['type'];
$name = $pluginoptionmodule['name']; $name = $pluginoptionmodule['name'];
...@@ -204,7 +202,7 @@ ...@@ -204,7 +202,7 @@
$form = $module->admin_form($qa_content); $form = $module->admin_form($qa_content);
if (!isset($form['tags'])) if (!isset($form['tags']))
$form['tags'] = 'method="post" action="'.qa_admin_plugin_options_path($plugindirectory).'"'; $form['tags'] = 'method="post" action="' . qa_admin_plugin_options_path($plugindirectory) . '"';
if (!isset($form['style'])) if (!isset($form['style']))
$form['style'] = 'tall'; $form['style'] = 'tall';
...@@ -215,16 +213,11 @@ ...@@ -215,16 +213,11 @@
$qa_content['form_plugin_options'] = $form; $qa_content['form_plugin_options'] = $form;
} }
} }
} }
}
$qa_content['navigation']['sub'] = qa_admin_sub_navigation(); $qa_content['navigation']['sub'] = qa_admin_sub_navigation();
return $qa_content;
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,68 +20,68 @@ ...@@ -20,68 +20,68 @@
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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/recalc.php'; require_once QA_INCLUDE_DIR . 'db/recalc.php';
require_once QA_INCLUDE_DIR.'db/points.php'; require_once QA_INCLUDE_DIR . 'db/points.php';
require_once QA_INCLUDE_DIR.'app/options.php'; require_once QA_INCLUDE_DIR . 'app/options.php';
require_once QA_INCLUDE_DIR.'app/admin.php'; require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR.'util/sort.php'; require_once QA_INCLUDE_DIR . 'util/sort.php';
// Check admin privileges // Check admin privileges
if (!qa_admin_check_privileges($qa_content)) if (!qa_admin_check_privileges($qa_content))
return $qa_content; return $qa_content;
// Process user actions // 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) foreach ($optionnames as $optionname)
$options[$optionname]=qa_default_option($optionname); $options[$optionname] = qa_default_option($optionname);
} else { } else {
if (qa_clicked('docancel')) if (qa_clicked('docancel'))
; ;
elseif (qa_clicked('dosaverecalc')) { elseif (qa_clicked('dosaverecalc')) {
if (!qa_check_form_security_code('admin/points', qa_post_text('code'))) if (!qa_check_form_security_code('admin/points', qa_post_text('code')))
$securityexpired=true; $securityexpired = true;
else { else {
foreach ($optionnames as $optionname) foreach ($optionnames as $optionname)
qa_set_option($optionname, (int)qa_post_text('option_'.$optionname)); qa_set_option($optionname, (int)qa_post_text('option_' . $optionname));
if (!qa_post_text('has_js')) if (!qa_post_text('has_js'))
qa_redirect('admin/recalc', array('dorecalcpoints' => 1)); qa_redirect('admin/recalc', array('dorecalcpoints' => 1));
else else
$recalculate=true; $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',
...@@ -97,41 +97,41 @@ ...@@ -97,41 +97,41 @@
'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'),
...@@ -139,7 +139,7 @@ ...@@ -139,7 +139,7 @@
switch ($optionname) { switch ($optionname) {
case 'points_multiple': case 'points_multiple':
$prefix='&#215;'; $prefix = '&#215;';
unset($optionfield['note']); unset($optionfield['note']);
break; break;
...@@ -147,41 +147,36 @@ ...@@ -147,41 +147,36 @@
case 'points_per_a_voted_up': case 'points_per_a_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':
$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_q_voted_max_loss': case 'points_q_voted_max_loss':
case 'points_a_voted_max_loss': case 'points_a_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_array_insert($qa_content['form']['fields'], 'points_post_a', array('blank0' => array('type' => 'blank')));
qa_array_insert($qa_content['form']['fields'], 'points_vote_up_q', array('blank1' => array('type' => 'blank')));
qa_array_insert($qa_content['form']['fields'], 'points_multiple', array('blank2' => array('type' => 'blank')));
$qa_content['form']['fields'][$optionname] = $optionfield;
}
$qa_content['navigation']['sub']=qa_admin_sub_navigation(); qa_array_insert($qa_content['form']['fields'], 'points_post_a', array('blank0' => array('type' => 'blank')));
qa_array_insert($qa_content['form']['fields'], 'points_vote_up_q', array('blank1' => array('type' => 'blank')));
qa_array_insert($qa_content['form']['fields'], 'points_multiple', array('blank2' => array('type' => 'blank')));
return $qa_content; $qa_content['navigation']['sub'] = qa_admin_sub_navigation();
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,24 +20,24 @@ ...@@ -20,24 +20,24 @@
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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'app/admin.php'; require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR.'app/recalc.php'; require_once QA_INCLUDE_DIR . 'app/recalc.php';
// Check we have administrative privileges // Check we have administrative privileges
if (!qa_admin_check_privileges($qa_content)) if (!qa_admin_check_privileges($qa_content))
return $qa_content; return $qa_content;
// Find out the operation // Find out the operation
$allowstates=array( $allowstates = array(
'dorecountposts', 'dorecountposts',
'doreindexcontent', 'doreindexcontent',
'dorecalcpoints', 'dorecalcpoints',
...@@ -46,69 +46,70 @@ ...@@ -46,69 +46,70 @@
'dodeletehidden', 'dodeletehidden',
'doblobstodisk', 'doblobstodisk',
'doblobstodb', 'doblobstodb',
); );
$recalcnow=false; $recalcnow = false;
foreach ($allowstates as $allowstate) foreach ($allowstates as $allowstate) {
if (qa_post_text($allowstate) || qa_get($allowstate)) { if (qa_post_text($allowstate) || qa_get($allowstate)) {
$state=$allowstate; $state = $allowstate;
$code=qa_post_text('code'); $code = qa_post_text('code');
if (isset($code) && qa_check_form_security_code('admin/recalc', $code)) if (isset($code) && qa_check_form_security_code('admin/recalc', $code))
$recalcnow=true; $recalcnow = true;
} }
}
if ($recalcnow) { if ($recalcnow) {
?> ?>
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
</head> </head>
<body> <body>
<tt> <tt>
<?php <?php
while ($state) { while ($state) {
set_time_limit(60); set_time_limit(60);
$stoptime=time()+2; // run in lumps of two seconds... $stoptime = time() + 2; // run in lumps of two seconds...
while ( qa_recalc_perform_step($state) && (time()<$stoptime) ) while (qa_recalc_perform_step($state) && time() < $stoptime)
; ;
echo qa_html(qa_recalc_get_message($state)).str_repeat(' ', 1024)."<br>\n"; echo qa_html(qa_recalc_get_message($state)) . str_repeat(' ', 1024) . "<br>\n";
flush(); flush();
sleep(1); // ... then rest for one sleep(1); // ... then rest for one
} }
?> ?>
</tt> </tt>
<a href="<?php echo qa_path_html('admin/stats')?>"><?php echo qa_lang_html('admin/admin_title').' - '.qa_lang_html('admin/stats_title')?></a> <a href="<?php echo qa_path_html('admin/stats')?>"><?php echo qa_lang_html('admin/admin_title').' - '.qa_lang_html('admin/stats_title')?></a>
</body> </body>
</html> </html>
<?php <?php
qa_exit(); qa_exit();
} elseif (isset($state)) { } elseif (isset($state)) {
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html('admin/admin_title'); $qa_content['title'] = qa_lang_html('admin/admin_title');
$qa_content['error']=qa_lang_html('misc/form_security_again'); $qa_content['error'] = qa_lang_html('misc/form_security_again');
$qa_content['form']=array( $qa_content['form'] = array(
'tags' => 'method="post" action="'.qa_self_html().'"', 'tags' => 'method="post" action="' . qa_self_html() . '"',
'style' => 'wide', 'style' => 'wide',
'buttons' => array( 'buttons' => array(
'recalc' => array( 'recalc' => array(
'tags' => 'name="'.qa_html($state).'"', 'tags' => 'name="' . qa_html($state) . '"',
'label' => qa_lang_html('misc/form_security_again'), 'label' => qa_lang_html('misc/form_security_again'),
), ),
), ),
...@@ -120,18 +121,13 @@ ...@@ -120,18 +121,13 @@
return $qa_content; return $qa_content;
} else { } else {
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html('admin/admin_title'); $qa_content['title'] = qa_lang_html('admin/admin_title');
$qa_content['error']=qa_lang_html('main/page_not_found'); $qa_content['error'] = qa_lang_html('main/page_not_found');
return $qa_content; return $qa_content;
} }
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,48 +20,49 @@ ...@@ -20,48 +20,49 @@
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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'app/admin.php'; require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
// Get current list of user fields and determine the state of this admin page // Get current list of user fields and determine the state of this admin page
$fieldid=qa_post_text('edit'); $fieldid = qa_post_text('edit');
if (!isset($fieldid)) if (!isset($fieldid))
$fieldid=qa_get('edit'); $fieldid = qa_get('edit');
$userfields=qa_db_select_with_pending(qa_db_userfields_selectspec()); $userfields = qa_db_select_with_pending(qa_db_userfields_selectspec());
$editfield=null; $editfield = null;
foreach ($userfields as $userfield) foreach ($userfields as $userfield) {
if ($userfield['fieldid']==$fieldid) if ($userfield['fieldid'] == $fieldid)
$editfield=$userfield; $editfield = $userfield;
}
// Check admin privileges (do late to allow one DB query) // Check admin privileges (do late to allow one DB query)
if (!qa_admin_check_privileges($qa_content)) if (!qa_admin_check_privileges($qa_content))
return $qa_content; return $qa_content;
// Process saving an old or new user field // Process saving an old or new user field
$securityexpired=false; $securityexpired = false;
if (qa_clicked('docancel')) if (qa_clicked('docancel'))
qa_redirect('admin/users'); qa_redirect('admin/users');
elseif (qa_clicked('dosavefield')) { elseif (qa_clicked('dosavefield')) {
require_once QA_INCLUDE_DIR.'db/admin.php'; require_once QA_INCLUDE_DIR . 'db/admin.php';
require_once QA_INCLUDE_DIR.'util/string.php'; require_once QA_INCLUDE_DIR . 'util/string.php';
if (!qa_check_form_security_code('admin/userfields', qa_post_text('code'))) if (!qa_check_form_security_code('admin/userfields', qa_post_text('code')))
$securityexpired=true; $securityexpired = true;
else { else {
if (qa_post_text('dodelete')) { if (qa_post_text('dodelete')) {
...@@ -69,19 +70,19 @@ ...@@ -69,19 +70,19 @@
qa_redirect('admin/users'); qa_redirect('admin/users');
} else { } else {
$inname=qa_post_text('name'); $inname = qa_post_text('name');
$intype=qa_post_text('type'); $intype = qa_post_text('type');
$inonregister=(int)qa_post_text('onregister'); $inonregister = (int)qa_post_text('onregister');
$inflags=$intype | ($inonregister ? QA_FIELD_FLAGS_ON_REGISTER : 0); $inflags = $intype | ($inonregister ? QA_FIELD_FLAGS_ON_REGISTER : 0);
$inposition=qa_post_text('position'); $inposition = qa_post_text('position');
$inpermit=(int)qa_post_text('permit'); $inpermit = (int)qa_post_text('permit');
$errors=array(); $errors = array();
// Verify the name is legitimate // Verify the name is legitimate
if (qa_strlen($inname)>QA_DB_MAX_PROFILE_TITLE_LENGTH) if (qa_strlen($inname) > QA_DB_MAX_PROFILE_TITLE_LENGTH)
$errors['name']=qa_lang_sub('main/max_length_x', QA_DB_MAX_PROFILE_TITLE_LENGTH); $errors['name'] = qa_lang_sub('main/max_length_x', QA_DB_MAX_PROFILE_TITLE_LENGTH);
// Perform appropriate database action // Perform appropriate database action
...@@ -93,25 +94,26 @@ ...@@ -93,25 +94,26 @@
qa_redirect('admin/users'); qa_redirect('admin/users');
else { else {
$userfields=qa_db_select_with_pending(qa_db_userfields_selectspec()); // reload after changes $userfields = qa_db_select_with_pending(qa_db_userfields_selectspec()); // reload after changes
foreach ($userfields as $userfield) foreach ($userfields as $userfield)
if ($userfield['fieldid']==$editfield['fieldid']) if ($userfield['fieldid'] == $editfield['fieldid'])
$editfield=$userfield; $editfield = $userfield;
} }
} elseif (empty($errors)) { // creating a new user field } elseif (empty($errors)) { // creating a new user field
for ($attempt=0; $attempt<1000; $attempt++) { for ($attempt = 0; $attempt < 1000; $attempt++) {
$suffix=$attempt ? ('-'.(1+$attempt)) : ''; $suffix = $attempt ? ('-' . (1 + $attempt)) : '';
$newtag=qa_substr(implode('-', qa_string_to_words($inname)), 0, QA_DB_MAX_PROFILE_TITLE_LENGTH-strlen($suffix)).$suffix; $newtag = qa_substr(implode('-', qa_string_to_words($inname)), 0, QA_DB_MAX_PROFILE_TITLE_LENGTH - strlen($suffix)) . $suffix;
$uniquetag=true; $uniquetag = true;
foreach ($userfields as $userfield) foreach ($userfields as $userfield) {
if (qa_strtolower(trim($newtag)) == qa_strtolower(trim($userfield['title']))) if (qa_strtolower(trim($newtag)) == qa_strtolower(trim($userfield['title'])))
$uniquetag=false; $uniquetag = false;
}
if ($uniquetag) { if ($uniquetag) {
$fieldid=qa_db_userfield_create($newtag, $inname, $inflags, $inpermit); $fieldid = qa_db_userfield_create($newtag, $inname, $inflags, $inpermit);
qa_db_userfield_move($fieldid, $inposition); qa_db_userfield_move($fieldid, $inposition);
qa_redirect('admin/users'); qa_redirect('admin/users');
} }
...@@ -121,52 +123,52 @@ ...@@ -121,52 +123,52 @@
} }
} }
} }
} }
// 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/users_title'); $qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/users_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();
$positionoptions=array(); $positionoptions = array();
$previous=null; $previous = null;
$passedself=false; $passedself = false;
foreach ($userfields as $userfield) { foreach ($userfields as $userfield) {
if (isset($previous)) if (isset($previous))
$positionhtml=qa_lang_html_sub('admin/after_x', qa_html(qa_user_userfield_label($passedself ? $userfield : $previous))); $positionhtml = qa_lang_html_sub('admin/after_x', qa_html(qa_user_userfield_label($passedself ? $userfield : $previous)));
else else
$positionhtml=qa_lang_html('admin/first'); $positionhtml = qa_lang_html('admin/first');
$positionoptions[$userfield['position']]=$positionhtml; $positionoptions[$userfield['position']] = $positionhtml;
if ($userfield['fieldid']==@$editfield['fieldid']) if ($userfield['fieldid'] == @$editfield['fieldid'])
$passedself=true; $passedself = true;
$previous=$userfield; $previous = $userfield;
} }
if (isset($editfield['position'])) if (isset($editfield['position']))
$positionvalue=$positionoptions[$editfield['position']]; $positionvalue = $positionoptions[$editfield['position']];
else { else {
$positionvalue=isset($previous) ? qa_lang_html_sub('admin/after_x', qa_html(qa_user_userfield_label($previous))) : qa_lang_html('admin/first'); $positionvalue = isset($previous) ? qa_lang_html_sub('admin/after_x', qa_html(qa_user_userfield_label($previous))) : qa_lang_html('admin/first');
$positionoptions[1+@max(array_keys($positionoptions))]=$positionvalue; $positionoptions[1 + @max(array_keys($positionoptions))] = $positionvalue;
} }
$typeoptions=array( $typeoptions = array(
0 => qa_lang_html('admin/field_single_line'), 0 => qa_lang_html('admin/field_single_line'),
QA_FIELD_FLAGS_MULTI_LINE => qa_lang_html('admin/field_multi_line'), QA_FIELD_FLAGS_MULTI_LINE => qa_lang_html('admin/field_multi_line'),
QA_FIELD_FLAGS_LINK_URL => qa_lang_html('admin/field_link_url'), QA_FIELD_FLAGS_LINK_URL => qa_lang_html('admin/field_link_url'),
); );
$permitoptions=qa_admin_permit_options(QA_PERMIT_ALL, QA_PERMIT_ADMINS, false, false); $permitoptions = qa_admin_permit_options(QA_PERMIT_ALL, QA_PERMIT_ADMINS, false, false);
$permitvalue=@$permitoptions[isset($inpermit) ? $inpermit : $editfield['permit']]; $permitvalue = @$permitoptions[isset($inpermit) ? $inpermit : $editfield['permit']];
$qa_content['form']=array( $qa_content['form'] = array(
'tags' => 'method="post" action="'.qa_path_html(qa_request()).'"', 'tags' => 'method="post" action="' . qa_path_html(qa_request()) . '"',
'style' => 'tall', 'style' => 'tall',
...@@ -191,7 +193,7 @@ ...@@ -191,7 +193,7 @@
'label' => qa_lang_html('admin/field_type'), 'label' => qa_lang_html('admin/field_type'),
'type' => 'select', 'type' => 'select',
'options' => $typeoptions, 'options' => $typeoptions,
'value' => @$typeoptions[isset($intype) ? $intype : (@$editfield['flags']&(QA_FIELD_FLAGS_MULTI_LINE|QA_FIELD_FLAGS_LINK_URL))], 'value' => @$typeoptions[isset($intype) ? $intype : (@$editfield['flags'] & (QA_FIELD_FLAGS_MULTI_LINE | QA_FIELD_FLAGS_LINK_URL))],
), ),
'permit' => array( 'permit' => array(
...@@ -217,7 +219,7 @@ ...@@ -217,7 +219,7 @@
'tags' => 'name="onregister"', 'tags' => 'name="onregister"',
'label' => qa_lang_html('admin/show_on_register_form'), 'label' => qa_lang_html('admin/show_on_register_form'),
'type' => 'checkbox', 'type' => 'checkbox',
'value' => isset($inonregister) ? $inonregister : (@$editfield['flags']&QA_FIELD_FLAGS_ON_REGISTER), 'value' => isset($inonregister) ? $inonregister : (@$editfield['flags'] & QA_FIELD_FLAGS_ON_REGISTER),
), ),
), ),
...@@ -237,26 +239,22 @@ ...@@ -237,26 +239,22 @@
'edit' => @$editfield['fieldid'], 'edit' => @$editfield['fieldid'],
'code' => qa_get_form_security_code('admin/userfields'), 'code' => qa_get_form_security_code('admin/userfields'),
), ),
); );
if (isset($editfield['fieldid'])) if (isset($editfield['fieldid'])) {
qa_set_display_rules($qa_content, array( qa_set_display_rules($qa_content, array(
'type_display' => '!dodelete', 'type_display' => '!dodelete',
'position_display' => '!dodelete', 'position_display' => '!dodelete',
'register_display' => '!dodelete', 'register_display' => '!dodelete',
'permit_display' => '!dodelete', 'permit_display' => '!dodelete',
)); ));
else } else {
unset($qa_content['form']['fields']['delete']); unset($qa_content['form']['fields']['delete']);
}
$qa_content['focusid']='name'; $qa_content['focusid'] = 'name';
$qa_content['navigation']['sub']=qa_admin_sub_navigation();
$qa_content['navigation']['sub'] = qa_admin_sub_navigation();
return $qa_content;
/* return $qa_content;
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,105 +20,105 @@ ...@@ -20,105 +20,105 @@
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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'app/admin.php'; require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
// Get current list of user titles and determine the state of this admin page // Get current list of user titles and determine the state of this admin page
$oldpoints=qa_post_text('edit'); $oldpoints = qa_post_text('edit');
if (!isset($oldpoints)) if (!isset($oldpoints))
$oldpoints=qa_get('edit'); $oldpoints = qa_get('edit');
$pointstitle=qa_get_points_to_titles(); $pointstitle = qa_get_points_to_titles();
// Check admin privileges (do late to allow one DB query) // Check admin privileges (do late to allow one DB query)
if (!qa_admin_check_privileges($qa_content)) if (!qa_admin_check_privileges($qa_content))
return $qa_content; return $qa_content;
// Process saving an old or new user title // Process saving an old or new user title
$securityexpired=false; $securityexpired = false;
if (qa_clicked('docancel')) if (qa_clicked('docancel'))
qa_redirect('admin/users'); qa_redirect('admin/users');
elseif (qa_clicked('dosavetitle')) { elseif (qa_clicked('dosavetitle')) {
require_once QA_INCLUDE_DIR.'util/string.php'; require_once QA_INCLUDE_DIR . 'util/string.php';
if (!qa_check_form_security_code('admin/usertitles', qa_post_text('code'))) if (!qa_check_form_security_code('admin/usertitles', qa_post_text('code')))
$securityexpired=true; $securityexpired = true;
else { else {
if (qa_post_text('dodelete')) { if (qa_post_text('dodelete')) {
unset($pointstitle[$oldpoints]); unset($pointstitle[$oldpoints]);
} else { } else {
$intitle=qa_post_text('title'); $intitle = qa_post_text('title');
$inpoints=qa_post_text('points'); $inpoints = qa_post_text('points');
$errors=array(); $errors = array();
// Verify the title and points are legitimate // Verify the title and points are legitimate
if (!strlen($intitle)) if (!strlen($intitle))
$errors['title']=qa_lang('main/field_required'); $errors['title'] = qa_lang('main/field_required');
if (!is_numeric($inpoints)) if (!is_numeric($inpoints))
$errors['points']=qa_lang('main/field_required'); $errors['points'] = qa_lang('main/field_required');
else { else {
$inpoints=(int)$inpoints; $inpoints = (int)$inpoints;
if (isset($pointstitle[$inpoints]) && ((!strlen(@$oldpoints)) || ($inpoints!=$oldpoints)) ) if (isset($pointstitle[$inpoints]) && ((!strlen(@$oldpoints)) || ($inpoints != $oldpoints)))
$errors['points']=qa_lang('admin/title_already_used'); $errors['points'] = qa_lang('admin/title_already_used');
} }
// Perform appropriate action // Perform appropriate action
if (isset($pointstitle[$oldpoints])) { // changing existing user title if (isset($pointstitle[$oldpoints])) { // changing existing user title
$newpoints=isset($errors['points']) ? $oldpoints : $inpoints; $newpoints = isset($errors['points']) ? $oldpoints : $inpoints;
$newtitle=isset($errors['title']) ? $pointstitle[$oldpoints] : $intitle; $newtitle = isset($errors['title']) ? $pointstitle[$oldpoints] : $intitle;
unset($pointstitle[$oldpoints]); unset($pointstitle[$oldpoints]);
$pointstitle[$newpoints]=$newtitle; $pointstitle[$newpoints] = $newtitle;
} elseif (empty($errors)) // creating a new user title } elseif (empty($errors)) // creating a new user title
$pointstitle[$inpoints]=$intitle; $pointstitle[$inpoints] = $intitle;
} }
// Save the new option value // Save the new option value
krsort($pointstitle, SORT_NUMERIC); krsort($pointstitle, SORT_NUMERIC);
$option=''; $option = '';
foreach ($pointstitle as $points => $title) foreach ($pointstitle as $points => $title)
$option.=(strlen($option) ? ',' : '').$points.' '.$title; $option .= (strlen($option) ? ',' : '') . $points . ' ' . $title;
qa_set_option('points_to_titles', $option); qa_set_option('points_to_titles', $option);
if (empty($errors)) if (empty($errors))
qa_redirect('admin/users'); qa_redirect('admin/users');
} }
} }
// 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/users_title'); $qa_content['title'] = qa_lang_html('admin/admin_title') . ' - ' . qa_lang_html('admin/users_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_path_html(qa_request()).'"', 'tags' => 'method="post" action="' . qa_path_html(qa_request()) . '"',
'style' => 'tall', 'style' => 'tall',
...@@ -163,23 +163,19 @@ ...@@ -163,23 +163,19 @@
'edit' => @$oldpoints, 'edit' => @$oldpoints,
'code' => qa_get_form_security_code('admin/usertitles'), 'code' => qa_get_form_security_code('admin/usertitles'),
), ),
); );
if (isset($pointstitle[$oldpoints])) if (isset($pointstitle[$oldpoints])) {
qa_set_display_rules($qa_content, array( qa_set_display_rules($qa_content, array(
'points_display' => '!dodelete', 'points_display' => '!dodelete',
)); ));
else } else {
unset($qa_content['form']['fields']['delete']); unset($qa_content['form']['fields']['delete']);
}
$qa_content['focusid']='title'; $qa_content['focusid'] = 'title';
$qa_content['navigation']['sub']=qa_admin_sub_navigation(); $qa_content['navigation']['sub'] = qa_admin_sub_navigation();
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
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