当前位置: 首页>>代码示例>>PHP>>正文


PHP ArchivedFile::userCan方法代码示例

本文整理汇总了PHP中ArchivedFile::userCan方法的典型用法代码示例。如果您正苦于以下问题:PHP ArchivedFile::userCan方法的具体用法?PHP ArchivedFile::userCan怎么用?PHP ArchivedFile::userCan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArchivedFile的用法示例。


在下文中一共展示了ArchivedFile::userCan方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fileComment

 /**
  * Wrap and format the given file's comment block, if the current
  * user is allowed to view it.
  *
  * @param ArchivedFile $file
  * @return string HTML
  */
 private function fileComment($file)
 {
     if ($file->userCan(File::DELETED_COMMENT)) {
         $block = $this->skin->commentBlock($file->description);
     } else {
         $block = ' ' . wfMsgHtml('rev-deleted-comment');
     }
     if ($file->isDeleted(File::DELETED_COMMENT)) {
         return "<span class=\"history-deleted\">{$block}</span>";
     }
     return $block;
 }
开发者ID:ruizrube,项目名称:spdef,代码行数:19,代码来源:SpecialRevisiondelete.php

示例2: getFileComment

 /**
  * Fetch file upload comment if it's available to this user
  *
  * @param File|ArchivedFile $file
  * @return string HTML fragment
  */
 function getFileComment($file)
 {
     if (!$file->userCan(File::DELETED_COMMENT, $this->getUser())) {
         return '<span class="history-deleted"><span class="comment">' . $this->msg('rev-deleted-comment')->escaped() . '</span></span>';
     }
     $link = Linker::commentBlock($file->getRawDescription());
     if ($file->isDeleted(File::DELETED_COMMENT)) {
         $link = '<span class="history-deleted">' . $link . '</span>';
     }
     return $link;
 }
开发者ID:raymondzhangl,项目名称:mediawiki,代码行数:17,代码来源:SpecialUndelete.php

示例3: checkWarnings

 /**
  * Check for non fatal problems with the file.
  *
  * This should not assume that mTempPath is set.
  *
  * @return Array of warnings
  */
 public function checkWarnings()
 {
     global $wgLang;
     wfProfileIn(__METHOD__);
     $warnings = array();
     $localFile = $this->getLocalFile();
     $filename = $localFile->getName();
     /**
      * Check whether the resulting filename is different from the desired one,
      * but ignore things like ucfirst() and spaces/underscore things
      */
     $comparableName = str_replace(' ', '_', $this->mDesiredDestName);
     $comparableName = Title::capitalize($comparableName, NS_FILE);
     if ($this->mDesiredDestName != $filename && $comparableName != $filename) {
         $warnings['badfilename'] = $filename;
         // Debugging for bug 62241
         wfDebugLog('upload', "Filename: '{$filename}', mDesiredDestName: '{$this->mDesiredDestName}', comparableName: '{$comparableName}'");
     }
     // Check whether the file extension is on the unwanted list
     global $wgCheckFileExtensions, $wgFileExtensions;
     if ($wgCheckFileExtensions) {
         $extensions = array_unique($wgFileExtensions);
         if (!$this->checkFileExtension($this->mFinalExtension, $extensions)) {
             $warnings['filetype-unwanted-type'] = array($this->mFinalExtension, $wgLang->commaList($extensions), count($extensions));
         }
     }
     global $wgUploadSizeWarning;
     if ($wgUploadSizeWarning && $this->mFileSize > $wgUploadSizeWarning) {
         $warnings['large-file'] = array($wgUploadSizeWarning, $this->mFileSize);
     }
     if ($this->mFileSize == 0) {
         $warnings['emptyfile'] = true;
     }
     $exists = self::getExistsWarning($localFile);
     if ($exists !== false) {
         $warnings['exists'] = $exists;
     }
     // Check dupes against existing files
     $hash = $this->getTempFileSha1Base36();
     $dupes = RepoGroup::singleton()->findBySha1($hash);
     $title = $this->getTitle();
     // Remove all matches against self
     foreach ($dupes as $key => $dupe) {
         if ($title->equals($dupe->getTitle())) {
             unset($dupes[$key]);
         }
     }
     if ($dupes) {
         $warnings['duplicate'] = $dupes;
     }
     // Check dupes against archives
     $archivedImage = new ArchivedFile(null, 0, "{$hash}.{$this->mFinalExtension}");
     if ($archivedImage->getID() > 0) {
         if ($archivedImage->userCan(File::DELETED_FILE)) {
             $warnings['duplicate-archive'] = $archivedImage->getName();
         } else {
             $warnings['duplicate-archive'] = '';
         }
     }
     wfProfileOut(__METHOD__);
     return $warnings;
 }
开发者ID:elf-pavlik,项目名称:web-payments.org,代码行数:69,代码来源:UploadBase.php

示例4: execute

 function execute($par)
 {
     $this->checkPermissions();
     $user = $this->getUser();
     $this->setHeaders();
     $this->outputHeader();
     $this->loadRequest($par);
     $out = $this->getOutput();
     if (is_null($this->mTargetObj)) {
         $out->addWikiMsg('undelete-header');
         # Not all users can just browse every deleted page from the list
         if ($user->isAllowed('browsearchive')) {
             $this->showSearchForm();
         }
         return;
     }
     if ($this->mAllowed) {
         $out->setPageTitle($this->msg('undeletepage'));
     } else {
         $out->setPageTitle($this->msg('viewdeletedpage'));
     }
     $this->getSkin()->setRelevantTitle($this->mTargetObj);
     if ($this->mTimestamp !== '') {
         $this->showRevision($this->mTimestamp);
     } elseif ($this->mFilename !== null) {
         $file = new ArchivedFile($this->mTargetObj, '', $this->mFilename);
         // Check if user is allowed to see this file
         if (!$file->exists()) {
             $out->addWikiMsg('filedelete-nofile', $this->mFilename);
         } elseif (!$file->userCan(File::DELETED_FILE, $user)) {
             if ($file->isDeleted(File::DELETED_RESTRICTED)) {
                 throw new PermissionsError('suppressrevision');
             } else {
                 throw new PermissionsError('deletedtext');
             }
         } elseif (!$user->matchEditToken($this->mToken, $this->mFilename)) {
             $this->showFileConfirmationForm($this->mFilename);
         } else {
             $this->showFile($this->mFilename);
         }
     } elseif ($this->mRestore && $this->mAction == 'submit') {
         $this->undelete();
     } else {
         $this->showHistory();
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:46,代码来源:SpecialUndelete.php

示例5: checkWarnings

 /**
  * Check for non fatal problems with the file.
  *
  * This should not assume that mTempPath is set.
  *
  * @return array Array of warnings
  */
 public function checkWarnings()
 {
     global $wgLang;
     $warnings = [];
     $localFile = $this->getLocalFile();
     $localFile->load(File::READ_LATEST);
     $filename = $localFile->getName();
     /**
      * Check whether the resulting filename is different from the desired one,
      * but ignore things like ucfirst() and spaces/underscore things
      */
     $comparableName = str_replace(' ', '_', $this->mDesiredDestName);
     $comparableName = Title::capitalize($comparableName, NS_FILE);
     if ($this->mDesiredDestName != $filename && $comparableName != $filename) {
         $warnings['badfilename'] = $filename;
     }
     // Check whether the file extension is on the unwanted list
     global $wgCheckFileExtensions, $wgFileExtensions;
     if ($wgCheckFileExtensions) {
         $extensions = array_unique($wgFileExtensions);
         if (!$this->checkFileExtension($this->mFinalExtension, $extensions)) {
             $warnings['filetype-unwanted-type'] = [$this->mFinalExtension, $wgLang->commaList($extensions), count($extensions)];
         }
     }
     global $wgUploadSizeWarning;
     if ($wgUploadSizeWarning && $this->mFileSize > $wgUploadSizeWarning) {
         $warnings['large-file'] = [$wgUploadSizeWarning, $this->mFileSize];
     }
     if ($this->mFileSize == 0) {
         $warnings['empty-file'] = true;
     }
     $hash = $this->getTempFileSha1Base36();
     $exists = self::getExistsWarning($localFile);
     if ($exists !== false) {
         $warnings['exists'] = $exists;
         // check if file is an exact duplicate of current file version
         if ($hash === $localFile->getSha1()) {
             $warnings['no-change'] = $localFile;
         }
         // check if file is an exact duplicate of older versions of this file
         $history = $localFile->getHistory();
         foreach ($history as $oldFile) {
             if ($hash === $oldFile->getSha1()) {
                 $warnings['duplicate-version'][] = $oldFile;
             }
         }
     }
     if ($localFile->wasDeleted() && !$localFile->exists()) {
         $warnings['was-deleted'] = $filename;
     }
     // Check dupes against existing files
     $dupes = RepoGroup::singleton()->findBySha1($hash);
     $title = $this->getTitle();
     // Remove all matches against self
     foreach ($dupes as $key => $dupe) {
         if ($title->equals($dupe->getTitle())) {
             unset($dupes[$key]);
         }
     }
     if ($dupes) {
         $warnings['duplicate'] = $dupes;
     }
     // Check dupes against archives
     $archivedFile = new ArchivedFile(null, 0, '', $hash);
     if ($archivedFile->getID() > 0) {
         if ($archivedFile->userCan(File::DELETED_FILE)) {
             $warnings['duplicate-archive'] = $archivedFile->getName();
         } else {
             $warnings['duplicate-archive'] = '';
         }
     }
     return $warnings;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:80,代码来源:UploadBase.php

示例6: execute

 function execute($par)
 {
     $this->setHeaders();
     if (!$this->userCanExecute($this->getUser())) {
         $this->displayRestrictionError();
         return;
     }
     $this->outputHeader();
     $this->loadRequest();
     $out = $this->getOutput();
     if ($this->mAllowed) {
         $out->setPageTitle(wfMsg('undeletepage'));
     } else {
         $out->setPageTitle(wfMsg('viewdeletedpage'));
     }
     if ($par != '') {
         $this->mTarget = $par;
     }
     if ($this->mTarget !== '') {
         $this->mTargetObj = Title::newFromURL($this->mTarget);
         $this->getSkin()->setRelevantTitle($this->mTargetObj);
     } else {
         $this->mTargetObj = null;
     }
     if (is_null($this->mTargetObj)) {
         # Not all users can just browse every deleted page from the list
         if ($this->getUser()->isAllowed('browsearchive')) {
             $this->showSearchForm();
             # List undeletable articles
             if ($this->mSearchPrefix) {
                 $result = PageArchive::listPagesByPrefix($this->mSearchPrefix);
                 $this->showList($result);
             }
         } else {
             $out->addWikiMsg('undelete-header');
         }
         return;
     }
     if ($this->mTimestamp !== '') {
         return $this->showRevision($this->mTimestamp);
     }
     if ($this->mFilename !== null) {
         $file = new ArchivedFile($this->mTargetObj, '', $this->mFilename);
         // Check if user is allowed to see this file
         if (!$file->exists()) {
             $out->addWikiMsg('filedelete-nofile', $this->mFilename);
             return;
         } elseif (!$file->userCan(File::DELETED_FILE)) {
             if ($file->isDeleted(File::DELETED_RESTRICTED)) {
                 $out->permissionRequired('suppressrevision');
             } else {
                 $out->permissionRequired('deletedtext');
             }
             return false;
         } elseif (!$this->getUser()->matchEditToken($this->mToken, $this->mFilename)) {
             $this->showFileConfirmationForm($this->mFilename);
             return false;
         } else {
             return $this->showFile($this->mFilename);
         }
     }
     if ($this->mRestore && $this->mAction == 'submit') {
         global $wgUploadMaintenance;
         if ($wgUploadMaintenance && $this->mTargetObj && $this->mTargetObj->getNamespace() == NS_FILE) {
             $out->wrapWikiMsg("<div class='error'>\n\$1\n</div>\n", array('filedelete-maintenance'));
             return;
         }
         return $this->undelete();
     }
     if ($this->mInvert && $this->mAction == 'submit') {
         return $this->showHistory();
     }
     return $this->showHistory();
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:74,代码来源:SpecialUndelete.php

示例7: execute

 function execute()
 {
     global $wgOut, $wgUser;
     if ($this->mAllowed) {
         $wgOut->setPagetitle(wfMsg("undeletepage"));
     } else {
         $wgOut->setPagetitle(wfMsg("viewdeletedpage"));
     }
     if (is_null($this->mTargetObj)) {
         # Not all users can just browse every deleted page from the list
         if ($wgUser->isAllowed('browsearchive')) {
             $this->showSearchForm();
             # List undeletable articles
             if ($this->mSearchPrefix) {
                 $result = PageArchive::listPagesByPrefix($this->mSearchPrefix);
                 $this->showList($result);
             }
         } else {
             $wgOut->addWikiText(wfMsgHtml('undelete-header'));
         }
         return;
     }
     if ($this->mTimestamp !== '') {
         return $this->showRevision($this->mTimestamp);
     }
     if ($this->mFile !== null) {
         $file = new ArchivedFile($this->mTargetObj, '', $this->mFile);
         // Check if user is allowed to see this file
         if (!$file->userCan(File::DELETED_FILE)) {
             $wgOut->permissionRequired('suppressrevision');
             return false;
         } elseif (!$wgUser->matchEditToken($this->mToken, $this->mFile)) {
             $this->showFileConfirmationForm($this->mFile);
             return false;
         } else {
             return $this->showFile($this->mFile);
         }
     }
     if ($this->mRestore && $this->mAction == "submit") {
         return $this->undelete();
     }
     if ($this->mInvert && $this->mAction == "submit") {
         return $this->showHistory();
     }
     return $this->showHistory();
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:46,代码来源:SpecialUndelete.php


注:本文中的ArchivedFile::userCan方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。