From 21206c45bf44d91bbefcafc70a4a5d499554e4bf Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Sun, 31 Aug 2008 05:36:11 -0400
Subject: [PATCH] - Added the readonly attribute to tabs. - Clients that are not resellers can not change the basic web settings anymore.

---
 interface/lib/classes/tform_actions.inc.php   |    2 +-
 interface/lib/classes/tform.inc.php           |    8 ++++++++
 interface/web/sites/form/web_domain.tform.php |   12 ++++++++++++
 3 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/interface/lib/classes/tform.inc.php b/interface/lib/classes/tform.inc.php
index 9f920c6..3d017aa 100644
--- a/interface/lib/classes/tform.inc.php
+++ b/interface/lib/classes/tform.inc.php
@@ -1024,6 +1024,14 @@
                 return $_SESSION["s"]["form"]["tab"];
         }
 		
+		function isReadonlyTab($tab) {
+			if(isset($this->formDef['tabs'][$tab]['readonly']) && $this->formDef['tabs'][$tab]['readonly'] == true) {
+				return true;
+			} else {
+				return false;
+			}
+        }
+		
 		
 		// translation function for forms, tries the form wordbook first and if this fails, it tries the global wordbook
 		function lng($msg) {
diff --git a/interface/lib/classes/tform_actions.inc.php b/interface/lib/classes/tform_actions.inc.php
index 023595e..812c792 100644
--- a/interface/lib/classes/tform_actions.inc.php
+++ b/interface/lib/classes/tform_actions.inc.php
@@ -168,7 +168,7 @@
 		
 		function onUpdateSave($sql) {
 			global $app;
-			if(!empty($sql)) {
+			if(!empty($sql) && !$app->tform->isReadonlyTab($app->tform->getCurrentTab())) {
 				$app->db->query($sql);
 				if($app->db->errorMessage != '') die($app->db->errorMessage);
 			}
diff --git a/interface/web/sites/form/web_domain.tform.php b/interface/web/sites/form/web_domain.tform.php
index 44f2193..d9e19f9 100644
--- a/interface/web/sites/form/web_domain.tform.php
+++ b/interface/web/sites/form/web_domain.tform.php
@@ -50,10 +50,19 @@
 $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
 $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
 
+// Clients may not change the website basic settings if they are not resellers
+if($app->auth->has_clients($_SESSION['s']['user']['userid']) || $app->auth->is_admin()) {
+	$web_domain_edit_readonly = false;
+} else {
+	$web_domain_edit_readonly = true;
+}
+
+
 $form["tabs"]['domain'] = array (
 	'title' 	=> "Domain",
 	'width' 	=> 100,
 	'template' 	=> "templates/web_domain_edit.htm",
+	'readonly'	=> $web_domain_edit_readonly,
 	'fields' 	=> array (
 	##################################
 	# Begin Datatable fields
@@ -188,6 +197,7 @@
 	'title' 	=> "Redirect",
 	'width' 	=> 100,
 	'template' 	=> "templates/web_domain_redirect.htm",
+	'readonly'	=> false,
 	'fields' 	=> array (
 	##################################
 	# Begin Datatable fields
@@ -216,6 +226,7 @@
 	'title' 	=> "SSL",
 	'width' 	=> 100,
 	'template' 	=> "templates/web_domain_ssl.htm",
+	'readonly'	=> false,
 	'fields' 	=> array (
 	##################################
 	# Begin Datatable fields
@@ -302,6 +313,7 @@
 	'title' 	=> "Options",
 	'width' 	=> 100,
 	'template' 	=> "templates/web_domain_advanced.htm",
+	'readonly'	=> false,
 	'fields' 	=> array (
 	##################################
 	# Begin Datatable fields

--
Gitblit v1.9.1