From 76a1008a5c4d6bacc000eec590006ea57c7dbb4f Mon Sep 17 00:00:00 2001 From: tbrehm Date: Sun, 20 May 2007 18:00:24 +0000 Subject: [PATCH] updated client form --- interface/lib/classes/tform.inc.php | 7 +- interface/lib/classes/validate_client.inc.php | 66 +++++++++++++ interface/web/client/client_edit.php | 64 ++++++++++++- interface/web/client/form/client.tform.php | 9 +- interface/web/client/lib/lang/en_client.lng | 84 ++++++++--------- .../client/templates/client_edit_address.htm | 92 +++++++++++++++++++ .../client/templates/client_edit_limits.htm | 44 +++++++++ 7 files changed, 319 insertions(+), 47 deletions(-) create mode 100644 interface/lib/classes/validate_client.inc.php create mode 100644 interface/web/client/templates/client_edit_address.htm create mode 100644 interface/web/client/templates/client_edit_limits.htm diff --git a/interface/lib/classes/tform.inc.php b/interface/lib/classes/tform.inc.php index 0fed37fc4..d8c58a3ce 100644 --- a/interface/lib/classes/tform.inc.php +++ b/interface/lib/classes/tform.inc.php @@ -104,10 +104,11 @@ class tform { var $errorMessage = ''; var $dateformat = "d.m.Y"; - var $formDef; + var $formDef; var $wordbook; var $module; var $primary_id; + var $diffrec = array(); /** * Laden der Tabellendefinition @@ -611,7 +612,7 @@ class tform { $validator_class = $validator['class']; $validator_function = $validator['function']; $app->uses($validator_class); - $this->errorMessage .= $app->$validator_class->$validator_function($validator); + $this->errorMessage .= $app->$validator_class->$validator_function($field_name, $field_value, $validator); } else { $this->errorMessage .= "Custom validator class or function is empty
\r\n"; } @@ -852,6 +853,8 @@ class tform { // Insert the server_id, if the record has a server_id $server_id = ($record_old["server_id"] > 0)?$record_old["server_id"]:0; + + $this->diffrec = $diffrec; if(count($diffrec) > 0) { diff --git a/interface/lib/classes/validate_client.inc.php b/interface/lib/classes/validate_client.inc.php new file mode 100644 index 000000000..a7b7ae8b0 --- /dev/null +++ b/interface/lib/classes/validate_client.inc.php @@ -0,0 +1,66 @@ +tform->action == 'NEW') { + $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM sys_user WHERE username = '".$app->db->quote($field_value)."'"); + if($num_rec["number"] > 0) { + $errmsg = $validator['errmsg']; + if(isset($this->wordbook[$errmsg])) { + return $app->tform->wordbook[$errmsg]."
\r\n"; + } else { + return $errmsg."
\r\n"; + } + } + } else { + $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM sys_user WHERE username = '".$app->db->quote($field_value)."' AND client_id != ".$app->tform->primary_id); + if($num_rec["number"] > 0) { + $errmsg = $validator['errmsg']; + if(isset($app->tform->wordbook[$errmsg])) { + return $app->tform->wordbook[$errmsg]."
\r\n"; + } else { + return $errmsg."
\r\n"; + } + } + } + } + + + + +} \ No newline at end of file diff --git a/interface/web/client/client_edit.php b/interface/web/client/client_edit.php index d66d6121d..68b8d3a0a 100644 --- a/interface/web/client/client_edit.php +++ b/interface/web/client/client_edit.php @@ -49,8 +49,68 @@ if(!stristr($_SESSION["s"]["user"]["modules"],$_SESSION["s"]["module"]["name"])) // Loading classes $app->uses('tpl,tform,tform_actions'); +$app->load('tform_actions'); -// let tform_actions handle the page -$app->tform_actions->onLoad(); +class page_action extends tform_actions { + + /* + This function is called automatically right after + the data was successful inserted in the database. + */ + function onAfterInsert() { + global $app; + // Create the group for the client + $sql = "INSERT INTO sys_group (name,description,client_id) VALUES ('".addslashes($this->dataRecord["username"])."','',".$this->id.")"; + $app->db->query($sql); + $groupid = $app->db->insertID(); + + $username = addslashes($this->dataRecord["username"]); + $password = addslashes($this->dataRecord["password"]); + $modules = 'mail'; + $startmodule = 'mail'; + $usertheme = addslashes($this->dataRecord["usertheme"]); + $type = 'user'; + $active = 1; + $language = addslashes($this->dataRecord["language"]); + + // Create the controlpaneluser for the client + $sql = "INSERT INTO sys_user (username,passwort,modules,startmodule,app_theme,typ,active,language,groups,default_group,client_id) + VALUES ('$username',md5('$password'),'$modules','$startmodule','$usertheme','$type','$active','$language',$groupid,$groupid,".$this->id.")"; + $app->db->query($sql); + } + + + /* + This function is called automatically right after + the data was successful updated in the database. + */ + function onAfterUpdate() { + global $app; + + // username changed + if(isset($app->tform->diffrec['username'])) { + $username = addslashes($this->dataRecord["username"]); + $client_id = $this->id; + $sql = "UPDATE sys_user SET username = '$username' WHERE client_id = $client_id"; + $app->db->query($sql); + $sql = "UPDATE sys_group SET name = '$username' WHERE client_id = $client_id"; + $app->db->query($sql); + } + + // password changed + if($this->dataRecord["password"] != '') { + $password = addslashes($this->dataRecord["password"]); + $sql = "UPDATE sys_user SET passwort = md5('$password') WHERE client_id = $client_id"; + } + + + + } + + +} + +$page = new page_action; +$page->onLoad(); ?> \ No newline at end of file diff --git a/interface/web/client/form/client.tform.php b/interface/web/client/form/client.tform.php index 491d01054..d783d2ff6 100644 --- a/interface/web/client/form/client.tform.php +++ b/interface/web/client/form/client.tform.php @@ -86,6 +86,13 @@ $form["tabs"]['address'] = array ( 'username' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'username_error_empty'), + 1 => array ( 'type' => 'CUSTOM', + 'class' => 'validate_client', + 'function' => 'username_unique', + 'errmsg'=> 'username_error_unique'), + ), 'default' => '', 'value' => '', 'separator' => '', @@ -120,7 +127,7 @@ $form["tabs"]['address'] = array ( 'datatype' => 'VARCHAR', 'formtype' => 'SELECT', 'default' => 'default', - 'value' => array('default' => 'default','grey' => 'grey'), + 'value' => array('default' => 'default'), 'separator' => '', 'width' => '30', 'maxlength' => '255', diff --git a/interface/web/client/lib/lang/en_client.lng b/interface/web/client/lib/lang/en_client.lng index 0accf4bd9..a4717854c 100644 --- a/interface/web/client/lib/lang/en_client.lng +++ b/interface/web/client/lib/lang/en_client.lng @@ -1,43 +1,43 @@ - \ No newline at end of file diff --git a/interface/web/client/templates/client_edit_address.htm b/interface/web/client/templates/client_edit_address.htm new file mode 100644 index 000000000..499e230b9 --- /dev/null +++ b/interface/web/client/templates/client_edit_address.htm @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{tmpl_var name='company_name_txt'}:
{tmpl_var name='contact_name_txt'}:
{tmpl_var name='username_txt'}:
{tmpl_var name='password_txt'}:
{tmpl_var name='language_txt'}: + +
{tmpl_var name='usertheme_txt'}: + +
{tmpl_var name='street_txt'}:
{tmpl_var name='zip_txt'}:
{tmpl_var name='city_txt'}:
{tmpl_var name='state_txt'}:
{tmpl_var name='country_txt'}:
{tmpl_var name='telephone_txt'}:
{tmpl_var name='mobile_txt'}:
{tmpl_var name='fax_txt'}:
{tmpl_var name='email_txt'}:
{tmpl_var name='internet_txt'}:
{tmpl_var name='icq_txt'}:
{tmpl_var name='notes_txt'}:
  
 
  +
+
+ \ No newline at end of file diff --git a/interface/web/client/templates/client_edit_limits.htm b/interface/web/client/templates/client_edit_limits.htm new file mode 100644 index 000000000..11ded7394 --- /dev/null +++ b/interface/web/client/templates/client_edit_limits.htm @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{tmpl_var name='limit_maildomain_txt'}:
{tmpl_var name='limit_mailbox_txt'}:
{tmpl_var name='limit_mailalias_txt'}:
{tmpl_var name='limit_mailcatchall_txt'}:
{tmpl_var name='limit_mailrouting_txt'}:
{tmpl_var name='limit_mailfilter_txt'}:
{tmpl_var name='limit_fetchmail_txt'}:
{tmpl_var name='limit_mailquota_txt'}: MB
  
 
  +
+
+ \ No newline at end of file -- GitLab