ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilFileDataGroup Class Reference
+ Inheritance diagram for ilFileDataGroup:
+ Collaboration diagram for ilFileDataGroup:

Public Member Functions

 ilFileDataGroup ($group_obj)
 Constructor call base constructors checks if directory is writable and sets the optional obj_id. More...
 
 createImportFile ($a_tmp_name, $a_name)
 
 unpackImportFile ()
 
 validateImportFile ()
 
 getImportFile ()
 
 getExportFile ($a_rel_name)
 
 getExportFiles ()
 
 deleteFile ($a_rel_name)
 
 deleteDirectory ($a_rel_dir)
 
 _deleteAll ($a_obj_id)
 
 addGroupDirectory ()
 
 addImportDirectory ()
 
 addDirectory ($a_rel_name)
 
 writeToFile ($a_data, $a_rel_name)
 
 zipFile ($a_rel_name, $a_zip_name)
 
 getGroupPath ()
 get exercise path @access public More...
 
 __checkPath ()
 
 __checkReadWrite ()
 check if directory is writable overwritten method from base class @access private More...
 
 __initDirectory ()
 init directory overwritten method @access public More...
 
- Public Member Functions inherited from ilFileData
 ilFileData ()
 Constructor class bas constructor and read path of directory from ilias.ini setup an mail object @access public. More...
 
 checkPath ($a_path)
 check if path exists and is writable More...
 
 getPath ()
 get Path @access public More...
 
- Public Member Functions inherited from ilFile
 ilFile ()
 Constructor get ilias object @access public. More...
 
 deleteTrailingSlash ($a_path)
 delete trailing slash of path variables More...
 

Data Fields

 $group_path
 
 $group_obj = null
 
- Data Fields inherited from ilFile
 $path
 
 $ilias
 

Detailed Description

Definition at line 16 of file class.ilFileDataGroup.php.

Member Function Documentation

◆ __checkPath()

ilFileDataGroup::__checkPath ( )

Definition at line 225 of file class.ilFileDataGroup.php.

226 {
227 if(!@file_exists($this->getGroupPath()))
228 {
229 return false;
230 }
231
232 $this->__checkReadWrite();
233
234 return true;
235 }
__checkReadWrite()
check if directory is writable overwritten method from base class @access private
getGroupPath()
get exercise path @access public

References __checkReadWrite(), and getGroupPath().

Referenced by ilFileDataGroup().

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

◆ __checkReadWrite()

ilFileDataGroup::__checkReadWrite ( )

check if directory is writable overwritten method from base class @access private

Returns
bool

Definition at line 243 of file class.ilFileDataGroup.php.

244 {
245 if(is_writable($this->group_path) && is_readable($this->group_path))
246 {
247 return true;
248 }
249 else
250 {
251 $this->ilias->raiseError("Group directory is not readable/writable by webserver",$this->ilias->error_obj->FATAL);
252 }
253 }
redirection script todo: (a better solution should control the processing via a xml file)

Referenced by __checkPath().

+ Here is the caller graph for this function:

◆ __initDirectory()

ilFileDataGroup::__initDirectory ( )

init directory overwritten method @access public

Returns
string path

Definition at line 260 of file class.ilFileDataGroup.php.

261 {
262 if(is_writable($this->getPath()))
263 {
264 ilUtil::makeDir($this->getPath().'/'.GROUP_PATH);
265 $this->group_path = $this->getPath().'/'.GROUP_PATH;
266
267 return true;
268 }
269 return false;
270 }
const GROUP_PATH
This class handles all operations of export files for the group object.
getPath()
get Path @access public
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...

References ilFileData\getPath(), GROUP_PATH, and ilUtil\makeDir().

Referenced by ilFileDataGroup().

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

◆ _deleteAll()

ilFileDataGroup::_deleteAll (   $a_obj_id)

Definition at line 152 of file class.ilFileDataGroup.php.

153 {
154 ilUtil::delDir(CLIENT_DATA_DIR.'/'.GROUP_PATH.'/grp_'.$a_obj_id);
155
156 return true;
157 }
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References ilUtil\delDir(), and GROUP_PATH.

+ Here is the call graph for this function:

◆ addDirectory()

ilFileDataGroup::addDirectory (   $a_rel_name)

Definition at line 182 of file class.ilFileDataGroup.php.

183 {
184 if(@file_exists($this->getGroupPath().'/grp_'.$this->group_obj->getId().'/'.$a_rel_name))
185 {
186 return false;
187 }
188 ilUtil::makeDir($this->getGroupPath().'/grp_'.$this->group_obj->getId().'/'.$a_rel_name);
189
190 return true;
191 }

References getGroupPath(), and ilUtil\makeDir().

+ Here is the call graph for this function:

◆ addGroupDirectory()

ilFileDataGroup::addGroupDirectory ( )

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

160 {
161 if(@file_exists($this->getGroupPath().'/grp_'.$this->group_obj->getId()))
162 {
163 return false;
164 }
165 ilUtil::makeDir($this->getGroupPath().'/grp_'.$this->group_obj->getId());
166
167 return true;
168 }

References getGroupPath(), and ilUtil\makeDir().

+ Here is the call graph for this function:

◆ addImportDirectory()

ilFileDataGroup::addImportDirectory ( )

Definition at line 170 of file class.ilFileDataGroup.php.

171 {
172 if(@file_exists($this->getGroupPath().'/import'))
173 {
174 return false;
175 }
176 ilUtil::makeDir($this->getGroupPath().'/import');
177
178 return true;
179 }

References getGroupPath(), and ilUtil\makeDir().

+ Here is the call graph for this function:

◆ createImportFile()

ilFileDataGroup::createImportFile (   $a_tmp_name,
  $a_name 
)

Definition at line 54 of file class.ilFileDataGroup.php.

55 {
56 ilUtil::moveUploadedFile($a_tmp_name,
57 $a_name,
58 $this->getGroupPath().'/import/'.$a_name);
59 $this->import_file_info = pathinfo($this->getGroupPath().'/import/'.$a_name);
60
61 }
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file

References getGroupPath(), and ilUtil\moveUploadedFile().

+ Here is the call graph for this function:

◆ deleteDirectory()

ilFileDataGroup::deleteDirectory (   $a_rel_dir)

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

141 {
142 if(!@file_exists($abs = $this->getGroupPath().'/grp_'.$this->group_obj->getId().'/'.$a_rel_dir))
143 {
144 return false;
145 }
146 ilUtil::delDir($abs);
147
148 return true;
149 }

References ilUtil\delDir(), and getGroupPath().

+ Here is the call graph for this function:

◆ deleteFile()

ilFileDataGroup::deleteFile (   $a_rel_name)

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

130 {
131 if(@file_exists($abs = $this->group_path.'/grp_'.$this->group_obj->getId().'/'.$a_rel_name))
132 {
133 @unlink($abs);
134
135 return true;
136 }
137 return false;
138 }

◆ getExportFile()

ilFileDataGroup::getExportFile (   $a_rel_name)

Definition at line 93 of file class.ilFileDataGroup.php.

94 {
95 if(@file_exists($abs = $this->group_path.'/grp_'.$this->group_obj->getId().'/'.$a_rel_name))
96 {
97 return $abs;
98 }
99 return false;
100 }

◆ getExportFiles()

ilFileDataGroup::getExportFiles ( )

Definition at line 102 of file class.ilFileDataGroup.php.

103 {
104 $path = $this->getGroupPath().'/grp_'.$this->group_obj->getId();
105
106
107 if(!@file_exists($path) or !is_readable($path))
108 {
109 return array();
110 }
111 $dp = dir($path);
112
113 // Get file
114 while($entry = $dp->read())
115 {
116 if ($entry != "." and
117 $entry != ".." and
118 substr($entry, -4) == ".zip" and
119 ereg("^[0-9]{10}_{2}[0-9]+_{2}(grp_)*[0-9]+\.zip\$", $entry))
120 {
121 $files[$entry] = array("file" => $entry,
122 "size" => filesize($path."/".$entry),
123 'type' => "XML");
124 }
125 }
126 return $files ? $files : array();
127 }

References ilFile\$path, and getGroupPath().

+ Here is the call graph for this function:

◆ getGroupPath()

ilFileDataGroup::getGroupPath ( )

get exercise path @access public

Returns
string path

Definition at line 218 of file class.ilFileDataGroup.php.

219 {
220 return $this->group_path;
221 }

References $group_path.

Referenced by __checkPath(), addDirectory(), addGroupDirectory(), addImportDirectory(), createImportFile(), deleteDirectory(), getExportFiles(), getImportFile(), unpackImportFile(), validateImportFile(), writeToFile(), and zipFile().

+ Here is the caller graph for this function:

◆ getImportFile()

ilFileDataGroup::getImportFile ( )

Definition at line 83 of file class.ilFileDataGroup.php.

84 {
85 return $this->getGroupPath().'/import'
86 .'/'.basename($this->import_file_info['basename'],'.zip')
87 .'/'.basename($this->import_file_info['basename'],'.zip').'.xml';
88 }

References getGroupPath().

+ Here is the call graph for this function:

◆ ilFileDataGroup()

ilFileDataGroup::ilFileDataGroup (   $group_obj)

Constructor call base constructors checks if directory is writable and sets the optional obj_id.

Parameters
integeregerobj_id @access public

Definition at line 34 of file class.ilFileDataGroup.php.

35 {
36 global $ilias;
37
38 parent::ilFileData();
39
40 $this->ilias =& $ilias;
41 $this->group_path = parent::getPath()."/".GROUP_PATH;
42 $this->group_obj =& $group_obj;
43
44 // IF DIRECTORY ISN'T CREATED CREATE IT
45 if(!$this->__checkPath())
46 {
47 $this->__initDirectory();
48 }
49 // Check import dir
50 #$this->__checkImportPath();
51 }
__initDirectory()
init directory overwritten method @access public

References $group_obj, ilFile\$ilias, __checkPath(), __initDirectory(), and GROUP_PATH.

+ Here is the call graph for this function:

◆ unpackImportFile()

ilFileDataGroup::unpackImportFile ( )

Definition at line 63 of file class.ilFileDataGroup.php.

64 {
65 return ilUtil::unzip($this->getGroupPath().'/import/'.$this->import_file_info['basename']);
66 }
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file

References getGroupPath(), and ilUtil\unzip().

+ Here is the call graph for this function:

◆ validateImportFile()

ilFileDataGroup::validateImportFile ( )

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

69 {
70 if(!is_dir($this->getGroupPath().'/import/'.basename($this->import_file_info['basename'],'.zip')))
71 {
72 return false;
73 }
74 if(!file_exists($this->getGroupPath().'/import'.
75 '/'.basename($this->import_file_info['basename'],'.zip').
76 '/'.basename($this->import_file_info['basename'],'.zip').'.xml'))
77 {
78 return false;
79 }
80 return true;
81 }

References getGroupPath().

+ Here is the call graph for this function:

◆ writeToFile()

ilFileDataGroup::writeToFile (   $a_data,
  $a_rel_name 
)

Definition at line 193 of file class.ilFileDataGroup.php.

194 {
195 if(!$fp = @fopen($this->getGroupPath().'/grp_'.$this->group_obj->getId().'/'.$a_rel_name,'w+'))
196 {
197 die("Cannot open file: ".$this->getGroupPath().'/'.$a_rel_name);
198 }
199 @fwrite($fp,$a_data);
200
201 return true;
202 }

References getGroupPath().

+ Here is the call graph for this function:

◆ zipFile()

ilFileDataGroup::zipFile (   $a_rel_name,
  $a_zip_name 
)

Definition at line 204 of file class.ilFileDataGroup.php.

205 {
206 ilUtil::zip($this->getGroupPath().'/grp_'.$this->group_obj->getId().'/'.$a_rel_name,
207 $this->getGroupPath().'/grp_'.$this->group_obj->getId().'/'.$a_zip_name);
208
209 return true;
210 }
static zip($a_dir, $a_file, $compress_content=false)

References getGroupPath(), and ilUtil\zip().

+ Here is the call graph for this function:

Field Documentation

◆ $group_obj

ilFileDataGroup::$group_obj = null

Definition at line 25 of file class.ilFileDataGroup.php.

Referenced by ilFileDataGroup().

◆ $group_path

ilFileDataGroup::$group_path

Definition at line 23 of file class.ilFileDataGroup.php.

Referenced by getGroupPath().


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