diff options
author | Philip Häusler <msquare@notrademark.de> | 2011-12-26 19:28:34 +0100 |
---|---|---|
committer | Philip Häusler <msquare@notrademark.de> | 2011-12-26 19:28:34 +0100 |
commit | 77381ebca8bdb20b6dbd1b48222da677999f631d (patch) | |
tree | 0af1764befd047f2826c23c443ecebb77ae49eae /includes | |
parent | b3d4d7dc52355df21bc1e3e67a2ab3435a31484a (diff) |
#44 confirm angel types
Diffstat (limited to 'includes')
-rw-r--r-- | includes/pages/admin_user_angeltypes.php | 46 | ||||
-rw-r--r-- | includes/pages/user_settings.php | 8 | ||||
-rw-r--r-- | includes/sys_menu.php | 1 |
3 files changed, 53 insertions, 2 deletions
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 @@ +<?php + + +/** + * Auf dieser Seite können Erzengel Engeltypen für bestimmte Nutzer freischalten, z.B. nachdem diese für die Aufgabe geschult wurden. + */ +function admin_user_angeltypes() { + if (isset ($_REQUEST['confirm']) && test_request_int('confirm') && sql_num_query("SELECT * FROM `UserAngelTypes` WHERE `id`=" . sql_escape($_REQUEST['confirm']) . " AND `confirm_user_id` IS NULL") > 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'] = '<a href="' . page_link_to('admin_user_angeltypes') . '&confirm=' . $user['id'] . '">confirm</a>'; + $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('<a href="' . page_link_to('admin_user_angeltypes') . '">There are unconfirmed angeltypes!</a>', 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", |