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