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

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

diff --git a/interface/web/sites/cron_edit.php b/interface/web/sites/cron_edit.php
index 092c7dd..6ec02c7 100644
--- a/interface/web/sites/cron_edit.php
+++ b/interface/web/sites/cron_edit.php
@@ -140,13 +140,18 @@
 		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"]) {
 					$app->error($app->tform->wordbook["limit_cron_frequency_txt"]);
 					$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;
 			}
 		}
 
@@ -165,7 +170,7 @@
 		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 @@
 					$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 e9fed68..864b5a5 100644
--- a/interface/web/sites/lib/lang/de_cron.lng
+++ b/interface/web/sites/lib/lang/de_cron.lng
@@ -19,4 +19,6 @@
 $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 e6ba8ad..fabb464 100644
--- a/interface/web/sites/lib/lang/en_cron.lng
+++ b/interface/web/sites/lib/lang/en_cron.lng
@@ -19,4 +19,6 @@
 $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

--
Gitblit v1.9.1