*
* May provide false positives, but should never provide a false negative.
*
- * @param string $action action that permission needs to be checked for
+ * @param $action String: action that permission needs to be checked for
+ * @param $user User object, optional
* @return boolean
*/
- public function quickUserCan( $action ) {
- return $this->userCan( $action, false );
+ public function quickUserCan( $action, $user = null ) {
+ return $this->userCan( $action, false, $user );
}
/**
/**
* Can $wgUser perform $action on this page?
- * @param string $action action that permission needs to be checked for
- * @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries.
+ * @param $action String: action that permission needs to be checked for
+ * @param $doExpensiveQueries Bool: set this to false to avoid doing unnecessary queries.
+ * @param $user User object, optional
* @return boolean
*/
- public function userCan( $action, $doExpensiveQueries = true ) {
- global $wgUser;
- return ( $this->getUserPermissionsErrorsInternal( $action, $wgUser, $doExpensiveQueries ) === array());
+ public function userCan( $action, $doExpensiveQueries = true, $user = null ) {
+ if( $user === null ){
+ global $wgUser;
+ $user = $wgUser;
+ }
+ return ( $this->getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries ) === array());
}
/**
* @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries.
* @return array Array of arrays of the arguments to wfMsg to explain permissions problems.
*/
- public function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true ) {
+ private function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true ) {
wfProfileIn( __METHOD__ );
$errors = array();
$section = $sectionIndex;
$tooltip = '';
}
- // Use Title::getUserPermissionsErrorsInternal() so that we can pass our User object
- if( $titleObj->getUserPermissionsErrorsInternal( 'edit', $this->mOptions->getUser(), false ) === array() ){
+ if( $titleObj->quickUserCan( 'edit', $this->mOptions->getUser() ) ){
$editlink = $sk->doEditSectionLink( $titleObj, $section, $tooltip );
} else {
$editlink = '';