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 | |
parent | b3d4d7dc52355df21bc1e3e67a2ab3435a31484a (diff) |
#44 confirm angel types
-rw-r--r-- | db/update.d/16_admin_user_angeltypes.php | 21 | ||||
-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 | ||||
-rw-r--r-- | public/index.php | 9 | ||||
-rw-r--r-- | templates/user_settings.html | 162 | ||||
-rw-r--r-- | templates/user_settings_tshirt.html | 4 |
7 files changed, 83 insertions, 168 deletions
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 @@ +<?php + + +// create admin_user_angeltypes permission/privilege and assign it to the archangel usergroup. +if (sql_num_query("SELECT * FROM `Privileges` WHERE `name`='admin_user_angeltypes'") == 0) { + sql_query("INSERT INTO `Privileges` (`id`, `name`, `desc`) VALUES ( NULL , 'admin_user_angeltypes', 'Confirm restricted angel types' );"); + $id = sql_id(); + sql_query("INSERT INTO `GroupPrivileges` SET `group_id`=-5, `privilege_id`=" . sql_escape($id)); + sql_query("INSERT INTO `Sprache` ( + `TextID` , + `Sprache` , + `Text` + ) + VALUES ( + 'admin_user_angeltypes', 'DE', 'Engeltypen freischalten' + ), ( + 'admin_user_angeltypes', 'EN', 'Confirm angeltypes' + );"); + $applied = true; +} +?>
\ 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 @@ +<?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", 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 @@ -<p> - %greeting% -</p> -<hr/> -<p> - %text_user_data% -</p> -<form action="%link%&action=setUserData" method="post"> - <table> - <tr> - <td> - %label_nick% - </td> - <td> - <input type="text" name="nick" size="23" value="%nick%"> - </td> - </tr> - <tr> - <td> - %label_name% - </td> - <td> - <input type="text" name="name" size="23" value="%name%"> - </td> - </tr> - <tr> - <td> - %label_prename% - </td> - <td> - <input type="text" name="prename" size="23" value="%prename%"> - </td> - </tr> - <tr> - <td> - %label_age% - </td> - <td> - <input type="text" name="age" size="3" value="%age%"> - </td> - </tr> - <tr> - <td> - %label_tel% - </td> - <td> - <input type="text" name="tel" size="40" value="%tel%"> - </td> - </tr> - <tr> - <td> - %label_mobile% - </td> - <td> - <input type="text" name="mobile" size="40" value="%mobile%"> - </td> - </tr> - <tr> - <td> - %label_dect% - </td> - <td> - <input type="text" name="dect" size="4" value="%dect%"> - </td> - </tr> - <tr> - <td> - %label_mail% - </td> - <td> - <input type="text" name="mail" size="40" value="%mail%"> - </td> - </tr> - <tr> - <td> - ICQ - </td> - <td> - <input type="text" name="icq" size="40" value="%icq%"> - </td> - </tr> - <tr> - <td> - jabber - </td> - <td> - <input type="text" name="jabber" size="40" value="%jabber%"> - </td> - </tr> - <tr> - <td> - %label_hometown% - </td> - <td> - <input type="text" name="hometown" size="40" value="%hometown%"> - </td> - </tr>%tshirts% - </table><input type="submit" value="%label_save%"> -</form><hr/> -<p> - %text_password% -</p> -<form action="%link%&action=set" method="post"> - <table> - <tr> - <td> - %current_pw_label% - </td> - <td> - <input type="password" name="current_pw" size="20"> - </td> - </tr> - <tr> - <td> - %new_pw_label% - </td> - <td> - <input type="password" name="new_pw" size="20"> - </td> - </tr> - <tr> - <td> - %new_pw2_label% - </td> - <td> - <input type="password" name="new_pw2" size="20"> - </td> - </tr> - </table><input type="submit" value="%label_save%"> -</form><hr/> -<p> - %text_theme% -</p> -<form action="%link%&action=colour" method="post"> - <table> - <tr> - <td> - %theme_label% - </td> - <td> - %theme_select% - </td> - </tr> - </table> - <input type="submit" value="%label_save%"> -</form><hr/> -<p> - %text_language% -</p> -<form action="%link%&action=sprache" method="post"> - <table> - <tr> - <td> - %language_label% - </td> - <td> - %language_select% - </td> - </tr> - </table> - <input type="submit" value="%label_save%"> -</form>
\ 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 @@ - <tr> - <td>%label_size%</td> - <td>%size_select%</td> - </tr>
\ No newline at end of file |