Public Member Functions | |
ilObjCourseGrouping ($a_id=0) | |
Constructor public. | |
setId ($a_id) | |
getId () | |
setCourseRefId ($a_ref_id) | |
getCourseRefId () | |
setCourseObjId ($a_obj_id) | |
getCourseObjId () | |
setType ($a_type) | |
getType () | |
setTitle ($a_title) | |
getTitle () | |
setDescription ($a_desc) | |
getDescription () | |
setUniqueField ($a_uni) | |
getUniqueField () | |
getCountAssignedCourses () | |
getAssignedCourses () | |
delete () | |
create ($a_course_ref_id, $a_course_id) | |
update () | |
isAssigned ($a_course_id) | |
read () | |
_getAllGroupings ($a_crs_ref_id, $a_check_write=true) | |
assign ($a_crs_ref_id, $a_course_id) | |
deassign ($a_crs_ref_id, $a_course_id) | |
__addCondition ($a_target_ref_id, $a_target_obj_id) | |
_deleteAll ($a_course_id) | |
_getGroupings ($a_course_id) | |
_isInGrouping ($a_crs_id) | |
_checkCondition ($trigger_obj_id, $operator, $value) | |
Data Fields | |
$db |
Definition at line 36 of file class.ilObjCourseGrouping.php.
ilObjCourseGrouping::__addCondition | ( | $ | a_target_ref_id, | |
$ | a_target_obj_id | |||
) |
Definition at line 317 of file class.ilObjCourseGrouping.php.
References getId(), and getUniqueField().
Referenced by assign().
{ include_once './classes/class.ilConditionHandler.php'; $tmp_condh =& new ilConditionHandler(); $tmp_condh->enableAutomaticValidation(false); $tmp_condh->setTargetRefId($a_target_ref_id); $tmp_condh->setTargetObjId($a_target_obj_id); $tmp_condh->setTargetType('crs'); $tmp_condh->setTriggerRefId(0); $tmp_condh->setTriggerObjId($this->getId()); $tmp_condh->setTriggerType('crsg'); $tmp_condh->setOperator('not_member'); $tmp_condh->setValue($this->getUniqueField()); if(!$tmp_condh->checkExists()) { $tmp_condh->storeCondition(); return true; } return false; }
ilObjCourseGrouping::_checkCondition | ( | $ | trigger_obj_id, | |
$ | operator, | |||
$ | value | |||
) |
Definition at line 393 of file class.ilObjCourseGrouping.php.
{ // in the moment i alway return true, there are some problems with presenting the condition if it fails, // only course register class check manually if this condition is fullfilled return true; }
ilObjCourseGrouping::_deleteAll | ( | $ | a_course_id | ) |
Definition at line 343 of file class.ilObjCourseGrouping.php.
References $query, and _getGroupings().
Referenced by ilObjCourse::delete().
{ global $ilDB; // DELETE CONDITIONS foreach($groupings = ilObjCourseGrouping::_getGroupings($a_course_id) as $grouping_id) { include_once './classes/class.ilConditionHandler.php'; $condh =& new ilConditionHandler(); $condh->deleteByObjId($grouping_id); } $query = "DELETE FROM crs_groupings ". "WHERE crs_id = '".$a_course_id."'"; $ilDB->query($query); return true; }
ilObjCourseGrouping::_getAllGroupings | ( | $ | a_crs_ref_id, | |
$ | a_check_write = true | |||
) |
Definition at line 257 of file class.ilObjCourseGrouping.php.
References _getGroupings(), and ilUtil::getObjectsByOperations().
Referenced by ilObjCourseGUI::listGroupingsObject(), ilObjCourseGroupingGUI::otherAssign(), and ilObjCourseGroupingGUI::otherSelectAssign().
{ if($a_check_write) { $courses = ilUtil::getObjectsByOperations('crs','write',false); } else { $courses = ilUtil::getObjectsByOperations('crs','visible',false); } $groupings = array(); foreach($courses as $crs_data) { if($a_crs_ref_id != $crs_data['ref_id']) { $groupings = array_merge($groupings,ilObjCourseGrouping::_getGroupings($crs_data['obj_id'])); } } return $groupings ? $groupings : array(); }
ilObjCourseGrouping::_getGroupings | ( | $ | a_course_id | ) |
Definition at line 364 of file class.ilObjCourseGrouping.php.
References $query, $res, and $row.
Referenced by _deleteAll(), _getAllGroupings(), and ilObjCourseGUI::listGroupingsObject().
{ global $ilDB; $query = "SELECT * FROM crs_groupings ". "WHERE crs_id = '".$a_course_id."'"; $res = $ilDB->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $groupings[] = $row->crs_grp_id; } return $groupings ? $groupings : array(); }
ilObjCourseGrouping::_isInGrouping | ( | $ | a_crs_id | ) |
Definition at line 379 of file class.ilObjCourseGrouping.php.
References ilConditionHandler::_getConditionsOfTarget().
{ include_once './classes/class.ilConditionHandler.php'; foreach(ilConditionHandler::_getConditionsOfTarget($a_crs_id,'crs') as $cond) { if($cond['operator'] == 'not_member') { return true; } } return false; }
ilObjCourseGrouping::assign | ( | $ | a_crs_ref_id, | |
$ | a_course_id | |||
) |
Definition at line 279 of file class.ilObjCourseGrouping.php.
References __addCondition(), getCourseObjId(), and getCourseRefId().
{ // Add the parent course of grouping $this->__addCondition($this->getCourseRefId(),$this->getCourseObjId()); $this->__addCondition($a_crs_ref_id,$a_course_id); return true; }
ilObjCourseGrouping::create | ( | $ | a_course_ref_id, | |
$ | a_course_id | |||
) |
Definition at line 153 of file class.ilObjCourseGrouping.php.
References $ilUser, $query, $res, $row, getDescription(), getId(), getTitle(), ilUtil::prepareDBString(), and setId().
{ global $ilUser; // INSERT IN object_data $query = "INSERT INTO object_data ". "(type,title,description,owner,create_date,last_update,import_id) ". "VALUES ". "('".$this->type."',".$this->db->quote($this->getTitle()).",'".ilUtil::prepareDBString($this->getDescription())."',". "'".$ilUser->getId()."',now(),now(),'')"; $this->db->query($query); // READ this id $query = "SELECT LAST_INSERT_ID() as last"; $res = $this->db->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $this->setId($row->last); } // INSERT in crs_groupings $query = "INSERT INTO crs_groupings ". "SET crs_ref_id = '".$a_course_ref_id."', ". "crs_id = '".$a_course_id."',". "crs_grp_id = '".$this->getId()."', ". "unique_field = '".$this->getUniqueField()."'"; $this->db->query($query); return $this->getId(); }
ilObjCourseGrouping::deassign | ( | $ | a_crs_ref_id, | |
$ | a_course_id | |||
) |
Definition at line 288 of file class.ilObjCourseGrouping.php.
References ilConditionHandler::_getConditionsOfTrigger(), getCountAssignedCourses(), and getId().
{ include_once './classes/class.ilConditionHandler.php'; $condh =& new ilConditionHandler(); // DELETE also original course if its the last if($this->getCountAssignedCourses() == 2) { $condh->deleteByObjId($this->getId()); return true; } foreach(ilConditionHandler::_getConditionsOfTrigger('crsg',$this->getId()) as $cond_data) { if($cond_data['target_ref_id'] == $a_crs_ref_id and $cond_data['target_obj_id'] == $a_course_id) { $condh->deleteCondition($cond_data['id']); } } return true; }
ilObjCourseGrouping::delete | ( | ) |
Definition at line 131 of file class.ilObjCourseGrouping.php.
References $query, getId(), and getType().
{ include_once './classes/class.ilConditionHandler.php'; if($this->getId() and $this->getType() === 'crsg') { $query = "DELETE FROM object_data WHERE obj_id = '".$this->getId()."'"; $this->db->query($query); $query = "DELETE FROM crs_groupings ". "WHERE crs_grp_id = '".$this->getId()."'"; $this->db->query($query); // Delete conditions $condh =& new ilConditionHandler(); $condh->deleteByObjId($this->getId()); return true; } return false; }
ilObjCourseGrouping::getAssignedCourses | ( | ) |
Definition at line 123 of file class.ilObjCourseGrouping.php.
References ilConditionHandler::_getConditionsOfTrigger(), getId(), and getType().
Referenced by getCountAssignedCourses(), and isAssigned().
{ include_once './classes/class.ilConditionHandler.php'; return ilConditionHandler::_getConditionsOfTrigger($this->getType(),$this->getId()); }
ilObjCourseGrouping::getCountAssignedCourses | ( | ) |
Definition at line 118 of file class.ilObjCourseGrouping.php.
References getAssignedCourses().
Referenced by deassign().
{ return count($this->getAssignedCourses()); }
ilObjCourseGrouping::getCourseObjId | ( | ) |
Definition at line 80 of file class.ilObjCourseGrouping.php.
Referenced by assign().
{
return $this->obj_id;
}
ilObjCourseGrouping::getCourseRefId | ( | ) |
Definition at line 72 of file class.ilObjCourseGrouping.php.
Referenced by assign().
{
return $this->ref_id;
}
ilObjCourseGrouping::getDescription | ( | ) |
Definition at line 105 of file class.ilObjCourseGrouping.php.
Referenced by create(), and update().
{
return $this->description;
}
ilObjCourseGrouping::getId | ( | ) |
Definition at line 64 of file class.ilObjCourseGrouping.php.
Referenced by __addCondition(), create(), deassign(), delete(), getAssignedCourses(), and update().
{
return $this->id;
}
ilObjCourseGrouping::getTitle | ( | ) |
Definition at line 97 of file class.ilObjCourseGrouping.php.
Referenced by create(), and update().
{
return $this->title;
}
ilObjCourseGrouping::getType | ( | ) |
Definition at line 88 of file class.ilObjCourseGrouping.php.
Referenced by delete(), getAssignedCourses(), and update().
{
return $this->type;
}
ilObjCourseGrouping::getUniqueField | ( | ) |
Definition at line 113 of file class.ilObjCourseGrouping.php.
Referenced by __addCondition().
{
return $this->unique_field;
}
ilObjCourseGrouping::ilObjCourseGrouping | ( | $ | a_id = 0 |
) |
Constructor public.
integer | reference_id or object_id | |
boolean | treat the id as reference_id (true) or object_id (false) |
Definition at line 46 of file class.ilObjCourseGrouping.php.
References read(), setId(), and setType().
{ global $ilDB; $this->setType('crsg'); $this->db =& $ilDB; $this->setId($a_id); if($a_id) { $this->read(); } }
ilObjCourseGrouping::isAssigned | ( | $ | a_course_id | ) |
Definition at line 219 of file class.ilObjCourseGrouping.php.
References getAssignedCourses().
{ foreach($this->getAssignedCourses() as $condition_data) { if($a_course_id == $condition_data['target_obj_id']) { return true; } } return false; }
ilObjCourseGrouping::read | ( | ) |
Definition at line 231 of file class.ilObjCourseGrouping.php.
References $query, $res, $row, setCourseObjId(), setCourseRefId(), setDescription(), setTitle(), and setUniqueField().
Referenced by ilObjCourseGrouping().
{ $query = "SELECT * FROM object_data ". "WHERE obj_id = '".$this->getId()."'"; $res = $this->db->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $this->setTitle($row->title); $this->setDescription($row->description); } $query = "SELECT * FROM crs_groupings ". "WHERE crs_grp_id = '".$this->getId()."'"; $res = $this->db->query($query); while($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $this->setUniqueField($row->unique_field); $this->setCourseRefId($row->crs_ref_id); $this->setCourseObjId($row->crs_id); } return true; }
ilObjCourseGrouping::setCourseObjId | ( | $ | a_obj_id | ) |
Definition at line 76 of file class.ilObjCourseGrouping.php.
Referenced by read().
{ $this->obj_id = $a_obj_id; }
ilObjCourseGrouping::setCourseRefId | ( | $ | a_ref_id | ) |
Definition at line 68 of file class.ilObjCourseGrouping.php.
Referenced by read().
{ $this->ref_id = $a_ref_id; }
ilObjCourseGrouping::setDescription | ( | $ | a_desc | ) |
Definition at line 101 of file class.ilObjCourseGrouping.php.
Referenced by read().
{ $this->description = $a_desc; }
ilObjCourseGrouping::setId | ( | $ | a_id | ) |
Definition at line 60 of file class.ilObjCourseGrouping.php.
Referenced by create(), and ilObjCourseGrouping().
{
$this->id = $a_id;
}
ilObjCourseGrouping::setTitle | ( | $ | a_title | ) |
Definition at line 93 of file class.ilObjCourseGrouping.php.
Referenced by read().
{ $this->title = $a_title; }
ilObjCourseGrouping::setType | ( | $ | a_type | ) |
Definition at line 84 of file class.ilObjCourseGrouping.php.
Referenced by ilObjCourseGrouping().
{ $this->type = $a_type; }
ilObjCourseGrouping::setUniqueField | ( | $ | a_uni | ) |
Definition at line 109 of file class.ilObjCourseGrouping.php.
Referenced by read().
{ $this->unique_field = $a_uni; }
ilObjCourseGrouping::update | ( | ) |
Definition at line 187 of file class.ilObjCourseGrouping.php.
References $query, getDescription(), getId(), getTitle(), and getType().
{ if($this->getId() and $this->getType() === 'crsg') { // UPDATe object_data $query = "UPDATE object_data ". "SET title = '".ilUtil::prepareDBString($this->getTitle())."', ". "description = '".ilUtil::prepareDBString($this->getDescription())."' ". "WHERE obj_id = '".$this->getId()."' ". "AND type = '".$this->getType()."'"; $this->db->query($query); // UPDATE crs_groupings $query = "UPDATE crs_groupings ". "SET unique_field = '".$this->getUniqueField()."' ". "WHERE crs_grp_id = '".$this->getId()."'"; $this->db->query($query); // UPDATE conditions $query = "UPDATE conditions ". "SET value = '".$this->getUniqueField()."' ". "WHERE trigger_obj_id = '".$this->getId()."' ". "AND trigger_type = 'crsg'"; $this->db->query($query); return true; } return false; }
ilObjCourseGrouping::$db |
Definition at line 38 of file class.ilObjCourseGrouping.php.