Added support for distinguishing betweek speaker, sleeper, supporter
authorJoey Schulze <joey@infodrom.org>
Fri, 17 Jun 2005 14:18:22 +0000 (14:18 +0000)
committerJoey Schulze <joey@infodrom.org>
Fri, 17 Jun 2005 14:18:22 +0000 (14:18 +0000)
and real people

src/LinuxTag/2005/search.wml

index ae103f5..96c660e 100644 (file)
@@ -51,35 +51,64 @@ function search_person ($dbh, $key)
 {
   global $foundsomething;
 
-  $query = sprintf ("SELECT oid,name,email,project FROM person WHERE "
+  $query = sprintf ("SELECT oid,name,email,project,id FROM person WHERE "
                   ."name ~* '%s' OR email ~* '%s' OR comment ~* '%s' "
                   ."ORDER BY name",
                    $key, $key, $key);
   $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
 
+  $id = array();
   if (pg_NumRows ($sth) > 0) {
     for ($nr=0; $nr < pg_NumRows ($sth); $nr++) {
       $row = pg_fetch_array ($sth, $nr);
+      $this = $row['id'];
       if (strlen ($row['email'])) {
-        $this = $row['name'] . " &lt;" . $row['email'] . "&gt;";
+        $name[$this] = $row['name'] . " &lt;" . $row['email'] . "&gt;";
       } else {
-        $this = $row['name'];
+        $name[$this] = $row['name'];
       }
       $result[$this] = $row['oid'];
       $project[$this] = $row['project'];
+      $id[] = $this;
     }
   }
   
   if (count ($result) > 0) {
+    $query = sprintf ("SELECT project,person FROM junction WHERE person = %s", implode($id, " OR person = "));
+    $sth = pg_exec ($dbh, $query) or die("Datenbank-Abfrage!");
+    if (pg_NumRows ($sth) > 0) {
+    for ($nr=0; $nr < pg_NumRows ($sth); $nr++) {
+      $row = pg_fetch_array ($sth, $nr);
+      $special[$row['person']] .= ':'.$row['project'];
+      }
+    }
+    while (list($k,$v) = each ($special)) {
+      $special[$k] .= ':';
+    }
+
     if ($foundsomething == false) {
       $foundsomething = true;
       echo "<ol>";
     }
 
     while (list($k,$v) = each ($result)) {
-      printf ("<li> Person <a href=\"projects/edit_person.php3?context=%s&oid=%d\">%s</a>",
-             urlencode ($project[$k]),
-             $v, $k);
+      if (strstr($special[$k], ':Supporter:')) {
+       printf ("<li> Supporter <a href=\"supporter/edit.php3?oid=%d\">%s</a>",
+               $v, $name[$k]);
+      } elseif (strstr($special[$k], ':Speaker:')) {
+       printf ("<li> Speaker <a href=\"projects/edit_person.php3?context=%s&oid=%d\">%s</a>",
+               urlencode ($project[$k]),
+               $v, $name[$k]);
+      } elseif (strstr($special[$k], ':Sleeper:')) {
+       printf ("<li> Sleeper <a href=\"projects/edit_person.php3?context=%s&oid=%d\">%s</a>",
+               urlencode ($project[$k]),
+               $v, $name[$k]);
+      } else {
+       printf ("<li> Person <a href=\"projects/edit_person.php3?context=%s&oid=%d\">%s</a>",
+               urlencode ($project[$k]),
+               $v, $name[$k]);
+      }
+
     }
   }
 } // function search_person ($dbh, $key)