Differential D13634 Diff 32956 src/applications/countdown/controller/PhabricatorCountdownEditController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/countdown/controller/PhabricatorCountdownEditController.php
Show All 35 Lines | if ($this->id) { | ||||
$date_value = AphrontFormDateControlValue::newFromEpoch($user, time()); | $date_value = AphrontFormDateControlValue::newFromEpoch($user, time()); | ||||
} | } | ||||
$errors = array(); | $errors = array(); | ||||
$e_text = true; | $e_text = true; | ||||
$e_epoch = null; | $e_epoch = null; | ||||
$v_text = $countdown->getTitle(); | $v_text = $countdown->getTitle(); | ||||
$v_space = $countdown->getSpacePHID(); | |||||
if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
$v_text = $request->getStr('title'); | $v_text = $request->getStr('title'); | ||||
$v_space = $request->getStr('spacePHID'); | |||||
$date_value = AphrontFormDateControlValue::newFromRequest( | $date_value = AphrontFormDateControlValue::newFromRequest( | ||||
$request, | $request, | ||||
'epoch'); | 'epoch'); | ||||
$view_policy = $request->getStr('viewPolicy'); | $view_policy = $request->getStr('viewPolicy'); | ||||
$e_text = null; | $e_text = null; | ||||
if (!strlen($v_text)) { | if (!strlen($v_text)) { | ||||
$e_text = pht('Required'); | $e_text = pht('Required'); | ||||
$errors[] = pht('You must give the countdown a name.'); | $errors[] = pht('You must give the countdown a name.'); | ||||
} | } | ||||
if (!$date_value->isValid()) { | if (!$date_value->isValid()) { | ||||
$e_epoch = pht('Invalid'); | $e_epoch = pht('Invalid'); | ||||
$errors[] = pht('You must give the countdown a valid end date.'); | $errors[] = pht('You must give the countdown a valid end date.'); | ||||
} | } | ||||
if (!count($errors)) { | if (!count($errors)) { | ||||
$countdown->setTitle($v_text); | $countdown->setTitle($v_text); | ||||
$countdown->setEpoch($date_value->getEpoch()); | $countdown->setEpoch($date_value->getEpoch()); | ||||
$countdown->setViewPolicy($view_policy); | $countdown->setViewPolicy($view_policy); | ||||
$countdown->setSpacePHID($v_space); | |||||
$countdown->save(); | $countdown->save(); | ||||
return id(new AphrontRedirectResponse()) | return id(new AphrontRedirectResponse()) | ||||
->setURI('/countdown/'.$countdown->getID().'/'); | ->setURI('/countdown/'.$countdown->getID().'/'); | ||||
} | } | ||||
} | } | ||||
$crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
Show All 30 Lines | $form = id(new AphrontFormView()) | ||||
->setError($e_epoch) | ->setError($e_epoch) | ||||
->setValue($date_value)) | ->setValue($date_value)) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormPolicyControl()) | id(new AphrontFormPolicyControl()) | ||||
->setUser($user) | ->setUser($user) | ||||
->setName('viewPolicy') | ->setName('viewPolicy') | ||||
->setPolicyObject($countdown) | ->setPolicyObject($countdown) | ||||
->setPolicies($policies) | ->setPolicies($policies) | ||||
->setSpacePHID($v_space) | |||||
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)) | ->setCapability(PhabricatorPolicyCapability::CAN_VIEW)) | ||||
->appendChild( | ->appendChild( | ||||
id(new AphrontFormSubmitControl()) | id(new AphrontFormSubmitControl()) | ||||
->addCancelButton($cancel_uri) | ->addCancelButton($cancel_uri) | ||||
->setValue($submit_label)); | ->setValue($submit_label)); | ||||
$form_box = id(new PHUIObjectBoxView()) | $form_box = id(new PHUIObjectBoxView()) | ||||
->setHeaderText($page_title) | ->setHeaderText($page_title) | ||||
Show All 14 Lines |