NotificationTarget::getReplyTo PHP Method

getReplyTo() public method

Get the reply to address
public getReplyTo ( $options = [] ) : the
$options array
return the reply to address
    function getReplyTo($options = array())
    {
        global $DB, $CFG_GLPI;
        //If the entity administrator's address is defined, return it
        foreach ($DB->request('glpi_entities', array('id' => $this->getEntity())) as $data) {
            if (NotificationMail::isUserAddressValid($data['admin_reply'])) {
                return array('email' => $data['admin_reply'], 'name' => $data['admin_reply_name']);
            }
        }
        //Entity admin is not defined, return the global admin's address
        return array('email' => $CFG_GLPI['admin_reply'], 'name' => $CFG_GLPI['admin_reply_name']);
    }

Usage Example

Example #1
0
 /**
  * @param $target              NotificationTarget object
  * @param $tid          string template computed id
  * @param $user_infos   array
  * @param $options      array
  **/
 function getDataToSend(NotificationTarget $target, $tid, array $user_infos, array $options)
 {
     $language = $user_infos['language'];
     $user_email = $user_infos['email'];
     $user_name = $user_infos['username'];
     $sender = $target->getSender($options);
     $replyto = $target->getReplyTo($options);
     $mailing_options['to'] = $user_email;
     $mailing_options['toname'] = $user_name;
     $mailing_options['from'] = $sender['email'];
     $mailing_options['fromname'] = $sender['name'];
     $mailing_options['replyto'] = $replyto['email'];
     $mailing_options['replytoname'] = $replyto['name'];
     $mailing_options['messageid'] = $target->getMessageID();
     $template_data = $this->templates_by_languages[$tid];
     $mailing_options['subject'] = $template_data['subject'];
     $mailing_options['content_html'] = $template_data['content_html'];
     $mailing_options['content_text'] = $template_data['content_text'];
     $mailing_options['items_id'] = $target->obj->getField('id');
     if (isset($target->obj->documents)) {
         $mailing_options['documents'] = $target->obj->documents;
     }
     return $mailing_options;
 }
All Usage Examples Of NotificationTarget::getReplyTo