Implemented new type: mail

* display and link clientside mails to other types and events
 * fixed favorites menu for new types
 * fixed sorting column triggered spells in enchantment listview
 * some misc cleanups
This commit is contained in:
Sarjuuk
2018-12-15 01:49:55 +01:00
parent ccef11323b
commit fd04e9f977
38 changed files with 682 additions and 171 deletions

View File

@@ -433,7 +433,7 @@ Markup.printHtml("description text here", "description-generic", { allow: Markup
);
if (!$ok)
return Lang::main('intError');
else if ($_ = $this->sendMail(Lang::mail('accConfirm', 0), sprintf(Lang::mail('accConfirm', 1), $token), CFG_ACC_CREATE_SAVE_DECAY))
else if ($_ = $this->sendMail(Lang::user('accConfirm', 0), sprintf(Lang::user('accConfirm', 1), $token), CFG_ACC_CREATE_SAVE_DECAY))
{
if ($id = DB::Aowow()->selectCell('SELECT id FROM ?_account WHERE token = ?', $token))
Util::gainSiteReputation($id, SITEREP_ACTION_REGISTER);
@@ -454,7 +454,7 @@ Markup.printHtml("description text here", "description-generic", { allow: Markup
return $_;
// send recovery mail
return $this->sendMail(Lang::mail('resetPass', 0), sprintf(Lang::mail('resetPass', 1), $token), CFG_ACC_RECOVERY_DECAY);
return $this->sendMail(Lang::user('resetPass', 0), sprintf(Lang::user('resetPass', 1), $token), CFG_ACC_RECOVERY_DECAY);
}
private function doResetPass()
@@ -486,7 +486,7 @@ Markup.printHtml("description text here", "description-generic", { allow: Markup
return $_;
// send recovery mail
return $this->sendMail(Lang::mail('recoverUser', 0), sprintf(Lang::mail('recoverUser', 1), $token), CFG_ACC_RECOVERY_DECAY);
return $this->sendMail(Lang::user('recoverUser', 0), sprintf(Lang::user('recoverUser', 1), $token), CFG_ACC_RECOVERY_DECAY);
}
private function initRecovery($type, $delay, &$token)
@@ -508,7 +508,7 @@ Markup.printHtml("description text here", "description-generic", { allow: Markup
{
// send recovery mail
$subj = CFG_NAME_SHORT.Lang::main('colon') . $subj;
$msg .= "\r\n\r\n".sprintf(Lang::mail('tokenExpires'), Util::formatTime($delay * 1000))."\r\n";
$msg .= "\r\n\r\n".sprintf(Lang::user('tokenExpires'), Util::formatTime($delay * 1000))."\r\n";
$header = 'From: '.CFG_CONTACT_EMAIL . "\r\n" .
'Reply-To: '.CFG_CONTACT_EMAIL . "\r\n" .
'X-Mailer: PHP/' . phpversion();

View File

@@ -572,12 +572,13 @@ class AchievementPage extends GenericPage
if ($_ = $this->subject->getField('mailTemplate'))
{
$letter = DB::Aowow()->selectRow('SELECT * FROM ?_mailtemplate WHERE id = ?d', $_);
$letter = DB::Aowow()->selectRow('SELECT * FROM ?_mails WHERE id = ?d', $_);
if (!$letter)
return [];
$reqCss = true;
$mail = array(
'id' => $_,
'delay' => null,
'sender' => null,
'attachments' => [],
@@ -589,6 +590,7 @@ class AchievementPage extends GenericPage
{
$reqCss = true;
$mail = array(
'id' => -$this->typeId,
'delay' => null,
'sender' => null,
'attachments' => [],
@@ -598,7 +600,7 @@ class AchievementPage extends GenericPage
}
if ($_ = CreatureList::getName($this->subject->getField('sender')))
$mail['sender'] = sprintf(Lang::quest('mailBy'), $this->subject->getField('sender'), $_);
$mail['sender'] = sprintf(Lang::mail('mailBy'), $this->subject->getField('sender'), $_);
return $mail;
}

View File

@@ -213,6 +213,7 @@ class GenericPage
'icongallery' => ['template' => 'icongallery', 'id' => 'icons', 'parent' => 'lv-generic', 'data' => [] ],
'item' => ['template' => 'item', 'id' => 'items', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_items' ],
'itemset' => ['template' => 'itemset', 'id' => 'itemsets', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_itemsets' ],
'mail' => ['template' => 'mail', 'id' => 'mails', 'parent' => 'lv-generic', 'data' => [] ],
'model' => ['template' => 'model', 'id' => 'gallery', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_gallery' ],
'object' => ['template' => 'object', 'id' => 'objects', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_objects' ],
'pet' => ['template' => 'pet', 'id' => 'hunter-pets', 'parent' => 'lv-generic', 'data' => [], 'name' => '$LANG.tab_pets' ],

168
pages/mail.php Normal file
View File

@@ -0,0 +1,168 @@
<?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::ucFirst($this->subject->getField('subject', true));
if (!$this->name)
$this->name = Lang::mail('untitled');
}
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'];
if ($r = Lang::getRaceString($mlr['raceMask'], $rId, $_, false))
{
$infobox[] = Lang::game('races').Lang::main('colon').$r;
$this->extendGlobalIds(TYPE_RACE, $rId);
}
$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, $this->name, Util::ucFirst(Lang::game('mail')));
}
protected function generatePath() { }
}
?>

46
pages/mails.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
// menuId 103: Mail g_initPath()
// tabid 0: Database g_initHeader()
class MailsPage extends GenericPage
{
use TrListPage;
protected $type = TYPE_MAIL;
protected $tpl = 'list-page-generic';
protected $path = [0, 103];
protected $tabId = 0;
protected $mode = CACHE_TYPE_PAGE;
public function __construct($pageCall, $pageParam)
{
parent::__construct($pageCall, $pageParam);
$this->name = Util::ucFirst(Lang::game('mails'));
}
protected function generateContent()
{
$tabData = [];
$mails = new MailList();
if (!$mails->error)
$tabData['data'] = array_values($mails->getListviewData());
$this->extendGlobalData($mails->getJsGlobals());
$this->lvTabs[] = ['mail', $tabData, 'mail'];
}
protected function generateTitle()
{
array_unshift($this->title, $this->name);
}
protected function generatePath() { }
}
?>

View File

@@ -1226,10 +1226,11 @@ class QuestPage extends GenericPage
if ($rmtId = $this->subject->getField('rewardMailTemplateId'))
{
$delay = $this->subject->getField('rewardMailDelay');
$letter = DB::Aowow()->selectRow('SELECT * FROM ?_mailtemplate WHERE id = ?d', $rmtId);
$letter = DB::Aowow()->selectRow('SELECT * FROM ?_mails WHERE id = ?d', $rmtId);
$mail = array(
'delay' => $delay ? sprintf(Lang::quest('mailIn'), Util::formatTime($delay * 1000)) : null,
'id' => $rmtId,
'delay' => $delay ? sprintf(Lang::mail('mailIn'), Util::formatTime($delay * 1000)) : null,
'sender' => null,
'attachments' => [],
'text' => $letter ? Util::parseHtmlText(Util::localizedString($letter, 'text')) : null,
@@ -1245,7 +1246,7 @@ class QuestPage extends GenericPage
$senderTypeId = $se['typeId'];
if ($ti = CreatureList::getName($senderTypeId))
$mail['sender'] = sprintf(Lang::quest('mailBy'), $senderTypeId, $ti);
$mail['sender'] = sprintf(Lang::mail('mailBy'), $senderTypeId, $ti);
// while mail attachemnts are handled as loot, it has no variance. Always 100% chance, always one item.
$mailLoot = new Loot();