Removed the $tmpFile parameter to UploadBase::verifyUpload in favour of $this->mTempFile.
[lhc/web/wiklou.git] / includes / upload / UploadFromStash.php
1 <?php
2 /**
3 * @file
4 * @ingroup upload
5 *
6 * Implements uploading from previously stored file.
7 *
8 * @author Bryan Tong Minh
9 */
10
11 class UploadFromStash extends UploadBase {
12 public static function isValidSessionKey( $key, $sessionData ) {
13 return !empty( $key ) &&
14 is_array( $sessionData ) &&
15 isset( $sessionData[$key] ) &&
16 isset( $sessionData[$key]['version'] ) &&
17 $sessionData[$key]['version'] == self::SESSION_VERSION;
18 }
19
20 public static function isValidRequest( $request ) {
21 $sessionData = $request->getSessionData( 'wsUploadData' );
22 return self::isValidSessionKey(
23 $request->getInt( 'wpSessionKey' ),
24 $sessionData
25 );
26 }
27 /*
28 * some $na vars for uploadBase method compatibility.
29 */
30 public function initialize( $name, $sessionData, $na, $na2=false ) {
31 /**
32 * Confirming a temporarily stashed upload.
33 * We don't want path names to be forged, so we keep
34 * them in the session on the server and just give
35 * an opaque key to the user agent.
36 */
37 parent::initialize( $name,
38 $sessionData['mTempPath'],
39 $sessionData['mFileSize'],
40 false
41 );
42
43 $this->mFileProps = $sessionData['mFileProps'];
44 }
45
46 public function initializeFromRequest( &$request ) {
47 $sessionKey = $request->getInt( 'wpSessionKey' );
48 $sessionData = $request->getSessionData('wsUploadData');
49
50 $desiredDestName = $request->getText( 'wpDestFile' );
51 if( !$desiredDestName )
52 $desiredDestName = $request->getText( 'wpUploadFile' );
53 return $this->initialize( $desiredDestName, $sessionData[$sessionKey], false );
54 }
55
56 /**
57 * File has been previously verified so no need to do so again.
58 */
59 protected function verifyFile() {
60 return true;
61 }
62
63 /**
64 * We're here from "ignore warnings anyway" so return just OK
65 */
66 public function checkWarnings() {
67 return array();
68 }
69
70 }