function user_news_comments() { global $user; $html = '<div class="col-md-12"><h1>' . user_news_comments_title() . '</h1>'; if (isset($_REQUEST["nid"]) && preg_match("/^[0-9]{1,}\$/", $_REQUEST['nid']) && sql_num_query("SELECT * FROM `News` WHERE `ID`='" . sql_escape($_REQUEST['nid']) . "' LIMIT 1") > 0) { $nid = $_REQUEST["nid"]; list($news) = sql_select("SELECT * FROM `News` WHERE `ID`='" . sql_escape($nid) . "' LIMIT 1"); if (isset($_REQUEST["text"])) { $text = preg_replace("/([^\\p{L}\\p{P}\\p{Z}\\p{N}\n]{1,})/ui", '', strip_tags($_REQUEST['text'])); sql_query("INSERT INTO `NewsComments` (`Refid`, `Datum`, `Text`, `UID`) VALUES ('" . sql_escape($nid) . "', '" . date("Y-m-d H:i:s") . "', '" . sql_escape($text) . "', '" . sql_escape($user["UID"]) . "')"); engelsystem_log("Created news_comment: " . $text); $html .= success(_("Entry saved."), true); } $html .= display_news($news); $comments = sql_select("SELECT * FROM `NewsComments` WHERE `Refid`='" . sql_escape($nid) . "' ORDER BY 'ID'"); foreach ($comments as $comment) { $user_source = User($comment['UID']); if ($user_source === false) { engelsystem_error(_("Unable to load user.")); } $html .= '<div class="panel panel-default">'; $html .= '<div class="panel-body">' . nl2br($comment['Text']) . '</div>'; $html .= '<div class="panel-footer text-muted">'; $html .= '<span class="glyphicon glyphicon-time"></span> ' . $comment['Datum'] . ' '; $html .= User_Nick_render($user_source); $html .= '</div>'; $html .= '</div>'; } $html .= '<hr /><h2>' . _("New Comment:") . '</h2>'; $html .= form(array(form_textarea('text', _("Message"), ''), form_submit('submit', _("Save"))), page_link_to('news_comments') . '&nid=' . $news['ID']); } else { $html .= _("Invalid request."); } return $html . '</div>'; }
} elseif ($p == "shifts") { list($title, $content) = shifts_controller(); } elseif ($p == "users") { list($title, $content) = users_controller(); } elseif ($p == "user_angeltypes") { list($title, $content) = user_angeltypes_controller(); } elseif ($p == "user_driver_licenses") { list($title, $content) = user_driver_licenses_controller(); } elseif ($p == "shifttypes") { list($title, $content) = shifttypes_controller(); } elseif ($p == "news") { $title = news_title(); $content = user_news(); } elseif ($p == "news_comments") { require_once realpath(__DIR__ . '/../includes/pages/user_news.php'); $title = user_news_comments_title(); $content = user_news_comments(); } elseif ($p == "user_meetings") { $title = meetings_title(); $content = user_meetings(); } elseif ($p == "user_myshifts") { $title = myshifts_title(); $content = user_myshifts(); } elseif ($p == "user_shifts") { $title = shifts_title(); $content = user_shifts(); } elseif ($p == "user_messages") { $title = messages_title(); $content = user_messages(); } elseif ($p == "user_questions") { $title = questions_title();