32 require_once
"./Services/Object/classes/class.ilObject.php";
70 $this->ref_id = $a_ref_id;
78 $this->obj_id = $a_obj_id;
86 return $this->container_type;
90 $this->container_type =
$a_type;
104 $this->title = $a_title;
112 $this->description = $a_desc;
116 return $this->description;
120 $this->unique_field = $a_uni;
124 return $this->unique_field;
136 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
138 $conditions =
array();
139 foreach($condition_data as $condition)
141 if($tree->isDeleted($condition[
'target_ref_id']))
145 $conditions[] = $condition;
147 return count($conditions) ? $conditions :
array();
154 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
158 $query =
"DELETE FROM object_data WHERE obj_id = ".$ilDB->quote($this->
getId(),
'integer').
" ";
161 $query =
"DELETE FROM crs_groupings ".
162 "WHERE crs_grp_id = ".$ilDB->quote($this->
getId(),
'integer').
" ";
167 $condh->deleteByObjId($this->
getId());
174 function create($a_course_ref_id,$a_course_id)
179 $this->
setId($ilDB->nextId(
"object_data"));
180 $query =
"INSERT INTO object_data ".
181 "(obj_id, type,title,description,owner,create_date,last_update) ".
184 $ilDB->quote($this->
getId(),
"integer").
",".
185 $ilDB->quote($this->type,
"text").
",".
186 $ilDB->quote($this->
getTitle(),
"text").
",".
188 $ilDB->quote($ilUser->getId(),
"integer").
",".
193 $ilDB->manipulate($query);
196 $query =
"INSERT INTO crs_groupings (crs_grp_id,crs_ref_id,crs_id,unique_field) ".
198 $ilDB->quote($this->
getId(),
'integer').
", ".
199 $ilDB->quote($a_course_ref_id,
'integer').
", ".
200 $ilDB->quote($a_course_id,
'integer').
", ".
203 $res = $ilDB->manipulate($query);
205 return $this->
getId();
215 $query =
"UPDATE object_data ".
216 "SET title = ".$ilDB->quote($this->
getTitle(),
'text').
", ".
217 "description = ".$ilDB->quote($this->
getDescription(),
'text').
" ".
218 "WHERE obj_id = ".$ilDB->quote($this->
getId(),
'integer').
" ".
219 "AND type = ".$ilDB->quote($this->
getType(),
'text').
" ";
223 $query =
"UPDATE crs_groupings ".
224 "SET unique_field = ".$ilDB->quote($this->
getUniqueField(),
'text').
" ".
225 "WHERE crs_grp_id = ".$ilDB->quote($this->
getId(),
'integer').
" ";
229 $query =
"UPDATE conditions ".
231 "WHERE trigger_obj_id = ".$ilDB->quote($this->
getId(),
'integer').
" ".
232 "AND trigger_type = 'crsg'";
244 if($a_course_id == $condition_data[
'target_obj_id'])
254 global $ilObjDataCache,
$ilDB;
256 $query =
"SELECT * FROM object_data ".
257 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
" ";
266 $query =
"SELECT * FROM crs_groupings ".
267 "WHERE crs_grp_id = ".$ilDB->quote($this->
getId(),
'integer').
" ";
275 $this->
setContainerType($ilObjDataCache->lookupType($this->getContainerObjId()));
283 global $ilAccess,$tree;
287 $found_invisible =
false;
288 foreach($tmp_grouping_obj->getAssignedItems() as $condition)
290 if(!$ilAccess->checkAccess(
'write',
'',$condition[
'target_ref_id']))
292 $found_invisible =
true;
296 return $found_invisible ? false :
true;
309 global $ilObjDataCache,$ilAccess,
$ilDB;
311 $container_type = $ilObjDataCache->lookupType($a_obj_id) ==
'grp' ?
'grp' :
'crs';
315 $query =
"SELECT * FROM object_data WHERE type = 'crsg' ORDER BY title";
317 $groupings =
array();
320 $groupings[] =
$row->obj_id;
324 foreach($groupings as $grouping_id)
329 if($tmp_grouping_obj->getContainerType() != $container_type)
334 if($tmp_grouping_obj->getContainerObjId() == $a_obj_id)
336 $visible_groupings[] = $grouping_id;
340 if(count($items = $tmp_grouping_obj->getAssignedItems()))
342 foreach($items as $condition_data)
344 if($ilAccess->checkAccess(
'write',
'',$condition_data[
'target_ref_id']))
346 $visible_groupings[] = $grouping_id;
353 return $visible_groupings ? $visible_groupings :
array();
356 function assign($a_crs_ref_id,$a_course_id)
367 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
373 if($this->getCountAssignedCourses() == 2)
375 $condh->deleteByObjId($this->
getId());
383 if($cond_data[
'target_ref_id'] == $a_crs_ref_id
and 384 $cond_data[
'target_obj_id'] == $a_course_id)
386 $condh->deleteCondition($cond_data[
'id']);
396 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
399 $tmp_condh->enableAutomaticValidation(
false);
401 $tmp_condh->setTargetRefId($a_target_ref_id);
402 $tmp_condh->setTargetObjId($a_target_obj_id);
403 $tmp_condh->setTargetType(
'crs');
404 $tmp_condh->setTriggerRefId(0);
405 $tmp_condh->setTriggerObjId($this->
getId());
406 $tmp_condh->setTriggerType(
'crsg');
407 $tmp_condh->setOperator(
'not_member');
410 if(!$tmp_condh->checkExists())
412 $tmp_condh->storeCondition();
427 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
430 $condh->deleteByObjId($grouping_id);
433 $query =
"DELETE FROM crs_groupings ".
434 "WHERE crs_id = ".$ilDB->quote($a_course_id,
'integer').
" ";
444 $query =
"SELECT * FROM crs_groupings ".
445 "WHERE crs_id = ".$ilDB->quote($a_course_id,
'integer').
" ";
450 $groupings[] =
$row->crs_grp_id;
452 return $groupings ? $groupings :
array();
455 public static function _checkCondition($trigger_obj_id,$operator,$value,$a_usr_id = 0)
473 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
478 if($condition[
'trigger_type'] ==
'crsg')
482 if($tree->isDeleted($target_condition[
'target_ref_id']))
486 $course_ids[] =
array(
'id' => $target_condition[
'target_obj_id'],
487 'unique' => $target_condition[
'value']);
491 return $course_ids ? $course_ids :
array();
501 return self::$assignedObjects ? self::$assignedObjects :
array();
508 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
510 $user_id = is_null($a_user_id) ? $ilUser->getId() : $a_user_id;
513 $trigger_ids =
array();
515 $container_obj->getId(),
516 $container_obj->getType()) as $condition)
518 if($condition[
'operator'] ==
'not_member')
520 $trigger_ids[] = $condition[
'trigger_obj_id'];
524 if(!count($trigger_ids))
528 $matriculation_message = $assigned_message =
'';
529 self::$assignedObjects =
array();
530 foreach($trigger_ids as $trigger_id)
535 if($tree->isDeleted($condition[
'target_ref_id']))
539 if($condition[
'operator'] ==
'not_member')
541 switch($condition[
'value'])
543 case 'matriculation':
546 if(!$matriculation_message)
548 $matriculation_message = $lng->txt(
'crs_grp_matriculation_required');
552 if($container_obj->getType() ==
'crs')
554 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
556 if($members->isGroupingMember($user_id,$condition[
'value']))
558 if(!$assigned_message)
560 self::$assignedObjects[] = $condition[
'target_obj_id'];
561 $assigned_message = $lng->txt(
'crs_grp_already_assigned');
565 elseif($container_obj->getType() ==
'grp')
567 include_once(
'Modules/Group/classes/class.ilGroupParticipants.php');
569 if($members->isGroupingMember($user_id,$condition[
'value']))
571 if(!$assigned_message)
573 self::$assignedObjects[] = $condition[
'target_obj_id'];
574 $assigned_message = $lng->txt(
'crs_grp_already_assigned');
583 if(!$assigned_message)
585 self::$assignedObjects[] = $condition[
'target_obj_id'];
586 $assigned_message = $lng->txt(
'crs_grp_already_assigned');
594 if($matriculation_message)
596 $container_obj->appendMessage($matriculation_message);
599 elseif($assigned_message)
601 $container_obj->appendMessage($assigned_message);
616 global $tree,$ilObjDataCache,$ilAccess,$tree;
618 include_once
'./Services/AccessControl/classes/class.ilConditionHandler.php';
620 $trigger_ids =
array();
622 $container_obj->getId(),
623 $container_obj->getType()) as $condition)
625 if($condition[
'operator'] ==
'not_member')
627 $trigger_ids[] = $condition[
'trigger_obj_id'];
630 if(!count($trigger_ids))
634 $hash_table =
array();
635 foreach($trigger_ids as $trigger_id)
640 if($tree->isDeleted($condition[
'target_ref_id']))
645 if($condition[
'operator'] ==
'not_member')
647 if(!$hash_table[$condition[
'target_ref_id']])
649 $items[] = $condition[
'target_ref_id'];
651 $hash_table[$condition[
'target_ref_id']] =
true;
655 return $items ? $items :
array();
static _checkCondition($trigger_obj_id, $operator,$value, $a_usr_id=0)
static _getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all conditions of target object
static lookupMatriculation($a_usr_id)
Lookup matriculation.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static getAssignedObjects()
Alway call checkGroupingDependencies before.
static _getConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
get all conditions of trigger object
static _getVisibleGroupings($a_obj_id)
_checkAccess($grouping_id)
__construct($a_id=0)
Constructor public.
assign($a_crs_ref_id, $a_course_id)
static _deleteAll($a_course_id)
static _getGroupingCourseIds($a_course_ref_id, $a_course_id)
Get all ids of courses that are grouped with another course static.
__addCondition($a_target_ref_id, $a_target_obj_id)
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Create styles array
The data for the language used.
static _checkGroupingDependencies(&$container_obj, $a_user_id=null)
setContainerObjId($a_obj_id)
Handles conditions for accesses to different ILIAS objects.
setContainerRefId($a_ref_id)
static _getGroupingItems($container_obj)
Get courses/groups that are assigned to the same membership limitation.
static _getGroupings($a_course_id)
create($a_course_ref_id, $a_course_id)
_isMember($a_user_id, $a_ref_id, $a_field='')
setContainerType($a_type)
deassign($a_crs_ref_id, $a_course_id)