From 4b5da4efdf0ebb1ee01ccfa66ba8b8ac71c592c0 Mon Sep 17 00:00:00 2001
From: Till Brehm <tbrehm@ispconfig.org>
Date: Fri, 4 Apr 2014 14:08:01 +0200
Subject: [PATCH] Fixed: FS#3423 - Clients with URL cron limit can also add
 chrooted cronjobs

---
 interface/web/sites/cron_edit.php        | 14 ++++++++++++--
 interface/web/sites/lib/lang/de_cron.lng |  2 ++
 interface/web/sites/lib/lang/en_cron.lng |  2 ++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/interface/web/sites/cron_edit.php b/interface/web/sites/cron_edit.php
index 092c7dd294..6ec02c7433 100644
--- a/interface/web/sites/cron_edit.php
+++ b/interface/web/sites/cron_edit.php
@@ -140,7 +140,7 @@ class page_action extends tform_actions {
 		if($_SESSION["s"]["user"]["typ"] != 'admin') {
 			// Get the limits of the client
 			$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
-			$client = $app->db->queryOneRecord("SELECT limit_cron_frequency FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
+			$client = $app->db->queryOneRecord("SELECT limit_cron_frequency, limit_cron_type FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
 
 			if($client["limit_cron_frequency"] > 1) {
 				if($app->tform->cron_min_freq < $client["limit_cron_frequency"]) {
@@ -148,6 +148,11 @@ class page_action extends tform_actions {
 					$has_error = true;
 				}
 			}
+			
+			if($client["limit_cron_type"] == 'url' && $this->dataRecord["type"] != 'url') {
+				$app->error($app->tform->wordbook["limit_cron_url_txt"]);
+				$has_error = true;
+			}
 		}
 
 		if($has_error == true) {
@@ -165,7 +170,7 @@ class page_action extends tform_actions {
 		if($_SESSION["s"]["user"]["typ"] != 'admin') {
 			// Get the limits of the client
 			$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
-			$client = $app->db->queryOneRecord("SELECT limit_cron_frequency FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
+			$client = $app->db->queryOneRecord("SELECT limit_cron_frequency, limit_cron_type FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
 
 			if($client["limit_cron_frequency"] > 1) {
 				if($app->tform->cron_min_freq < $client["limit_cron_frequency"]) {
@@ -173,6 +178,11 @@ class page_action extends tform_actions {
 					$has_error = true;
 				}
 			}
+			
+			if($client["limit_cron_type"] == 'url' && $this->dataRecord["type"] != 'url') {
+				$app->error($app->tform->wordbook["limit_cron_url_txt"]);
+				$has_error = true;
+			}
 		}
 
 		if($has_error == true) {
diff --git a/interface/web/sites/lib/lang/de_cron.lng b/interface/web/sites/lib/lang/de_cron.lng
index e9fed6846d..864b5a59cc 100644
--- a/interface/web/sites/lib/lang/de_cron.lng
+++ b/interface/web/sites/lib/lang/de_cron.lng
@@ -19,4 +19,6 @@ $wb['run_wday_error_format'] = 'Das Format für Wochentage ist nicht korrekt.';
 $wb['command_error_format'] = 'Das Format für den Befehl ist nicht korrekt. Beachten Sie, dass bei einem URL Aufruf nur http und https erlaubt ist.';
 $wb['unknown_fieldtype_error'] = 'Es wurde ein unbekanntes Feld verwendet.';
 $wb['server_id_error_empty'] = 'Die Server-ID ist leer.';
+$wb['limit_cron_url_txt'] = 'Es sind nur URL cronjobs möglich. Der Cron-Befehl muss mit http:// beginnen.';
+$wb['command_error_empty'] = 'Befehl ist leer.';
 ?>
diff --git a/interface/web/sites/lib/lang/en_cron.lng b/interface/web/sites/lib/lang/en_cron.lng
index e6ba8ad3dc..fabb4645c4 100644
--- a/interface/web/sites/lib/lang/en_cron.lng
+++ b/interface/web/sites/lib/lang/en_cron.lng
@@ -19,4 +19,6 @@ $wb['run_wday_error_format'] = 'Invalid format for days of the week.';
 $wb['command_error_format'] = 'Invalid command format. Please note that in case of an url call only http/https is allowed.';
 $wb['unknown_fieldtype_error'] = 'An unknown field type has been used.';
 $wb['server_id_error_empty'] = 'The server ID is empty.';
+$wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with http:// as cron command.';
+$wb['command_error_empty'] = 'Command is empty.';
 ?>
\ No newline at end of file
-- 
GitLab