Commit 14d54fd4 by Scott

Coding style (admin pages)

parent 2be2b6bb
......@@ -20,121 +20,118 @@
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;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../');
exit;
}
require_once QA_INCLUDE_DIR.'app/admin.php';
require_once QA_INCLUDE_DIR.'db/admin.php';
require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR . 'db/admin.php';
// Check we're not using single-sign on integration
if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User accounts are handled by external code');
if (QA_FINAL_EXTERNAL_USERS)
qa_fatal_error('User accounts are handled by external code');
// 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'));
$userfields=qa_db_select_with_pending(qa_db_userfields_selectspec());
$users = qa_db_get_unapproved_users(qa_opt('page_size_users'));
$userfields = qa_db_select_with_pending(qa_db_userfields_selectspec());
// Check admin privileges (do late to allow one DB query)
if (qa_get_logged_in_level()<QA_USER_LEVEL_MODERATOR) {
$qa_content=qa_content_prepare();
$qa_content['error']=qa_lang_html('users/no_permission');
return $qa_content;
}
if (qa_get_logged_in_level() < QA_USER_LEVEL_MODERATOR) {
$qa_content = qa_content_prepare();
$qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content;
}
// Check to see if any were approved or blocked here
$pageerror=qa_admin_check_clicks();
$pageerror = qa_admin_check_clicks();
// 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['error']=isset($pageerror) ? $pageerror : qa_admin_page_error();
$qa_content['title'] = qa_lang_html('admin/approve_users_title');
$qa_content['error'] = isset($pageerror) ? $pageerror : qa_admin_page_error();
$qa_content['message_list']=array(
'form' => array(
'tags' => 'method="post" action="'.qa_self_html().'"',
$qa_content['message_list'] = array(
'form' => array(
'tags' => 'method="post" action="' . qa_self_html() . '"',
'hidden' => array(
'code' => qa_get_form_security_code('admin/click'),
),
'hidden' => array(
'code' => qa_get_form_security_code('admin/click'),
),
),
'messages' => array(),
);
'messages' => array(),
);
if (count($users)) {
foreach ($users as $user) {
$message=array();
if (count($users)) {
foreach ($users as $user) {
$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').' '.
strtr(qa_lang_html('users/x_ago_from_y'), array(
'^1' => qa_time_to_string(qa_opt('db_time')-$user['created']),
'^2' => qa_ip_anchor_html(@inet_ntop($user['createip'])),
)).'<br/>';
$message['content'] = qa_lang_html('users/registered_label') . ' ' .
strtr(qa_lang_html('users/x_ago_from_y'), array(
'^1' => qa_time_to_string(qa_opt('db_time') - $user['created']),
'^2' => qa_ip_anchor_html(@inet_ntop($user['createip'])),
)) . '<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'))
$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)
if (strlen(@$user['profile'][$userfield['title']]))
$message['content'].='<br/>'.qa_html($userfield['content'].': '.$user['profile'][$userfield['title']]);
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['meta_order']=qa_lang_html('main/meta_order');
$message['who']['data']=qa_get_one_user_html($user['handle']);
foreach ($userfields as $userfield) {
if (strlen(@$user['profile'][$userfield['title']]))
$message['content'] .= '<br/>' . qa_html($userfield['content'] . ': ' . $user['profile'][$userfield['title']]);
}
$message['form']=array(
'style' => 'light',
$message['meta_order'] = qa_lang_html('main/meta_order');
$message['who']['data'] = qa_get_one_user_html($user['handle']);
'buttons' => array(
'approve' => array(
'tags' => 'name="admin_'.$user['userid'].'_userapprove" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/approve_button'),
'popup' => qa_lang_html('admin/approve_user_popup'),
),
$message['form'] = array(
'style' => 'light',
'block' => array(
'tags' => 'name="admin_'.$user['userid'].'_userblock" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('admin/block_button'),
'popup' => qa_lang_html('admin/block_user_popup'),
),
'buttons' => array(
'approve' => array(
'tags' => 'name="admin_' . $user['userid'] . '_userapprove" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/approve_button'),
'popup' => qa_lang_html('admin/approve_user_popup'),
),
);
$qa_content['message_list']['messages'][]=$message;
}
'block' => array(
'tags' => 'name="admin_' . $user['userid'] . '_userblock" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('admin/block_button'),
'popup' => qa_lang_html('admin/block_user_popup'),
),
),
);
} else
$qa_content['title']=qa_lang_html('admin/no_unapproved_found');
$qa_content['message_list']['messages'][] = $message;
}
} else
$qa_content['title'] = qa_lang_html('admin/no_unapproved_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;
/*
Omit PHP closing tag to help avoid accidental output
*/
return $qa_content;
......@@ -20,121 +20,119 @@
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;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../');
exit;
}
require_once QA_INCLUDE_DIR.'app/admin.php';
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php';
require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
// Find most flagged questions, answers, comments
$userid=qa_get_logged_in_userid();
$userid = qa_get_logged_in_userid();
$questions=qa_db_select_with_pending(
qa_db_flagged_post_qs_selectspec($userid, 0, true)
);
$questions = qa_db_select_with_pending(
qa_db_flagged_post_qs_selectspec($userid, 0, true)
);
// Check admin privileges (do late to allow one DB query)
if (qa_user_maximum_permit_error('permit_hide_show')) {
$qa_content=qa_content_prepare();
$qa_content['error']=qa_lang_html('users/no_permission');
return $qa_content;
}
if (qa_user_maximum_permit_error('permit_hide_show')) {
$qa_content = qa_content_prepare();
$qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content;
}
// 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
if (qa_user_permit_error('permit_hide_show')) // if user not allowed to show/hide all posts
foreach ($questions as $index => $question)
if (qa_user_post_permit_error('permit_hide_show', $question))
unset($questions[$index]);
if (qa_user_permit_error('permit_hide_show')) { // if user not allowed to show/hide all posts
foreach ($questions as $index => $question) {
if (qa_user_post_permit_error('permit_hide_show', $question)) {
unset($questions[$index]);
}
}
}
// 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
$qa_content=qa_content_prepare();
$qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html('admin/most_flagged_title');
$qa_content['error']=isset($pageerror) ? $pageerror : qa_admin_page_error();
$qa_content['title'] = qa_lang_html('admin/most_flagged_title');
$qa_content['error'] = isset($pageerror) ? $pageerror : qa_admin_page_error();
$qa_content['q_list']=array(
'form' => array(
'tags' => 'method="post" action="'.qa_self_html().'"',
$qa_content['q_list'] = array(
'form' => array(
'tags' => 'method="post" action="' . qa_self_html() . '"',
'hidden' => array(
'code' => qa_get_form_security_code('admin/click'),
),
'hidden' => array(
'code' => qa_get_form_security_code('admin/click'),
),
),
'qs' => array(),
);
'qs' => array(),
);
if (count($questions)) {
foreach ($questions as $question) {
$postid=qa_html(isset($question['opostid']) ? $question['opostid'] : $question['postid']);
$elementid='p'.$postid;
$htmloptions=qa_post_html_options($question);
$htmloptions['voteview']=false;
$htmloptions['tagsview']=($question['obasetype']=='Q');
$htmloptions['answersview']=false;
$htmloptions['viewsview']=false;
$htmloptions['contentview']=true;
$htmloptions['flagsview']=true;
$htmloptions['elementid']=$elementid;
if (count($questions)) {
foreach ($questions as $question) {
$postid = qa_html(isset($question['opostid']) ? $question['opostid'] : $question['postid']);
$elementid = 'p' . $postid;
$htmlfields=qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions);
$htmloptions = qa_post_html_options($question);
$htmloptions['voteview'] = false;
$htmloptions['tagsview'] = ($question['obasetype'] == 'Q');
$htmloptions['answersview'] = false;
$htmloptions['viewsview'] = false;
$htmloptions['contentview'] = true;
$htmloptions['flagsview'] = true;
$htmloptions['elementid'] = $elementid;
if (isset($htmlfields['what_url'])) // link directly to relevant content
$htmlfields['url']=$htmlfields['what_url'];
$htmlfields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions);
$htmlfields['form']=array(
'style' => 'light',
if (isset($htmlfields['what_url'])) // link directly to relevant content
$htmlfields['url'] = $htmlfields['what_url'];
'buttons' => array(
'clearflags' => array(
'tags' => 'name="admin_'.$postid.'_clearflags" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/clear_flags_button'),
),
$htmlfields['form'] = array(
'style' => 'light',
'hide' => array(
'tags' => 'name="admin_'.$postid.'_hide" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/hide_button'),
),
'buttons' => array(
'clearflags' => array(
'tags' => 'name="admin_' . $postid . '_clearflags" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/clear_flags_button'),
),
);
$qa_content['q_list']['qs'][]=$htmlfields;
}
} else
$qa_content['title']=qa_lang_html('admin/no_flagged_found');
'hide' => array(
'tags' => 'name="admin_' . $postid . '_hide" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/hide_button'),
),
),
);
$qa_content['q_list']['qs'][] = $htmlfields;
}
$qa_content['navigation']['sub']=qa_admin_sub_navigation();
$qa_content['script_rel'][]='qa-content/qa-admin.js?'.QA_VERSION;
} else
$qa_content['title'] = qa_lang_html('admin/no_flagged_found');
return $qa_content;
$qa_content['navigation']['sub'] = qa_admin_sub_navigation();
$qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return $qa_content;
......@@ -20,152 +20,153 @@
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;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../');
exit;
}
require_once QA_INCLUDE_DIR.'app/admin.php';
require_once QA_INCLUDE_DIR.'db/admin.php';
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php';
require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR . 'db/admin.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
// 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(
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_c_qs_selectspec($userid, 0, null, null, 'C_HIDDEN', true)
);
list($hiddenquestions, $hiddenanswers, $hiddencomments) = qa_db_select_with_pending(
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_c_qs_selectspec($userid, 0, null, null, 'C_HIDDEN', true)
);
// 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')) {
$qa_content=qa_content_prepare();
$qa_content['error']=qa_lang_html('users/no_permission');
return $qa_content;
}
if (qa_user_maximum_permit_error('permit_hide_show') && qa_user_maximum_permit_error('permit_delete_hidden')) {
$qa_content = qa_content_prepare();
$qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content;
}
// 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
$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
foreach ($questions as $index => $question)
if (qa_user_post_permit_error('permit_hide_show', $question) && qa_user_post_permit_error('permit_delete_hidden', $question))
unset($questions[$index]);
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) {
if (qa_user_post_permit_error('permit_hide_show', $question) && qa_user_post_permit_error('permit_delete_hidden', $question)) {
unset($questions[$index]);
}
}
}
// 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
$qhiddenpostid=array();
foreach ($questions as $key => $question)
$qhiddenpostid[$key]=isset($question['opostid']) ? $question['opostid'] : $question['postid'];
$qhiddenpostid = array();
foreach ($questions as $key => $question)
$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
$qa_content=qa_content_prepare();
$qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html('admin/recent_hidden_title');
$qa_content['error']=isset($pageerror) ? $pageerror : qa_admin_page_error();
$qa_content['title'] = qa_lang_html('admin/recent_hidden_title');
$qa_content['error'] = isset($pageerror) ? $pageerror : qa_admin_page_error();
$qa_content['q_list']=array(
'form' => array(
'tags' => 'method="post" action="'.qa_self_html().'"',
$qa_content['q_list'] = array(
'form' => array(
'tags' => 'method="post" action="' . qa_self_html() . '"',
'hidden' => array(
'code' => qa_get_form_security_code('admin/click'),
),
'hidden' => array(
'code' => qa_get_form_security_code('admin/click'),
),
),
'qs' => array(),
);
if (count($questions)) {
foreach ($questions as $key => $question) {
$elementid = 'p' . $qhiddenpostid[$key];
$htmloptions = qa_post_html_options($question);
$htmloptions['voteview'] = false;
$htmloptions['tagsview'] = !isset($question['opostid']);
$htmloptions['answersview'] = false;
$htmloptions['viewsview'] = false;
$htmloptions['updateview'] = false;
$htmloptions['contentview'] = true;
$htmloptions['flagsview'] = true;
$htmloptions['elementid'] = $elementid;
$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
$htmlfields['url'] = $htmlfields['what_url'];
$htmlfields['what_2'] = qa_lang_html('main/hidden');
'qs' => array(),
);
if (count($questions)) {
foreach ($questions as $key => $question) {
$elementid='p'.$qhiddenpostid[$key];
$htmloptions=qa_post_html_options($question);
$htmloptions['voteview']=false;
$htmloptions['tagsview']=!isset($question['opostid']);
$htmloptions['answersview']=false;
$htmloptions['viewsview']=false;
$htmloptions['updateview']=false;
$htmloptions['contentview']=true;
$htmloptions['flagsview']=true;
$htmloptions['elementid']=$elementid;
$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
$htmlfields['url']=$htmlfields['what_url'];
$htmlfields['what_2']=qa_lang_html('main/hidden');
if (@$htmloptions['whenview']) {
$updated=@$question[isset($question['opostid']) ? 'oupdated' : 'updated'];
if (isset($updated))
$htmlfields['when_2']=qa_when_to_html($updated, @$htmloptions['fulldatedays']);
}
$buttons=array();
$posttype = qa_strtolower(isset($question['obasetype']) ? $question['obasetype'] : $question['basetype']);
if (!qa_user_post_permit_error('permit_hide_show', $question))
// Possible values for popup: reshow_q_popup, reshow_a_popup, reshow_c_popup
$buttons['reshow']=array(
'tags' => 'name="admin_'.qa_html($qhiddenpostid[$key]).'_reshow" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/reshow_button'),
'popup' => qa_lang_html(sprintf('question/reshow_%s_popup', $posttype)),
);
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
$buttons['delete']=array(
'tags' => 'name="admin_'.qa_html($qhiddenpostid[$key]).'_delete" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/delete_button'),
'popup' => qa_lang_html(sprintf('question/delete_%s_popup', $posttype)),
);
if (count($buttons))
$htmlfields['form']=array(
'style' => 'light',
'buttons' => $buttons,
);
$qa_content['q_list']['qs'][]=$htmlfields;
if (@$htmloptions['whenview']) {
$updated = @$question[isset($question['opostid']) ? 'oupdated' : 'updated'];
if (isset($updated))
$htmlfields['when_2'] = qa_when_to_html($updated, @$htmloptions['fulldatedays']);
}
} else
$qa_content['title']=qa_lang_html('admin/no_hidden_found');
$buttons = array();
$posttype = qa_strtolower(isset($question['obasetype']) ? $question['obasetype'] : $question['basetype']);
$qa_content['navigation']['sub']=qa_admin_sub_navigation();
$qa_content['script_rel'][]='qa-content/qa-admin.js?'.QA_VERSION;
if (!qa_user_post_permit_error('permit_hide_show', $question)) {
// Possible values for popup: reshow_q_popup, reshow_a_popup, reshow_c_popup
$buttons['reshow'] = array(
'tags' => 'name="admin_' . qa_html($qhiddenpostid[$key]) . '_reshow" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/reshow_button'),
'popup' => qa_lang_html(sprintf('question/reshow_%s_popup', $posttype)),
);
}
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
$buttons['delete'] = array(
'tags' => 'name="admin_' . qa_html($qhiddenpostid[$key]) . '_delete" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/delete_button'),
'popup' => qa_lang_html(sprintf('question/delete_%s_popup', $posttype)),
);
}
return $qa_content;
if (count($buttons)) {
$htmlfields['form'] = array(
'style' => 'light',
'buttons' => $buttons,
);
}
$qa_content['q_list']['qs'][] = $htmlfields;
}
} else
$qa_content['title'] = qa_lang_html('admin/no_hidden_found');
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
$qa_content['navigation']['sub'] = qa_admin_sub_navigation();
$qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
return $qa_content;
......@@ -20,144 +20,141 @@
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;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../');
exit;
}
require_once QA_INCLUDE_DIR.'app/admin.php';
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php';
require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
// 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(
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_c_qs_selectspec($userid, 0, null, null, 'C_QUEUED', true)
);
list($queuedquestions, $queuedanswers, $queuedcomments) = qa_db_select_with_pending(
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_c_qs_selectspec($userid, 0, null, null, 'C_QUEUED', true)
);
// Check admin privileges (do late to allow one DB query)
if (qa_user_maximum_permit_error('permit_moderate')) {
$qa_content=qa_content_prepare();
$qa_content['error']=qa_lang_html('users/no_permission');
return $qa_content;
}
if (qa_user_maximum_permit_error('permit_moderate')) {
$qa_content = qa_content_prepare();
$qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content;
}
// 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
$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
foreach ($questions as $index => $question)
if (qa_user_post_permit_error('permit_moderate', $question))
unset($questions[$index]);
if (qa_user_permit_error('permit_moderate')) { // if user not allowed to moderate all posts
foreach ($questions as $index => $question) {
if (qa_user_post_permit_error('permit_moderate', $question))
unset($questions[$index]);
}
}
// 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
$qa_content=qa_content_prepare();
$qa_content = qa_content_prepare();
$qa_content['title']=qa_lang_html('admin/recent_approve_title');
$qa_content['error']=isset($pageerror) ? $pageerror : qa_admin_page_error();
$qa_content['title'] = qa_lang_html('admin/recent_approve_title');
$qa_content['error'] = isset($pageerror) ? $pageerror : qa_admin_page_error();
$qa_content['q_list']=array(
'form' => array(
'tags' => 'method="post" action="'.qa_self_html().'"',
$qa_content['q_list'] = array(
'form' => array(
'tags' => 'method="post" action="' . qa_self_html() . '"',
'hidden' => array(
'code' => qa_get_form_security_code('admin/click'),
),
'hidden' => array(
'code' => qa_get_form_security_code('admin/click'),
),
),
'qs' => array(),
);
if (count($questions)) {
foreach ($questions as $question) {
$postid = qa_html(isset($question['opostid']) ? $question['opostid'] : $question['postid']);
$elementid = 'p' . $postid;
$htmloptions = qa_post_html_options($question);
$htmloptions['voteview'] = false;
$htmloptions['tagsview'] = !isset($question['opostid']);
$htmloptions['answersview'] = false;
$htmloptions['viewsview'] = false;
$htmloptions['contentview'] = true;
$htmloptions['elementid'] = $elementid;
$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
$htmlfields['url'] = $htmlfields['what_url'];
$posttype = qa_strtolower(isset($question['obasetype']) ? $question['obasetype'] : $question['basetype']);
switch ($posttype) {
case 'q':
default:
$approveKey = 'question/approve_q_popup';
$rejectKey = 'question/reject_q_popup';
break;
case 'a':
$approveKey = 'question/approve_a_popup';
$rejectKey = 'question/reject_a_popup';
break;
case 'c':
$approveKey = 'question/approve_c_popup';
$rejectKey = 'question/reject_c_popup';
break;
}
'qs' => array(),
);
if (count($questions)) {
foreach ($questions as $question) {
$postid=qa_html(isset($question['opostid']) ? $question['opostid'] : $question['postid']);
$elementid='p'.$postid;
$htmloptions=qa_post_html_options($question);
$htmloptions['voteview']=false;
$htmloptions['tagsview']=!isset($question['opostid']);
$htmloptions['answersview']=false;
$htmloptions['viewsview']=false;
$htmloptions['contentview']=true;
$htmloptions['elementid']=$elementid;
$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
$htmlfields['url']=$htmlfields['what_url'];
$posttype = qa_strtolower(isset($question['obasetype']) ? $question['obasetype'] : $question['basetype']);
switch ($posttype) {
case 'q':
default:
$approveKey = 'question/approve_q_popup';
$rejectKey = 'question/reject_q_popup';
break;
case 'a':
$approveKey = 'question/approve_a_popup';
$rejectKey = 'question/reject_a_popup';
break;
case 'c':
$approveKey = 'question/approve_c_popup';
$rejectKey = 'question/reject_c_popup';
break;
}
$htmlfields['form']=array(
'style' => 'light',
'buttons' => array(
// Possible values for popup: approve_q_popup, approve_a_popup, approve_c_popup
'approve' => array(
'tags' => 'name="admin_'.$postid.'_approve" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/approve_button'),
'popup' => qa_lang_html($approveKey),
),
// Possible values for popup: reject_q_popup, reject_a_popup, reject_c_popup
'reject' => array(
'tags' => 'name="admin_'.$postid.'_reject" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/reject_button'),
'popup' => qa_lang_html($rejectKey),
),
),
);
$htmlfields['form'] = array(
'style' => 'light',
$qa_content['q_list']['qs'][]=$htmlfields;
}
'buttons' => array(
// Possible values for popup: approve_q_popup, approve_a_popup, approve_c_popup
'approve' => array(
'tags' => 'name="admin_' . $postid . '_approve" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/approve_button'),
'popup' => qa_lang_html($approveKey),
),
} else
$qa_content['title']=qa_lang_html('admin/no_approve_found');
// Possible values for popup: reject_q_popup, reject_a_popup, reject_c_popup
'reject' => array(
'tags' => 'name="admin_' . $postid . '_reject" onclick="return qa_admin_click(this);"',
'label' => qa_lang_html('question/reject_button'),
'popup' => qa_lang_html($rejectKey),
),
),
);
$qa_content['q_list']['qs'][] = $htmlfields;
}
$qa_content['navigation']['sub']=qa_admin_sub_navigation();
$qa_content['script_rel'][]='qa-content/qa-admin.js?'.QA_VERSION;
} else
$qa_content['title'] = qa_lang_html('admin/no_approve_found');
return $qa_content;
$qa_content['navigation']['sub'] = qa_admin_sub_navigation();
$qa_content['script_rel'][] = 'qa-content/qa-admin.js?' . QA_VERSION;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return $qa_content;
......@@ -20,168 +20,163 @@
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;
}
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.'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';
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;
if (!qa_admin_check_privileges($qa_content))
return $qa_content;
// 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);
foreach ($optionnames as $optionname)
$options[$optionname] = qa_default_option($optionname);
} else {
if (qa_clicked('docancel'))
;
} else {
if (qa_clicked('docancel'))
;
elseif (qa_clicked('dosaverecalc')) {
if (!qa_check_form_security_code('admin/points', qa_post_text('code')))
$securityexpired=true;
elseif (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));
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;
}
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
$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'),
);
$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');
} 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['form']['buttons']['showdefaults']=array(
'tags' => 'name="doshowdefaults"',
'label' => qa_lang_html('admin/show_defaults_button'),
$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'),
);
}
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_q_voted_max_gain':
case 'points_a_voted_max_gain':
$prefix='+';
break;
case 'points_per_q_voted_down':
case 'points_per_a_voted_down':
case 'points_q_voted_max_loss':
case 'points_a_voted_max_loss':
$prefix='&ndash;';
break;
case 'points_base':
$prefix='+';
break;
default:
$prefix='<span style="visibility:hidden;">+</span>'; // for even alignment
break;
}
$optionfield['prefix']='<span style="width:1em; display:inline-block; display:-moz-inline-stack;">'.$prefix.'</span>';
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'),
);
$qa_content['form']['fields'][$optionname]=$optionfield;
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_q_voted_max_gain':
case 'points_a_voted_max_gain':
$prefix = '+';
break;
case 'points_per_q_voted_down':
case 'points_per_a_voted_down':
case 'points_q_voted_max_loss':
case 'points_a_voted_max_loss':
$prefix = '&ndash;';
break;
case 'points_base':
$prefix = '+';
break;
default:
$prefix = '<span style="visibility:hidden;">+</span>'; // for even alignment
break;
}
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')));
$optionfield['prefix'] = '<span style="width:1em; display:inline-block; display:-moz-inline-stack;">' . $prefix . '</span>';
$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();
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return $qa_content;
......@@ -20,118 +20,114 @@
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;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../');
exit;
}
require_once QA_INCLUDE_DIR.'app/admin.php';
require_once QA_INCLUDE_DIR.'app/recalc.php';
require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR . 'app/recalc.php';
// Check we have administrative privileges
if (!qa_admin_check_privileges($qa_content))
return $qa_content;
if (!qa_admin_check_privileges($qa_content))
return $qa_content;
// Find out the operation
$allowstates=array(
'dorecountposts',
'doreindexcontent',
'dorecalcpoints',
'dorefillevents',
'dorecalccategories',
'dodeletehidden',
'doblobstodisk',
'doblobstodb',
);
$recalcnow=false;
foreach ($allowstates as $allowstate)
if (qa_post_text($allowstate) || qa_get($allowstate)) {
$state=$allowstate;
$code=qa_post_text('code');
if (isset($code) && qa_check_form_security_code('admin/recalc', $code))
$recalcnow=true;
}
if ($recalcnow) {
?>
$allowstates = array(
'dorecountposts',
'doreindexcontent',
'dorecalcpoints',
'dorefillevents',
'dorecalccategories',
'dodeletehidden',
'doblobstodisk',
'doblobstodb',
);
$recalcnow = false;
foreach ($allowstates as $allowstate) {
if (qa_post_text($allowstate) || qa_get($allowstate)) {
$state = $allowstate;
$code = qa_post_text('code');
if (isset($code) && qa_check_form_security_code('admin/recalc', $code))
$recalcnow = true;
}
}
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<tt>
if ($recalcnow) {
?>
<?php
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<tt>
while ($state) {
set_time_limit(60);
<?php
$stoptime=time()+2; // run in lumps of two seconds...
while ($state) {
set_time_limit(60);
while ( qa_recalc_perform_step($state) && (time()<$stoptime) )
;
$stoptime = time() + 2; // run in lumps of two seconds...
echo qa_html(qa_recalc_get_message($state)).str_repeat(' ', 1024)."<br>\n";
while (qa_recalc_perform_step($state) && time() < $stoptime)
;
flush();
sleep(1); // ... then rest for one
}
echo qa_html(qa_recalc_get_message($state)) . str_repeat(' ', 1024) . "<br>\n";
?>
</tt>
flush();
sleep(1); // ... then rest for one
}
<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>
</html>
?>
</tt>
<?php
qa_exit();
<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>
</html>
} elseif (isset($state)) {
$qa_content=qa_content_prepare();
<?php
qa_exit();
$qa_content['title']=qa_lang_html('admin/admin_title');
$qa_content['error']=qa_lang_html('misc/form_security_again');
} elseif (isset($state)) {
$qa_content = qa_content_prepare();
$qa_content['form']=array(
'tags' => 'method="post" action="'.qa_self_html().'"',
$qa_content['title'] = qa_lang_html('admin/admin_title');
$qa_content['error'] = qa_lang_html('misc/form_security_again');
'style' => 'wide',
$qa_content['form'] = array(
'tags' => 'method="post" action="' . qa_self_html() . '"',
'buttons' => array(
'recalc' => array(
'tags' => 'name="'.qa_html($state).'"',
'label' => qa_lang_html('misc/form_security_again'),
),
),
'style' => 'wide',
'hidden' => array(
'code' => qa_get_form_security_code('admin/recalc'),
'buttons' => array(
'recalc' => array(
'tags' => 'name="' . qa_html($state) . '"',
'label' => qa_lang_html('misc/form_security_again'),
),
);
return $qa_content;
),
} else {
require_once QA_INCLUDE_DIR.'app/format.php';
'hidden' => array(
'code' => qa_get_form_security_code('admin/recalc'),
),
);
$qa_content=qa_content_prepare();
return $qa_content;
$qa_content['title']=qa_lang_html('admin/admin_title');
$qa_content['error']=qa_lang_html('main/page_not_found');
} else {
require_once QA_INCLUDE_DIR . 'app/format.php';
return $qa_content;
}
$qa_content = qa_content_prepare();
$qa_content['title'] = qa_lang_html('admin/admin_title');
$qa_content['error'] = qa_lang_html('main/page_not_found');
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
return $qa_content;
}
......@@ -20,166 +20,162 @@
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;
}
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../');
exit;
}
require_once QA_INCLUDE_DIR.'app/admin.php';
require_once QA_INCLUDE_DIR.'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/admin.php';
require_once QA_INCLUDE_DIR . 'db/selects.php';
// Get current list of user titles and determine the state of this admin page
$oldpoints=qa_post_text('edit');
if (!isset($oldpoints))
$oldpoints=qa_get('edit');
$oldpoints = qa_post_text('edit');
if (!isset($oldpoints))
$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)
if (!qa_admin_check_privileges($qa_content))
return $qa_content;
if (!qa_admin_check_privileges($qa_content))
return $qa_content;
// Process saving an old or new user title
$securityexpired=false;
$securityexpired = false;
if (qa_clicked('docancel'))
qa_redirect('admin/users');
if (qa_clicked('docancel'))
qa_redirect('admin/users');
elseif (qa_clicked('dosavetitle')) {
require_once QA_INCLUDE_DIR.'util/string.php';
elseif (qa_clicked('dosavetitle')) {
require_once QA_INCLUDE_DIR . 'util/string.php';
if (!qa_check_form_security_code('admin/usertitles', qa_post_text('code')))
$securityexpired=true;
if (!qa_check_form_security_code('admin/usertitles', qa_post_text('code')))
$securityexpired = true;
else {
if (qa_post_text('dodelete')) {
unset($pointstitle[$oldpoints]);
else {
if (qa_post_text('dodelete')) {
unset($pointstitle[$oldpoints]);
} else {
$intitle=qa_post_text('title');
$inpoints=qa_post_text('points');
} else {
$intitle = qa_post_text('title');
$inpoints = qa_post_text('points');
$errors=array();
$errors = array();
// Verify the title and points are legitimate
if (!strlen($intitle))
$errors['title']=qa_lang('main/field_required');
if (!strlen($intitle))
$errors['title'] = qa_lang('main/field_required');
if (!is_numeric($inpoints))
$errors['points']=qa_lang('main/field_required');
else {
$inpoints=(int)$inpoints;
if (!is_numeric($inpoints))
$errors['points'] = qa_lang('main/field_required');
else {
$inpoints = (int)$inpoints;
if (isset($pointstitle[$inpoints]) && ((!strlen(@$oldpoints)) || ($inpoints!=$oldpoints)) )
$errors['points']=qa_lang('admin/title_already_used');
}
if (isset($pointstitle[$inpoints]) && ((!strlen(@$oldpoints)) || ($inpoints != $oldpoints)))
$errors['points'] = qa_lang('admin/title_already_used');
}
// Perform appropriate action
if (isset($pointstitle[$oldpoints])) { // changing existing user title
$newpoints=isset($errors['points']) ? $oldpoints : $inpoints;
$newtitle=isset($errors['title']) ? $pointstitle[$oldpoints] : $intitle;
if (isset($pointstitle[$oldpoints])) { // changing existing user title
$newpoints = isset($errors['points']) ? $oldpoints : $inpoints;
$newtitle = isset($errors['title']) ? $pointstitle[$oldpoints] : $intitle;
unset($pointstitle[$oldpoints]);
$pointstitle[$newpoints]=$newtitle;
unset($pointstitle[$oldpoints]);
$pointstitle[$newpoints] = $newtitle;
} elseif (empty($errors)) // creating a new user title
$pointstitle[$inpoints]=$intitle;
}
} elseif (empty($errors)) // creating a new user title
$pointstitle[$inpoints] = $intitle;
}
// Save the new option value
krsort($pointstitle, SORT_NUMERIC);
krsort($pointstitle, SORT_NUMERIC);
$option='';
foreach ($pointstitle as $points => $title)
$option.=(strlen($option) ? ',' : '').$points.' '.$title;
$option = '';
foreach ($pointstitle as $points => $title)
$option .= (strlen($option) ? ',' : '') . $points . ' ' . $title;
qa_set_option('points_to_titles', $option);
qa_set_option('points_to_titles', $option);
if (empty($errors))
qa_redirect('admin/users');
}
if (empty($errors))
qa_redirect('admin/users');
}
}
// Prepare content for theme
$qa_content=qa_content_prepare();
$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['form']=array(
'tags' => 'method="post" action="'.qa_path_html(qa_request()).'"',
'style' => 'tall',
'fields' => array(
'title' => array(
'tags' => 'name="title" id="title"',
'label' => qa_lang_html('admin/user_title'),
'value' => qa_html(isset($intitle) ? $intitle : @$pointstitle[$oldpoints]),
'error' => qa_html(@$errors['title']),
),
'delete' => array(
'tags' => 'name="dodelete" id="dodelete"',
'label' => qa_lang_html('admin/delete_title'),
'value' => 0,
'type' => 'checkbox',
),
'points' => array(
'id' => 'points_display',
'tags' => 'name="points"',
'label' => qa_lang_html('admin/points_required'),
'type' => 'number',
'value' => qa_html(isset($inpoints) ? $inpoints : @$oldpoints),
'error' => qa_html(@$errors['points']),
),
$qa_content = qa_content_prepare();
$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['form'] = array(
'tags' => 'method="post" action="' . qa_path_html(qa_request()) . '"',
'style' => 'tall',
'fields' => array(
'title' => array(
'tags' => 'name="title" id="title"',
'label' => qa_lang_html('admin/user_title'),
'value' => qa_html(isset($intitle) ? $intitle : @$pointstitle[$oldpoints]),
'error' => qa_html(@$errors['title']),
),
'buttons' => array(
'save' => array(
'label' => qa_lang_html(isset($pointstitle[$oldpoints]) ? 'main/save_button' : ('admin/add_title_button')),
),
'delete' => array(
'tags' => 'name="dodelete" id="dodelete"',
'label' => qa_lang_html('admin/delete_title'),
'value' => 0,
'type' => 'checkbox',
),
'cancel' => array(
'tags' => 'name="docancel"',
'label' => qa_lang_html('main/cancel_button'),
),
'points' => array(
'id' => 'points_display',
'tags' => 'name="points"',
'label' => qa_lang_html('admin/points_required'),
'type' => 'number',
'value' => qa_html(isset($inpoints) ? $inpoints : @$oldpoints),
'error' => qa_html(@$errors['points']),
),
),
'hidden' => array(
'dosavetitle' => '1', // for IE
'edit' => @$oldpoints,
'code' => qa_get_form_security_code('admin/usertitles'),
'buttons' => array(
'save' => array(
'label' => qa_lang_html(isset($pointstitle[$oldpoints]) ? 'main/save_button' : ('admin/add_title_button')),
),
);
if (isset($pointstitle[$oldpoints]))
qa_set_display_rules($qa_content, array(
'points_display' => '!dodelete',
));
else
unset($qa_content['form']['fields']['delete']);
'cancel' => array(
'tags' => 'name="docancel"',
'label' => qa_lang_html('main/cancel_button'),
),
),
$qa_content['focusid']='title';
'hidden' => array(
'dosavetitle' => '1', // for IE
'edit' => @$oldpoints,
'code' => qa_get_form_security_code('admin/usertitles'),
),
);
$qa_content['navigation']['sub']=qa_admin_sub_navigation();
if (isset($pointstitle[$oldpoints])) {
qa_set_display_rules($qa_content, array(
'points_display' => '!dodelete',
));
} else {
unset($qa_content['form']['fields']['delete']);
}
$qa_content['focusid'] = 'title';
return $qa_content;
$qa_content['navigation']['sub'] = qa_admin_sub_navigation();
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
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