Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F98209961
PhabricatorCalendarEventCancelController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jan 11, 02:17
Size
3 KB
Mime Type
text/x-php
Expires
Mon, Jan 13, 02:17 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23534432
Attached To
rPH Phabricator
PhabricatorCalendarEventCancelController.php
View Options
<?php
final
class
PhabricatorCalendarEventCancelController
extends
PhabricatorCalendarController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$id
=
$request
->
getURIData
(
'id'
);
// Just check CAN_VIEW first. Then we'll check if this is an import so
// we can raise a better error.
$event
=
id
(
new
PhabricatorCalendarEventQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$id
))
->
executeOne
();
if
(!
$event
)
{
return
new
Aphront404Response
();
}
$response
=
$this
->
newImportedEventResponse
(
$event
);
if
(
$response
)
{
return
$response
;
}
// Now that we've done the import check, check for CAN_EDIT.
PhabricatorPolicyFilter
::
requireCapability
(
$viewer
,
$event
,
PhabricatorPolicyCapability
::
CAN_EDIT
);
$cancel_uri
=
$event
->
getURI
();
$is_parent
=
$event
->
isParentEvent
();
$is_child
=
$event
->
isChildEvent
();
$is_cancelled
=
$event
->
getIsCancelled
();
if
(
$is_child
)
{
$is_parent_cancelled
=
$event
->
getParentEvent
()->
getIsCancelled
();
}
else
{
$is_parent_cancelled
=
false
;
}
$validation_exception
=
null
;
if
(
$request
->
isFormPost
())
{
$xactions
=
array
();
$xaction
=
id
(
new
PhabricatorCalendarEventTransaction
())
->
setTransactionType
(
PhabricatorCalendarEventCancelTransaction
::
TRANSACTIONTYPE
)
->
setNewValue
(!
$is_cancelled
);
$editor
=
id
(
new
PhabricatorCalendarEventEditor
())
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnNoEffect
(
true
)
->
setContinueOnMissingFields
(
true
);
try
{
$editor
->
applyTransactions
(
$event
,
array
(
$xaction
));
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$cancel_uri
);
}
catch
(
PhabricatorApplicationTransactionValidationException
$ex
)
{
$validation_exception
=
$ex
;
}
}
if
(
$is_cancelled
)
{
if
(
$is_parent_cancelled
)
{
$title
=
pht
(
'Cannot Reinstate Instance'
);
$paragraph
=
pht
(
'You cannot reinstate an instance of a cancelled recurring event.'
);
$cancel
=
pht
(
'Back'
);
$submit
=
null
;
}
else
if
(
$is_child
)
{
$title
=
pht
(
'Reinstate Instance'
);
$paragraph
=
pht
(
'Reinstate this instance of this recurring event?'
);
$cancel
=
pht
(
'Back'
);
$submit
=
pht
(
'Reinstate Instance'
);
}
else
if
(
$is_parent
)
{
$title
=
pht
(
'Reinstate Recurring Event'
);
$paragraph
=
pht
(
'Reinstate all instances of this recurring event which have not '
.
'been individually cancelled?'
);
$cancel
=
pht
(
'Back'
);
$submit
=
pht
(
'Reinstate Recurring Event'
);
}
else
{
$title
=
pht
(
'Reinstate Event'
);
$paragraph
=
pht
(
'Reinstate this event?'
);
$cancel
=
pht
(
'Back'
);
$submit
=
pht
(
'Reinstate Event'
);
}
}
else
{
if
(
$is_child
)
{
$title
=
pht
(
'Cancel Instance'
);
$paragraph
=
pht
(
'Cancel this instance of this recurring event?'
);
$cancel
=
pht
(
'Back'
);
$submit
=
pht
(
'Cancel Instance'
);
}
else
if
(
$is_parent
)
{
$title
=
pht
(
'Cancel Recurrin Event'
);
$paragraph
=
pht
(
'Cancel this entire series of recurring events?'
);
$cancel
=
pht
(
'Back'
);
$submit
=
pht
(
'Cancel Recurring Event'
);
}
else
{
$title
=
pht
(
'Cancel Event'
);
$paragraph
=
pht
(
'Cancel this event? You can always reinstate the event later.'
);
$cancel
=
pht
(
'Back'
);
$submit
=
pht
(
'Cancel Event'
);
}
}
return
$this
->
newDialog
()
->
setTitle
(
$title
)
->
setValidationException
(
$validation_exception
)
->
appendParagraph
(
$paragraph
)
->
addCancelButton
(
$cancel_uri
,
$cancel
)
->
addSubmitButton
(
$submit
);
}
}
Event Timeline
Log In to Comment