diff --git a/include/class-User.php b/include/class-User.php index ebce5c4..dfb76b8 100644 --- a/include/class-User.php +++ b/include/class-User.php @@ -1,162 +1,162 @@ . trait UserTrait { /** * Normalize a User object */ protected function normalizeUser() { $this->integers( 'user_ID' ); } /** * Get the user ID * * @return int */ public function getUserID() { return $this->get( 'user_ID' ); } /** * Get the user first name * * @return string */ public function getUserName() { return $this->get( 'user_name' ); } /** * Get the user surname * * @return string */ public function getUserSurname() { return $this->get( 'user_surname' ); } /** * Get the user UID * * @return string */ public function getUserUID() { return $this->get( 'user_uid' ); } /** * Get the user E-mail * * @return string */ public function getUserEmail() { return $this->get( 'user_email' ); } /** * Get the role of this user * * @return string */ public function getUserRole() { return $this->get( 'user_role' ); } /** * Get the human name of the user role * * @return string */ public function getUserRoleLabel() { $roles = User::roles(); $role = $this->getUserRole(); return $roles[ $role ]; } /** * Check if this user is me * * @return boolean */ public function isUserMyself() { $id = $this->getUserID(); return is_logged() && get_user()->getUserID() === $id; } /** * Check if I can edit this user * * @return boolean */ public function isUserEditable() { return $this->isUserMyself() || has_permission( 'edit-user-all' ); } /** * Get the domain edit URl * * @param boolean $absolute True for an absolute URL * @return string */ public function getUserPermalink( $absolute = false ) { return User::permalink( $this->getUserUID(), $absolute ); } } /** * A mailbox */ class User extends Sessionuser { use UserTrait; /** * Constructor */ public function __construct() { $this->normalizeUser(); } /** * Get the known user roles * * @return array */ public static function roles() { return [ 'user' => __( "User" ), 'admin' => __( "Admin" ), ]; } /** * Get the User permalink * - * @param string $user User UID - * @param boolean $absolute + * @param string $uid User UID + * @param boolean $absolute Set to true for an absolute URL * @return string */ - public static function permalink( $user = null, $absolute = false ) { + public static function permalink( $uid = null, $absolute = false ) { $part = site_page( 'user.php', $absolute ); - if( $user ) { - $part .= _ . $user; + if( $uid ) { + $part .= _ . $uid; } return $part; } }