1 <?php
2 /**
3 * ProfileQuestion.php
4 *
5 * @author Elvyrra SAS
6 * @license http://rem.mit-license.org/ MIT
7 */
8 namespace Hawk;
9
10
11 /**
12 * This model describes the customized profile data types
13 *
14 * @package BaseModels
15 */
16 class ProfileQuestion extends Model{
17 /**
18 * The associated table
19 *
20 * @var string
21 */
22 protected static $tablename = "ProfileQuestion";
23
24 /**
25 * The primary column in the table
26 *
27 * @var string
28 */
29 protected static $primaryColumn = 'name';
30
31 /**
32 * The allowed input types for customization of profile questions
33 *
34 * @var array
35 */
36 public static $allowedTypes = array(
37 'text',
38 'textarea',
39 'checkbox',
40 'radio',
41 'select',
42 'datetime',
43 'file'
44 );
45
46 /**
47 * Get a question by it name
48 *
49 * @param string $name The name to search
50 *
51 * @return ProfileQuestion
52 */
53 public static function getByName($name){
54 return self::getById($name);
55 }
56
57 /**
58 * Get the profile questions that are displayed in the register form
59 *
60 * @return array
61 */
62 public static function getRegisterQuestions(){
63 $example = array(
64 'displayInRegister' => 1
65 );
66 return self::getListByExample(new DBExample($example), self::$primaryColumn, array(), array('order' => DB::SORT_ASC));
67 }
68
69 /**
70 * Get the profile questions that are displayed publically on the users' profile
71 *
72 * @return array
73 */
74 public static function getDisplayProfileQuestions(){
75 $example = array(
76 'displayInProfile' => 1
77 );
78 return self::getListByExample(new DBExample($example), self::$primaryColumn, array(), array('order' => DB::SORT_ASC));
79 }
80
81
82 }