-
Notifications
You must be signed in to change notification settings - Fork 217
/
Copy pathmail.php
167 lines (139 loc) · 6.39 KB
/
mail.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
// menuId 103: Mail g_initPath()
// tabId 0: Database g_initHeader()
class MailPage extends GenericPage
{
use TrDetailPage;
protected $type = Type::MAIL;
protected $typeId = 0;
protected $tpl = 'detail-page-generic';
protected $path = [0, 103];
protected $tabId = 0;
protected $mode = CACHE_TYPE_PAGE;
public function __construct($pageCall, $id)
{
parent::__construct($pageCall, $id);
$this->typeId = intVal($id);
$this->subject = new MailList(array(['id', $this->typeId]));
if ($this->subject->error)
$this->notFound(lang::game('mail'), Lang::mail('notFound'));
$this->extendGlobalData($this->subject->getJSGlobals());
$this->name = Util::htmlEscape(Util::ucFirst($this->subject->getField('name', true)));
}
protected function generateContent()
{
/***********/
/* Infobox */
/***********/
$infobox = [];
// sender + delay
if ($this->typeId < 0) // def. achievement
{
if ($npcId = DB::World()->selectCell('SELECT Sender FROM achievement_reward WHERE ID = ?d', -$this->typeId))
{
$infobox[] = Lang::mail('sender').Lang::main('colon').'[npc='.$npcId.']';
$this->extendGlobalIds(Type::NPC, $npcId);
}
}
else if ($mlr = DB::World()->selectRow('SELECT * FROM mail_level_reward WHERE mailTemplateId = ?d', $this->typeId)) // level rewards
{
if ($mlr['level'])
$infobox[] = Lang::game('level').Lang::main('colon').$mlr['level'];
$rIds = [];
if ($r = Lang::getRaceString($mlr['raceMask'], $rIds, Lang::FMT_MARKUP))
{
$infobox[] = Lang::game('races').Lang::main('colon').$r;
$this->extendGlobalIds(Type::CHR_RACE, ...$rIds);
}
$infobox[] = Lang::mail('sender').Lang::main('colon').'[npc='.$mlr['senderEntry'].']';
$this->extendGlobalIds(Type::NPC, $mlr['senderEntry']);
}
else // achievement or quest
{
if ($q = DB::Aowow()->selectRow('SELECT id, rewardMailDelay FROM ?_quests WHERE rewardMailTemplateId = ?d', $this->typeId))
{
if ($npcId= DB::World()->selectCell('SELECT RewardMailSenderEntry FROM quest_mail_sender WHERE QuestId = ?d', $q['id']))
{
$infobox[] = Lang::mail('sender').Lang::main('colon').'[npc='.$npcId.']';
$this->extendGlobalIds(Type::NPC, $npcId);
}
else if ($npcId = DB::Aowow()->selectCell('SELECT typeId FROM ?_quests_startend WHERE questId = ?d AND type = ?d AND method & ?d', $q['id'], Type::NPC, 0x2))
{
$infobox[] = Lang::mail('sender').Lang::main('colon').'[npc='.$npcId.']';
$this->extendGlobalIds(Type::NPC, $npcId);
}
if ($q['rewardMailDelay'] > 0)
$infobox[] = Lang::mail('delay').Lang::main('colon').''.Util::formatTime($q['rewardMailDelay'] * 1000);
}
else if ($npcId = DB::World()->selectCell('SELECT Sender FROM achievement_reward WHERE MailTemplateId = ?d', $this->typeId))
{
$infobox[] = Lang::mail('sender').Lang::main('colon').'[npc='.$npcId.']';
$this->extendGlobalIds(Type::NPC, $npcId);
}
}
/****************/
/* Main Content */
/****************/
$this->infobox = $infobox ? '[ul][li]'.implode('[/li][li]', $infobox).'[/li][/ul]' : '';
$this->redButtons = array(
BUTTON_LINKS => ['type' => $this->type, 'typeId' => $this->typeId],
BUTTON_WOWHEAD => false
);
$this->extraText = Util::parseHtmlText($this->subject->getField('text', true), true);
/**************/
/* Extra Tabs */
/**************/
// tab: attachment
if ($itemId = $this->subject->getField('attachment'))
{
$attachment = new ItemList(array(['id', $itemId]));
if (!$attachment->error)
{
$this->extendGlobalData($attachment->getJsGlobals());
$this->lvTabs[] = [ItemList::$brickFile, array(
'data' => array_values($attachment->getListviewData()),
'name' => Lang::mail('attachment'),
'id' => 'attachment'
)];
}
}
if ($this->typeId < 0 || // used by: achievement
($acvId = DB::World()->selectCell('SELECT ID FROM achievement_reward WHERE MailTemplateId = ?d', $this->typeId)))
{
$ubAchievements = new AchievementList(array(['id', $this->typeId < 0 ? -$this->typeId : $acvId]));
if (!$ubAchievements->error)
{
$this->extendGlobalData($ubAchievements->getJsGlobals());
$this->lvTabs[] = [AchievementList::$brickFile, array(
'data' => array_values($ubAchievements->getListviewData()),
'id' => 'used-by-achievement'
)];
}
}
else if ($npcId = DB::World()->selectCell('SELECT ID FROM achievement_reward WHERE MailTemplateId = ?d', $this->typeId))
{
$infobox[] = '[Sender]: [npc='.$npcId.']';
$this->extendGlobalIds(Type::NPC, $npcId);
}
else // used by: quest
{
$ubQuests = new QuestList(array(['rewardMailTemplateId', $this->typeId]));
if (!$ubQuests->error)
{
$this->extendGlobalData($ubQuests->getJsGlobals());
$this->lvTabs[] = [QuestList::$brickFile, array(
'data' => array_values($ubQuests->getListviewData()),
'id' => 'used-by-quest'
)];
}
}
}
protected function generateTitle()
{
array_unshift($this->title, Util::ucFirst($this->subject->getField('name', true)), Util::ucFirst(Lang::game('mail')));
}
protected function generatePath() { }
}
?>