function Room_name_render($room) { global $privileges; if (in_array('admin_rooms', $privileges)) { return '<a href="' . room_link($room) . '">' . glyph('map-marker') . $room['Name'] . '</a>'; } return glyph('map-marker') . $room['Name']; }
function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source, $user_shift_admin, $admin_rooms, $admin_shifttypes, $user_shifts, $signed_up) { $parsedown = new Parsedown(); $angeltypes = []; foreach ($angeltypes_source as $angeltype) { $angeltypes[$angeltype['id']] = $angeltype; } $needed_angels = ''; foreach ($shift['NeedAngels'] as $needed_angeltype) { $class = 'progress-bar-warning'; if ($needed_angeltype['taken'] == 0) { $class = 'progress-bar-danger'; } if ($needed_angeltype['taken'] >= $needed_angeltype['count']) { $class = 'progress-bar-success'; } $needed_angels .= '<div class="list-group-item">'; $needed_angels .= '<div class="pull-right">' . Shift_signup_button_render($shift, $angeltypes[$needed_angeltype['TID']]) . '</div>'; $needed_angels .= '<h3>' . AngelType_name_render($angeltypes[$needed_angeltype['TID']]) . '</h3>'; $needed_angels .= progress_bar(0, $needed_angeltype['count'], min($needed_angeltype['taken'], $needed_angeltype['count']), $class, $needed_angeltype['taken'] . ' / ' . $needed_angeltype['count']); $angels = []; foreach ($shift['ShiftEntry'] as $shift_entry) { if ($shift_entry['TID'] == $needed_angeltype['TID']) { $entry = User_Nick_render(User($shift_entry['UID'])); if ($shift_entry['freeloaded']) { $entry = '<strike>' . $entry . '</strike>'; } if ($user_shift_admin) { $entry .= ' <div class="btn-group">'; $entry .= button_glyph(page_link_to('user_myshifts') . '&edit=' . $shift_entry['id'] . '&id=' . $shift_entry['UID'], 'pencil', 'btn-xs'); $entry .= button_glyph(page_link_to('user_shifts') . '&entry_id=' . $shift_entry['id'], 'trash', 'btn-xs'); $entry .= '</div>'; } $angels[] = $entry; } } $needed_angels .= join(', ', $angels); $needed_angels .= '</div>'; } $shiftManagers = getShiftManagers($shift['SID']); return page_with_title($shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [msg(), Shift_collides($shift, $user_shifts) ? info(_('This shift collides with one of your shifts.'), true) : '', $signed_up ? info(_('You are signed up for this shift.'), true) : '', $shift_admin || $admin_shifttypes || $admin_rooms ? buttons([$shift_admin ? button(shift_edit_link($shift), glyph('pencil') . _('edit')) : '', $shift_admin ? button(shift_delete_link($shift), glyph('trash') . _('delete')) : '', $admin_shifttypes ? button(shifttype_link($shifttype), $shifttype['name']) : '', $admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : '']) : '', div('row', [div('col-sm-3 col-xs-6', ['<h4>' . _('Title') . '</h4>', '<p class="lead">' . ($shift['URL'] != '' ? '<a href="' . $shift['URL'] . '">' . $shift['title'] . '</a>' : $shift['title']) . '</p>']), div('col-sm-3 col-xs-6', ['<h4>' . _('Start') . '</h4>', '<p class="lead' . (time() >= $shift['start'] ? ' text-success' : '') . '">', glyph('calendar') . date('Y-m-d', $shift['start']), '<br />', glyph('time') . date('H:i', $shift['start']), '</p>']), div('col-sm-3 col-xs-6', ['<h4>' . _('End') . '</h4>', '<p class="lead' . (time() >= $shift['end'] ? ' text-success' : '') . '">', glyph('calendar') . date('Y-m-d', $shift['end']), '<br />', glyph('time') . date('H:i', $shift['end']), '</p>']), div('col-sm-3 col-xs-6', ['<h4>' . _('Location') . '</h4>', '<p class="lead">' . glyph('map-marker') . $room['Name'] . '</p>'])]), div('row', [div('col-sm-6', ['<h2>' . _('Needed angels') . '</h2>', '<div class="list-group">' . $needed_angels . '</div>']), div('col-sm-6', [!empty($shiftManagers) ? '<h2>' . _('Shift Manager') . '</h2>' : '', !empty($shiftManagers) ? implode('<br>', array_map(function ($manager) { return $manager['Vorname'] . ' ' . $manager['Name']; }, $shiftManagers)) : '', '<h2>' . _('Description') . '</h2>', $parsedown->parse($shifttype['description'])])]), $shift_admin ? Shift_editor_info_render($shift) : '']); }
function User_angeltypes_render($user_angeltypes) { $output = array(); foreach ($user_angeltypes as $angeltype) { $class = ""; if ($angeltype['restricted'] == 1) { if ($angeltype['confirm_user_id'] != null) { $class = 'text-success'; } else { $class = 'text-warning'; } } else { $class = 'text-success'; } $output[] = '<a href="' . angeltype_link($angeltype['id']) . '" class="' . $class . '">' . ($angeltype['coordinator'] ? glyph('education') : '') . $angeltype['name'] . '</a>'; } return join('<br />', $output); }
function admin_import() { global $rooms_import; global $user; $html = ""; $step = "input"; if (isset($_REQUEST['step']) && in_array($step, ['input', 'check', 'import'])) { $step = $_REQUEST['step']; } if ($test_handle = fopen('../import/tmp', 'w')) { fclose($test_handle); unlink('../import/tmp'); } else { error(_('Webserver has no write-permission on import directory.')); } $import_file = '../import/import_' . $user['UID'] . '.xml'; $shifttype_id = null; $shifttypes_source = ShiftTypes(); if ($shifttypes_source === false) { engelsystem_error('Unable to load shifttypes.'); } $shifttypes = []; foreach ($shifttypes_source as $shifttype) { $shifttypes[$shifttype['id']] = $shifttype['name']; } switch ($step) { case 'input': $ok = false; if (isset($_REQUEST['submit'])) { $ok = true; if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) { $shifttype_id = $_REQUEST['shifttype_id']; } else { $ok = false; error(_('Please select a shift type.')); } if (isset($_FILES['xcal_file']) && $_FILES['xcal_file']['error'] == 0) { if (move_uploaded_file($_FILES['xcal_file']['tmp_name'], $import_file)) { libxml_use_internal_errors(true); if (simplexml_load_file($import_file) === false) { $ok = false; error(_('No valid xml/xcal file provided.')); unlink($import_file); } } else { $ok = false; error(_('File upload went wrong.')); } } else { $ok = false; error(_('Please provide some data.')); } } if ($ok) { redirect(page_link_to('admin_import') . "&step=check&shifttype_id=" . $shifttype_id); } else { $html .= div('well well-sm text-center', [_('File Upload') . mute(glyph('arrow-right')) . mute(_('Validation')) . mute(glyph('arrow-right')) . mute(_('Import'))]) . div('row', [div('col-md-offset-3 col-md-6', [form(array(form_info('', _("This import will create/update/delete rooms and shifts by given FRAB-export file. The needed file format is xcal.")), form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id), form_file('xcal_file', _("xcal-File (.xcal)")), form_submit('submit', _("Import"))))])]); } break; case 'check': if (!file_exists($import_file)) { error(_('Missing import file.')); redirect(page_link_to('admin_import')); } if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) { $shifttype_id = $_REQUEST['shifttype_id']; } else { error(_('Please select a shift type.')); redirect(page_link_to('admin_import')); } list($rooms_new, $rooms_deleted) = prepare_rooms($import_file); list($events_new, $events_updated, $events_deleted) = prepare_events($import_file, $shifttype_id); $html .= div('well well-sm text-center', ['<span class="text-success">' . _('File Upload') . glyph('ok-circle') . '</span>' . mute(glyph('arrow-right')) . _('Validation') . mute(glyph('arrow-right')) . mute(_('Import'))]) . form([div('row', [div('col-sm-6', ['<h3>' . _("Rooms to create") . '</h3>', table(_("Name"), $rooms_new)]), div('col-sm-6', ['<h3>' . _("Rooms to delete") . '</h3>', table(_("Name"), $rooms_deleted)])]), '<h3>' . _("Shifts to create") . '</h3>', table(array('day' => _("Day"), 'start' => _("Start"), 'end' => _("End"), 'shifttype' => _('Shift type'), 'title' => _("Title"), 'room' => _("Room")), shifts_printable($events_new, $shifttypes)), '<h3>' . _("Shifts to update") . '</h3>', table(array('day' => _("Day"), 'start' => _("Start"), 'end' => _("End"), 'shifttype' => _('Shift type'), 'title' => _("Title"), 'room' => _("Room")), shifts_printable($events_updated, $shifttypes)), '<h3>' . _("Shifts to delete") . '</h3>', table(array('day' => _("Day"), 'start' => _("Start"), 'end' => _("End"), 'shifttype' => _('Shift type'), 'title' => _("Title"), 'room' => _("Room")), shifts_printable($events_deleted, $shifttypes)), form_submit('submit', _("Import"))], page_link_to('admin_import') . '&step=import&shifttype_id=' . $shifttype_id); break; case 'import': if (!file_exists($import_file)) { error(_('Missing import file.')); redirect(page_link_to('admin_import')); } if (!file_exists($import_file)) { redirect(page_link_to('admin_import')); } if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) { $shifttype_id = $_REQUEST['shifttype_id']; } else { error(_('Please select a shift type.')); redirect(page_link_to('admin_import')); } list($rooms_new, $rooms_deleted) = prepare_rooms($import_file); foreach ($rooms_new as $room) { $result = Room_create($room, true, true); if ($result === false) { engelsystem_error('Unable to create room.'); } $rooms_import[trim($room)] = sql_id(); } foreach ($rooms_deleted as $room) { sql_query("DELETE FROM `Room` WHERE `Name`='" . sql_escape($room) . "' LIMIT 1"); } list($events_new, $events_updated, $events_deleted) = prepare_events($import_file, $shifttype_id); foreach ($events_new as $event) { $result = Shift_create($event); if ($result === false) { engelsystem_error('Unable to create shift.'); } } foreach ($events_updated as $event) { $result = Shift_update_by_psid($event); if ($result === false) { engelsystem_error('Unable to update shift.'); } } foreach ($events_deleted as $event) { $result = Shift_delete_by_psid($event['PSID']); if ($result === false) { engelsystem_error('Unable to delete shift.'); } } engelsystem_log("Pentabarf import done"); unlink($import_file); $html .= div('well well-sm text-center', ['<span class="text-success">' . _('File Upload') . glyph('ok-circle') . '</span>' . mute(glyph('arrow-right')) . '<span class="text-success">' . _('Validation') . glyph('ok-circle') . '</span>' . mute(glyph('arrow-right')) . '<span class="text-success">' . _('Import') . glyph('ok-circle') . '</span>']) . success(_("It's done!"), true); break; default: redirect(page_link_to('admin_import')); } return page_with_title(admin_import_title(), [msg(), $html]); }
function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) { global $LETZTES_AUSTRAGEN, $privileges; $user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']); $myshifts_table = array(); $html = ""; $timesum = 0; foreach ($shifts as $shift) { $shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>'; if ($shift['title']) { $shift_info .= '<br /><a href="' . shift_link($shift) . '">' . $shift['title'] . '</a>'; } foreach ($shift['needed_angeltypes'] as $needed_angel_type) { $shift_info .= '<br><b>' . $needed_angel_type['name'] . ':</b> '; $shift_entries = array(); foreach ($needed_angel_type['users'] as $user_shift) { $member = User_Nick_render($user_shift); if ($user_shift['freeloaded']) { $member = '<strike>' . $member . '</strike>'; } $shift_entries[] = $member; } $shift_info .= join(", ", $shift_entries); } $myshift = array('date' => date("Y-m-d", $shift['start']), 'time' => date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']), 'room' => $shift['Name'], 'shift_info' => $shift_info, 'comment' => $shift['Comment']); if ($shift['freeloaded']) { if (in_array("user_shifts_admin", $privileges)) { $myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . ': ' . $shift['freeload_comment'] . '</p>'; } else { $myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . '</p>'; } } $myshift['actions'] = [button(shift_link($shift), glyph('eye-open') . _('view'), 'btn-xs')]; if ($its_me || in_array('user_shifts_admin', $privileges)) { $myshift['actions'][] = button(page_link_to('user_myshifts') . '&edit=' . $shift['id'] . '&id=' . $user_source['UID'], glyph('edit') . _('edit'), 'btn-xs'); } if ($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600 || in_array('user_shifts_admin', $privileges)) { $myshift['actions'][] = button(page_link_to('user_myshifts') . (!$its_me ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'], glyph('trash') . _('sign off'), 'btn-xs'); } $myshift['actions'] = table_buttons($myshift['actions']); if ($shift['freeloaded']) { $timesum += -2 * ($shift['end'] - $shift['start']); } else { $timesum += $shift['end'] - $shift['start']; } $myshifts_table[] = $myshift; } if (count($myshifts_table) > 0) { $myshifts_table[] = array('date' => '<b>' . _("Sum:") . '</b>', 'time' => "<b>" . round($timesum / (60 * 60), 1) . " h</b>", 'room' => "", 'shift_info' => "", 'comment' => "", 'actions' => ""); } return page_with_title('<span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . ' <small>' . $user_name . '</small>', array(msg(), div('row', array(div('col-md-3', array('<h1>', '<span class="glyphicon glyphicon-phone"></span>', $user_source['DECT'], '</h1>')), div('col-md-3', array('<h4>' . _("User state") . '</h4>', $admin_user_privilege && $freeloader ? '<span class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"></span> ' . _("Freeloader") . '</span><br />' : '', $user_source['Gekommen'] ? User_shift_state_render($user_source) . '<br />' : '', $admin_user_privilege ? $user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . sprintf(_("Arrived at %s"), date('Y-m-d', $user_source['arrival_date'])) . '</span>' : '<span class="text-danger">' . sprintf(_("Not arrived (Planned: %s)"), date('Y-m-d', $user_source['planned_arrival_date'])) . '</span>' : ($user_source['Gekommen'] ? '<span class="text-success"><span class="glyphicon glyphicon-home"></span> ' . _("Arrived") . '</span>' : '<span class="text-danger">' . _("Not arrived") . '</span>'), $admin_user_privilege ? $user_source['got_voucher'] ? '<br /><span class="text-success">' . glyph('cutlery') . _("Got vouchers") . '</span>' : '<br /><span class="text-danger">' . _("Got no vouchers") . '</span>' : '', $user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv'] ? ' <span class="text-success">' . _("Active") . '</span>' : '', $user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt'] ? ' <span class="text-success">' . _("T-Shirt") . '</span>' : '')), div('col-md-3', array('<h4>' . _("Angeltypes") . '</h4>', User_angeltypes_render($user_angeltypes))), div('col-md-3', array('<h4>' . _("Rights") . '</h4>', User_groups_render($user_groups))))), div('row space-top', array(div('col-md-12', array(buttons(array($admin_user_privilege ? button(page_link_to('admin_user') . '&id=' . $user_source['UID'], glyph("edit") . _("edit")) : '', $admin_user_privilege && !$user_source['Gekommen'] ? button(page_link_to('admin_arrive') . '&arrived=' . $user_source['UID'], _("arrived")) : '', $admin_user_privilege && !$user_source['got_voucher'] ? button(page_link_to('users') . '&action=got_voucher&user_id=' . $user_source['UID'] . '&got_voucher=true', _('Got vouchers')) : '', $admin_user_privilege && $user_source['got_voucher'] ? button(page_link_to('users') . '&action=got_voucher&user_id=' . $user_source['UID'] . '&got_voucher=', _('Remove vouchers')) : '', $its_me ? button(page_link_to('user_settings'), glyph('list-alt') . _("Settings")) : '', $its_me ? button(page_link_to('ical') . '&key=' . $user_source['api_key'], glyph('calendar') . _("iCal Export")) : '', $its_me ? button(page_link_to('shifts_json_export') . '&key=' . $user_source['api_key'], glyph('export') . _("JSON Export")) : '', $its_me ? button(page_link_to('user_myshifts') . '&reset', glyph('repeat') . _('Reset API key')) : '')))))), $its_me || $admin_user_privilege ? '<h2>' . _("Shifts") . '</h2>' : '', $its_me || $admin_user_privilege ? table(array('date' => _("Day"), 'time' => _("Time"), 'room' => _("Location"), 'shift_info' => _("Name & workmates"), 'comment' => _("Comment"), 'actions' => _("Action")), $myshifts_table) : '', $its_me && count($shifts) == 0 ? error(sprintf(_("Go to the <a href=\"%s\">shifts table</a> to sign yourself up for some shifts."), page_link_to('user_shifts')), true) : '')); }
function make_select($items, $selected, $name, $title = null) { $html_items = array(); if (isset($title)) { $html_items[] = '<h4>' . $title . '</h4>' . "\n"; } foreach ($items as $i) { $html_items[] = '<div class="checkbox"><label><input type="checkbox" name="' . $name . '[]" value="' . $i['id'] . '"' . (in_array($i['id'], $selected) ? ' checked="checked"' : '') . '> ' . $i['name'] . '</label>' . (!isset($i['enabled']) || $i['enabled'] ? '' : glyph("lock")) . '</div><br />'; } $html = '<div id="selection_' . $name . '" class="selection ' . $name . '">' . "\n"; $html .= implode("\n", $html_items); $html .= buttons(array(button("javascript: check_all('selection_" . $name . "')", _("All"), ""), button("javascript: uncheck_all('selection_" . $name . "')", _("None"), ""))); $html .= '</div>' . "\n"; return $html; }
/** * View a list of all angeltypes. */ function angeltypes_list_controller() { global $privileges, $user; if (!in_array('angeltypes', $privileges)) { redirect('?'); } $angeltypes = AngelTypes_with_user($user); if ($angeltypes === false) { engelsystem_error("Unable to load angeltypes."); } foreach ($angeltypes as &$angeltype) { $actions = array(button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("view"), "btn-xs")); if (in_array('admin_angel_types', $privileges)) { $actions[] = button(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), "btn-xs"); $actions[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), "btn-xs"); //$actions[] = '<a class="edit" href="' . page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'] . '">' . _("edit") . '</a>'; //$actions[] = '<a class="delete" href="' . page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '">' . _("delete") . '</a>'; } $angeltype['membership'] = AngelType_render_membership($angeltype); if ($angeltype['user_angeltype_id'] != null) { //$actions[] = '<a class="cancel" href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'] . '">' . _("leave") . '</a>'; $actions[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], _("leave"), "btn-xs"); } else { $actions[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), "btn-xs"); //$actions[] = '<a class="add" href="' . page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'] . '">' . _("join") . '</a>'; } $angeltype['restricted'] = $angeltype['restricted'] ? glyph('lock') : ''; $angeltype['name'] = '<a href="' . page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'] . '">' . $angeltype['name'] . '</a>'; $angeltype['actions'] = table_buttons($actions); } return array(angeltypes_title(), AngelTypes_list_view($angeltypes, in_array('admin_angel_types', $privileges))); }
/** * Rendert einen Knopf mit Glyph */ function button_glyph($href, $glyph, $class = "") { return button($href, glyph($glyph), $class); }
function make_select($items, $selected, $name, $title = null) { $html = ""; if (isset($title)) { $html .= '<h4 style="margin-top: 41px;">'; $html .= $title; if ($name == 'types') { $html .= ' <small><span class="" data-trigger="hover focus" data-toggle="popover" data-placement="bottom" data-html="true" data-content=\''; $html .= _("The tasks shown here are influenced by the preferences you defined in your settings!") . " <a href=\"" . page_link_to('angeltypes') . '&action=about' . "\">" . _("Description of the jobs.") . "</a>"; $html .= '\'>'; $html .= glyph('info-sign'); $html .= '</span></small>'; } $html .= '</h4>'; } $html .= sprintf('<select id="%s" class="%s" name="%s[]" multiple="multiple">', uniqid(), 'filterselect', $name); foreach ($items as $item) { $html .= sprintf('<option value="%s"%s>%s%s</option>', $item['id'], in_array($item['id'], $selected) ? ' selected="selected"' : '', $item['name'], !isset($item['enabled']) || $item['enabled'] ? '' : " " . htmlentities(glyph("lock"))); } $html .= "</select>"; return $html; }
/** * Display the list of angeltypes. * * @param array $angeltypes */ function AngelTypes_list_view($angeltypes, $admin_angeltypes) { return page_with_title(angeltypes_title(), array(msg(), buttons(array($admin_angeltypes ? button(page_link_to('angeltypes') . '&action=edit', _("New angeltype"), 'add') : '', button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description")))), table(array('name' => _("Name"), 'restricted' => glyph('lock') . _("Restricted"), 'membership' => _("Membership"), 'actions' => ""), $angeltypes))); }
function vote_button($id, $g) { $b = make_tag("button", "btn btn-default btn-sm vote"); $b["attribs"]["type"] = "button"; $b["attribs"]["value"] = $id; $b["children"][] = glyph($g); return $b; }
function admin_user() { global $user, $privileges, $tshirt_sizes, $privileges; $html = ''; if (!isset($_REQUEST['id'])) { redirect(users_link()); } $id = $_REQUEST['id']; if (!isset($_REQUEST['action'])) { $user_source = User($id); if ($user_source === false) { engelsystem_error('Unable to load user.'); } if ($user_source == null) { error(_('This user does not exist.')); redirect(users_link()); } $html .= "Hallo,<br />" . "hier kannst du den Eintrag ändern. Unter dem Punkt 'Gekommen' " . "wird der Engel als anwesend markiert, ein Ja bei Aktiv bedeutet, " . "dass der Engel aktiv war und damit ein Anspruch auf ein T-Shirt hat. " . "Wenn T-Shirt ein 'Ja' enthält, bedeutet dies, dass der Engel " . "bereits sein T-Shirt erhalten hat.<br /><br />\n"; $html .= "<form action=\"" . page_link_to("admin_user") . "&action=save&id={$id}\" method=\"post\">\n"; $html .= "<table border=\"0\">\n"; $html .= "<input type=\"hidden\" name=\"Type\" value=\"Normal\">\n"; $html .= "<tr><td>\n"; $html .= "<table>\n"; $html .= " <tr><td>Nick</td><td>" . "<input type=\"text\" size=\"40\" name=\"eNick\" value=\"" . $user_source['Nick'] . "\"></td></tr>\n"; $html .= " <tr><td>lastLogIn</td><td>" . date("Y-m-d H:i", $user_source['lastLogIn']) . "</td></tr>\n"; $html .= " <tr><td>Name</td><td>" . "<input type=\"text\" size=\"40\" name=\"eName\" value=\"" . $user_source['Name'] . "\"></td></tr>\n"; $html .= " <tr><td>Vorname</td><td>" . "<input type=\"text\" size=\"40\" name=\"eVorname\" value=\"" . $user_source['Vorname'] . "\"></td></tr>\n"; $html .= " <tr><td>Alter</td><td>" . "<input type=\"text\" size=\"5\" name=\"eAlter\" value=\"" . $user_source['Alter'] . "\"></td></tr>\n"; $html .= " <tr><td>Telefon</td><td>" . "<input type=\"text\" size=\"40\" name=\"eTelefon\" value=\"" . $user_source['Telefon'] . "\"></td></tr>\n"; $html .= " <tr><td>Handy</td><td>" . "<input type=\"text\" size=\"40\" name=\"eHandy\" value=\"" . $user_source['Handy'] . "\"></td></tr>\n"; $html .= " <tr><td>DECT</td><td>" . "<input type=\"text\" size=\"4\" name=\"eDECT\" value=\"" . $user_source['DECT'] . "\"></td></tr>\n"; $html .= " <tr><td>email</td><td>" . "<input type=\"text\" size=\"40\" name=\"eemail\" value=\"" . $user_source['email'] . "\"></td></tr>\n"; $html .= "<tr><td>" . form_checkbox('email_shiftinfo', _("Please send me an email if my shifts change"), $user_source['email_shiftinfo']) . "</td></tr>\n"; $html .= " <tr><td>jabber</td><td>" . "<input type=\"text\" size=\"40\" name=\"ejabber\" value=\"" . $user_source['jabber'] . "\"></td></tr>\n"; $html .= " <tr><td>Size</td><td>" . html_select_key('size', 'eSize', $tshirt_sizes, $user_source['Size']) . "</td></tr>\n"; $options = array('1' => "Yes", '0' => "No"); // Gekommen? $html .= " <tr><td>Gekommen</td><td>\n"; $html .= html_options('eGekommen', $options, $user_source['Gekommen']) . "</td></tr>\n"; // Aktiv? $html .= " <tr><td>Aktiv</td><td>\n"; $html .= html_options('eAktiv', $options, $user_source['Aktiv']) . "</td></tr>\n"; // Aktiv erzwingen if (in_array('admin_active', $privileges)) { $html .= " <tr><td>" . _("Force active") . "</td><td>\n"; $html .= html_options('force_active', $options, $user_source['force_active']) . "</td></tr>\n"; } // T-Shirt bekommen? $html .= " <tr><td>T-Shirt</td><td>\n"; $html .= html_options('eTshirt', $options, $user_source['Tshirt']) . "</td></tr>\n"; $html .= " <tr><td>Hometown</td><td>" . "<input type=\"text\" size=\"40\" name=\"Hometown\" value=\"" . $user_source['Hometown'] . "\"></td></tr>\n"; $html .= "</table>\n</td><td valign=\"top\"></td></tr>"; $html .= "</td></tr>\n"; $html .= "</table>\n<br />\n"; $html .= "<input type=\"submit\" value=\"Speichern\">\n"; $html .= "</form>"; $html .= "<hr />"; $html .= form_info('', _('Please visit the angeltypes page or the users profile to manage users angeltypes.')); $html .= "Hier kannst Du das Passwort dieses Engels neu setzen:<form action=\"" . page_link_to("admin_user") . "&action=change_pw&id={$id}\" method=\"post\">\n"; $html .= "<table>\n"; $html .= " <tr><td>Passwort</td><td>" . "<input type=\"password\" size=\"40\" name=\"new_pw\" value=\"\"></td></tr>\n"; $html .= " <tr><td>Wiederholung</td><td>" . "<input type=\"password\" size=\"40\" name=\"new_pw2\" value=\"\"></td></tr>\n"; $html .= "</table>"; $html .= "<input type=\"submit\" value=\"Speichern\">\n"; $html .= "</form>"; $html .= "<hr />"; $my_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($user['UID']) . "' ORDER BY `group_id` LIMIT 1"); if (count($my_highest_group) > 0) { $my_highest_group = $my_highest_group[0]['group_id']; } $his_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($id) . "' ORDER BY `group_id` LIMIT 1"); if (count($his_highest_group) > 0) { $his_highest_group = $his_highest_group[0]['group_id']; } if ($id != $user['UID'] && $my_highest_group <= $his_highest_group) { $html .= "Hier kannst Du die Benutzergruppen des Engels festlegen:<form action=\"" . page_link_to("admin_user") . "&action=save_groups&id=" . $id . "\" method=\"post\">\n"; $html .= '<table>'; $groups = sql_select("SELECT * FROM `Groups` LEFT OUTER JOIN `UserGroups` ON (`UserGroups`.`group_id` = `Groups`.`UID` AND `UserGroups`.`uid` = '" . sql_escape($id) . "') WHERE `Groups`.`UID` >= '" . sql_escape($my_highest_group) . "' ORDER BY `Groups`.`Name`"); foreach ($groups as $group) { $html .= '<tr><td><input type="checkbox" name="groups[]" value="' . $group['UID'] . '"' . ($group['group_id'] != "" ? ' checked="checked"' : '') . ' /></td><td>' . $group['Name'] . '</td></tr>'; } $html .= '</table>'; $html .= "<input type=\"submit\" value=\"Speichern\">\n"; $html .= "</form>"; $html .= "<hr />"; } $html .= buttons([button(user_delete_link($user_source), glyph('lock') . _("delete"), 'btn-danger')]); $html .= "<hr />"; } else { switch ($_REQUEST['action']) { case 'save_groups': if ($id != $user['UID']) { $my_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($user['UID']) . "' ORDER BY `group_id`"); $his_highest_group = sql_select("SELECT * FROM `UserGroups` WHERE `uid`='" . sql_escape($id) . "' ORDER BY `group_id`"); if (count($my_highest_group) > 0 && (count($his_highest_group) == 0 || $my_highest_group[0]['group_id'] <= $his_highest_group[0]['group_id'])) { $groups_source = sql_select("SELECT * FROM `Groups` LEFT OUTER JOIN `UserGroups` ON (`UserGroups`.`group_id` = `Groups`.`UID` AND `UserGroups`.`uid` = '" . sql_escape($id) . "') WHERE `Groups`.`UID` >= '" . sql_escape($my_highest_group[0]['group_id']) . "' ORDER BY `Groups`.`Name`"); $groups = array(); $grouplist = array(); foreach ($groups_source as $group) { $groups[$group['UID']] = $group; $grouplist[] = $group['UID']; } if (!is_array($_REQUEST['groups'])) { $_REQUEST['groups'] = array(); } sql_query("DELETE FROM `UserGroups` WHERE `uid`='" . sql_escape($id) . "'"); $user_groups_info = array(); foreach ($_REQUEST['groups'] as $group) { if (in_array($group, $grouplist)) { sql_query("INSERT INTO `UserGroups` SET `uid`='" . sql_escape($id) . "', `group_id`='" . sql_escape($group) . "'"); $user_groups_info[] = $groups[$group]['Name']; } } $user_source = User($id); engelsystem_log("Set groups of " . User_Nick_render($user_source) . " to: " . join(", ", $user_groups_info)); $html .= success("Benutzergruppen gespeichert.", true); } else { $html .= error("Du kannst keine Engel mit mehr Rechten bearbeiten.", true); } } else { $html .= error("Du kannst Deine eigenen Rechte nicht bearbeiten.", true); } break; case 'save': $force_active = $user['force_active']; if (in_array('admin_active', $privileges)) { $force_active = $_REQUEST['force_active']; } $SQL = "UPDATE `User` SET \n `Nick` = '" . sql_escape($_POST["eNick"]) . "', \n `Name` = '" . sql_escape($_POST["eName"]) . "', \n `Vorname` = '" . sql_escape($_POST["eVorname"]) . "', \n `Telefon` = '" . sql_escape($_POST["eTelefon"]) . "', \n `Handy` = '" . sql_escape($_POST["eHandy"]) . "', \n `Alter` = '" . sql_escape($_POST["eAlter"]) . "', \n `DECT` = '" . sql_escape($_POST["eDECT"]) . "', \n `email` = '" . sql_escape($_POST["eemail"]) . "', \n `email_shiftinfo` = " . sql_bool(isset($_REQUEST['email_shiftinfo'])) . ", \n `jabber` = '" . sql_escape($_POST["ejabber"]) . "', \n `Size` = '" . sql_escape($_POST["eSize"]) . "', \n `Gekommen`= '" . sql_escape($_POST["eGekommen"]) . "', \n `Aktiv`= '" . sql_escape($_POST["eAktiv"]) . "', \n `force_active`= " . sql_escape($force_active) . ", \n `Tshirt` = '" . sql_escape($_POST["eTshirt"]) . "', \n `Hometown` = '" . sql_escape($_POST["Hometown"]) . "' \n WHERE `UID` = '" . sql_escape($id) . "' \n LIMIT 1"; sql_query($SQL); engelsystem_log("Updated user: "******"eNick"] . ", " . $_POST["eSize"] . ", arrived: " . $_POST["eGekommen"] . ", active: " . $_POST["eAktiv"] . ", tshirt: " . $_POST["eTshirt"]); $html .= success("Änderung wurde gespeichert...\n", true); break; case 'change_pw': if ($_REQUEST['new_pw'] != "" && $_REQUEST['new_pw'] == $_REQUEST['new_pw2']) { set_password($id, $_REQUEST['new_pw']); $user_source = User($id); engelsystem_log("Set new password for " . User_Nick_render($user_source)); $html .= success("Passwort neu gesetzt.", true); } else { $html .= error("Die Eingaben müssen übereinstimmen und dürfen nicht leer sein!", true); } break; } } return page_with_title(_('Edit user'), array($html)); }