@ -7,9 +7,6 @@ function user_angeltypes_unconfirmed_hint() {
global $user;
$unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes($user);
if ($unconfirmed_user_angeltypes === false) {
engelsystem_error("Unable to load user angeltypes.");
}
if (count($unconfirmed_user_angeltypes) == 0) {
return '';
}
@ -34,9 +31,6 @@ function user_angeltypes_delete_all_controller() {
}
$angeltype = AngelType($_REQUEST['angeltype_id']);
if ($angeltype === false) {
engelsystem_error("Unable to load angeltype.");
}
if ($angeltype == null) {
error(_("Angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
@ -48,10 +42,7 @@ function user_angeltypes_delete_all_controller() {
}
if (isset($_REQUEST['confirmed'])) {
$result = UserAngelTypes_delete_all($angeltype['id']);
if ($result === false) {
engelsystem_error("Unable to confirm all users.");
}
UserAngelTypes_delete_all($angeltype['id']);
engelsystem_log(sprintf("Denied all users for angeltype %s", AngelType_name_render($angeltype)));
success(sprintf(_("Denied all users for angeltype %s."), AngelType_name_render($angeltype)));
@ -76,18 +67,12 @@ function user_angeltypes_confirm_all_controller() {
}
$angeltype = AngelType($_REQUEST['angeltype_id']);
if ($angeltype === false) {
engelsystem_error("Unable to load angeltype.");
}
if ($angeltype == null) {
error(_("Angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
}
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
if ($user_angeltype === false) {
engelsystem_error("Unable to load user angeltype.");
}
if ($user_angeltype == null) {
error(_("User angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
@ -99,10 +84,7 @@ function user_angeltypes_confirm_all_controller() {
}
if (isset($_REQUEST['confirmed'])) {
$result = UserAngelTypes_confirm_all($angeltype['id'], $user);
if ($result === false) {
engelsystem_error("Unable to confirm all users.");
}
UserAngelTypes_confirm_all($angeltype['id'], $user);
engelsystem_log(sprintf("Confirmed all users for angeltype %s", AngelType_name_render($angeltype)));
success(sprintf(_("Confirmed all users for angeltype %s."), AngelType_name_render($angeltype)));
@ -127,18 +109,12 @@ function user_angeltype_confirm_controller() {
}
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
if ($user_angeltype === false) {
engelsystem_error("Unable to load user angeltype.");
}
if ($user_angeltype == null) {
error(_("User angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
}
$angeltype = AngelType($user_angeltype['angeltype_id']);
if ($angeltype === false) {
engelsystem_error("Unable to load angeltype.");
}
if ($angeltype == null) {
error(_("Angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
@ -150,9 +126,6 @@ function user_angeltype_confirm_controller() {
}
$user_source = User($user_angeltype['user_id']);
if ($user_source === false) {
engelsystem_error("Unable to load user.");
}
if ($user_source == null) {
error(_("User doesn't exist."));
redirect(page_link_to('angeltypes'));
@ -187,27 +160,18 @@ function user_angeltype_delete_controller() {
}
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
if ($user_angeltype === false) {
engelsystem_error("Unable to load user angeltype.");
}
if ($user_angeltype == null) {
error(_("User angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
}
$angeltype = AngelType($user_angeltype['angeltype_id']);
if ($angeltype === false) {
engelsystem_error("Unable to load angeltype.");
}
if ($angeltype == null) {
error(_("Angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
}
$user_source = User($user_angeltype['user_id']);
if ($user_source === false) {
engelsystem_error("Unable to load user.");
}
if ($user_source == null) {
error(_("User doesn't exist."));
redirect(page_link_to('angeltypes'));
@ -261,37 +225,25 @@ function user_angeltype_update_controller() {
}
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
if ($user_angeltype === false) {
engelsystem_error("Unable to load user angeltype.");
}
if ($user_angeltype == null) {
error(_("User angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
}
$angeltype = AngelType($user_angeltype['angeltype_id']);
if ($angeltype === false) {
engelsystem_error("Unable to load angeltype.");
}
if ($angeltype == null) {
error(_("Angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
}
$user_source = User($user_angeltype['user_id']);
if ($user_source === false) {
engelsystem_error("Unable to load user.");
}
if ($user_source == null) {
error(_("User doesn't exist."));
redirect(page_link_to('angeltypes'));
}
if (isset($_REQUEST['confirmed'])) {
$result = UserAngelType_update($user_angeltype['id'], $coordinator);
if ($result === false) {
engelsystem_error("Unable to update coordinator rights.");
}
UserAngelType_update($user_angeltype['id'], $coordinator);
$success_message = sprintf($coordinator ? _("Added coordinator rights for %s to %s.") : _("Removed coordinator rights for %s from %s."), AngelType_name_render($angeltype), User_Nick_render($user_source));
engelsystem_log($success_message);
@ -326,26 +278,17 @@ function user_angeltype_add_controller() {
// Load possible users, that are not in the angeltype already
$users_source = Users_by_angeltype_inverted($angeltype);
if ($users_source === false) {
engelsystem_error("Unable to load users.");
}
if (isset($_REQUEST['submit'])) {
$user_source = load_user();
if (! UserAngelType_exists($user_source, $angeltype)) {
$user_angeltype_id = UserAngelType_create($user_source, $angeltype);
if ($user_angeltype_id === false) {
engelsystem_error("Unable to create user angeltype.");
}
engelsystem_log(sprintf("User %s added to %s.", User_Nick_render($user_source), AngelType_name_render($angeltype)));
success(sprintf(_("User %s added to %s."), User_Nick_render($user_source), AngelType_name_render($angeltype)));
$result = UserAngelType_confirm($user_angeltype_id, $user_source);
if ($result === false) {
engelsystem_error("Unable to confirm user angeltype.");
}
UserAngelType_confirm($user_angeltype_id, $user_source);
engelsystem_log(sprintf("User %s confirmed as %s.", User_Nick_render($user), AngelType_name_render($angeltype)));
redirect(page_link_to('angeltypes') . '& action=view& angeltype_id=' . $angeltype['id']);
@ -365,9 +308,6 @@ function user_angeltype_join_controller($angeltype) {
global $user, $privileges;
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
if ($user_angeltype === false) {
engelsystem_error("Unable to load user angeltype.");
}
if ($user_angeltype != null) {
error(sprintf(_("You are already a %s."), $angeltype['name']));
redirect(page_link_to('angeltypes'));
@ -375,19 +315,13 @@ function user_angeltype_join_controller($angeltype) {
if (isset($_REQUEST['confirmed'])) {
$user_angeltype_id = UserAngelType_create($user, $angeltype);
if ($user_angeltype_id === false) {
engelsystem_error("Unable to create user angeltype.");
}
$success_message = sprintf(_("You joined %s."), $angeltype['name']);
engelsystem_log(sprintf("User %s joined %s.", User_Nick_render($user), AngelType_name_render($angeltype)));
success($success_message);
if (in_array('admin_user_angeltypes', $privileges)) {
$result = UserAngelType_confirm($user_angeltype_id, $user);
if ($result === false) {
engelsystem_error("Unable to confirm user angeltype.");
}
UserAngelType_confirm($user_angeltype_id, $user);
engelsystem_log(sprintf("User %s confirmed as %s.", User_Nick_render($user), AngelType_name_render($angeltype)));
}