private function prepareEmailAddresses() { $authorname = $this->Users->getUserDetails($this->author); $addresses = array(); foreach ($this->subscriberToSend as $ss => $item) { $groupname = $ss; if ($groupname == 'ungroupped') { $fromname = !empty($authorname['settings'][0]['name']) ? $authorname['settings'][0]['name'] : $this->author; $fromaddress = Helper::getUserAlias($this->author, $this->projectName); $replyto = Helper::getUserAlias($this->author, $this->projectName, $this->hash); } else { $fromname = $groupname; $fromaddress = Helper::getGroupAlias($groupname, $this->projectName); $replyto = Helper::getGroupAlias($groupname, $this->projectName, $this->hash); } foreach ($item['groupusers'] as $gu => $user) { if (!empty($user['settings'][0])) { $addresses[] = ['name' => !empty($user['settings'][0]['name']) ? $user['settings'][0]['name'] : $gu, 'email' => $user['settings'][0]['email'], 'groupname' => $groupname, 'fromname' => $fromname, 'fromaddress' => $fromaddress, 'replyto' => $replyto]; } } } return $addresses; }