public function PrivateMessageMapper::checkPrivateMessageMemberExists in Private Message 8.2
Same name and namespace in other branches
- 8 src/Mapper/PrivateMessageMapper.php \Drupal\private_message\Mapper\PrivateMessageMapper::checkPrivateMessageMemberExists()
Determine whether or not the given username exists.
The user must also have the 'use private messaging system' permission.
Parameters
string $username: The username to be validated.
Return value
bool
- TRUE if the belongs to an account that has the 'use private messaging system' permission
- FALSE if the account doesn't exist, or does not have the required permission
Overrides PrivateMessageMapperInterface::checkPrivateMessageMemberExists
File
- src/
Mapper/ PrivateMessageMapper.php, line 236
Class
- PrivateMessageMapper
- Interface for the Private Message Mapper class.
Namespace
Drupal\private_message\MapperCode
public function checkPrivateMessageMemberExists($username) {
return $this->database
->queryRange('SELECT 1 FROM {users_field_data} AS user_data ' . 'LEFT JOIN {user__roles} AS user_roles ' . 'ON user_roles.entity_id = user_data.uid ' . 'LEFT JOIN {config} AS role_config ' . "ON role_config.name = CONCAT('user.role.', user_roles.roles_target_id) " . 'LEFT JOIN {config} AS authenticated_config ' . 'ON authenticated_config.name = :authenticated_user_role ' . 'WHERE user_data.name = :username ' . 'AND user_roles.roles_target_id IN (:rids[]) ' . 'AND user_data.status = 1', 0, 1, [
':username' => $username,
':authenticated_user_role' => 'user.role.authenticated',
':rids[]' => $this
->getCanUseRids(),
])
->fetchField();
}