summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Philipp Litza <janphilipp@litza.de>2012-12-28 17:47:02 +0100
committerJan-Philipp Litza <janphilipp@litza.de>2012-12-28 17:47:02 +0100
commit9270b54eb187df650df55a2ee8bcead0b863c7a9 (patch)
tree97a525b7adf34a6f644d3b2610759d448f834270
parentc5438d5228887e638208f347fa132bfd5b60dacb (diff)
optimizations and minor fixes for user_shifts and admin_user
-rw-r--r--includes/pages/admin_user.php8
-rw-r--r--includes/pages/user_settings.php10
2 files changed, 10 insertions, 8 deletions
diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php
index 5f2bdbe6..94e90a24 100644
--- a/includes/pages/admin_user.php
+++ b/includes/pages/admin_user.php
@@ -102,8 +102,12 @@ function admin_user() {
$angel_types[$angel_type['id']] = $angel_type['name'];
if (isset ($_REQUEST['submit_user_angeltypes'])) {
- $selected_angel_types = array_intersect($_REQUEST['selected_angel_types'], array_keys($angel_types));
- $accepted_angel_types = array_unique(array_diff(array_intersect($_REQUEST['accepted_angel_types'], array_keys($angel_types)), $nonrestricted_angel_types));
+ $selected_angel_types = isset($_REQUEST['selected_angel_types']) && is_array($_REQUEST['selected_angel_types'])?
+ array_intersect($_REQUEST['selected_angel_types'], array_keys($angel_types))
+ : array();
+ $accepted_angel_types = isset($_REQUEST['accepted_angel_types']) && is_array($_REQUEST['accepted_angel_types'])?
+ array_unique(array_diff(array_intersect($_REQUEST['accepted_angel_types'], array_keys($angel_types)), $nonrestricted_angel_types))
+ : array();
if (in_array("admin_user_angeltypes", $privileges))
$selected_angel_types = array_merge((array) $selected_angel_types, $accepted_angel_types);
$selected_angel_types = array_unique($selected_angel_types);
diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php
index 7aaad79a..62b78751 100644
--- a/includes/pages/user_settings.php
+++ b/includes/pages/user_settings.php
@@ -67,7 +67,7 @@ function user_settings() {
if (isset ($_REQUEST['tshirt_size']) && isset ($tshirt_sizes[$_REQUEST['tshirt_size']]))
$tshirt_size = $_REQUEST['tshirt_size'];
- else {
+ elseif($enable_tshirt_size) {
$ok = false;
}
@@ -100,12 +100,10 @@ function user_settings() {
// Assign angel-types
$user_angel_type_info = array();
- 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");
- else
+ sql_query("DELETE FROM `UserAngelTypes` WHERE `user_id`='" . sql_escape($user['UID']) . "' AND `angeltype_id` IN (" . implode(",", array_diff(array_keys($angel_types), $selected_angel_types)) . ")");
+ foreach ($angel_types_source as $angel_type)
+ if (in_array($angel_type['id'], $selected_angel_types))
$user_angel_type_info[] = $angel_type['name'];
- }
foreach ($selected_angel_types as $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)