From 77381ebca8bdb20b6dbd1b48222da677999f631d Mon Sep 17 00:00:00 2001 From: Philip Häusler Date: Mon, 26 Dec 2011 19:28:34 +0100 Subject: #44 confirm angel types --- includes/pages/admin_user_angeltypes.php | 46 ++++++++++++++++++++++++++++++++ includes/pages/user_settings.php | 8 ++++-- includes/sys_menu.php | 1 + 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 includes/pages/admin_user_angeltypes.php (limited to 'includes') 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", -- cgit v1.2.3-70-g09d2