Index: trunk/extensions/EducationProgram/includes/EPRoleObject.php |
— | — | @@ -35,11 +35,12 @@ |
36 | 36 | * @since 0.1 |
37 | 37 | * |
38 | 38 | * @param integer $userId |
39 | | - * @param null|array|string $fields |
40 | | - * |
| 39 | + * @param boolean $load If the object should be loaded from the db if it already exists |
| 40 | + * @param null|array|string $fields Fields to load |
| 41 | + * |
41 | 42 | * @return EPRoleObject |
42 | 43 | */ |
43 | | - public static function newFromUserId( $userId, $fields = null ) { |
| 44 | + public static function newFromUserId( $userId, $load = false, $fields = null ) { |
44 | 45 | $data = array( 'user_id' => $userId ); |
45 | 46 | |
46 | 47 | $map = array( |
— | — | @@ -52,7 +53,7 @@ |
53 | 54 | $class = $map[get_called_class()]; |
54 | 55 | $table = $class::singleton(); |
55 | 56 | |
56 | | - $userRole = $table->selectRow( $fields, $data ); |
| 57 | + $userRole = $load ? $table->selectRow( $fields, $data ) : false; |
57 | 58 | |
58 | 59 | if ( $userRole === false ) { |
59 | 60 | return new static( $table, $data, true ); |
— | — | @@ -69,12 +70,13 @@ |
70 | 71 | * @since 0.1 |
71 | 72 | * |
72 | 73 | * @param User $user |
73 | | - * @param null|array|string $fields |
74 | | - * |
| 74 | + * @param boolean $load If the object should be loaded from the db if it already exists |
| 75 | + * @param null|array|string $fields Fields to load |
| 76 | + * |
75 | 77 | * @return EPRoleObject |
76 | 78 | */ |
77 | | - public static function newFromUser( User $user, $fields = null ) { |
78 | | - return static::newFromUserId( $user->getId(), $fields ); |
| 79 | + public static function newFromUser( User $user, $load = false, $fields = null ) { |
| 80 | + return static::newFromUserId( $user->getId(), $load, $fields ); |
79 | 81 | } |
80 | 82 | |
81 | 83 | /** |
Index: trunk/extensions/EducationProgram/includes/EPIRole.php |
— | — | @@ -19,11 +19,12 @@ |
20 | 20 | * @since 0.1 |
21 | 21 | * |
22 | 22 | * @param integer $userId |
23 | | - * @param null|array|string $fields |
| 23 | + * @param boolean $load If the object should be loaded from the db if it already exists |
| 24 | + * @param null|array|string $fields Fields to load |
24 | 25 | * |
25 | 26 | * @return EPIRole |
26 | 27 | */ |
27 | | - public static function newFromUserId( $userId, $fields = null ); |
| 28 | + public static function newFromUserId( $userId, $load = false, $fields = null ); |
28 | 29 | |
29 | 30 | /** |
30 | 31 | * Create a new role object from a user object. |
— | — | @@ -31,11 +32,12 @@ |
32 | 33 | * @since 0.1 |
33 | 34 | * |
34 | 35 | * @param User $user |
35 | | - * @param null|array|string $fields |
| 36 | + * @param boolean $load If the object should be loaded from the db if it already exists |
| 37 | + * @param null|array|string $fields Fields to load |
36 | 38 | * |
37 | 39 | * @return EPIRole |
38 | 40 | */ |
39 | | - public static function newFromUser( User $user, $fields = null ); |
| 41 | + public static function newFromUser( User $user, $load = false, $fields = null ); |
40 | 42 | |
41 | 43 | |
42 | 44 | /** |