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

Public Member Functions

 __construct ()
 Constructor. More...
 
 getId ()
 Get id.
Returns
string
More...
 
 getTitle ()
 Get title.
Returns
string
More...
 
 getDescription ()
 Get description.
Returns
string
More...
 
 getDefaultScheduleType ()
 Get schedule type.
Returns
int
More...
 
 getDefaultScheduleValue ()
 Get schedule value.
Returns
int|array
More...
 
 hasAutoActivation ()
 Is to be activated on "installation".
Returns
boolean
More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured?
Returns
boolean
More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited?
Returns
boolean
More...
 
 run ()
 Run job.
Returns
ilCronJobResult
More...
 
 recalculate ()
 Recalculate. More...
 
 quotaHandleFile ($a_obj_id, $a_owner_id)
 
 quotaHandleMob ($a_obj_id, $a_owner_id)
 
 quotaHandleFileStorage ($a_type, $a_obj_id, $a_owner_id, $a_dir)
 
 quotaHandleVerification ($a_type, $a_obj_id, $a_owner_id)
 
- Public Member Functions inherited from ilCronJob
 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active? More...
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule ($a_type, $a_value)
 Update current schedule (if flexible) More...
 
 getValidScheduleTypes ()
 Get all available schedule types. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually. More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 Run job. More...
 

Protected Attributes

 $lng
 
 $db
 
 $job_status
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 
const SCHEDULE_TYPE_IN_HOURS = 3
 
const SCHEDULE_TYPE_IN_DAYS = 4
 
const SCHEDULE_TYPE_WEEKLY = 5
 
const SCHEDULE_TYPE_MONTHLY = 6
 
const SCHEDULE_TYPE_QUARTERLY = 7
 
const SCHEDULE_TYPE_YEARLY = 8
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCronPersonalWorkspaceRecalculateQuota::__construct ( )

Constructor.

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

35 {
36 global $DIC;
37
38 $this->lng = $DIC->language();
39 $ilDB = $DIC->database();
40
41 $this->db = $ilDB;
42 }
global $DIC
Definition: saml.php:7
global $ilDB

References $DIC, and $ilDB.

Member Function Documentation

◆ getDefaultScheduleType()

ilCronPersonalWorkspaceRecalculateQuota::getDefaultScheduleType ( )

Get schedule type.

Returns
int

Reimplemented from ilCronJob.

Definition at line 76 of file class.ilCronPersonalWorkspaceRecalculateQuota.php.

77 {
79 }
const SCHEDULE_TYPE_DAILY

References ilCronJob\SCHEDULE_TYPE_DAILY.

◆ getDefaultScheduleValue()

ilCronPersonalWorkspaceRecalculateQuota::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

Reimplemented from ilCronJob.

Definition at line 84 of file class.ilCronPersonalWorkspaceRecalculateQuota.php.

85 {
86 return;
87 }

◆ getDescription()

ilCronPersonalWorkspaceRecalculateQuota::getDescription ( )

Get description.

Returns
string

Reimplemented from ilCronJob.

Definition at line 66 of file class.ilCronPersonalWorkspaceRecalculateQuota.php.

67 {
69
70 return $lng->txt("pwsp_recalculate_disk_quota_desc");
71 }

References $lng.

◆ getId()

ilCronPersonalWorkspaceRecalculateQuota::getId ( )

Get id.

Returns
string

Reimplemented from ilCronJob.

Definition at line 48 of file class.ilCronPersonalWorkspaceRecalculateQuota.php.

49 {
50 return "pwsp_recalc_quota";
51 }

◆ getTitle()

ilCronPersonalWorkspaceRecalculateQuota::getTitle ( )

Get title.

Returns
string

Reimplemented from ilCronJob.

Definition at line 56 of file class.ilCronPersonalWorkspaceRecalculateQuota.php.

57 {
59
60 return $lng->txt("pwsp_recalculate_disk_quota");
61 }

References $lng.

◆ hasAutoActivation()

ilCronPersonalWorkspaceRecalculateQuota::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

Reimplemented from ilCronJob.

Definition at line 92 of file class.ilCronPersonalWorkspaceRecalculateQuota.php.

93 {
94 return false;
95 }

◆ hasCustomSettings()

ilCronPersonalWorkspaceRecalculateQuota::hasCustomSettings ( )

Has cron job any custom setting which can be edited?

Returns
boolean

Reimplemented from ilCronJob.

Definition at line 108 of file class.ilCronPersonalWorkspaceRecalculateQuota.php.

109 {
110 return true;
111 }

◆ hasFlexibleSchedule()

ilCronPersonalWorkspaceRecalculateQuota::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

Reimplemented from ilCronJob.

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

101 {
102 return true;
103 }

◆ quotaHandleFile()

ilCronPersonalWorkspaceRecalculateQuota::quotaHandleFile (   $a_obj_id,
  $a_owner_id 
)
Parameters
int$a_obj_id
int$a_owner_id

Definition at line 294 of file class.ilCronPersonalWorkspaceRecalculateQuota.php.

295 {
297
298 // see ilFileSystemStorage::_createPathFromId()
299 $tpath = array();
300 $tfound = false;
301 $tnum = $a_obj_id;
302 for ($i = 3; $i > 0; $i--) {
303 $factor = pow(100, $i);
304 if (($tmp = (int) ($tnum / $factor)) or $tfound) {
305 $tpath[] = $tmp;
306 $tnum = $tnum % $factor;
307 $tfound = true;
308 }
309 }
310
311 $file_path = ilUtil::getDataDir() . "/ilFile/";
312 if (count($tpath)) {
313 $file_path .= (implode('/', $tpath) . '/');
314 }
315 $file_path .= "file_" . $a_obj_id;
316 if (file_exists($file_path)) {
317 $file_size = (int) ilUtil::dirsize($file_path);
318 if ($file_size > 0) {
319 $ilDB->manipulate("INSERT INTO il_disk_quota" .
320 " (owner_id, src_type, src_obj_id, src_size)" .
321 " VALUES (" . $ilDB->quote($a_owner_id, "integer") .
322 ", " . $ilDB->quote("file", "text") .
323 ", " . $ilDB->quote($a_obj_id, "integer") .
324 ", " . $ilDB->quote($file_size, "integer") . ")");
325 }
326 }
327 }
static getDataDir()
get data directory (outside webspace)
static dirsize($directory)
get size of a directory or a file.
$i
Definition: disco.tpl.php:19

References $db, $i, $ilDB, ilUtil\dirsize(), and ilUtil\getDataDir().

Referenced by recalculate().

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

◆ quotaHandleFileStorage()

ilCronPersonalWorkspaceRecalculateQuota::quotaHandleFileStorage (   $a_type,
  $a_obj_id,
  $a_owner_id,
  $a_dir 
)
Parameters
string$a_type
int$a_obj_id
int$a_owner_id
string$a_dir

Definition at line 357 of file class.ilCronPersonalWorkspaceRecalculateQuota.php.

358 {
360
361 // see ilFileSystemStorage::_createPathFromId()
362 $tpath = array();
363 $tfound = false;
364 $tnum = $a_obj_id;
365 for ($i = 3; $i > 0; $i--) {
366 $factor = pow(100, $i);
367 if (($tmp = (int) ($tnum / $factor)) or $tfound) {
368 $tpath[] = $tmp;
369 $tnum = $tnum % $factor;
370 $tfound = true;
371 }
372 }
373
374 $file_path = CLIENT_WEB_DIR . "/" . $a_dir . "/";
375 if (count($tpath)) {
376 $file_path .= (implode('/', $tpath) . '/');
377 }
378 $file_path .= $a_type . "_" . $a_obj_id;
379
380 if (file_exists($file_path)) {
381 $file_size = (int) ilUtil::dirsize($file_path);
382 if ($file_size > 0) {
383 $ilDB->manipulate("INSERT INTO il_disk_quota" .
384 " (owner_id, src_type, src_obj_id, src_size)" .
385 " VALUES (" . $ilDB->quote($a_owner_id, "integer") .
386 ", " . $ilDB->quote($a_type, "text") .
387 ", " . $ilDB->quote($a_obj_id, "integer") .
388 ", " . $ilDB->quote($file_size, "integer") . ")");
389 }
390 }
391 }
$a_type
Definition: workflow.php:92

References $a_type, $db, $i, $ilDB, and ilUtil\dirsize().

Referenced by recalculate().

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

◆ quotaHandleMob()

ilCronPersonalWorkspaceRecalculateQuota::quotaHandleMob (   $a_obj_id,
  $a_owner_id 
)
Parameters
int$a_obj_id
int$a_owner_id

Definition at line 333 of file class.ilCronPersonalWorkspaceRecalculateQuota.php.

334 {
336
337 $file_path = CLIENT_WEB_DIR . "/mobs/mm_" . $a_obj_id;
338 if (file_exists($file_path)) {
339 $file_size = (int) ilUtil::dirsize($file_path);
340 if ($file_size > 0) {
341 $ilDB->manipulate("INSERT INTO il_disk_quota" .
342 " (owner_id, src_type, src_obj_id, src_size)" .
343 " VALUES (" . $ilDB->quote($a_owner_id, "integer") .
344 ", " . $ilDB->quote("mob", "text") .
345 ", " . $ilDB->quote($a_obj_id, "integer") .
346 ", " . $ilDB->quote($file_size, "integer") . ")");
347 }
348 }
349 }

References $db, $ilDB, and ilUtil\dirsize().

Referenced by recalculate().

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

◆ quotaHandleVerification()

ilCronPersonalWorkspaceRecalculateQuota::quotaHandleVerification (   $a_type,
  $a_obj_id,
  $a_owner_id 
)
Parameters
strin$a_type
int$a_obj_id
int$a_owner_id

Definition at line 398 of file class.ilCronPersonalWorkspaceRecalculateQuota.php.

399 {
401
402 // see ilFileSystemStorage::_createPathFromId()
403 $tpath = array();
404 $tfound = false;
405 $tnum = $a_obj_id;
406 for ($i = 3; $i > 0;$i--) {
407 $factor = pow(100, $i);
408 if (($tmp = (int) ($tnum / $factor)) or $tfound) {
409 $tpath[] = $tmp;
410 $tnum = $tnum % $factor;
411 $tfound = true;
412 }
413 }
414
415 $file_path = ilUtil::getDataDir() . "/ilVerification/";
416 if (count($tpath)) {
417 $file_path .= (implode('/', $tpath) . '/');
418 }
419 $file_path .= "vrfc_" . $a_obj_id;
420 if (file_exists($file_path)) {
421 $file_size = (int) ilUtil::dirsize($file_path);
422 if ($file_size > 0) {
423 $ilDB->manipulate("INSERT INTO il_disk_quota" .
424 " (owner_id, src_type, src_obj_id, src_size)" .
425 " VALUES (" . $ilDB->quote($a_owner_id, "integer") .
426 ", " . $ilDB->quote($a_type, "text") .
427 ", " . $ilDB->quote($a_obj_id, "integer") .
428 ", " . $ilDB->quote($file_size, "integer") . ")");
429 }
430 }
431 }

References $a_type, $db, $i, $ilDB, ilUtil\dirsize(), and ilUtil\getDataDir().

Referenced by recalculate().

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

◆ recalculate()

ilCronPersonalWorkspaceRecalculateQuota::recalculate ( )

Recalculate.

Definition at line 132 of file class.ilCronPersonalWorkspaceRecalculateQuota.php.

133 {
135
136 //
137 // Files (workspace, blogs and portfolios)
138 //
139
140 $ilDB->manipulate("DELETE FROM il_disk_quota" .
141 " WHERE src_type = " . $ilDB->quote("file", "text"));
142
143 $quota_done = array();
144
145 // get all workspace files
146 $set = $ilDB->query("SELECT od.owner, od.obj_id" .
147 " FROM object_data od" .
148 " JOIN object_reference_ws ref ON (ref.obj_id = od.obj_id)" .
149 " JOIN tree_workspace t ON (t.child = ref.wsp_id)" .
150 " WHERE od.type = " . $ilDB->quote("file", "text") .
151 " AND t.tree = od.owner");
152 while ($row = $ilDB->fetchAssoc($set)) {
153 $id = $row["owner"] . "-" . $row["obj_id"];
154 if (!in_array($id, $quota_done)) {
155 $this->quotaHandleFile($row["obj_id"], $row["owner"]);
156 $quota_done[] = $id;
157 }
158 }
159
160 // get all file usage for workspace blogs
161 $set = $ilDB->query("SELECT od.owner, fu.id" .
162 " FROM object_data od" .
163 " JOIN object_reference_ws ref ON (ref.obj_id = od.obj_id)" .
164 " JOIN tree_workspace t ON (t.child = ref.wsp_id)" .
165 " JOIN il_blog_posting blp ON (blp.blog_id = od.obj_id)" .
166 " JOIN file_usage fu ON (fu.usage_id = blp.id)" .
167 " WHERE fu.usage_type = " . $ilDB->quote("blp:pg", "text") .
168 " AND fu.usage_hist_nr = " . $ilDB->quote(0, "integer"));
169 while ($row = $ilDB->fetchAssoc($set)) {
170 $id = $row["owner"] . "-" . $row["id"];
171 if (!in_array($id, $quota_done)) {
172 $this->quotaHandleFile($row["id"], $row["owner"]);
173 $quota_done[] = $id;
174 }
175 }
176
177 // get all file usage for portfolios
178 $set = $ilDB->query($q = "SELECT od.owner, fu.id" .
179 " FROM object_data od" .
180 " JOIN usr_portfolio_page prtf ON (prtf.portfolio_id = od.obj_id)" .
181 " JOIN file_usage fu ON (fu.usage_id = prtf.id)" .
182 " WHERE fu.usage_type = " . $ilDB->quote("prtf:pg", "text") .
183 " AND fu.usage_hist_nr = " . $ilDB->quote(0, "integer"));
184
185 while ($row = $ilDB->fetchAssoc($set)) {
186 $id = $row["owner"] . "-" . $row["id"];
187 if (!in_array($id, $quota_done)) {
188 $this->quotaHandleFile($row["id"], $row["owner"]);
189 $quota_done[] = $id;
190 }
191 }
192
193
194 //
195 // Media objects (blogs and portfolios)
196 //
197
198 $ilDB->manipulate("DELETE FROM il_disk_quota" .
199 " WHERE src_type = " . $ilDB->quote("mob", "text"));
200
201 $quota_done = array();
202
203 // get all mob usage for workspace blogs
204 $set = $ilDB->query("SELECT od.owner, mu.id" .
205 " FROM object_data od" .
206 " JOIN object_reference_ws ref ON (ref.obj_id = od.obj_id)" .
207 " JOIN tree_workspace t ON (t.child = ref.wsp_id)" .
208 " JOIN il_blog_posting blp ON (blp.blog_id = od.obj_id)" .
209 " JOIN mob_usage mu ON (mu.usage_id = blp.id)" .
210 " WHERE mu.usage_type = " . $ilDB->quote("blp:pg", "text") .
211 " AND mu.usage_hist_nr = " . $ilDB->quote(0, "integer"));
212 while ($row = $ilDB->fetchAssoc($set)) {
213 $id = $row["owner"] . "-" . $row["id"];
214 if (!in_array($id, $quota_done)) {
215 $this->quotaHandleMob($row["id"], $row["owner"]);
216 $quota_done[] = $id;
217 }
218 }
219
220 // get all mob usage for portfolios
221 $set = $ilDB->query("SELECT od.owner, mu.id" .
222 " FROM object_data od" .
223 " JOIN usr_portfolio_page prtf ON (prtf.portfolio_id = od.obj_id)" .
224 " JOIN mob_usage mu ON (mu.usage_id = prtf.id)" .
225 " WHERE mu.usage_type = " . $ilDB->quote("prtf:pg", "text") .
226 " AND mu.usage_hist_nr = " . $ilDB->quote(0, "integer"));
227 while ($row = $ilDB->fetchAssoc($set)) {
228 $id = $row["owner"] . "-" . $row["id"];
229 if (!in_array($id, $quota_done)) {
230 $this->quotaHandleMob($row["id"], $row["owner"]);
231 $quota_done[] = $id;
232 }
233 }
234
235 //
236 // Portfolio / Blog images
237 //
238
239 $ilDB->manipulate("DELETE FROM il_disk_quota" .
240 " WHERE src_type = " . $ilDB->quote("prtf", "text"));
241 $ilDB->manipulate("DELETE FROM il_disk_quota" .
242 " WHERE src_type = " . $ilDB->quote("blog", "text"));
243
244 // portfolios
245 $set = $ilDB->query("SELECT od.owner, od.obj_id" .
246 " FROM object_data od" .
247 " JOIN usr_portfolio prtf ON (prtf.id = od.obj_id)" .
248 " WHERE od.type = " . $ilDB->quote("prtf", "text") .
249 " AND prtf.img IS NOT NULL");
250 while ($row = $ilDB->fetchAssoc($set)) {
251 $this->quotaHandleFileStorage("prtf", $row["obj_id"], $row["owner"], "sec/ilPortfolio");
252 }
253
254 // (workspace) blogs
255 $set = $ilDB->query("SELECT od.owner, od.obj_id" .
256 " FROM object_data od" .
257 " JOIN object_reference_ws ref ON (ref.obj_id = od.obj_id)" .
258 " JOIN tree_workspace t ON (t.child = ref.wsp_id)" .
259 " JOIN il_blog blog ON (blog.id = od.obj_id)" .
260 " WHERE od.type = " . $ilDB->quote("blog", "text") .
261 " AND blog.img IS NOT NULL" .
262 " AND t.tree = od.owner");
263 while ($row = $ilDB->fetchAssoc($set)) {
264 $this->quotaHandleFileStorage("blog", $row["obj_id"], $row["owner"], "sec/ilBlog");
265 }
266
267 return;
268
269 //
270 // Verifications
271 //
272
273 $ilDB->manipulate("DELETE FROM il_disk_quota" .
274 " WHERE src_type = " . $ilDB->quote("tstv", "text"));
275 $ilDB->manipulate("DELETE FROM il_disk_quota" .
276 " WHERE src_type = " . $ilDB->quote("excv", "text"));
277
278 // (workspace) verifications
279 $set = $ilDB->query("SELECT od.owner, od.obj_id, od.type" .
280 " FROM object_data od" .
281 " JOIN object_reference_ws ref ON (ref.obj_id = od.obj_id)" .
282 " JOIN tree_workspace t ON (t.child = ref.wsp_id)" .
283 " WHERE " . $ilDB->in("od.type", array("tstv", "excv"), "", "text") .
284 " AND t.tree = od.owner");
285 while ($row = $ilDB->fetchAssoc($set)) {
286 $this->quotaHandleVerification($row["type"], $row["obj_id"], $row["owner"]);
287 }
288 }
if(!array_key_exists('StateId', $_REQUEST)) $id

References $db, $id, $ilDB, $row, quotaHandleFile(), quotaHandleFileStorage(), quotaHandleMob(), and quotaHandleVerification().

Referenced by run().

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

◆ run()

ilCronPersonalWorkspaceRecalculateQuota::run ( )

Run job.

Returns
ilCronJobResult

Reimplemented from ilCronJob.

Definition at line 116 of file class.ilCronPersonalWorkspaceRecalculateQuota.php.

117 {
118 $this->job_status = ilCronJobResult::STATUS_NO_ACTION;
119
120 $this->recalculate();
121
122 $this->job_status = ilCronJobResult::STATUS_OK;
123
124 $result = new ilCronJobResult();
125 $result->setStatus($this->job_status);
126 return $result;
127 }
$result
Cron job result data container.

References $result, recalculate(), ilCronJobResult\STATUS_NO_ACTION, and ilCronJobResult\STATUS_OK.

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilCronPersonalWorkspaceRecalculateQuota::$db
protected

◆ $job_status

ilCronPersonalWorkspaceRecalculateQuota::$job_status
protected

◆ $lng

ilCronPersonalWorkspaceRecalculateQuota::$lng
protected

Definition at line 19 of file class.ilCronPersonalWorkspaceRecalculateQuota.php.

Referenced by getDescription(), and getTitle().


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