1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16: class IMP_Mime_Viewer_Status extends Horde_Mime_Viewer_Base
17: {
18: 19: 20: 21: 22:
23: protected $_capability = array(
24: 'full' => false,
25: 'info' => true,
26: 'inline' => true,
27: 'raw' => false
28: );
29:
30: 31: 32: 33: 34:
35: protected $_metadata = array(
36: 'compressed' => false,
37: 'embedded' => false,
38: 'forceinline' => true
39: );
40:
41: 42: 43: 44: 45:
46: protected function _renderInline()
47: {
48: return $this->_renderInfo();
49: }
50:
51: 52: 53: 54: 55:
56: protected function _renderInfo()
57: {
58: $parts = array_keys($this->_mimepart->contentTypeMap());
59:
60: 61: 62: 63: 64: 65: 66: 67: 68:
69:
70: if (count($parts) < 2) {
71: return array();
72: }
73:
74: reset($parts);
75: $part1_id = next($parts);
76: $part2_id = Horde_Mime::mimeIdArithmetic($part1_id, 'next');
77: $part3_id = Horde_Mime::mimeIdArithmetic($part2_id, 'next');
78:
79:
80: $action = null;
81: $part2 = $this->getConfigParam('imp_contents')->getMIMEPart($part2_id);
82:
83: foreach (explode("\n", $part2->getContents()) as $line) {
84: if (stristr($line, 'Action:') !== false) {
85: $action = strtolower(trim(substr($line, strpos($line, ':') + 1)));
86: if (strpos($action, ' ') !== false) {
87: $action = substr($action, 0, strpos($action, ' '));
88: }
89: break;
90: }
91: }
92:
93: if (is_null($action)) {
94: return array();
95: }
96:
97:
98: switch ($action) {
99: case 'failed':
100: case 'delayed':
101: $status = new IMP_Mime_Status(array(
102: _("ERROR: Your message could not be delivered."),
103: sprintf(_("Technical error details can be viewed %s."), $this->getConfigParam('imp_contents')->linkViewJS($part2, 'view_attach', _("HERE"), array('jstext' => _("Technical details"), 'params' => array('ctype' => 'text/plain', 'mode' => IMP_Contents::RENDER_FULL))))
104: ));
105: $status->action(IMP_Mime_Status::ERROR);
106: $msg_link = _("The text of the returned message can be viewed %s.");
107: $msg_link_status = _("The text of the returned message");
108: break;
109:
110: case 'delivered':
111: case 'expanded':
112: case 'relayed':
113: $status = new IMP_Mime_Status(array(
114: _("Your message was successfully delivered."),
115: sprintf(_("Technical message details can be viewed %s."), $this->getConfigParam('imp_contents')->linkViewJS($part2, 'view_attach', _("HERE"), array('jstext' => _("Technical details"), 'params' => array('ctype' => 'text/x-simple', 'mode' => IMP_Contents::RENDER_FULL))))
116: ));
117: $status->action(IMP_Mime_Status::SUCCESS);
118: $msg_link = _("The text of the message can be viewed %s.");
119: $msg_link_status = _("The text of the message");
120: break;
121: }
122:
123:
124: $part3 = $this->getConfigParam('imp_contents')->getMIMEPart($part3_id);
125: if ($part3) {
126: $status->addText(sprintf($msg_link, $this->getConfigParam('imp_contents')->linkViewJS($part3, 'view_attach', _("HERE"), array('jstext' => $msg_link_status, 'params' => array('ctype' => 'message/rfc822')))));
127: }
128:
129: $ret = array_fill_keys(array_diff($parts, array($part1_id)), null);
130:
131: $ret[$this->_mimepart->getMimeId()] = array(
132: 'data' => '',
133: 'status' => $status,
134: 'type' => 'text/html; charset=' . $this->getConfigParam('charset'),
135: 'wrap' => 'mimePartWrap'
136: );
137:
138: return $ret;
139: }
140:
141: }
142: