Page MenuHomestyx hydra

PhabricatorMetaMTAListController.php
No OneTemporary

PhabricatorMetaMTAListController.php

<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class PhabricatorMetaMTAListController
extends PhabricatorMetaMTAController {
public function processRequest() {
// Get a page of mails together with pager.
$request = $this->getRequest();
$user = $request->getUser();
$offset = $request->getInt('offset', 0);
$related_phid = $request->getStr('phid');
$status = $request->getStr('status');
$pager = new AphrontPagerView();
$pager->setOffset($offset);
$pager->setURI($request->getRequestURI(), 'offset');
$mail = new PhabricatorMetaMTAMail();
$conn_r = $mail->establishConnection('r');
$wheres = array();
if ($status) {
$wheres[] = qsprintf(
$conn_r,
'status = %s',
$status);
}
if ($related_phid) {
$wheres[] = qsprintf(
$conn_r,
'relatedPHID = %s',
$related_phid);
}
if (count($wheres)) {
$where_clause = 'WHERE '.implode($wheres, ' AND ');
} else {
$where_clause = 'WHERE 1 = 1';
}
$data = queryfx_all(
$conn_r,
'SELECT * FROM %T
%Q
ORDER BY id DESC
LIMIT %d, %d',
$mail->getTableName(),
$where_clause,
$pager->getOffset(), $pager->getPageSize() + 1);
$data = $pager->sliceResults($data);
$mails = $mail->loadAllFromArray($data);
// Render the details table.
$rows = array();
foreach ($mails as $mail) {
$next_retry = $mail->getNextRetry() - time();
if ($next_retry <= 0) {
$next_retry = "None";
} else {
$next_retry = phabricator_format_relative_time_detailed($next_retry);
}
$rows[] = array(
PhabricatorMetaMTAMail::getReadableStatus($mail->getStatus()),
$mail->getRetryCount(),
$next_retry,
phabricator_datetime($mail->getDateCreated(), $user),
phabricator_format_relative_time_detailed(
time() - $mail->getDateModified()),
phutil_escape_html($mail->getSubject()),
phutil_render_tag(
'a',
array(
'class' => 'button small grey',
'href' => $this->getApplicationURI('/view/'.$mail->getID().'/'),
),
'View'),
);
}
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
'Status',
'Retry',
'Next',
'Created',
'Updated',
'Subject',
'',
));
$table->setColumnClasses(
array(
null,
null,
null,
null,
null,
'wide',
'action',
));
// Render the whole page.
$panel = new AphrontPanelView();
$panel->appendChild($table);
$panel->setHeader('MetaMTA Messages');
$panel->appendChild($pager);
$nav = $this->buildSideNavView();
$nav->selectFilter('sent');
$nav->appendChild($panel);
return $this->buildApplicationPage(
$nav,
array(
'title' => 'Sent Mail',
));
}
}

File Metadata

Mime Type
text/x-php
Expires
Mon, Nov 24, 2:47 PM (4 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
399739
Default Alt Text
PhabricatorMetaMTAListController.php (3 KB)

Event Timeline