CMS  Version 3.9
forum_search_by_author.inc
Go to the documentation of this file.
1 <?php
2 Fakoli::using("forum", "user");
4 
5 $text = $_GET["author"];
6 $forum_id = checkNumeric($_GET["forum_id"]);
7 
8 $mgr = new UserManager();
9 $cl = $mgr->getUserClass();
10 $u = new $cl;
11 if (!($u->hasField("first_name") && $u->hasField("last_name")))
12 {
13  throw new FakoliException("User object model does not support search by name");
14 }
15 
16 $pk = $u->getPrimaryKey();
17 $table = $u->table;
18 $text = "%{$text}%";
19 
20 $messages = Query::create(ForumMessage, "WHERE deleted=0 AND forum_id=:f AND author_id IN (SELECT $pk FROM $table WHERE concat(first_name, ' ', last_name) LIKE :t) ORDER BY date_posted DESC")
21  ->bind(":f", $forum_id, ":t", $text)
22  ->execute();
23 
24 $view = new ForumSearchResultsView($messages, $_GET["author"]);
25 
26 $script .= $view->writeScript();
27 $view->drawView();
FakoliException is the base exception class for all Fakoli errors.
Definition: core.inc:53
static usingFeature()
Uses the specified framework feature(s).
Definition: core.inc:388
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
Provides the interface to the user model for the application.
if(!($u->hasField("first_name") && $u->hasField("last_name"))) $pk