r1368: - Input checkboxes for custom fields should have an Ignore,Yes,No option on...
authorRobert Sesek <rsesek@bluestatic.org>
Wed, 13 Dec 2006 03:22:51 +0000 (03:22 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Wed, 13 Dec 2006 03:22:51 +0000 (03:22 +0000)
- Change the favorite status option values for searches to match that of the input checkboxes

includes/functions.php
search.php
templates/bugfield_input_checkbox.tpl
templates/search.tpl

index 01e5428a84eb3c43e31768c37237a6386c27aae2..f64674d3e39374afb6cb96a7b7d6217798c74463 100755 (executable)
@@ -192,7 +192,7 @@ function construct_datastore_select($datastore, $labelname, $valuename, $selecte
 }
 
 // ################## Start construct_custom_fields ##################
-function construct_custom_fields($bug = array(), $ignore21mask = false, $nodefault = false)
+function construct_custom_fields($bug = array(), $ignore21mask = false, $nodefault = false, $searchMode = false)
 {
        global $bugsys;
        static $fields;
@@ -249,7 +249,7 @@ function construct_custom_fields($bug = array(), $ignore21mask = false, $nodefau
                                break;
                                
                                case 'input_checkbox':
-                                       $selected = (($value) ? ' checked="checked"' : '');
+                                       $selected = ($value ? ' checked="checked"' : '');
                                        eval('$tempfield = "' . $bugsys->template->fetch('bugfield_input_checkbox') . '";');
                                break;
                                
index a590548cae133d25ebd32db90370440dc87b5f95..9cfcf8232f79d4308e63e86b2572f085cec4aae2 100644 (file)
@@ -183,15 +183,16 @@ if ($_REQUEST['do'] == 'process')
        }
        
        // -------------------------------------------------------------------
-       // favoritess
-       if (($bugsys->in['favorite'] == 1 OR $bugsys->in['favorite'] == 0) AND $bugsys->userinfo['userid'])
+       // favorites
+       $bugsys->input_clean('favorite', TYPE_INT);
+       if ($bugsys->in['favorite'] != 0 AND $bugsys->userinfo['userid'])
        {
                $favorites = $db->query("SELECT * FROM " . TABLE_PREFIX . "favorite WHERE userid = " . $bugsys->userinfo['userid']);
                while ($favorite = $db->fetch_array($favorites))
                {
                        $ids[] = $favorite['bugid'];
                }
-               $querybuild['favorites'] = "AND bug.bugid " . ($bugsys->in['favorite'] == 0 ? "NOT IN" : "IN") . " (" . implode(', ', $ids) . ")";
+               $querybuild['favorites'] = "AND bug.bugid " . ($bugsys->in['favorite'] > 0 ? "IN" : "NOT IN") . " (" . implode(', ', $ids) . ")";
        }
        
        // -------------------------------------------------------------------
@@ -227,9 +228,9 @@ if ($_REQUEST['do'] == 'process')
        {
                if (!empty($bugsys->in["field$field[fieldid]"]) OR ($field['type'] == 'select_single' AND isset($bugsys->in["field$field[fieldid]"])))
                {
-                       if ($field['type'] == 'input_checkbox')
+                       if ($field['type'] == 'input_checkbox' AND $bugsys->input_clean("field$field[fieldid]", TYPE_INT) != 0)
                        {
-                               $querybuild[] = "AND bugfieldvalue.field$field[fieldid] = " . (($bugsys->in["field$field[fieldid]"] == 1) ? 0 : 1);
+                               $querybuild[] = "AND bugfieldvalue.field$field[fieldid] = " . (($bugsys->in["field$field[fieldid]"] > 0) ? 1 : 0);
                        }
                        else if ($field['type'] == 'input_text')
                        {
@@ -357,7 +358,7 @@ if ($_REQUEST['do'] == 'search')
                
                // -------------------------------------------------------------------
                // custom fields
-               $fields = construct_custom_fields(null, true);          
+               $fields = construct_custom_fields(null, true, false, true);             
                $i = 0;
                foreach ($fields AS $field)
                {
index 9abd4bc7020737565208be3e22225383228a2825..d6dd245f77f7cf9b3b8d081bd023f18cce9b1522 100644 (file)
@@ -1,6 +1,6 @@
        <!-- custom field$field[fieldid] -->
        <fieldset>
                <legend>$field[name] $help[field$field[fieldid]]</legend>
-               <div class="field"><input name="<if condition="$show['search']">custom[$field[fieldid]]<else />field$field[fieldid]</if>" type="checkbox" value="1"$selected /></div>
+               <div class="field"><if condition="$searchMode"><select name="<if condition="$show['search']">custom[$field[fieldid]]<else />field$field[fieldid]</if>"><option value="0">{@"Ignore"}</option><option value="1">{@"Yes"}</option><option value="-1">{@"No"}</option></select><else /><input name="<if condition="$show['search']">custom[$field[fieldid]]<else />field$field[fieldid]</if>" type="checkbox" value="1"$selected /></if></div>
        </fieldset>
        <!-- / custom field$field[fieldid] -->
\ No newline at end of file
index 0fcead1fb9f4249051cf2164a2253740ccb5ac64..0d2631fd99443f3becf3fefab94bbf5f2f0aa41f 100644 (file)
@@ -153,9 +153,9 @@ $header
                        <legend>{@"Favorite"}</legend>
                        <div class="field">
                                <select name="favorite">
-                                       <option value="-1">{@"Ignore favorite status"}</option>
-                                       <option value="1">{@"Yes, search for favorites only"}</option>
-                                       <option value="0">{@"No, exclude all favorites"}</option>
+                                       <option value="0">{@"Ignore"}</option>
+                                       <option value="1">{@"Yes"}</option>
+                                       <option value="-1">{@"No"}</option>
                                </select>
                        </div>
                </fieldset>