From f40b78faace47a564e0efbc613fac85b69ed8b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20H=C3=A4usler?= Date: Sun, 9 Mar 2014 13:39:04 +0100 Subject: [PATCH] angeltypes about section --- includes/controller/angeltypes_controller.php | 25 +++++++++++++++++++ includes/model/AngelType_model.php | 10 ++++++++ includes/pages/guest_login.php | 4 +-- includes/pages/user_settings.php | 6 ++--- includes/pages/user_shifts.php | 6 ++--- includes/view/AngelTypes_view.php | 15 +++++++++++ public/index.php | 3 ++- 7 files changed, 60 insertions(+), 9 deletions(-) diff --git a/includes/controller/angeltypes_controller.php b/includes/controller/angeltypes_controller.php index d3690645..7566a80e 100644 --- a/includes/controller/angeltypes_controller.php +++ b/includes/controller/angeltypes_controller.php @@ -27,6 +27,9 @@ function angeltypes_controller() { case 'delete': list($title, $content) = angeltype_delete_controller(); break; + case 'about': + list($title, $content) = angeltypes_about_controller(); + break; } return array( @@ -35,6 +38,22 @@ function angeltypes_controller() { ); } +/** + * Job description for all angeltypes (public to everyone) + */ +function angeltypes_about_controller() { + global $privileges, $user; + + $angeltypes = AngelTypes(); + if ($angeltypes === false) + engelsystem_error("Unable to load angeltypes."); + + return array( + _("Teams/Engeltypes description"), + AngelTypes_about_view($angeltypes) + ); +} + /** * Delete an Angeltype. */ @@ -139,6 +158,9 @@ function angeltype_edit_controller() { function angeltype_controller() { global $privileges, $user; + if (! in_array('angeltypes', $privileges)) + redirect('?'); + if (! isset($_REQUEST['angeltype_id'])) redirect(page_link_to('angeltypes')); @@ -168,6 +190,9 @@ function angeltype_controller() { 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."); diff --git a/includes/model/AngelType_model.php b/includes/model/AngelType_model.php index 8f577571..7eb23794 100644 --- a/includes/model/AngelType_model.php +++ b/includes/model/AngelType_model.php @@ -99,6 +99,16 @@ function AngelTypes_with_user($user) { ORDER BY `name`"); } +/** + * Returns all angeltypes. + */ +function AngelTypes() { + return sql_select(" + SELECT * + FROM `AngelTypes` + ORDER BY `name`"); +} + /** * Returns AngelType id array */ diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index b9aca87d..4540bffb 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -13,7 +13,7 @@ function logout_title() { // Engel registrieren function guest_register() { - global $tshirt_sizes, $enable_tshirt_size, $default_theme, $faq_url; + global $tshirt_sizes, $enable_tshirt_size, $default_theme; $msg = ""; $nick = ""; @@ -153,7 +153,7 @@ function guest_register() { form_text('hometown', _("Hometown"), $hometown), $enable_tshirt_size ? form_select('tshirt_size', _("Shirt size") . "*", $tshirt_sizes, $tshirt_size) : '', // form_textarea('comment', _("Did you help at former CCC events and which tasks have you performed then?"), $comment), - form_checkboxes('angel_types', _("What do you want to do?") . sprintf("
(%s)", $faq_url, _("Description of job types")), $angel_types, $selected_angel_types), + form_checkboxes('angel_types', _("What do you want to do?") . sprintf("
(%s)", page_link_to('angeltypes') . '&action=about', _("Description of job types")), $angel_types, $selected_angel_types), form_info("", _("Restricted angel types need will be confirmed later by an archangel. You can change your selection in the options section.")), form_password('password', _("Password") . "*"), form_password('password2', _("Confirm password") . "*"), diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php index 0edacd48..2a54a485 100644 --- a/includes/pages/user_settings.php +++ b/includes/pages/user_settings.php @@ -4,7 +4,7 @@ function settings_title() { } function user_settings() { - global $enable_tshirt_size, $tshirt_sizes, $themes, $locales, $faq_url; + global $enable_tshirt_size, $tshirt_sizes, $themes, $locales; global $user; $msg = ""; @@ -102,7 +102,7 @@ function user_settings() { // Assign angel-types $user_angel_type_info = array(); $deleted_angel_types = array_diff(array_keys($angel_types), $selected_angel_types); - if(count($deleted_angel_types) > 0) + if (count($deleted_angel_types) > 0) sql_query("DELETE FROM `UserAngelTypes` WHERE `user_id`='" . sql_escape($user['UID']) . "' AND `angeltype_id` IN (" . implode(",", $deleted_angel_types) . ")"); foreach ($angel_types_source as $angel_type) if (in_array($angel_type['id'], $selected_angel_types)) @@ -180,7 +180,7 @@ function user_settings() { form_text('jabber', _("Jabber"), $jabber), form_text('hometown', _("Hometown"), $hometown), $enable_tshirt_size ? form_select('tshirt_size', _("Shirt size"), $tshirt_sizes, $tshirt_size) : '', - form_checkboxes('angel_types', _("What do you want to do?") . sprintf("
(%s)", $faq_url, _("Description of job types")), $angel_types, $selected_angel_types), + form_checkboxes('angel_types', _("What do you want to do?") . sprintf("
(%s)", page_link_to('angeltypes') . '&action=about', _("Description of job types")), $angel_types, $selected_angel_types), form_submit('submit', _("Save")) )), form(array( diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index fd5f4a15..ea3be85f 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -292,7 +292,7 @@ function user_shifts() { function view_user_shifts() { global $user, $privileges; - global $ical_shifts, $faq_url; + global $ical_shifts; $ical_shifts = array(); $days = sql_select_single_col("SELECT DISTINCT DATE(FROM_UNIXTIME(`start`)) AS `id`, DATE(FROM_UNIXTIME(`start`)) AS `name` FROM `Shifts` ORDER BY `start`"); @@ -641,7 +641,7 @@ function view_user_shifts() { $angeltypes = sql_select($query); if (count($angeltypes) > 0) { $my_shift = sql_num_query("SELECT * FROM `ShiftEntry` WHERE `SID`=" . sql_escape($shift['SID']) . " AND `UID`=" . sql_escape($user['UID']) . " LIMIT 1") > 0; - + foreach ($angeltypes as &$angeltype) { $entries = sql_select("SELECT * FROM `ShiftEntry` JOIN `User` ON (`ShiftEntry`.`UID` = `User`.`UID`) WHERE `SID`=" . sql_escape($shift['SID']) . " AND `TID`=" . sql_escape($angeltype['id']) . " ORDER BY `Nick`"); $entry_list = array(); @@ -726,7 +726,7 @@ function view_user_shifts() { 'end_time' => $_SESSION['user_shifts']['end_time'], 'type_select' => make_select($types, $_SESSION['user_shifts']['types'], "types", _("Tasks") . '1'), 'filled_select' => make_select($filled, $_SESSION['user_shifts']['filled'], "filled", _("Occupancy")), - 'task_notice' => '1' . _("The tasks shown here are influenced by the preferences you defined in your settings!") . " " . _("Description of the jobs.") . "", + 'task_notice' => '1' . _("The tasks shown here are influenced by the preferences you defined in your settings!") . " " . _("Description of the jobs.") . "", 'new_style_checkbox' => '', 'shifts_table' => $shifts_table, 'ical_text' => '

' . _("iCal export") . '

' . sprintf(_("Export of shown shifts. iCal format or JSON format available (please keep secret, otherwise reset the api key)."), page_link_to_absolute('ical') . '&key=' . $user['api_key'], page_link_to_absolute('shifts_json_export') . '&key=' . $user['api_key'], page_link_to('user_myshifts') . '&reset') . '

', diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php index e8e1f56d..08305930 100644 --- a/includes/view/AngelTypes_view.php +++ b/includes/view/AngelTypes_view.php @@ -117,4 +117,19 @@ function AngelTypes_list_view($angeltypes, $admin_angeltypes) { )); } +function AngelTypes_about_view($angeltypes) { + $content = array( + '

' . _("Here is the list of teams and their tasks:") . '

' + ); + $parsedown = new Parsedown(); + foreach ($angeltypes as $angeltype) { + $content[] = '

' . $angeltype['name'] . '

'; + if ($angeltype['restricted']) + $content[] = info(_("This angeltype is restricted by double-opt-in by a team coordinator. Please show up at the according introduction meetings."), true); + $content[] = $parsedown->parse($angeltype['description']); + } + + return page($content); +} + ?> \ No newline at end of file diff --git a/public/index.php b/public/index.php index dc58fa06..968a8286 100644 --- a/public/index.php +++ b/public/index.php @@ -77,7 +77,8 @@ $free_pages = array( 'shifts_json_export_all', 'user_password_recovery', 'api', - 'credits' + 'credits', + 'angeltypes' ); // Gewünschte Seite/Funktion