You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.8 KiB
PHTML

<?php
function admin_arrive_title() {
return _("Arrived angels");
}
function admin_arrive() {
12 years ago
$msg = "";
$search = "";
11 years ago
if (isset($_REQUEST['search']))
12 years ago
$search = strip_request_item('search');
11 years ago
if (isset($_REQUEST['reset']) && preg_match("/^[0-9]*$/", $_REQUEST['reset'])) {
12 years ago
$id = $_REQUEST['reset'];
$user_source = User($id);
11 years ago
if ($user_source != null) {
12 years ago
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));
$msg = success(_("Reset done. Angel has not arrived."), true);
11 years ago
} else
$msg = error(_("Angel not found."), true);
11 years ago
} elseif (isset($_REQUEST['arrived']) && preg_match("/^[0-9]*$/", $_REQUEST['arrived'])) {
12 years ago
$id = $_REQUEST['arrived'];
$user_source = User($id);
11 years ago
if ($user_source != null) {
12 years ago
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));
$msg = success(_("Angel has been marked as arrived."), true);
11 years ago
} else
$msg = error(_("Angel not found."), true);
12 years ago
}
11 years ago
12 years ago
$users = sql_select("SELECT * FROM `User` ORDER BY `Nick`");
$table = "";
11 years ago
$users_matched = array();
12 years ago
if ($search == "")
11 years ago
$tokens = array();
12 years ago
else
$tokens = explode(" ", $search);
foreach ($users as $usr) {
if (count($tokens) > 0) {
$match = false;
$index = join(" ", $usr);
12 years ago
foreach ($tokens as $t)
if (stristr($index, trim($t))) {
11 years ago
$match = true;
break;
}
if (! $match)
12 years ago
continue;
}
$table .= '<tr>';
$table .= '<td>' . User_Nick_render($usr) . '</td>';
11 years ago
$usr['nick'] = User_Nick_render($usr);
$usr['arrived'] = $usr['Gekommen'] == 1 ? _("yes") : "";
$usr['actions'] = $usr['Gekommen'] == 1 ? '<a href="' . page_link_to('admin_arrive') . '&reset=' . $usr['UID'] . '&search=' . $search . '">' . _("reset") . '</a>' : '<a href="' . page_link_to('admin_arrive') . '&arrived=' . $usr['UID'] . '&search=' . $search . '">' . _("arrived") . '</a>';
12 years ago
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>';
11 years ago
$users_matched[] = $usr;
12 years ago
}
return page_with_title(admin_arrive_title(), array(
11 years ago
msg(),
form(array(
form_text('search', _("Search"), $search),
form_submit('submit', _("Search"))
)),
table(array(
'nick' => _("Nickname"),
'arrived' => _("Arrived?"),
'actions' => ""
), $users_matched)
12 years ago
));
}
?>