From 74647e16d37fac9425a4561b49618b52cdc3e75c Mon Sep 17 00:00:00 2001 From: Philip Häusler Date: Fri, 22 Aug 2014 22:34:13 +0200 Subject: add basic bootstrap theme --- includes/pages/admin_questions.php | 90 +++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 46 deletions(-) (limited to 'includes/pages/admin_questions.php') diff --git a/includes/pages/admin_questions.php b/includes/pages/admin_questions.php index b70495f6..5d4fbd61 100644 --- a/includes/pages/admin_questions.php +++ b/includes/pages/admin_questions.php @@ -5,77 +5,75 @@ function admin_questions_title() { function admin_new_questions() { global $user, $privileges; - + if (in_array("admin_questions", $privileges)) { - $new_messages = sql_num_query("SELECT * FROM `Questions` WHERE `AID`=0"); - + $new_messages = sql_num_query("SELECT * FROM `Questions` WHERE `AID` IS NULL"); + if ($new_messages > 0) - return '

Es gibt unbeantwortete Fragen!


'; + return info('Es gibt unbeantwortete Fragen!', true); } - + return ""; } function admin_questions() { global $user; - - if (!isset ($_REQUEST['action'])) { + + if (! isset($_REQUEST['action'])) { $open_questions = ""; - $questions = sql_select("SELECT * FROM `Questions` WHERE `AID`=0"); + $questions = sql_select("SELECT * FROM `Questions` WHERE `AID` IS NULL"); foreach ($questions as $question) { $user_source = User($question['UID']); - if($user_source === false) + if ($user_source === false) engelsystem_error("Unable to load user."); - - $open_questions .= template_render( - '../templates/admin_question_unanswered.html', array ( - 'question_nick' => User_Nick_render($user_source), - 'question_id' => $question['QID'], - 'link' => page_link_to("admin_questions"), - 'question' => str_replace("\n", '
', $question['Question']) - )); + + $open_questions .= template_render('../templates/admin_question_unanswered.html', array( + 'question_nick' => User_Nick_render($user_source), + 'question_id' => $question['QID'], + 'link' => page_link_to("admin_questions"), + 'question' => str_replace("\n", '
', $question['Question']) + )); } - + $answered_questions = ""; - $questions = sql_select("SELECT * FROM `Questions` WHERE `AID`>0"); - + $questions = sql_select("SELECT * FROM `Questions` WHERE NOT `AID` IS NULL"); + foreach ($questions as $question) { $user_source = User($question['UID']); - if($user_source === false) + if ($user_source === false) engelsystem_error("Unable to load user."); - + $answer_user_source = User($question['AID']); - if($answer_user_source === false) + if ($answer_user_source === false) engelsystem_error("Unable to load user."); - - $answered_questions .= template_render( - '../templates/admin_question_answered.html', array ( - 'question_id' => $question['QID'], - 'question_nick' => User_Nick_render($user_source), - 'question' => str_replace("\n", "
", $question['Question']), - 'answer_nick' => User_Nick_render($answer_user_source), - 'answer' => str_replace("\n", "
", $question['Answer']), - 'link' => page_link_to("admin_questions"), - )); + + $answered_questions .= template_render('../templates/admin_question_answered.html', array( + 'question_id' => $question['QID'], + 'question_nick' => User_Nick_render($user_source), + 'question' => str_replace("\n", "
", $question['Question']), + 'answer_nick' => User_Nick_render($answer_user_source), + 'answer' => str_replace("\n", "
", $question['Answer']), + 'link' => page_link_to("admin_questions") + )); } - - return template_render('../templates/admin_questions.html', array ( - 'link' => page_link_to("admin_questions"), - 'open_questions' => $open_questions, - 'answered_questions' => $answered_questions + + return template_render('../templates/admin_questions.html', array( + 'link' => page_link_to("admin_questions"), + 'open_questions' => $open_questions, + 'answered_questions' => $answered_questions )); } else { switch ($_REQUEST['action']) { - case 'answer' : - if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) + case 'answer': + if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) $id = $_REQUEST['id']; else return error("Incomplete call, missing Question ID.", true); - + $question = sql_select("SELECT * FROM `Questions` WHERE `QID`=" . sql_escape($id) . " LIMIT 1"); - if (count($question) > 0 && $question[0]['AID'] == "0") { + if (count($question) > 0 && $question[0]['AID'] == null) { $answer = trim(preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($_REQUEST['answer']))); - + if ($answer != "") { sql_query("UPDATE `Questions` SET `AID`=" . sql_escape($user['UID']) . ", `Answer`='" . sql_escape($answer) . "' WHERE `QID`=" . sql_escape($id) . " LIMIT 1"); engelsystem_log("Question " . $question[0]['Question'] . " answered: " . $answer); @@ -85,12 +83,12 @@ function admin_questions() { } else return error("No question found.", true); break; - case 'delete' : - if (isset ($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) + case 'delete': + if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) $id = $_REQUEST['id']; else return error("Incomplete call, missing Question ID.", true); - + $question = sql_select("SELECT * FROM `Questions` WHERE `QID`=" . sql_escape($id) . " LIMIT 1"); if (count($question) > 0) { sql_query("DELETE FROM `Questions` WHERE `QID`=" . sql_escape($id) . " LIMIT 1"); -- cgit v1.2.3-70-g09d2