示例#1
0
 /**
  * Wrapper around the parent function in order to defer checking protection
  * until we are sure that the file can actually be uploaded
  */
 public function verifyPermissions($user)
 {
     if ($this->mAsync) {
         return true;
     }
     return parent::verifyPermissions($user);
 }
 /**
  * @param UploadBase $upload
  * @return array
  */
 private function uploadImage($upload)
 {
     global $wgRequest, $wgUser, $wgEnableUploads;
     $uploadStatus = array("status" => "error");
     if (empty($wgEnableUploads)) {
         $uploadStatus["errors"] = [wfMessage('themedesigner-upload-disabled')->plain()];
     } else {
         $upload->initializeFromRequest($wgRequest);
         $permErrors = $upload->verifyPermissions($wgUser);
         if ($permErrors !== true) {
             $uploadStatus["errors"] = array(wfMsg('badaccess'));
         } else {
             $details = $upload->verifyUpload();
             if ($details['status'] != UploadBase::OK) {
                 $uploadStatus["errors"] = array($this->getUploadErrorMessage($details));
             } else {
                 $warnings = $upload->checkWarnings();
                 if (!empty($warnings)) {
                     $uploadStatus["errors"] = $this->getUploadWarningMessages($warnings);
                 } else {
                     //save temp file
                     $status = $upload->performUpload();
                     $uploadStatus["status"] = "uploadattempted";
                     $uploadStatus["isGood"] = $status->isGood();
                 }
             }
         }
     }
     return $uploadStatus;
 }