Commit 2cca3ddce43c897b4d28c8c26aaba598ec3e91ec
1 parent
34fdd917
Restored function in KTUploadManager which is required by CMIS code (or anything…
… else which may want to store content which is not base64 encoded. KTS-4407. Function for storing non-base64 files required by CMIS document content functionality missing Fixed Committed by: Paul Barrett Reviewed by: Jarrett Jordaan
Showing
2 changed files
with
32 additions
and
4 deletions
ktwebservice/KTUploadManager.inc.php
| @@ -110,6 +110,7 @@ class KTUploadManager | @@ -110,6 +110,7 @@ class KTUploadManager | ||
| 110 | return ($tempdir == $this->temp_dir); | 110 | return ($tempdir == $this->temp_dir); |
| 111 | */ | 111 | */ |
| 112 | } | 112 | } |
| 113 | + | ||
| 113 | function store_base64_file($base64, $prefix= 'sa_') | 114 | function store_base64_file($base64, $prefix= 'sa_') |
| 114 | { | 115 | { |
| 115 | $tempfilename = $this->get_temp_filename($prefix); | 116 | $tempfilename = $this->get_temp_filename($prefix); |
| @@ -133,6 +134,36 @@ class KTUploadManager | @@ -133,6 +134,36 @@ class KTUploadManager | ||
| 133 | 134 | ||
| 134 | return $tempfilename; | 135 | return $tempfilename; |
| 135 | } | 136 | } |
| 137 | + | ||
| 138 | + /** | ||
| 139 | + * | ||
| 140 | + * @param string $content file content NOT base64 encoded (may be string, may be binary) | ||
| 141 | + * @param string $prefix [optional] | ||
| 142 | + * @return $tempfilename the name of the temporary file created | ||
| 143 | + */ | ||
| 144 | + function store_file($content, $prefix= 'sa_') | ||
| 145 | + { | ||
| 146 | + $tempfilename = $this->get_temp_filename($prefix); | ||
| 147 | + if (!is_writable($tempfilename)) | ||
| 148 | + { | ||
| 149 | + return new PEAR_Error("Cannot write to file: $tempfilename"); | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + if (!$this->is_valid_temporary_file($tempfilename)) | ||
| 153 | + { | ||
| 154 | + return new PEAR_Error("Invalid temporary file: $tempfilename. There is a problem with the temporary storage path: $this->temp_dir."); | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + $fp=fopen($tempfilename, 'wb'); | ||
| 158 | + if ($fp === false) | ||
| 159 | + { | ||
| 160 | + return new PEAR_Error("Cannot write content to temporary file: $tempfilename."); | ||
| 161 | + } | ||
| 162 | + fwrite($fp, $content); | ||
| 163 | + fclose($fp); | ||
| 164 | + | ||
| 165 | + return $tempfilename; | ||
| 166 | + } | ||
| 136 | 167 | ||
| 137 | /** | 168 | /** |
| 138 | * This tells the manager to manage a file that has been uploaded. | 169 | * This tells the manager to manage a file that has been uploaded. |
webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php
| @@ -447,7 +447,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { | @@ -447,7 +447,7 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { | ||
| 447 | $repositoryId = $repositories[0]['repositoryId']; | 447 | $repositoryId = $repositories[0]['repositoryId']; |
| 448 | 448 | ||
| 449 | $checkedout = $NavigationService->getCheckedOutDocs($repositoryId); | 449 | $checkedout = $NavigationService->getCheckedOutDocs($repositoryId); |
| 450 | -//print_r($checkedout);exit; | 450 | + |
| 451 | //Create a new response feed | 451 | //Create a new response feed |
| 452 | $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); | 452 | $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); |
| 453 | $workspace = $feed->getWorkspace(); | 453 | $workspace = $feed->getWorkspace(); |
| @@ -492,9 +492,6 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { | @@ -492,9 +492,6 @@ class KT_cmis_atom_service_checkedout extends KT_cmis_atom_service { | ||
| 492 | 492 | ||
| 493 | $feed->newField('cmis:hasMoreItems', 'false', $feed); | 493 | $feed->newField('cmis:hasMoreItems', 'false', $feed); |
| 494 | 494 | ||
| 495 | -// $entry = null; | ||
| 496 | -// $feed->newField('cmis:hasMoreItems', 'false', $entry, true); | ||
| 497 | - | ||
| 498 | // Expose the responseFeed | 495 | // Expose the responseFeed |
| 499 | $this->responseFeed = $feed; | 496 | $this->responseFeed = $feed; |
| 500 | } | 497 | } |