public function findMembers(Area $area) { $items = $this->conn->fetchAll('SELECT u.name, u.avatar, p.location, p.telephone, p.publicMail, p.privShowTelephone, p.privShowPublicMail, m.note ' . 'FROM `' . CoreTables::USER_TBL . '` u ' . 'INNER JOIN `' . CoreTables::USER_PROFILE_TBL . '` p ON p.`userId` = u.`id` ' . 'INNER JOIN `' . CoreTables::AREA_MEMBER_TBL . '` m ON m.`userId` = u.`id` ' . 'WHERE m.`areaId` = :areaId ORDER BY m.`role` DESC, u.`name`', [':areaId' => $area->getId()]); foreach ($items as &$item) { $item['publicMail'] = User::evaluateUserPrivacy($item['privShowPublicMail'], $this->project) ? $item['publicMail'] : ''; $item['telephone'] = User::evaluateUserPrivacy($item['privShowTelephone'], $this->project) ? $item['telephone'] : ''; } return $items; }
/** * Displays the information about the group members for members of the given other entity. * * @param Connection $conn * @param MembershipEntityInterface $entity Another entity that views the information about members. * @return array */ public function findMemberInformationForEntity(Connection $conn, MembershipEntityInterface $entity) { $stmt = $conn->prepare('SELECT u.id, u.name, u.avatar, u.lastVisit, p.location, p.telephone, p.publicMail, p.privShowTelephone, p.privShowPublicMail, m.note ' . 'FROM `' . CoreTables::USER_TBL . '` u ' . 'INNER JOIN `' . CoreTables::USER_PROFILE_TBL . '` p ON p.`userId` = u.`id` ' . 'INNER JOIN `' . CoreTables::GROUP_MEMBER_TBL . '` m ON m.`userId` = u.`id` ' . 'WHERE m.`groupId` = :groupId ORDER BY m.role DESC, u.name'); $stmt->bindValue(':groupId', $this->getId()); $stmt->execute(); $result = array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $row['privShowTelephone'] = User::evaluateUserPrivacy($row['privShowTelephone'], $entity); $row['privShowPublicMail'] = User::evaluateUserPrivacy($row['privShowPublicMail'], $entity); $result[] = $row; } $stmt->closeCursor(); return $result; }