ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCourseFile Class Reference
+ Inheritance diagram for ilCourseFile:
+ Collaboration diagram for ilCourseFile:

Public Member Functions

 ilCourseFile ($a_file_id=null)
 setFileId ($a_id)
 getFileId ()
 getCourseId ()
 setCourseId ($a_course_id)
 setFileName ($a_name)
 getFileName ()
 setFileType ($a_type)
 getFileType ()
 setFileSize ($a_size)
 getFileSize ()
 setTemporaryName ($a_name)
 getTemporaryName ()
 setErrorCode ($a_code)
 getErrorCode ()
 getAbsolutePath ()
 validate ()
 create ($a_upload=true)
 delete ()
 _deleteByCourse ($a_course_id)
_readFilesByCourse ($a_course_id)
 __read ()

Static Public Member Functions

static _cloneFiles ($a_source_id, $a_target_id)
 Clone course files.

Data Fields

 $ilErr
 $ilDB
 $tree
 $lng
 $course_id = null
 $file_id = null

Private Attributes

 $fss_storage = null

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id:
class.ilCourseFile.php 23143 2010-03-09 12:15:33Z smeyer

Definition at line 35 of file class.ilCourseFile.php.

Member Function Documentation

ilCourseFile::__read ( )

Definition at line 263 of file class.ilCourseFile.php.

References $ilDB, $query, $res, $row, getCourseId(), setCourseId(), setFileName(), setFileSize(), and setFileType().

Referenced by ilCourseFile().

{
global $ilDB;
if(!$this->file_id)
{
return true;
}
// read file data
$query = "SELECT * FROM crs_file WHERE file_id = ".$ilDB->quote($this->file_id,'integer');
$res = $this->db->query($query);
while($row = $ilDB->fetchObject($res))
{
$this->setFileName($row->file_name);
$this->setFileSize($row->file_size);
$this->setFileType($row->file_type);
$this->setCourseId($row->course_id);
}
$this->fss_storage = new ilFSStorageCourse($this->getCourseId());
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilCourseFile::_cloneFiles (   $a_source_id,
  $a_target_id 
)
static

Clone course files.

public

Parameters
intsource id
inttarget_id

Definition at line 68 of file class.ilCourseFile.php.

References _readFilesByCourse(), and ilCourseFile().

Referenced by ilObjCourse\cloneObject().

{
$source = new ilFSStorageCourse($a_source_id);
foreach(ilCourseFile::_readFilesByCourse($a_source_id) as $file_obj)
{
$new_file = new ilCourseFile();
$new_file->setCourseId($a_target_id);
$new_file->setFileName($file_obj->getFileName());
$new_file->setFileSize($file_obj->getFileSize());
$new_file->setFileType($file_obj->getFileType());
$new_file->create(false);
$target = new ilFSStorageCourse($a_target_id);
$target->initInfoDirectory();
$source->copyFile($file_obj->getAbsolutePath(),$new_file->getAbsolutePath());
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseFile::_deleteByCourse (   $a_course_id)

Definition at line 236 of file class.ilCourseFile.php.

References $ilDB, $query, and $res.

Referenced by ilObjCourse\delete().

{
global $ilDB;
// delete all course ids and delete assigned files
$query = "DELETE FROM crs_file ".
"WHERE course_id = ".$ilDB->quote($a_course_id,'integer')."";
$res = $ilDB->manipulate($query);
return true;
}

+ Here is the caller graph for this function:

& ilCourseFile::_readFilesByCourse (   $a_course_id)

Definition at line 248 of file class.ilCourseFile.php.

References $ilDB, $query, $res, $row, and ilCourseFile().

Referenced by _cloneFiles(), ilObjCourseGUI\editInfoObject(), and ilObjCourseGUI\infoScreen().

{
global $ilDB;
$query = "SELECT * FROM crs_file ".
"WHERE course_id = ".$ilDB->quote($a_course_id,'integer')."";
$res = $ilDB->query($query);
while($row = $ilDB->fetchObject($res))
{
$files[] =& new ilCourseFile($row->file_id);
}
return is_array($files) ? $files : array();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseFile::create (   $a_upload = true)

Definition at line 186 of file class.ilCourseFile.php.

References $ilDB, $query, $res, getCourseId(), getErrorCode(), getFileId(), getFileName(), getFileSize(), getFileType(), getTemporaryName(), ilUtil\moveUploadedFile(), and setFileId().

{
global $ilDB;
if($this->getErrorCode() != 0)
{
return false;
}
$next_id = $ilDB->nextId('crs_file');
$query = "INSERT INTO crs_file (file_id,course_id,file_name,file_size,file_type) ".
"VALUES( ".
$ilDB->quote($next_id,'integer').", ".
$ilDB->quote($this->getCourseId(),'integer').", ".
$ilDB->quote($this->getFileName(),'text').", ".
$ilDB->quote($this->getFileSize(),'integer').", ".
$ilDB->quote($this->getFileType(),'text')." ".
")";
$res = $ilDB->manipulate($query);
$this->setFileId($next_id);
$this->fss_storage = new ilFSStorageCourse($this->getCourseId());
$this->fss_storage->initInfoDirectory();
if($a_upload)
{
// now create file
$this->getFileName(),
$this->fss_storage->getInfoDirectory().'/'.$this->getFileId());
}
return true;
}

+ Here is the call graph for this function:

ilCourseFile::delete ( )

Definition at line 221 of file class.ilCourseFile.php.

References $ilDB, $query, $res, getAbsolutePath(), and getFileId().

{
global $ilDB;
// Delete db entry
$query = "DELETE FROM crs_file ".
"WHERE file_id = ".$ilDB->quote($this->getFileId(),'integer')."";
$res = $ilDB->manipulate($query);
// Delete file
unlink($this->getAbsolutePath());
return true;
}

+ Here is the call graph for this function:

ilCourseFile::getAbsolutePath ( )

Definition at line 146 of file class.ilCourseFile.php.

References getFileId().

Referenced by delete().

{
if(is_object($this->fss_storage))
{
return $this->fss_storage->getInfoDirectory().'/'.$this->getFileId();
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseFile::getCourseId ( )

Definition at line 96 of file class.ilCourseFile.php.

References $course_id.

Referenced by __read(), and create().

{
}

+ Here is the caller graph for this function:

ilCourseFile::getErrorCode ( )

Definition at line 141 of file class.ilCourseFile.php.

Referenced by create(), and validate().

{
return $this->error_code;
}

+ Here is the caller graph for this function:

ilCourseFile::getFileId ( )

Definition at line 91 of file class.ilCourseFile.php.

References $file_id.

Referenced by create(), delete(), and getAbsolutePath().

{
}

+ Here is the caller graph for this function:

ilCourseFile::getFileName ( )

Definition at line 109 of file class.ilCourseFile.php.

Referenced by create().

{
return $this->file_name;
}

+ Here is the caller graph for this function:

ilCourseFile::getFileSize ( )

Definition at line 125 of file class.ilCourseFile.php.

Referenced by create().

{
return $this->file_size;
}

+ Here is the caller graph for this function:

ilCourseFile::getFileType ( )

Definition at line 117 of file class.ilCourseFile.php.

Referenced by create().

{
return $this->file_type;
}

+ Here is the caller graph for this function:

ilCourseFile::getTemporaryName ( )

Definition at line 133 of file class.ilCourseFile.php.

Referenced by create().

{
return $this->tmp_name;
}

+ Here is the caller graph for this function:

ilCourseFile::ilCourseFile (   $a_file_id = null)

Definition at line 47 of file class.ilCourseFile.php.

References $ilDB, $ilErr, $lng, and __read().

Referenced by _cloneFiles(), and _readFilesByCourse().

{
global $ilErr,$ilDB,$lng;
$this->ilErr =& $ilErr;
$this->db =& $ilDB;
$this->lng =& $lng;
$this->file_id = $a_file_id;
$this->__read();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCourseFile::setCourseId (   $a_course_id)

Definition at line 100 of file class.ilCourseFile.php.

Referenced by __read().

{
$this->course_id = $a_course_id;
}

+ Here is the caller graph for this function:

ilCourseFile::setErrorCode (   $a_code)

Definition at line 137 of file class.ilCourseFile.php.

{
$this->error_code = $a_code;
}
ilCourseFile::setFileId (   $a_id)

Definition at line 87 of file class.ilCourseFile.php.

Referenced by create().

{
$this->file_id = $a_id;
}

+ Here is the caller graph for this function:

ilCourseFile::setFileName (   $a_name)

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

Referenced by __read().

{
$this->file_name = $a_name;
}

+ Here is the caller graph for this function:

ilCourseFile::setFileSize (   $a_size)

Definition at line 121 of file class.ilCourseFile.php.

Referenced by __read().

{
$this->file_size = $a_size;
}

+ Here is the caller graph for this function:

ilCourseFile::setFileType (   $a_type)

Definition at line 113 of file class.ilCourseFile.php.

Referenced by __read().

{
$this->file_type = $a_type;
}

+ Here is the caller graph for this function:

ilCourseFile::setTemporaryName (   $a_name)

Definition at line 129 of file class.ilCourseFile.php.

{
$this->tmp_name = $a_name;
}
ilCourseFile::validate ( )

Definition at line 155 of file class.ilCourseFile.php.

References getErrorCode().

{
switch($this->getErrorCode())
{
case UPLOAD_ERR_INI_SIZE:
$this->ilErr->appendMessage($this->lng->txt('file_upload_ini_size'));
break;
case UPLOAD_ERR_FORM_SIZE:
$this->ilErr->appendMessage($this->lng->txt('file_upload_form_size'));
break;
case UPLOAD_ERR_PARTIAL:
$this->ilErr->appendMessage($this->lng->txt('file_upload_only_partial'));
break;
case UPLOAD_ERR_NO_TMP_DIR:
$this->ilErr->appendMessage($this->lng->txt('file_upload_no_tmp_dir'));
break;
// not possible with php 4
#case UPLOAD_ERR_CANT_WRITE:
# $this->ilErr->appendMessage($this->lng->txt('file_upload_no_write'));
# break;
case UPLOAD_ERR_OK:
case UPLOAD_ERR_NO_FILE:
default:
return true;
}
}

+ Here is the call graph for this function:

Field Documentation

ilCourseFile::$course_id = null

Definition at line 42 of file class.ilCourseFile.php.

Referenced by getCourseId().

ilCourseFile::$file_id = null

Definition at line 43 of file class.ilCourseFile.php.

Referenced by getFileId().

ilCourseFile::$fss_storage = null
private

Definition at line 45 of file class.ilCourseFile.php.

ilCourseFile::$ilDB
ilCourseFile::$ilErr

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

Referenced by ilCourseFile().

ilCourseFile::$lng

Definition at line 40 of file class.ilCourseFile.php.

Referenced by ilCourseFile().

ilCourseFile::$tree

Definition at line 39 of file class.ilCourseFile.php.


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