Index: branches/ApiEdit_Vodafone/includes/api/ApiUploadFile.php |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 |
|
32 | 32 | /**
|
33 | 33 | * A module to upload given files
|
34 | | - *
|
| 34 | + *
|
35 | 35 | * @addtogroup API
|
36 | 36 | */
|
37 | 37 | class ApiUploadFile extends ApiBase {
|
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | const UPLOAD_READ_ONLY = -6;
|
44 | 44 | const UPLOAD_BAD_TOKEN = -7;
|
45 | 45 |
|
46 | | -
|
| 46 | +
|
47 | 47 | public function __construct($query, $moduleName) {
|
48 | 48 | parent :: __construct($query, $moduleName, 'up');
|
49 | 49 | }
|
— | — | @@ -58,20 +58,20 @@ |
59 | 59 | extract($this->extractRequestParams());
|
60 | 60 |
|
61 | 61 | /*** VODAFONE DEBUG COMMENTS ***/
|
62 | | - print "\nPARAMETERS POST:\n <br>";
|
| 62 | + /** print "\nPARAMETERS POST:\n <br>";
|
63 | 63 | print_r($this->extractRequestParams());
|
64 | 64 | print "<br><br>";
|
65 | 65 | print "\n_FILES:\n <br>";
|
66 | 66 | print_r($_FILES);
|
67 | | - print "<br><br>";
|
| 67 | + print "<br><br>"; */
|
68 | 68 | /*******************************/
|
69 | 69 |
|
70 | | - $data = array(//'wpUploadFile' => $file,
|
71 | | - 'wpSourceType' => "file",
|
72 | | - 'wpDestFile' => $destfile,
|
73 | | - 'wpUploadDescription' => $summary,
|
74 | | - 'wpWatchthis' => $watch,
|
75 | | - 'wpIgnoreWarning' => $ignore,
|
| 70 | + $data = array(//'wpUploadFile' => $file,
|
| 71 | + 'wpSourceType' => "file",
|
| 72 | + 'wpDestFile' => $destfile,
|
| 73 | + 'wpUploadDescription' => $summary,
|
| 74 | + 'wpWatchthis' => $watch,
|
| 75 | + 'wpIgnoreWarning' => $ignore,
|
76 | 76 | 'wpLicense' => $license);
|
77 | 77 | $request = new FauxRequest($data);
|
78 | 78 |
|
— | — | @@ -86,16 +86,16 @@ |
87 | 87 | if( $userid!="" && $usertoken!="" ){
|
88 | 88 | $MyUser = new User();
|
89 | 89 | $MyUser->setID( $userid );
|
90 | | -
|
| 90 | +
|
91 | 91 | if( $MyUser->loadFromId() ){
|
92 | | - print "\n<br>entro x 1 - user cargado\n<br>";
|
93 | | -
|
| 92 | + //print "\n<br>entro x 1 - user cargado\n<br>";
|
| 93 | +
|
94 | 94 | if( $usertoken == $MyUser->mToken ){
|
95 | | - print "\n<br>entro x 2 - tokens coinciden\n<br>";
|
| 95 | + //print "\n<br>entro x 2 - tokens coinciden\n<br>";
|
96 | 96 | $MyUser->setCookies();
|
97 | 97 | $wgUser = $MyUser;
|
98 | 98 | }else{
|
99 | | - print "\n<br>entro x 3 - mal token\n<br>";
|
| 99 | + //print "\n<br>entro x 3 - mal token\n<br>";
|
100 | 100 | $this->process( self::UPLOAD_BAD_TOKEN );
|
101 | 101 | return;
|
102 | 102 | }
|
— | — | @@ -103,12 +103,12 @@ |
104 | 104 | }
|
105 | 105 |
|
106 | 106 | /*** VODAFONE DEBUG COMMENTS ***/
|
107 | | - print "\n<br>USER: <br>";
|
| 107 | + /**print "\n<br>USER: <br>";
|
108 | 108 | print_r($wgUser);
|
109 | 109 | print "<br><br>";
|
110 | 110 | print "_SESSION: <br>";
|
111 | 111 | print_r($_SESSION);
|
112 | | - print "<br><br>";
|
| 112 | + print "<br><br>"; */
|
113 | 113 | /*******************************/
|
114 | 114 |
|
115 | 115 | # Check uploading enabled
|
— | — | @@ -143,9 +143,9 @@ |
144 | 144 | return;
|
145 | 145 | }
|
146 | 146 |
|
147 | | - $this->process($form->processUpload());
|
| 147 | + $this->process($form->internalProcessUpload());
|
148 | 148 | // $this->cleanupTempFile();
|
149 | | -
|
| 149 | +
|
150 | 150 | } else {
|
151 | 151 | $this->process( self::UPLOAD_INVALID );
|
152 | 152 | }
|
— | — | @@ -178,7 +178,7 @@ |
179 | 179 | case ApiUploadFile::UPLOAD_READ_ONLY :
|
180 | 180 | $result['result'] = 'Upload_Read_Only';
|
181 | 181 | break;
|
182 | | -
|
| 182 | +
|
183 | 183 | case ApiUploadFile::UPLOAD_BAD_TOKEN :
|
184 | 184 | $result['result'] = 'UPLOAD_BAD_TOKEN';
|
185 | 185 | break;
|
— | — | @@ -236,7 +236,7 @@ |
237 | 237 | case UploadForm::UPLOAD_WARNING:
|
238 | 238 | $result['result'] = 'Upload_Warning';
|
239 | 239 | break;
|
240 | | -
|
| 240 | +
|
241 | 241 | default :
|
242 | 242 | $result['result'] = 'Upload_Invalid';
|
243 | 243 | }
|
— | — | @@ -271,7 +271,7 @@ |
272 | 272 | ApiBase :: PARAM_TYPE => 'string'
|
273 | 273 | ),
|
274 | 274 |
|
275 | | -
|
| 275 | +
|
276 | 276 | );
|
277 | 277 | }
|
278 | 278 |
|
— | — | @@ -294,9 +294,17 @@ |
295 | 295 |
|
296 | 296 | protected function getExamples() {
|
297 | 297 | return array (
|
298 | | - "For test Upload file selected: ",
|
299 | | - " http://esdt32606/wikisvn/api_upload_form.php",
|
300 | | -
|
| 298 | + "Multipart post request: api.php ? action=upload ",
|
| 299 | + "Post Parameters:",
|
| 300 | + " upfile=<path_to_file>",
|
| 301 | + " upsourcetype=<file>",
|
| 302 | + " updestfile=<file_name.jpg>",
|
| 303 | + " upsummary=<summary>",
|
| 304 | + " [upwatch=yes/no]",
|
| 305 | + " [upignore=yes/no]",
|
| 306 | + " [uplicense=<License>]",
|
| 307 | + " [upuserid=<userId>]",
|
| 308 | + " [uplgtoken=lgToken]",
|
301 | 309 | );
|
302 | 310 | }
|
303 | 311 |
|