1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

MetaMetaView

This commit is contained in:
epriestley 2011-01-26 09:08:26 -08:00
parent 7bd6169035
commit a6274d9270
6 changed files with 122 additions and 47 deletions

View file

@ -117,6 +117,7 @@ phutil_register_library_map(array(
'PhabricatorMetaMTAListController' => 'applications/metamta/controller/list',
'PhabricatorMetaMTAMail' => 'applications/metamta/storage/mail',
'PhabricatorMetaMTASendController' => 'applications/metamta/controller/send',
'PhabricatorMetaMTAViewController' => 'applications/metamta/controller/view',
'PhabricatorObjectHandle' => 'applications/phid/handle',
'PhabricatorObjectHandleData' => 'applications/phid/handle/data',
'PhabricatorPHID' => 'applications/phid/storage/phid',
@ -241,6 +242,7 @@ phutil_register_library_map(array(
'PhabricatorMetaMTAListController' => 'PhabricatorMetaMTAController',
'PhabricatorMetaMTAMail' => 'PhabricatorMetaMTADAO',
'PhabricatorMetaMTASendController' => 'PhabricatorMetaMTAController',
'PhabricatorMetaMTAViewController' => 'PhabricatorMetaMTAController',
'PhabricatorPHID' => 'PhabricatorPHIDDAO',
'PhabricatorPHIDAllocateController' => 'PhabricatorPHIDController',
'PhabricatorPHIDController' => 'PhabricatorController',

View file

@ -25,18 +25,42 @@ class PhabricatorMetaMTAListController extends PhabricatorMetaMTAController {
$rows = array();
foreach ($mails as $mail) {
$rows[] = array(
$mail->getID(),
PhabricatorMetaMTAMail::getReadableStatus($mail->getStatus()),
$mail->getRetryCount(),
($mail->getNextRetry() - time()).' s',
date('Y-m-d g:i:s A', $mail->getDateCreated()),
(time() - $mail->getDateModified()).' s',
phutil_escape_html($mail->getSubject()),
phutil_render_tag(
'a',
array(
'class' => 'button small grey',
'href' => '/mail/'.$mail->getID().'/',
),
'View'),
);
}
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
'ID',
'Status',
'Retry',
'Next',
'Created',
'Updated',
'Subject',
'',
));
$table->setColumnClasses(
array(
null,
null,
null,
null,
null,
'wide',
'action',
));
$panel = new AphrontPanelView();

View file

@ -101,45 +101,6 @@ class PhabricatorMetaMTASendController extends PhabricatorMetaMTAController {
array(
'title' => 'Send Mail',
));
/*
return
<metamta:standard-page title="Send Email">
<tools:form width="wide" method="post" action={URI::getRequestURI()}>
<h1>Send Email</h1>
<tools:fieldset>
<tools:instructions>This form will send a normal email using MetaMTA
as a transport mechanism.</tools:instructions>
<tools:control type="text" label="To">
<tools:tokenizer name="to" datasource="mailable" />
</tools:control>
<tools:control type="text" label="CC">
<tools:tokenizer name="cc" datasource="mailable" />
</tools:control>
<tools:control type="text" label="Subject">
<input type="text" name="subject" />
</tools:control>
<tools:control type="textarea" label="Body">
<textarea name="body"></textarea>
</tools:control>
<tools:control type="text" label="Simulate Failures"
caption={$failure_caption}>
<input type="text" name="failures" />
</tools:control>
<tools:control type="checkbox" label="HTML">
<input type="checkbox" name="html" value="1" />
Send as HTML email.
</tools:control>
<tools:control type="checkbox" label="Send Now">
<input type="checkbox" name="immediately" value="1" />
Send immediately, not via MetaMTA daemon.
</tools:control>
<tools:control type="submit">
<button>Send Email</button>
</tools:control>
</tools:fieldset>
</tools:form>
</metamta:standard-page>;
*/
}
}

View file

@ -0,0 +1,69 @@
<?php
/*
* Copyright 2011 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.
*/
class PhabricatorMetaMTAViewController extends PhabricatorMetaMTAController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$mail = id(new PhabricatorMetaMTAMail())->load($this->id);
if (!$mail) {
return new Aphront404Response();
}
$form = new AphrontFormView();
$form->setAction('/mail/send/');
$form
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Subject')
->setValue($mail->getSubject()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Created')
->setValue(date('F jS, Y g:i:s A', $mail->getDateCreated())))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Related PHID')
->setValue($mail->getRelatedPHID()))
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel('Parameters')
->setValue(json_encode($mail->getParameters())))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton('/mail/'));
$panel = new AphrontPanelView();
$panel->setHeader('View Email');
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_WIDE);
return $this->buildStandardPageResponse(
$panel,
array(
'title' => 'View Mail',
));
}
}

View file

@ -0,0 +1,19 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'applications/metamta/controller/base');
phutil_require_module('phabricator', 'applications/metamta/storage/mail');
phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorMetaMTAViewController.php');

View file

@ -86,8 +86,8 @@ class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO {
return $this;
}
public function setReplyTo($phid) {
$this->setParam('reply-to', $phid);
public function setReplyTo($reply_to) {
$this->setParam('reply-to', $reply_to);
return $this;
}
@ -115,9 +115,10 @@ class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO {
return $this;
}
public function sendNow($force_send = false) {
public function sendNow(
$force_send = false,
PhabricatorMailImplementationAdapater $mailer) {
/*
if (!$force_send) {
if ($this->getStatus() != self::STATUS_QUEUE) {
throw new Exception("Trying to send an already-sent mail!");
@ -128,7 +129,6 @@ class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO {
}
}
require_module_lazy('intern/mailer');
try {
$mailer = new InternMailer();
foreach ($this->parameters as $key => $value) {
@ -185,7 +185,7 @@ class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO {
$ok = $mailer->send();
$error = $mailer->getError();
}
*/
$error = null;
$ok = true;