本文整理汇总了PHP中Revision::userCanBitfield方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::userCanBitfield方法的具体用法?PHP Revision::userCanBitfield怎么用?PHP Revision::userCanBitfield使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revision
的用法示例。
在下文中一共展示了Revision::userCanBitfield方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: userCan
/**
* Determine if the current user is allowed to view a particular
* field of this revision, if it's marked as deleted.
* @param $rc RCCacheEntry
* @param $field Integer
* @param $user User object to check, or null to use $wgUser
* @return Boolean
*/
public static function userCan($rc, $field, User $user = null)
{
if ($rc->mAttribs['rc_type'] == RC_LOG) {
return LogEventsList::userCanBitfield($rc->mAttribs['rc_deleted'], $field, $user);
} else {
return Revision::userCanBitfield($rc->mAttribs['rc_deleted'], $field, $user);
}
}
示例2: extractRowInfo
/**
* Extracts from a single sql row the data needed to describe one recent change.
*
* @param stdClass $row The row from which to extract the data.
* @return array An array mapping strings (descriptors) to their respective string values.
* @access public
*/
public function extractRowInfo($row)
{
/* Determine the title of the page that has been changed. */
$title = Title::makeTitle($row->rc_namespace, $row->rc_title);
$user = $this->getUser();
/* Our output data. */
$vals = array();
$type = intval($row->rc_type);
$vals['type'] = RecentChange::parseFromRCType($type);
$anyHidden = false;
/* Create a new entry in the result for the title. */
if ($this->fld_title || $this->fld_ids) {
if ($type === RC_LOG && $row->rc_deleted & LogPage::DELETED_ACTION) {
$vals['actionhidden'] = true;
$anyHidden = true;
}
if ($type !== RC_LOG || LogEventsList::userCanBitfield($row->rc_deleted, LogPage::DELETED_ACTION, $user)) {
if ($this->fld_title) {
ApiQueryBase::addTitleInfo($vals, $title);
}
if ($this->fld_ids) {
$vals['pageid'] = intval($row->rc_cur_id);
$vals['revid'] = intval($row->rc_this_oldid);
$vals['old_revid'] = intval($row->rc_last_oldid);
}
}
}
if ($this->fld_ids) {
$vals['rcid'] = intval($row->rc_id);
}
/* Add user data and 'anon' flag, if user is anonymous. */
if ($this->fld_user || $this->fld_userid) {
if ($row->rc_deleted & Revision::DELETED_USER) {
$vals['userhidden'] = true;
$anyHidden = true;
}
if (Revision::userCanBitfield($row->rc_deleted, Revision::DELETED_USER, $user)) {
if ($this->fld_user) {
$vals['user'] = $row->rc_user_text;
}
if ($this->fld_userid) {
$vals['userid'] = $row->rc_user;
}
if (!$row->rc_user) {
$vals['anon'] = true;
}
}
}
/* Add flags, such as new, minor, bot. */
if ($this->fld_flags) {
$vals['bot'] = (bool) $row->rc_bot;
$vals['new'] = $row->rc_type == RC_NEW;
$vals['minor'] = (bool) $row->rc_minor;
}
/* Add sizes of each revision. (Only available on 1.10+) */
if ($this->fld_sizes) {
$vals['oldlen'] = intval($row->rc_old_len);
$vals['newlen'] = intval($row->rc_new_len);
}
/* Add the timestamp. */
if ($this->fld_timestamp) {
$vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->rc_timestamp);
}
/* Add edit summary / log summary. */
if ($this->fld_comment || $this->fld_parsedcomment) {
if ($row->rc_deleted & Revision::DELETED_COMMENT) {
$vals['commenthidden'] = true;
$anyHidden = true;
}
if (Revision::userCanBitfield($row->rc_deleted, Revision::DELETED_COMMENT, $user)) {
if ($this->fld_comment && isset($row->rc_comment)) {
$vals['comment'] = $row->rc_comment;
}
if ($this->fld_parsedcomment && isset($row->rc_comment)) {
$vals['parsedcomment'] = Linker::formatComment($row->rc_comment, $title);
}
}
}
if ($this->fld_redirect) {
$vals['redirect'] = (bool) $row->page_is_redirect;
}
/* Add the patrolled flag */
if ($this->fld_patrolled) {
$vals['patrolled'] = $row->rc_patrolled == 1;
$vals['unpatrolled'] = ChangesList::isUnpatrolled($row, $user);
}
if ($this->fld_loginfo && $row->rc_type == RC_LOG) {
if ($row->rc_deleted & LogPage::DELETED_ACTION) {
$vals['actionhidden'] = true;
$anyHidden = true;
}
if (LogEventsList::userCanBitfield($row->rc_deleted, LogPage::DELETED_ACTION, $user)) {
$vals['logid'] = intval($row->rc_logid);
//.........这里部分代码省略.........
示例3: userCan
/**
* Determine if the current user is allowed to view a particular
* field of this image file, if it's marked as deleted.
*
* @param $field Integer
* @return bool
*/
function userCan($field)
{
$this->load();
return Revision::userCanBitfield($this->deleted, $field);
}
示例4: execute
//.........这里部分代码省略.........
$sha1 = strtolower($params['sha1base36']);
if (!$this->validateSha1Base36Hash($sha1)) {
$this->dieUsage('The SHA1Base36 hash provided is not valid', 'invalidsha1base36hash');
}
}
if ($sha1) {
$this->addWhereFld('fa_sha1', $sha1);
}
}
// Exclude files this user can't view.
if (!$user->isAllowed('deletedtext')) {
$bitmask = File::DELETED_FILE;
} elseif (!$user->isAllowedAny('suppressrevision', 'viewsuppressed')) {
$bitmask = File::DELETED_FILE | File::DELETED_RESTRICTED;
} else {
$bitmask = 0;
}
if ($bitmask) {
$this->addWhere($this->getDB()->bitAnd('fa_deleted', $bitmask) . " != {$bitmask}");
}
$limit = $params['limit'];
$this->addOption('LIMIT', $limit + 1);
$sort = $params['dir'] == 'descending' ? ' DESC' : '';
$this->addOption('ORDER BY', array('fa_name' . $sort, 'fa_timestamp' . $sort, 'fa_id' . $sort));
$res = $this->select(__METHOD__);
$count = 0;
$result = $this->getResult();
foreach ($res as $row) {
if (++$count > $limit) {
// We've reached the one extra which shows that there are
// additional pages to be had. Stop here...
$this->setContinueEnumParameter('continue', "{$row->fa_name}|{$row->fa_timestamp}|{$row->fa_id}");
break;
}
$file = array();
$file['id'] = (int) $row->fa_id;
$file['name'] = $row->fa_name;
$title = Title::makeTitle(NS_FILE, $row->fa_name);
self::addTitleInfo($file, $title);
if ($fld_description && Revision::userCanBitfield($row->fa_deleted, File::DELETED_COMMENT, $user)) {
$file['description'] = $row->fa_description;
if (isset($prop['parseddescription'])) {
$file['parseddescription'] = Linker::formatComment($row->fa_description, $title);
}
}
if ($fld_user && Revision::userCanBitfield($row->fa_deleted, File::DELETED_USER, $user)) {
$file['userid'] = (int) $row->fa_user;
$file['user'] = $row->fa_user_text;
}
if ($fld_sha1) {
$file['sha1'] = wfBaseConvert($row->fa_sha1, 36, 16, 40);
}
if ($fld_timestamp) {
$file['timestamp'] = wfTimestamp(TS_ISO_8601, $row->fa_timestamp);
}
if ($fld_size || $fld_dimensions) {
$file['size'] = $row->fa_size;
$pageCount = ArchivedFile::newFromRow($row)->pageCount();
if ($pageCount !== false) {
$file['pagecount'] = $pageCount;
}
$file['height'] = $row->fa_height;
$file['width'] = $row->fa_width;
}
if ($fld_mediatype) {
$file['mediatype'] = $row->fa_media_type;
}
if ($fld_metadata) {
$file['metadata'] = $row->fa_metadata ? ApiQueryImageInfo::processMetaData(unserialize($row->fa_metadata), $result) : null;
}
if ($fld_bitdepth) {
$file['bitdepth'] = $row->fa_bits;
}
if ($fld_mime) {
$file['mime'] = "{$row->fa_major_mime}/{$row->fa_minor_mime}";
}
if ($fld_archivename && !is_null($row->fa_archive_name)) {
$file['archivename'] = $row->fa_archive_name;
}
if ($row->fa_deleted & File::DELETED_FILE) {
$file['filehidden'] = true;
}
if ($row->fa_deleted & File::DELETED_COMMENT) {
$file['commenthidden'] = true;
}
if ($row->fa_deleted & File::DELETED_USER) {
$file['userhidden'] = true;
}
if ($row->fa_deleted & File::DELETED_RESTRICTED) {
// This file is deleted for normal admins
$file['suppressed'] = true;
}
$fit = $result->addValue(array('query', $this->getModuleName()), null, $file);
if (!$fit) {
$this->setContinueEnumParameter('continue', "{$row->fa_name}|{$row->fa_timestamp}|{$row->fa_id}");
break;
}
}
$result->addIndexedTagName(array('query', $this->getModuleName()), 'fa');
}
示例5: extractRowInfo
/**
* Extract fields from the database row and append them to a result array
*
* @param $row
* @return array
*/
private function extractRowInfo($row)
{
$vals = array();
$anyHidden = false;
if ($row->rev_deleted & Revision::DELETED_TEXT) {
$vals['texthidden'] = '';
$anyHidden = true;
}
// Any rows where we can't view the user were filtered out in the query.
$vals['userid'] = $row->rev_user;
$vals['user'] = $row->rev_user_text;
if ($row->rev_deleted & Revision::DELETED_USER) {
$vals['userhidden'] = '';
$anyHidden = true;
}
if ($this->fld_ids) {
$vals['pageid'] = intval($row->rev_page);
$vals['revid'] = intval($row->rev_id);
// $vals['textid'] = intval( $row->rev_text_id ); // todo: Should this field be exposed?
if (!is_null($row->rev_parent_id)) {
$vals['parentid'] = intval($row->rev_parent_id);
}
}
$title = Title::makeTitle($row->page_namespace, $row->page_title);
if ($this->fld_title) {
ApiQueryBase::addTitleInfo($vals, $title);
}
if ($this->fld_timestamp) {
$vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->rev_timestamp);
}
if ($this->fld_flags) {
if ($row->rev_parent_id == 0 && !is_null($row->rev_parent_id)) {
$vals['new'] = '';
}
if ($row->rev_minor_edit) {
$vals['minor'] = '';
}
if ($row->page_latest == $row->rev_id) {
$vals['top'] = '';
}
}
if (($this->fld_comment || $this->fld_parsedcomment) && isset($row->rev_comment)) {
if ($row->rev_deleted & Revision::DELETED_COMMENT) {
$vals['commenthidden'] = '';
$anyHidden = true;
}
$userCanView = Revision::userCanBitfield($row->rev_deleted, Revision::DELETED_COMMENT, $this->getUser());
if ($userCanView) {
if ($this->fld_comment) {
$vals['comment'] = $row->rev_comment;
}
if ($this->fld_parsedcomment) {
$vals['parsedcomment'] = Linker::formatComment($row->rev_comment, $title);
}
}
}
if ($this->fld_patrolled && $row->rc_patrolled) {
$vals['patrolled'] = '';
}
if ($this->fld_size && !is_null($row->rev_len)) {
$vals['size'] = intval($row->rev_len);
}
if ($this->fld_sizediff && !is_null($row->rev_len) && !is_null($row->rev_parent_id)) {
$parentLen = isset($this->parentLens[$row->rev_parent_id]) ? $this->parentLens[$row->rev_parent_id] : 0;
$vals['sizediff'] = intval($row->rev_len - $parentLen);
}
if ($this->fld_tags) {
if ($row->ts_tags) {
$tags = explode(',', $row->ts_tags);
$this->getResult()->setIndexedTagName($tags, 'tag');
$vals['tags'] = $tags;
} else {
$vals['tags'] = array();
}
}
if ($anyHidden && $row->rev_deleted & Revision::DELETED_RESTRICTED) {
$vals['suppressed'] = '';
}
return $vals;
}
示例6: userCan
/**
* Determine if the current user is allowed to view a particular
* field of this FileStore image file, if it's marked as deleted.
* @param int $field
* @param null|User $user User object to check, or null to use $wgUser
* @return bool
*/
public function userCan($field, User $user = null)
{
$this->load();
return Revision::userCanBitfield($this->deleted, $field, $user);
}
示例7: extractRowInfo
private function extractRowInfo($row)
{
/* Determine the title of the page that has been changed. */
$title = Title::makeTitle($row->rc_namespace, $row->rc_title);
$user = $this->getUser();
/* Our output data. */
$vals = array();
$type = intval($row->rc_type);
/* Determine what kind of change this was. */
switch ($type) {
case RC_EDIT:
$vals['type'] = 'edit';
break;
case RC_NEW:
$vals['type'] = 'new';
break;
case RC_MOVE:
$vals['type'] = 'move';
break;
case RC_LOG:
$vals['type'] = 'log';
break;
case RC_EXTERNAL:
$vals['type'] = 'external';
break;
case RC_MOVE_OVER_REDIRECT:
$vals['type'] = 'move over redirect';
break;
default:
$vals['type'] = $type;
}
$anyHidden = false;
/* Create a new entry in the result for the title. */
if ($this->fld_title || $this->fld_ids) {
// These should already have been filtered out of the query, but just in case.
if ($type === RC_LOG && $row->rc_deleted & LogPage::DELETED_ACTION) {
$vals['actionhidden'] = '';
$anyHidden = true;
}
if ($type !== RC_LOG || LogEventsList::userCanBitfield($row->rc_deleted, LogPage::DELETED_ACTION, $user)) {
if ($this->fld_title) {
ApiQueryBase::addTitleInfo($vals, $title);
}
if ($this->fld_ids) {
$vals['pageid'] = intval($row->rc_cur_id);
$vals['revid'] = intval($row->rc_this_oldid);
$vals['old_revid'] = intval($row->rc_last_oldid);
}
}
}
/* Add user data and 'anon' flag, if user is anonymous. */
if ($this->fld_user || $this->fld_userid) {
if ($row->rc_deleted & Revision::DELETED_USER) {
$vals['userhidden'] = '';
$anyHidden = true;
}
if (Revision::userCanBitfield($row->rc_deleted, Revision::DELETED_USER, $user)) {
if ($this->fld_userid) {
$vals['userid'] = $row->rc_user;
// for backwards compatibility
$vals['user'] = $row->rc_user;
}
if ($this->fld_user) {
$vals['user'] = $row->rc_user_text;
}
if (!$row->rc_user) {
$vals['anon'] = '';
}
}
}
/* Add flags, such as new, minor, bot. */
if ($this->fld_flags) {
if ($row->rc_bot) {
$vals['bot'] = '';
}
if ($row->rc_type == RC_NEW) {
$vals['new'] = '';
}
if ($row->rc_minor) {
$vals['minor'] = '';
}
}
/* Add sizes of each revision. (Only available on 1.10+) */
if ($this->fld_sizes) {
$vals['oldlen'] = intval($row->rc_old_len);
$vals['newlen'] = intval($row->rc_new_len);
}
/* Add the timestamp. */
if ($this->fld_timestamp) {
$vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->rc_timestamp);
}
if ($this->fld_notificationtimestamp) {
$vals['notificationtimestamp'] = $row->wl_notificationtimestamp == null ? '' : wfTimestamp(TS_ISO_8601, $row->wl_notificationtimestamp);
}
/* Add edit summary / log summary. */
if ($this->fld_comment || $this->fld_parsedcomment) {
if ($row->rc_deleted & Revision::DELETED_COMMENT) {
$vals['commenthidden'] = '';
$anyHidden = true;
}
//.........这里部分代码省略.........
示例8: extractRowInfo
private function extractRowInfo($row)
{
/* Determine the title of the page that has been changed. */
$title = Title::makeTitle($row->rc_namespace, $row->rc_title);
$user = $this->getUser();
/* Our output data. */
$vals = [];
$type = intval($row->rc_type);
$vals['type'] = RecentChange::parseFromRCType($type);
$anyHidden = false;
/* Create a new entry in the result for the title. */
if ($this->fld_title || $this->fld_ids) {
// These should already have been filtered out of the query, but just in case.
if ($type === RC_LOG && $row->rc_deleted & LogPage::DELETED_ACTION) {
$vals['actionhidden'] = true;
$anyHidden = true;
}
if ($type !== RC_LOG || LogEventsList::userCanBitfield($row->rc_deleted, LogPage::DELETED_ACTION, $user)) {
if ($this->fld_title) {
ApiQueryBase::addTitleInfo($vals, $title);
}
if ($this->fld_ids) {
$vals['pageid'] = intval($row->rc_cur_id);
$vals['revid'] = intval($row->rc_this_oldid);
$vals['old_revid'] = intval($row->rc_last_oldid);
}
}
}
/* Add user data and 'anon' flag, if user is anonymous. */
if ($this->fld_user || $this->fld_userid) {
if ($row->rc_deleted & Revision::DELETED_USER) {
$vals['userhidden'] = true;
$anyHidden = true;
}
if (Revision::userCanBitfield($row->rc_deleted, Revision::DELETED_USER, $user)) {
if ($this->fld_userid) {
$vals['userid'] = (int) $row->rc_user;
// for backwards compatibility
$vals['user'] = (int) $row->rc_user;
}
if ($this->fld_user) {
$vals['user'] = $row->rc_user_text;
}
if (!$row->rc_user) {
$vals['anon'] = true;
}
}
}
/* Add flags, such as new, minor, bot. */
if ($this->fld_flags) {
$vals['bot'] = (bool) $row->rc_bot;
$vals['new'] = $row->rc_type == RC_NEW;
$vals['minor'] = (bool) $row->rc_minor;
}
/* Add sizes of each revision. (Only available on 1.10+) */
if ($this->fld_sizes) {
$vals['oldlen'] = intval($row->rc_old_len);
$vals['newlen'] = intval($row->rc_new_len);
}
/* Add the timestamp. */
if ($this->fld_timestamp) {
$vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->rc_timestamp);
}
if ($this->fld_notificationtimestamp) {
$vals['notificationtimestamp'] = $row->wl_notificationtimestamp == null ? '' : wfTimestamp(TS_ISO_8601, $row->wl_notificationtimestamp);
}
/* Add edit summary / log summary. */
if ($this->fld_comment || $this->fld_parsedcomment) {
if ($row->rc_deleted & Revision::DELETED_COMMENT) {
$vals['commenthidden'] = true;
$anyHidden = true;
}
if (Revision::userCanBitfield($row->rc_deleted, Revision::DELETED_COMMENT, $user)) {
if ($this->fld_comment && isset($row->rc_comment)) {
$vals['comment'] = $row->rc_comment;
}
if ($this->fld_parsedcomment && isset($row->rc_comment)) {
$vals['parsedcomment'] = Linker::formatComment($row->rc_comment, $title);
}
}
}
/* Add the patrolled flag */
if ($this->fld_patrol) {
$vals['patrolled'] = $row->rc_patrolled == 1;
$vals['unpatrolled'] = ChangesList::isUnpatrolled($row, $user);
}
if ($this->fld_loginfo && $row->rc_type == RC_LOG) {
if ($row->rc_deleted & LogPage::DELETED_ACTION) {
$vals['actionhidden'] = true;
$anyHidden = true;
}
if (LogEventsList::userCanBitfield($row->rc_deleted, LogPage::DELETED_ACTION, $user)) {
$vals['logid'] = intval($row->rc_logid);
$vals['logtype'] = $row->rc_log_type;
$vals['logaction'] = $row->rc_log_action;
$vals['logparams'] = LogFormatter::newFromRow($row)->formatParametersForApi();
}
}
if ($anyHidden && $row->rc_deleted & Revision::DELETED_RESTRICTED) {
$vals['suppressed'] = true;
//.........这里部分代码省略.........
示例9: userCan
/**
* Determine if the current user is allowed to view a particular
* field of this FileStore image file, if it's marked as deleted.
* @param int $field
* @param null|User $user User object to check, or null to use $wgUser
* @return bool
*/
public function userCan($field, User $user = null)
{
$this->load();
$title = $this->getTitle();
return Revision::userCanBitfield($this->deleted, $field, $user, $title ?: null);
}
示例10: execute
//.........这里部分代码省略.........
$this->addTimestampWhereRange('ar_timestamp', $dir, $params['start'], $params['end']);
// Include in ORDER BY for uniqueness
$this->addWhereRange('ar_id', $dir, null, null);
}
$res = $this->select(__METHOD__);
$pageMap = array();
// Maps ns&title to (fake) pageid
$count = 0;
$newPageID = 0;
foreach ($res as $row) {
if (++$count > $limit) {
// We've had enough
if ($mode == 'all' || $mode == 'revs') {
$this->setContinueEnumParameter('continue', "{$row->ar_namespace}|{$row->ar_title}|{$row->ar_timestamp}|{$row->ar_id}");
} else {
$this->setContinueEnumParameter('continue', "{$row->ar_timestamp}|{$row->ar_id}");
}
break;
}
$rev = array();
$anyHidden = false;
$rev['timestamp'] = wfTimestamp(TS_ISO_8601, $row->ar_timestamp);
if ($fld_revid) {
$rev['revid'] = intval($row->ar_rev_id);
}
if ($fld_parentid && !is_null($row->ar_parent_id)) {
$rev['parentid'] = intval($row->ar_parent_id);
}
if ($fld_user || $fld_userid) {
if ($row->ar_deleted & Revision::DELETED_USER) {
$rev['userhidden'] = true;
$anyHidden = true;
}
if (Revision::userCanBitfield($row->ar_deleted, Revision::DELETED_USER, $user)) {
if ($fld_user) {
$rev['user'] = $row->ar_user_text;
}
if ($fld_userid) {
$rev['userid'] = $row->ar_user;
}
}
}
if ($fld_comment || $fld_parsedcomment) {
if ($row->ar_deleted & Revision::DELETED_COMMENT) {
$rev['commenthidden'] = true;
$anyHidden = true;
}
if (Revision::userCanBitfield($row->ar_deleted, Revision::DELETED_COMMENT, $user)) {
if ($fld_comment) {
$rev['comment'] = $row->ar_comment;
}
if ($fld_parsedcomment) {
$title = Title::makeTitle($row->ar_namespace, $row->ar_title);
$rev['parsedcomment'] = Linker::formatComment($row->ar_comment, $title);
}
}
}
if ($fld_minor) {
$rev['minor'] = $row->ar_minor_edit == 1;
}
if ($fld_len) {
$rev['len'] = $row->ar_len;
}
if ($fld_sha1) {
if ($row->ar_deleted & Revision::DELETED_TEXT) {
$rev['sha1hidden'] = true;
示例11: userCan
/**
* Determine if the current user is allowed to view a particular
* field of this revision, if it's marked as deleted.
* @param $rc InterwikiIntegrationRCCacheEntry
* @param $field Integer
* @return Boolean
*/
public static function userCan($rc, $field)
{
if ($rc->mAttribs['integration_rc_type'] == RC_LOG) {
return LogEventsList::userCanBitfield($rc->mAttribs['integration_rc_deleted'], $field);
} else {
return Revision::userCanBitfield($rc->mAttribs['integration_rc_deleted'], $field);
}
}