2012-10-24 22:22:24 +02:00
|
|
|
<?php
|
|
|
|
|
2014-02-06 19:10:07 +01:00
|
|
|
final class PhabricatorCalendarEventEditController
|
2012-10-24 22:22:24 +02:00
|
|
|
extends PhabricatorCalendarController {
|
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = idx($data, 'id');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isCreate() {
|
|
|
|
return !$this->id;
|
|
|
|
}
|
|
|
|
|
2015-05-19 22:09:28 +02:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
2015-05-24 20:22:33 +02:00
|
|
|
$viewer = $request->getViewer();
|
|
|
|
$user_phid = $viewer->getPHID();
|
2015-04-28 17:34:26 +02:00
|
|
|
$error_name = true;
|
2015-05-02 01:07:57 +02:00
|
|
|
$error_start_date = true;
|
|
|
|
$error_end_date = true;
|
2015-04-28 17:34:26 +02:00
|
|
|
$validation_exception = null;
|
|
|
|
|
2015-05-21 02:10:12 +02:00
|
|
|
$all_day_id = celerity_generate_unique_node_id();
|
|
|
|
$start_date_id = celerity_generate_unique_node_id();
|
|
|
|
$end_date_id = null;
|
|
|
|
|
2015-05-24 20:22:33 +02:00
|
|
|
$next_workflow = $request->getStr('next');
|
|
|
|
$uri_query = $request->getStr('query');
|
|
|
|
|
2012-10-24 22:22:24 +02:00
|
|
|
if ($this->isCreate()) {
|
2015-05-24 20:22:33 +02:00
|
|
|
$event = PhabricatorCalendarEvent::initializeNewCalendarEvent($viewer);
|
|
|
|
|
|
|
|
$create_start_year = $request->getInt('year');
|
|
|
|
$create_start_month = $request->getInt('month');
|
|
|
|
$create_start_day = $request->getInt('day');
|
|
|
|
$create_start_time = $request->getStr('time');
|
|
|
|
|
|
|
|
if ($create_start_year) {
|
|
|
|
$start = AphrontFormDateControlValue::newFromParts(
|
|
|
|
$viewer,
|
|
|
|
$create_start_year,
|
|
|
|
$create_start_month,
|
|
|
|
$create_start_day,
|
|
|
|
$create_start_time);
|
|
|
|
if (!$start->isValid()) {
|
|
|
|
return new Aphront400Response();
|
|
|
|
}
|
|
|
|
$start_value = AphrontFormDateControlValue::newFromEpoch(
|
|
|
|
$viewer,
|
|
|
|
$start->getEpoch());
|
|
|
|
|
|
|
|
$end = clone $start_value->getDateTime();
|
|
|
|
$end->modify('+1 hour');
|
|
|
|
$end_value = AphrontFormDateControlValue::newFromEpoch(
|
|
|
|
$viewer,
|
|
|
|
$end->format('U'));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
list($start_value, $end_value) = $this->getDefaultTimeValues($viewer);
|
|
|
|
}
|
|
|
|
|
2015-05-20 19:59:41 +02:00
|
|
|
|
2012-10-24 22:22:24 +02:00
|
|
|
$submit_label = pht('Create');
|
2015-04-28 15:26:48 +02:00
|
|
|
$page_title = pht('Create Event');
|
|
|
|
$redirect = 'created';
|
2015-04-28 19:40:35 +02:00
|
|
|
$subscribers = array();
|
2015-04-30 00:31:02 +02:00
|
|
|
$invitees = array($user_phid);
|
2015-05-01 02:09:45 +02:00
|
|
|
$cancel_uri = $this->getApplicationURI();
|
2015-05-21 02:10:12 +02:00
|
|
|
$end_date_id = celerity_generate_unique_node_id();
|
2012-10-24 22:22:24 +02:00
|
|
|
} else {
|
2015-04-28 17:34:26 +02:00
|
|
|
$event = id(new PhabricatorCalendarEventQuery())
|
2015-05-24 20:22:33 +02:00
|
|
|
->setViewer($viewer)
|
2014-02-06 19:07:42 +01:00
|
|
|
->withIDs(array($this->id))
|
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
|
|
|
->executeOne();
|
2015-04-28 17:34:26 +02:00
|
|
|
if (!$event) {
|
2014-03-22 03:11:48 +01:00
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
2014-02-06 19:07:42 +01:00
|
|
|
|
2015-05-02 01:07:57 +02:00
|
|
|
$end_value = AphrontFormDateControlValue::newFromEpoch(
|
2015-05-24 20:22:33 +02:00
|
|
|
$viewer,
|
2015-05-02 01:07:57 +02:00
|
|
|
$event->getDateTo());
|
|
|
|
$start_value = AphrontFormDateControlValue::newFromEpoch(
|
2015-05-24 20:22:33 +02:00
|
|
|
$viewer,
|
2015-05-02 01:07:57 +02:00
|
|
|
$event->getDateFrom());
|
|
|
|
|
2012-10-24 22:22:24 +02:00
|
|
|
$submit_label = pht('Update');
|
2014-02-06 19:10:07 +01:00
|
|
|
$page_title = pht('Update Event');
|
2015-04-28 19:40:35 +02:00
|
|
|
|
|
|
|
$subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
|
|
|
|
$event->getPHID());
|
2015-04-30 04:48:46 +02:00
|
|
|
|
2015-04-30 00:31:02 +02:00
|
|
|
$invitees = array();
|
|
|
|
foreach ($event->getInvitees() as $invitee) {
|
|
|
|
if ($invitee->isUninvited()) {
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
$invitees[] = $invitee->getInviteePHID();
|
|
|
|
}
|
|
|
|
}
|
2015-05-01 02:09:45 +02:00
|
|
|
|
|
|
|
$cancel_uri = '/'.$event->getMonogram();
|
2012-10-24 22:22:24 +02:00
|
|
|
}
|
|
|
|
|
2015-05-01 18:11:51 +02:00
|
|
|
$name = $event->getName();
|
|
|
|
$description = $event->getDescription();
|
2015-05-08 03:57:28 +02:00
|
|
|
$is_all_day = $event->getIsAllDay();
|
2015-05-19 22:09:28 +02:00
|
|
|
$icon = $event->getIcon();
|
2015-05-01 18:11:51 +02:00
|
|
|
|
|
|
|
$current_policies = id(new PhabricatorPolicyQuery())
|
2015-05-24 20:22:33 +02:00
|
|
|
->setViewer($viewer)
|
2015-05-01 18:11:51 +02:00
|
|
|
->setObject($event)
|
|
|
|
->execute();
|
|
|
|
|
2012-10-24 22:22:24 +02:00
|
|
|
if ($request->isFormPost()) {
|
2015-04-28 17:34:26 +02:00
|
|
|
$xactions = array();
|
|
|
|
$name = $request->getStr('name');
|
2015-05-02 01:07:57 +02:00
|
|
|
|
|
|
|
$start_value = AphrontFormDateControlValue::newFromRequest(
|
|
|
|
$request,
|
|
|
|
'start');
|
|
|
|
$end_value = AphrontFormDateControlValue::newFromRequest(
|
|
|
|
$request,
|
|
|
|
'end');
|
2012-10-24 22:22:24 +02:00
|
|
|
$description = $request->getStr('description');
|
2015-04-28 19:40:35 +02:00
|
|
|
$subscribers = $request->getArr('subscribers');
|
2015-05-01 18:11:51 +02:00
|
|
|
$edit_policy = $request->getStr('editPolicy');
|
|
|
|
$view_policy = $request->getStr('viewPolicy');
|
2015-05-08 03:57:28 +02:00
|
|
|
$is_all_day = $request->getStr('isAllDay');
|
2015-05-19 22:09:28 +02:00
|
|
|
$icon = $request->getStr('icon');
|
2015-04-30 04:48:46 +02:00
|
|
|
|
2015-04-30 00:31:02 +02:00
|
|
|
$invitees = $request->getArr('invitees');
|
|
|
|
$new_invitees = $this->getNewInviteeList($invitees, $event);
|
2015-04-30 04:48:46 +02:00
|
|
|
$status_attending = PhabricatorCalendarEventInvitee::STATUS_ATTENDING;
|
2015-04-30 00:31:02 +02:00
|
|
|
if ($this->isCreate()) {
|
2015-05-24 20:22:33 +02:00
|
|
|
$status = idx($new_invitees, $viewer->getPHID());
|
2015-04-30 00:31:02 +02:00
|
|
|
if ($status) {
|
2015-05-24 20:22:33 +02:00
|
|
|
$new_invitees[$viewer->getPHID()] = $status_attending;
|
2015-04-30 00:31:02 +02:00
|
|
|
}
|
|
|
|
}
|
2012-10-24 22:22:24 +02:00
|
|
|
|
2015-05-02 01:07:57 +02:00
|
|
|
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
|
|
|
->setTransactionType(
|
|
|
|
PhabricatorCalendarEventTransaction::TYPE_NAME)
|
|
|
|
->setNewValue($name);
|
|
|
|
|
2015-05-08 03:57:28 +02:00
|
|
|
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
|
|
|
->setTransactionType(
|
|
|
|
PhabricatorCalendarEventTransaction::TYPE_ALL_DAY)
|
|
|
|
->setNewValue($is_all_day);
|
|
|
|
|
2015-05-19 22:09:28 +02:00
|
|
|
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
|
|
|
->setTransactionType(
|
|
|
|
PhabricatorCalendarEventTransaction::TYPE_ICON)
|
|
|
|
->setNewValue($icon);
|
|
|
|
|
2015-05-02 01:07:57 +02:00
|
|
|
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
|
|
|
->setTransactionType(
|
|
|
|
PhabricatorCalendarEventTransaction::TYPE_START_DATE)
|
|
|
|
->setNewValue($start_value);
|
|
|
|
|
|
|
|
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
|
|
|
->setTransactionType(
|
|
|
|
PhabricatorCalendarEventTransaction::TYPE_END_DATE)
|
|
|
|
->setNewValue($end_value);
|
|
|
|
|
|
|
|
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
|
|
|
->setTransactionType(
|
|
|
|
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);
|
|
|
|
|
|
|
|
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
|
|
|
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
|
|
|
|
->setNewValue($request->getStr('viewPolicy'));
|
|
|
|
|
|
|
|
$xactions[] = id(new PhabricatorCalendarEventTransaction())
|
|
|
|
->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY)
|
|
|
|
->setNewValue($request->getStr('editPolicy'));
|
|
|
|
|
|
|
|
$editor = id(new PhabricatorCalendarEventEditor())
|
2015-05-24 20:22:33 +02:00
|
|
|
->setActor($viewer)
|
2015-05-02 01:07:57 +02:00
|
|
|
->setContentSourceFromRequest($request)
|
|
|
|
->setContinueOnNoEffect(true);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$xactions = $editor->applyTransactions($event, $xactions);
|
|
|
|
$response = id(new AphrontRedirectResponse());
|
2015-05-24 20:22:33 +02:00
|
|
|
switch ($next_workflow) {
|
|
|
|
case 'day':
|
|
|
|
if (!$uri_query) {
|
|
|
|
$uri_query = 'month';
|
|
|
|
}
|
|
|
|
$year = $start_value->getDateTime()->format('Y');
|
|
|
|
$month = $start_value->getDateTime()->format('m');
|
|
|
|
$day = $start_value->getDateTime()->format('d');
|
|
|
|
$response->setURI(
|
|
|
|
'/calendar/query/'.$uri_query.'/'.$year.'/'.$month.'/'.$day.'/');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$response->setURI('/E'.$event->getID());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return $response;
|
2015-05-02 01:07:57 +02:00
|
|
|
} catch (PhabricatorApplicationTransactionValidationException $ex) {
|
|
|
|
$validation_exception = $ex;
|
|
|
|
$error_name = $ex->getShortMessage(
|
|
|
|
PhabricatorCalendarEventTransaction::TYPE_NAME);
|
|
|
|
$error_start_date = $ex->getShortMessage(
|
|
|
|
PhabricatorCalendarEventTransaction::TYPE_START_DATE);
|
|
|
|
$error_end_date = $ex->getShortMessage(
|
|
|
|
PhabricatorCalendarEventTransaction::TYPE_END_DATE);
|
|
|
|
|
2015-05-01 18:11:51 +02:00
|
|
|
$event->setViewPolicy($view_policy);
|
|
|
|
$event->setEditPolicy($edit_policy);
|
2012-10-24 22:22:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-08 19:01:13 +02:00
|
|
|
Javelin::initBehavior('event-all-day', array(
|
|
|
|
'allDayID' => $all_day_id,
|
|
|
|
'startDateID' => $start_date_id,
|
|
|
|
'endDateID' => $end_date_id,
|
|
|
|
));
|
|
|
|
|
2015-04-28 17:34:26 +02:00
|
|
|
$name = id(new AphrontFormTextControl())
|
|
|
|
->setLabel(pht('Name'))
|
|
|
|
->setName('name')
|
2015-05-01 18:11:51 +02:00
|
|
|
->setValue($name)
|
2015-04-28 17:34:26 +02:00
|
|
|
->setError($error_name);
|
|
|
|
|
2015-05-08 19:01:13 +02:00
|
|
|
$all_day_checkbox = id(new AphrontFormCheckboxControl())
|
2015-05-08 03:57:28 +02:00
|
|
|
->addCheckbox(
|
|
|
|
'isAllDay',
|
|
|
|
1,
|
|
|
|
pht('All Day Event'),
|
2015-05-08 19:01:13 +02:00
|
|
|
$is_all_day,
|
|
|
|
$all_day_id);
|
2015-05-08 03:57:28 +02:00
|
|
|
|
2015-05-02 01:07:57 +02:00
|
|
|
$start_control = id(new AphrontFormDateControl())
|
2015-05-24 20:22:33 +02:00
|
|
|
->setUser($viewer)
|
2015-05-02 01:07:57 +02:00
|
|
|
->setName('start')
|
|
|
|
->setLabel(pht('Start'))
|
|
|
|
->setError($error_start_date)
|
2015-05-08 19:01:13 +02:00
|
|
|
->setValue($start_value)
|
|
|
|
->setID($start_date_id)
|
2015-05-21 02:10:12 +02:00
|
|
|
->setIsTimeDisabled($is_all_day)
|
|
|
|
->setEndDateID($end_date_id);
|
2015-05-02 01:07:57 +02:00
|
|
|
|
|
|
|
$end_control = id(new AphrontFormDateControl())
|
2015-05-24 20:22:33 +02:00
|
|
|
->setUser($viewer)
|
2015-05-02 01:07:57 +02:00
|
|
|
->setName('end')
|
|
|
|
->setLabel(pht('End'))
|
|
|
|
->setError($error_end_date)
|
2015-05-08 19:01:13 +02:00
|
|
|
->setValue($end_value)
|
|
|
|
->setID($end_date_id)
|
|
|
|
->setIsTimeDisabled($is_all_day);
|
2015-05-02 01:07:57 +02:00
|
|
|
|
2012-10-24 22:22:24 +02:00
|
|
|
$description = id(new AphrontFormTextAreaControl())
|
|
|
|
->setLabel(pht('Description'))
|
|
|
|
->setName('description')
|
2015-05-01 18:11:51 +02:00
|
|
|
->setValue($description);
|
2013-05-29 23:35:34 +02:00
|
|
|
|
2015-04-30 23:43:48 +02:00
|
|
|
$view_policies = id(new AphrontFormPolicyControl())
|
2015-05-24 20:22:33 +02:00
|
|
|
->setUser($viewer)
|
2015-04-30 23:43:48 +02:00
|
|
|
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
|
|
|
|
->setPolicyObject($event)
|
|
|
|
->setPolicies($current_policies)
|
|
|
|
->setName('viewPolicy');
|
|
|
|
$edit_policies = id(new AphrontFormPolicyControl())
|
2015-05-24 20:22:33 +02:00
|
|
|
->setUser($viewer)
|
2015-04-30 23:43:48 +02:00
|
|
|
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
|
|
|
|
->setPolicyObject($event)
|
|
|
|
->setPolicies($current_policies)
|
|
|
|
->setName('editPolicy');
|
|
|
|
|
2015-04-28 19:40:35 +02:00
|
|
|
$subscribers = id(new AphrontFormTokenizerControl())
|
|
|
|
->setLabel(pht('Subscribers'))
|
|
|
|
->setName('subscribers')
|
|
|
|
->setValue($subscribers)
|
2015-05-24 20:22:33 +02:00
|
|
|
->setUser($viewer)
|
2015-04-28 19:40:35 +02:00
|
|
|
->setDatasource(new PhabricatorMetaMTAMailableDatasource());
|
|
|
|
|
2015-04-30 00:31:02 +02:00
|
|
|
$invitees = id(new AphrontFormTokenizerControl())
|
|
|
|
->setLabel(pht('Invitees'))
|
|
|
|
->setName('invitees')
|
|
|
|
->setValue($invitees)
|
2015-05-24 20:22:33 +02:00
|
|
|
->setUser($viewer)
|
2015-04-30 00:31:02 +02:00
|
|
|
->setDatasource(new PhabricatorMetaMTAMailableDatasource());
|
|
|
|
|
2015-05-19 22:09:28 +02:00
|
|
|
if ($this->isCreate()) {
|
|
|
|
$icon_uri = $this->getApplicationURI('icon/');
|
|
|
|
} else {
|
|
|
|
$icon_uri = $this->getApplicationURI('icon/'.$event->getID().'/');
|
|
|
|
}
|
|
|
|
$icon_display = PhabricatorCalendarIcon::renderIconForChooser($icon);
|
|
|
|
$icon = id(new AphrontFormChooseButtonControl())
|
|
|
|
->setLabel(pht('Icon'))
|
|
|
|
->setName('icon')
|
|
|
|
->setDisplayValue($icon_display)
|
|
|
|
->setButtonText(pht('Choose Icon...'))
|
|
|
|
->setChooseURI($icon_uri)
|
|
|
|
->setValue($icon);
|
|
|
|
|
2015-04-28 17:34:26 +02:00
|
|
|
$form = id(new AphrontFormView())
|
2015-05-24 20:22:33 +02:00
|
|
|
->addHiddenInput('next', $next_workflow)
|
|
|
|
->addHiddenInput('query', $uri_query)
|
|
|
|
->setUser($viewer)
|
2015-04-28 17:34:26 +02:00
|
|
|
->appendChild($name)
|
2015-05-08 19:01:13 +02:00
|
|
|
->appendChild($all_day_checkbox)
|
2015-05-02 01:07:57 +02:00
|
|
|
->appendChild($start_control)
|
|
|
|
->appendChild($end_control)
|
2015-04-30 23:43:48 +02:00
|
|
|
->appendControl($view_policies)
|
|
|
|
->appendControl($edit_policies)
|
2015-04-28 19:40:35 +02:00
|
|
|
->appendControl($subscribers)
|
2015-04-30 00:31:02 +02:00
|
|
|
->appendControl($invitees)
|
2015-05-19 22:09:28 +02:00
|
|
|
->appendChild($description)
|
|
|
|
->appendChild($icon);
|
2012-10-24 22:22:24 +02:00
|
|
|
|
2015-05-01 02:09:45 +02:00
|
|
|
|
|
|
|
if ($request->isAjax()) {
|
|
|
|
return $this->newDialog()
|
|
|
|
->setTitle($page_title)
|
|
|
|
->setWidth(AphrontDialogView::WIDTH_FULL)
|
|
|
|
->appendForm($form)
|
|
|
|
->addCancelButton($cancel_uri)
|
|
|
|
->addSubmitButton($submit_label);
|
|
|
|
}
|
|
|
|
|
2015-04-28 17:34:26 +02:00
|
|
|
$submit = id(new AphrontFormSubmitControl())
|
2015-05-01 02:09:45 +02:00
|
|
|
->addCancelButton($cancel_uri)
|
2015-04-28 17:34:26 +02:00
|
|
|
->setValue($submit_label);
|
2013-05-29 23:35:34 +02:00
|
|
|
|
2012-10-24 22:22:24 +02:00
|
|
|
$form->appendChild($submit);
|
|
|
|
|
2013-09-25 20:23:29 +02:00
|
|
|
$form_box = id(new PHUIObjectBoxView())
|
2013-08-26 20:53:11 +02:00
|
|
|
->setHeaderText($page_title)
|
|
|
|
->setForm($form);
|
|
|
|
|
2015-04-27 23:27:00 +02:00
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
|
|
|
|
if (!$this->isCreate()) {
|
2015-04-28 17:34:26 +02:00
|
|
|
$crumbs->addTextCrumb('E'.$event->getId(), '/E'.$event->getId());
|
2015-04-27 23:27:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$crumbs->addTextCrumb($page_title);
|
2014-02-18 01:08:50 +01:00
|
|
|
|
2015-04-28 17:34:26 +02:00
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText($page_title)
|
|
|
|
->setValidationException($validation_exception)
|
|
|
|
->appendChild($form);
|
|
|
|
|
2015-05-01 01:18:15 +02:00
|
|
|
return $this->buildApplicationPage(
|
2012-10-24 22:22:24 +02:00
|
|
|
array(
|
2014-02-18 01:08:50 +01:00
|
|
|
$crumbs,
|
2015-04-28 17:34:26 +02:00
|
|
|
$object_box,
|
2015-05-01 01:18:15 +02:00
|
|
|
),
|
2012-10-24 22:22:24 +02:00
|
|
|
array(
|
|
|
|
'title' => $page_title,
|
2013-02-19 22:33:10 +01:00
|
|
|
));
|
2012-10-24 22:22:24 +02:00
|
|
|
}
|
|
|
|
|
2015-04-30 00:31:02 +02:00
|
|
|
|
|
|
|
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) {
|
2015-04-30 04:48:46 +02:00
|
|
|
$old_status = $event->getUserInviteStatus($phid);
|
|
|
|
if ($old_status != $uninvited_status) {
|
|
|
|
continue;
|
2015-04-30 00:31:02 +02:00
|
|
|
}
|
|
|
|
$new[$phid] = $invited_status;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($invitees as $invitee) {
|
|
|
|
$deleted_invitee = !idx($phids, $invitee->getInviteePHID());
|
|
|
|
if ($deleted_invitee) {
|
|
|
|
$new[$invitee->getInviteePHID()] = $uninvited_status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $new;
|
|
|
|
}
|
|
|
|
|
2015-05-24 20:22:33 +02:00
|
|
|
private function getDefaultTimeValues($viewer) {
|
2015-05-20 19:59:41 +02:00
|
|
|
$start = new DateTime('@'.time());
|
2015-05-24 20:22:33 +02:00
|
|
|
$start->setTimeZone($viewer->getTimeZone());
|
2015-05-20 19:59:41 +02:00
|
|
|
|
|
|
|
$start->setTime($start->format('H'), 0, 0);
|
|
|
|
$start->modify('+1 hour');
|
|
|
|
$end = id(clone $start)->modify('+1 hour');
|
|
|
|
|
|
|
|
$start_value = AphrontFormDateControlValue::newFromEpoch(
|
2015-05-24 20:22:33 +02:00
|
|
|
$viewer,
|
2015-05-20 19:59:41 +02:00
|
|
|
$start->format('U'));
|
|
|
|
$end_value = AphrontFormDateControlValue::newFromEpoch(
|
2015-05-24 20:22:33 +02:00
|
|
|
$viewer,
|
2015-05-20 19:59:41 +02:00
|
|
|
$end->format('U'));
|
|
|
|
|
|
|
|
return array($start_value, $end_value);
|
|
|
|
}
|
|
|
|
|
2012-10-24 22:22:24 +02:00
|
|
|
}
|