From 257cd788f8aebaa3703f67e9a367947042d669ae Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Thu, 16 Jul 2009 06:40:29 -0400
Subject: [PATCH] Fixed: FS#812 - Mails are missing for user if the username conatins uppercase characters.
---
interface/lib/classes/tform.inc.php | 116 +++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 90 insertions(+), 26 deletions(-)
diff --git a/interface/lib/classes/tform.inc.php b/interface/lib/classes/tform.inc.php
index 5a53a4f..ec37de2 100644
--- a/interface/lib/classes/tform.inc.php
+++ b/interface/lib/classes/tform.inc.php
@@ -160,11 +160,11 @@
foreach($this->formDef['tabs'][$tab]['fields'] as $key => $field) {
switch ($field['datatype']) {
case 'VARCHAR':
- $new_record[$key] = stripslashes($record[$key]);
+ $new_record[$key] = $record[$key];
break;
case 'TEXT':
- $new_record[$key] = stripslashes($record[$key]);
+ $new_record[$key] = $record[$key];
break;
case 'DATE':
@@ -186,7 +186,7 @@
break;
default:
- $new_record[$key] = stripslashes($record[$key]);
+ $new_record[$key] = $record[$key];
}
}
@@ -364,7 +364,7 @@
case 'CHECKBOX':
$checked = ($val == $field['value'][1])?' CHECKED':'';
- $new_record[$key] = "<input name=\"".$key."\" type=\"checkbox\" value=\"".$field['value'][1]."\" $checked>\r\n";
+ $new_record[$key] = "<input name=\"".$key."\" id=\"".$key."\" value=\"".$field['value'][1]."\" type=\"checkbox\" $checked />\r\n";
break;
case 'CHECKBOXARRAY':
@@ -381,10 +381,8 @@
foreach($vals as $tvl) {
if(trim($tvl) == trim($k)) $checked = ' CHECKED';
}
- $out .= "<span class=\"wf_oneChoice\">\r\n
- <input type=\"checkbox\" value=\"$k\" id=\"".$key."[]\" name=\"".$key."[]\" $checked>\r\n
- <label for=\"".$key."[]\" id=\"".$key."[]-L\" class=\"wf_postField\">$v</label>\r\n
- </span>\r\n";
+ // $out .= "<label for=\"".$key."[]\" class=\"inlineLabel\"><input name=\"".$key."[]\" id=\"".$key."[]\" value=\"$k\" type=\"checkbox\" $checked /> $v</label>\r\n";
+ $out .= "<input name=\"".$key."[]\" id=\"".$key."[]\" value=\"$k\" type=\"checkbox\" $checked /> $v \r\n";
}
}
$new_record[$key] = $out;
@@ -397,10 +395,8 @@
$out = '';
foreach($field['value'] as $k => $v) {
$checked = ($k == $val)?' CHECKED':'';
- $out .= "<span class=\"wf_oneChoice\">\r\n
- <input type=\"radio\" value=\"$k\" id=\"".$key."[]\" name=\"".$key."[]\" $checked>\r\n
- <label for=\"".$key."[]\" id=\"".$key."[]-L\" class=\"wf_postField\">$v</label>\r\n
- </span><br />\r\n";
+ //$out .= "<label for=\"".$key."[]\" class=\"inlineLabel\"><input name=\"".$key."[]\" id=\"".$key."[]\" value=\"$k\" type=\"radio\" $checked/> $v</label>\r\n";
+ $out .= "<input name=\"".$key."[]\" id=\"".$key."[]\" value=\"$k\" type=\"radio\" $checked/> $v\r\n";
}
}
$new_record[$key] = $out;
@@ -460,7 +456,7 @@
case 'CHECKBOX':
// $checked = (empty($field["default"]))?'':' CHECKED';
$checked = ($field["default"] == $field['value'][1])?' CHECKED':'';
- $new_record[$key] = "<input name=\"".$key."\" type=\"checkbox\" value=\"".$field['value'][1]."\" $checked>\r\n";
+ $new_record[$key] = "<input name=\"".$key."\" id=\"".$key."\" value=\"".$field['value'][1]."\" type=\"checkbox\" $checked />\r\n";
break;
case 'CHECKBOXARRAY':
@@ -477,10 +473,8 @@
foreach($vals as $tvl) {
if(trim($tvl) == trim($k)) $checked = ' CHECKED';
}
- $out .= "<span class=\"wf_oneChoice\">\r\n
- <input type=\"checkbox\" value=\"$k\" id=\"".$key."[]\" name=\"".$key."[]\" $checked>\r\n
- <label for=\"".$key."[]\" id=\"".$key."[]-L\" class=\"wf_postField\">$v</label>\r\n
- </span>\r\n";
+ // $out .= "<label for=\"".$key."[]\" class=\"inlineLabel\"><input name=\"".$key."[]\" id=\"".$key."[]\" value=\"$k\" type=\"checkbox\" $checked /> $v</label>\r\n";
+ $out .= "<input name=\"".$key."[]\" id=\"".$key."[]\" value=\"$k\" type=\"checkbox\" $checked /> $v \r\n";
}
}
$new_record[$key] = $out;
@@ -493,10 +487,8 @@
$out = '';
foreach($field['value'] as $k => $v) {
$checked = ($k == $field["default"])?' CHECKED':'';
- $out .= "<span class=\"wf_oneChoice\">\r\n
- <input type=\"radio\" value=\"$k\" id=\"".$key."[]\" name=\"".$key."[]\" $checked>\r\n
- <label for=\"".$key."[]\" id=\"".$key."[]-L\" class=\"wf_postField\">$v</label>\r\n
- </span><br />\r\n";
+ //$out .= "<label for=\"".$key."[]\" class=\"inlineLabel\"><input name=\"".$key."[]\" id=\"".$key."[]\" value=\"$k\" type=\"radio\" $checked/> $v</label>\r\n";
+ $out .= "<input name=\"".$key."[]\" id=\"".$key."[]\" value=\"$k\" type=\"radio\" $checked/> $v\r\n";
}
}
$new_record[$key] = $out;
@@ -750,10 +742,10 @@
$sql_insert_val = '';
$sql_update = '';
- if(!is_array($this->formDef)) $app->error("Keine Formulardefinition vorhanden.");
- if(!is_array($this->formDef['tabs'][$tab])) $app->error("Tab ist leer oder existiert nicht (TAB: $tab).");
+ if(!is_array($this->formDef)) $app->error("Form definition not found.");
+ if(!is_array($this->formDef['tabs'][$tab])) $app->error("The tab is empty or does not exist (TAB: $tab).");
- // gehe durch alle Felder des Tabs
+ // go trough all fields of the tab
if(is_array($record)) {
foreach($this->formDef['tabs'][$tab]['fields'] as $key => $field) {
// Wenn es kein leeres Passwortfeld ist
@@ -877,6 +869,8 @@
$app->error("Primary ID fehlt!");
}
}
+ //* return a empty string if there is nothing to update
+ if(trim($sql_update) == '') $sql = '';
}
return $sql;
@@ -1121,8 +1115,21 @@
return $_SESSION["s"]["form"]["tab"];
}
- function isReadonlyTab($tab) {
- if(isset($this->formDef['tabs'][$tab]['readonly']) && $this->formDef['tabs'][$tab]['readonly'] == true) {
+ function isReadonlyTab($tab, $primary_id) {
+ global $app, $conf;
+
+ // Add backticks for incomplete table names.
+ if(stristr($this->formDef['db_table'],'.')) {
+ $escape = '';
+ } else {
+ $escape = '`';
+ }
+
+ $sql = "SELECT sys_userid FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id;
+ $record = $app->db->queryOneRecord($sql);
+
+ // return true if the readonly flag of the form is set and the current loggedin user is not the owner of the record.
+ if(isset($this->formDef['tabs'][$tab]['readonly']) && $this->formDef['tabs'][$tab]['readonly'] == true && $record['sys_userid'] != $_SESSION["s"]["user"]["userid"]) {
return true;
} else {
return false;
@@ -1141,6 +1148,63 @@
}
}
+
+ function checkClientLimit($limit_name,$sql_where = '') {
+ global $app;
+
+ $check_passed = true;
+ $limit_name = $app->db->quote($limit_name);
+ if($limit_name == '') $app->error('Limit name missing in function checkClientLimit.');
+
+ // Get the limits of the client that is currently logged in
+ $client_group_id = $_SESSION["s"]["user"]["default_group"];
+ $client = $app->db->queryOneRecord("SELECT $limit_name as number, parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
+
+ // Check if the user may add another item
+ if($client["number"] >= 0) {
+ $sql = "SELECT count(".$this->formDef['db_table_idx'].") as number FROM ".$this->formDef['db_table']." WHERE ".$this->getAuthSQL('u');
+ if($sql_where != '') $sql .= ' and '.$sql_where;
+ $tmp = $app->db->queryOneRecord($sql);
+ if($tmp["number"] >= $client["number"]) $check_passed = false;
+ }
+
+ return $check_passed;
+ }
+
+ function checkResellerLimit($limit_name,$sql_where = '') {
+ global $app;
+
+ $check_passed = true;
+ $limit_name = $app->db->quote($limit_name);
+ if($limit_name == '') $app->error('Limit name missing in function checkClientLimit.');
+
+ // Get the limits of the client that is currently logged in
+ $client_group_id = $_SESSION["s"]["user"]["default_group"];
+ $client = $app->db->queryOneRecord("SELECT parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
+
+ //* If the client belongs to a reseller, we will check against the reseller Limit too
+ if($client['parent_client_id'] != 0) {
+
+ //* first we need to know the groups of this reseller
+ $tmp = $app->db->queryOneRecord("SELECT userid, groups FROM sys_user WHERE client_id = ".$client['parent_client_id']);
+ $reseller_groups = $tmp["groups"];
+ $reseller_userid = $tmp["userid"];
+
+ // Get the limits of the reseller of the logged in client
+ $client_group_id = $_SESSION["s"]["user"]["default_group"];
+ $reseller = $app->db->queryOneRecord("SELECT $limit_name as number FROM client WHERE client_id = ".$client['parent_client_id']);
+
+ // Check if the user may add another item
+ if($reseller["number"] >= 0) {
+ $sql = "SELECT count(".$this->formDef['db_table_idx'].") as number FROM ".$this->formDef['db_table']." WHERE (sys_groupid IN (".$reseller_groups.") or sys_userid = ".$reseller_userid.")";
+ if($sql_where != '') $sql .= ' and '.$sql_where;
+ $tmp = $app->db->queryOneRecord($sql);
+ if($tmp["number"] >= $reseller["number"]) $check_passed = false;
+ }
+ }
+
+ return $check_passed;
+ }
}
--
Gitblit v1.9.1