Skip to content

Commit

Permalink
Split out date data generation
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Jan 16, 2015
1 parent 1641f52 commit a3664b6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
5 changes: 5 additions & 0 deletions imp/lib/Ajax/Queue.php
Expand Up @@ -468,6 +468,11 @@ public function message(IMP_Indices $indices, array $opts = array())
$msg->subjectlink = $subject['subjectlink'];
}

if ($date = $show_msg->getDateOb()) {
$msg->datestamp = $date->format($date::DATE_ISO_8601);
$msg->localdate = $date->format($date::DATE_LOCAL);
}

$this->maillog($indices);
$show_msg->addChangedFlag();

Expand Down
25 changes: 13 additions & 12 deletions imp/lib/Contents/Message.php
Expand Up @@ -118,10 +118,7 @@ public function __construct(IMP_Indices $indices, $peek = false)
* - list: (array) Attachment information.
* - bcc: (array) The Bcc addresses.
* - cc: (array) The CC addresses.
* - datestamp: (string) ISO 8601 date string.
* - fulldate: (string) The full canonical date.
* - from: (array) The From addresses.
* - localdate: (string) The date formatted to the user's timezone.
* - md: (array) Metadata.
* - msgtext: (string) The text of the message.
* - onepart: (boolean) True if message only contains one part.
Expand All @@ -142,15 +139,6 @@ public function showMessage()
}
}

/* Build the date information. */
if ($date = $this->_envelope->date) {
$date_ob = new IMP_Message_Date($date);
$val = $date_ob->format($date_ob::DATE_LOCAL);
$result['datestamp'] = $date_ob->format($date_ob::DATE_ISO_8601);
$result['fulldate'] = $date_ob->format($date_ob::DATE_FORCE);
$result['localdate'] = $val;
}

// Create message text and attachment list.
$result['msgtext'] = '';
$part_info = $this->part_info;
Expand Down Expand Up @@ -441,6 +429,19 @@ public function getSubject()
return $this->_cache['subject'];
}

/**
* Return date data.
*
* @return mixed Either a IMP_Message_Date object or null if no date
* information is available.
*/
public function getDateOb()
{
return ($date = $this->_envelope->date)
? new IMP_Message_Date($date)
: null;
}

/**
* Return the save link for the message source.
*
Expand Down
8 changes: 4 additions & 4 deletions imp/lib/Dynamic/Message.php
Expand Up @@ -156,10 +156,10 @@ protected function _init()

$this->view->save_as = $show_msg->getSaveAs();

if (isset($msg_res['datestamp'])) {
$this->view->datestamp = $msg_res['datestamp'];
$this->view->fulldate = $msg_res['fulldate'];
$this->view->localdate = $msg_res['localdate'];
if ($date = $show_msg->getDateOb()) {
$this->view->datestamp = $date->format($date::DATE_ISO_8601);
$this->view->fulldate = $date->format($date::DATE_FORCE);
$this->view->localdate = $date->format($date::DATE_LOCAL);
$this->view->addHelper('Text');
}

Expand Down

0 comments on commit a3664b6

Please sign in to comment.