-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAdminChangeAnyFileVisibilityController.php
64 lines (54 loc) · 1.75 KB
/
AdminChangeAnyFileVisibilityController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
class AdminChangeAnyFileVisibilityController extends PhabricatorController {
public function handleRequest( AphrontRequest $request ) {
$viewer = $this->getViewer();
if ( !$viewer->getIsAdmin() ) {
return new Aphront403Response();
}
$id = $request->getInt( 'id' );
$path = $request->getStr( 'path' );
$file = null;
if ( $id ) {
$file = id( new PhabricatorFile() )
->loadOneWhere( 'id = %d', $id );
} elseif ( $path ) {
$file = id( new PhabricatorFile() )
->loadOneWhere( 'name = %s', $path );
}
$title = pht( 'Change File Visibility: %s', $file ? $file->getName() : '' );
$header = id( new PHUIHeaderView() )
->setHeader( $title );
$form = id( new AphrontFormView() )
->setUser( $viewer )
->setMethod( 'POST' )
->setAction( $this->getApplicationURI( 'file/visibility/' ) )
->appendChild(
id( new AphrontFormSelectControl() )
->setLabel( pht( 'Visibility' ) )
->setName( 'visibility' )
->setOptions( [
PhabricatorPolicies::POLICY_PUBLIC => pht( 'Public' ),
PhabricatorPolicies::POLICY_USER => pht( 'Logged In Users' ),
PhabricatorPolicies::POLICY_ADMIN => pht( 'Administrators' ),
PhabricatorPolicies::POLICY_NOONE => pht( 'Only Me' ),
] )
->setValue( $file ? $file->getViewPolicy() : PhabricatorPolicies::POLICY_NOONE )
)
->appendChild(
id( new AphrontFormTextControl() )
->setLabel( pht( 'ID' ) )
->setName( 'id' )
->setValue( $file ? $file->getID() : '' )
)
->appendChild(
id( new AphrontFormSubmitControl() )
->setValue( pht( 'Save Visibility' ) )
);
$view = id( new PHUITwoColumnView() )
->setHeader( $header )
->setFooter( $form );
return $this->newPage()
->setTitle( $title )
->appendChild( $view );
}
}