Exemplo n.º 1
0
 /**
  * Prepares TO, CC and BCC recipients
  *
  * @param Psn_Model_Rule $rule
  * @param $post
  */
 protected function _prepareRecipients(Psn_Model_Rule $rule, $post)
 {
     // recipient handling (To, Cc, Bcc)
     $recipientSelections = array(array('name' => 'recipient_selection', 'modelGetter' => 'getRecipient', 'serviceAdder' => 'addTo', 'custom_field_name' => 'to'), array('name' => 'cc_selection', 'modelGetter' => 'getCcSelect', 'serviceAdder' => 'addCc', 'custom_field_name' => 'cc'), array('name' => 'bcc_selection', 'modelGetter' => 'getBccSelect', 'serviceAdder' => 'addBcc', 'custom_field_name' => 'bcc'));
     foreach ($recipientSelections as $recSel) {
         $recipient = $rule->{$recSel}['modelGetter']();
         if (in_array('admin', $recipient)) {
             $this->{$recSel}['serviceAdder'](IfwPsn_Wp_Proxy_Blog::getAdminEmail());
         }
         if (in_array('author', $recipient)) {
             $this->{$recSel}['serviceAdder'](IfwPsn_Wp_Proxy_User::getEmail($post->post_author));
         }
         // handle dynamic recipients managed by modules
         IfwPsn_Wp_Proxy_Action::doAction('psn_service_email_' . $recSel['name'], $this);
         // check for custom recipient
         $custom_recipient = $rule->get($recSel['custom_field_name']);
         if (!empty($custom_recipient)) {
             $custom_recipient = $rule->getReplacer()->replace($custom_recipient);
             $customRecipientStack = explode(',', $custom_recipient);
             foreach ($customRecipientStack as $customRecipientEmail) {
                 $this->{$recSel}['serviceAdder'](trim($customRecipientEmail));
             }
         }
     }
 }