@@ -81,6 +81,7 @@ class User extends Model
8181
8282 /**
8383 * Determine if the property for this object exists.
84+ *
8485 * We add relations here so that Twig will be able to find them.
8586 * See http://stackoverflow.com/questions/29514081/cannot-access-eloquent-attributes-on-twig/35908957#35908957
8687 * Every property in __get must also be implemented here for Twig to recognize it.
@@ -192,7 +193,7 @@ public static function exists($value, $identifier = 'user_name', $checkDeleted =
192193 /**
193194 * Return a cache instance specific to that user
194195 *
195- * @return Illuminate\\Cache\\* Store
196+ * @return Illuminate\Contracts \Cache\Store
196197 */
197198 public function getCache ()
198199 {
@@ -263,6 +264,19 @@ public function group()
263264 return $ this ->belongsTo ($ classMapper ->getClassMapping ('group ' ), 'group_id ' );
264265 }
265266
267+ /**
268+ * Returns whether or not this user is the master user.
269+ *
270+ * @return bool
271+ */
272+ public function isMaster ()
273+ {
274+ $ masterId = static ::$ ci ->config ['reserved_user_ids.master ' ];
275+
276+ // Need to use loose comparison for now, because some DBs return `id` as a string
277+ return ($ this ->id == $ masterId );
278+ }
279+
266280 /**
267281 * Get the most recent activity for this user, based on the user's last_activity_id.
268282 *
@@ -317,7 +331,7 @@ public function lastActivityTime($type)
317331 * @param mixed[] $params Optional array of parameters used for this event handler.
318332 * @todo Transition to Laravel Event dispatcher to handle this
319333 */
320- public function onLogin ($ params = array () )
334+ public function onLogin ($ params = [] )
321335 {
322336 // Add a sign in activity (time is automatically set by database)
323337 static ::$ ci ->userActivityLogger ->info ("User {$ this ->user_name } signed in. " , [
@@ -329,15 +343,15 @@ public function onLogin($params = array())
329343
330344 if ($ passwordType != "modern " ) {
331345 if (!isset ($ params ['password ' ])) {
332- error_log ("Notice: Unhashed password must be supplied to update to modern password hashing. " );
346+ Debug:: debug ("Notice: Unhashed password must be supplied to update to modern password hashing. " );
333347 } else {
334348 // Hash the user's password and update
335349 $ passwordHash = Password::hash ($ params ['password ' ]);
336350 if ($ passwordHash === null ) {
337- error_log ("Notice: outdated password hash could not be updated because the new hashing algorithm is not supported. Are you running PHP >= 5.3.7? " );
351+ Debug:: debug ("Notice: outdated password hash could not be updated because the new hashing algorithm is not supported. Are you running PHP >= 5.3.7? " );
338352 } else {
339353 $ this ->password = $ passwordHash ;
340- error_log ("Notice: outdated password hash has been automatically updated to modern hashing. " );
354+ Debug:: debug ("Notice: outdated password hash has been automatically updated to modern hashing. " );
341355 }
342356 }
343357 }
@@ -355,7 +369,7 @@ public function onLogin($params = array())
355369 * @param mixed[] $params Optional array of parameters used for this event handler.
356370 * @todo Transition to Laravel Event dispatcher to handle this
357371 */
358- public function onLogout ($ params = array () )
372+ public function onLogout ($ params = [] )
359373 {
360374 static ::$ ci ->userActivityLogger ->info ("User {$ this ->user_name } signed out. " , [
361375 'type ' => 'sign_out '
0 commit comments