ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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)

Protected Member Functions

 loadUnits ()
 clearUnits ()
 addUnit ($unit)

Protected Attributes

 $consumer_id = 0
 $lng

Private Attributes

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

Detailed Description

Member Function Documentation

ilUnitConfigurationRepository::addUnit (   $unit)
protected

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

Referenced by loadUnits().

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

+ Here is the caller graph for this function:

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

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

References $ilDB, and $result.

Referenced by deleteUnit().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_var WHERE unit_fi = %s",
array('integer'),
array($id)
);
if($result->numRows() > 0)
{
return $this->lng->txt("err_unit_in_variables");
}
$result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_res WHERE unit_fi = %s",
array('integer'),
array($id)
);
if($result->numRows() > 0)
{
return $this->lng->txt("err_unit_in_results");
}
if(!is_null($category_id))
{
$result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_unit WHERE baseunit_fi = %s AND category_fi != %s",
array('integer', 'integer', 'integer'),
array($id, $id, $category_id)
);
}
else
{
$result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_unit WHERE baseunit_fi = %s AND unit_id != %s",
array('integer', 'integer'),
array($id, $id)
);
}
if($result->numRows() > 0)
{
return $this->lng->txt("err_unit_is_baseunit");
}
return null;
}

+ Here is the caller graph for this function:

ilUnitConfigurationRepository::clearUnits ( )
protected

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

Referenced by deleteUnit().

{
$this->units = array();
}

+ Here is the caller graph for this function:

ilUnitConfigurationRepository::deleteUnit (   $id)

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

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

{
global $ilDB;
$res = $this->checkDeleteUnit($id);
if(!is_null($res)) return $res;
$affectedRows = $ilDB->manipulateF("DELETE FROM il_qpl_qst_fq_unit WHERE unit_id = %s",
array('integer'),
array($id)
);
if($affectedRows > 0) $this->clearUnits();
return null;
}

+ Here is the call graph for this function:

ilUnitConfigurationRepository::getAdminUnitCategories ( )

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

References $ilDB, and $result.

{
global $ilDB;
$categories = array();
$result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_ucat WHERE question_fi = %s ORDER BY category",
array('integer'), array(0));
if($result->numRows())
{
while($row = $ilDB->fetchAssoc($result))
{
$value = (strcmp("-qpl_qst_formulaquestion_" . $row["category"] . "-", $this->lng->txt($row["category"])) == 0) ? $row["category"] : $this->lng->txt($row["category"]);
if(strlen(trim($row["category"])))
{
$cat = array(
"value" => $row["category_id"],
"text" => $value,
"qst_id" => $row['question_fi']
);
$categories[$row["category_id"]] = $cat;
}
}
}
return $categories;
}
ilUnitConfigurationRepository::getCategorizedUnits ( )

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

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

{
global $ilDB;
if(count($this->categorizedUnits) == 0)
{
$result = $ilDB->queryF("
SELECT units.*, il_qpl_qst_fq_ucat.category, il_qpl_qst_fq_ucat.question_fi, baseunits.unit baseunit_title
FROM il_qpl_qst_fq_unit units
INNER JOIN il_qpl_qst_fq_ucat ON il_qpl_qst_fq_ucat.category_id = units.category_fi
LEFT JOIN il_qpl_qst_fq_unit baseunits ON baseunits.unit_id = units.baseunit_fi
WHERE units.question_fi = %s
ORDER BY il_qpl_qst_fq_ucat.category, units.sequence",
array('integer'), array($this->getConsumerId()));
if($result->numRows())
{
$category = '';
while($row = $ilDB->fetchAssoc($result))
{
$unit = new assFormulaQuestionUnit();
$unit->initFormArray($row);
if(strcmp($category, $unit->getCategory()) != 0)
{
$cat->initFormArray(array(
'category_id' => $row['category_fi'],
'category' => $row['category'],
'question_fi' => $row['question_fi'],
));
array_push($this->categorizedUnits, $cat);
$category = $unit->getCategory();
}
array_push($this->categorizedUnits, $unit);
}
}
}
}

+ Here is the call graph for this function:

ilUnitConfigurationRepository::getCategoryUnitCount (   $id)

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

References $ilDB, and $result.

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_unit WHERE category_fi = %s",
array('integer'),
array($id)
);
return $result->numRows();
}
ilUnitConfigurationRepository::getConsumerId ( )
Returns
int

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

References $consumer_id.

Referenced by getCategorizedUnits().

{
}

+ Here is the caller graph for this function:

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

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

References loadUnits().

{
if(count($this->units) == 0)
{
$this->loadUnits();
}
if(array_key_exists($id, $this->units))
{
return $this->units[$id];
}
else
{
//maybee this is a new unit ...
// reload $this->units
$this->loadUnits();
if(array_key_exists($id, $this->units))
{
return $this->units[$id];
}
}
return null;
}

+ Here is the call graph for this function:

ilUnitConfigurationRepository::getUnitCategories ( )

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

References $ilDB, and $result.

{
global $ilDB;
$categories = array();
$result = $ilDB->queryF("SELECT * FROM il_qpl_qst_fq_ucat WHERE question_fi > %s ORDER BY category",
array('integer'), array(0));
if($result->numRows())
{
while($row = $ilDB->fetchAssoc($result))
{
$value = (strcmp("-qpl_qst_formulaquestion_" . $row["category"] . "-", $this->lng->txt($row["category"])) == 0) ? $row["category"] : $this->lng->txt($row["category"]);
if(strlen(trim($row["category"])))
{
$cat = array(
"value" => $row["category_id"],
"text" => $value,
"qst_id" => $row['question_fi']
);
$categories[$row["category_id"]] = $cat;
}
}
}
return $categories;
}
ilUnitConfigurationRepository::getUnits ( )

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

References $units, and loadUnits().

{
if(count($this->units) == 0)
{
$this->loadUnits();
}
return $this->units;
}

+ Here is the call graph for this function:

ilUnitConfigurationRepository::isUnitInUse (   $id)

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

References $ilDB.

{
global $ilDB;
$result_1 = $ilDB->queryF("SELECT unit_fi FROM il_qpl_qst_fq_res_unit WHERE unit_fi = %s",
array('integer'),
array($id)
);
$result_2 = $ilDB->queryF("SELECT unit_fi FROM il_qpl_qst_fq_var WHERE unit_fi = %s",
array('integer'),
array($id)
);
$result_3 = $ilDB->queryF("SELECT unit_fi FROM il_qpl_qst_fq_res WHERE unit_fi = %s",
array('integer'),
array($id)
);
$cnt_1 = $ilDB->numRows($result_1);
$cnt_2 = $ilDB->numRows($result_2);
$cnt_3 = $ilDB->numRows($result_3);
if($cnt_1 || $cnt_2 || $cnt_3)
{
return true;
}
else
{
return false;
}
}
ilUnitConfigurationRepository::loadUnits ( )
protected

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

References $ilDB, $result, and addUnit().

Referenced by getUnit(), and getUnits().

{
global $ilDB;
$result = $ilDB->query("
SELECT units.*, il_qpl_qst_fq_ucat.category, baseunits.unit baseunit_title
FROM il_qpl_qst_fq_unit units
INNER JOIN il_qpl_qst_fq_ucat ON il_qpl_qst_fq_ucat.category_id = units.category_fi
LEFT JOIN il_qpl_qst_fq_unit baseunits ON baseunits.unit_id = units.baseunit_fi
ORDER BY il_qpl_qst_fq_ucat.category, units.sequence"
);
if($result->numRows())
{
while($row = $ilDB->fetchAssoc($result))
{
$unit = new assFormulaQuestionUnit();
$unit->initFormArray($row);
$this->addUnit($unit);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilUnitConfigurationRepository::loadUnitsForCategory (   $category)

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

References $ilDB, $result, and $units.

{
global $ilDB;
$units = array();
$result = $ilDB->queryF("
SELECT units.*, baseunits.unit baseunit_title
FROM il_qpl_qst_fq_unit units
INNER JOIN il_qpl_qst_fq_ucat ON il_qpl_qst_fq_ucat.category_id = units.category_fi
LEFT JOIN il_qpl_qst_fq_unit baseunits ON baseunits.unit_id = units.baseunit_fi
WHERE il_qpl_qst_fq_ucat.category_id = %s
ORDER BY units.sequence",
array('integer'),
array($category)
);
if($result->numRows())
{
while($row = $ilDB->fetchAssoc($result))
{
$unit = new assFormulaQuestionUnit();
$unit->initFormArray($row);
array_push($units, $unit);
}
}
return $units;
}
ilUnitConfigurationRepository::setConsumerId (   $consumer_id)
Parameters
int$context_id

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

References $consumer_id.

{
$this->consumer_id = $consumer_id;
}

Field Documentation

ilUnitConfigurationRepository::$categorizedUnits = array()
private

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

Referenced by getCategorizedUnits().

ilUnitConfigurationRepository::$consumer_id = 0
protected

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

Referenced by getConsumerId(), and setConsumerId().

ilUnitConfigurationRepository::$lng
protected

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

ilUnitConfigurationRepository::$units = array()
private

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

Referenced by getUnits(), and loadUnitsForCategory().


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