Skip to content
Snippets Groups Projects
Commit cf6cd814 authored by Jared Hancock's avatar Jared Hancock
Browse files

emails: Drop in-use check when deleting

parent ec0b2c54
Branches
Tags
No related merge requests found
...@@ -200,10 +200,15 @@ class Email extends VerySimpleModel { ...@@ -200,10 +200,15 @@ class Email extends VerySimpleModel {
Dept::objects() Dept::objects()
->filter(array('email_id' => $this->getId())) ->filter(array('email_id' => $this->getId()))
->update(array( ->update(array(
'autoresp_email_id' => 0,
'email_id' => $cfg->getDefaultEmailId() 'email_id' => $cfg->getDefaultEmailId()
)); ));
Dept::objects()
->filter(array('autoresp_email_id' => $this->getId()))
->update(array(
'autoresp_email_id' => 0,
));
return true; return true;
} }
......
...@@ -50,14 +50,8 @@ if($_POST){ ...@@ -50,14 +50,8 @@ if($_POST){
} else { } else {
$count=count($_POST['ids']); $count=count($_POST['ids']);
$sql='SELECT count(dept_id) FROM '.DEPT_TABLE.' dept ' switch (strtolower($_POST['a'])) {
.' WHERE email_id IN ('.implode(',', db_input($_POST['ids'])).') ' case 'delete':
.' OR autoresp_email_id IN ('.implode(',', db_input($_POST['ids'])).')';
list($depts)=db_fetch_row(db_query($sql));
if($depts>0) {
$errors['err'] = __('One or more of the selected emails is being used by a department. Remove association first!');
} elseif(!strcasecmp($_POST['a'], 'delete')) {
$i=0; $i=0;
foreach($_POST['ids'] as $k=>$v) { foreach($_POST['ids'] as $k=>$v) {
if($v!=$cfg->getDefaultEmailId() && ($e=Email::lookup($v)) && $e->delete()) if($v!=$cfg->getDefaultEmailId() && ($e=Email::lookup($v)) && $e->delete())
...@@ -73,8 +67,9 @@ if($_POST){ ...@@ -73,8 +67,9 @@ if($_POST){
elseif(!$errors['err']) elseif(!$errors['err'])
$errors['err'] = sprintf(__('Unable to delete %s'), $errors['err'] = sprintf(__('Unable to delete %s'),
_N('selected email', 'selected emails', $count)); _N('selected email', 'selected emails', $count));
break;
} else { default:
$errors['err'] = __('Unknown action - get technical help.'); $errors['err'] = __('Unknown action - get technical help.');
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment