mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Ability to invite users, but no RSVP capability yet.
Summary: Ref T7986, Ability to invite users, but not RSVP yet. Test Plan: Open event, add invitees, save, event detail view should show invitees. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7986 Differential Revision: https://secure.phabricator.com/D12617
This commit is contained in:
parent
d3aceeba9e
commit
8039e52ac2
4 changed files with 76 additions and 13 deletions
|
@ -19,7 +19,6 @@ final class PhabricatorCalendarEventEditController
|
||||||
$user_phid = $user->getPHID();
|
$user_phid = $user->getPHID();
|
||||||
$error_name = true;
|
$error_name = true;
|
||||||
$validation_exception = null;
|
$validation_exception = null;
|
||||||
$invitees = null;
|
|
||||||
|
|
||||||
$start_time = id(new AphrontFormDateControl())
|
$start_time = id(new AphrontFormDateControl())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
@ -42,9 +41,7 @@ final class PhabricatorCalendarEventEditController
|
||||||
$page_title = pht('Create Event');
|
$page_title = pht('Create Event');
|
||||||
$redirect = 'created';
|
$redirect = 'created';
|
||||||
$subscribers = array();
|
$subscribers = array();
|
||||||
$invitees = array(
|
$invitees = array($user_phid);
|
||||||
$user_phid => PhabricatorCalendarEventInvitee::STATUS_ATTENDING,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
$event = id(new PhabricatorCalendarEventQuery())
|
$event = id(new PhabricatorCalendarEventQuery())
|
||||||
->setViewer($user)
|
->setViewer($user)
|
||||||
|
@ -68,6 +65,14 @@ final class PhabricatorCalendarEventEditController
|
||||||
|
|
||||||
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
|
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
|
||||||
$event->getPHID());
|
$event->getPHID());
|
||||||
|
$invitees = array();
|
||||||
|
foreach ($event->getInvitees() as $invitee) {
|
||||||
|
if ($invitee->isUninvited()) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
$invitees[] = $invitee->getInviteePHID();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
@ -79,6 +84,16 @@ final class PhabricatorCalendarEventEditController
|
||||||
$end_value = $end_time->readValueFromRequest($request);
|
$end_value = $end_time->readValueFromRequest($request);
|
||||||
$description = $request->getStr('description');
|
$description = $request->getStr('description');
|
||||||
$subscribers = $request->getArr('subscribers');
|
$subscribers = $request->getArr('subscribers');
|
||||||
|
$invitees = $request->getArr('invitees');
|
||||||
|
$new_invitees = $this->getNewInviteeList($invitees, $event);
|
||||||
|
|
||||||
|
if ($this->isCreate()) {
|
||||||
|
$status = idx($new_invitees, $user->getPHID());
|
||||||
|
$status_attending = PhabricatorCalendarEventInvitee::STATUS_ATTENDING;
|
||||||
|
if ($status) {
|
||||||
|
$new_invitees[$user->getPHID()] = $status_attending;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($start_time->getError()) {
|
if ($start_time->getError()) {
|
||||||
$errors[] = pht('Invalid start time; reset to default.');
|
$errors[] = pht('Invalid start time; reset to default.');
|
||||||
|
@ -114,16 +129,13 @@ final class PhabricatorCalendarEventEditController
|
||||||
|
|
||||||
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
||||||
->setTransactionType(
|
->setTransactionType(
|
||||||
PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION)
|
PhabricatorCalendarEventTransaction::TYPE_INVITE)
|
||||||
->setNewValue($description);
|
->setNewValue($new_invitees);
|
||||||
|
|
||||||
if ($invitees) {
|
|
||||||
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
||||||
->setTransactionType(
|
->setTransactionType(
|
||||||
PhabricatorCalendarEventTransaction::TYPE_INVITE)
|
PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION)
|
||||||
->setNewValue($invitees);
|
->setNewValue($description);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$editor = id(new PhabricatorCalendarEventEditor())
|
$editor = id(new PhabricatorCalendarEventEditor())
|
||||||
->setActor($user)
|
->setActor($user)
|
||||||
|
@ -173,6 +185,13 @@ final class PhabricatorCalendarEventEditController
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
->setDatasource(new PhabricatorMetaMTAMailableDatasource());
|
->setDatasource(new PhabricatorMetaMTAMailableDatasource());
|
||||||
|
|
||||||
|
$invitees = id(new AphrontFormTokenizerControl())
|
||||||
|
->setLabel(pht('Invitees'))
|
||||||
|
->setName('invitees')
|
||||||
|
->setValue($invitees)
|
||||||
|
->setUser($user)
|
||||||
|
->setDatasource(new PhabricatorMetaMTAMailableDatasource());
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
$form = id(new AphrontFormView())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
->appendChild($name)
|
->appendChild($name)
|
||||||
|
@ -180,6 +199,7 @@ final class PhabricatorCalendarEventEditController
|
||||||
->appendChild($start_time)
|
->appendChild($start_time)
|
||||||
->appendChild($end_time)
|
->appendChild($end_time)
|
||||||
->appendControl($subscribers)
|
->appendControl($subscribers)
|
||||||
|
->appendControl($invitees)
|
||||||
->appendChild($description);
|
->appendChild($description);
|
||||||
|
|
||||||
$submit = id(new AphrontFormSubmitControl())
|
$submit = id(new AphrontFormSubmitControl())
|
||||||
|
@ -226,4 +246,34 @@ final class PhabricatorCalendarEventEditController
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getNewInviteeList(array $phids, $event) {
|
||||||
|
$invitees = $event->getInvitees();
|
||||||
|
$invitees = mpull($invitees, null, 'getInviteePHID');
|
||||||
|
$invited_status = PhabricatorCalendarEventInvitee::STATUS_INVITED;
|
||||||
|
$uninvited_status = PhabricatorCalendarEventInvitee::STATUS_UNINVITED;
|
||||||
|
$phids = array_fuse($phids);
|
||||||
|
|
||||||
|
$new = array();
|
||||||
|
foreach ($phids as $phid) {
|
||||||
|
$old_invitee = idx($invitees, $phid);
|
||||||
|
if ($old_invitee) {
|
||||||
|
$old_status = $old_invitee->getStatus();
|
||||||
|
if ($old_status != $uninvited_status) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$new[$phid] = $invited_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($invitees as $invitee) {
|
||||||
|
$deleted_invitee = !idx($phids, $invitee->getInviteePHID());
|
||||||
|
if ($deleted_invitee) {
|
||||||
|
$new[$invitee->getInviteePHID()] = $uninvited_status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $new;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,9 +130,13 @@ final class PhabricatorCalendarEventViewController
|
||||||
$invitees = $event->getInvitees();
|
$invitees = $event->getInvitees();
|
||||||
$invitee_list = new PHUIStatusListView();
|
$invitee_list = new PHUIStatusListView();
|
||||||
foreach ($invitees as $invitee) {
|
foreach ($invitees as $invitee) {
|
||||||
|
if ($invitee->isUninvited()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$item = new PHUIStatusItemView();
|
$item = new PHUIStatusItemView();
|
||||||
$invitee_phid = $invitee->getInviteePHID();
|
$invitee_phid = $invitee->getInviteePHID();
|
||||||
$target = $viewer->renderHandle($invitee_phid);
|
$target = $viewer->renderHandle($invitee_phid);
|
||||||
|
$item->setNote($invitee->getStatus());
|
||||||
$item->setTarget($target);
|
$item->setTarget($target);
|
||||||
$invitee_list->addItem($item);
|
$invitee_list->addItem($item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,8 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
||||||
|
|
||||||
return id(new PhabricatorCalendarEvent())
|
return id(new PhabricatorCalendarEvent())
|
||||||
->setUserPHID($actor->getPHID())
|
->setUserPHID($actor->getPHID())
|
||||||
->setIsCancelled(0);
|
->setIsCancelled(0)
|
||||||
|
->attachInvitees(array());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static $statusTexts = array(
|
private static $statusTexts = array(
|
||||||
|
|
|
@ -38,6 +38,14 @@ final class PhabricatorCalendarEventInvitee extends PhabricatorCalendarDAO
|
||||||
) + parent::getConfiguration();
|
) + parent::getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isUninvited() {
|
||||||
|
if ($this->getStatus() == self::STATUS_UNINVITED) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue