Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
FriendsSearchWidget.php
1 <?php
2 /**
3  * Gentics Portal.Node PHP
4  * Author & Copyright (c) by Gentics Software GmbH
5  * sales@gentics.com
6  * http://www.gentics.com
7  * Licenses can be found in the LICENSE.txt file in the root-folder of this installation
8  * You must not use this software without a valid license agreement.
9  *
10  *
11  * Execute search for users which existing in DB.
12  * Fields which will used for search are configurable.
13  */
15 {
16  /**
17  * @var array Array of User model fields which will used for search
18  */
19  public $userFields = array(
20  'username'
21  );
22 
23  /**
24  * @var array Array of Profile model fields which will used for search
25  */
26  public $profileFields = array(
27  'firstname',
28  'gender',
29  'birthday'
30  );
31 
32  //TODO: move to global context?
33  public $searchResultPageUrl = '';
34 
35  public function init()
36  {
37  parent::init();
38 
39  foreach ($this->userFields as $f) {
40  if (!User::model()->hasAttribute($f)) {
41  throw new Exception("Attribute '$f' not available in 'userFields'");
42  }
43  }
44 
45  foreach ($this->profileFields as $f) {
46  if (!Profile::model()->hasAttribute($f)) {
47  throw new Exception("Attribute '$f' not available in 'profileFields'");
48  }
49  }
50 
51  }
52 
53 
54  public function run()
55  {
56  $user = new UserSearch('view');
57  $profile = new Profile();
58  if (isset($_GET['UserSearch'])) {
59  $user->attributes = $_GET['UserSearch'];
60 
61  }
62  if (isset($_GET['Profile'])) {
63  $profile->attributes = $_GET['Profile'];
64  }
65 
66  $this->render('FriendsSearchWidget', array('user' => $user, 'profile' => $profile));
67  }
68 
69 
70 }