ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilUnitConfigurationRepository Class Reference

Class ilUnitConfigurationRepository. More...

+ Collaboration diagram for ilUnitConfigurationRepository:

Public Member Functions

 setConsumerId ($consumer_id)
 
 getConsumerId ()
 
 getCategoryUnitCount ($id)
 
 isUnitInUse ($id)
 
 deleteUnit ($id)
 
 getCategorizedUnits ()
 
 getUnits ()
 
 loadUnitsForCategory ($category)
 
 getUnit ($id)
 
 getUnitCategories ()
 
 getAdminUnitCategories ()
 
 checkDeleteUnit ($id, $category_id=null)
 

Static Public Attributes

static $result_buffer
 

Protected Member Functions

 loadUnits ()
 
 clearUnits ()
 
 addUnit ($unit)
 

Protected Attributes

 $consumer_id = 0
 
 $lng
 

Private Attributes

 $units = array()
 
 $categorizedUnits = array()
 

Detailed Description

Member Function Documentation

◆ addUnit()

ilUnitConfigurationRepository::addUnit (   $unit)
protected

Definition at line 379 of file class.ilUnitConfigurationRepository.php.

380 {
381 $this->units[$unit->getId()] = $unit;
382 }

Referenced by loadUnits().

+ Here is the caller graph for this function:

◆ checkDeleteUnit()

ilUnitConfigurationRepository::checkDeleteUnit (   $id,
  $category_id = null 
)

Definition at line 524 of file class.ilUnitConfigurationRepository.php.

525 {
526 global $DIC;
527 $ilDB = $DIC['ilDB'];
528
529 $result = $ilDB->queryF(
530 "SELECT * FROM il_qpl_qst_fq_var WHERE unit_fi = %s",
531 array('integer'),
532 array($id)
533 );
534 if ($result->numRows() > 0) {
535 return $this->lng->txt("err_unit_in_variables");
536 }
537 $result = $ilDB->queryF(
538 "SELECT * FROM il_qpl_qst_fq_res WHERE unit_fi = %s",
539 array('integer'),
540 array($id)
541 );
542 if ($result->numRows() > 0) {
543 return $this->lng->txt("err_unit_in_results");
544 }
545 if (!is_null($category_id)) {
546 $result = $ilDB->queryF(
547 "SELECT * FROM il_qpl_qst_fq_unit WHERE baseunit_fi = %s AND category_fi != %s",
548 array('integer', 'integer', 'integer'),
549 array($id, $id, $category_id)
550 );
551 } else {
552 $result = $ilDB->queryF(
553 "SELECT * FROM il_qpl_qst_fq_unit WHERE baseunit_fi = %s AND unit_id != %s",
554 array('integer', 'integer'),
555 array($id, $id)
556 );
557 }
558 if ($result->numRows() > 0) {
559 return $this->lng->txt("err_unit_is_baseunit");
560 }
561 return null;
562 }
$result
if(!array_key_exists('StateId', $_REQUEST)) $id
global $DIC
Definition: saml.php:7
global $ilDB

References $DIC, $id, $ilDB, and $result.

Referenced by deleteUnit().

+ Here is the caller graph for this function:

◆ clearUnits()

ilUnitConfigurationRepository::clearUnits ( )
protected

Definition at line 373 of file class.ilUnitConfigurationRepository.php.

374 {
375 $this->units = array();
376 self::$result_buffer = null;
377 }

Referenced by deleteUnit().

+ Here is the caller graph for this function:

◆ deleteUnit()

ilUnitConfigurationRepository::deleteUnit (   $id)

Definition at line 281 of file class.ilUnitConfigurationRepository.php.

282 {
283 global $DIC;
284 $ilDB = $DIC['ilDB'];
285
286 $res = $this->checkDeleteUnit($id);
287 if (!is_null($res)) {
288 return $res;
289 }
290 $affectedRows = $ilDB->manipulateF(
291 "DELETE FROM il_qpl_qst_fq_unit WHERE unit_id = %s",
292 array('integer'),
293 array($id)
294 );
295 if ($affectedRows > 0) {
296 $this->clearUnits();
297 }
298 self::$result_buffer = null;
299 return null;
300 }
foreach($_POST as $key=> $value) $res

References $DIC, $id, $ilDB, $res, checkDeleteUnit(), and clearUnits().

+ Here is the call graph for this function:

◆ getAdminUnitCategories()

ilUnitConfigurationRepository::getAdminUnitCategories ( )

Definition at line 471 of file class.ilUnitConfigurationRepository.php.

472 {
473 global $DIC;
474 $ilDB = $DIC['ilDB'];
475
476 $categories = array();
477 $result = $ilDB->queryF(
478 "SELECT * FROM il_qpl_qst_fq_ucat WHERE question_fi = %s ORDER BY category",
479 array('integer'),
480 array(0)
481 );
482 if ($result->numRows()) {
483 while ($row = $ilDB->fetchAssoc($result)) {
484 $value = (strcmp("-qpl_qst_formulaquestion_" . $row["category"] . "-", $this->lng->txt($row["category"])) == 0) ? $row["category"] : $this->lng->txt($row["category"]);
485
486 if (strlen(trim($row["category"]))) {
487 $cat = array(
488 "value" => $row["category_id"],
489 "text" => $value,
490 "qst_id" => $row['question_fi']
491 );
492 $categories[$row["category_id"]] = $cat;
493 }
494 }
495 }
496
497 return $categories;
498 }
$row

References $DIC, $ilDB, $result, and $row.

◆ getCategorizedUnits()

ilUnitConfigurationRepository::getCategorizedUnits ( )

Definition at line 332 of file class.ilUnitConfigurationRepository.php.

333 {
334 global $DIC;
335 $ilDB = $DIC['ilDB'];
336
337 if (count($this->categorizedUnits) == 0) {
338 $result = $ilDB->queryF(
339 "
340 SELECT units.*, il_qpl_qst_fq_ucat.category, il_qpl_qst_fq_ucat.question_fi, baseunits.unit baseunit_title
341 FROM il_qpl_qst_fq_unit units
342 INNER JOIN il_qpl_qst_fq_ucat ON il_qpl_qst_fq_ucat.category_id = units.category_fi
343 LEFT JOIN il_qpl_qst_fq_unit baseunits ON baseunits.unit_id = units.baseunit_fi
344 WHERE units.question_fi = %s
345 ORDER BY il_qpl_qst_fq_ucat.category, units.sequence",
346 array('integer'),
347 array($this->getConsumerId())
348 );
349
350 if ($result->numRows()) {
351 $category = '';
352 while ($row = $ilDB->fetchAssoc($result)) {
353 $unit = new assFormulaQuestionUnit();
354 $unit->initFormArray($row);
355 if (strcmp($category, $unit->getCategory()) != 0) {
357 $cat->initFormArray(array(
358 'category_id' => $row['category_fi'],
359 'category' => $row['category'],
360 'question_fi' => $row['question_fi'],
361 ));
362 array_push($this->categorizedUnits, $cat);
363 $category = $unit->getCategory();
364 }
365 array_push($this->categorizedUnits, $unit);
366 }
367 }
368 }
369
371 }

References $categorizedUnits, $DIC, $ilDB, $result, $row, and getConsumerId().

+ Here is the call graph for this function:

◆ getCategoryUnitCount()

ilUnitConfigurationRepository::getCategoryUnitCount (   $id)

Definition at line 207 of file class.ilUnitConfigurationRepository.php.

208 {
209 global $DIC;
210 $ilDB = $DIC['ilDB'];
211
212 $result = $ilDB->queryF(
213 "SELECT * FROM il_qpl_qst_fq_unit WHERE category_fi = %s",
214 array('integer'),
215 array($id)
216 );
217 return $result->numRows();
218 }

References $DIC, $id, $ilDB, and $result.

◆ getConsumerId()

ilUnitConfigurationRepository::getConsumerId ( )
Returns
int

Definition at line 58 of file class.ilUnitConfigurationRepository.php.

References $consumer_id.

Referenced by getCategorizedUnits().

+ Here is the caller graph for this function:

◆ getUnit()

ilUnitConfigurationRepository::getUnit (   $id)
Parameters
int$id
Returns
assFormulaQuestionUnit

Definition at line 423 of file class.ilUnitConfigurationRepository.php.

424 {
425 if (count($this->units) == 0) {
426 $this->loadUnits();
427 }
428 if (array_key_exists($id, $this->units)) {
429 return $this->units[$id];
430 } else {
431 //maybee this is a new unit ...
432 // reload $this->units
433
434 $this->loadUnits();
435 if (array_key_exists($id, $this->units)) {
436 return $this->units[$id];
437 }
438 }
439 return null;
440 }

References $id, and loadUnits().

+ Here is the call graph for this function:

◆ getUnitCategories()

ilUnitConfigurationRepository::getUnitCategories ( )

Definition at line 443 of file class.ilUnitConfigurationRepository.php.

444 {
445 global $DIC;
446 $ilDB = $DIC['ilDB'];
447
448 $categories = array();
449 $result = $ilDB->queryF(
450 "SELECT * FROM il_qpl_qst_fq_ucat WHERE question_fi > %s ORDER BY category",
451 array('integer'),
452 array(0)
453 );
454 if ($result->numRows()) {
455 while ($row = $ilDB->fetchAssoc($result)) {
456 $value = (strcmp("-qpl_qst_formulaquestion_" . $row["category"] . "-", $this->lng->txt($row["category"])) == 0) ? $row["category"] : $this->lng->txt($row["category"]);
457
458 if (strlen(trim($row["category"]))) {
459 $cat = array(
460 "value" => $row["category_id"],
461 "text" => $value,
462 "qst_id" => $row['question_fi']
463 );
464 $categories[$row["category_id"]] = $cat;
465 }
466 }
467 }
468 return $categories;
469 }

References $DIC, $ilDB, $result, and $row.

◆ getUnits()

ilUnitConfigurationRepository::getUnits ( )

Definition at line 384 of file class.ilUnitConfigurationRepository.php.

385 {
386 if (count($this->units) == 0) {
387 $this->loadUnits();
388 }
389 return $this->units;
390 }

References $units, and loadUnits().

+ Here is the call graph for this function:

◆ isUnitInUse()

ilUnitConfigurationRepository::isUnitInUse (   $id)

Definition at line 220 of file class.ilUnitConfigurationRepository.php.

221 {
222 global $DIC;
223 $ilDB = $DIC['ilDB'];
224
225 $result_1 = $ilDB->queryF(
226 "SELECT unit_fi FROM il_qpl_qst_fq_res_unit WHERE unit_fi = %s",
227 array('integer'),
228 array($id)
229 );
230
231 $result_2 = $ilDB->queryF(
232 "SELECT unit_fi FROM il_qpl_qst_fq_var WHERE unit_fi = %s",
233 array('integer'),
234 array($id)
235 );
236 $result_3 = $ilDB->queryF(
237 "SELECT unit_fi FROM il_qpl_qst_fq_res WHERE unit_fi = %s",
238 array('integer'),
239 array($id)
240 );
241
242 $cnt_1 = $ilDB->numRows($result_1);
243 $cnt_2 = $ilDB->numRows($result_2);
244 $cnt_3 = $ilDB->numRows($result_3);
245
246 if ($cnt_1 || $cnt_2 || $cnt_3) {
247 return true;
248 } else {
249 return false;
250 }
251 }

References $DIC, $id, and $ilDB.

◆ loadUnits()

ilUnitConfigurationRepository::loadUnits ( )
protected

Definition at line 304 of file class.ilUnitConfigurationRepository.php.

305 {
306 global $DIC;
307 $ilDB = $DIC['ilDB'];
308
309 if (self::$result_buffer == null) {
310 $result = $ilDB->query(
311 "
312 SELECT units.*, il_qpl_qst_fq_ucat.category, baseunits.unit baseunit_title
313 FROM il_qpl_qst_fq_unit units
314 INNER JOIN il_qpl_qst_fq_ucat ON il_qpl_qst_fq_ucat.category_id = units.category_fi
315 LEFT JOIN il_qpl_qst_fq_unit baseunits ON baseunits.unit_id = units.baseunit_fi
316 ORDER BY il_qpl_qst_fq_ucat.category, units.sequence"
317 );
318
319
320 if ($result->numRows()) {
321 while ($row = $ilDB->fetchAssoc($result)) {
322 $unit = new assFormulaQuestionUnit();
323 $unit->initFormArray($row);
324 $this->addUnit($unit);
325 }
326 }
327 self::$result_buffer = $this->units;
328 }
329 $this->units = self::$result_buffer;
330 }

References $DIC, $ilDB, $result, $result_buffer, $row, $units, and addUnit().

Referenced by getUnit(), and getUnits().

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

◆ loadUnitsForCategory()

ilUnitConfigurationRepository::loadUnitsForCategory (   $category)

Definition at line 392 of file class.ilUnitConfigurationRepository.php.

393 {
394 global $DIC;
395 $ilDB = $DIC['ilDB'];
396
397 $units = array();
398 $result = $ilDB->queryF(
399 "
400 SELECT units.*, baseunits.unit baseunit_title
401 FROM il_qpl_qst_fq_unit units
402 INNER JOIN il_qpl_qst_fq_ucat ON il_qpl_qst_fq_ucat.category_id = units.category_fi
403 LEFT JOIN il_qpl_qst_fq_unit baseunits ON baseunits.unit_id = units.baseunit_fi
404 WHERE il_qpl_qst_fq_ucat.category_id = %s
405 ORDER BY units.sequence",
406 array('integer'),
407 array($category)
408 );
409 if ($result->numRows()) {
410 while ($row = $ilDB->fetchAssoc($result)) {
411 $unit = new assFormulaQuestionUnit();
412 $unit->initFormArray($row);
413 array_push($units, $unit);
414 }
415 }
416 return $units;
417 }

References $DIC, $ilDB, $result, $row, and $units.

◆ setConsumerId()

ilUnitConfigurationRepository::setConsumerId (   $consumer_id)
Parameters
int$context_id

Definition at line 50 of file class.ilUnitConfigurationRepository.php.

51 {
52 $this->consumer_id = $consumer_id;
53 }

References $consumer_id.

Field Documentation

◆ $categorizedUnits

ilUnitConfigurationRepository::$categorizedUnits = array()
private

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

Referenced by getCategorizedUnits().

◆ $consumer_id

ilUnitConfigurationRepository::$consumer_id = 0
protected

Definition at line 15 of file class.ilUnitConfigurationRepository.php.

Referenced by getConsumerId(), and setConsumerId().

◆ $lng

ilUnitConfigurationRepository::$lng
protected

Definition at line 20 of file class.ilUnitConfigurationRepository.php.

◆ $result_buffer

ilUnitConfigurationRepository::$result_buffer
static

Definition at line 302 of file class.ilUnitConfigurationRepository.php.

Referenced by loadUnits().

◆ $units

ilUnitConfigurationRepository::$units = array()
private

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