32 require_once
"./classes/class.ilObject.php";
71 $this->ref_id = $a_ref_id;
79 $this->obj_id = $a_obj_id;
87 return $this->container_type;
91 $this->container_type = $a_type;
96 $this->type = $a_type;
105 $this->title = $a_title;
113 $this->description = $a_desc;
117 return $this->description;
121 $this->unique_field = $a_uni;
125 return $this->unique_field;
137 include_once
'./classes/class.ilConditionHandler.php';
139 $conditions = array();
140 foreach($condition_data as $condition)
142 if($tree->isDeleted($condition[
'target_ref_id']))
146 $conditions[] = $condition;
148 return count($conditions) ? $conditions : array();
155 include_once
'./classes/class.ilConditionHandler.php';
159 $query =
"DELETE FROM object_data WHERE obj_id = ".$ilDB->quote($this->
getId(),
'integer').
" ";
162 $query =
"DELETE FROM crs_groupings ".
163 "WHERE crs_grp_id = ".$ilDB->quote($this->
getId(),
'integer').
" ";
168 $condh->deleteByObjId($this->
getId());
175 function create($a_course_ref_id,$a_course_id)
177 global $ilUser,
$ilDB;
180 $this->
setId($ilDB->nextId(
"object_data"));
181 $query =
"INSERT INTO object_data ".
182 "(obj_id, type,title,description,owner,create_date,last_update) ".
185 $ilDB->quote($this->
getId(),
"integer").
",".
186 $ilDB->quote($this->type,
"text").
",".
187 $ilDB->quote($this->
getTitle(),
"text").
",".
189 $ilDB->quote($ilUser->getId(),
"integer").
",".
194 $ilDB->manipulate($query);
197 $query =
"INSERT INTO crs_groupings (crs_grp_id,crs_ref_id,crs_id,unique_field) ".
199 $ilDB->quote($this->
getId(),
'integer').
", ".
200 $ilDB->quote($a_course_ref_id,
'integer').
", ".
201 $ilDB->quote($a_course_id,
'integer').
", ".
204 $res = $ilDB->manipulate($query);
206 return $this->
getId();
216 $query =
"UPDATE object_data ".
217 "SET title = ".$ilDB->quote($this->
getTitle(),
'text').
", ".
218 "description = ".$ilDB->quote($this->
getDescription(),
'text').
" ".
219 "WHERE obj_id = ".$ilDB->quote($this->
getId(),
'integer').
" ".
220 "AND type = ".$ilDB->quote($this->
getType(),
'text').
" ";
224 $query =
"UPDATE crs_groupings ".
225 "SET unique_field = ".$ilDB->quote($this->
getUniqueField(),
'text').
" ".
226 "WHERE crs_grp_id = ".$ilDB->quote($this->
getId(),
'integer').
" ";
230 $query =
"UPDATE conditions ".
232 "WHERE trigger_obj_id = ".$ilDB->quote($this->
getId(),
'integer').
" ".
233 "AND trigger_type = 'crsg'";
245 if($a_course_id == $condition_data[
'target_obj_id'])
255 global $ilObjDataCache,
$ilDB;
257 $query =
"SELECT * FROM object_data ".
258 "WHERE obj_id = ".$ilDB->quote($this->
getId() ,
'integer').
" ";
267 $query =
"SELECT * FROM crs_groupings ".
268 "WHERE crs_grp_id = ".$ilDB->quote($this->
getId(),
'integer').
" ";
276 $this->
setContainerType($ilObjDataCache->lookupType($this->getContainerObjId()));
284 global $ilAccess,$tree;
288 $found_invisible =
false;
289 foreach($tmp_grouping_obj->getAssignedItems() as $condition)
291 if(!$ilAccess->checkAccess(
'write',
'',$condition[
'target_ref_id']))
293 $found_invisible =
true;
297 return $found_invisible ?
false :
true;
307 global $ilObjDataCache,$ilAccess,
$ilDB;
309 $container_type = $ilObjDataCache->lookupType($a_obj_id) ==
'grp' ?
'grp' :
'crs';
313 $query =
"SELECT * FROM object_data WHERE type = 'crsg' ORDER BY title";
315 $groupings = array();
318 $groupings[] =
$row->obj_id;
322 foreach($groupings as $grouping_id)
327 if($tmp_grouping_obj->getContainerType() != $container_type)
332 if($tmp_grouping_obj->getContainerObjId() == $a_obj_id)
334 $visible_groupings[] = $grouping_id;
338 if(count($items = $tmp_grouping_obj->getAssignedItems()))
340 foreach($items as $condition_data)
342 if($ilAccess->checkAccess(
'write',
'',$condition_data[
'target_ref_id']))
344 $visible_groupings[] = $grouping_id;
351 return $visible_groupings ? $visible_groupings : array();
354 function assign($a_crs_ref_id,$a_course_id)
365 include_once
'./classes/class.ilConditionHandler.php';
371 if($this->getCountAssignedCourses() == 2)
373 $condh->deleteByObjId($this->
getId());
381 if($cond_data[
'target_ref_id'] == $a_crs_ref_id and
382 $cond_data[
'target_obj_id'] == $a_course_id)
384 $condh->deleteCondition($cond_data[
'id']);
394 include_once
'./classes/class.ilConditionHandler.php';
397 $tmp_condh->enableAutomaticValidation(
false);
399 $tmp_condh->setTargetRefId($a_target_ref_id);
400 $tmp_condh->setTargetObjId($a_target_obj_id);
401 $tmp_condh->setTargetType(
'crs');
402 $tmp_condh->setTriggerRefId(0);
403 $tmp_condh->setTriggerObjId($this->
getId());
404 $tmp_condh->setTriggerType(
'crsg');
405 $tmp_condh->setOperator(
'not_member');
408 if(!$tmp_condh->checkExists())
410 $tmp_condh->storeCondition();
425 include_once
'./classes/class.ilConditionHandler.php';
428 $condh->deleteByObjId($grouping_id);
431 $query =
"DELETE FROM crs_groupings ".
432 "WHERE crs_id = ".$ilDB->quote($a_course_id,
'integer').
" ";
442 $query =
"SELECT * FROM crs_groupings ".
443 "WHERE crs_id = ".$ilDB->quote($a_course_id,
'integer').
" ";
448 $groupings[] =
$row->crs_grp_id;
450 return $groupings ? $groupings : array();
471 include_once
'./classes/class.ilConditionHandler.php';
476 if($condition[
'trigger_type'] ==
'crsg')
480 if($tree->isDeleted($target_condition[
'target_ref_id']))
484 $course_ids[] = array(
'id' => $target_condition[
'target_obj_id'],
485 'unique' => $target_condition[
'value']);
489 return $course_ids ? $course_ids : array();
499 return self::$assignedObjects ? self::$assignedObjects : array();
504 global $ilUser,
$lng,$tree;
506 include_once
'./classes/class.ilConditionHandler.php';
508 $user_id = is_null($a_user_id) ? $ilUser->getId() : $a_user_id;
511 $trigger_ids = array();
513 $container_obj->getId(),
514 $container_obj->getType()) as $condition)
516 if($condition[
'operator'] ==
'not_member')
518 $trigger_ids[] = $condition[
'trigger_obj_id'];
522 if(!count($trigger_ids))
526 $matriculation_message = $assigned_message =
'';
527 self::$assignedObjects = array();
528 foreach($trigger_ids as $trigger_id)
533 if($tree->isDeleted($condition[
'target_ref_id']))
537 if($condition[
'operator'] ==
'not_member')
539 switch($condition[
'value'])
541 case 'matriculation':
544 if(!$matriculation_message)
546 $matriculation_message = $lng->txt(
'crs_grp_matriculation_required');
550 if($container_obj->getType() ==
'crs')
552 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
554 if($members->isGroupingMember($user_id,$condition[
'value']))
556 if(!$assigned_message)
558 self::$assignedObjects[] = $condition[
'target_obj_id'];
559 $assigned_message = $lng->txt(
'crs_grp_already_assigned');
563 elseif($container_obj->getType() ==
'grp')
565 include_once(
'Modules/Group/classes/class.ilGroupParticipants.php');
567 if($members->isGroupingMember($user_id,$condition[
'value']))
569 if(!$assigned_message)
571 self::$assignedObjects[] = $condition[
'target_obj_id'];
572 $assigned_message = $lng->txt(
'crs_grp_already_assigned');
581 if(!$assigned_message)
583 self::$assignedObjects[] = $condition[
'target_obj_id'];
584 $assigned_message = $lng->txt(
'crs_grp_already_assigned');
592 if($matriculation_message)
594 $container_obj->appendMessage($matriculation_message);
597 elseif($assigned_message)
599 $container_obj->appendMessage($assigned_message);
614 global $tree,$ilObjDataCache,$ilAccess,$tree;
616 include_once
'./classes/class.ilConditionHandler.php';
618 $trigger_ids = array();
620 $container_obj->getId(),
621 $container_obj->getType()) as $condition)
623 if($condition[
'operator'] ==
'not_member')
625 $trigger_ids[] = $condition[
'trigger_obj_id'];
628 if(!count($trigger_ids))
632 $hash_table = array();
633 foreach($trigger_ids as $trigger_id)
638 if($tree->isDeleted($condition[
'target_ref_id']))
643 if($condition[
'operator'] ==
'not_member')
645 if(!$hash_table[$condition[
'target_ref_id']])
647 $items[] = $condition[
'target_ref_id'];
649 $hash_table[$condition[
'target_ref_id']] =
true;
653 return $items ? $items : array();