Better disable the buttons so that a user can't remove his own admin rights,

than showing a warning dialog (for an action that can't be undone, and doesn't
make sense!).
https://intevation.de/roundup/kolab/issue377

svn path=/branches/KDE_3_3_BRANCH/kdepim/; revision=349112
wilder-work
David Faure 22 years ago
parent 2b229e009d
commit cb92f6ec3d
  1. 25
      folderdiaacltab.cpp

@ -529,6 +529,13 @@ void KMail::FolderDiaACLTab::slotEditACL(QListViewItem* item)
{
if ( !item ) return;
bool canAdmin = ( mUserRights & ACLJobs::Administer );
// Same logic as in slotSelectionChanged, but this is also needed for double-click IIRC
if ( canAdmin && mImapAccount && item ) {
// Don't allow users to remove their own admin permissions - there's no way back
ListViewItem* ACLitem = static_cast<ListViewItem *>( item );
if ( mImapAccount->login() == ACLitem->userId() && ACLitem->permissions() == ACLJobs::All )
canAdmin = false;
}
if ( !canAdmin ) return;
ListViewItem* ACLitem = static_cast<ListViewItem *>( mListView->currentItem() );
@ -545,12 +552,6 @@ void KMail::FolderDiaACLTab::slotEditACL(QListViewItem* item)
userIds.pop_front();
addACLs( userIds, dlg.permissions() );
}
if ( mImapAccount && mImapAccount->login() == ACLitem->userId()
&& ( dlg.permissions() & ACLJobs::Administer ) == 0 ) {
if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel( topLevelWidget(),
i18n( "Do you really want to remove your own administration permissions for this folder? You will not be able to edit the permissions anymore afterwards." ), i18n( "Remove" ) ) )
return;
}
}
}
@ -583,10 +584,18 @@ void KMail::FolderDiaACLTab::slotAddACL()
void KMail::FolderDiaACLTab::slotSelectionChanged(QListViewItem* item)
{
bool canAdmin = ( mUserRights & ACLJobs::Administer );
bool canAdminThisItem = canAdmin;
if ( canAdmin && mImapAccount && item ) {
// Don't allow users to remove their own admin permissions - there's no way back
ListViewItem* ACLitem = static_cast<ListViewItem *>( item );
if ( mImapAccount->login() == ACLitem->userId() && ACLitem->permissions() == ACLJobs::All )
canAdminThisItem = false;
}
bool lvVisible = mStack->visibleWidget() == mACLWidget;
mAddACL->setEnabled( lvVisible && canAdmin && !mSaving );
mEditACL->setEnabled( item && lvVisible && canAdmin && !mSaving );
mRemoveACL->setEnabled( item && lvVisible && canAdmin && !mSaving );
mEditACL->setEnabled( item && lvVisible && canAdminThisItem && !mSaving );
mRemoveACL->setEnabled( item && lvVisible && canAdminThisItem && !mSaving );
}
void KMail::FolderDiaACLTab::slotRemoveACL()

Loading…
Cancel
Save