32 require_once
"./classes/class.ilObjectGUI.php";
54 $this->content_type = $ilObjDataCache->lookupType($this->content_obj->getId());
56 $this->
id = $a_obj_id;
57 $this->ctrl->saveParameter($this,
'obj_id');
65 return $this->content_type;
70 global
$ilErr,$ilAccess,$ilObjDataCache;
72 if(!$ilAccess->checkAccess(
'write',
'',$this->content_obj->getRefId()))
74 $ilErr->raiseError($this->lng->txt(
'permission_denied'),$ilErr->MESSAGE);
77 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.groupings.html",
'Modules/Course');
79 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
80 $this->tpl->setVariable(
"HEADER_DESC",$this->lng->txt(
'description'));
81 $this->tpl->setVariable(
"HEADER_UNAMBIGUOUSNESS",$this->lng->txt(
'unambiguousness'));
82 $this->tpl->setVariable(
"ASSIGNED_ITEMS",$this->lng->txt(
'groupings_assigned_obj_'.$this->getContentType()));
89 foreach($items as $grouping_id)
94 if(strlen($tmp_obj->getDescription()))
96 $this->tpl->setCurrentBlock(
"description");
97 $this->tpl->setVariable(
"DESCRIPTION_GRP",$tmp_obj->getDescription());
98 $this->tpl->parseCurrentBlock();
102 $assigned_items = $tmp_obj->getAssignedItems();
103 if($num_items = count($assigned_items))
105 $this->tpl->setVariable(
"ASSIGNED_COURSES",$this->lng->txt(
'crs_grp_assigned_courses_info'));
109 $this->tpl->setVariable(
"ASSIGNED_COURSES",$this->lng->txt(
'crs_grp_no_courses_assigned'));
112 foreach($assigned_items as $condition)
114 $this->tpl->setCurrentBlock(
"item");
115 $this->tpl->setVariable(
"ITEM_TITLE",$ilObjDataCache->lookupTitle($condition[
'target_obj_id']));
116 $this->tpl->parseCurrentBlock();
120 $this->tpl->setCurrentBlock(
"grouping_row");
121 $this->tpl->setVariable(
"GRP_TITLE",$tmp_obj->getTitle());
128 $this->tpl->setVariable(
"AMB_GRP",$this->lng->txt($tmp_obj->getUniqueField()));
131 $this->ctrl->setParameterByClass(
'ilobjcoursegroupinggui',
'obj_id',$grouping_id);
132 $this->tpl->setVariable(
"EDIT_LINK",$this->ctrl->getLinkTargetByClass(
'ilobjcoursegroupinggui',
'edit'));
134 $this->tpl->parseCurrentBlock();
137 if(count($items) and $has_access)
139 $this->tpl->setCurrentBlock(
"has_items");
141 $this->tpl->setVariable(
"EDIT",$this->lng->txt(
'edit'));
142 $this->tpl->setVariable(
"DELETE",$this->lng->txt(
'delete'));
143 $this->tpl->setVariable(
"ACTIONS",$this->lng->txt(
'actions'));
144 $this->tpl->parseCurrentBlock();
146 elseif(!count($items))
149 $this->tpl->setCurrentBlock(
"no_items");
150 $this->tpl->setVariable(
"TXT_NO_ITEMS",$this->lng->txt(
'no_datasets'));
151 $this->tpl->parseCurrentBlock();
154 $this->tpl->setVariable(
"ADD",$this->lng->txt(
'crs_add_grouping'));
161 global
$ilErr,$ilAccess,$ilObjDataCache;
163 if(!$ilAccess->checkAccess(
'write',
'',$this->content_obj->getRefId()))
165 $ilErr->raiseError($this->lng->txt(
'permission_denied'),$ilErr->MESSAGE);
168 if(!count(
$_POST[
'grouping']))
177 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.crs_ask_delete_goupings.html",
'Modules/Course');
179 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
180 $this->tpl->setVariable(
"HEADER_DESC",$this->lng->txt(
'description'));
181 $this->tpl->setVariable(
"BTN_CANCEL",$this->lng->txt(
'cancel'));
182 $this->tpl->setVariable(
"BTN_DELETE",$this->lng->txt(
'delete'));
186 foreach(
$_POST[
'grouping'] as $grouping_id)
190 if(strlen($tmp_obj->getDescription()))
192 $this->tpl->setCurrentBlock(
"description");
193 $this->tpl->setVariable(
"DESCRIPTION_GRP",$tmp_obj->getDescription());
194 $this->tpl->parseCurrentBlock();
196 $this->tpl->setCurrentBlock(
"grouping_row");
197 $this->tpl->setVariable(
"GRP_TITLE",$tmp_obj->getTitle());
199 $this->tpl->parseCurrentBlock();
206 global
$ilErr,$ilAccess,$ilObjDataCache;
208 if(!$ilAccess->checkAccess(
'write',
'',$this->content_obj->getRefId()))
210 $ilErr->raiseError($this->lng->txt(
'permission_denied'),$ilErr->MESSAGE);
213 if(!count(
$_SESSION[
'crs_grouping_del']))
220 foreach(
$_SESSION[
'crs_grouping_del'] as $grouping_id)
234 $options = array(
'login' =>
'login',
236 'matriculation' =>
'matriculation');
241 $unique =
$_POST[
'unique'] ?
$_POST[
'unique'] :
'login';
243 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.crs_grp_add.html",
'Modules/Course');
245 $this->tpl->setVariable(
"TITLE",
$title);
246 $this->tpl->setVariable(
"DESC",
$desc);
249 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
250 $this->tpl->setVariable(
"TXT_HEADER",$this->lng->txt(
'crs_add_grouping'));
251 $this->tpl->setVariable(
"TXT_TITLE",$this->lng->txt(
'title'));
252 $this->tpl->setVariable(
"TXT_DESC",$this->lng->txt(
'description'));
253 $this->tpl->setVariable(
"TXT_UNAM",$this->lng->txt(
'unambiguousness'));
254 $this->tpl->setVariable(
"TXT_REQUIRED_FLD",$this->lng->txt(
'required_field'));
255 $this->tpl->setVariable(
"CMD_SUBMIT",
'add');
256 $this->tpl->setVariable(
"TXT_SUBMIT",$this->lng->txt(
'btn_add'));
257 $this->tpl->setVariable(
"TXT_CANCEL",$this->lng->txt(
'cancel'));
281 $this->grp_obj->setUniqueField(
$_POST[
'unique']);
282 if($this->grp_obj->create($this->content_obj->getRefId(),$this->content_obj->getId()))
295 function edit($a_grouping_id = 0)
297 global
$ilErr,$ilAccess,$ilObjDataCache;
299 if(!$ilAccess->checkAccess(
'write',
'',$this->content_obj->getRefId()))
301 $ilErr->raiseError($this->lng->txt(
'permission_denied'),$ilErr->MESSAGE);
305 $grouping_id = $a_grouping_id;
307 elseif(count(
$_POST[
'grouping']) != 1)
315 $grouping_id = (int)
$_POST[
'grouping'][0];
318 $options = array(
'login' =>
'login',
320 'matriculation' =>
'matriculation');
326 $unique =
$_POST[
'unique'] ?
$_POST[
'unique'] : $tmp_grouping->getUniqueField();
328 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.crs_grp_edit.html",
'Modules/Course');
330 $this->ctrl->setParameter($this,
'obj_id',$grouping_id);
331 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
332 $this->tpl->setVariable(
"EDIT_GROUPING",$this->lng->txt(
'edit_grouping'));
333 $this->tpl->setVariable(
"BTN_UPDATE",$this->lng->txt(
'save'));
334 $this->tpl->setVariable(
"BTN_ADD",$this->lng->txt(
'grouping_change_assignment'));
335 $this->tpl->setVariable(
"BTN_CANCEL",$this->lng->txt(
'cancel'));
336 $this->tpl->setVariable(
"TXT_TITLE",$this->lng->txt(
'title'));
337 $this->tpl->setVariable(
"TXT_DESCRIPTION",$this->lng->txt(
'description'));
339 $this->tpl->setVariable(
"TXT_UNAM",$this->lng->txt(
'unambiguousness'));
342 $this->tpl->setVariable(
"TITLE",
$title);
343 $this->tpl->setVariable(
"DESCRIPTION",$description);
346 $items = $tmp_grouping->getAssignedItems();
347 foreach($items as $cond_data)
349 $this->tpl->setCurrentBlock(
"list_courses");
350 $this->tpl->setVariable(
"LIST_CRS_TITLE",$ilObjDataCache->lookupTitle($cond_data[
'target_obj_id']));
351 $this->tpl->parseCurrentBlock();
355 $this->tpl->setCurrentBlock(
"assigned");
356 $this->tpl->setVariable(
"ASS_COURSES",$this->lng->txt(
'crs_grp_table_assigned_courses'));
357 $this->tpl->parseCurrentBlock();
361 $this->tpl->setCurrentBlock(
"no_assigned");
362 $this->tpl->setVariable(
"MESSAGE_NO_COURSES",$this->lng->txt(
'crs_grp_no_courses_assigned'));
363 $this->tpl->parseCurrentBlock();
370 global
$ilErr,$ilAccess,$ilObjDataCache;
372 if(!$ilAccess->checkAccess(
'write',
'',$this->content_obj->getRefId()))
374 $ilErr->raiseError($this->lng->txt(
'permission_denied'),$ilErr->MESSAGE);
393 $tmp_grouping->setUniqueField(
$_POST[
'unique']);
394 $tmp_grouping->update();
404 global
$ilErr,$ilAccess,$ilObjDataCache,$tree,$ilUser;
406 if(!$ilAccess->checkAccess(
'write',
'',$this->content_obj->getRefId()))
408 $ilErr->raiseError($this->lng->txt(
'permission_denied'),$ilErr->MESSAGE);
420 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.crs_grp_select_crs.html",
'Modules/Course');
422 $this->ctrl->setParameter($this,
'obj_id',(
int) $_GET[
'obj_id']);
423 $this->tpl->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this));
424 $this->tpl->setVariable(
"TBL_TITLE",$this->lng->txt(
'crs_grp_assign_crs').
' ('.$this->grp_obj->getTitle().
')');
425 $this->tpl->setVariable(
"BTN_ASSIGN",$this->lng->txt(
'grouping_change_assignment'));
426 $this->tpl->setVariable(
"BTN_CANCEL",$this->lng->txt(
'cancel'));
428 $this->tpl->setVariable(
"HEADER_DESC",$this->lng->txt(
'description'));
433 $ilUser->getId(),-1);
435 $items_obj_id = array();
436 $items_ids = array();
439 $obj_id = $ilObjDataCache->lookupObjId($ref_id);
441 $items_obj_id[] = $obj_id;
443 $items_obj_id =
ilUtil::_sortIds($items_obj_id,
'object_data',
'title',
'obj_id');
444 foreach($items_obj_id as $obj_id)
446 $item_id = $items_ids[$obj_id];
447 if($tree->checkForParentType($item_id,
'adm'))
451 $obj_id = $ilObjDataCache->lookupObjId($item_id);
452 $title = $ilObjDataCache->lookupTitle($obj_id);
453 $description = $ilObjDataCache->lookupDescription($obj_id);
455 $assigned = $tmp_grouping->isAssigned($obj_id) ? 1 : 0;
457 if(strlen($description))
459 $this->tpl->setCurrentBlock(
"description");
460 $this->tpl->setVariable(
"DESCRIPTION_CRS",$description);
461 $this->tpl->parseCurrentBlock();
464 $this->tpl->setCurrentBlock(
"crs_row");
467 $this->tpl->setVariable(
"CRS_TITLE",
$title);
470 $this->tpl->setVariable(
"CRS_PATH",$this->lng->txt(
'path').
": ".
$path);
471 $this->tpl->parseCurrentBlock();
479 global
$ilErr,$ilAccess,$ilObjDataCache,$tree,$ilUser;
481 if(!$ilAccess->checkAccess(
'write',
'',$this->content_obj->getRefId()))
483 $ilErr->raiseError($this->lng->txt(
'permission_denied'),$ilErr->MESSAGE);
493 $container_ids = is_array(
$_POST[
'crs_ids']) ?
$_POST[
'crs_ids'] : array();
498 include_once
'./classes/class.ilConditionHandler.php';
501 $condh->deleteByObjId((
int) $_GET[
'obj_id']);
504 foreach($container_ids as $course_ref_id)
508 $tmp_condh->enableAutomaticValidation(
false);
510 $tmp_condh->setTargetRefId($course_ref_id);
511 $tmp_condh->setTargetObjId($tmp_crs->getId());
513 $tmp_condh->setTriggerRefId(0);
514 $tmp_condh->setTriggerObjId($this->
id);
515 $tmp_condh->setTriggerType(
'crsg');
516 $tmp_condh->setOperator(
'not_member');
517 $tmp_condh->setValue($this->grp_obj->getUniqueField());
519 if(!$tmp_condh->checkExists())
521 $tmp_condh->storeCondition();
525 $this->
edit((
int) $_GET[
'obj_id']);
533 $ilTabs->setTabActive(
'crs_groupings');
535 $cmd = $this->ctrl->getCmd();
536 if (!
$cmd = $this->ctrl->getCmd())
546 include_once
'./Modules/Course/classes/class.ilObjCourseGrouping.php';
554 foreach($a_path_arr as
$data)
564 $path .= $data[
'title'];