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()).
" ";
160 $this->db->query($query);
162 $query =
"DELETE FROM crs_groupings ".
163 "WHERE crs_grp_id = ".$ilDB->quote($this->
getId()).
" ";
164 $this->db->query($query);
168 $condh->deleteByObjId($this->
getId());
175 function create($a_course_ref_id,$a_course_id)
177 global $ilUser,$ilDB;
180 $query =
"INSERT INTO object_data ".
181 "(type,title,description,owner,create_date,last_update,import_id) ".
183 "(".$ilDB->quote($this->type).
",".$this->db->quote($this->
getTitle()).
",".$ilDB->quote($this->
getDescription()).
",".
184 " ".$ilDB->quote($ilUser->getId()).
",now(),now(),'')";
186 $this->db->query($query);
189 $query =
"SELECT LAST_INSERT_ID() as last";
190 $res = $this->db->query($query);
193 $this->
setId($row->last);
198 $query =
"INSERT INTO crs_groupings ".
199 "SET crs_ref_id = ".$ilDB->quote($a_course_ref_id).
", ".
200 "crs_id = ".$ilDB->quote($a_course_id).
",".
201 "crs_grp_id = ".$ilDB->quote($this->
getId()).
", ".
204 $this->db->query($query);
206 return $this->
getId();
216 $query =
"UPDATE object_data ".
217 "SET title = ".$ilDB->quote($this->
getTitle()).
", ".
219 "WHERE obj_id = ".$ilDB->quote($this->
getId()).
" ".
220 "AND type = ".$ilDB->quote($this->
getType()).
" ";
222 $this->db->query($query);
225 $query =
"UPDATE crs_groupings ".
227 "WHERE crs_grp_id = ".$ilDB->quote($this->
getId()).
" ";
229 $this->db->query($query);
232 $query =
"UPDATE conditions ".
234 "WHERE trigger_obj_id = ".$ilDB->quote($this->
getId()).
" ".
235 "AND trigger_type = 'crsg'";
236 $this->db->query($query);
247 if($a_course_id == $condition_data[
'target_obj_id'])
257 global $ilObjDataCache,$ilDB;
259 $query =
"SELECT * FROM object_data ".
260 "WHERE obj_id = ".$ilDB->quote($this->
getId()).
" ";
262 $res = $this->db->query($query);
269 $query =
"SELECT * FROM crs_groupings ".
270 "WHERE crs_grp_id = ".$ilDB->quote($this->
getId()).
" ";
271 $res = $this->db->query($query);
278 $this->
setContainerType($ilObjDataCache->lookupType($this->getContainerObjId()));
286 global $ilAccess,$tree;
290 $found_invisible =
false;
291 foreach($tmp_grouping_obj->getAssignedItems() as $condition)
293 if(!$ilAccess->checkAccess(
'write',
'',$condition[
'target_ref_id']))
295 $found_invisible =
true;
299 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";
316 $res = $ilDB->query($query);
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
'./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
'./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
'./classes/class.ilConditionHandler.php';
430 $condh->deleteByObjId($grouping_id);
433 $query =
"DELETE FROM crs_groupings ".
434 "WHERE crs_id = ".$ilDB->quote($a_course_id).
" ";
436 $ilDB->query($query);
445 $query =
"SELECT * FROM crs_groupings ".
446 "WHERE crs_id = ".$ilDB->quote($a_course_id).
" ";
448 $res = $ilDB->query($query);
451 $groupings[] = $row->crs_grp_id;
453 return $groupings ? $groupings : array();
474 include_once
'./classes/class.ilConditionHandler.php';
479 if($condition[
'trigger_type'] ==
'crsg')
483 if($tree->isDeleted($target_condition[
'target_ref_id']))
487 $course_ids[] = array(
'id' => $target_condition[
'target_obj_id'],
488 'unique' => $target_condition[
'value']);
492 return $course_ids ? $course_ids : array();
502 return self::$assignedObjects ? self::$assignedObjects : array();
507 global $ilUser,
$lng,$tree;
509 include_once
'./classes/class.ilConditionHandler.php';
511 $user_id = is_null($a_user_id) ? $ilUser->getId() : $a_user_id;
514 $trigger_ids = array();
516 $container_obj->getId(),
517 $container_obj->getType()) as $condition)
519 if($condition[
'operator'] ==
'not_member')
521 $trigger_ids[] = $condition[
'trigger_obj_id'];
525 if(!count($trigger_ids))
529 $matriculation_message = $assigned_message =
'';
530 self::$assignedObjects = array();
531 foreach($trigger_ids as $trigger_id)
536 if($tree->isDeleted($condition[
'target_ref_id']))
540 if($condition[
'operator'] ==
'not_member')
542 switch($condition[
'value'])
544 case 'matriculation':
547 if(!$matriculation_message)
549 $matriculation_message = $lng->txt(
'crs_grp_matriculation_required');
553 if($container_obj->getType() ==
'crs')
555 include_once(
'Modules/Course/classes/class.ilCourseParticipants.php');
557 if($members->isGroupingMember($user_id,$condition[
'value']))
559 if(!$assigned_message)
561 self::$assignedObjects[] = $condition[
'target_obj_id'];
562 $assigned_message = $lng->txt(
'crs_grp_already_assigned');
566 elseif($container_obj->getType() ==
'grp')
568 include_once(
'Modules/Group/classes/class.ilGroupParticipants.php');
570 if($members->isGroupingMember($user_id,$condition[
'value']))
572 if(!$assigned_message)
574 self::$assignedObjects[] = $condition[
'target_obj_id'];
575 $assigned_message = $lng->txt(
'crs_grp_already_assigned');
584 if(!$assigned_message)
586 self::$assignedObjects[] = $condition[
'target_obj_id'];
587 $assigned_message = $lng->txt(
'crs_grp_already_assigned');
595 if($matriculation_message)
597 $container_obj->appendMessage($matriculation_message);
600 elseif($assigned_message)
602 $container_obj->appendMessage($assigned_message);
617 global $tree,$ilObjDataCache,$ilAccess,$tree;
619 include_once
'./classes/class.ilConditionHandler.php';
621 $trigger_ids = array();
623 $container_obj->getId(),
624 $container_obj->getType()) as $condition)
626 if($condition[
'operator'] ==
'not_member')
628 $trigger_ids[] = $condition[
'trigger_obj_id'];
631 if(!count($trigger_ids))
635 $hash_table = array();
636 foreach($trigger_ids as $trigger_id)
641 if($tree->isDeleted($condition[
'target_ref_id']))
646 if($condition[
'operator'] ==
'not_member')
648 if(!$hash_table[$condition[
'target_ref_id']])
650 $items[] = $condition[
'target_ref_id'];
652 $hash_table[$condition[
'target_ref_id']] =
true;
656 return $items ? $items : array();