null , 'lst' => '' , 'ssttid' => '' , 'dest' => '' , 'reason' => '' ); $params = array_merge($default, $params); $dom_xml = new DOMDocument('1.0', 'UTF-8'); $dom_xml->preserveWhiteSpace = false; $dom_xml->formatOutput = true; $root = $dom_xml->createElement('datas'); $lst = $dom_xml->createElement('lst'); $ssttid = $dom_xml->createElement('ssttid'); $dest = $dom_xml->createElement('dest'); $reason = $dom_xml->createElement('reason'); $lst->appendChild($dom_xml->createTextNode($params['lst'])); $ssttid->appendChild($dom_xml->createTextNode($params['ssttid'])); $dest->appendChild($dom_xml->createTextNode($params['dest'])); $reason->appendChild($dom_xml->createTextNode($params['reason'])); $root->appendChild($lst); $root->appendChild($ssttid); $root->appendChild($dest); $root->appendChild($reason); $dom_xml->appendChild($root); $datas = $dom_xml->saveXml(); $mailed = false; if ($this->shouldSendNotificationFor($params['usr_id'])) { if (parent::email()) $mailed = true; } $this->broker->notify($params['usr_id'], __CLASS__, $datas, $mailed); return; } /** * * @param Array $datas * @param boolean $unread * @return Array */ public function datas($datas, $unread) { $sx = simplexml_load_string($datas); $reason = (int) $sx->reason; $dest = (string) $sx->dest; if ($reason == self::MAIL_NO_VALID) { $reason = _('email is not valid'); } elseif ($reason == self::MAIL_FAIL) { $reason = _('failed to send mail'); } else { $reason = _('an error occured while exporting records'); } $text = sprintf( _("The delivery to %s failed for the following reason : %s") , $dest , $reason ); $ret = array( 'text' => $text , 'class' => '' ); return $ret; } /** * * @return string */ public function get_name() { return _('Email export fails'); } /** * * @return string */ public function get_description() { return _('Get a notification when a mail export fails'); } /** * @param integer $usr_id The id of the user to check * * @return boolean */ public function is_available($usr_id) { return true; } }