summaryrefslogtreecommitdiff
path: root/includes/view/AngelTypes_view.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/view/AngelTypes_view.php')
-rw-r--r--includes/view/AngelTypes_view.php119
1 files changed, 81 insertions, 38 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index cdaa9f12..53396a05 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -65,7 +65,10 @@ function AngelType_edit_view($name, $restricted, $description, $coordinator_mode
]);
}
-function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $coordinator, $user_driver_license, $user) {
+/**
+ * Renders the buttons for the angeltype view.
+ */
+function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $coordinator, $user_driver_license, $user) {
$buttons = [
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
];
@@ -94,17 +97,15 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
$buttons[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), 'delete');
}
- $page = [
- msg(),
- buttons($buttons)
- ];
-
- $page[] = '<h3>' . _("Description") . '</h3>';
- $parsedown = new Parsedown();
- if ($angeltype['description'] != "") {
- $page[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
- }
-
+ return buttons($buttons);
+}
+
+/**
+ * Renders and sorts the members of an angeltype into coordinators, members and unconfirmed members.
+ *
+ * @return [coordinators, members, unconfirmed members]
+ */
+function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $admin_angeltypes) {
$coordinators = [];
$members_confirmed = [];
$members_unconfirmed = [];
@@ -147,14 +148,19 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
}
}
- $table_headers = [
- 'Nick' => _("Nick"),
- 'DECT' => _("DECT"),
- 'actions' => ''
+ return [
+ $coordinators,
+ $members_confirmed,
+ $members_unconfirmed
];
-
+}
+
+/**
+ * Creates the needed member table headers according to given rights and settings from the angeltype.
+ */
+function AngelType_view_table_headers($angeltype, $coordinator, $admin_angeltypes) {
if ($angeltype['requires_driver_license'] && ($coordinator || $admin_angeltypes)) {
- $table_headers = [
+ return [
'Nick' => _("Nick"),
'DECT' => _("DECT"),
'wants_to_drive' => _("Driver"),
@@ -167,6 +173,30 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
'actions' => ''
];
}
+ return [
+ 'Nick' => _("Nick"),
+ 'DECT' => _("DECT"),
+ 'actions' => ''
+ ];
+}
+
+/**
+ * Render an angeltype page containing the member lists.
+ */
+function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes, $coordinator, $user_driver_license, $user) {
+ $page = [
+ msg(),
+ AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $coordinator, $user_driver_license, $user)
+ ];
+
+ $page[] = '<h3>' . _("Description") . '</h3>';
+ $parsedown = new Parsedown();
+ if ($angeltype['description'] != "") {
+ $page[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
+ }
+
+ list($coordinators, $members_confirmed, $members_unconfirmed) = AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $admin_angeltypes);
+ $table_headers = AngelType_view_table_headers($angeltype, $coordinator, $admin_angeltypes);
if (count($coordinators) > 0) {
$page[] = '<h3>' . _("Coordinators") . '</h3>';
@@ -230,6 +260,38 @@ function AngelTypes_list_view($angeltypes, $admin_angeltypes) {
]);
}
+/**
+ * Renders the about info for an angeltype.
+ */
+function AngelTypes_about_view_angeltype($angeltype) {
+ $parsedown = new Parsedown();
+
+ $html = '<h2>' . $angeltype['name'] . '</h2>';
+
+ if (isset($angeltype['user_angeltype_id'])) {
+ $buttons = [];
+ if ($angeltype['user_angeltype_id'] != null) {
+ $buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], _("leave"), 'cancel');
+ } else {
+ $buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add');
+ }
+ $html .= buttons($buttons);
+ }
+
+ if ($angeltype['restricted']) {
+ $html .= info(_("This angeltype is restricted by double-opt-in by a team coordinator. Please show up at the according introduction meetings."), true);
+ }
+ if ($angeltype['description'] != "") {
+ $html .= '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
+ }
+ $html .= '<hr />';
+
+ return $html;
+}
+
+/**
+ * Renders a site that contains every angeltype and its description, basically as an overview of the needed help types.
+ */
function AngelTypes_about_view($angeltypes, $user_logged_in) {
global $faq_url;
@@ -243,27 +305,8 @@ function AngelTypes_about_view($angeltypes, $user_logged_in) {
'<p>' . _("Here is the list of teams and their tasks. If you have questions, read the FAQ.") . '</p>',
'<hr />'
];
- $parsedown = new Parsedown();
foreach ($angeltypes as $angeltype) {
- $content[] = '<h2>' . $angeltype['name'] . '</h2>';
-
- if (isset($angeltype['user_angeltype_id'])) {
- $buttons = [];
- if ($angeltype['user_angeltype_id'] != null) {
- $buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], _("leave"), 'cancel');
- } else {
- $buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add');
- }
- $content[] = buttons($buttons);
- }
-
- 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);
- }
- if ($angeltype['description'] != "") {
- $content[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
- }
- $content[] = '<hr />';
+ $content[] = AngelTypes_about_view_angeltype($angeltype);
}
return page_with_title(_("Teams/Job description"), $content);