Skip to content

Commit 59118c7

Browse files
committed
- Added further tables to global search.
- Added translations to global search.
1 parent 86985d0 commit 59118c7

22 files changed

+187
-54
lines changed

interface/lib/app.inc.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,13 @@ public function tpl_defaults() {
246246
$this->tpl->setVar('cpuser', $_SESSION['s']['user']['username']);
247247
$this->tpl->setVar('logout_txt', $this->lng('logout_txt'));
248248
}
249+
250+
/* Global Search */
251+
$this->tpl->setVar('globalsearch_resultslimit_of_txt', $this->lng('globalsearch_resultslimit_of_txt'));
252+
$this->tpl->setVar('globalsearch_resultslimit_results_txt', $this->lng('globalsearch_resultslimit_results_txt'));
253+
$this->tpl->setVar('globalsearch_noresults_text_txt', $this->lng('globalsearch_noresults_text_txt'));
254+
$this->tpl->setVar('globalsearch_noresults_limit_txt', $this->lng('globalsearch_noresults_limit_txt'));
255+
$this->tpl->setVar('globalsearch_searchfield_watermark_txt', $this->lng('globalsearch_searchfield_watermark_txt'));
249256
}
250257

251258
} // end class

interface/lib/lang/de.lng

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,9 @@ $wb['datepicker_nextText'] = 'Vor';
7070
$wb['datepicker_prevText'] = 'Zurück';
7171
$wb['logout_txt'] = 'LOGOUT';
7272
$wb['submit_confirmation'] = 'Wollen Sie diese Aktion wirlich ausführen?';
73+
$wb['globalsearch_resultslimit_of_txt'] = "von";
74+
$wb['globalsearch_resultslimit_results_txt'] = "Treffern";
75+
$wb['globalsearch_noresults_text_txt'] = "Keine Treffer.";
76+
$wb['globalsearch_noresults_limit_txt'] = "0 Treffer";
77+
$wb['globalsearch_searchfield_watermark_txt'] = "Suche";
7378
?>

interface/lib/lang/en.lng

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,9 @@ $wb['monthnamesshort_dec'] = "Dec";
7171
$wb['datepicker_nextText'] = "Next";
7272
$wb['datepicker_prevText'] = "Prev";
7373
$wb['submit_confirmation'] = "Do you really want to perform this action?";
74+
$wb['globalsearch_resultslimit_of_txt'] = "of";
75+
$wb['globalsearch_resultslimit_results_txt'] = "results";
76+
$wb['globalsearch_noresults_text_txt'] = "No results.";
77+
$wb['globalsearch_noresults_limit_txt'] = "0 results";
78+
$wb['globalsearch_searchfield_watermark_txt'] = "Search";
7479
?>

interface/web/client/form/reseller.tform.php

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
Hint:
3030
The ID field of the database table is not part of the datafield definition.
3131
The ID field must be always auto incement (int or bigint).
32+
33+
Search:
34+
- searchable = 1 or searchable = 2 include the field in the search
35+
- searchable = 1: this field will be the title of the search result
36+
- searchable = 2: this field will be included in the description of the search result
3237
3338
3439
*/
@@ -90,7 +95,8 @@
9095
'width' => '30',
9196
'maxlength' => '255',
9297
'rows' => '',
93-
'cols' => ''
98+
'cols' => '',
99+
'searchable' => 2
94100
),
95101
'contact_name' => array (
96102
'datatype' => 'VARCHAR',
@@ -104,7 +110,8 @@
104110
'width' => '30',
105111
'maxlength' => '255',
106112
'rows' => '',
107-
'cols' => ''
113+
'cols' => '',
114+
'searchable' => 1
108115
),
109116
'customer_no' => array (
110117
'datatype' => 'VARCHAR',
@@ -115,7 +122,8 @@
115122
'width' => '30',
116123
'maxlength' => '255',
117124
'rows' => '',
118-
'cols' => ''
125+
'cols' => '',
126+
'searchable' => 2
119127
),
120128
'username' => array (
121129
'datatype' => 'VARCHAR',
@@ -140,7 +148,8 @@
140148
'width' => '30',
141149
'maxlength' => '255',
142150
'rows' => '',
143-
'cols' => ''
151+
'cols' => '',
152+
'searchable' => 2
144153
),
145154
'password' => array (
146155
'datatype' => 'VARCHAR',
@@ -185,7 +194,8 @@
185194
'width' => '30',
186195
'maxlength' => '255',
187196
'rows' => '',
188-
'cols' => ''
197+
'cols' => '',
198+
'searchable' => 2
189199
),
190200
'zip' => array (
191201
'datatype' => 'VARCHAR',
@@ -196,7 +206,8 @@
196206
'width' => '10',
197207
'maxlength' => '255',
198208
'rows' => '',
199-
'cols' => ''
209+
'cols' => '',
210+
'searchable' => 2
200211
),
201212
'city' => array (
202213
'datatype' => 'VARCHAR',
@@ -207,7 +218,8 @@
207218
'width' => '30',
208219
'maxlength' => '255',
209220
'rows' => '',
210-
'cols' => ''
221+
'cols' => '',
222+
'searchable' => 2
211223
),
212224
'state' => array (
213225
'datatype' => 'VARCHAR',
@@ -218,7 +230,8 @@
218230
'width' => '30',
219231
'maxlength' => '255',
220232
'rows' => '',
221-
'cols' => ''
233+
'cols' => '',
234+
'searchable' => 2
222235
),
223236
'country' => array (
224237
'datatype' => 'VARCHAR',
@@ -241,7 +254,8 @@
241254
'width' => '30',
242255
'maxlength' => '255',
243256
'rows' => '',
244-
'cols' => ''
257+
'cols' => '',
258+
'searchable' => 2
245259
),
246260
'mobile' => array (
247261
'datatype' => 'VARCHAR',
@@ -252,7 +266,8 @@
252266
'width' => '30',
253267
'maxlength' => '255',
254268
'rows' => '',
255-
'cols' => ''
269+
'cols' => '',
270+
'searchable' => 2
256271
),
257272
'fax' => array (
258273
'datatype' => 'VARCHAR',
@@ -263,7 +278,8 @@
263278
'width' => '30',
264279
'maxlength' => '255',
265280
'rows' => '',
266-
'cols' => ''
281+
'cols' => '',
282+
'searchable' => 2
267283
),
268284
'email' => array (
269285
'datatype' => 'VARCHAR',
@@ -274,7 +290,8 @@
274290
'width' => '30',
275291
'maxlength' => '255',
276292
'rows' => '',
277-
'cols' => ''
293+
'cols' => '',
294+
'searchable' => 2
278295
),
279296
'internet' => array (
280297
'datatype' => 'VARCHAR',
@@ -285,7 +302,8 @@
285302
'width' => '30',
286303
'maxlength' => '255',
287304
'rows' => '',
288-
'cols' => ''
305+
'cols' => '',
306+
'searchable' => 2
289307
),
290308
'icq' => array (
291309
'datatype' => 'VARCHAR',

interface/web/dashboard/ajax_get_json.php

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,22 @@
4646
$authsql = " AND ".$app->tform->getAuthSQL('r');
4747
$modules = explode(',', $_SESSION['s']['user']['modules']);
4848

49+
$result = array();
50+
4951
// clients
50-
$result_clients = _search('client', 'client');
52+
$result[] = _search('client', 'client', "AND limit_client = 0");
53+
54+
// resellers
55+
$result[] = _search('client', 'reseller', "AND limit_client != 0");
5156

5257
// web sites
53-
$result_webs = _search('sites', 'web_domain');
58+
$result[] = _search('sites', 'web_domain');
5459

5560
// FTP users
56-
$result_ftp_users = _search('sites', 'ftp_user');
61+
$result[] = _search('sites', 'ftp_user');
5762

5863
// shell users
59-
$result_shell_users = _search('sites', 'shell_user');
64+
$result[] = _search('sites', 'shell_user');
6065

6166
// databases
6267
/*
@@ -81,42 +86,60 @@
8186
}
8287
}
8388
*/
84-
$result_databases = _search('sites', 'database');
89+
$result[] = _search('sites', 'database');
8590

8691
// email domains
87-
$result_email_domains = _search('mail', 'mail_domain');
92+
$result[] = _search('mail', 'mail_domain');
93+
94+
// email alias domains
95+
$result[] = _search('mail', 'mail_aliasdomain', "AND type = 'aliasdomain'");
8896

8997
// email mailboxes
90-
$result_email_mailboxes = _search('mail', 'mail_user');
98+
$result[] = _search('mail', 'mail_user');
99+
100+
// email aliases
101+
$result[] = _search('mail', 'mail_alias', "AND type = 'alias'");
102+
103+
// email forwards
104+
$result[] = _search('mail', 'mail_forward', "AND type = 'forward'");
105+
106+
// email catchalls
107+
$result[] = _search('mail', 'mail_domain_catchall', "AND type = 'catchall'");
108+
109+
// email transports
110+
$result[] = _search('mail', 'mail_transport');
111+
112+
// mailinglists
113+
$result[] = _search('mail', 'mail_mailinglist');
114+
115+
// getmails
116+
$result[] = _search('mail', 'mail_get');
91117

92118
// dns zones
93-
$result_dns_zones = _search('dns', 'dns_soa');
119+
$result[] = _search('dns', 'dns_soa');
94120

95121
// secondary dns zones
96-
$result_secondary_dns_zones = _search('dns', 'dns_slave');
122+
$result[] = _search('dns', 'dns_slave');
97123

98124
// virtual machines
99-
$result_vms = _search('vm', 'openvz_vm');
125+
$result[] = _search('vm', 'openvz_vm');
100126

101127
// virtual machines os templates
102-
$result_vm_ostemplates = _search('vm', 'openvz_ostemplate');
128+
$result[] = _search('vm', 'openvz_ostemplate');
103129

104130
// virtual machines vm templates
105-
$result_vm_vmtemplates = _search('vm', 'openvz_template');
131+
$result[] = _search('vm', 'openvz_template');
106132

107133
// virtual machines ip addresses
108-
$result_vm_ip_addresses = _search('vm', 'openvz_ip');
134+
$result[] = _search('vm', 'openvz_ip');
109135

110-
$json = $app->functions->json_encode(array($result_clients, $result_webs, $result_ftp_users, $result_shell_users, $result_databases, $result_email_domains, $result_email_mailboxes, $result_dns_zones, $result_secondary_dns_zones, $result_vms, $result_vm_ostemplates, $result_vm_vmtemplates, $result_vm_ip_addresses));
136+
$json = $app->functions->json_encode($result);
111137
}
112138

113139
//}
114140

115-
function _search($module, $section){
141+
function _search($module, $section, $additional_sql = ''){
116142
global $app, $q, $authsql, $modules;
117-
//$q = $app->db->quote($_GET["q"]);
118-
//$authsql = " AND ".$app->tform->getAuthSQL('r');
119-
//$user_modules = explode(',', $_SESSION['s']['user']['modules']);
120143

121144
$result_array = array('cheader' => array(), 'cdata' => array());
122145
if(in_array($module, $modules)){
@@ -159,10 +182,13 @@ function _search($module, $section){
159182
// valid SQL query which returns an empty result set
160183
$where_clause = '1 = 0';
161184
}
185+
if($where_clause != '') $where_clause = '('.$where_clause.')';
186+
if($additional_sql != '') $where_clause .= ' '.$additional_sql.' ';
162187
$order_clause = '';
163188
if($order_by != '') $order_clause = ' ORDER BY '.$order_by;
164189

165-
$results = $app->db->queryAllRecords("SELECT * FROM ".$db_table." WHERE ".$where_clause.$authsql.$order_clause);
190+
$sql = "SELECT * FROM ".$db_table." WHERE ".$where_clause.$authsql.$order_clause." LIMIT 0,10";
191+
$results = $app->db->queryAllRecords($sql);
166192

167193
if(is_array($results) && !empty($results)){
168194
$lng_file = '../'.$module.'/lib/lang/'.$_SESSION['s']['language'].'_'.$section.'.lng';

interface/web/js/jquery.ispconfigsearch.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3636
cssPrefix: 'gs-',
3737
fillSearchField: false,
3838
fillSearchFieldWith: 'title',
39-
resultsText: '$ of % results',
39+
resultsLimit: '$ of % results',
4040
noResultsText: 'No results.',
41+
noResultsLimit: '0 results',
42+
searchFieldWatermark: 'Search',
4143
displayEmptyCategories: false,
4244
runJS: true
4345
};
@@ -48,6 +50,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4850
settings.resultBox = $(this).attr('id')+settings.resultBox;
4951

5052
$(this).attr('autocomplete', 'off');
53+
$(this).val(settings.searchFieldWatermark);
5154
$(this).wrap('<div class="'+settings.cssPrefix+'container" />');
5255
$(this).after('<ul id="'+settings.resultBox+'" class="'+settings.cssPrefix+'resultbox" style="display:none;"></ul>');
5356
var searchField = $(this);
@@ -91,7 +94,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9194
}
9295

9396
if (!resultsFound){
94-
output += '<li class="'+settings.cssPrefix+'cheader"><p class="'+settings.cssPrefix+'cheader-title">'+settings.noResultsText+'</p><p class="'+settings.cssPrefix+'cheader-limit">0 results</p></li>';
97+
output += '<li class="'+settings.cssPrefix+'cheader"><p class="'+settings.cssPrefix+'cheader-title">'+settings.noResultsText+'</p><p class="'+settings.cssPrefix+'cheader-limit">'+settings.noResultsLimit+'</p></li>';
9598
} else {
9699

97100
$.each(data, function(i, category){
@@ -100,7 +103,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
100103
var limit = category['cheader']['limit'];
101104
var cnt = 0;
102105

103-
output += '<li class="'+settings.cssPrefix+'cheader"><p class="'+settings.cssPrefix+'cheader-title">'+category['cheader']['title']+'</p><p class="'+settings.cssPrefix+'cheader-limit">'+settings.resultsText.replace("%", category['cheader']['total']).replace("$", (category['cheader']['limit'] < category['cdata'].length ? category['cheader']['limit'] : category['cdata'].length))+'</p></li>';
106+
output += '<li class="'+settings.cssPrefix+'cheader"><p class="'+settings.cssPrefix+'cheader-title">'+category['cheader']['title']+'</p><p class="'+settings.cssPrefix+'cheader-limit">'+settings.resultsLimit.replace("%", category['cheader']['total']).replace("$", (category['cheader']['limit'] < category['cdata'].length ? category['cheader']['limit'] : category['cdata'].length))+'</p></li>';
104107

105108
var fillSearchFieldCode = (settings.fillSearchField) ? 'document.getElementById(\''+searchField.attr('id')+'\').value = \'%\';' : '';
106109
//var fillSearchFieldCode = 'document.getElementById(\''+searchField.attr('id')+'\').value = \'%\';';
@@ -137,11 +140,16 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
137140

138141
searchField.blur(function(){
139142
resultBox.fadeOut();
143+
if (searchField.val() == ''){
144+
searchField.val(settings.searchFieldWatermark);
145+
}
140146
});
141147

142148
searchField.focus(function(){
143149
if (searchField.val() == previousQ && searchField.val() != ''){
144150
resultBox.fadeIn();
151+
} else if(searchField.val() == settings.searchFieldWatermark){
152+
searchField.val('');
145153
} else if (searchField.val() != ''){
146154
searchField.trigger('keyup');
147155
}

interface/web/mail/form/mail_alias.tform.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
Hint:
3030
The ID field of the database table is not part of the datafield definition.
3131
The ID field must be always auto incement (int or bigint).
32+
33+
Search:
34+
- searchable = 1 or searchable = 2 include the field in the search
35+
- searchable = 1: this field will be the title of the search result
36+
- searchable = 2: this field will be included in the description of the search result
3237
3338
3439
*/
@@ -75,7 +80,8 @@
7580
'default' => '',
7681
'value' => '',
7782
'width' => '30',
78-
'maxlength' => '255'
83+
'maxlength' => '255',
84+
'searchable' => 1
7985
),
8086
'destination' => array (
8187
'datatype' => 'VARCHAR',
@@ -89,7 +95,8 @@
8995
'validators' => array ( 0 => array ( 'type' => 'ISEMAIL',
9096
'errmsg'=> 'destination_error_isemail'),
9197
),
92-
'value' => ''
98+
'value' => '',
99+
'searchable' => 2
93100
),
94101
'type' => array (
95102
'datatype' => 'VARCHAR',

0 commit comments

Comments
 (0)