From 615c265d0041edc3706d9e6c8387c3db72758ea9 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 11 Feb 2010 22:39:15 +0000 Subject: [PATCH] Allow the addition of a committee role to an existing user. --- admin/user_editor_window.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/admin/user_editor_window.php b/admin/user_editor_window.php index 3fa6e87..7fbd841 100644 --- a/admin/user_editor_window.php +++ b/admin/user_editor_window.php @@ -92,12 +92,21 @@ echo mysql_error(); if(mysql_num_rows($q)) { $r = mysql_fetch_object($q); if($r->deleted == 'no') { - echo "Username already exists."; - exit; + /* Load the user */ + $u = user_load_by_email($username); + if(in_array($type, $u['types'])) { + echo "Username already exists with role '$type'"; + exit; + } else { + /* Add the role, user_create does a role_allowed check + * so we'll never add a judge/committee role to a student */ + user_create($type, $username, $u); + } } + } else { + $u = user_create($type, $username); + $u['email'] = $username; } - $u = user_create($type, $username); - $u['email'] = $username; user_save($u); $id = $u['id']; } else {