small code improvements

main
msquare 8 years ago
parent b87eb49b93
commit 6dfefc3bb9

@ -42,12 +42,12 @@ function alert($class, $msg, $immediatly = false) {
return ""; return "";
} }
return '<div class="alert alert-' . $class . '">' . $msg . '</div>'; return '<div class="alert alert-' . $class . '">' . $msg . '</div>';
} else {
if (! isset($_SESSION['msg'])) {
$_SESSION['msg'] = "";
}
$_SESSION['msg'] .= alert($class, $msg, true);
} }
if (! isset($_SESSION['msg'])) {
$_SESSION['msg'] = "";
}
$_SESSION['msg'] .= alert($class, $msg, true);
} }
?> ?>

@ -22,6 +22,9 @@ function LogEntries() {
* Returns log entries filtered by a keyword * Returns log entries filtered by a keyword
*/ */
function LogEntries_filter($keyword) { function LogEntries_filter($keyword) {
if ($keyword == "") {
return LogEntries();
}
return sql_select("SELECT * FROM `LogEntries` WHERE `nick` LIKE '%" . sql_escape($keyword) . "%' OR `message` LIKE '%" . sql_escape($keyword) . "%' ORDER BY `timestamp` DESC"); return sql_select("SELECT * FROM `LogEntries` WHERE `nick` LIKE '%" . sql_escape($keyword) . "%' OR `message` LIKE '%" . sql_escape($keyword) . "%' ORDER BY `timestamp` DESC");
} }

@ -43,9 +43,9 @@ function Message_send($receiver_user_id, $text) {
if (($text != "" && is_numeric($receiver_user_id)) && (sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($receiver_user_id) . "' AND NOT `UID`='" . sql_escape($user['UID']) . "' LIMIT 1") > 0)) { if (($text != "" && is_numeric($receiver_user_id)) && (sql_num_query("SELECT * FROM `User` WHERE `UID`='" . sql_escape($receiver_user_id) . "' AND NOT `UID`='" . sql_escape($user['UID']) . "' LIMIT 1") > 0)) {
sql_query("INSERT INTO `Messages` SET `Datum`='" . sql_escape(time()) . "', `SUID`='" . sql_escape($user['UID']) . "', `RUID`='" . sql_escape($receiver_user_id) . "', `Text`='" . sql_escape($text) . "'"); sql_query("INSERT INTO `Messages` SET `Datum`='" . sql_escape(time()) . "', `SUID`='" . sql_escape($user['UID']) . "', `RUID`='" . sql_escape($receiver_user_id) . "', `Text`='" . sql_escape($text) . "'");
return true; return true;
} else {
return false;
} }
return false;
} }
?> ?>

@ -5,13 +5,11 @@ function admin_log_title() {
} }
function admin_log() { function admin_log() {
if (isset($_POST['keyword'])) { $filter = "";
$filter = $_POST['keyword']; if (isset($_REQUEST['keyword'])) {
$log_entries_source = LogEntries_filter($_POST['keyword']); $filter = strip_request_item('keyword');
} else {
$filter = "";
$log_entries_source = LogEntries();
} }
$log_entries_source = LogEntries_filter($_POST['keyword']);
$log_entries = []; $log_entries = [];
foreach ($log_entries_source as $log_entry) { foreach ($log_entries_source as $log_entry) {

@ -13,12 +13,14 @@ function load_auth() {
// User ist eingeloggt, Datensatz zur Verfügung stellen und Timestamp updaten // User ist eingeloggt, Datensatz zur Verfügung stellen und Timestamp updaten
list($user) = $user; list($user) = $user;
sql_query("UPDATE `User` SET " . "`lastLogIn` = '" . time() . "'" . " WHERE `UID` = '" . sql_escape($_SESSION['uid']) . "' LIMIT 1;"); sql_query("UPDATE `User` SET " . "`lastLogIn` = '" . time() . "'" . " WHERE `UID` = '" . sql_escape($_SESSION['uid']) . "' LIMIT 1;");
} else { $privileges = privileges_for_user($user['UID']);
unset($_SESSION['uid']); return;
} }
unset($_SESSION['uid']);
} }
$privileges = isset($user) ? privileges_for_user($user['UID']) : privileges_for_group(- 1); // guest privileges
$privileges = privileges_for_group(- 1);
} }
/** /**

@ -10,10 +10,9 @@
function engelsystem_log($message) { function engelsystem_log($message) {
global $user; global $user;
$nick = "Guest";
if (isset($user)) { if (isset($user)) {
$nick = User_Nick_render($user); $nick = User_Nick_render($user);
} else {
$nick = "Guest";
} }
LogEntry_create($nick, $message); LogEntry_create($nick, $message);
} }

@ -12,13 +12,12 @@
* @return string * @return string
*/ */
function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment, $freeloaded, $freeload_comment, $user_admin_shifts = false) { function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment, $freeloaded, $freeload_comment, $user_admin_shifts = false) {
$freeload_form = [];
if ($user_admin_shifts) { if ($user_admin_shifts) {
$freeload_form = [ $freeload_form = [
form_checkbox('freeloaded', _("Freeloaded"), $freeloaded), form_checkbox('freeloaded', _("Freeloaded"), $freeloaded),
form_textarea('freeload_comment', _("Freeload comment (Only for shift coordination):"), $freeload_comment) form_textarea('freeload_comment', _("Freeload comment (Only for shift coordination):"), $freeload_comment)
]; ];
} else {
$freeload_form = [];
} }
return page_with_title(_("Edit shift entry"), [ return page_with_title(_("Edit shift entry"), [
msg(), msg(),

@ -24,8 +24,9 @@ class Room_model_test extends PHPUnit_Framework_TestCase {
* @after * @after
*/ */
public function teardown() { public function teardown() {
if ($this->room_id != null) if ($this->room_id != null) {
Room_delete($this->room_id); Room_delete($this->room_id);
}
} }
} }

Loading…
Cancel
Save