Skip to content

Commit c86da31

Browse files
committed
Fixed: FS#1111 - Delete an 'in use' template should be blocked
1 parent 4bf3f93 commit c86da31

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

interface/web/client/client_template_del.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,21 @@
4444

4545
//* Check permissions for module
4646
$app->auth->check_module_permissions('client');
47-
if(!$_SESSION["s"]["user"]["typ"] == 'admin') die('Client-Templates are only for Admins.');
47+
if(!$_SESSION["s"]["user"]["typ"] == 'admin') die('Client-Templates are for Admins only.');
4848

4949
$app->uses('tpl,tform');
5050
$app->load('tform_actions');
5151

5252
class page_action extends tform_actions {
53+
function onBeforeDelete() {
54+
global $app;
55+
56+
$rec = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE template_master = ".$this->id." OR template_additional like '%/".$this->id."/%'");
57+
if($rec['number'] > 0) {
58+
$app->error($app->tform->lng('template_del_aborted_txt'));
59+
}
60+
61+
}
5362
}
5463

5564
$page = new page_action;

interface/web/client/lib/lang/en_client_template.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ $wb["error_template_name_empty"] = 'Please enter a Template name';
5757
$wb["limit_web_quota_txt"] = 'Web Quota';
5858
$wb["limit_traffic_quota_txt"] = 'Traffic Quota';
5959
$wb["limit_trafficquota_error_notint"] = 'Traffic Quota must be a number.';
60+
$wb["template_del_aborted_txt"] = 'Delete aborted. There is still a client which has this template selected.';
6061
?>

0 commit comments

Comments
 (0)