From e3a0af34d52c41fc2f45522528e484f858f1ce3e Mon Sep 17 00:00:00 2001
From: till <till@php.net>
Date: Sun, 10 Feb 2008 12:08:40 -0500
Subject: [PATCH] * fixing #1484494 (people can delete the last identity otherwise) * FOR TRANSLATERS: introducing new message
---
program/include/rcube_user.inc | 9 +++++++++
program/localization/de_DE/messages.inc | 2 +-
program/steps/settings/delete_identity.inc | 7 ++++++-
program/localization/en_US/messages.inc | 2 +-
program/localization/en_GB/messages.inc | 2 +-
5 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/program/include/rcube_user.inc b/program/include/rcube_user.inc
index 841c843..20c8dd8 100644
--- a/program/include/rcube_user.inc
+++ b/program/include/rcube_user.inc
@@ -241,6 +241,15 @@
if (!$this->ID)
return false;
+
+ $sql_result = $DB->query("SELECT count(*) AS ident_count FROM " .
+ get_table_name('identities') .
+ " WHERE user_id = ? AND del != 1",
+ $this->ID);
+
+ $sql_arr = $DB->fetch_assoc($sql_result);
+ if ($sql_arr['ident_count'] <= 1)
+ return false;
$DB->query(
"UPDATE ".get_table_name('identities')."
diff --git a/program/localization/de_DE/messages.inc b/program/localization/de_DE/messages.inc
index d927b4b..2ef66ac 100644
--- a/program/localization/de_DE/messages.inc
+++ b/program/localization/de_DE/messages.inc
@@ -76,5 +76,5 @@
$messages['movingmessage'] = 'Die E-Mail wird verschoben...';
$messages['receiptsent'] = 'Bestätigung erfolgreich gesendet';
$messages['errorsendingreceipt'] = 'Bestätigung konnte nicht gesendet werden';
-
+$messages['nodeletelastidentity'] = 'Sie koennen diesen Absender nicht loeschen.';
?>
diff --git a/program/localization/en_GB/messages.inc b/program/localization/en_GB/messages.inc
index 5995108..20c0c14 100644
--- a/program/localization/en_GB/messages.inc
+++ b/program/localization/en_GB/messages.inc
@@ -74,5 +74,5 @@
$messages['sourceisreadonly'] = 'This address source is read-only';
$messages['errorsavingcontact'] = 'Could not save the contact address';
$messages['movingmessage'] = 'Moving message...';
-
+$messages['nodeletelastidentity'] = 'You cannot delete this identity, it\'s your last one.';
?>
\ No newline at end of file
diff --git a/program/localization/en_US/messages.inc b/program/localization/en_US/messages.inc
index 3576bf9..5ee04d7 100644
--- a/program/localization/en_US/messages.inc
+++ b/program/localization/en_US/messages.inc
@@ -76,5 +76,5 @@
$messages['movingmessage'] = 'Moving message...';
$messages['receiptsent'] = 'Successfully sent a read receipt';
$messages['errorsendingreceipt'] = 'Could not send the receipt';
-
+$messages['nodeletelastidentity'] = 'You cannot delete this identity, it\'s your last one.';
?>
\ No newline at end of file
diff --git a/program/steps/settings/delete_identity.inc b/program/steps/settings/delete_identity.inc
index 06fdd94..a5f3d44 100644
--- a/program/steps/settings/delete_identity.inc
+++ b/program/steps/settings/delete_identity.inc
@@ -23,8 +23,13 @@
{
if ($USER->delete_identity($ids))
+ {
$OUTPUT->show_message('deletedsuccessfully', 'confirmation');
-
+ }
+ else
+ {
+ $OUTPUT->show_message('nodeletelastidentity', 'error');
+ }
// send response
if ($OUTPUT->ajax_call)
$OUTPUT->send();
--
Gitblit v1.9.1