protected function _sendIntroductionMail(array $attributes)
 {
     if (!isset($attributes['urn:mace:dir:attribute-def:mail'])) {
         return;
     }
     $config = EngineBlock_ApplicationSingleton::getInstance()->getConfiguration();
     if (!isset($config->email->sendWelcomeMail) || !$config->email->sendWelcomeMail) {
         return;
     }
     $emailAddress = $attributes['urn:mace:dir:attribute-def:mail'][0];
     $this->_mailer->sendMail($emailAddress, EngineBlock_Corto_Module_Services::INTRODUCTION_EMAIL, array('{user}' => $this->_preferredNameAttributeFilter->getAttribute($attributes)));
 }
 protected function _sendIntroductionMail($response, $attributes)
 {
     if (!isset($attributes['urn:mace:dir:attribute-def:mail'])) {
         return;
     }
     $config = EngineBlock_ApplicationSingleton::getInstance()->getConfiguration();
     if (!isset($config->email->sendWelcomeMail) || !$config->email->sendWelcomeMail) {
         return;
     }
     $dbh = $this->_getConsentDatabaseConnection();
     $hashedUserId = sha1($this->_getConsentUid($response, $attributes));
     $query = "SELECT COUNT(*) FROM consent where hashed_user_id = ?";
     $parameters = array($hashedUserId);
     $statement = $dbh->prepare($query);
     $statement->execute($parameters);
     $timesUserGaveConsent = (int) $statement->fetchColumn();
     //we only send a mail if an user provides consent the first time
     if ($timesUserGaveConsent > 1) {
         return;
     }
     $mailer = new EngineBlock_Mail_Mailer();
     $emailAddress = $attributes['urn:mace:dir:attribute-def:mail'][0];
     $mailer->sendMail($emailAddress, EngineBlock_Corto_Module_Services::INTRODUCTION_EMAIL, array('{user}' => $this->_getUserName($attributes)));
 }
 protected function _sendTeamMemberWarning(array $users, $timeOffset)
 {
     $deprovisionTime = date('d-m-Y', $timeOffset);
     $mailer = new EngineBlock_Mail_Mailer();
     $grouperClient = $this->_getGrouperClient();
     foreach ($users as $userId => $user) {
         $grouperClient->setSubjectId($userId);
         $groups = $grouperClient->getGroups();
         foreach ($groups as $group) {
             /* @var $group Grouper_Model_Group */
             $members = $grouperClient->getMembersWithPrivileges($group->name);
             if ($this->_isUserOnlyAdmin($members, $userId)) {
                 // send the actual email to group members
                 foreach ($members as $member) {
                     // Do not send the mail to the user that is to be deprovisioned
                     if ($member->id != $userId) {
                         /* @var $member Grouper_Model_Subject */
                         $user = $this->_getLdapUser($member->id);
                         $replacements = array('{user}' => $member->name, '{team}' => $group->displayName, '{deprovision_time}' => $deprovisionTime);
                         $emailAddress = $user['emails'][0];
                         $mailer->sendMail($emailAddress, EngineBlock_Deprovisioning::DEPROVISION_WARNING_EMAIL_GROUP_MEMBERS, $replacements);
                     }
                 }
             }
             // do nothing if user is not the admin or the only admin
         }
     }
 }