1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +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:
lkassianik 2015-04-29 15:31:02 -07:00
parent d3aceeba9e
commit 8039e52ac2
4 changed files with 76 additions and 13 deletions

View file

@ -19,7 +19,6 @@ final class PhabricatorCalendarEventEditController
$user_phid = $user->getPHID();
$error_name = true;
$validation_exception = null;
$invitees = null;
$start_time = id(new AphrontFormDateControl())
->setUser($user)
@ -42,9 +41,7 @@ final class PhabricatorCalendarEventEditController
$page_title = pht('Create Event');
$redirect = 'created';
$subscribers = array();
$invitees = array(
$user_phid => PhabricatorCalendarEventInvitee::STATUS_ATTENDING,
);
$invitees = array($user_phid);
} else {
$event = id(new PhabricatorCalendarEventQuery())
->setViewer($user)
@ -68,6 +65,14 @@ final class PhabricatorCalendarEventEditController
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$event->getPHID());
$invitees = array();
foreach ($event->getInvitees() as $invitee) {
if ($invitee->isUninvited()) {
continue;
} else {
$invitees[] = $invitee->getInviteePHID();
}
}
}
$errors = array();
@ -79,6 +84,16 @@ final class PhabricatorCalendarEventEditController
$end_value = $end_time->readValueFromRequest($request);
$description = $request->getStr('description');
$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()) {
$errors[] = pht('Invalid start time; reset to default.');
@ -112,19 +127,16 @@ final class PhabricatorCalendarEventEditController
PhabricatorTransactions::TYPE_SUBSCRIBERS)
->setNewValue(array('=' => array_fuse($subscribers)));
$xactions[] = id(new PhabricatorCalendarEventTransaction())
->setTransactionType(
PhabricatorCalendarEventTransaction::TYPE_INVITE)
->setNewValue($new_invitees);
$xactions[] = id(new PhabricatorCalendarEventTransaction())
->setTransactionType(
PhabricatorCalendarEventTransaction::TYPE_DESCRIPTION)
->setNewValue($description);
if ($invitees) {
$xactions[] = id(new PhabricatorCalendarEventTransaction())
->setTransactionType(
PhabricatorCalendarEventTransaction::TYPE_INVITE)
->setNewValue($invitees);
}
$editor = id(new PhabricatorCalendarEventEditor())
->setActor($user)
->setContentSourceFromRequest($request)
@ -173,6 +185,13 @@ final class PhabricatorCalendarEventEditController
->setUser($user)
->setDatasource(new PhabricatorMetaMTAMailableDatasource());
$invitees = id(new AphrontFormTokenizerControl())
->setLabel(pht('Invitees'))
->setName('invitees')
->setValue($invitees)
->setUser($user)
->setDatasource(new PhabricatorMetaMTAMailableDatasource());
$form = id(new AphrontFormView())
->setUser($user)
->appendChild($name)
@ -180,6 +199,7 @@ final class PhabricatorCalendarEventEditController
->appendChild($start_time)
->appendChild($end_time)
->appendControl($subscribers)
->appendControl($invitees)
->appendChild($description);
$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;
}
}

View file

@ -130,9 +130,13 @@ final class PhabricatorCalendarEventViewController
$invitees = $event->getInvitees();
$invitee_list = new PHUIStatusListView();
foreach ($invitees as $invitee) {
if ($invitee->isUninvited()) {
continue;
}
$item = new PHUIStatusItemView();
$invitee_phid = $invitee->getInviteePHID();
$target = $viewer->renderHandle($invitee_phid);
$item->setNote($invitee->getStatus());
$item->setTarget($target);
$invitee_list->addItem($item);
}

View file

@ -31,7 +31,8 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
return id(new PhabricatorCalendarEvent())
->setUserPHID($actor->getPHID())
->setIsCancelled(0);
->setIsCancelled(0)
->attachInvitees(array());
}
private static $statusTexts = array(

View file

@ -38,6 +38,14 @@ final class PhabricatorCalendarEventInvitee extends PhabricatorCalendarDAO
) + parent::getConfiguration();
}
public function isUninvited() {
if ($this->getStatus() == self::STATUS_UNINVITED) {
return true;
} else {
return false;
}
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */