Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F460910
PhabricatorEditEngineConfigurationLockController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
PhabricatorEditEngineConfigurationLockController.php
View Options
<?php
final
class
PhabricatorEditEngineConfigurationLockController
extends
PhabricatorEditEngineController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$engine_key
=
$request
->
getURIData
(
'engineKey'
);
$this
->
setEngineKey
(
$engine_key
);
$key
=
$request
->
getURIData
(
'key'
);
$viewer
=
$this
->
getViewer
();
$config
=
id
(
new
PhabricatorEditEngineConfigurationQuery
())
->
setViewer
(
$viewer
)
->
withEngineKeys
(
array
(
$engine_key
))
->
withIdentifiers
(
array
(
$key
))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$config
)
{
return
id
(
new
Aphront404Response
());
}
$cancel_uri
=
"/transactions/editengine/{$engine_key}/view/{$key}/"
;
if
(
$request
->
isFormPost
())
{
$xactions
=
array
();
$locks
=
$request
->
getArr
(
'locks'
);
$type_locks
=
PhabricatorEditEngineConfigurationTransaction
::
TYPE_LOCKS
;
$xactions
[]
=
id
(
new
PhabricatorEditEngineConfigurationTransaction
())
->
setTransactionType
(
$type_locks
)
->
setNewValue
(
$locks
);
$editor
=
id
(
new
PhabricatorEditEngineConfigurationEditor
())
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnMissingFields
(
true
)
->
setContinueOnNoEffect
(
true
);
$editor
->
applyTransactions
(
$config
,
$xactions
);
return
id
(
new
AphrontRedirectResponse
())
->
setURI
(
$cancel_uri
);
}
$engine
=
$config
->
getEngine
();
$fields
=
$engine
->
getFieldsForConfig
(
$config
);
$help
=
pht
(
<<<EOTEXT
**Locked** fields are visible in the form, but their values can not be changed
by the user.
**Hidden** fields are not visible in the form.
Any assigned default values are still respected, even if the field is locked
or hidden.
EOTEXT
);
$form
=
id
(
new
AphrontFormView
())
->
setUser
(
$viewer
)
->
appendRemarkupInstructions
(
$help
);
$locks
=
$config
->
getFieldLocks
();
$lock_visible
=
PhabricatorEditEngineConfiguration
::
LOCK_VISIBLE
;
$lock_locked
=
PhabricatorEditEngineConfiguration
::
LOCK_LOCKED
;
$lock_hidden
=
PhabricatorEditEngineConfiguration
::
LOCK_HIDDEN
;
$map
=
array
(
$lock_visible
=>
pht
(
'Visible'
),
$lock_locked
=>
pht
(
"
\x
F0
\x
9F
\x
94
\x
92 Locked"
),
$lock_hidden
=>
pht
(
"
\x
E2
\x
9C
\x
98 Hidden"
),
);
foreach
(
$fields
as
$field
)
{
if
(!
$field
->
getIsLockable
())
{
continue
;
}
$key
=
$field
->
getKey
();
$label
=
$field
->
getLabel
();
if
(!
strlen
(
$label
))
{
$label
=
$key
;
}
$form
->
appendControl
(
id
(
new
AphrontFormSelectControl
())
->
setName
(
'locks['
.
$key
.
']'
)
->
setLabel
(
$label
)
->
setValue
(
idx
(
$locks
,
$key
,
$lock_visible
))
->
setOptions
(
$map
));
}
return
$this
->
newDialog
()
->
setTitle
(
pht
(
'Lock / Hide Fields'
))
->
setWidth
(
AphrontDialogView
::
WIDTH_FORM
)
->
appendForm
(
$form
)
->
addSubmitButton
(
pht
(
'Save Changes'
))
->
addCancelButton
(
$cancel_uri
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 5, 4:14 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
72206
Default Alt Text
PhabricatorEditEngineConfigurationLockController.php (3 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment