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