Class ilObj<module_name> More...
Public Member Functions | |
| ilObjCourseGrouping ($a_id=0) | |
| Constructor public. | |
| setId ($a_id) | |
| getId () | |
| setContainerRefId ($a_ref_id) | |
| getContainerRefId () | |
| setContainerObjId ($a_obj_id) | |
| getContainerObjId () | |
| getContainerType () | |
| setContainerType ($a_type) | |
| setType ($a_type) | |
| getType () | |
| setTitle ($a_title) | |
| getTitle () | |
| setDescription ($a_desc) | |
| getDescription () | |
| setUniqueField ($a_uni) | |
| getUniqueField () | |
| getCountAssignedItems () | |
| getAssignedItems () | |
| delete () | |
| create ($a_course_ref_id, $a_course_id) | |
| update () | |
| isAssigned ($a_course_id) | |
| read () | |
| _checkAccess ($grouping_id) | |
| _getVisibleGroupings ($a_obj_id) | |
| Returns a list of all groupings for which the current user hast write permission on all assigned objects. | |
| 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) | |
| _checkCondition ($trigger_obj_id, $operator, $value) | |
| _getGroupingCourseIds ($a_course_ref_id, $a_course_id) | |
| Get all ids of courses that are grouped with another course static. | |
| _checkGroupingDependencies (&$container_obj) | |
| _getGroupingItemsAsString (&$container_obj) | |
Data Fields | |
| $db | |
Class ilObj<module_name>
Definition at line 34 of file class.ilObjCourseGrouping.php.
| ilObjCourseGrouping::__addCondition | ( | $ | a_target_ref_id, | |
| $ | a_target_obj_id | |||
| ) |
Definition at line 392 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;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjCourseGrouping::_checkAccess | ( | $ | grouping_id | ) |
Definition at line 282 of file class.ilObjCourseGrouping.php.
References ilObjCourseGrouping().
Referenced by ilObjCourseGroupingGUI::listGroupings().
{
global $ilAccess,$tree;
$tmp_grouping_obj = new ilObjCourseGrouping($grouping_id);
$found_invisible = false;
foreach($tmp_grouping_obj->getAssignedItems() as $condition)
{
if(!$ilAccess->checkAccess('write','',$condition['target_ref_id']))
{
$found_invisible = true;
break;
}
}
return $found_invisible ? false : true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjCourseGrouping::_checkCondition | ( | $ | trigger_obj_id, | |
| $ | operator, | |||
| $ | value | |||
| ) |
Definition at line 454 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::_checkGroupingDependencies | ( | &$ | container_obj | ) |
Definition at line 493 of file class.ilObjCourseGrouping.php.
References $lng, ilConditionHandler::_getConditionsOfTarget(), ilConditionHandler::_getConditionsOfTrigger(), ilCourseParticipants::_getInstanceByObjId(), and ilObjGroup::_isMember().
Referenced by ilCourseRegisterGUI::__validateStatus(), and ilRegisterGUI::showRegistrationForm().
{
global $ilUser,$lng,$tree;
include_once './classes/class.ilConditionHandler.php';
$trigger_ids = array();
foreach(ilConditionHandler::_getConditionsOfTarget($container_obj->getRefId(),
$container_obj->getId(),
$container_obj->getType()) as $condition)
{
if($condition['operator'] == 'not_member')
{
$trigger_ids[] = $condition['trigger_obj_id'];
break;
}
}
if(!count($trigger_ids))
{
return true;
}
$matriculation_message = $assigned_message = '';
foreach($trigger_ids as $trigger_id)
{
foreach(ilConditionHandler::_getConditionsOfTrigger('crsg',$trigger_id) as $condition)
{
// Handle deleted items
if($tree->isDeleted($condition['target_ref_id']))
{
continue;
}
if($condition['operator'] == 'not_member')
{
switch($condition['value'])
{
case 'matriculation':
if(!strlen($ilUser->getMatriculation()))
{
if(!$matriculation_message)
{
$matriculation_message = $lng->txt('crs_grp_matriculation_required');
}
}
}
if($container_obj->getType() == 'crs')
{
include_once('Modules/Course/classes/class.ilCourseParticipants.php');
$members = ilCourseParticipants::_getInstanceByObjId($condition['target_obj_id']);
if($members->isGroupingMember($ilUser->getId(),$condition['value']))
{
if(!$assigned_message)
{
$assigned_message = $lng->txt('crs_grp_already_assigned');
}
}
}
else
{
if(ilObjGroup::_isMember($ilUser->getId(),$condition['target_ref_id'],$condition['value']))
{
if(!$assigned_message)
{
$assigned_message = $lng->txt('crs_grp_already_assigned');
}
}
}
}
}
}
if($matriculation_message)
{
$container_obj->appendMessage($matriculation_message);
return false;
}
elseif($assigned_message)
{
$container_obj->appendMessage($assigned_message);
return false;
}
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjCourseGrouping::_deleteAll | ( | $ | a_course_id | ) |
Definition at line 418 of file class.ilObjCourseGrouping.php.
References _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 = ".$ilDB->quote($a_course_id)." ";
$ilDB->query($query);
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjCourseGrouping::_getGroupingCourseIds | ( | $ | a_course_ref_id, | |
| $ | a_course_id | |||
| ) |
Get all ids of courses that are grouped with another course static.
| integer | object_id of one course | |
| array | integer ids of courses or empty array if course is not in grouping |
Definition at line 468 of file class.ilObjCourseGrouping.php.
References ilConditionHandler::_getConditionsOfTarget(), and ilConditionHandler::_getConditionsOfTrigger().
Referenced by ilObjCourseGUI::__showWaitingList().
{
global $tree;
include_once './classes/class.ilConditionHandler.php';
// get all grouping ids the course is assigned to
foreach(ilConditionHandler::_getConditionsOfTarget($a_course_ref_id,$a_course_id,'crs') as $condition)
{
if($condition['trigger_type'] == 'crsg')
{
foreach(ilConditionHandler::_getConditionsOfTrigger('crsg',$condition['trigger_obj_id']) as $target_condition)
{
if($tree->isDeleted($target_condition['target_ref_id']))
{
continue;
}
$course_ids[] = array('id' => $target_condition['target_obj_id'],
'unique' => $target_condition['value']);
}
}
}
return $course_ids ? $course_ids : array();
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjCourseGrouping::_getGroupingItemsAsString | ( | &$ | container_obj | ) |
Definition at line 576 of file class.ilObjCourseGrouping.php.
References ilConditionHandler::_getConditionsOfTarget(), and ilConditionHandler::_getConditionsOfTrigger().
Referenced by ilCourseRegisterGUI::showRegistrationForm(), and ilRegisterGUI::showRegistrationForm().
{
global $tree,$ilObjDataCache,$ilAccess,$tree;
include_once './classes/class.ilConditionHandler.php';
$trigger_ids = array();
foreach(ilConditionHandler::_getConditionsOfTarget($container_obj->getRefId(),
$container_obj->getId(),
$container_obj->getType()) as $condition)
{
if($condition['operator'] == 'not_member')
{
$trigger_ids[] = $condition['trigger_obj_id'];
}
}
if(!count($trigger_ids))
{
return false;
}
$hash_table = array();
foreach($trigger_ids as $trigger_id)
{
foreach(ilConditionHandler::_getConditionsOfTrigger('crsg',$trigger_id) as $condition)
{
// Continue if trigger is deleted
if($tree->isDeleted($condition['target_ref_id']))
{
continue;
}
if($condition['operator'] == 'not_member')
{
if(!$hash_table[$condition['target_ref_id']])
{
$courses .= (' <br/>'.$ilObjDataCache->lookupTitle($condition['target_obj_id']));
}
$hash_table[$condition['target_ref_id']] = true;
}
}
}
return $courses;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjCourseGrouping::_getGroupings | ( | $ | a_course_id | ) |
Definition at line 439 of file class.ilObjCourseGrouping.php.
References $res.
Referenced by _deleteAll().
{
global $ilDB;
$query = "SELECT * FROM crs_groupings ".
"WHERE crs_id = ".$ilDB->quote($a_course_id)." ";
$res = $ilDB->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$groupings[] = $row->crs_grp_id;
}
return $groupings ? $groupings : array();
}
Here is the caller graph for this function:| ilObjCourseGrouping::_getVisibleGroupings | ( | $ | a_obj_id | ) |
Returns a list of all groupings for which the current user hast write permission on all assigned objects.
Or groupings the given object id is assigned to.
Definition at line 305 of file class.ilObjCourseGrouping.php.
References $res, and ilObjCourseGrouping().
Referenced by ilObjCourseGroupingGUI::listGroupings().
{
global $ilObjDataCache,$ilAccess,$ilDB;
$container_type = $ilObjDataCache->lookupType($a_obj_id) == 'grp' ? 'grp' : 'crs';
// First get all groupings
$query = "SELECT * FROM object_data WHERE type = 'crsg' ORDER BY title";
$res = $ilDB->query($query);
$groupings = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$groupings[] = $row->obj_id;
}
//check access
foreach($groupings as $grouping_id)
{
$tmp_grouping_obj = new ilObjCourseGrouping($grouping_id);
// Check container type
if($tmp_grouping_obj->getContainerType() != $container_type)
{
continue;
}
// Check if container is current container
if($tmp_grouping_obj->getContainerObjId() == $a_obj_id)
{
$visible_groupings[] = $grouping_id;
continue;
}
// check if items are assigned
if(count($items = $tmp_grouping_obj->getAssignedItems()))
{
foreach($items as $condition_data)
{
if($ilAccess->checkAccess('write','',$condition_data['target_ref_id']))
{
$visible_groupings[] = $grouping_id;
break;
}
}
}
}
return $visible_groupings ? $visible_groupings : array();
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjCourseGrouping::assign | ( | $ | a_crs_ref_id, | |
| $ | a_course_id | |||
| ) |
Definition at line 354 of file class.ilObjCourseGrouping.php.
References __addCondition(), getContainerObjId(), and getContainerRefId().
{
// Add the parent course of grouping
$this->__addCondition($this->getContainerRefId(),$this->getContainerObjId());
$this->__addCondition($a_crs_ref_id,$a_course_id);
return true;
}
Here is the call graph for this function:| ilObjCourseGrouping::create | ( | $ | a_course_ref_id, | |
| $ | a_course_id | |||
| ) |
Definition at line 173 of file class.ilObjCourseGrouping.php.
References $res, getDescription(), getId(), getTitle(), getUniqueField(), and setId().
{
global $ilUser,$ilDB;
// INSERT IN object_data
$query = "INSERT INTO object_data ".
"(type,title,description,owner,create_date,last_update,import_id) ".
"VALUES ".
"(".$ilDB->quote($this->type).",".$this->db->quote($this->getTitle()).",".$ilDB->quote($this->getDescription()).",".
" ".$ilDB->quote($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 = ".$ilDB->quote($a_course_ref_id).", ".
"crs_id = ".$ilDB->quote($a_course_id).",".
"crs_grp_id = ".$ilDB->quote($this->getId()).", ".
"unique_field = ".$ilDB->quote($this->getUniqueField())." ";
$this->db->query($query);
return $this->getId();
}
Here is the call graph for this function:| ilObjCourseGrouping::deassign | ( | $ | a_crs_ref_id, | |
| $ | a_course_id | |||
| ) |
Definition at line 363 of file class.ilObjCourseGrouping.php.
References ilConditionHandler::_getConditionsOfTrigger(), 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;
}
Here is the call graph for this function:| ilObjCourseGrouping::delete | ( | ) |
Definition at line 149 of file class.ilObjCourseGrouping.php.
References getId(), and getType().
{
global $ilDB;
include_once './classes/class.ilConditionHandler.php';
if($this->getId() and $this->getType() === 'crsg')
{
$query = "DELETE FROM object_data WHERE obj_id = ".$ilDB->quote($this->getId())." ";
$this->db->query($query);
$query = "DELETE FROM crs_groupings ".
"WHERE crs_grp_id = ".$ilDB->quote($this->getId())." ";
$this->db->query($query);
// Delete conditions
$condh =& new ilConditionHandler();
$condh->deleteByObjId($this->getId());
return true;
}
return false;
}
Here is the call graph for this function:| ilObjCourseGrouping::getAssignedItems | ( | ) |
Definition at line 131 of file class.ilObjCourseGrouping.php.
References ilConditionHandler::_getConditionsOfTrigger(), getId(), and getType().
Referenced by getCountAssignedItems(), and isAssigned().
{
global $tree;
include_once './classes/class.ilConditionHandler.php';
$condition_data = ilConditionHandler::_getConditionsOfTrigger($this->getType(),$this->getId());
$conditions = array();
foreach($condition_data as $condition)
{
if($tree->isDeleted($condition['target_ref_id']))
{
continue;
}
$conditions[] = $condition;
}
return count($conditions) ? $conditions : array();
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjCourseGrouping::getContainerObjId | ( | ) |
Definition at line 79 of file class.ilObjCourseGrouping.php.
Referenced by assign().
{
return $this->obj_id;
}
Here is the caller graph for this function:| ilObjCourseGrouping::getContainerRefId | ( | ) |
Definition at line 71 of file class.ilObjCourseGrouping.php.
Referenced by assign().
{
return $this->ref_id;
}
Here is the caller graph for this function:| ilObjCourseGrouping::getContainerType | ( | ) |
Definition at line 83 of file class.ilObjCourseGrouping.php.
{
return $this->container_type;
}
| ilObjCourseGrouping::getCountAssignedItems | ( | ) |
Definition at line 126 of file class.ilObjCourseGrouping.php.
References getAssignedItems().
{
return count($this->getAssignedItems());
}
Here is the call graph for this function:| ilObjCourseGrouping::getDescription | ( | ) |
Definition at line 113 of file class.ilObjCourseGrouping.php.
Referenced by create(), and update().
{
return $this->description;
}
Here is the caller graph for this function:| ilObjCourseGrouping::getId | ( | ) |
Definition at line 62 of file class.ilObjCourseGrouping.php.
Referenced by __addCondition(), create(), deassign(), delete(), getAssignedItems(), read(), and update().
{
return $this->id;
}
Here is the caller graph for this function:| ilObjCourseGrouping::getTitle | ( | ) |
Definition at line 105 of file class.ilObjCourseGrouping.php.
Referenced by create(), and update().
{
return $this->title;
}
Here is the caller graph for this function:| ilObjCourseGrouping::getType | ( | ) |
Definition at line 96 of file class.ilObjCourseGrouping.php.
Referenced by delete(), getAssignedItems(), and update().
{
return $this->type;
}
Here is the caller graph for this function:| ilObjCourseGrouping::getUniqueField | ( | ) |
Definition at line 121 of file class.ilObjCourseGrouping.php.
Referenced by __addCondition(), create(), and update().
{
return $this->unique_field;
}
Here is the caller graph for this function:| 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 44 of file class.ilObjCourseGrouping.php.
References read(), setId(), and setType().
Referenced by _checkAccess(), and _getVisibleGroupings().
{
global $ilDB;
$this->setType('crsg');
$this->db =& $ilDB;
$this->setId($a_id);
if($a_id)
{
$this->read();
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjCourseGrouping::isAssigned | ( | $ | a_course_id | ) |
Definition at line 241 of file class.ilObjCourseGrouping.php.
References getAssignedItems().
{
foreach($this->getAssignedItems() as $condition_data)
{
if($a_course_id == $condition_data['target_obj_id'])
{
return true;
}
}
return false;
}
Here is the call graph for this function:| ilObjCourseGrouping::read | ( | ) |
Definition at line 253 of file class.ilObjCourseGrouping.php.
References $res, getId(), setContainerObjId(), setContainerRefId(), setContainerType(), setDescription(), setTitle(), and setUniqueField().
Referenced by ilObjCourseGrouping().
{
global $ilObjDataCache,$ilDB;
$query = "SELECT * FROM object_data ".
"WHERE obj_id = ".$ilDB->quote($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 = ".$ilDB->quote($this->getId())." ";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$this->setUniqueField($row->unique_field);
$this->setContainerRefId($row->crs_ref_id);
$this->setContainerObjId($row->crs_id);
$this->setContainerType($ilObjDataCache->lookupType($this->getContainerObjId()));
}
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilObjCourseGrouping::setContainerObjId | ( | $ | a_obj_id | ) |
Definition at line 75 of file class.ilObjCourseGrouping.php.
Referenced by read().
{
$this->obj_id = $a_obj_id;
}
Here is the caller graph for this function:| ilObjCourseGrouping::setContainerRefId | ( | $ | a_ref_id | ) |
Definition at line 67 of file class.ilObjCourseGrouping.php.
Referenced by read().
{
$this->ref_id = $a_ref_id;
}
Here is the caller graph for this function:| ilObjCourseGrouping::setContainerType | ( | $ | a_type | ) |
Definition at line 87 of file class.ilObjCourseGrouping.php.
Referenced by read().
{
$this->container_type = $a_type;
}
Here is the caller graph for this function:| ilObjCourseGrouping::setDescription | ( | $ | a_desc | ) |
Definition at line 109 of file class.ilObjCourseGrouping.php.
Referenced by read().
{
$this->description = $a_desc;
}
Here is the caller graph for this function:| ilObjCourseGrouping::setId | ( | $ | a_id | ) |
Definition at line 58 of file class.ilObjCourseGrouping.php.
Referenced by create(), and ilObjCourseGrouping().
{
$this->id = $a_id;
}
Here is the caller graph for this function:| ilObjCourseGrouping::setTitle | ( | $ | a_title | ) |
Definition at line 101 of file class.ilObjCourseGrouping.php.
Referenced by read().
{
$this->title = $a_title;
}
Here is the caller graph for this function:| ilObjCourseGrouping::setType | ( | $ | a_type | ) |
Definition at line 92 of file class.ilObjCourseGrouping.php.
Referenced by ilObjCourseGrouping().
{
$this->type = $a_type;
}
Here is the caller graph for this function:| ilObjCourseGrouping::setUniqueField | ( | $ | a_uni | ) |
Definition at line 117 of file class.ilObjCourseGrouping.php.
Referenced by read().
{
$this->unique_field = $a_uni;
}
Here is the caller graph for this function:| ilObjCourseGrouping::update | ( | ) |
Definition at line 207 of file class.ilObjCourseGrouping.php.
References getDescription(), getId(), getTitle(), getType(), and getUniqueField().
{
global $ilDB;
if($this->getId() and $this->getType() === 'crsg')
{
// UPDATe object_data
$query = "UPDATE object_data ".
"SET title = ".$ilDB->quote($this->getTitle()).", ".
"description = ".$ilDB->quote($this->getDescription())." ".
"WHERE obj_id = ".$ilDB->quote($this->getId())." ".
"AND type = ".$ilDB->quote($this->getType())." ";
$this->db->query($query);
// UPDATE crs_groupings
$query = "UPDATE crs_groupings ".
"SET unique_field = ".$ilDB->quote($this->getUniqueField())." ".
"WHERE crs_grp_id = ".$ilDB->quote($this->getId())." ";
$this->db->query($query);
// UPDATE conditions
$query = "UPDATE conditions ".
"SET value = ".$ilDB->quote($this->getUniqueField())." ".
"WHERE trigger_obj_id = ".$ilDB->quote($this->getId())." ".
"AND trigger_type = 'crsg'";
$this->db->query($query);
return true;
}
return false;
}
Here is the call graph for this function:| ilObjCourseGrouping::$db |
Definition at line 36 of file class.ilObjCourseGrouping.php.
1.7.1