summaryrefslogtreecommitdiff
path: root/includes/view
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2014-01-05 19:30:06 +0100
committerPhilip Häusler <msquare@notrademark.de>2014-01-05 19:30:06 +0100
commit5e8453992810181facf168d6aaede9d2dcd61dba (patch)
treec6aad1564d86ed5789c25b7bab0b36047f0fbaac /includes/view
parentd921cf903eedd98fce74114d43f7c98ed8baabdc (diff)
rewritten angeltypes and user angeltypes
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/AngelTypes_view.php115
-rw-r--r--includes/view/UserAngelTypes_view.php58
2 files changed, 173 insertions, 0 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
new file mode 100644
index 00000000..f0ab0e42
--- /dev/null
+++ b/includes/view/AngelTypes_view.php
@@ -0,0 +1,115 @@
+<?php
+
+function AngelType_delete_view($angeltype) {
+ return page(array(
+ info(sprintf(_("Do you want to delete angeltype %s?"), $angeltype['name']), true),
+ buttons(array(
+ button(page_link_to('angeltypes'), _("cancel"), 'cancel'),
+ button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed', _("delete"), 'ok')
+ ))
+ ));
+}
+
+function AngelType_edit_view($name, $restricted) {
+ return page(array(
+ buttons(array(
+ button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
+ )),
+ msg(),
+ form(array(
+ form_text('name', _("Name"), $name),
+ form_checkbox('restricted', _("Restricted"), $restricted),
+ form_info("", _("Restricted angel types can only be used by an angel if enabled by an archangel (double opt-in).")),
+ form_submit('submit', _("Save"))
+ ))
+ ));
+}
+
+function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angeltypes, $admin_angeltypes) {
+ $buttons = array(
+ button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
+ );
+
+ if ($user_angeltype == null)
+ $buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add');
+ else {
+ if ($angeltype['restricted'] && $user_angeltype['confirm_user_id'] == null)
+ error(sprintf(_("You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed."), $angeltype['name']));
+ $buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'], _("leave"), 'cancel');
+ }
+
+ if ($admin_angeltypes) {
+ $buttons[] = button(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), 'edit');
+ $buttons[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), 'delete');
+ }
+
+ $page = array(
+ msg(),
+ buttons($buttons)
+ );
+
+ // $page[] = '<h3>' . _("Info") . '</h3>';
+ // Description + Team-Coordinators
+
+ $page[] = '<h3>' . _("Members") . '</h3>';
+ $members_confirmed = array();
+ $members_unconfirmed = array();
+ foreach ($members as $member) {
+ $member['Nick'] = User_Nick_render($member);
+ if ($angeltype['restricted'] && $member['confirm_user_id'] == null) {
+ $member['actions'] = join(" ", array(
+ '<a href="' . page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="ok">' . ("confirm") . '</a>',
+ '<a href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="cancel">' . ("deny") . '</a>'
+ ));
+ $members_unconfirmed[] = $member;
+ } else {
+ if ($admin_user_angeltypes)
+ $member['actions'] = join(" ", array(
+ '<a href="' . page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'] . '" class="cancel">' . ("remove") . '</a>'
+ ));
+ $members_confirmed[] = $member;
+ }
+ }
+ $page[] = table(array(
+ 'Nick' => _("Nick"),
+ 'DECT' => _("DECT"),
+ 'actions' => ""
+ ), $members_confirmed);
+
+ if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) {
+ $page[] = '<h3>' . _("Unconfirmed") . '</h3>';
+ $page[] = buttons(array(
+ button(page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'], _("confirm all"), 'ok'),
+ button(page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'], _("deny all"), 'cancel')
+ ));
+ $page[] = table(array(
+ 'Nick' => _("Nick"),
+ 'DECT' => _("DECT"),
+ 'actions' => ""
+ ), $members_unconfirmed);
+ }
+
+ return page($page);
+}
+
+/**
+ * Display the list of angeltypes.
+ *
+ * @param array $angeltypes
+ */
+function AngelTypes_list_view($angeltypes, $admin_angeltypes) {
+ return page(array(
+ msg(),
+ $admin_angeltypes ? buttons(array(
+ button(page_link_to('angeltypes') . '&action=edit', _("New angeltype"), 'add')
+ )) : '',
+ table(array(
+ 'name' => _("Name"),
+ 'restricted' => '<img src="pic/icons/lock.png" alt="' . _("Restricted") . '" title="' . _("Restricted") . '" />',
+ 'membership' => _("Membership"),
+ 'actions' => ""
+ ), $angeltypes)
+ ));
+}
+
+?> \ No newline at end of file
diff --git a/includes/view/UserAngelTypes_view.php b/includes/view/UserAngelTypes_view.php
new file mode 100644
index 00000000..ed825c04
--- /dev/null
+++ b/includes/view/UserAngelTypes_view.php
@@ -0,0 +1,58 @@
+<?php
+
+function UserAngelTypes_delete_all_view($angeltype) {
+ return page(array(
+ msg(),
+ info(sprintf(_("Do you really want to deny all users for %s?"), $angeltype['name']), true),
+ buttons(array(
+ button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
+ button(page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'] . '&confirmed', _("yes"), 'ok')
+ ))
+ ));
+}
+
+function UserAngelTypes_confirm_all_view($angeltype) {
+ return page(array(
+ msg(),
+ info(sprintf(_("Do you really want to confirm all users for %s?"), $angeltype['name']), true),
+ buttons(array(
+ button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
+ button(page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'] . '&confirmed', _("yes"), 'ok')
+ ))
+ ));
+}
+
+function UserAngelType_confirm_view($user_angeltype, $user, $angeltype) {
+ return page(array(
+ msg(),
+ info(sprintf(_("Do you really want to confirm %s for %s?"), User_Nick_render($user), $angeltype['name']), true),
+ buttons(array(
+ button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
+ button(page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', _("yes"), 'ok')
+ ))
+ ));
+}
+
+function UserAngelType_delete_view($user_angeltype, $user, $angeltype) {
+ return page(array(
+ msg(),
+ info(sprintf(_("Do you really want to delete %s from %s?"), User_Nick_render($user), $angeltype['name']), true),
+ buttons(array(
+ button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
+ button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', _("yes"), 'ok')
+ ))
+ ));
+}
+
+function UserAngelType_add_view($user, $angeltype) {
+ return page(array(
+ msg(),
+ info(sprintf(_("Do you really want to add %s to %s?"), User_Nick_render($user), $angeltype['name']), true),
+ buttons(array(
+ button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
+ button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'] . '&user_id=' . $user['UID'] . '&confirmed', _("save"), 'ok')
+ ))
+ ));
+}
+
+?> \ No newline at end of file