Index: trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php
===================================================================
--- trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php	(revision 5934)
+++ trunk/expressoAdmin1_2/inc/class.ldap_functions.inc.php	(revision 6096)
@@ -2718,5 +2718,5 @@
 			for ($i=0; $i<$entries['count']; $i++)
 			{
-				$tr = "<tr class='normal' onMouseOver=this.className='selected' onMouseOut=this.className='normal'><td onClick=edit_shared_account('".$entries[$i]['uid'][0]."')>" . utf8_decode($entries[$i]['cn'][0]) . "</td><td onClick=edit_shared_account('".$entries[$i]['uid'][0]."')>" . utf8_decode($entries[$i]['cn'][0]). " (" . $entries[$i]['uid'][0] . ")" . "</td><td onClick=edit_shared_account('".$entries[$i]['uid'][0]."')>" . $entries[$i]['mail'][0] . "<td align='center' onClick=delete_shared_accounts('".$entries[$i]['uid'][0]."')><img HEIGHT='16' WIDTH='16' src=./expressoAdmin1_2/templates/default/images/delete.png></td></tr>";
+				$tr = "<tr class='normal' onMouseOver=this.className='selected' onMouseOut=this.className='normal'><td onClick=edit_shared_account('".$entries[$i]['uid'][0]."')>" . utf8_decode($entries[$i]['cn'][0]) . "</td><td onClick=edit_shared_account('".$entries[$i]['uid'][0]."')>" . utf8_decode($entries[$i]['cn'][0]). " (" . $entries[$i]['uid'][0] . ")" . "</td><td onClick=edit_shared_account('".$entries[$i]['uid'][0]."')>" . $entries[$i]['mail'][0] . "<td align='center' onClick=delete_shared_accounts('".$entries[$i]['uid'][0]."','".$entries[$i]['mail'][0]."')><img HEIGHT='16' WIDTH='16' src=./expressoAdmin1_2/templates/default/images/delete.png></td></tr>";
 				$trs[$tr] = utf8_decode($entries[$i]['cn'][0]);
 			}
Index: trunk/expressoAdmin1_2/js/jscode/shared_accounts.js
===================================================================
--- trunk/expressoAdmin1_2/js/jscode/shared_accounts.js	(revision 6018)
+++ trunk/expressoAdmin1_2/js/jscode/shared_accounts.js	(revision 6096)
@@ -443,4 +443,23 @@
 }
 
+function callbackDelete(sharedUser){
+
+    if(!!sharedUser && $.isArray(sharedUser))
+	for(var i = 0; i < sharedUser.length; i++)
+	    if(sharedUser[i].phpgwAccountType == 's'){
+		sharedUser = sharedUser[i];
+		break;
+	    }
+	
+	var signature = DataLayer.get('calendarSignature', {
+		filter: ['=','user', sharedUser.id]
+	    });
+	
+	signature = $.isArray(signature) ? signature[0] : signature;
+	
+	DataLayer.remove('calendarSignature', signature.id)
+	DataLayer.commit();
+}
+
 function calback(){
     var sharedUser = DataLayer.get('user', {
@@ -527,9 +546,16 @@
 
 
-function delete_shared_accounts(uid)
+function delete_shared_accounts(uid, mail)
 {
     if (!confirm(get_lang('Are you sure that you want to delete this shared account') + "?"))
 	return;
 	
+	var user = {};
+	if(sharemailbox.ownersExpressoCalendarAcl)
+		user =  DataLayer.get('user', {
+			filter: ['=','mail',mail]
+		});
+	
+	
     var handle_delete_shared_account = function(data_return)
     {
@@ -540,4 +566,8 @@
 	else
 	{
+		if(sharemailbox.ownersExpressoCalendarAcl){
+			callbackDelete(user);
+		}
+	
 	    write_msg(get_lang('Shared account successful deleted') + '.', 'normal');
 	    get_shared_accounts(Element('ea_shared_account_search').value);
@@ -545,4 +575,7 @@
 	return;
     }
+	
+	
+	
     cExecute ('$this.shared_accounts.delete&uid='+uid, handle_delete_shared_account);
 }
Index: trunk/prototype/modules/calendar/interceptors/DBMapping.php
===================================================================
--- trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 6066)
+++ trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 6096)
@@ -759,7 +759,22 @@
 
 	    if (!empty($schedulables))
-		Controller::deleteALL(array('concept' => 'schedulable'), null, array('filter' => array('IN', 'id', $schedulables)));
+			Controller::deleteALL(array('concept' => 'schedulable'), null, array('filter' => array('IN', 'id', $schedulables)));
 
 	    Controller::delete(array('concept' => 'calendar', 'id' => $signature['calendar']));
+		
+		$permissions = Controller::find(array('concept' => 'calendarToPermission'), array('id'), array('filter' => array('=', 'calendar', $signature['calendar'])));
+
+		
+		
+		if($permissions && count($permissions) > 0){
+			$ids = array();
+			foreach($permissions as $key => $value)
+				array_push($ids, $value['id']);
+		
+			Controller::deleteALL(array('concept' => 'calendarToPermission'), null, array('filter' => array('IN', 'id', $ids)));
+			
+		}
+		
+		
 	}
     }
