Page MenuHomePhabricator
Paste P7615

flow opt-out debug
ActivePublic

Authored by kostajh on Oct 2 2018, 2:28 PM.
Tags
None
Referenced Files
F26276439: flow opt-out debug
Oct 2 2018, 2:28 PM
Subscribers
None
<?php
use Flow\Container;
use User;
function checkFlowTalkPageManagerPermissions( $action, Title $talkpage, User $user ) {
$errors = [ 'talkpage' => $talkpage->getUserPermissionsErrors( 'edit', $user, 'secure' ) ];
$subpages = $talkpage->getSubpages();
/** @var Title $subpage */
foreach ( $subpages as $subpage ) {
$errors['subpages'][] = $subpage->getUserPermissionsErrors( 'edit', $user, 'secure' );
}
if ( count( $errors ) ) {
print "Found errors\n";
var_dump( $errors );
return false;
}
print "No errors\n";
return true;
}
$user_id = 0; // get from DB
$user = User::newFromId( $user_id );
/** @var \Flow\TalkpageManager $occupationController */
$occupationController = Container::get( 'occupation_controller' );
/** @var \Flow\Import\OptInController $optInController */
$optInController = Container::get( 'controller.opt_in' );
// Check permissions.
checkFlowTalkPageManagerPermissions( 'disable', $user->getTalkPage(), $occupationController->getTalkpageManager() );
$optInController->initiateChange( 'disable', $user->getTalkPage(), $user );