diff --git a/interface/lib/classes/tform.inc.php b/interface/lib/classes/tform.inc.php index 0fed37fc4176821c0af867867954fb9bf984b394..d8c58a3ceb66e3e50930a8b35a3b40bf8328e391 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 0000000000000000000000000000000000000000..a7b7ae8b065076d8e32fd0708767d2cf849d4fa3 --- /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 d66d6121d581e60e2094fb9f74bbac77c0ad3367..68b8d3a0a5d212e5735d3fb18ccdae350c3afa0c 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 491d01054d9634c481f848054479f9810ec93857..d783d2ff6869145a235cece95322823b6533cfe3 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 0accf4bd9360dbbd0325646ec4817133f06cf010..a4717854cf23a8a9e88f2787f2fb651217d035de 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 0000000000000000000000000000000000000000..499e230b99f975e879a9cac808c7f798034d4681 --- /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 0000000000000000000000000000000000000000..11ded7394d1ac369879c198ea6655df45e201986 --- /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