r2974 - changeset:2973 was a mistake
authorDenis Ovsienko <infrastation@yandex.ru>
Mon, 20 Jul 2009 17:28:58 +0000 (17:28 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Mon, 20 Jul 2009 17:28:58 +0000 (17:28 +0000)
inc/database.php
inc/interface.php

index e29a0d0c9f3fdff836fd5699626c84b88cdf477d..5a9c9c1376f4ab5bbb81869331b0b8315cc09022 100644 (file)
@@ -1657,25 +1657,6 @@ function getObjectAttrsSearchResults ($what)
        return $ret;
 }
 
-// This function will eventually merge the functionality of the "older"
-// searching function. Both ones are used at the moment, and they do
-// search in different value spaces.
-function getObjectSearchResults_new ($what)
-{
-       $ret = array();
-       foreach (getStickerSearchResults ($what) as $objRecord)
-       {
-               $ret[$objRecord['id']]['id'] = $objRecord['id'];
-               $ret[$objRecord['id']]['by_sticker'] = $objRecord['by_sticker'];
-       }
-       foreach (getPortRsvSearchResults ($what) as $objRecord)
-       {
-               $ret[$objRecord['id']]['id'] = $objRecord['id'];
-               $ret[$objRecord['id']]['by_portrsv'] = $objRecord['by_portrsv'];
-       }
-       return $ret;
-}
-
 // Look for EXACT value in stickers and return a list of pairs "object_id-attribute_id",
 // which matched. A partilar object_id could be returned more, than once, if it has
 // multiple matching stickers. Search is only performed on "string" attributes.
@@ -1738,24 +1719,25 @@ function getPortSearchResults ($what)
        return $ret;
 }
 
-// search in port "reservation comment" column
-function getPortRsvSearchResults ($what)
+// Look for EXACT value in stickers and return a list of pairs "object_id-attribute_id",
+// which matched. A partilar object_id could be returned more, than once, if it has
+// multiple matching stickers. Search is only performed on "string" attributes.
+function getStickerSearchResults ($what)
 {
-       $ports = getSearchResultByField
+       $stickers = getSearchResultByField
        (
-               'Port',
-               array ('object_id', 'id'),
-               'reservation_comment',
+               'AttributeValue',
+               array ('object_id', 'attr_id'),
+               'string_value',
                $what,
                'object_id',
-               0
+               1
        );
+       $map = getAttrMap();
        $ret = array();
-       foreach ($ports as $port)
-       {
-               $ret[$port['object_id']]['id'] = $port['object_id'];
-               $ret[$port['object_id']]['by_portrsv'][] = $port['id'];
-       }
+       foreach ($stickers as $sticker)
+               if ($map[$sticker['attr_id']]['type'] == 'string')
+                       $ret[] = $sticker;
        return $ret;
 }
 
index 4816f313f3a68f10ad5d534b35634485aee27ebf..a733f960e85507b2fb46f50bd8d0c997f02d671a 100644 (file)
@@ -2767,13 +2767,6 @@ function renderSearchResults ()
                        $lasthit = 'object';
                        $summary['object'] = $tmp;
                }
-               $tmp = getObjectSearchResults_new ($terms);
-               if (count ($tmp))
-               {
-                       $nhits += count ($tmp);
-                       $lasthit = 'object_new';
-                       $summary['object_new'] = $tmp;
-               }
                $tmp = getIPv4AddressSearchResult ($terms);
                if (count ($tmp))
                {
@@ -2851,7 +2844,6 @@ function renderSearchResults ()
                                echo "';//</script>";
                                break;
                        case 'object':
-                       case 'object_new':
                                echo "<script language='Javascript'>document.location='${root}?page=object&object_id=${record['id']}';//</script>";
                                break;
                        case 'ipv4rspool':
@@ -2934,51 +2926,6 @@ function renderSearchResults ()
                                        echo '</table>';
                                        finishPortlet();
                                        break;
-                               case 'object_new':
-                                       startPortlet ("<a href='${root}?page=depot'>Objects (continued)</a>");
-                                       echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
-                                       echo '<tr><th>what</th><th>why</th></tr>';
-                                       foreach ($what as $obj)
-                                       {
-                                               echo "<tr class=row_${order} valign=top><td>";
-                                               renderCell (spotEntity ('object', $obj['id']));
-                                               echo "</td><td>";
-                                               if (isset ($obj['by_sticker']))
-                                               {
-                                                       echo '<table>';
-                                                       $aval = getAttrValues ($obj['id']);
-                                                       foreach ($obj['by_sticker'] as $attr_id)
-                                                       {
-                                                               $record = array
-                                                               (
-                                                                       'name' => $aval[$attr_id]['name'],
-                                                                       'a_value' => $aval[$attr_id]['a_value']
-                                                               );
-                                                               echo "<tr><th width='50%' class=sticker>${record['name']}:</th>";
-                                                               echo "<td class=sticker>${record['a_value']}</td></tr>";
-                                                       }
-                                                       echo '</table>';
-                                               }
-                                               if (isset ($obj['by_portrsv']))
-                                               {
-                                                       echo '<table>';
-                                                       $ports = getObjectPortsAndLinks ($obj['id']);
-                                                       foreach ($obj['by_portrsv'] as $port_id)
-                                                               foreach ($ports as $port)
-                                                                       if ($port['id'] == $port_id)
-                                                                       {
-                                                                               echo "<tr><td>port ${port['name']} (${port['type']}):</td>";
-                                                                               echo "<td class=tdleft>${port['reservation_comment']}</td></tr>";
-                                                                               break; // next reason
-                                                                       }
-                                                       echo '</table>';
-                                               }
-                                               echo "</td></tr>";
-                                               $order = $nextorder[$order];
-                                       }
-                                       echo '</table>';
-                                       finishPortlet();
-                                       break;
                                case 'ipv4network':
                                        startPortlet ("<a href='${root}?page=ipv4space'>IPv4 networks</a>");
                                        echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';