Example #1
0
 function onView()
 {
     global $wgSquidMaxage, $wgForcedRawSMaxage, $wgJsMimeType;
     $this->getOutput()->disable();
     $request = $this->getRequest();
     if (!$request->checkUrlExtension()) {
         return;
     }
     if ($this->getOutput()->checkLastModified($this->page->getTouched())) {
         return;
         // Client cache fresh and headers sent, nothing more to do.
     }
     # special case for 'generated' raw things: user css/js
     # This is deprecated and will only return empty content
     $gen = $request->getVal('gen');
     $smaxage = $request->getIntOrNull('smaxage');
     if ($gen == 'css' || $gen == 'js') {
         $this->mGen = $gen;
         if ($smaxage === null) {
             $smaxage = $wgSquidMaxage;
         }
     } else {
         $this->mGen = false;
     }
     $contentType = $this->getContentType();
     # Force caching for CSS and JS raw content, default: 5 minutes
     if ($smaxage === null) {
         if ($contentType == 'text/css' || $contentType == $wgJsMimeType) {
             $smaxage = intval($wgForcedRawSMaxage);
         } else {
             $smaxage = 0;
         }
     }
     $maxage = $request->getInt('maxage', $wgSquidMaxage);
     $response = $request->response();
     $response->header('Content-type: ' . $contentType . '; charset=UTF-8');
     # Output may contain user-specific data;
     # vary generated content for open sessions on private wikis
     $privateCache = !User::groupHasPermission('*', 'read') && ($smaxage == 0 || session_id() != '');
     # allow the client to cache this for 24 hours
     $mode = $privateCache ? 'private' : 'public';
     $response->header('Cache-Control: ' . $mode . ', s-maxage=' . $smaxage . ', max-age=' . $maxage);
     $text = $this->getRawText();
     if ($text === false && $contentType == 'text/x-wiki') {
         # Don't return a 404 response for CSS or JavaScript;
         # 404s aren't generally cached and it would create
         # extra hits when user CSS/JS are on and the user doesn't
         # have the pages.
         $response->header('HTTP/1.x 404 Not Found');
     }
     if (!wfRunHooks('RawPageViewBeforeOutput', array(&$this, &$text))) {
         wfDebug(__METHOD__ . ": RawPageViewBeforeOutput hook broke raw page output.\n");
     }
     echo $text;
 }
Example #2
0
 function getQueryInfo()
 {
     $conds = [];
     $conds['rc_new'] = 1;
     $namespace = $this->opts->getValue('namespace');
     $namespace = $namespace === 'all' ? false : intval($namespace);
     $username = $this->opts->getValue('username');
     $user = Title::makeTitleSafe(NS_USER, $username);
     $size = abs(intval($this->opts->getValue('size')));
     if ($size > 0) {
         if ($this->opts->getValue('size-mode') === 'max') {
             $conds[] = 'page_len <= ' . $size;
         } else {
             $conds[] = 'page_len >= ' . $size;
         }
     }
     $rcIndexes = [];
     if ($namespace !== false) {
         if ($this->opts->getValue('invert')) {
             $conds[] = 'rc_namespace != ' . $this->mDb->addQuotes($namespace);
         } else {
             $conds['rc_namespace'] = $namespace;
         }
     }
     if ($user) {
         $conds['rc_user_text'] = $user->getText();
         $rcIndexes = 'rc_user_text';
     } elseif (User::groupHasPermission('*', 'createpage') && $this->opts->getValue('hideliu')) {
         # If anons cannot make new pages, don't "exclude logged in users"!
         $conds['rc_user'] = 0;
     }
     # If this user cannot see patrolled edits or they are off, don't do dumb queries!
     if ($this->opts->getValue('hidepatrolled') && $this->getUser()->useNPPatrol()) {
         $conds['rc_patrolled'] = 0;
     }
     if ($this->opts->getValue('hidebots')) {
         $conds['rc_bot'] = 0;
     }
     if ($this->opts->getValue('hideredirs')) {
         $conds['page_is_redirect'] = 0;
     }
     // Allow changes to the New Pages query
     $tables = ['recentchanges', 'page'];
     $fields = ['rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user', 'rc_user_text', 'rc_comment', 'rc_timestamp', 'rc_patrolled', 'rc_id', 'rc_deleted', 'length' => 'page_len', 'rev_id' => 'page_latest', 'rc_this_oldid', 'page_namespace', 'page_title'];
     $join_conds = ['page' => ['INNER JOIN', 'page_id=rc_cur_id']];
     Hooks::run('SpecialNewpagesConditions', [&$this, $this->opts, &$conds, &$tables, &$fields, &$join_conds]);
     $options = [];
     if ($rcIndexes) {
         $options = ['USE INDEX' => ['recentchanges' => $rcIndexes]];
     }
     $info = ['tables' => $tables, 'fields' => $fields, 'conds' => $conds, 'options' => $options, 'join_conds' => $join_conds];
     // Modify query for tags
     ChangeTags::modifyDisplayQuery($info['tables'], $info['fields'], $info['conds'], $info['join_conds'], $info['options'], $this->opts['tagfilter']);
     return $info;
 }
Example #3
0
 /**
  * Output a standard permission error page
  *
  * @param array $errors Error message keys
  * @param string $action Action that was denied or null if unknown
  */
 public function showPermissionsErrorPage(array $errors, $action = null)
 {
     // For some action (read, edit, create and upload), display a "login to do this action"
     // error if all of the following conditions are met:
     // 1. the user is not logged in
     // 2. the only error is insufficient permissions (i.e. no block or something else)
     // 3. the error can be avoided simply by logging in
     if (in_array($action, array('read', 'edit', 'createpage', 'createtalk', 'upload')) && $this->getUser()->isAnon() && count($errors) == 1 && isset($errors[0][0]) && ($errors[0][0] == 'badaccess-groups' || $errors[0][0] == 'badaccess-group0') && (User::groupHasPermission('user', $action) || User::groupHasPermission('autoconfirmed', $action))) {
         $displayReturnto = null;
         # Due to bug 32276, if a user does not have read permissions,
         # $this->getTitle() will just give Special:Badtitle, which is
         # not especially useful as a returnto parameter. Use the title
         # from the request instead, if there was one.
         $request = $this->getRequest();
         $returnto = Title::newFromURL($request->getVal('title', ''));
         if ($action == 'edit') {
             $msg = 'whitelistedittext';
             $displayReturnto = $returnto;
         } elseif ($action == 'createpage' || $action == 'createtalk') {
             $msg = 'nocreatetext';
         } elseif ($action == 'upload') {
             $msg = 'uploadnologintext';
         } else {
             # Read
             $msg = 'loginreqpagetext';
             $displayReturnto = Title::newMainPage();
         }
         $query = array();
         if ($returnto) {
             $query['returnto'] = $returnto->getPrefixedText();
             if (!$request->wasPosted()) {
                 $returntoquery = $request->getValues();
                 unset($returntoquery['title']);
                 unset($returntoquery['returnto']);
                 unset($returntoquery['returntoquery']);
                 $query['returntoquery'] = wfArrayToCgi($returntoquery);
             }
         }
         $loginLink = Linker::linkKnown(SpecialPage::getTitleFor('Userlogin'), $this->msg('loginreqlink')->escaped(), array(), $query);
         $this->prepareErrorPage($this->msg('loginreqtitle'));
         $this->addHTML($this->msg($msg)->rawParams($loginLink)->parse());
         # Don't return to a page the user can't read otherwise
         # we'll end up in a pointless loop
         if ($displayReturnto && $displayReturnto->userCan('read', $this->getUser())) {
             $this->returnToMain(null, $displayReturnto);
         }
     } else {
         $this->prepareErrorPage($this->msg('permissionserrors'));
         $this->addWikiText($this->formatPermissionsErrorMessage($errors, $action));
     }
 }
Example #4
0
 /**
  * Permissions checks that fail most often, and which are easiest to test.
  *
  * @param string $action The action to check
  * @param User $user User to check
  * @param array $errors List of current errors
  * @param string $rigor Same format as Title::getUserPermissionsErrors()
  * @param bool $short Short circuit on first error
  *
  * @return array List of errors
  */
 private function checkQuickPermissions($action, $user, $errors, $rigor, $short)
 {
     if (!Hooks::run('TitleQuickPermissions', array($this, $user, $action, &$errors, $rigor !== 'quick', $short))) {
         return $errors;
     }
     if ($action == 'create') {
         if ($this->isTalkPage() && !$user->isAllowed('createtalk') || !$this->isTalkPage() && !$user->isAllowed('createpage')) {
             $errors[] = $user->isAnon() ? array('nocreatetext') : array('nocreate-loggedin');
         }
     } elseif ($action == 'move') {
         if (!$user->isAllowed('move-rootuserpages') && $this->mNamespace == NS_USER && !$this->isSubpage()) {
             // Show user page-specific message only if the user can move other pages
             $errors[] = array('cant-move-user-page');
         }
         // Check if user is allowed to move files if it's a file
         if ($this->mNamespace == NS_FILE && !$user->isAllowed('movefile')) {
             $errors[] = array('movenotallowedfile');
         }
         // Check if user is allowed to move category pages if it's a category page
         if ($this->mNamespace == NS_CATEGORY && !$user->isAllowed('move-categorypages')) {
             $errors[] = array('cant-move-category-page');
         }
         if (!$user->isAllowed('move')) {
             // User can't move anything
             $userCanMove = User::groupHasPermission('user', 'move');
             $autoconfirmedCanMove = User::groupHasPermission('autoconfirmed', 'move');
             if ($user->isAnon() && ($userCanMove || $autoconfirmedCanMove)) {
                 // custom message if logged-in users without any special rights can move
                 $errors[] = array('movenologintext');
             } else {
                 $errors[] = array('movenotallowed');
             }
         }
     } elseif ($action == 'move-target') {
         if (!$user->isAllowed('move')) {
             // User can't move anything
             $errors[] = array('movenotallowed');
         } elseif (!$user->isAllowed('move-rootuserpages') && $this->mNamespace == NS_USER && !$this->isSubpage()) {
             // Show user page-specific message only if the user can move other pages
             $errors[] = array('cant-move-to-user-page');
         } elseif (!$user->isAllowed('move-categorypages') && $this->mNamespace == NS_CATEGORY) {
             // Show category page-specific message only if the user can move other pages
             $errors[] = array('cant-move-to-category-page');
         }
     } elseif (!$user->isAllowed($action)) {
         $errors[] = $this->missingPermissionError($action, $short);
     }
     return $errors;
 }
 function getQueryInfo()
 {
     global $wgEnableNewpagesUserFilter;
     $conds = array();
     $conds['rc_new'] = 1;
     $namespace = $this->opts->getValue('namespace');
     $namespace = $namespace === 'all' ? false : intval($namespace);
     $username = $this->opts->getValue('username');
     $user = Title::makeTitleSafe(NS_USER, $username);
     if ($namespace !== false) {
         if ($this->opts->getValue('invert')) {
             $conds[] = 'rc_namespace != ' . $this->mDb->addQuotes($namespace);
         } else {
             $conds['rc_namespace'] = $namespace;
         }
         $rcIndexes = array('new_name_timestamp');
     } else {
         $rcIndexes = array('rc_timestamp');
     }
     # $wgEnableNewpagesUserFilter - temp WMF hack
     if ($wgEnableNewpagesUserFilter && $user) {
         $conds['rc_user_text'] = $user->getText();
         $rcIndexes = 'rc_user_text';
         # If anons cannot make new pages, don't "exclude logged in users"!
     } elseif (User::groupHasPermission('*', 'createpage') && $this->opts->getValue('hideliu')) {
         $conds['rc_user'] = 0;
     }
     # If this user cannot see patrolled edits or they are off, don't do dumb queries!
     if ($this->opts->getValue('hidepatrolled') && $this->getUser()->useNPPatrol()) {
         $conds['rc_patrolled'] = 0;
     }
     if ($this->opts->getValue('hidebots')) {
         $conds['rc_bot'] = 0;
     }
     if ($this->opts->getValue('hideredirs')) {
         $conds['page_is_redirect'] = 0;
     }
     // Allow changes to the New Pages query
     $tables = array('recentchanges', 'page');
     $fields = array('rc_namespace', 'rc_title', 'rc_cur_id', 'rc_user', 'rc_user_text', 'rc_comment', 'rc_timestamp', 'rc_patrolled', 'rc_id', 'rc_deleted', 'length' => 'page_len', 'rev_id' => 'page_latest', 'rc_this_oldid', 'page_namespace', 'page_title');
     $join_conds = array('page' => array('INNER JOIN', 'page_id=rc_cur_id'));
     wfRunHooks('SpecialNewpagesConditions', array(&$this, $this->opts, &$conds, &$tables, &$fields, &$join_conds));
     $info = array('tables' => $tables, 'fields' => $fields, 'conds' => $conds, 'options' => array('USE INDEX' => array('recentchanges' => $rcIndexes)), 'join_conds' => $join_conds);
     // Modify query for tags
     ChangeTags::modifyDisplayQuery($info['tables'], $info['fields'], $info['conds'], $info['join_conds'], $info['options'], $this->opts['tagfilter']);
     return $info;
 }
 public function isRestricted()
 {
     return !User::groupHasPermission('*', 'createaccount');
 }
Example #7
0
 /**
  * build array of urls for personal toolbar
  * @return array
  */
 protected function buildPersonalUrls()
 {
     $title = $this->getTitle();
     $request = $this->getRequest();
     $pageurl = $title->getLocalURL();
     /* set up the default links for the personal toolbar */
     $personal_urls = array();
     # Due to bug 32276, if a user does not have read permissions,
     # $this->getTitle() will just give Special:Badtitle, which is
     # not especially useful as a returnto parameter. Use the title
     # from the request instead, if there was one.
     if ($this->getUser()->isAllowed('read')) {
         $page = $this->getTitle();
     } else {
         $page = Title::newFromText($request->getVal('title', ''));
     }
     $page = $request->getVal('returnto', $page);
     $a = array();
     if (strval($page) !== '') {
         $a['returnto'] = $page;
         $query = $request->getVal('returntoquery', $this->thisquery);
         if ($query != '') {
             $a['returntoquery'] = $query;
         }
     }
     $returnto = wfArrayToCgi($a);
     if ($this->loggedin) {
         $personal_urls['userpage'] = array('text' => $this->username, 'href' => &$this->userpageUrlDetails['href'], 'class' => $this->userpageUrlDetails['exists'] ? false : 'new', 'active' => $this->userpageUrlDetails['href'] == $pageurl, 'dir' => 'auto');
         $usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage);
         $personal_urls['mytalk'] = array('text' => $this->msg('mytalk')->text(), 'href' => &$usertalkUrlDetails['href'], 'class' => $usertalkUrlDetails['exists'] ? false : 'new', 'active' => $usertalkUrlDetails['href'] == $pageurl);
         $href = self::makeSpecialUrl('Preferences');
         $personal_urls['preferences'] = array('text' => $this->msg('mypreferences')->text(), 'href' => $href, 'active' => $href == $pageurl);
         if ($this->getUser()->isAllowed('viewmywatchlist')) {
             $href = self::makeSpecialUrl('Watchlist');
             $personal_urls['watchlist'] = array('text' => $this->msg('mywatchlist')->text(), 'href' => $href, 'active' => $href == $pageurl);
         }
         # We need to do an explicit check for Special:Contributions, as we
         # have to match both the title, and the target, which could come
         # from request values (Special:Contributions?target=Jimbo_Wales)
         # or be specified in "sub page" form
         # (Special:Contributions/Jimbo_Wales). The plot
         # thickens, because the Title object is altered for special pages,
         # so it doesn't contain the original alias-with-subpage.
         $origTitle = Title::newFromText($request->getText('title'));
         if ($origTitle instanceof Title && $origTitle->isSpecialPage()) {
             list($spName, $spPar) = SpecialPageFactory::resolveAlias($origTitle->getText());
             $active = $spName == 'Contributions' && ($spPar && $spPar == $this->username || $request->getText('target') == $this->username);
         } else {
             $active = false;
         }
         $href = self::makeSpecialUrlSubpage('Contributions', $this->username);
         $personal_urls['mycontris'] = array('text' => $this->msg('mycontris')->text(), 'href' => $href, 'active' => $active);
         $personal_urls['logout'] = array('text' => $this->msg('pt-userlogout')->text(), 'href' => self::makeSpecialUrl('Userlogout', $title->isSpecial('Preferences') ? 'noreturnto' : $returnto), 'active' => false);
     } else {
         $useCombinedLoginLink = $this->useCombinedLoginLink();
         $loginlink = $this->getUser()->isAllowed('createaccount') && $useCombinedLoginLink ? 'nav-login-createaccount' : 'pt-login';
         $is_signup = $request->getText('type') == 'signup';
         $login_url = array('text' => $this->msg($loginlink)->text(), 'href' => self::makeSpecialUrl('Userlogin', $returnto), 'active' => $title->isSpecial('Userlogin') && ($loginlink == 'nav-login-createaccount' || !$is_signup));
         $createaccount_url = array('text' => $this->msg('pt-createaccount')->text(), 'href' => self::makeSpecialUrl('Userlogin', "{$returnto}&type=signup"), 'active' => $title->isSpecial('Userlogin') && $is_signup);
         // No need to show Talk and Contributions to anons if they can't contribute!
         if (User::groupHasPermission('*', 'edit')) {
             // Show the text "Not logged in"
             $personal_urls['anonuserpage'] = array('text' => $this->msg('notloggedin')->text());
             // Because of caching, we can't link directly to the IP talk and
             // contributions pages. Instead we use the special page shortcuts
             // (which work correctly regardless of caching). This means we can't
             // determine whether these links are active or not, but since major
             // skins (MonoBook, Vector) don't use this information, it's not a
             // huge loss.
             $personal_urls['anontalk'] = array('text' => $this->msg('anontalk')->text(), 'href' => self::makeSpecialUrlSubpage('Mytalk', false), 'active' => false);
             $personal_urls['anoncontribs'] = array('text' => $this->msg('anoncontribs')->text(), 'href' => self::makeSpecialUrlSubpage('Mycontributions', false), 'active' => false);
         }
         if ($this->getUser()->isAllowed('createaccount') && !$useCombinedLoginLink) {
             $personal_urls['createaccount'] = $createaccount_url;
         }
         $personal_urls['login'] = $login_url;
     }
     Hooks::run('PersonalUrls', array(&$personal_urls, &$title, $this));
     return $personal_urls;
 }
 public static function removeUserFromBastionProject($user, &$group)
 {
     global $wgOpenStackManagerRemoveUserFromBastionProjectOnShellDisable;
     global $wgOpenStackManagerRemoveUserFromAllProjectsOnShellDisable;
     global $wgOpenStackManagerBastionProjectName;
     // Check whether after removing the group the user would still
     // have the loginviashell permission.
     foreach ($user->getEffectiveGroups() as $g) {
         // Ignore the group that will be removed.
         if ($g === $group) {
             continue;
         }
         // If the user still has the loginviashell permission, we
         // can immediately return.
         if (User::groupHasPermission($g, 'loginviashell')) {
             return true;
         }
     }
     // At this point we know that the user will not have the
     // loginviashell permission after the group is removed so we
     // can remove him from the bastion projects if the
     // configuration requires that.
     $username = $user->getName();
     if ($wgOpenStackManagerRemoveUserFromAllProjectsOnShellDisable) {
         // Get a users projects
         $userLDAP = new OpenStackNovaUser($username);
         foreach ($userLDAP->getProjects() as $projectName) {
             // Remove the user from the project
             $project = new OpenStackNovaProject($projectName);
             $project->deleteMember($username);
         }
     } elseif ($wgOpenStackManagerRemoveUserFromBastionProjectOnShellDisable) {
         // Remove the user from the bastion project
         $project = new OpenStackNovaProject($wgOpenStackManagerBastionProjectName);
         if (in_array($username, $project->getMembers())) {
             $project->deleteMember($username);
         }
     }
     return true;
 }
 /**
  * Can be overridden by subclasses with more complicated permissions
  * schemes.
  *
  * @return bool Should the page be displayed with the restricted-access
  *   pages?
  */
 public function isRestricted()
 {
     // DWIM: If anons can do something, then it is not restricted
     return $this->mRestriction != '' && !User::groupHasPermission('*', $this->mRestriction);
 }
Example #10
0
 /**
  * Check that the user is allowed to read this page.
  *
  * @param $action String the action to check
  * @param $user User to check
  * @param $errors Array list of current errors
  * @param $doExpensiveQueries Boolean whether or not to perform expensive queries
  * @param $short Boolean short circuit on first error
  *
  * @return Array list of errors
  */
 private function checkReadPermissions($action, $user, $errors, $doExpensiveQueries, $short)
 {
     global $wgWhitelistRead, $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;
                 }
             }
         }
     }
     $whitelisted = false;
     if ($useShortcut) {
         # Shortcut for public wikis, allows skipping quite a bit of code
         $whitelisted = true;
     } elseif ($user->isAllowed('read')) {
         # If the user is allowed to read pages, he is allowed to read all pages
         $whitelisted = true;
     } elseif ($this->isSpecial('Userlogin') || $this->isSpecial('ChangePassword') || $this->isSpecial('PasswordReset')) {
         # Always grant access to the login page.
         # Even anons need to be able to log in.
         $whitelisted = true;
     } elseif (is_array($wgWhitelistRead) && count($wgWhitelistRead)) {
         # Time to check the whitelist
         # Only do these checks is there's something to check against
         $name = $this->getPrefixedText();
         $dbName = $this->getPrefixedDBKey();
         // Check for explicit whitelisting with and without underscores
         if (in_array($name, $wgWhitelistRead, true) || in_array($dbName, $wgWhitelistRead, true)) {
             $whitelisted = true;
         } elseif ($this->getNamespace() == NS_MAIN) {
             # Old settings might have the title prefixed with
             # a colon for main-namespace pages
             if (in_array(':' . $name, $wgWhitelistRead)) {
                 $whitelisted = true;
             }
         } elseif ($this->isSpecialPage()) {
             # If it's a special page, ditch the subpage bit and check again
             $name = $this->getDBkey();
             list($name, ) = SpecialPageFactory::resolveAlias($name);
             if ($name !== false) {
                 $pure = SpecialPage::getTitleFor($name)->getPrefixedText();
                 if (in_array($pure, $wgWhitelistRead, true)) {
                     $whitelisted = true;
                 }
             }
         }
     }
     if (!$whitelisted) {
         # If the title is not whitelisted, give extensions a chance to do so...
         wfRunHooks('TitleReadWhitelist', array($this, $user, &$whitelisted));
         if (!$whitelisted) {
             $errors[] = $this->missingPermissionError($action, $short);
         }
     }
     return $errors;
 }
Example #11
0
 /**
  * Check for sufficient permissions to execute
  * @param $module ApiBase An Api module
  */
 protected function checkExecutePermissions($module)
 {
     $user = $this->getUser();
     if ($module->isReadMode() && !User::groupHasPermission('*', 'read') && !$user->isAllowed('read')) {
         $this->dieUsageMsg('readrequired');
     }
     if ($module->isWriteMode()) {
         if (!$this->mEnableWrite) {
             $this->dieUsageMsg('writedisabled');
         }
         if (!$user->isAllowed('writeapi')) {
             $this->dieUsageMsg('writerequired');
         }
         if (wfReadOnly()) {
             $this->dieReadOnly();
         }
     }
     // Allow extensions to stop execution for arbitrary reasons.
     $message = false;
     if (!wfRunHooks('ApiCheckCanExecute', array($module, $user, &$message))) {
         $this->dieUsageMsg($message);
     }
 }
Example #12
0
    /**
     * Template filter callback for MonoBook skin.
     * Takes an associative array of data set from a SkinTemplate-based
     * class, and a wrapper for MediaWiki's localization database, and
     * outputs a formatted page.
     *
     * @access private
     */
    public function execute()
    {
        // Suppress warnings to prevent notices about missing indexes in $this->data
        wfSuppressWarnings();
        $this->html('headelement');
        ?>
<div id="globalWrapper">
		<div id="column-content">
			<div id="content" class="mw-body" role="main">
				<a id="top"></a>
				<?php 
        if ($this->data['sitenotice']) {
            ?>
					<div id="siteNotice"><?php 
            $this->html('sitenotice');
            ?>
</div><?php 
        }
        ?>

				<?php 
        echo $this->getIndicators();
        // Loose comparison with '!=' is intentional, to catch null and false too, but not '0'
        if ($this->data['title'] != '') {
            ?>
				<h1 id="firstHeading" class="firstHeading" lang="<?php 
            $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
            $this->text('pageLanguage');
            ?>
"><?php 
            $this->html('title');
            ?>
</h1>
				<?php 
        }
        ?>

				<div id="bodyContent" class="mw-body-content">
					<div id="siteSub"><?php 
        $this->msg('tagline');
        ?>
</div>
					<div id="contentSub"<?php 
        $this->html('userlangattributes');
        ?>
><?php 
        $this->html('subtitle');
        ?>
</div>
					<?php 
        if ($this->data['undelete']) {
            ?>
						<div id="contentSub2"><?php 
            $this->html('undelete');
            ?>
</div>
					<?php 
        }
        if ($this->data['newtalk']) {
            ?>
						<div class="usermessage"><?php 
            $this->html('newtalk');
            ?>
</div>
					<?php 
        }
        ?>
					<div id="jump-to-nav" class="mw-jump"><?php 
        $this->msg('jumpto');
        ?>
 <a href="#column-one"><?php 
        $this->msg('jumptonavigation');
        ?>
</a><?php 
        $this->msg('comma-separator');
        ?>
<a href="#searchInput"><?php 
        $this->msg('jumptosearch');
        ?>
</a></div>

					<!-- start content -->
					<?php 
        $this->html('bodytext');
        ?>
					<?php 
        if ($this->data['catlinks']) {
            $this->html('catlinks');
        }
        ?>
					<!-- end content -->
					<?php 
        if ($this->data['dataAfterContent']) {
            $this->html('dataAfterContent');
        }
        ?>
					<div class="visualClear"></div>
				</div>
			</div>
		</div>
		<div id="column-one"<?php 
        $this->html('userlangattributes');
        ?>
>
			<h2><?php 
        $this->msg('navigation-heading');
        ?>
</h2>
			<?php 
        $this->cactions();
        ?>
			<div class="portlet" id="p-personal" role="navigation">
				<h3><?php 
        $this->msg('personaltools');
        ?>
</h3>

				<div class="pBody">
					<ul<?php 
        $this->html('userlangattributes');
        ?>
>
						<?php 
        $personalTools = $this->getPersonalTools();
        if (array_key_exists('uls', $personalTools)) {
            echo $this->makeListItem('uls', $personalTools['uls']);
            unset($personalTools['uls']);
        }
        if (!$this->getSkin()->getUser()->isLoggedIn() && User::groupHasPermission('*', 'edit')) {
            echo Html::rawElement('li', array('id' => 'pt-anonuserpage'), $this->getMsg('notloggedin')->escaped());
        }
        foreach ($personalTools as $key => $item) {
            ?>
							<?php 
            echo $this->makeListItem($key, $item);
            ?>

						<?php 
        }
        ?>
					</ul>
				</div>
			</div>
			<div class="portlet" id="p-logo" role="banner">
				<?php 
        echo Html::element('a', array('href' => $this->data['nav_urls']['mainpage']['href'], 'class' => 'mw-wiki-logo') + Linker::tooltipAndAccesskeyAttribs('p-logo'));
        ?>

			</div>
			<?php 
        $this->renderPortals($this->data['sidebar']);
        ?>
		</div><!-- end of the left (by default at least) column -->
		<div class="visualClear"></div>
		<?php 
        $validFooterIcons = $this->getFooterIcons("icononly");
        $validFooterLinks = $this->getFooterLinks("flat");
        // Additional footer links
        if (count($validFooterIcons) + count($validFooterLinks) > 0) {
            ?>
			<div id="footer" role="contentinfo"<?php 
            $this->html('userlangattributes');
            ?>
>
			<?php 
            $footerEnd = '</div>';
        } else {
            $footerEnd = '';
        }
        foreach ($validFooterIcons as $blockName => $footerIcons) {
            ?>
			<div id="f-<?php 
            echo htmlspecialchars($blockName);
            ?>
ico">
				<?php 
            foreach ($footerIcons as $icon) {
                ?>
					<?php 
                echo $this->getSkin()->makeFooterIcon($icon);
                ?>

				<?php 
            }
            ?>
			</div>
		<?php 
        }
        if (count($validFooterLinks) > 0) {
            ?>
			<ul id="f-list">
				<?php 
            foreach ($validFooterLinks as $aLink) {
                ?>
					<li id="<?php 
                echo $aLink;
                ?>
"><?php 
                $this->html($aLink);
                ?>
</li>
				<?php 
            }
            ?>
			</ul>
		<?php 
        }
        echo $footerEnd;
        ?>

		</div>
		<?php 
        $this->printTrail();
        echo Html::closeElement('body');
        echo Html::closeElement('html');
        echo "\n";
        wfRestoreWarnings();
    }
Example #13
0
 /**
  * Save submitted protection form
  *
  * @return Boolean: success
  */
 function save()
 {
     global $wgRequest, $wgUser, $wgOut;
     # Permission check!
     if ($this->disabled) {
         $this->show();
         return false;
     }
     $token = $wgRequest->getVal('wpEditToken');
     if (!$wgUser->matchEditToken($token, array('protect', $this->mTitle->getPrefixedDBkey()))) {
         $this->show(array('sessionfailure'));
         return false;
     }
     # Create reason string. Use list and/or custom string.
     $reasonstr = $this->mReasonSelection;
     if ($reasonstr != 'other' && $this->mReason != '') {
         // Entry from drop down menu + additional comment
         $reasonstr .= wfMessage('colon-separator')->text() . $this->mReason;
     } elseif ($reasonstr == 'other') {
         $reasonstr = $this->mReason;
     }
     $expiry = array();
     foreach ($this->mApplicableTypes as $action) {
         $expiry[$action] = $this->getExpiry($action);
         if (empty($this->mRestrictions[$action])) {
             continue;
             // unprotected
         }
         if (!$expiry[$action]) {
             $this->show(array('protect_expiry_invalid'));
             return false;
         }
         if ($expiry[$action] < wfTimestampNow()) {
             $this->show(array('protect_expiry_old'));
             return false;
         }
     }
     # They shouldn't be able to do this anyway, but just to make sure, ensure that cascading restrictions aren't being applied
     #  to a semi-protected page.
     $edit_restriction = isset($this->mRestrictions['edit']) ? $this->mRestrictions['edit'] : '';
     $this->mCascade = $wgRequest->getBool('mwProtect-cascade');
     if ($this->mCascade && $edit_restriction != 'protect' && !User::groupHasPermission($edit_restriction, 'protect')) {
         $this->mCascade = false;
     }
     $status = $this->mArticle->doUpdateRestrictions($this->mRestrictions, $expiry, $this->mCascade, $reasonstr, $wgUser);
     if (!$status->isOK()) {
         $this->show($wgOut->parseInline($status->getWikiText()));
         return false;
     }
     /**
      * Give extensions a change to handle added form items
      *
      * @since 1.19 you can (and you should) return false to abort saving;
      *             you can also return an array of message name and its parameters
      */
     $errorMsg = '';
     if (!wfRunHooks('ProtectionForm::save', array($this->mArticle, &$errorMsg))) {
         if ($errorMsg == '') {
             $errorMsg = array('hookaborted');
         }
     }
     if ($errorMsg != '') {
         $this->show($errorMsg);
         return false;
     }
     if ($wgUser->isLoggedIn() && $wgRequest->getCheck('mwProtectWatch') != $wgUser->isWatched($this->mTitle)) {
         if ($wgRequest->getCheck('mwProtectWatch')) {
             WatchAction::doWatch($this->mTitle, $wgUser);
         } else {
             WatchAction::doUnwatch($this->mTitle, $wgUser);
         }
     }
     return true;
 }
 function buildCleanupScript()
 {
     global $wgRestrictionLevels, $wgOut;
     $cascadeableLevels = array();
     foreach ($wgRestrictionLevels as $key) {
         if (User::groupHasPermission($key, 'protect') || $key == 'protect') {
             $cascadeableLevels[] = $key;
         }
     }
     $options = array('tableId' => 'mwProtectSet', 'labelText' => wfMessage('protect-unchain-permissions')->plain(), 'numTypes' => count($this->mApplicableTypes), 'existingMatch' => count(array_unique($this->mExistingExpiry)) === 1);
     $wgOut->addJsConfigVars('wgCascadeableLevels', $cascadeableLevels);
     $script = Xml::encodeJsCall('ProtectionForm.init', array($options));
     return Html::inlineScript(ResourceLoader::makeLoaderConditionalScript($script));
 }
Example #15
0
 protected function filterLinks()
 {
     // show/hide links
     $showhide = [$this->msg('show')->escaped(), $this->msg('hide')->escaped()];
     // Option value -> message mapping
     $filters = ['hideliu' => 'rcshowhideliu', 'hidepatrolled' => 'rcshowhidepatr', 'hidebots' => 'rcshowhidebots', 'hideredirs' => 'whatlinkshere-hideredirs'];
     foreach ($this->customFilters as $key => $params) {
         $filters[$key] = $params['msg'];
     }
     // Disable some if needed
     if (!User::groupHasPermission('*', 'createpage')) {
         unset($filters['hideliu']);
     }
     if (!$this->getUser()->useNPPatrol()) {
         unset($filters['hidepatrolled']);
     }
     $links = [];
     $changed = $this->opts->getChangedValues();
     unset($changed['offset']);
     // Reset offset if query type changes
     $self = $this->getPageTitle();
     foreach ($filters as $key => $msg) {
         $onoff = 1 - $this->opts->getValue($key);
         $link = Linker::link($self, $showhide[$onoff], [], [$key => $onoff] + $changed);
         $links[$key] = $this->msg($msg)->rawParams($link)->escaped();
     }
     return $this->getLanguage()->pipeList($links);
 }