diff --git a/db/update.d/16_admin_user_angeltypes.php b/db/update.d/16_admin_user_angeltypes.php new file mode 100644 index 00000000..de1803ea --- /dev/null +++ b/db/update.d/16_admin_user_angeltypes.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/includes/pages/admin_user_angeltypes.php b/includes/pages/admin_user_angeltypes.php new file mode 100644 index 00000000..26a08fe2 --- /dev/null +++ b/includes/pages/admin_user_angeltypes.php @@ -0,0 +1,46 @@ + 0) { + sql_query("UPDATE `UserAngelTypes` SET `confirm_user_id`=" . sql_escape($_SESSION['uid']) . " WHERE `id`=" . sql_escape($_REQUEST['confirm']) . " LIMIT 1"); + + success("Confirmed."); + redirect(page_link_to('admin_user_angeltypes')); + } + + $users_source = sql_select("SELECT `UserAngelTypes`.`id`, `AngelTypes`.`name`, `User`.`Nick` FROM `UserAngelTypes` JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id` JOIN `User` ON `UserAngelTypes`.`user_id`=`User`.`UID` WHERE `AngelTypes`.`restricted`=1 AND `UserAngelTypes`.`confirm_user_id` IS NULL"); + $users = array (); + foreach ($users_source as $user) { + $user['actions'] = 'confirm'; + $users[] = $user; + } + + return page(array ( + msg(), + table(array ( + 'Nick' => "Nick", + 'name' => "Angeltype", + 'actions' => "" + ), $users) + )); +} + +/** + * Anzeige, ob noch Engeltypen bestätigt werden müssen. Damit werden Erzengel auf jeder Seite im Kopfbereich "genervt". + */ +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 `AngelTypes`.`restricted`=1 AND `UserAngelTypes`.`confirm_user_id` IS NULL LIMIT 1") > 0; + + if ($unconfirmed_angeltypes) + return info('There are unconfirmed angeltypes!', true); + } + return ""; +} +?> \ No newline at end of file diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php index d3c76405..28fc88f1 100644 --- a/includes/pages/user_settings.php +++ b/includes/pages/user_settings.php @@ -99,9 +99,13 @@ function user_settings() { "', `Hometown`='" . sql_escape($hometown) . "' WHERE `UID`=" . sql_escape($user['UID'])); // Assign angel-types - sql_query("DELETE FROM `UserAngelTypes` WHERE `user_id`=" . sql_escape($user['UID'])); + foreach ($angel_types_source as $angel_type) + if (!in_array($angel_type['id'], $selected_angel_types)) + sql_query("DELETE FROM `UserAngelTypes` WHERE `user_id`=" . sql_escape($user['UID']) . " AND `angeltype_id`=" . sql_escape($angel_type['id']) . " LIMIT 1"); + foreach ($selected_angel_types as $selected_angel_type_id) - sql_query("INSERT INTO `UserAngelTypes` SET `user_id`=" . sql_escape($user['UID']) . ", `angeltype_id`=" . sql_escape($selected_angel_type_id)); + if (sql_num_query("SELECT * FROM `UserAngelTypes` WHERE `user_id`=" . sql_escape($user['UID']) . " AND `angeltype_id`=" . sql_escape($selected_angel_type_id) . " LIMIT 1") == 0) + sql_query("INSERT INTO `UserAngelTypes` SET `user_id`=" . sql_escape($user['UID']) . ", `angeltype_id`=" . sql_escape($selected_angel_type_id)); success("Settings saved."); redirect(page_link_to('user_settings')); diff --git a/includes/sys_menu.php b/includes/sys_menu.php index 6dd2c3aa..6dd483d9 100644 --- a/includes/sys_menu.php +++ b/includes/sys_menu.php @@ -43,6 +43,7 @@ function make_navigation() { "admin_usershifts", "admin_questions", "admin_angel_types", + "admin_user_angeltypes", "admin_shifts", "admin_rooms", "admin_groups", diff --git a/public/index.php b/public/index.php index 0e4739dc..5940f4aa 100644 --- a/public/index.php +++ b/public/index.php @@ -14,6 +14,7 @@ require_once ('config/config.php'); require_once ('config/config_db.php'); require_once ('includes/pages/admin_questions.php'); +require_once ('includes/pages/admin_user_angeltypes.php'); require_once ('includes/pages/user_messages.php'); session_start(); @@ -94,6 +95,10 @@ elseif (in_array($p, $privileges)) { require_once ('includes/pages/admin_user.php'); $content = admin_user(); } + elseif ($p == "admin_user_angeltypes") { + require_once ('includes/pages/admin_user_angeltypes.php'); + $content = admin_user_angeltypes(); + } elseif ($p == "admin_arrive") { require_once ('includes/pages/admin_arrive.php'); $content = admin_arrive(); @@ -172,6 +177,10 @@ if (isset ($user) && $p != "user_messages") if (isset ($user) && $p != "admin_questions") $content = admin_new_questions() . $content; +// Erzengel Hinweis für freizuschaltende Engeltypen +if (isset ($user) && $p != "admin_user_angeltypes") + $content = admin_new_user_angeltypes() . $content; + echo template_render('../templates/layout.html', array ( 'theme' => isset ($user) ? $user['color'] : $default_theme, 'title' => $title, diff --git a/templates/user_settings.html b/templates/user_settings.html deleted file mode 100644 index 47e5647e..00000000 --- a/templates/user_settings.html +++ /dev/null @@ -1,162 +0,0 @@ -
- %greeting% -
-- %text_user_data% -
-- %text_password% -
-- %text_theme% -
-- %text_language% -
- \ No newline at end of file diff --git a/templates/user_settings_tshirt.html b/templates/user_settings_tshirt.html deleted file mode 100644 index e147acae..00000000 --- a/templates/user_settings_tshirt.html +++ /dev/null @@ -1,4 +0,0 @@ -