|
Revision 3782, 1.3 KB
(checked in by wjohnald, 2 years ago)
|
|
refactored categories filter to be saved in the session. Added a wrapper to aPeopleTools for setting and getting user attributes.
|
| Line | |
|---|
| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | /** |
|---|
| 4 | * aPerson actions. |
|---|
| 5 | * |
|---|
| 6 | * @package cs |
|---|
| 7 | * @subpackage aPerson |
|---|
| 8 | * @author P'unk Avenue |
|---|
| 9 | * @version SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $ |
|---|
| 10 | */ |
|---|
| 11 | class PluginaPeopleComponents extends sfComponents |
|---|
| 12 | { |
|---|
| 13 | /** |
|---|
| 14 | * Executes sidebar component |
|---|
| 15 | * |
|---|
| 16 | * Displays the Program links that are used to filter the Person in the content area. |
|---|
| 17 | * |
|---|
| 18 | * @param sfRequest $request A request object |
|---|
| 19 | */ |
|---|
| 20 | public function executeSidebar(sfWebRequest $request) |
|---|
| 21 | { |
|---|
| 22 | $defaults = array(); |
|---|
| 23 | $defaults['categories'] = aPeopleTools::getAttribute('categories_filter', array()); |
|---|
| 24 | |
|---|
| 25 | $this->form = new aPeopleCategoryForm($defaults); |
|---|
| 26 | $this->actionUrl = url_for($request->getUri()); |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | public function executeSearch(sfWebRequest $request) |
|---|
| 30 | { |
|---|
| 31 | $q = $this->q; |
|---|
| 32 | // Matches middle names promiscuously if user types firstname lastname; also works around the lack of a space |
|---|
| 33 | // between concatenated first and last name in the simplest way. There are other approaches but this works fine. |
|---|
| 34 | // Don't make consecutive %'s, MySQL doesn't seem to mind much but why ask for trouble |
|---|
| 35 | $q = preg_replace('/\s+/', '%', $q); |
|---|
| 36 | $this->results = Doctrine::getTable('aPerson')->createQuery('p')->where('concat(coalesce(p.first_name, ""), coalesce(p.middle_name, ""), coalesce(p.last_name, "")) LIKE ?', "%$q%")->limit(10)->execute(); |
|---|
| 37 | } |
|---|
| 38 | } |
|---|