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[] = '
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.
Webspace, development platform and domain is currently provided by would you buy this? (ichdasich)
-and adminstrated by helios, derf and ichdasich.
Some icons from the famfamfam.com silk iconset have been used. They are licensed under the Creative Commons Attribution 2.5 License.