summaryrefslogtreecommitdiff
path: root/includes/view
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2016-11-09 18:02:01 +0100
committermsquare <msquare@notrademark.de>2016-11-09 18:02:01 +0100
commit0ba0ce207d47a0ff506aca44526aa8228e7e0d6e (patch)
tree8ff6f14dd45c133d8cd7f92058ffdfe25bac2bc0 /includes/view
parentd43eb41d25d0d5c0509417247030dd6c21118cf6 (diff)
split angeltype view into different methods
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/AngelTypes_view.php66
1 files changed, 48 insertions, 18 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index 10c02745..dbeabe95 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>';