本文整理汇总了PHP中Title::quickUserCan方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::quickUserCan方法的具体用法?PHP Title::quickUserCan怎么用?PHP Title::quickUserCan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::quickUserCan方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMarkPatrolledLinkInfo
/**
* Returns an array of meta data needed to build a "mark as patrolled" link and
* adds the mediawiki.page.patrol.ajax to the output.
*
* @return array|false An array of meta data for a patrol link (rcid & token)
* or false if no link is needed
*/
protected function getMarkPatrolledLinkInfo()
{
global $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
$user = $this->getUser();
// Prepare a change patrol link, if applicable
if ($wgUseRCPatrol && $this->mNewPage->quickUserCan('patrol', $user) && RecentChange::isInRCLifespan($this->mNewRev->getTimestamp(), 21600)) {
// Look for an unpatrolled change corresponding to this diff
$db = wfGetDB(DB_SLAVE);
$change = RecentChange::newFromConds(array('rc_timestamp' => $db->timestamp($this->mNewRev->getTimestamp()), 'rc_this_oldid' => $this->mNewid, 'rc_patrolled' => 0), __METHOD__);
if ($change && !$change->getPerformer()->equals($user)) {
$rcid = $change->getAttribute('rc_id');
} else {
// None found or the page has been created by the current user.
// If the user could patrol this it already would be patrolled
$rcid = 0;
}
// Build the link
if ($rcid) {
$this->getOutput()->preventClickjacking();
if ($wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed('writeapi')) {
$this->getOutput()->addModules('mediawiki.page.patrol.ajax');
}
$token = $user->getEditToken($rcid);
return array('rcid' => $rcid, 'token' => $token);
}
}
// No mark as patrolled link applicable
return false;
}
示例2: testUserBlock
public function testUserBlock()
{
global $wgEmailConfirmToEdit, $wgEmailAuthentication;
$wgEmailConfirmToEdit = true;
$wgEmailAuthentication = true;
$this->setUserPerm(array("createpage", "move"));
$this->setTitle(NS_HELP, "test page");
# $short
$this->assertEquals(array(array('confirmedittext')), $this->title->getUserPermissionsErrors('move-target', $this->user));
$wgEmailConfirmToEdit = false;
$this->assertEquals(true, $this->title->userCan('move-target', $this->user));
# $wgEmailConfirmToEdit && !$user->isEmailConfirmed() && $action != 'createaccount'
$this->assertEquals(array(), $this->title->getUserPermissionsErrors('move-target', $this->user));
global $wgLang;
$prev = time();
$now = time() + 120;
$this->user->mBlockedby = $this->user->getId();
$this->user->mBlock = new Block('127.0.8.1', 0, $this->user->getId(), 'no reason given', $prev + 3600, 1, 0);
$this->user->mBlock->mTimestamp = 0;
$this->assertEquals(array(array('autoblockedtext', '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1', 'Useruser', null, 'infinite', '127.0.8.1', $wgLang->timeanddate(wfTimestamp(TS_MW, $prev), true))), $this->title->getUserPermissionsErrors('move-target', $this->user));
$this->assertEquals(false, $this->title->userCan('move-target', $this->user));
// quickUserCan should ignore user blocks
$this->assertEquals(true, $this->title->quickUserCan('move-target', $this->user));
global $wgLocalTZoffset;
$wgLocalTZoffset = -60;
$this->user->mBlockedby = $this->user->getName();
$this->user->mBlock = new Block('127.0.8.1', 0, $this->user->getId(), 'no reason given', $now, 0, 10);
$this->assertEquals(array(array('blockedtext', '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1', 'Useruser', null, '23:00, 31 December 1969', '127.0.8.1', $wgLang->timeanddate(wfTimestamp(TS_MW, $now), true))), $this->title->getUserPermissionsErrors('move-target', $this->user));
# $action != 'read' && $action != 'createaccount' && $user->isBlockedFrom( $this )
# $user->blockedFor() == ''
# $user->mBlock->mExpiry == 'infinity'
}
示例3: markPatrolledLink
/**
* Get a link to mark the change as patrolled, or '' if there's either no
* revision to patrol or the user is not allowed to to it.
* Side effect: When the patrol link is build, this method will call
* OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
*
* @return string
*/
protected function markPatrolledLink()
{
global $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
$user = $this->getUser();
if ($this->mMarkPatrolledLink === null) {
// Prepare a change patrol link, if applicable
if ($wgUseRCPatrol && $this->mNewPage->quickUserCan('patrol', $user) && RecentChange::isInRCLifespan($this->mNewRev->getTimestamp(), 21600)) {
// Look for an unpatrolled change corresponding to this diff
$db = wfGetDB(DB_SLAVE);
$change = RecentChange::newFromConds(array('rc_timestamp' => $db->timestamp($this->mNewRev->getTimestamp()), 'rc_this_oldid' => $this->mNewid, 'rc_patrolled' => 0), __METHOD__, array('USE INDEX' => 'rc_timestamp'));
if ($change && $change->getPerformer()->getName() !== $user->getName()) {
$rcid = $change->getAttribute('rc_id');
} else {
// None found or the page has been created by the current user.
// If the user could patrol this it already would be patrolled
$rcid = 0;
}
// Build the link
if ($rcid) {
$this->getOutput()->preventClickjacking();
if ($wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed('writeapi')) {
$this->getOutput()->addModules('mediawiki.page.patrol.ajax');
}
$token = $user->getEditToken($rcid);
$this->mMarkPatrolledLink = ' <span class="patrollink">[' . Linker::linkKnown($this->mNewPage, $this->msg('markaspatrolleddiff')->escaped(), array(), array('action' => 'markpatrolled', 'rcid' => $rcid, 'token' => $token)) . ']</span>';
} else {
$this->mMarkPatrolledLink = '';
}
} else {
$this->mMarkPatrolledLink = '';
}
}
return $this->mMarkPatrolledLink;
}
示例4: getMarkPatrolledLinkInfo
/**
* Returns an array of meta data needed to build a "mark as patrolled" link and
* adds the mediawiki.page.patrol.ajax to the output.
*
* @return array|false An array of meta data for a patrol link (rcid & token)
* or false if no link is needed
*/
protected function getMarkPatrolledLinkInfo()
{
global $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
$user = $this->getUser();
// Prepare a change patrol link, if applicable
if ($wgUseRCPatrol && $this->mNewPage->quickUserCan('patrol', $user) && RecentChange::isInRCLifespan($this->mNewRev->getTimestamp(), 21600)) {
// Look for an unpatrolled change corresponding to this diff
$db = wfGetDB(DB_REPLICA);
$change = RecentChange::newFromConds(['rc_timestamp' => $db->timestamp($this->mNewRev->getTimestamp()), 'rc_this_oldid' => $this->mNewid, 'rc_patrolled' => 0], __METHOD__);
if ($change && !$change->getPerformer()->equals($user)) {
$rcid = $change->getAttribute('rc_id');
} else {
// None found or the page has been created by the current user.
// If the user could patrol this it already would be patrolled
$rcid = 0;
}
// Allow extensions to possibly change the rcid here
// For example the rcid might be set to zero due to the user
// being the same as the performer of the change but an extension
// might still want to show it under certain conditions
Hooks::run('DifferenceEngineMarkPatrolledRCID', [&$rcid, $this, $change, $user]);
// Build the link
if ($rcid) {
$this->getOutput()->preventClickjacking();
if ($wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed('writeapi')) {
$this->getOutput()->addModules('mediawiki.page.patrol.ajax');
}
$token = $user->getEditToken($rcid);
return ['rcid' => $rcid, 'token' => $token];
}
}
// No mark as patrolled link applicable
return false;
}
示例5: markPatrolledLink
public function markPatrolledLink()
{
global $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
$user = $this->getUser();
if ($this->mMarkPatrolledLink === null) {
// Prepare a change patrol link, if applicable
if ($wgUseRCPatrol && $this->mNewPage->quickUserCan('patrol', $user) && RecentChange::isInRCLifespan($this->mNewRev->getTimestamp(), 21600)) {
// Look for an unpatrolled change corresponding to this diff
$db = wfGetDB(DB_SLAVE);
$change = RecentChange::newFromConds(array('rc_timestamp' => $db->timestamp($this->mNewRev->getTimestamp()), 'rc_this_oldid' => $this->mNewid, 'rc_patrolled' => 0), __METHOD__, array('USE INDEX' => 'rc_timestamp'));
if ($change && $change->getPerformer()->getName() !== $user->getName()) {
$rcid = $change->getAttribute('rc_id');
} else {
// None found or the page has been created by the current user.
// If the user could patrol this it already would be patrolled
$rcid = 0;
}
// WIKIHOW - we might want to change the rcid here
// for example the rcid might be set to zero due to the user being the same
// as the performer of the change but on wikihow we still want to show it
// under certain conditions
wfRunHooks('DifferenceEngineMarkPatrolledRCID', array(&$rcid, $this, $change, $user));
// Build the link
if ($rcid) {
$this->getOutput()->preventClickjacking();
if ($wgEnableAPI && $wgEnableWriteAPI && $user->isAllowed('writeapi')) {
$this->getOutput()->addModules('mediawiki.page.patrol.ajax');
}
$token = $user->getEditToken($rcid);
$this->mMarkPatrolledLink = ' <span class="patrollink">[' . Linker::linkKnown($this->mNewPage, $this->msg('markaspatrolleddiff')->escaped(), array(), array('action' => 'markpatrolled', 'rcid' => $rcid, 'token' => $token)) . ']</span>';
// WIKIHOW - added this hook to change the markpatrolled link
wfRunHooks('DifferenceEngineMarkPatrolledLink', array($this, &$this->mMarkPatrolledLink, $rcid, $token));
} else {
$this->mMarkPatrolledLink = '';
}
} else {
$this->mMarkPatrolledLink = '';
}
}
return $this->mMarkPatrolledLink;
}
示例6: imageHistoryLine
/**
* @param $iscur
* @param $file File
* @return string
*/
public function imageHistoryLine($iscur, $file)
{
global $wgContLang;
$user = $this->getUser();
$lang = $this->getLanguage();
$timestamp = wfTimestamp(TS_MW, $file->getTimestamp());
$img = $iscur ? $file->getName() : $file->getArchiveName();
$userId = $file->getUser('id');
$userText = $file->getUser('text');
$description = $file->getDescription(File::FOR_THIS_USER, $user);
$local = $this->current->isLocal();
$row = $selected = '';
// Deletion link
if ($local && $user->isAllowedAny('delete', 'deletedhistory')) {
$row .= '<td>';
# Link to remove from history
if ($user->isAllowed('delete')) {
$q = array('action' => 'delete');
if (!$iscur) {
$q['oldimage'] = $img;
}
$row .= Linker::linkKnown($this->title, $this->msg($iscur ? 'filehist-deleteall' : 'filehist-deleteone')->escaped(), array(), $q);
}
# Link to hide content. Don't show useless link to people who cannot hide revisions.
$canHide = $user->isAllowed('deleterevision');
if ($canHide || $user->isAllowed('deletedhistory') && $file->getVisibility()) {
if ($user->isAllowed('delete')) {
$row .= '<br />';
}
// If file is top revision or locked from this user, don't link
if ($iscur || !$file->userCan(File::DELETED_RESTRICTED, $user)) {
$del = Linker::revDeleteLinkDisabled($canHide);
} else {
list($ts, ) = explode('!', $img, 2);
$query = array('type' => 'oldimage', 'target' => $this->title->getPrefixedText(), 'ids' => $ts);
$del = Linker::revDeleteLink($query, $file->isDeleted(File::DELETED_RESTRICTED), $canHide);
}
$row .= $del;
}
$row .= '</td>';
}
// Reversion link/current indicator
$row .= '<td>';
if ($iscur) {
$row .= $this->msg('filehist-current')->escaped();
} elseif ($local && $this->title->quickUserCan('edit', $user) && $this->title->quickUserCan('upload', $user)) {
if ($file->isDeleted(File::DELETED_FILE)) {
$row .= $this->msg('filehist-revert')->escaped();
} else {
$row .= Linker::linkKnown($this->title, $this->msg('filehist-revert')->escaped(), array(), array('action' => 'revert', 'oldimage' => $img, 'wpEditToken' => $user->getEditToken($img)));
}
}
$row .= '</td>';
// Date/time and image link
if ($file->getTimestamp() === $this->img->getTimestamp()) {
$selected = "class='filehistory-selected'";
}
$row .= "<td {$selected} style='white-space: nowrap;'>";
if (!$file->userCan(File::DELETED_FILE, $user)) {
# Don't link to unviewable files
$row .= '<span class="history-deleted">' . $lang->userTimeAndDate($timestamp, $user) . '</span>';
} elseif ($file->isDeleted(File::DELETED_FILE)) {
if ($local) {
$this->preventClickjacking();
$revdel = SpecialPage::getTitleFor('Revisiondelete');
# Make a link to review the image
$url = Linker::linkKnown($revdel, $lang->userTimeAndDate($timestamp, $user), array(), array('target' => $this->title->getPrefixedText(), 'file' => $img, 'token' => $user->getEditToken($img)));
} else {
$url = $lang->userTimeAndDate($timestamp, $user);
}
$row .= '<span class="history-deleted">' . $url . '</span>';
} else {
$url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl($img);
$row .= Xml::element('a', array('href' => $url), $lang->userTimeAndDate($timestamp, $user));
}
$row .= "</td>";
// Thumbnail
if ($this->showThumb) {
$row .= '<td>' . $this->getThumbForLine($file) . '</td>';
}
// Image dimensions + size
$row .= '<td>';
$row .= htmlspecialchars($file->getDimensionsString());
$row .= $this->msg('word-separator')->plain();
$row .= '<span style="white-space: nowrap;">';
$row .= $this->msg('parentheses')->rawParams(Linker::formatSize($file->getSize()))->plain();
$row .= '</span>';
$row .= '</td>';
// Uploading user
$row .= '<td>';
// Hide deleted usernames
if ($file->isDeleted(File::DELETED_USER)) {
$row .= '<span class="history-deleted">' . $this->msg('rev-deleted-user')->escaped() . '</span>';
} else {
if ($local) {
//.........这里部分代码省略.........
示例7: isUserAllowedAdvancedView
public static function isUserAllowedAdvancedView(Title $title)
{
return $title->quickUserCan('edit');
}
示例8: buildEditLink
/**
* Return a link to the edit page, with the text
* saying "view source" if the user can't edit the page
*
* @param Title $titleObj
* @return string
*/
private function buildEditLink(Title $titleObj)
{
if ($titleObj->quickUserCan('edit', $this->context->getUser())) {
$linkMsg = 'editlink';
} else {
$linkMsg = 'viewsourcelink';
}
return $this->linkRenderer->makeLink($titleObj, $this->context->msg($linkMsg)->text(), [], ['action' => 'edit']);
}