Skip to content

Commit 4c28d9c

Browse files
committed
- Added global search (FS#2210, FS#2146).
1 parent cb904e4 commit 4c28d9c

22 files changed

+685
-44
lines changed

interface/lib/classes/functions.inc.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,46 @@ public function get_ispconfig_url() {
109109
return $url;
110110
}
111111

112+
function json_encode($data) {
113+
if(!function_exists('json_encode')){
114+
switch ($type = gettype($data)){
115+
case 'NULL':
116+
return 'null';
117+
case 'boolean':
118+
return ($data ? 'true' : 'false');
119+
case 'integer':
120+
case 'double':
121+
case 'float':
122+
return $data;
123+
case 'string':
124+
return '"' . addslashes($data) . '"';
125+
case 'object':
126+
$data = get_object_vars($data);
127+
case 'array':
128+
$output_index_count = 0;
129+
$output_indexed = array();
130+
$output_associative = array();
131+
foreach($data as $key => $value){
132+
$output_indexed[] = $this->json_encode($value);
133+
$output_associative[] = $this->json_encode($key) . ':' . $this->json_encode($value);
134+
if($output_index_count !== NULL && $output_index_count++ !== $key){
135+
$output_index_count = NULL;
136+
}
137+
}
138+
if($output_index_count !== NULL){
139+
return '[' . implode(',', $output_indexed) . ']';
140+
} else {
141+
return '{' . implode(',', $output_associative) . '}';
142+
}
143+
default:
144+
return ''; // Not supported
145+
}
146+
} else {
147+
return json_encode($data);
148+
}
149+
}
150+
151+
112152

113153
}
114154

interface/web/capp.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@
3333

3434
//* Import module variable
3535
$mod = $_REQUEST["mod"];
36+
//* If we click on a search result, load that one instead of the module's start page
37+
$redirect = (isset($_REQUEST["redirect"]) ? $_REQUEST["redirect"] : '');
3638

3739
//* Check if user is logged in
3840
if($_SESSION["s"]["user"]['active'] != 1) {
3941
die("URL_REDIRECT: /index.php");
4042
//die();
4143
}
4244

45+
if(!preg_match("/^[a-z]{2,20}$/i", $mod)) die('module name contains unallowed chars.');
46+
4347
//* Check if user may use the module.
4448
$user_modules = explode(",",$_SESSION["s"]["user"]["modules"]);
4549

@@ -50,7 +54,12 @@
5054
include_once($mod."/lib/module.conf.php");
5155
$_SESSION["s"]["module"] = $module;
5256
session_write_close();
53-
echo "HEADER_REDIRECT:".$_SESSION["s"]["module"]["startpage"];
57+
if($redirect == ''){
58+
echo "HEADER_REDIRECT:".$_SESSION["s"]["module"]["startpage"];
59+
} else {
60+
//* If we click on a search result, load that one instead of the module's start page
61+
echo "HEADER_REDIRECT:".$redirect;
62+
}
5463
} else {
5564
$app->error($app->lng(302));
5665
}

interface/web/client/form/client.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',
@@ -136,7 +144,8 @@
136144
'width' => '30',
137145
'maxlength' => '255',
138146
'rows' => '',
139-
'cols' => ''
147+
'cols' => '',
148+
'searchable' => 2
140149
),
141150
'password' => array (
142151
'datatype' => 'VARCHAR',
@@ -181,7 +190,8 @@
181190
'width' => '30',
182191
'maxlength' => '255',
183192
'rows' => '',
184-
'cols' => ''
193+
'cols' => '',
194+
'searchable' => 2
185195
),
186196
'zip' => array (
187197
'datatype' => 'VARCHAR',
@@ -192,7 +202,8 @@
192202
'width' => '10',
193203
'maxlength' => '255',
194204
'rows' => '',
195-
'cols' => ''
205+
'cols' => '',
206+
'searchable' => 2
196207
),
197208
'city' => array (
198209
'datatype' => 'VARCHAR',
@@ -203,7 +214,8 @@
203214
'width' => '30',
204215
'maxlength' => '255',
205216
'rows' => '',
206-
'cols' => ''
217+
'cols' => '',
218+
'searchable' => 2
207219
),
208220
'state' => array (
209221
'datatype' => 'VARCHAR',
@@ -214,7 +226,8 @@
214226
'width' => '30',
215227
'maxlength' => '255',
216228
'rows' => '',
217-
'cols' => ''
229+
'cols' => '',
230+
'searchable' => 2
218231
),
219232
'country' => array (
220233
'datatype' => 'VARCHAR',
@@ -237,7 +250,8 @@
237250
'width' => '30',
238251
'maxlength' => '255',
239252
'rows' => '',
240-
'cols' => ''
253+
'cols' => '',
254+
'searchable' => 2
241255
),
242256
'mobile' => array (
243257
'datatype' => 'VARCHAR',
@@ -248,7 +262,8 @@
248262
'width' => '30',
249263
'maxlength' => '255',
250264
'rows' => '',
251-
'cols' => ''
265+
'cols' => '',
266+
'searchable' => 2
252267
),
253268
'fax' => array (
254269
'datatype' => 'VARCHAR',
@@ -259,7 +274,8 @@
259274
'width' => '30',
260275
'maxlength' => '255',
261276
'rows' => '',
262-
'cols' => ''
277+
'cols' => '',
278+
'searchable' => 2
263279
),
264280
'email' => array (
265281
'datatype' => 'VARCHAR',
@@ -270,7 +286,8 @@
270286
'width' => '30',
271287
'maxlength' => '255',
272288
'rows' => '',
273-
'cols' => ''
289+
'cols' => '',
290+
'searchable' => 2
274291
),
275292
'internet' => array (
276293
'datatype' => 'VARCHAR',
@@ -281,7 +298,8 @@
281298
'width' => '30',
282299
'maxlength' => '255',
283300
'rows' => '',
284-
'cols' => ''
301+
'cols' => '',
302+
'searchable' => 2
285303
),
286304
'icq' => array (
287305
'datatype' => 'VARCHAR',

0 commit comments

Comments
 (0)