From 5e8453992810181facf168d6aaede9d2dcd61dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20H=C3=A4usler?= Date: Sun, 5 Jan 2014 19:30:06 +0100 Subject: [PATCH] rewritten angeltypes and user angeltypes --- db/install.sql | 18 -- db/update.sql | 3 + includes/controller/angeltypes_controller.php | 196 +++++++++++++ .../controller/user_angeltypes_controller.php | 272 ++++++++++++++++++ includes/model/AngelType_model.php | 134 +++++++-- includes/model/UserAngelTypes_model.php | 69 +++++ includes/model/User_model.php | 20 +- includes/pages/admin_angel_types.php | 116 -------- includes/pages/admin_user_angeltypes.php | 14 - includes/sys_menu.php | 2 +- includes/view/AngelTypes_view.php | 115 ++++++++ includes/view/UserAngelTypes_view.php | 58 ++++ public/css/base.css | 35 ++- public/index.php | 35 +-- public/pic/icons/arrow_left.png | Bin 0 -> 345 bytes templates/guest_credits.html | 4 +- 16 files changed, 883 insertions(+), 208 deletions(-) create mode 100644 includes/controller/angeltypes_controller.php create mode 100644 includes/controller/user_angeltypes_controller.php create mode 100644 includes/model/UserAngelTypes_model.php delete mode 100644 includes/pages/admin_angel_types.php create mode 100644 includes/view/AngelTypes_view.php create mode 100644 includes/view/UserAngelTypes_view.php create mode 100755 public/pic/icons/arrow_left.png diff --git a/db/install.sql b/db/install.sql index 7eb404a9..896093e4 100644 --- a/db/install.sql +++ b/db/install.sql @@ -41,24 +41,6 @@ CREATE TABLE IF NOT EXISTS `AngelTypes` ( -- -------------------------------------------------------- --- --- Tabellenstruktur für Tabelle `ChangeLog` --- - -DROP TABLE IF EXISTS `ChangeLog`; -CREATE TABLE IF NOT EXISTS `ChangeLog` ( - `Time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `UID` int(11) NOT NULL DEFAULT '0', - `Commend` text NOT NULL, - `SQLCommad` text NOT NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Daten für Tabelle `ChangeLog` --- - - --- -------------------------------------------------------- -- -- Tabellenstruktur für Tabelle `Counter` diff --git a/db/update.sql b/db/update.sql index 407a8539..29b4a7dc 100644 --- a/db/update.sql +++ b/db/update.sql @@ -1,3 +1,6 @@ +/* angeltype view */ +INSERT INTO `engelsystem`.`Privileges` (`id`, `name`, `desc`) VALUES (NULL , 'angeltypes', 'View angeltypes'); + /* force active */ ALTER TABLE `User` ADD `force_active` BOOLEAN NOT NULL AFTER `Aktiv`, ADD INDEX ( `force_active` ); diff --git a/includes/controller/angeltypes_controller.php b/includes/controller/angeltypes_controller.php new file mode 100644 index 00000000..03c9651d --- /dev/null +++ b/includes/controller/angeltypes_controller.php @@ -0,0 +1,196 @@ +' . _("view") . '' + ); + + if (in_array('admin_angel_types', $privileges)) { + $actions[] = '' . _("edit") . ''; + $actions[] = '' . _("delete") . ''; + } + + $angeltype['membership'] = ""; + if ($angeltype['user_angeltype_id'] != null) { + if ($angeltype['restricted']) { + if ($angeltype['confirm_user_id'] == null) + $angeltype['membership'] = '' . _( ' . _("Unconfirmed"); + else + $angeltype['membership'] = '' . _( ' . _("Member"); + } else + $angeltype['membership'] = '' . _( ' . _("Member"); + $actions[] = '' . _("leave") . ''; + } else { + $angeltype['membership'] = ''; + $actions[] = '' . _("join") . ''; + } + + $angeltype['restricted'] = $angeltype['restricted'] ? '' . _(' : ''; + $angeltype['name'] = '' . $angeltype['name'] . ''; + + $angeltype['actions'] = join(" ", $actions); + } + + return array( + angeltypes_title(), + AngelTypes_list_view($angeltypes, in_array('admin_angel_types', $privileges)) + ); +} +?> \ No newline at end of file diff --git a/includes/controller/user_angeltypes_controller.php b/includes/controller/user_angeltypes_controller.php new file mode 100644 index 00000000..d110f7a7 --- /dev/null +++ b/includes/controller/user_angeltypes_controller.php @@ -0,0 +1,272 @@ + \ No newline at end of file diff --git a/includes/model/AngelType_model.php b/includes/model/AngelType_model.php index 49d1c702..22baa4a4 100644 --- a/includes/model/AngelType_model.php +++ b/includes/model/AngelType_model.php @@ -1,29 +1,107 @@ - 0) - return $angelType_source; - return null; -} - -/** - * Returns angelType by id. - * - * @param $id angelType ID - */ -function mAngelType($id) { - $angelType_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($id) . " LIMIT 1"); - if ($angelType_source === false) - return false; - if (count($angelType_source) > 0) - return $angelType_source[0]; - return null; -} - + 0) + return $angelType_source; + return null; +} + +/** + * Returns angelType by id. + * + * @param $id angelType + * ID + */ +function mAngelType($id) { + $angelType_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($id) . " LIMIT 1"); + if ($angelType_source === false) + return false; + if (count($angelType_source) > 0) + return $angelType_source[0]; + return null; +} + ?> \ No newline at end of file diff --git a/includes/model/UserAngelTypes_model.php b/includes/model/UserAngelTypes_model.php new file mode 100644 index 00000000..e931e04b --- /dev/null +++ b/includes/model/UserAngelTypes_model.php @@ -0,0 +1,69 @@ + \ No newline at end of file diff --git a/includes/model/User_model.php b/includes/model/User_model.php index 6b23f74b..84097333 100644 --- a/includes/model/User_model.php +++ b/includes/model/User_model.php @@ -1,5 +1,18 @@ $angel_type['id'], - 'name' => $angel_type['name'], - 'restricted' => $angel_type['restricted'] == 1 ? '✓' : '', - 'actions' => 'edit delete' - ); - } - - if (isset ($_REQUEST['show'])) { - $msg = ""; - $name = ""; - $restricted = 0; - - if (test_request_int('id')) { - $angel_type = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($_REQUEST['id'])); - if (count($angel_type) > 0) { - $id = $_REQUEST['id']; - $name = $angel_type[0]['name']; - $restricted = $angel_type[0]['restricted']; - } else - redirect(page_link_to('admin_angel_types')); - } - - if ($_REQUEST['show'] == 'edit') { - if (isset ($_REQUEST['submit'])) { - $ok = true; - - if (isset ($_REQUEST['name']) && strlen(strip_request_item('name')) > 0) { - $name = strip_request_item('name'); - if (sql_num_query("SELECT * FROM `AngelTypes` WHERE NOT `id`=" . sql_escape(isset ($id) ? $id : 0) . " AND `name`='" . sql_escape(strip_request_item('name')) . "' LIMIT 1") > 0) { - $ok = false; - $msg .= error("This angel type name is already given.", true); - } - } else { - $ok = false; - $msg .= error("Please enter a name.", true); - } - - if (isset ($_REQUEST['restricted'])) - $restricted = 1; - else - $restricted = 0; - - if ($ok) { - if (isset ($id)) { - sql_query("UPDATE `AngelTypes` SET `name`='" . sql_escape($name) . "', `restricted`=" . sql_escape($restricted) . " WHERE `id`=" . sql_escape($id) . " LIMIT 1"); - engelsystem_log("Updated angeltype: " . $name . ", restricted: " . $restricted); - } else { - sql_query("INSERT INTO `AngelTypes` SET `name`='" . sql_escape($name) . "', `restricted`=" . sql_escape($restricted)); - engelsystem_log("Created angeltype: " . $name . ", restricted: " . $restricted); - } - - success("Angel type saved."); - redirect(page_link_to('admin_angel_types')); - } - } - - return page(array ( - buttons(array ( - button(page_link_to('admin_angel_types'), "Back", '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') - )) - )); - } - elseif ($_REQUEST['show'] == 'delete') { - if (isset ($_REQUEST['ack'])) { - sql_query("DELETE FROM `NeededAngelTypes` WHERE `angel_type_id`=" . sql_escape($id) . " LIMIT 1"); - sql_query("DELETE FROM `ShiftEntry` WHERE `TID`=" . sql_escape($id) . " LIMIT 1"); - sql_query("DELETE FROM `AngelTypes` WHERE `id`=" . sql_escape($id) . " LIMIT 1"); - sql_query("DELETE FROM `UserAngelTypes` WHERE `angeltype_id`=" . sql_escape($id) . " LIMIT 1"); - engelsystem_log("Deleted angel type: " . $name); - success(sprintf("Angel type %s deleted.", $name)); - redirect(page_link_to('admin_angel_types')); - } - - return page(array ( - buttons(array ( - button(page_link_to('admin_angel_types'), "Back", 'cancel') - )), - sprintf("Do you want to delete angel type %s?", $name), - buttons(array ( - button(page_link_to('admin_angel_types') . '&show=delete&id=' . $id . '&ack', "Delete", 'ok') - )) - )); - } else - redirect(page_link_to('admin_angel_types')); - } - - return page(array ( - buttons(array ( - button(page_link_to('admin_angel_types') . '&show=edit', "Add", 'add') - )), - msg(), - table(array ( - 'name' => "Name", - 'restricted' => "Restricted", - 'actions' => "" - ), $angel_types) - )); -} -?> diff --git a/includes/pages/admin_user_angeltypes.php b/includes/pages/admin_user_angeltypes.php index 9377dc20..2b623d72 100644 --- a/includes/pages/admin_user_angeltypes.php +++ b/includes/pages/admin_user_angeltypes.php @@ -97,18 +97,4 @@ function admin_user_angeltypes() { )); } -/** - * Anzeige, ob noch Engeltypen bestätigt werden müssen. Damit werden Erzengel auf jeder Seite im Kopfbereich "genervt", wenn zu ihren Aufgaben noch Engel bestätigt werden müssen. - */ -function admin_new_user_angeltypes() { - global $user, $privileges; - - if (in_array("admin_user_angeltypes", $privileges)) { - $unconfirmed_angeltypes = sql_num_query("SELECT * FROM `UserAngelTypes` JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id` WHERE `UserAngelTypes`.`angeltype_id` IN (SELECT `angeltype_id` FROM `UserAngelTypes` WHERE `user_id`=" . sql_escape($user['UID']) . ") AND `AngelTypes`.`restricted`=1 AND `UserAngelTypes`.`confirm_user_id` IS NULL LIMIT 1") > 0; - - if ($unconfirmed_angeltypes) - return info('' . _("There are unconfirmed angeltypes!") . '', true); - } - return ""; -} ?> diff --git a/includes/sys_menu.php b/includes/sys_menu.php index d4620753..ae39afeb 100644 --- a/includes/sys_menu.php +++ b/includes/sys_menu.php @@ -44,6 +44,7 @@ function make_navigation() { "user_meetings" => meetings_title(), "user_myshifts" => myshifts_title(), "user_shifts" => shifts_title(), + "angeltypes" => angeltypes_title(), "user_messages" => messages_title(), "user_questions" => questions_title(), "user_wakeup" => wakeup_title(), @@ -52,7 +53,6 @@ function make_navigation() { "admin_user" => admin_user_title(), "admin_free" => admin_free_title(), "admin_questions" => admin_questions_title(), - "admin_angel_types" => admin_angel_types_title(), "admin_user_angeltypes" => admin_user_angeltypes_title(), "admin_shifts" => admin_shifts_title(), "admin_rooms" => admin_rooms_title(), 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 @@ +' . _("Info") . ''; + // Description + Team-Coordinators + + $page[] = '

' . _("Members") . '

'; + $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( + '' . ("confirm") . '', + '' . ("deny") . '' + )); + $members_unconfirmed[] = $member; + } else { + if ($admin_user_angeltypes) + $member['actions'] = join(" ", array( + '' . ("remove") . '' + )); + $members_confirmed[] = $member; + } + } + $page[] = table(array( + 'Nick' => _("Nick"), + 'DECT' => _("DECT"), + 'actions' => "" + ), $members_confirmed); + + if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) { + $page[] = '

' . _("Unconfirmed") . '

'; + $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' => '' . _(', + '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 @@ + \ No newline at end of file diff --git a/public/css/base.css b/public/css/base.css index 2f5aa18c..89fa62a5 100644 --- a/public/css/base.css +++ b/public/css/base.css @@ -357,8 +357,13 @@ tr:hover .hidden { margin: 0 0 10px 0; } +.actions a { + background: 2px 1px no-repeat; + padding-right: 5px; +} + a.button { - background: #f0f0f0; + background: #f0f0f0 2px 2px no-repeat; border: 1px solid #888; border-radius: 4px; line-height: 25px; @@ -374,26 +379,36 @@ a.button { .button:hover, .toolbar .button:hover { color: #000; - background: #fff; + background-color: #fff; } -.button.add { - background: url('../pic/icons/add.png') 2px 2px no-repeat; +.button.add, .actions .add { + background-image: url('../pic/icons/add.png'); padding-left: 20px; } -.button.edit { - background: url('../pic/icons/pencil.png') 2px 2px no-repeat; +.button.edit, .actions .edit { + background-image: url('../pic/icons/pencil.png'); padding-left: 20px; } -.button.ok { - background: url('../pic/icons/tick.png') 2px 2px no-repeat; +.button.ok, .actions .ok { + background-image: url('../pic/icons/tick.png'); padding-left: 20px; } -.button.cancel { - background: url('../pic/icons/cross.png') 2px 2px no-repeat; +.button.cancel, .actions .cancel { + background-image: url('../pic/icons/cross.png'); + padding-left: 20px; +} + +.button.delete, .actions .delete { + background-image: url('../pic/icons/bin.png'); + padding-left: 20px; +} + +.button.back, .actions .back { + background-image: url('../pic/icons/arrow_left.png'); padding-left: 20px; } diff --git a/public/index.php b/public/index.php index 24d92b9d..9cd01e40 100644 --- a/public/index.php +++ b/public/index.php @@ -10,20 +10,26 @@ require_once ('includes/sys_menu.php'); require_once ('includes/sys_page.php'); require_once ('includes/sys_template.php'); +require_once ('includes/model/AngelType_model.php'); require_once ('includes/model/LogEntries_model.php'); +require_once ('includes/model/Message_model.php'); require_once ('includes/model/NeededAngelTypes_model.php'); +require_once ('includes/model/Room_model.php'); require_once ('includes/model/ShiftEntry_model.php'); require_once ('includes/model/Shifts_model.php'); +require_once ('includes/model/UserAngelTypes_model.php'); require_once ('includes/model/User_model.php'); -require_once ('includes/model/Room_model.php'); -require_once ('includes/model/Message_model.php'); -require_once ('includes/model/AngelType_model.php'); +require_once ('includes/view/AngelTypes_view.php'); require_once ('includes/view/Questions_view.php'); require_once ('includes/view/Shifts_view.php'); require_once ('includes/view/ShiftEntry_view.php'); +require_once ('includes/view/UserAngelTypes_view.php'); require_once ('includes/view/User_view.php'); +require_once ('includes/controller/angeltypes_controller.php'); +require_once ('includes/controller/user_angeltypes_controller.php'); + require_once ('includes/helper/internationalization_helper.php'); require_once ('includes/helper/message_helper.php'); require_once ('includes/helper/error_helper.php'); @@ -34,7 +40,6 @@ if (file_exists('../config/config.php')) require_once ('config/config.php'); require_once ('includes/pages/admin_active.php'); -require_once ('includes/pages/admin_angel_types.php'); require_once ('includes/pages/admin_arrive.php'); require_once ('includes/pages/admin_free.php'); require_once ('includes/pages/admin_groups.php'); @@ -70,7 +75,8 @@ $free_pages = array( 'stats', 'shifts_json_export_all', 'user_password_recovery', - 'api' + 'api', + 'credits' ); // Gewünschte Seite/Funktion @@ -86,7 +92,7 @@ if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && (i require_once ('includes/controller/api.php'); error("Api disabled temporily."); redirect(page_link_to('login')); - //api_controller(); + // api_controller(); } elseif ($p == "ical") { require_once ('includes/pages/user_ical.php'); user_ical(); @@ -106,6 +112,10 @@ if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && (i require_once ('includes/controller/users_controller.php'); $title = user_password_recovery_title(); $content = user_password_recovery_controller(); + } elseif ($p == "angeltypes") { + list($title, $content) = angeltypes_controller(); + } elseif ($p == "user_angeltypes") { + list($title, $content) = user_angeltypes_controller(); } elseif ($p == "news") { $title = news_title(); $content = user_news(); @@ -164,9 +174,6 @@ if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && (i } elseif ($p == "admin_news") { require_once ('includes/pages/admin_news.php'); $content = admin_news(); - } elseif ($p == "admin_angel_types") { - $title = admin_angel_types_title(); - $content = admin_angel_types(); } elseif ($p == "admin_rooms") { $title = admin_rooms_title(); $content = admin_rooms(); @@ -206,10 +213,10 @@ if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && (i if (isset($user)) { $freeloaded_shifts_count = count(ShiftEntries_freeloaded_by_user($user)); - if($freeloaded_shifts_count >= $max_freeloadable_shifts) + if ($freeloaded_shifts_count >= $max_freeloadable_shifts) $content = error(sprintf(_("You freeloaded %s shifts. Shift signup is locked. Please go to heavens desk to be unlocked again."), $freeloaded_shifts_count), true) . $content; - - // Hinweis für ungelesene Nachrichten + + // Hinweis für ungelesene Nachrichten if ($p != "user_messages") $content = user_unread_messages() . $content; @@ -226,10 +233,6 @@ if (isset($user)) { // Erzengel Hinweis für unbeantwortete Fragen if ($p != "admin_questions") $content = admin_new_questions() . $content; - - // Erzengel Hinweis für freizuschaltende Engeltypen - if ($p != "admin_user_angeltypes") - $content = admin_new_user_angeltypes() . $content; } echo template_render('../templates/layout.html', array( diff --git a/public/pic/icons/arrow_left.png b/public/pic/icons/arrow_left.png new file mode 100755 index 0000000000000000000000000000000000000000..5dc696781e6135d37b5bf2e98e46fd94f020c48d GIT binary patch literal 345 zcmV-f0jBq$gGR5;6H z{Qv(y10{fofkH6I3@AO3$p*x`Nil#0jeqs;pT9Ds7{CaN1)$9r#n~kE{`~pF@bLXZ zhF?E_GyM7i!oL`P0x_8Wj$ni2F7#hzWPxfvDaISource code -

The original system was written by cookie. It was then completely rewritten and greatly enhanced by msquare and helios of planet cyborg and jplitza.

+

The original system was written by cookie. It was then completely rewritten and greatly enhanced by msquare and mortzu of planet cyborg and jplitza.

Hosting

Webspace, development platform and domain is currently provided by would you buy this? (ichdasich)
-and adminstrated by helios, derf and ichdasich.

+and adminstrated by mortzu, derf and ichdasich.

Icons

Some icons from the famfamfam.com silk iconset have been used. They are licensed under the Creative Commons Attribution 2.5 License.