X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=blobdiff_plain;f=includes%2FTitle.php;h=3e6f11bd1ea7eecc251fcb0273c39ac59f8c5d6d;hb=386ba287d7716007e6a448674e0375bec15abbb1;hp=56c2ed4be9c9ae3cabf63dfa95b1726a751d2f52;hpb=17ff55004c2fa2eeac6b8c246edeacbfd412abb9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Title.php b/includes/Title.php index 56c2ed4be9..3e6f11bd1e 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1441,7 +1441,7 @@ class Title { $url = str_replace( '$1', $dbkey, $wgArticlePath ); wfRunHooks( 'GetLocalURL::Article', array( &$this, &$url ) ); } else { - global $wgVariantArticlePath, $wgActionPaths; + global $wgVariantArticlePath, $wgActionPaths, $wgContLang; $url = false; $matches = array(); @@ -1463,6 +1463,7 @@ class Title { if ( $url === false && $wgVariantArticlePath && + $wgContLang->getCode() === $this->getPageLanguage()->getCode() && $this->getPageLanguage()->hasVariants() && preg_match( '/^variant=([^&]*)$/', $query, $matches ) ) { @@ -1925,18 +1926,21 @@ class Title { */ private function checkPageRestrictions( $action, $user, $errors, $doExpensiveQueries, $short ) { foreach ( $this->getRestrictions( $action ) as $right ) { - // Backwards compatibility, rewrite sysop -> protect + // Backwards compatibility, rewrite sysop -> editprotected if ( $right == 'sysop' ) { - $right = 'protect'; + $right = 'editprotected'; } - if ( $right != '' && !$user->isAllowed( $right ) ) { - // Users with 'editprotected' permission can edit protected pages - // without cascading option turned on. - if ( $action != 'edit' || !$user->isAllowed( 'editprotected' ) - || $this->mCascadeRestriction ) - { - $errors[] = array( 'protectedpagetext', $right ); - } + // Backwards compatibility, rewrite autoconfirmed -> editsemiprotected + if ( $right == 'autoconfirmed' ) { + $right = 'editsemiprotected'; + } + if ( $right == '' ) { + continue; + } + if ( !$user->isAllowed( $right ) ) { + $errors[] = array( 'protectedpagetext', $right ); + } elseif ( $this->mCascadeRestriction && !$user->isAllowed( 'protect' ) ) { + $errors[] = array( 'protectedpagetext', 'protect' ); } } @@ -1968,8 +1972,15 @@ class Title { # This is only for protection restrictions, not for all actions if ( isset( $restrictions[$action] ) ) { foreach ( $restrictions[$action] as $right ) { - $right = ( $right == 'sysop' ) ? 'protect' : $right; - if ( $right != '' && !$user->isAllowed( $right ) ) { + // Backwards compatibility, rewrite sysop -> editprotected + if ( $right == 'sysop' ) { + $right = 'editprotected'; + } + // Backwards compatibility, rewrite autoconfirmed -> editsemiprotected + if ( $right == 'autoconfirmed' ) { + $right = 'editsemiprotected'; + } + if ( $right != '' && !$user->isAllowedAll( 'protect', $right ) ) { $pages = ''; foreach ( $cascadingSources as $page ) { $pages .= '* [[:' . $page->getPrefixedText() . "]]\n"; @@ -2006,7 +2017,10 @@ class Title { $title_protection = $this->getTitleProtection(); if ( $title_protection ) { if ( $title_protection['pt_create_perm'] == 'sysop' ) { - $title_protection['pt_create_perm'] = 'protect'; // B/C + $title_protection['pt_create_perm'] = 'editprotected'; // B/C + } + if ( $title_protection['pt_create_perm'] == 'autoconfirmed' ) { + $title_protection['pt_create_perm'] = 'editsemiprotected'; // B/C } if ( $title_protection['pt_create_perm'] == '' || !$user->isAllowed( $title_protection['pt_create_perm'] ) ) @@ -2086,34 +2100,10 @@ class Title { * @return Array list of errors */ private function checkReadPermissions( $action, $user, $errors, $doExpensiveQueries, $short ) { - global $wgWhitelistRead, $wgWhitelistReadRegexp, $wgRevokePermissions; - static $useShortcut = null; - - # Initialize the $useShortcut boolean, to determine if we can skip quite a bit of code below - if ( is_null( $useShortcut ) ) { - $useShortcut = true; - if ( !User::groupHasPermission( '*', 'read' ) ) { - # Not a public wiki, so no shortcut - $useShortcut = false; - } elseif ( !empty( $wgRevokePermissions ) ) { - /** - * Iterate through each group with permissions being revoked (key not included since we don't care - * what the group name is), then check if the read permission is being revoked. If it is, then - * we don't use the shortcut below since the user might not be able to read, even though anon - * reading is allowed. - */ - foreach ( $wgRevokePermissions as $perms ) { - if ( !empty( $perms['read'] ) ) { - # We might be removing the read right from the user, so no shortcut - $useShortcut = false; - break; - } - } - } - } + global $wgWhitelistRead, $wgWhitelistReadRegexp; $whitelisted = false; - if ( $useShortcut ) { + if ( User::isEveryoneAllowed( 'read' ) ) { # Shortcut for public wikis, allows skipping quite a bit of code $whitelisted = true; } elseif ( $user->isAllowed( 'read' ) ) { @@ -2376,7 +2366,9 @@ class Title { $restrictions = $this->getRestrictions( $action ); if ( count( $restrictions ) > 0 ) { foreach ( $restrictions as $restriction ) { - if ( strtolower( $restriction ) != 'autoconfirmed' ) { + if ( strtolower( $restriction ) != 'editsemiprotected' && + strtolower( $restriction ) != 'autoconfirmed' // BC + ) { return false; } } @@ -3548,7 +3540,13 @@ class Title { } } else { $tp = $nt->getTitleProtection(); - $right = ( $tp['pt_create_perm'] == 'sysop' ) ? 'protect' : $tp['pt_create_perm']; + $right = $tp['pt_create_perm']; + if ( $right == 'sysop' ) { + $right = 'editprotected'; // B/C + } + if ( $right == 'autoconfirmed' ) { + $right = 'editsemiprotected'; // B/C + } if ( $tp and !$wgUser->isAllowed( $right ) ) { $errors[] = array( 'cantmove-titleprotected' ); } @@ -3622,6 +3620,8 @@ class Title { $createRedirect = true; } + wfRunHooks( 'TitleMove', array( $this, $nt, $wgUser ) ); + // If it is a file, move it first. // It is done before all other moving stuff is done because it's hard to revert. $dbw = wfGetDB( DB_MASTER ); @@ -4754,9 +4754,10 @@ class Title { * they will already be wrapped in paragraphs. * * @since 1.21 + * @param int oldid Revision ID that's being edited * @return Array */ - public function getEditNotices() { + public function getEditNotices( $oldid = 0 ) { $notices = array(); # Optional notices on a per-namespace and per-page basis @@ -4783,6 +4784,8 @@ class Title { $notices[$editnoticeText] = $editnoticeMsg->parseAsBlock(); } } + + wfRunHooks( 'TitleGetEditNotices', array( $this, $oldid, &$notices ) ); return $notices; } }