ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 314 of file class.ilFSStorageExercise5069.php.

315 {
316 $fbf = $this->getFeedbackFiles($a_user_id);
317 return count($fbf);
318 }
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 168 of file class.ilFSStorageExercise5069.php.

169 {
170 parent::create();
171 if(!file_exists($this->submission_path))
172 {
173 ilUtil::makeDirParents($this->submission_path);
174 }
175 if(!file_exists($this->tmp_path))
176 {
177 ilUtil::makeDirParents($this->tmp_path);
178 }
179 if(!file_exists($this->feedb_path))
180 {
181 ilUtil::makeDirParents($this->feedb_path);
182 }
183 return true;
184 }
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 93 of file class.ilFSStorageExercise5069.php.

94 {
95 return $this->submission_path;
96 }

Referenced by uploadFile().

+ Here is the caller graph for this function:

◆ getAssignmentFilePath()

ilFSStorageExercise5069::getAssignmentFilePath (   $a_file)

Get path for assignment file.

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

324 {
325 return $this->getAbsolutePath()."/".$a_file;
326 }
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 331 of file class.ilFSStorageExercise5069.php.

332 {
333 $dir = $this->getFeedbackPath($a_user_id);
334 return $dir."/".$a_file;
335 }
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 291 of file class.ilFSStorageExercise5069.php.

292 {
293 $files = array();
294
295 $dir = $this->getFeedbackPath($a_user_id);
296 if (@is_dir($dir))
297 {
298 $dp = opendir($dir);
299 while($file = readdir($dp))
300 {
301 if(!is_dir($this->path.'/'.$file) && substr($file, 0, 1) != ".")
302 {
303 $files[] = $file;
304 }
305 }
306 }
307
308 return $files;
309 }
$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 109 of file class.ilFSStorageExercise5069.php.

110 {
111 $path = $this->feedb_path."/".$a_user_id;
112 if(!file_exists($path))
113 {
115 }
116 return $path;
117 }

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 189 of file class.ilFSStorageExercise5069.php.

190 {
191 $files = array();
192 if (!is_dir($this->path))
193 {
194 return $files;
195 }
196
197 $dp = opendir($this->path);
198 while($file = readdir($dp))
199 {
200 if(!is_dir($this->path.'/'.$file))
201 {
202 $files[] = array(
203 'name' => $file,
204 'size' => filesize($this->path.'/'.$file),
205 'ctime' => filectime($this->path.'/'.$file),
206 'fullpath' => $this->path.'/'.$file);
207 }
208 }
209 closedir($dp);
210 $files = ilUtil::sortArray($files, "name", "asc");
211 return $files;
212 }
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 119 of file class.ilFSStorageExercise5069.php.

120 {
121 $path = $this->feedb_path."/0";
122 if(!file_exists($path))
123 {
125 }
126 return $path;
127 }

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 133 of file class.ilFSStorageExercise5069.php.

134 {
135 $path = $this->multi_feedback_upload_path."/".$a_user_id;
136 if(!file_exists($path))
137 {
139 }
140 return $path;
141 }

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 74 of file class.ilFSStorageExercise5069.php.

75 {
76 return 'exc';
77 }

◆ getPathPrefix()

ilFSStorageExercise5069::getPathPrefix ( )
protected

Implementation of abstract method.

@access protected

Reimplemented from ilFileSystemStorage5069.

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

86 {
87 return 'ilExercise';
88 }

◆ 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 147 of file class.ilFSStorageExercise5069.php.

148 {
149 $path = $this->peer_review_upload_path."/".$a_peer_id."/".$a_giver_id;
150
151 if((int)$a_crit_id)
152 {
153 $path .= (int)$a_crit_id."/";
154 }
155 if(!file_exists($path))
156 {
158 }
159 return $path;
160 }

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

+ Here is the call graph for this function:

◆ getTempPath()

ilFSStorageExercise5069::getTempPath ( )

Get submission path.

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

102 {
103 return $this->tmp_path;
104 }

◆ 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 {
50 if ($this->ass_id > 0)
51 {
52 $this->submission_path = $this->path."/subm_".$this->ass_id;
53 $this->tmp_path = $this->path."/tmp_".$this->ass_id;
54 $this->feedb_path = $this->path."/feedb_".$this->ass_id;
55 $this->multi_feedback_upload_path = $this->path."/mfb_up_".$this->ass_id;
56 $this->peer_review_upload_path = $this->path."/peer_up_".$this->ass_id;
57 $this->path.= "/ass_".$this->ass_id;
58 }
59 }
60 else
61 {
62 return false;
63 }
64 return true;
65 }

◆ uploadAssignmentFiles()

ilFSStorageExercise5069::uploadAssignmentFiles (   $a_files)

Upload assignment files (e.g.

from assignment creation form)

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

342 {
343 if (is_array($a_files["name"]))
344 {
345 foreach ($a_files["name"] as $k => $name)
346 {
347 if ($name != "")
348 {
349 $type = $a_files["type"][$k];
350 $tmp_name = $a_files["tmp_name"][$k];
351 $size = $a_files["size"][$k];
352 ilUtil::moveUploadedFile($tmp_name,
353 basename($name),
354 $this->path.DIRECTORY_SEPARATOR.basename($name),
355 false);
356 }
357 }
358 }
359 }
$size
Definition: RandomTest.php:79
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file

References $size, and ilUtil\moveUploadedFile().

+ Here is the call graph for this function:

◆ 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 226 of file class.ilFSStorageExercise5069.php.

227 {
228 $this->create();
229
230 // TODO:
231 // CHECK UPLOAD LIMIT
232 //
233 $result = false;
234 if(isset($a_http_post_file) && $a_http_post_file['size'])
235 {
236 $filename = $a_http_post_file['name'];
237 // replace whitespaces with underscores
238 $filename = preg_replace("/\s/", "_", $filename);
239 // remove all special characters
240 $filename = preg_replace("/[^_a-zA-Z0-9\.]/", "", $filename);
241
242 if(!is_dir($savepath = $this->getAbsoluteSubmissionPath()))
243 {
244 ilUtil::makeDir($savepath);
245 }
246 $savepath .= '/' .$user_id;
247 if(!is_dir($savepath))
248 {
249 ilUtil::makeDir($savepath);
250 }
251
252 // CHECK IF FILE PATH EXISTS
253 if (!is_dir($savepath))
254 {
255 ilUtil::makeDir($savepath);
256 }
257 $now = getdate();
258 $prefix = sprintf("%04d%02d%02d%02d%02d%02d", $now["year"], $now["mon"], $now["mday"], $now["hours"],
259 $now["minutes"], $now["seconds"]);
260
261 if (!$is_unziped)
262 {
263 //move_uploaded_file($a_http_post_file["tmp_name"], $savepath . $prefix . "_" . $filename);
264 ilUtil::moveUploadedFile($a_http_post_file["tmp_name"], $a_http_post_file["name"],
265 $savepath . "/" . $prefix . "_" . $filename);
266 }
267 else
268 {
269
270 rename($a_http_post_file['tmp_name'],
271 $savepath . "/" . $prefix . "_" . $filename);
272 }
273
274 require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
275
276 if (is_file($savepath . "/" . $prefix . "_" . $filename))
277 {
278 $result = array(
279 "filename" => $prefix . "_" . $filename,
280 "fullname" => $savepath . "/" . $prefix . "_" . $filename,
281 "mimetype" => ilObjMediaObject::getMimeType($savepath . "/" . $prefix . "_" . $filename)
282 );
283 }
284 }
285 return $result;
286 }
sprintf('%.4f', $callTime)
$result
getAbsoluteSubmissionPath()
Get submission path.
static getMimeType($a_file, $a_external=false)
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(), ilUtil\moveUploadedFile(), and sprintf.

+ Here is the call graph for this function:

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