Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93462273
PhabricatorProjectBoardEditController.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
Thu, Nov 28, 23:17
Size
4 KB
Mime Type
text/x-php
Expires
Sat, Nov 30, 23:17 (2 d)
Engine
blob
Format
Raw Data
Handle
22645009
Attached To
rPH Phabricator
PhabricatorProjectBoardEditController.php
View Options
<?php
final
class
PhabricatorProjectBoardEditController
extends
PhabricatorProjectBoardController
{
private
$id
;
private
$projectID
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
projectID
=
$data
[
'projectID'
];
$this
->
id
=
idx
(
$data
,
'id'
);
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$project
=
id
(
new
PhabricatorProjectQuery
())
->
setViewer
(
$viewer
)
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
withIDs
(
array
(
$this
->
projectID
))
->
executeOne
();
if
(!
$project
)
{
return
new
Aphront404Response
();
}
$this
->
setProject
(
$project
);
$is_new
=
(
$this
->
id
?
false
:
true
);
if
(!
$is_new
)
{
$column
=
id
(
new
PhabricatorProjectColumnQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$this
->
id
))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$column
)
{
return
new
Aphront404Response
();
}
}
else
{
$column
=
PhabricatorProjectColumn
::
initializeNewColumn
(
$viewer
);
}
$e_name
=
null
;
$validation_exception
=
null
;
$base_uri
=
'/board/'
.
$this
->
projectID
.
'/'
;
if
(
$is_new
)
{
// we want to go back to the board
$view_uri
=
$this
->
getApplicationURI
(
$base_uri
);
}
else
{
$view_uri
=
$this
->
getApplicationURI
(
$base_uri
.
'column/'
.
$this
->
id
.
'/'
);
}
if
(
$request
->
isFormPost
())
{
$new_name
=
$request
->
getStr
(
'name'
);
if
(
$is_new
)
{
$column
->
setProjectPHID
(
$project
->
getPHID
());
$column
->
attachProject
(
$project
);
$columns
=
id
(
new
PhabricatorProjectColumnQuery
())
->
setViewer
(
$viewer
)
->
withProjectPHIDs
(
array
(
$project
->
getPHID
()))
->
execute
();
$new_sequence
=
1
;
if
(
$columns
)
{
$values
=
mpull
(
$columns
,
'getSequence'
);
$new_sequence
=
max
(
$values
)
+
1
;
}
$column
->
setSequence
(
$new_sequence
);
}
$type_name
=
PhabricatorProjectColumnTransaction
::
TYPE_NAME
;
$xactions
=
array
(
id
(
new
PhabricatorProjectColumnTransaction
())
->
setTransactionType
(
$type_name
)
->
setNewValue
(
$new_name
));
try
{
$editor
=
id
(
new
PhabricatorProjectColumnTransactionEditor
())
->
setActor
(
$viewer
)
->
setContinueOnNoEffect
(
true
)
->
setContentSourceFromRequest
(
$request
)
->
applyTransactions
(
$column
,
$xactions
);
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$view_uri
);
}
catch
(
PhabricatorApplicationTransactionValidationException
$ex
)
{
$e_name
=
$ex
->
getShortMessage
(
$type_name
);
$validation_exception
=
$ex
;
}
}
$form
=
new
AphrontFormView
();
$form
->
setUser
(
$request
->
getUser
())
->
appendChild
(
id
(
new
AphrontFormTextControl
())
->
setValue
(
$column
->
getName
())
->
setLabel
(
pht
(
'Name'
))
->
setName
(
'name'
)
->
setError
(
$e_name
)
->
setCaption
(
pht
(
'This will be displayed as the header of the column.'
)));
if
(
$is_new
)
{
$title
=
pht
(
'Create Column'
);
$submit
=
pht
(
'Create Column'
);
}
else
{
$title
=
pht
(
'Edit %s'
,
$column
->
getName
());
$submit
=
pht
(
'Save Column'
);
}
$form
->
appendChild
(
id
(
new
AphrontFormSubmitControl
())
->
setValue
(
$submit
)
->
addCancelButton
(
$view_uri
));
$crumbs
=
$this
->
buildApplicationCrumbs
();
$crumbs
->
addTextCrumb
(
pht
(
'Board'
),
$this
->
getApplicationURI
(
'board/'
.
$project
->
getID
().
'/'
));
$crumbs
->
addTextCrumb
(
$title
);
$form_box
=
id
(
new
PHUIObjectBoxView
())
->
setHeaderText
(
$title
)
->
setValidationException
(
$validation_exception
)
->
setForm
(
$form
);
return
$this
->
buildApplicationPage
(
array
(
$crumbs
,
$form_box
,
),
array
(
'title'
=>
$title
,
));
}
}
Event Timeline
Log In to Comment