mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
Mailing lists
This commit is contained in:
parent
2112673f06
commit
336a8b3212
16 changed files with 367 additions and 12 deletions
|
@ -118,6 +118,9 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMetaMTADAO' => 'applications/metamta/storage/base',
|
||||
'PhabricatorMetaMTAListController' => 'applications/metamta/controller/list',
|
||||
'PhabricatorMetaMTAMail' => 'applications/metamta/storage/mail',
|
||||
'PhabricatorMetaMTAMailingList' => 'applications/metamta/storage/mailinglist',
|
||||
'PhabricatorMetaMTAMailingListEditController' => 'applications/metamta/controller/mailinglistedit',
|
||||
'PhabricatorMetaMTAMailingListsController' => 'applications/metamta/controller/mailinglists',
|
||||
'PhabricatorMetaMTASendController' => 'applications/metamta/controller/send',
|
||||
'PhabricatorMetaMTAViewController' => 'applications/metamta/controller/view',
|
||||
'PhabricatorObjectHandle' => 'applications/phid/handle',
|
||||
|
@ -244,6 +247,9 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMetaMTADAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorMetaMTAListController' => 'PhabricatorMetaMTAController',
|
||||
'PhabricatorMetaMTAMail' => 'PhabricatorMetaMTADAO',
|
||||
'PhabricatorMetaMTAMailingList' => 'PhabricatorMetaMTADAO',
|
||||
'PhabricatorMetaMTAMailingListEditController' => 'PhabricatorMetaMTAController',
|
||||
'PhabricatorMetaMTAMailingListsController' => 'PhabricatorMetaMTAController',
|
||||
'PhabricatorMetaMTASendController' => 'PhabricatorMetaMTAController',
|
||||
'PhabricatorMetaMTAViewController' => 'PhabricatorMetaMTAController',
|
||||
'PhabricatorPHID' => 'PhabricatorPHIDDAO',
|
||||
|
|
|
@ -99,7 +99,10 @@ class AphrontDefaultApplicationConfiguration
|
|||
'$' => 'PhabricatorMetaMTAListController',
|
||||
'send/$' => 'PhabricatorMetaMTASendController',
|
||||
'view/(?<id>\d+)/$' => 'PhabricatorMetaMTAViewController',
|
||||
)
|
||||
'lists/$' => 'PhabricatorMetaMTAMailingListsController',
|
||||
'lists/edit/(?:(?<id>\d+)/)?$'
|
||||
=> 'PhabricatorMetaMTAMailingListEditController',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,18 @@ abstract class PhabricatorMetaMTAController extends PhabricatorController {
|
|||
$page->setApplicationName('MetaMTA');
|
||||
$page->setBaseURI('/mail/');
|
||||
$page->setTitle(idx($data, 'title'));
|
||||
$page->setTabs(
|
||||
array(
|
||||
'queue' => array(
|
||||
'name' => 'Mail Queue',
|
||||
'href' => '/mail/',
|
||||
),
|
||||
'lists' => array(
|
||||
'name' => 'Mailing Lists',
|
||||
'href' => '/mail/lists/',
|
||||
),
|
||||
),
|
||||
idx($data, 'tab'));
|
||||
$page->setGlyph("@");
|
||||
$page->appendChild($view);
|
||||
|
||||
|
|
|
@ -72,6 +72,7 @@ class PhabricatorMetaMTAListController extends PhabricatorMetaMTAController {
|
|||
$panel,
|
||||
array(
|
||||
'title' => 'MetaMTA',
|
||||
'tab' => 'queue',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'applications/metamta/storage/mail');
|
|||
phutil_require_module('phabricator', 'view/control/table');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,121 @@
|
|||
<?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 PhabricatorMetaMTAMailingListEditController
|
||||
extends PhabricatorMetaMTAController {
|
||||
|
||||
private $id;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = idx($data, 'id');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
if ($this->id) {
|
||||
$list = id(new PhabricatorMetaMTAMailingList())->load($this->id);
|
||||
if (!$list) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
} else {
|
||||
$list = new PhabricatorMetaMTAMailingList();
|
||||
}
|
||||
|
||||
$e_email = true;
|
||||
$errors = array();
|
||||
|
||||
$request = $this->getRequest();
|
||||
if ($request->isFormPost()) {
|
||||
$list->setName($request->getStr('name'));
|
||||
$list->setEmail($request->getStr('email'));
|
||||
$list->setURI($request->getStr('uri'));
|
||||
|
||||
if (!strlen($list->getEmail())) {
|
||||
$e_email = 'Required';
|
||||
$errors[] = 'Email is required.';
|
||||
}
|
||||
|
||||
if (!$errors) {
|
||||
$list->save();
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/mail/lists/');
|
||||
}
|
||||
}
|
||||
|
||||
$error_view = null;
|
||||
if ($errors) {
|
||||
$error_view = id(new AphrontErrorView())
|
||||
->setTitle('Form Errors')
|
||||
->setErrors($errors);
|
||||
}
|
||||
|
||||
$form = new AphrontFormView();
|
||||
if ($list->getID()) {
|
||||
$form->setAction('/mail/lists/edit/'.$list->getID().'/');
|
||||
} else {
|
||||
$form->setAction('/mail/lists/edit/');
|
||||
}
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('Email')
|
||||
->setName('email')
|
||||
->setValue($list->getEmail())
|
||||
->setError($e_email))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('Name')
|
||||
->setName('name')
|
||||
->setValue($list->getName()))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('URI')
|
||||
->setName('uri')
|
||||
->setValue($list->getURI()))
|
||||
->appendChild(
|
||||
id(new AphrontFormStaticControl())
|
||||
->setLabel('ID')
|
||||
->setValue(nonempty($list->getID(), '-')))
|
||||
->appendChild(
|
||||
id(new AphrontFormStaticControl())
|
||||
->setLabel('PHID')
|
||||
->setValue(nonempty($list->getPHID(), '-')))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->setValue('Save')
|
||||
->addCancelButton('/mail/lists/'));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
if ($list->getID()) {
|
||||
$panel->setHeader('Edit Mailing List');
|
||||
} else {
|
||||
$panel->setHeader('Create New Mailing List');
|
||||
}
|
||||
|
||||
$panel->appendChild($form);
|
||||
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
array($error_view, $panel),
|
||||
array(
|
||||
'title' => 'Edit Mailing List',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/404');
|
||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||
phutil_require_module('phabricator', 'applications/metamta/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/metamta/storage/mailinglist');
|
||||
phutil_require_module('phabricator', 'view/form/base');
|
||||
phutil_require_module('phabricator', 'view/form/control/submit');
|
||||
phutil_require_module('phabricator', 'view/form/error');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorMetaMTAMailingListEditController.php');
|
|
@ -0,0 +1,70 @@
|
|||
<?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 PhabricatorMetaMTAMailingListsController
|
||||
extends PhabricatorMetaMTAController {
|
||||
|
||||
public function processRequest() {
|
||||
$lists = id(new PhabricatorMetaMTAMailingList())->loadAllWhere(
|
||||
'1 = 1 ORDER BY id DESC LIMIT 100');
|
||||
|
||||
$rows = array();
|
||||
foreach ($lists as $list) {
|
||||
$rows[] = array(
|
||||
phutil_escape_html($list->getPHID()),
|
||||
phutil_escape_html($list->getEmail()),
|
||||
phutil_escape_html($list->getName()),
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'class' => 'button grey small',
|
||||
'href' => '/mail/lists/edit/'.$list->getID().'/',
|
||||
),
|
||||
'Edit'),
|
||||
);
|
||||
}
|
||||
|
||||
$table = new AphrontTableView($rows);
|
||||
$table->setHeaders(
|
||||
array(
|
||||
'PHID',
|
||||
'Email',
|
||||
'Name',
|
||||
'',
|
||||
));
|
||||
$table->setColumnClasses(
|
||||
array(
|
||||
null,
|
||||
null,
|
||||
'wide',
|
||||
'action',
|
||||
));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->appendChild($table);
|
||||
$panel->setHeader('Mailing Lists');
|
||||
$panel->setCreateButton('Add New List', '/mail/lists/edit/');
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$panel,
|
||||
array(
|
||||
'title' => 'Mailing Lists',
|
||||
'tab' => 'lists',
|
||||
));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/metamta/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/metamta/storage/mailinglist');
|
||||
phutil_require_module('phabricator', 'view/control/table');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorMetaMTAMailingListsController.php');
|
|
@ -59,12 +59,12 @@ class PhabricatorMetaMTASendController extends PhabricatorMetaMTAController {
|
|||
id(new AphrontFormTokenizerControl())
|
||||
->setLabel('To')
|
||||
->setName('to')
|
||||
->setDatasource('/typeahead/common/user/'))
|
||||
->setDatasource('/typeahead/common/mailable/'))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setLabel('CC')
|
||||
->setName('cc')
|
||||
->setDatasource('/typeahead/common/user/'))
|
||||
->setDatasource('/typeahead/common/mailable/'))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('Subject')
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||
phutil_require_module('phabricator', 'applications/metamta/adapter/phpmailerlite');
|
||||
phutil_require_module('phabricator', 'applications/metamta/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/metamta/storage/mail');
|
||||
phutil_require_module('phabricator', 'view/form/base');
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?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 PhabricatorMetaMTAMailingList extends PhabricatorMetaMTADAO {
|
||||
|
||||
const TYPE_MAILING_LIST = 'MLST';
|
||||
|
||||
protected $name;
|
||||
protected $phid;
|
||||
protected $email;
|
||||
protected $uri;
|
||||
|
||||
public function generatePHID() {
|
||||
return PhabricatorPHID::generateNewPHID(self::TYPE_MAILING_LIST);
|
||||
}
|
||||
|
||||
public function getConfiguration() {
|
||||
return array(
|
||||
self::CONFIG_AUX_PHID => true,
|
||||
) + parent::getConfiguration();
|
||||
}
|
||||
|
||||
}
|
13
src/applications/metamta/storage/mailinglist/__init__.php
Normal file
13
src/applications/metamta/storage/mailinglist/__init__.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/metamta/storage/base');
|
||||
phutil_require_module('phabricator', 'applications/phid/storage/phid');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorMetaMTAMailingList.php');
|
|
@ -62,6 +62,31 @@ class PhabricatorObjectHandleData {
|
|||
$handles[$phid] = $handle;
|
||||
}
|
||||
break;
|
||||
case 'MLST':
|
||||
$class = 'PhabricatorMetaMTAMailingList';
|
||||
|
||||
PhutilSymbolLoader::loadClass($class);
|
||||
$object = newv($class, array());
|
||||
|
||||
$lists = $object->loadAllWhere('phid IN (%Ls)', $phids);
|
||||
$lists = mpull($lists, null, 'getPHID');
|
||||
|
||||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
$handle->setPHID($phid);
|
||||
if (empty($lists[$phid])) {
|
||||
$handle->setType(self::TYPE_UNKNOWN);
|
||||
$handle->setName('Unknown Mailing List');
|
||||
} else {
|
||||
$list = $lists[$phid];
|
||||
$handle->setType($type);
|
||||
$handle->setEmail($list->getEmail());
|
||||
$handle->setName($list->getName());
|
||||
$handle->setURI($list->getURI());
|
||||
}
|
||||
$handles[$phid] = $handle;
|
||||
}
|
||||
break;
|
||||
case 'FILE':
|
||||
$class = 'PhabricatorFile';
|
||||
PhutilSymbolLoader::loadClass($class);
|
||||
|
|
|
@ -25,17 +25,41 @@ class PhabricatorTypeaheadCommonDatasourceController
|
|||
|
||||
public function processRequest() {
|
||||
|
||||
$data = array();
|
||||
|
||||
$users = id(new PhabricatorUser())->loadAll();
|
||||
$need_users = false;
|
||||
$need_lists = false;
|
||||
switch ($this->type) {
|
||||
case 'users':
|
||||
$need_users = true;
|
||||
break;
|
||||
case 'mailable':
|
||||
$need_users = true;
|
||||
$need_lists = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
foreach ($users as $user) {
|
||||
$data[] = array(
|
||||
$user->getUsername().' ('.$user->getRealName().')',
|
||||
'/p/'.$user->getUsername(),
|
||||
$user->getPHID(),
|
||||
);
|
||||
|
||||
|
||||
if ($need_users) {
|
||||
$users = id(new PhabricatorUser())->loadAll();
|
||||
foreach ($users as $user) {
|
||||
$data[] = array(
|
||||
$user->getUsername().' ('.$user->getRealName().')',
|
||||
'/p/'.$user->getUsername(),
|
||||
$user->getPHID(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($need_lists) {
|
||||
$lists = id(new PhabricatorMetaMTAMailingList())->loadAll();
|
||||
foreach ($lists as $list) {
|
||||
$data[] = array(
|
||||
$list->getEmail(),
|
||||
$list->getURI(),
|
||||
$list->getPHID(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return id(new AphrontAjaxResponse())
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/ajax');
|
||||
phutil_require_module('phabricator', 'applications/metamta/storage/mailinglist');
|
||||
phutil_require_module('phabricator', 'applications/people/storage/user');
|
||||
phutil_require_module('phabricator', 'applications/typeahead/controller/base');
|
||||
|
||||
|
|
Loading…
Reference in a new issue