View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0010575 | mantisbt | feature | public | 2009-06-10 11:01 | 2009-06-10 11:01 |
| Reporter | buknon | Assigned To | |||
| Priority | normal | Severity | minor | Reproducibility | have not tried |
| Status | new | Resolution | open | ||
| Product Version | git trunk | ||||
| Summary | 0010575: autocomplete for profile with full test search in all related field | ||||
| Description | new feature. | ||||
| Tags | No tags attached. | ||||
| Attached Files | profile-fulltext-search_master.patch (5,702 bytes)
From 361790ff7e4e4682c893e4274de286dcb4bd7831 Mon Sep 17 00:00:00 2001
From: buknon <tristan@a-t-h.fr>
Date: Wed, 10 Jun 2009 16:14:04 +0200
Subject: [PATCH] Add full text search in profile related fields with autocomplete
---
bug_report.php | 20 ++++++++++++++++++++
bug_report_advanced_page.php | 13 ++++++++++---
config_defaults_inc.php | 6 ++++++
core/projax_api.php | 18 ++++++++++++++++++
core/xmlhttprequest_api.php | 22 ++++++++++++++++++++++
5 files changed, 76 insertions(+), 3 deletions(-)
diff --git a/bug_report.php b/bug_report.php
index 747af4f..30fcabe 100644
--- a/bug_report.php
+++ b/bug_report.php
@@ -77,6 +77,9 @@
$t_bug_data->target_version = access_has_project_level( config_get( 'roadmap_update_threshold' ), $t_bug_data->project_id ) ? gpc_get_string( 'target_version', '' ) : '';
# if a profile was selected then let's use that information
+
+ $t_profile = gpc_get_string('profile',"");
+
if ( 0 != $t_bug_data->profile_id ) {
if ( profile_is_global( $t_bug_data->profile_id ) ) {
$row = user_get_profile_row( ALL_USERS, $t_bug_data->profile_id );
@@ -93,7 +96,24 @@
if ( is_blank( $t_bug_data->os_build ) ) {
$t_bug_data->os_build = $row['os_build'];
}
+ } elseif ( $t_profile != "") {
+ if (!eregi("^[a-z0-9\.\-]*[_]{1}[a-z0-9\.\-]*[_]{1}[a-z0-9\.\-]*$", $t_profile)) {
+ error_parameters( lang_get_defaulted( 'Profil' )) ;
+ trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR );
+ } else {
+ $t_profile_array=explode("_",$t_profile);
+ if ( is_blank( $t_bug_data->platform )) {
+ $t_bug_data->platform = $t_profile_array[0];
+ }
+ if ( is_blank( $t_bug_data->os )) {
+ $t_bug_data->os = $t_profile_array[1];
+ }
+ if ( is_blank( $t_bug_data->os_build )) {
+ $t_bug_data->os_build = $t_profile_array[2];
+ }
+ }
}
+
helper_call_custom_function( 'issue_create_validate', array( $t_bug_data ) );
# Validate the custom fields before adding the bug.
diff --git a/bug_report_advanced_page.php b/bug_report_advanced_page.php
index 9e1f1cb..103387c 100644
--- a/bug_report_advanced_page.php
+++ b/bug_report_advanced_page.php
@@ -237,11 +237,18 @@
<?php echo lang_get( 'select_profile' ) ?>
</td>
<td>
- <?php if (count(profile_get_all_for_user( auth_get_current_user_id() )) > 0) { ?>
+
+ <?php
+ if ( config_get( 'allow_freetext_in_profile_fields' ) == ON && config_get('allow_full_text_search_in_profile_fields' ) == ON) {
+ projax_autocomplete( 'profile_get_full_text', 'profile', array( 'value' => $f_profile, 'size' => '32', 'maxlength' => '32', 'tabindex' => helper_get_tab_index_value() ) );
+ } elseif (count(profile_get_all_for_user( auth_get_current_user_id() )) > 0) {
+ ?>
<select <?php echo helper_get_tab_index() ?> name="profile_id">
- <?php print_profile_option_list( auth_get_current_user_id(), $f_profile_id ) ?>
+ <?php print_profile_option_list( auth_get_current_user_id(), $f_profile_id ) ?>
</select>
- <?php } ?>
+ <?php
+ }
+ ?>
</td>
</tr>
<tr <?php echo helper_alternate_class() ?>>
diff --git a/config_defaults_inc.php b/config_defaults_inc.php
index 2244b0f..e8cb2ea 100644
--- a/config_defaults_inc.php
+++ b/config_defaults_inc.php
@@ -3476,6 +3476,12 @@
* @global int $g_allow_freetext_in_profile_fields
*/
$g_allow_freetext_in_profile_fields = ON;
+
+ /**
+ * Enable the full text search in profile related fields with autocomplete
+ * Work only when allow_freetext_in_profile_fields is enabled
+ */
+ $g_allow_full_text_search_in_profile_fields = ON;
/********************
* Twitter Settings *
diff --git a/core/projax_api.php b/core/projax_api.php
index 1ea3072..3f3e939 100644
--- a/core/projax_api.php
+++ b/core/projax_api.php
@@ -65,6 +65,24 @@ function projax_array_filter_by_prefix( $p_array, $p_prefix ) {
return $t_matches;
}
+# Filters the provided array of strings and only returns the ones that containing $p_text.
+# The comparison is not case sensitive.
+# Returns the array of the filtered strings, or an empty array. If the input array has non-unique
+# entries, then the output one may contain duplicates.
+function projax_array_filter_full_text( $p_array, $p_text ) {
+ $t_matches = array();
+
+ foreach( $p_array as $t_entry ) {
+ if( strpos(strtolower($t_entry), $p_text ) !== FALSE ) {
+ $t_matches[] = $t_entry;
+ }
+ }
+
+ return $t_matches;
+}
+
+
+
# Serializes the provided array of strings into the format expected by the auto-complete library.
function projax_array_serialize_for_autocomplete( $p_array ) {
$t_matches = '<ul>';
diff --git a/core/xmlhttprequest_api.php b/core/xmlhttprequest_api.php
index fb8cfec..cd6ac39 100644
--- a/core/xmlhttprequest_api.php
+++ b/core/xmlhttprequest_api.php
@@ -111,3 +111,25 @@ function xmlhttprequest_os_build_get_with_prefix() {
echo projax_array_serialize_for_autocomplete( $t_matching_entries );
}
+
+/**
+ * Echos a serialized list of profiles which have in plateform, os, description the text specified in the $_POST (full text search)
+ * @return null
+ * @access public
+ */
+function xmlhttprequest_profile_get_full_text() {
+ $f_profile = gpc_get_string( 'profile' );
+ $f_user_id = auth_get_current_user_id();
+
+ $t_rows = array();
+
+ $t_unique_entries = profile_get_all_for_user( $f_user_id);
+ foreach( $t_unique_entries as $t_profile ) {
+ extract( $t_profile, EXTR_PREFIX_ALL, 'v' );
+ array_push ($t_rows, $v_platform."_".$v_os."_".$v_os_build);
+ }
+
+ $t_matching_entries = projax_array_filter_full_text( $t_rows, $f_profile);
+
+ echo projax_array_serialize_for_autocomplete( $t_matching_entries );
+}
\ No newline at end of file
--
1.5.6.3
| ||||