ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilFSStorageExercise5069 Class Reference
+ Inheritance diagram for ilFSStorageExercise5069:
+ Collaboration diagram for ilFSStorageExercise5069:

Public Member Functions

 __construct ($a_container_id=0, $a_ass_id=0)
 Constructor. More...
 
 init ()
 Append ass_<ass_id> to path (assignment id) More...
 
 getAbsoluteSubmissionPath ()
 Get submission path. More...
 
 getTempPath ()
 Get submission path. More...
 
 getFeedbackPath ($a_user_id)
 Get feedback path. More...
 
 getGlobalFeedbackPath ()
 
 getMultiFeedbackUploadPath ($a_user_id)
 Get multi feedback upload path (each uploader handled in a separate path) More...
 
 getPeerReviewUploadPath ($a_peer_id, $a_giver_id, $a_crit_id)
 Get pear review upload path (each peer handled in a separate path) More...
 
 create ()
 Create directory. More...
 
 getFiles ()
 Get assignment files. More...
 
 uploadFile ($a_http_post_file, $user_id, $is_unziped=false)
 store delivered file in filesystem More...
 
 getFeedbackFiles ($a_user_id)
 Get number of feedback files. More...
 
 countFeedbackFiles ($a_user_id)
 Count number of feedback files for a user. More...
 
 getAssignmentFilePath ($a_file)
 Get path for assignment file. More...
 
 getFeedbackFilePath ($a_user_id, $a_file)
 Get path for feedback file. More...
 
 uploadAssignmentFiles ($a_files)
 Upload assignment files (e.g. More...
 
- Public Member Functions inherited from ilFileSystemStorage5069
 __construct ($a_storage_type, $a_path_conversion, $a_container_id)
 Constructor. More...
 
 getContainerId ()
 
 create ()
 Create directory. More...
 
 getAbsolutePath ()
 Get absolute path of storage directory. More...
 
 writeToFile ($a_data, $a_absolute_path)
 Write data to file. More...
 
 deleteFile ($a_abs_name)
 Delete file. More...
 
 deleteDirectory ($a_abs_name)
 Delete directory. More...
 
 delete ()
 Delete complete directory. More...
 
 copyFile ($a_from, $a_to)
 Copy files. More...
 
 appendToPath ($a_appendix)
 
 getStorageType ()
 
 getPath ()
 Get path. More...
 

Protected Member Functions

 getPathPostfix ()
 Implementation of abstract method. More...
 
 getPathPrefix ()
 Implementation of abstract method. More...
 
 getPathPrefix ()
 Get path prefix. More...
 
 getPathPostfix ()
 Get directory name. More...
 
 init ()
 Read path info. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFileSystemStorage5069
static _createPathFromId ($a_container_id, $a_name)
 Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5. More...
 
static _copyDirectory ($a_source, $a_target)
 Copy directory and all contents. More...
 
- Data Fields inherited from ilFileSystemStorage5069
const STORAGE_WEB = 1
 
const STORAGE_DATA = 2
 
const STORAGE_SECURED = 3
 
const FACTOR = 100
 
const MAX_EXPONENT = 3
 
const SECURED_DIRECTORY = "sec"
 
- Protected Attributes inherited from ilFileSystemStorage5069
 $path
 

Detailed Description

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 30 of file class.ilFSStorageExercise5069.php.

Constructor & Destructor Documentation

◆ __construct()

ilFSStorageExercise5069::__construct (   $a_container_id = 0,
  $a_ass_id = 0 
)

Constructor.

Parameters
intexercise id

Definition at line 37 of file class.ilFSStorageExercise5069.php.

38 {
39 $this->ass_id = $a_ass_id;
40 parent::__construct(self::STORAGE_DATA, true, $a_container_id);
41 }

Member Function Documentation

◆ countFeedbackFiles()

ilFSStorageExercise5069::countFeedbackFiles (   $a_user_id)

Count number of feedback files for a user.

Definition at line 299 of file class.ilFSStorageExercise5069.php.

300 {
301 $fbf = $this->getFeedbackFiles($a_user_id);
302 return count($fbf);
303 }
getFeedbackFiles($a_user_id)
Get number of feedback files.

References getFeedbackFiles().

+ Here is the call graph for this function:

◆ create()

ilFSStorageExercise5069::create ( )

Create directory.

@access public

Reimplemented from ilFileSystemStorage5069.

Definition at line 159 of file class.ilFSStorageExercise5069.php.

160 {
161 parent::create();
162 if (!file_exists($this->submission_path)) {
163 ilUtil::makeDirParents($this->submission_path);
164 }
165 if (!file_exists($this->tmp_path)) {
166 ilUtil::makeDirParents($this->tmp_path);
167 }
168 if (!file_exists($this->feedb_path)) {
169 ilUtil::makeDirParents($this->feedb_path);
170 }
171 return true;
172 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References ilUtil\makeDirParents().

Referenced by uploadFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAbsoluteSubmissionPath()

ilFSStorageExercise5069::getAbsoluteSubmissionPath ( )

Get submission path.

Definition at line 89 of file class.ilFSStorageExercise5069.php.

90 {
91 return $this->submission_path;
92 }

Referenced by uploadFile().

+ Here is the caller graph for this function:

◆ getAssignmentFilePath()

ilFSStorageExercise5069::getAssignmentFilePath (   $a_file)

Get path for assignment file.

Definition at line 308 of file class.ilFSStorageExercise5069.php.

309 {
310 return $this->getAbsolutePath() . "/" . $a_file;
311 }
getAbsolutePath()
Get absolute path of storage directory.

References ilFileSystemStorage5069\getAbsolutePath().

+ Here is the call graph for this function:

◆ getFeedbackFilePath()

ilFSStorageExercise5069::getFeedbackFilePath (   $a_user_id,
  $a_file 
)

Get path for feedback file.

Definition at line 316 of file class.ilFSStorageExercise5069.php.

317 {
318 $dir = $this->getFeedbackPath($a_user_id);
319 return $dir . "/" . $a_file;
320 }
getFeedbackPath($a_user_id)
Get feedback path.

References getFeedbackPath().

+ Here is the call graph for this function:

◆ getFeedbackFiles()

ilFSStorageExercise5069::getFeedbackFiles (   $a_user_id)

Get number of feedback files.

Definition at line 279 of file class.ilFSStorageExercise5069.php.

280 {
281 $files = array();
282
283 $dir = $this->getFeedbackPath($a_user_id);
284 if (@is_dir($dir)) {
285 $dp = opendir($dir);
286 while ($file = readdir($dp)) {
287 if (!is_dir($this->path . '/' . $file) && substr($file, 0, 1) != ".") {
288 $files[] = $file;
289 }
290 }
291 }
292
293 return $files;
294 }
$files
Definition: add-vimline.php:18
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $file, $files, and getFeedbackPath().

Referenced by countFeedbackFiles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFeedbackPath()

ilFSStorageExercise5069::getFeedbackPath (   $a_user_id)

Get feedback path.

Definition at line 105 of file class.ilFSStorageExercise5069.php.

106 {
107 $path = $this->feedb_path . "/" . $a_user_id;
108 if (!file_exists($path)) {
110 }
111 return $path;
112 }

References ilFileSystemStorage5069\$path, and ilUtil\makeDirParents().

Referenced by getFeedbackFilePath(), and getFeedbackFiles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFiles()

ilFSStorageExercise5069::getFiles ( )

Get assignment files.

Definition at line 177 of file class.ilFSStorageExercise5069.php.

178 {
179 $files = array();
180 if (!is_dir($this->path)) {
181 return $files;
182 }
183
184 $dp = opendir($this->path);
185 while ($file = readdir($dp)) {
186 if (!is_dir($this->path . '/' . $file)) {
187 $files[] = array(
188 'name' => $file,
189 'size' => filesize($this->path . '/' . $file),
190 'ctime' => filectime($this->path . '/' . $file),
191 'fullpath' => $this->path . '/' . $file);
192 }
193 }
194 closedir($dp);
195 $files = ilUtil::sortArray($files, "name", "asc");
196 return $files;
197 }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray

References $file, $files, and ilUtil\sortArray().

+ Here is the call graph for this function:

◆ getGlobalFeedbackPath()

ilFSStorageExercise5069::getGlobalFeedbackPath ( )

Definition at line 114 of file class.ilFSStorageExercise5069.php.

115 {
116 $path = $this->feedb_path . "/0";
117 if (!file_exists($path)) {
119 }
120 return $path;
121 }

References ilFileSystemStorage5069\$path, and ilUtil\makeDirParents().

+ Here is the call graph for this function:

◆ getMultiFeedbackUploadPath()

ilFSStorageExercise5069::getMultiFeedbackUploadPath (   $a_user_id)

Get multi feedback upload path (each uploader handled in a separate path)

Definition at line 127 of file class.ilFSStorageExercise5069.php.

128 {
129 $path = $this->multi_feedback_upload_path . "/" . $a_user_id;
130 if (!file_exists($path)) {
132 }
133 return $path;
134 }

References ilFileSystemStorage5069\$path, and ilUtil\makeDirParents().

+ Here is the call graph for this function:

◆ getPathPostfix()

ilFSStorageExercise5069::getPathPostfix ( )
protected

Implementation of abstract method.

@access protected

Reimplemented from ilFileSystemStorage5069.

Definition at line 70 of file class.ilFSStorageExercise5069.php.

71 {
72 return 'exc';
73 }

◆ getPathPrefix()

ilFSStorageExercise5069::getPathPrefix ( )
protected

Implementation of abstract method.

@access protected

Reimplemented from ilFileSystemStorage5069.

Definition at line 81 of file class.ilFSStorageExercise5069.php.

82 {
83 return 'ilExercise';
84 }

◆ getPeerReviewUploadPath()

ilFSStorageExercise5069::getPeerReviewUploadPath (   $a_peer_id,
  $a_giver_id,
  $a_crit_id 
)

Get pear review upload path (each peer handled in a separate path)

Definition at line 140 of file class.ilFSStorageExercise5069.php.

141 {
142 $path = $this->peer_review_upload_path . "/" . $a_peer_id . "/" . $a_giver_id;
143
144 if ((int) $a_crit_id) {
145 $path .= (int) $a_crit_id . "/";
146 }
147 if (!file_exists($path)) {
149 }
150 return $path;
151 }

References ilFileSystemStorage5069\$path, and ilUtil\makeDirParents().

+ Here is the call graph for this function:

◆ getTempPath()

ilFSStorageExercise5069::getTempPath ( )

Get submission path.

Definition at line 97 of file class.ilFSStorageExercise5069.php.

98 {
99 return $this->tmp_path;
100 }

◆ init()

ilFSStorageExercise5069::init ( )

Append ass_<ass_id> to path (assignment id)

Reimplemented from ilFileSystemStorage5069.

Definition at line 46 of file class.ilFSStorageExercise5069.php.

47 {
48 if (parent::init()) {
49 if ($this->ass_id > 0) {
50 $this->submission_path = $this->path . "/subm_" . $this->ass_id;
51 $this->tmp_path = $this->path . "/tmp_" . $this->ass_id;
52 $this->feedb_path = $this->path . "/feedb_" . $this->ass_id;
53 $this->multi_feedback_upload_path = $this->path . "/mfb_up_" . $this->ass_id;
54 $this->peer_review_upload_path = $this->path . "/peer_up_" . $this->ass_id;
55 $this->path.= "/ass_" . $this->ass_id;
56 }
57 } else {
58 return false;
59 }
60 return true;
61 }

◆ uploadAssignmentFiles()

ilFSStorageExercise5069::uploadAssignmentFiles (   $a_files)

Upload assignment files (e.g.

from assignment creation form)

Definition at line 326 of file class.ilFSStorageExercise5069.php.

327 {
328 if (is_array($a_files["name"])) {
329 foreach ($a_files["name"] as $k => $name) {
330 if ($name != "") {
331 $type = $a_files["type"][$k];
332 $tmp_name = $a_files["tmp_name"][$k];
333 $size = $a_files["size"][$k];
334 ilUtil::moveUploadedFile(
335 $tmp_name,
336 basename($name),
337 $this->path . DIRECTORY_SEPARATOR . basename($name),
338 false
339 );
340 }
341 }
342 }
343 }
$size
Definition: RandomTest.php:84
if($format !==null) $name
Definition: metadata.php:146
$type

References $name, $size, and $type.

◆ uploadFile()

ilFSStorageExercise5069::uploadFile (   $a_http_post_file,
  $user_id,
  $is_unziped = false 
)

store delivered file in filesystem

Parameters
arrayHTTP_POST_FILES
numericdatabase id of the user who delivered the file @access public
Returns
mixed Returns a result array with filename and mime type of the saved file, otherwise false

Definition at line 211 of file class.ilFSStorageExercise5069.php.

212 {
213 $this->create();
214
215 // TODO:
216 // CHECK UPLOAD LIMIT
217 //
218 $result = false;
219 if (isset($a_http_post_file) && $a_http_post_file['size']) {
220 $filename = $a_http_post_file['name'];
221 // replace whitespaces with underscores
222 $filename = preg_replace("/\s/", "_", $filename);
223 // remove all special characters
224 $filename = preg_replace("/[^_a-zA-Z0-9\.]/", "", $filename);
225
226 if (!is_dir($savepath = $this->getAbsoluteSubmissionPath())) {
227 ilUtil::makeDir($savepath);
228 }
229 $savepath .= '/' . $user_id;
230 if (!is_dir($savepath)) {
231 ilUtil::makeDir($savepath);
232 }
233
234 // CHECK IF FILE PATH EXISTS
235 if (!is_dir($savepath)) {
236 ilUtil::makeDir($savepath);
237 }
238 $now = getdate();
239 $prefix = sprintf(
240 "%04d%02d%02d%02d%02d%02d",
241 $now["year"],
242 $now["mon"],
243 $now["mday"],
244 $now["hours"],
245 $now["minutes"],
246 $now["seconds"]
247 );
248
249 if (!$is_unziped) {
250 //move_uploaded_file($a_http_post_file["tmp_name"], $savepath . $prefix . "_" . $filename);
251 ilUtil::moveUploadedFile(
252 $a_http_post_file["tmp_name"],
253 $a_http_post_file["name"],
254 $savepath . "/" . $prefix . "_" . $filename
255 );
256 } else {
257 rename(
258 $a_http_post_file['tmp_name'],
259 $savepath . "/" . $prefix . "_" . $filename
260 );
261 }
262
263 require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
264
265 if (is_file($savepath . "/" . $prefix . "_" . $filename)) {
266 $result = array(
267 "filename" => $prefix . "_" . $filename,
268 "fullname" => $savepath . "/" . $prefix . "_" . $filename,
269 "mimetype" => ilObjMediaObject::getMimeType($savepath . "/" . $prefix . "_" . $filename)
270 );
271 }
272 }
273 return $result;
274 }
sprintf('%.4f', $callTime)
$result
getAbsoluteSubmissionPath()
Get submission path.
static getMimeType($a_file, $a_external=null)
get mime type for file
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...

References $filename, $result, create(), getAbsoluteSubmissionPath(), ilObjMediaObject\getMimeType(), ilUtil\makeDir(), and sprintf.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: