engelsystem/includes/pages/admin_arrive.php

65 lines
2.2 KiB
PHP
Raw Normal View History

<?php
2013-11-25 21:04:58 +01:00
function admin_arrive_title() {
return _("Arrived angels");
}
function admin_arrive() {
2012-12-26 14:02:27 +01:00
$msg = "";
$search = "";
if (isset ($_REQUEST['search']))
$search = strip_request_item('search');
2011-07-19 21:08:19 +02:00
2012-12-26 14:02:27 +01:00
if (isset ($_REQUEST['reset']) && preg_match("/^[0-9]*$/", $_REQUEST['reset'])) {
$id = $_REQUEST['reset'];
$user_source = User($id);
if($user_source != null) {
sql_query("UPDATE `User` SET `Gekommen`=0 WHERE `UID`=" . sql_escape($id) . " LIMIT 1");
engelsystem_log("User set to not arrived: " . User_Nick_render($user_source));
2012-12-26 14:02:27 +01:00
$msg = success("Reset done. Angel has not arrived.", true);
} else $msg = error("Angel not found.", true);
}
elseif (isset ($_REQUEST['arrived']) && preg_match("/^[0-9]*$/", $_REQUEST['arrived'])) {
$id = $_REQUEST['arrived'];
$user_source = User($id);
if($user_source != null) {
sql_query("UPDATE `User` SET `Gekommen`=1 WHERE `UID`=" . sql_escape($id) . " LIMIT 1");
engelsystem_log("User set has arrived: " . User_Nick_render($user_source));
2012-12-26 14:02:27 +01:00
$msg = success("Angel has been marked as arrived.", true);
} else $msg = error("Angel not found.", true);
}
2011-07-19 21:08:19 +02:00
2012-12-26 14:02:27 +01:00
$users = sql_select("SELECT * FROM `User` ORDER BY `Nick`");
$table = "";
if ($search == "")
$tokens = array ();
else
$tokens = explode(" ", $search);
foreach ($users as $usr) {
if (count($tokens) > 0) {
$match = false;
$index = join("", $usr);
foreach ($tokens as $t)
2012-12-27 14:24:05 +01:00
if (stristr($index, trim($t))) {
2012-12-26 14:02:27 +01:00
$match = true;
break;
}
if (!$match)
continue;
}
$table .= '<tr>';
$table .= '<td>' . User_Nick_render($usr) . '</td>';
2012-12-26 14:02:27 +01:00
if ($usr['Gekommen'] == 1)
$table .= '<td>yes</td><td><a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">reset</a></td>';
else
$table .= '<td></td><td><a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">arrived</a></td>';
$table .= '</tr>';
}
return template_render('../templates/admin_arrive.html', array (
'search' => $search,
'table' => $table,
'msg' => $msg,
'link' => page_link_to('admin_arrive')
));
}
2012-12-27 14:24:05 +01:00
?>