Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F123805591
20141107.phriction.policy.2.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
Tue, Jul 29, 16:35
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Jul 31, 16:35 (2 d)
Engine
blob
Format
Raw Data
Handle
27757009
Attached To
rPH Phabricator
20141107.phriction.policy.2.php
View Options
<?php
$table
=
new
PhrictionDocument
();
$conn_w
=
$table
->
establishConnection
(
'w'
);
echo
"Populating Phriction policies.
\n
"
;
$default_view_policy
=
PhabricatorPolicies
::
getMostOpenPolicy
();
$default_edit_policy
=
PhabricatorPolicies
::
POLICY_USER
;
foreach
(
new
LiskMigrationIterator
(
$table
)
as
$doc
)
{
$id
=
$doc
->
getID
();
if
(
$doc
->
getViewPolicy
()
&&
$doc
->
getEditPolicy
())
{
echo
"Skipping doc $id; already has policy set.
\n
"
;
continue
;
}
// project documents get the project policy
if
(
PhrictionDocument
::
isProjectSlug
(
$doc
->
getSlug
()))
{
$project_slug
=
PhrictionDocument
::
getProjectSlugIdentifier
(
$doc
->
getSlug
());
$project_slugs
=
array
(
$project_slug
);
$project
=
id
(
new
PhabricatorProjectQuery
())
->
setViewer
(
PhabricatorUser
::
getOmnipotentUser
())
->
withPhrictionSlugs
(
$project_slugs
)
->
executeOne
();
$project_name
=
$project
->
getName
();
echo
"Migrating doc $id to project policy $project_name...
\n
"
;
$doc
->
setViewPolicy
(
$project
->
getViewPolicy
());
$doc
->
setEditPolicy
(
$project
->
getEditPolicy
());
$doc
->
save
();
// non-project documents get the most open policy possible
}
else
{
echo
"Migrating doc $id to default install policy...
\n
"
;
$doc
->
setViewPolicy
(
$default_view_policy
);
$doc
->
setEditPolicy
(
$default_edit_policy
);
$doc
->
save
();
}
}
echo
"Done.
\n
"
;
Event Timeline
Log In to Comment