Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92727498
PhabricatorPeopleProfileEditController.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, Nov 23, 04:49
Size
2 KB
Mime Type
text/x-php
Expires
Mon, Nov 25, 04:49 (2 d)
Engine
blob
Format
Raw Data
Handle
22481044
Attached To
rPH Phabricator
PhabricatorPeopleProfileEditController.php
View Options
<?php
final
class
PhabricatorPeopleProfileEditController
extends
PhabricatorPeopleController
{
private
$id
;
public
function
shouldRequireAdmin
()
{
return
false
;
}
public
function
willProcessRequest
(
array
$data
)
{
$this
->
id
=
$data
[
'id'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$user
=
id
(
new
PhabricatorPeopleQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$this
->
id
))
->
needProfileImage
(
true
)
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$user
)
{
return
new
Aphront404Response
();
}
$profile_uri
=
'/p/'
.
$user
->
getUsername
().
'/'
;
$field_list
=
PhabricatorCustomField
::
getObjectFields
(
$user
,
PhabricatorCustomField
::
ROLE_EDIT
);
$field_list
->
setViewer
(
$viewer
)
->
readFieldsFromStorage
(
$user
);
$validation_exception
=
null
;
if
(
$request
->
isFormPost
())
{
$xactions
=
$field_list
->
buildFieldTransactionsFromRequest
(
new
PhabricatorUserTransaction
(),
$request
);
$editor
=
id
(
new
PhabricatorUserProfileEditor
())
->
setActor
(
$viewer
)
->
setContentSource
(
PhabricatorContentSource
::
newFromRequest
(
$request
))
->
setContinueOnNoEffect
(
true
);
try
{
$editor
->
applyTransactions
(
$user
,
$xactions
);
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$profile_uri
);
}
catch
(
PhabricatorApplicationTransactionValidationException
$ex
)
{
$validation_exception
=
$ex
;
}
}
$title
=
pht
(
'Edit Profile'
);
$form
=
id
(
new
AphrontFormView
())
->
setUser
(
$viewer
);
$field_list
->
appendFieldsToForm
(
$form
);
$form
->
appendChild
(
id
(
new
AphrontFormSubmitControl
())
->
addCancelButton
(
$profile_uri
)
->
setValue
(
pht
(
'Save Profile'
)));
$form_box
=
id
(
new
PHUIObjectBoxView
())
->
setHeaderText
(
pht
(
'Edit Profile'
))
->
setValidationException
(
$validation_exception
)
->
setForm
(
$form
);
$nav
=
$this
->
buildIconNavView
(
$user
);
$nav
->
selectFilter
(
'/'
);
$nav
->
appendChild
(
$form_box
);
return
$this
->
buildApplicationPage
(
$nav
,
array
(
'title'
=>
$title
,
));
}
}
Event Timeline
Log In to Comment