From 4c28d9c34f5f3e5ccbbed6dbb0ba08bc5235b53b Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Thu, 10 May 2012 12:24:12 -0400
Subject: [PATCH] - Added global search (FS#2210, FS#2146).

---
 interface/web/client/form/client.tform.php |  402 +++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 357 insertions(+), 45 deletions(-)

diff --git a/interface/web/client/form/client.tform.php b/interface/web/client/form/client.tform.php
index 11def8e..3fca605 100644
--- a/interface/web/client/form/client.tform.php
+++ b/interface/web/client/form/client.tform.php
@@ -29,6 +29,11 @@
 	Hint:
 	The ID field of the database table is not part of the datafield definition.
 	The ID field must be always auto incement (int or bigint).
+	
+	Search:
+	- searchable = 1 or searchable = 2 include the field in the search
+	- searchable = 1: this field will be the title of the search result
+	- searchable = 2: this field will be included in the description of the search result
 
 
 */
@@ -50,6 +55,29 @@
 $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
 
+//* Languages
+$language_list = array();
+$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
+while ($file = @readdir ($handle)) {
+    if ($file != '.' && $file != '..') {
+        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
+			$tmp = substr($file, 0, 2);
+			$language_list[$tmp] = $tmp;
+        }
+	}
+}
+
+//* Load themes
+$themes_list = array();
+$handle = @opendir(ISPC_THEMES_PATH); 
+while ($file = @readdir ($handle)) { 
+    if (substr($file, 0, 1) != '.') {
+        if(@is_dir(ISPC_THEMES_PATH."/$file")) {
+			$themes_list[$file] = $file;
+        }
+	}
+}
+
 $form["tabs"]['address'] = array (
 	'title' 	=> "Address",
 	'width' 	=> 100,
@@ -67,7 +95,8 @@
 			'width'		=> '30',
 			'maxlength'	=> '255',
 			'rows'		=> '',
-			'cols'		=> ''
+			'cols'		=> '',
+			'searchable' => 2
 		),
 		'contact_name' => array (
 			'datatype'	=> 'VARCHAR',
@@ -81,7 +110,20 @@
 			'width'		=> '30',
 			'maxlength'	=> '255',
 			'rows'		=> '',
-			'cols'		=> ''
+			'cols'		=> '',
+			'searchable' => 1
+		),
+		'customer_no' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255',
+			'rows'		=> '',
+			'cols'		=> '',
+			'searchable' => 2
 		),
 		'username' => array (
 			'datatype'	=> 'VARCHAR',
@@ -92,6 +134,9 @@
 														'class' => 'validate_client',
 														'function' => 'username_unique',
 														'errmsg'=> 'username_error_unique'),
+										2 => array (	'type'	=> 'REGEX',
+														'regex' => '/^[\w\.\-\_]{0,64}$/',
+														'errmsg'=> 'username_error_regex'),
 										),
 			'default'	=> '',
 			'value'		=> '',
@@ -99,12 +144,13 @@
 			'width'		=> '30',
 			'maxlength'	=> '255',
 			'rows'		=> '',
-			'cols'		=> ''
+			'cols'		=> '',
+			'searchable' => 2
 		),
 		'password' => array (
 			'datatype'	=> 'VARCHAR',
 			'formtype'	=> 'PASSWORD',
-			'encryption'=> 'MD5',
+			'encryption'=> 'CRYPT',
 			'default'	=> '',
 			'value'		=> '',
 			'separator'	=> '',
@@ -117,7 +163,7 @@
 			'datatype'	=> 'VARCHAR',
 			'formtype'	=> 'SELECT',
 			'default'	=> $conf["language"],
-			'value'		=> array('en' => 'en'),
+			'value'		=> $language_list,
 			'separator'	=> '',
 			'width'		=> '30',
 			'maxlength'	=> '255',
@@ -127,8 +173,8 @@
 		'usertheme' => array (
 			'datatype'	=> 'VARCHAR',
 			'formtype'	=> 'SELECT',
-			'default'	=> 'default',
-			'value'		=> array('default' => 'default'),
+			'default'	=> $conf["theme"],
+			'value'		=> $themes_list,
 			'separator'	=> '',
 			'width'		=> '30',
 			'maxlength'	=> '255',
@@ -144,7 +190,8 @@
 			'width'		=> '30',
 			'maxlength'	=> '255',
 			'rows'		=> '',
-			'cols'		=> ''
+			'cols'		=> '',
+			'searchable' => 2
 		),
 		'zip' => array (
 			'datatype'	=> 'VARCHAR',
@@ -155,7 +202,8 @@
 			'width'		=> '10',
 			'maxlength'	=> '255',
 			'rows'		=> '',
-			'cols'		=> ''
+			'cols'		=> '',
+			'searchable' => 2
 		),
 		'city' => array (
 			'datatype'	=> 'VARCHAR',
@@ -166,7 +214,8 @@
 			'width'		=> '30',
 			'maxlength'	=> '255',
 			'rows'		=> '',
-			'cols'		=> ''
+			'cols'		=> '',
+			'searchable' => 2
 		),
 		'state' => array (
 			'datatype'	=> 'VARCHAR',
@@ -177,18 +226,20 @@
 			'width'		=> '30',
 			'maxlength'	=> '255',
 			'rows'		=> '',
-			'cols'		=> ''
+			'cols'		=> '',
+			'searchable' => 2
 		),
 		'country' => array (
 			'datatype'	=> 'VARCHAR',
-			'formtype'	=> 'TEXT',
-			'default'	=> '',
-			'value'		=> '',
-			'separator'	=> '',
-			'width'		=> '30',
-			'maxlength'	=> '255',
-			'rows'		=> '',
-			'cols'		=> ''
+
+			'formtype'	=> 'SELECT',
+			'default'	=> (isset($conf['language']) ? strtoupper($conf['language']) : ''),
+			'datasource'	=> array ( 	'type'	=> 'SQL',
+										'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name',
+										'keyfield'=> 'iso',
+										'valuefield'=> 'printable_name'
+									 ),
+			'value'		=> ''
 		),
 		'telephone' => array (
 			'datatype'	=> 'VARCHAR',
@@ -199,7 +250,8 @@
 			'width'		=> '30',
 			'maxlength'	=> '255',
 			'rows'		=> '',
-			'cols'		=> ''
+			'cols'		=> '',
+			'searchable' => 2
 		),
 		'mobile' => array (
 			'datatype'	=> 'VARCHAR',
@@ -210,7 +262,8 @@
 			'width'		=> '30',
 			'maxlength'	=> '255',
 			'rows'		=> '',
-			'cols'		=> ''
+			'cols'		=> '',
+			'searchable' => 2
 		),
 		'fax' => array (
 			'datatype'	=> 'VARCHAR',
@@ -221,7 +274,8 @@
 			'width'		=> '30',
 			'maxlength'	=> '255',
 			'rows'		=> '',
-			'cols'		=> ''
+			'cols'		=> '',
+			'searchable' => 2
 		),
 		'email' => array (
 			'datatype'	=> 'VARCHAR',
@@ -232,7 +286,8 @@
 			'width'		=> '30',
 			'maxlength'	=> '255',
 			'rows'		=> '',
-			'cols'		=> ''
+			'cols'		=> '',
+			'searchable' => 2
 		),
 		'internet' => array (
 			'datatype'	=> 'VARCHAR',
@@ -243,9 +298,87 @@
 			'width'		=> '30',
 			'maxlength'	=> '255',
 			'rows'		=> '',
-			'cols'		=> ''
+			'cols'		=> '',
+			'searchable' => 2
 		),
 		'icq' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'vat_id' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'company_id' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '20',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'bank_account_number' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'bank_code' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'bank_name' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'bank_account_iban' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+			'default'	=> '',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '30',
+			'maxlength'	=> '255',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'bank_account_swift' => array (
 			'datatype'	=> 'VARCHAR',
 			'formtype'	=> 'TEXT',
 			'default'	=> '',
@@ -281,16 +414,30 @@
 	##################################
 	# Begin Datatable fields
 	##################################
+		'template_master' => array (
+			'datatype'	=> 'INTEGER',
+			'formtype'	=> 'SELECT',
+			'default'	=> '1',
+			'datasource'	=> array ( 	'type'	=> 'CUSTOM',
+										'class'=> 'custom_datasource',
+										'function'=> 'master_templates'
+									 ),
+			'value'		=> ''
+		),
+		'template_additional' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'TEXT',
+		),
 		'default_mailserver' => array (
 			'datatype'	=> 'INTEGER',
 			'formtype'	=> 'SELECT',
 			'default'	=> '1',
-			'datasource'	=> array ( 	'type'	=> 'SQL',
-										'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND {AUTHSQL} ORDER BY server_name',
-										'keyfield'=> 'server_id',
-										'valuefield'=> 'server_name'
+			'datasource'	=> array ( 	'type'	=> 'CUSTOM',
+										'class'=> 'custom_datasource',
+										'function'=> 'client_servers'
 									 ),
-			'value'		=> ''
+			'value'		=> '',
+			'name'		=> 'default_mailserver'
 		),
 		'limit_maildomain' => array (
 			'datatype'	=> 'INTEGER',
@@ -325,6 +472,34 @@
 			'formtype'	=> 'TEXT',
 			'validators'	=> array ( 	0 => array (	'type'	=> 'ISINT',
 														'errmsg'=> 'limit_mailalias_error_notint'),
+									),
+			'default'	=> '-1',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '10',
+			'maxlength'	=> '10',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'limit_mailaliasdomain' => array (
+			'datatype'	=> 'INTEGER',
+			'formtype'	=> 'TEXT',
+			'validators'	=> array ( 	0 => array (	'type'	=> 'ISINT',
+														'errmsg'=> 'limit_mailaliasdomain_error_notint'),
+									),
+			'default'	=> '-1',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '10',
+			'maxlength'	=> '10',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'limit_mailmailinglist' => array (
+			'datatype'	=> 'INTEGER',
+			'formtype'	=> 'TEXT',
+			'validators'	=> array ( 	0 => array (	'type'	=> 'ISINT',
+														'errmsg'=> 'limit_mailmailinglist_error_notint'),
 									),
 			'default'	=> '-1',
 			'value'		=> '',
@@ -464,12 +639,12 @@
 			'datatype'	=> 'INTEGER',
 			'formtype'	=> 'SELECT',
 			'default'	=> '1',
-			'datasource'	=> array ( 	'type'	=> 'SQL',
-										'querystring' => 'SELECT server_id,server_name FROM server WHERE web_server = 1 AND {AUTHSQL} ORDER BY server_name',
-										'keyfield'=> 'server_id',
-										'valuefield'=> 'server_name'
+			'datasource'	=> array ( 	'type'	=> 'CUSTOM',
+										'class'=> 'custom_datasource',
+										'function'=> 'client_servers'
 									 ),
-			'value'		=> ''
+			'value'		=> '',
+			'name'		=> 'default_webserver'
 		),
 		'limit_web_domain' => array (
 			'datatype'	=> 'INTEGER',
@@ -484,6 +659,31 @@
 			'maxlength'	=> '10',
 			'rows'		=> '',
 			'cols'		=> ''
+		),
+		'limit_web_quota' => array (
+			'datatype'	=> 'INTEGER',
+			'formtype'	=> 'TEXT',
+			'validators'	=> array ( 	0 => array (	'type'	=> 'ISINT',
+														'errmsg'=> 'limit_web_quota_error_notint'),
+									),
+			'default'	=> '-1',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '10',
+			'maxlength'	=> '10',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'web_php_options' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'CHECKBOXARRAY',
+			'validators'	=> array ( 	0 => array (	'type'	=> 'NOTEMPTY',
+														'errmsg'=> 'web_php_options_notempty'),
+									),
+			'default'	=> '',
+			'separator' => ',',
+			'valuelimit' => 'client:web_php_options',
+			'value'		=> array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP', 'php-fpm' => 'PHP-FPM')
 		),
 		'limit_web_aliasdomain' => array (
 			'datatype'	=> 'INTEGER',
@@ -541,16 +741,41 @@
 			'rows'		=> '',
 			'cols'		=> ''
 		),
+		'ssh_chroot' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'CHECKBOXARRAY',
+			'validators'	=> array ( 	0 => array (	'type'	=> 'NOTEMPTY',
+														'errmsg'=> 'ssh_chroot_notempty'),
+									),
+			'default'	=> '',
+			'separator' => ',',
+			'valuelimit' => 'client:ssh_chroot',
+			'value'		=> array('no' => 'None', 'jailkit' => 'Jailkit')
+		),
+		'limit_webdav_user' => array (
+			'datatype'	=> 'INTEGER',
+			'formtype'	=> 'TEXT',
+			'validators'	=> array ( 	0 => array (	'type'	=> 'ISINT',
+														'errmsg'=> 'limit_webdav_user_error_notint'),
+									),
+			'default'	=> '-1',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '10',
+			'maxlength'	=> '10',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
 		'default_dnsserver' => array (
 			'datatype'	=> 'INTEGER',
 			'formtype'	=> 'SELECT',
 			'default'	=> '1',
-			'datasource'	=> array ( 	'type'	=> 'SQL',
-										'querystring' => 'SELECT server_id,server_name FROM server WHERE dns_server = 1 AND {AUTHSQL} ORDER BY server_name',
-										'keyfield'=> 'server_id',
-										'valuefield'=> 'server_name'
+			'datasource'	=> array ( 	'type'	=> 'CUSTOM',
+										'class'=> 'custom_datasource',
+										'function'=> 'client_servers'
 									 ),
-			'value'		=> ''
+			'value'		=> '',
+			'name'		=> 'default_dnsserver'
 		),
 		'limit_dns_zone' => array (
 			'datatype'	=> 'INTEGER',
@@ -566,6 +791,20 @@
 			'rows'		=> '',
 			'cols'		=> ''
 		),
+                'limit_dns_slave_zone' => array (
+                        'datatype'      => 'INTEGER',
+                        'formtype'      => 'TEXT',
+                        'validators'    => array (      0 => array (    'type'  => 'ISINT',
+                                                                                                                'errmsg'=> 'limit_dns_slave_zone_error_notint'),
+                                                                        ),
+                        'default'       => '-1',
+                        'value'         => '',
+                        'separator'     => '',
+                        'width'         => '10',
+                        'maxlength'     => '10',
+                        'rows'          => '',
+                        'cols'          => ''
+                ),
 		'limit_dns_record' => array (
 			'datatype'	=> 'INTEGER',
 			'formtype'	=> 'TEXT',
@@ -598,12 +837,12 @@
 			'datatype'	=> 'INTEGER',
 			'formtype'	=> 'SELECT',
 			'default'	=> '1',
-			'datasource'	=> array ( 	'type'	=> 'SQL',
-										'querystring' => 'SELECT server_id,server_name FROM server WHERE db_server = 1 AND {AUTHSQL} ORDER BY server_name',
-										'keyfield'=> 'server_id',
-										'valuefield'=> 'server_name'
+			'datasource'	=> array ( 	'type'	=> 'CUSTOM',
+										'class'=> 'custom_datasource',
+										'function'=> 'client_servers'
 									 ),
-			'value'		=> ''
+			'value'		=> '',
+			'name'		=> 'default_dbserver'
 		),
 		'limit_database' => array (
 			'datatype'	=> 'INTEGER',
@@ -618,6 +857,79 @@
 			'maxlength'	=> '10',
 			'rows'		=> '',
 			'cols'		=> ''
+		),
+        'limit_cron' => array (
+            'datatype'  => 'INTEGER',
+            'formtype'  => 'TEXT',
+            'validators'    => array (  0 => array (    'type'  => 'ISINT',
+                                                        'errmsg'=> 'limit_cron_error_notint'),
+                                    ),
+            'default'   => '0',
+            'value'     => '',
+            'separator' => '',
+            'width'     => '10',
+            'maxlength' => '10',
+            'rows'      => '',
+            'cols'      => ''
+        ),
+        'limit_cron_type' => array (
+            'datatype'  => 'VARCHAR',
+            'formtype'  => 'SELECT',
+            'default'   => '',
+            'value'     => array('full' => 'Full Cron','chrooted' => 'Chrooted Cron','url' => 'URL Cron')
+        ),
+        'limit_cron_frequency' => array (
+            'datatype'  => 'INTEGER',
+            'formtype'  => 'TEXT',
+            'validators'    => array (  0 => array (    'type'  => 'ISINT',
+                                                        'errmsg'=> 'limit_cron_error_frequency'),
+                                    ),
+            'default'   => '-1',
+            'value'     => '',
+            'separator' => '',
+            'width'     => '10',
+            'maxlength' => '10',
+            'rows'      => '',
+            'cols'      => ''
+        ),
+		'limit_traffic_quota' => array (
+			'datatype'	=> 'INTEGER',
+			'formtype'	=> 'TEXT',
+			'validators'	=> array ( 	0 => array (	'type'	=> 'ISINT',
+														'errmsg'=> 'limit_traffic_quota_error_notint'),
+									),
+			'default'	=> '-1',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '10',
+			'maxlength'	=> '10',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'limit_openvz_vm' => array (
+			'datatype'	=> 'INTEGER',
+			'formtype'	=> 'TEXT',
+			'validators'	=> array ( 	0 => array (	'type'	=> 'ISINT',
+														'errmsg'=> 'limit_openvz_vm_error_notint'),
+									),
+			'default'	=> '0',
+			'value'		=> '',
+			'separator'	=> '',
+			'width'		=> '10',
+			'maxlength'	=> '10',
+			'rows'		=> '',
+			'cols'		=> ''
+		),
+		'limit_openvz_vm_template_id' => array (
+			'datatype'	=> 'INTEGER',
+			'formtype'	=> 'SELECT',
+			'default'	=> '',
+			'datasource'	=> array ( 	'type'	=> 'SQL',
+										'querystring' => 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name',
+										'keyfield'=> 'template_id',
+										'valuefield'=> 'template_name'
+									 ),
+			'value'		=> array(0 => ' ')
 		),
 	##################################
 	# END Datatable fields
@@ -649,4 +961,4 @@
 */
 
 
-?>
\ No newline at end of file
+?>

--
Gitblit v1.9.1