2011-06-13 01:06:17 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2012-01-15 10:07:56 +01:00
|
|
|
* Copyright 2012 Facebook, Inc.
|
2011-06-13 01:06:17 +02:00
|
|
|
*
|
|
|
|
* 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 PhabricatorCountdownDeleteController
|
|
|
|
extends PhabricatorCountdownController {
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = $data['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$timer = id(new PhabricatorTimer())->load($this->id);
|
|
|
|
if (!$timer) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (($timer->getAuthorPHID() !== $user->getPHID())
|
|
|
|
&& $user->getIsAdmin() === false) {
|
2012-01-15 10:07:56 +01:00
|
|
|
return new Aphront403Response();
|
2011-06-13 01:06:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
|
|
|
$timer->delete();
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setURI('/countdown/');
|
|
|
|
}
|
|
|
|
|
|
|
|
$dialog = new AphrontDialogView();
|
|
|
|
$dialog->setUser($request->getUser());
|
|
|
|
$dialog->setTitle('Really delete this countdown?');
|
Countdown tweaks
Summary:
A few tweaks to hsb's Countdown implementation:
- Allow the page to be rendered "chromeless", suitable for display on one of
the dozens of monitors everyone has laying around.
- Show title of countdown in deletion dialog.
- When creating a new countdown default to time(), not Dec 31, 1969.
- Add extra "/" after editing to avoid needless redirect.
- Tweak some page titles.
- Show countdown author in list view.
- Highlight tab in list view.
- Tweak menu copy.
- Link countdown title in list view, separate buttons into different columns
so they pick up padding.
Test Plan:
Created, edited and deleted a timer. Viewed a timer and toggled chrome mode.
Viewed timer list.
Reviewed By: hsb
Reviewers: hsb, aran, jungejason, tuomaspelkonen
CC: aran, hsb, epriestley
Differential Revision: 454
2011-06-14 02:35:13 +02:00
|
|
|
$dialog->appendChild(
|
|
|
|
'<p>Are you sure you want to delete the countdown "'.
|
|
|
|
phutil_escape_html($timer->getTitle()).'"?</p>');
|
2011-06-13 01:06:17 +02:00
|
|
|
$dialog->addSubmitButton('Delete');
|
|
|
|
$dialog->addCancelButton('/countdown/');
|
|
|
|
$dialog->setSubmitURI($request->getPath());
|
|
|
|
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|