Gazelle/sections/questions/questions.php

95 lines
3.1 KiB
PHP
Raw Normal View History

2013-10-13 08:01:01 +00:00
<?
if (!check_perms("users_mod")) {
error(404);
}
2013-12-12 08:01:01 +00:00
Text::$TOC = true;
2015-10-27 08:00:28 +00:00
define('QUESTIONS_PER_PAGE', 25);
list($Page, $Limit) = Format::page_limit(QUESTIONS_PER_PAGE);
2013-10-13 08:01:01 +00:00
$DB->query("
2013-10-14 08:00:53 +00:00
SELECT
uq.ID,
uq.Question,
uq.UserID,
uq.Date,
(
SELECT COUNT(1)
2013-11-17 08:00:47 +00:00
FROM staff_answers AS sa
WHERE sa.QuestionID = uq.ID
2013-10-14 08:00:53 +00:00
) AS Responses
FROM user_questions AS uq
WHERE uq.ID NOT IN
2013-10-19 08:01:09 +00:00
(
SELECT siq.QuestionID
FROM staff_ignored_questions AS siq
WHERE siq.UserID = '$LoggedUser[ID]'
)
AND uq.ID NOT IN
(
SELECT sq.QuestionID
FROM staff_answers AS sq
WHERE sq.UserID = '$LoggedUser[ID]'
)
2015-10-27 08:00:28 +00:00
ORDER BY uq.Date DESC
LIMIT $Limit");
2013-10-13 08:01:01 +00:00
$Questions = $DB->to_array();
2013-10-14 08:00:53 +00:00
$DB->query("
SELECT COUNT(1)
FROM user_questions");
2013-10-13 08:01:01 +00:00
list($TotalQuestions) = $DB->next_record();
2013-10-30 08:01:19 +00:00
View::show_header('Ask the Staff', 'questions,bbcode');
2015-10-27 08:00:28 +00:00
if ($TotalQuestions > QUESTIONS_PER_PAGE) { ?>
<div class="linkbox">
<?
$Pages = Format::get_pages($Page, $TotalQuestions, QUESTIONS_PER_PAGE);
echo $Pages;?>
</div>
<? } ?>
2013-10-13 08:01:01 +00:00
<div class="thin">
2013-10-14 08:00:53 +00:00
<div class="header">
2014-03-23 08:00:50 +00:00
<h2>User Questions</h2>
<h3><?=number_format($TotalQuestions)?> questions asked; <?=number_format(count($Questions))?> left to answer</h3>
2013-10-14 08:00:53 +00:00
</div>
2013-10-13 08:01:01 +00:00
<div class="linkbox">
<a class="brackets" href="questions.php?action=answers">View staff answers</a>
2013-10-14 08:00:53 +00:00
<a class="brackets" href="questions.php?action=popular_questions">Popular questions</a>
2013-10-13 08:01:01 +00:00
</div>
<? foreach($Questions as $Question) { ?>
<div id="question<?=$Question['ID']?>" class="box box2">
<div class="head">
<span>
<a class="post_id" href="questions.php#question<?=$Question['ID']?>">#<?=$Question['ID']?></a>
<?=Users::format_username($Question['UserID'])?> - <?=time_diff($Question['Date'])?>
</span>
<span style="float: right;">
2013-10-14 08:00:53 +00:00
<? if ($Question['Responses'] > 0) { ?>
<a href="#" id="<?=$Question['ID']?>" class="view_responses brackets"><?=$Question['Responses'] == 1 ? ("View " . $Question['Responses'] . " response") : ("View " . $Question['Responses'] . " responses")?></a>
-
<? } ?>
2013-10-22 08:01:07 +00:00
<form class="hidden" id="delete_<?=$Question['ID']?>" method="post" action="">
2013-10-13 08:01:01 +00:00
<input type="hidden" name="action" value="take_remove_question" />
<input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
<input type="hidden" name="question_id" value="<?=$Question['ID']?>" />
</form>
2013-10-14 08:00:53 +00:00
<a href="#" onclick="if (confirm('Are you sure?') == true) { $('#delete_<?=$Question['ID']?>').raw().submit(); } return false;" class="brackets">Delete</a>
-
2013-10-28 08:01:14 +00:00
<a href="#" id="<?=$Question['ID']?>" class="brackets ignore_link">Ignore</a>
2013-10-13 08:01:01 +00:00
-
<a href="#" id="<?=$Question['ID']?>" class="answer_link brackets">Answer</a>
</span>
</div>
<div class="pad">
2013-12-12 08:01:01 +00:00
<?=Text::full_format($Question['Question'])?>
2013-10-13 08:01:01 +00:00
</div>
</div>
<div id="answer<?=$Question['ID']?>" class="hidden center box pad">
2013-10-14 08:00:53 +00:00
<? new TEXTAREA_PREVIEW("replybox_" . $Question['ID'], "replybox_" . $Question['ID'], '', 40, 8); ?>
<input type="submit" class="submit submit_button" id="<?=$Question['ID']?>" value="Answer" />
2013-10-13 08:01:01 +00:00
</div>
<? } ?>
</div>
<?
2013-10-14 08:00:53 +00:00
View::show_footer();