-
Notifications
You must be signed in to change notification settings - Fork 4
/
details.php
114 lines (104 loc) · 3.34 KB
/
details.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
// Copyright (C) 2013 Combodo SARL
//
// This file is part of iTop.
//
// iTop is free software; you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// iTop is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
/**
* Processing of AJAX calls for the CalendarView
*
* @copyright Copyright (C) 2013 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
use Combodo\iTop\Application\UI\Base\Component\Panel\PanelUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
require_once('../approot.inc.php');
/**
* @param \iTopWebPage $oPage
* @param $sUIDL
*
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
*/
function GetMessageDetails($oPage, $sUIDL)
{
$oReplicaSearch = new DBObjectSearch('EmailReplica');
$oReplicaSearch->AddCondition('uidl', $sUIDL);
$oReplicaSet = new DBObjectSet($oReplicaSearch);
$oReplica = $oReplicaSet->Fetch();
if (empty($oReplica))
{
return;
}
$oPage->set_title(Dict::S('MailInbox:MessageDetails'));
if(MailInboxBase::UseLegacy()){
$oPage->add('<h2>'.Dict::S('MailInbox:MessageDetails').'</h2>');
}
else{
$oPanel = PanelUIBlockFactory::MakeForInformation(Dict::S('MailInbox:MessageDetails'));
$oPage->AddUiBlock($oPanel);
}
// Display the eml link
$iDocId = $oReplica->GetKey();
/** @var \ormDocument $oDoc */
$oDoc = $oReplica->Get('contents');
if (!$oDoc->IsEmpty())
{
$sDownloadURL = $oDoc->GetDownloadURL('EmailReplica', $iDocId, 'contents');
if(MailInboxBase::UseLegacy()){
$oPage->add('<h3><div class="attachment" id="display_attachment_'.$iDocId.'"><a href="'.$sDownloadURL.'">'.Dict::S('MailInbox:DownloadEml').'</a></div></h3>');
}
else{
$oSubtitle = new UIContentBlock();
$oSubtitle->AddHtml('<a href="'.$sDownloadURL.'">'.Dict::S('MailInbox:DownloadEml').'</a>');
$oPanel->SetSubTitleBlock($oSubtitle);
}
}
$aList = array('message_date', 'status', 'error_message', 'error_trace');
$aValues = array();
foreach($aList as $sAttCode)
{
$aValues[$sAttCode] = array('label' => MetaModel::GetLabel(get_class($oReplica), $sAttCode), 'value' => $oReplica->GetAsHTML($sAttCode));
}
if(MailInboxBase::UseLegacy()){
$oPage->details($aValues);
}
else{
$oPanel->AddHtml($oPage->GetDetails($aValues));
$oPage->AddUiBlock($oPanel);
}
}
try
{
require_once(APPROOT.'/application/startup.inc.php');
require_once(APPROOT.'/application/loginwebpage.class.inc.php');
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
$oPage = new iTopWebPage("");
$sOperation = utils::ReadParam('operation', '');
switch($sOperation)
{
case 'message_details':
$sUIDL = utils::ReadParam('sUIDL', 0, false, 'raw_data');
GetMessageDetails($oPage, $sUIDL);
break;
}
$oPage->output();
}
catch(Exception $e)
{
$oPage->SetContentType('text/html');
$oPage->add($e->getMessage());
$oPage->output();
}