ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilObjCourseGroupingGUI Class Reference

Class ilObjCourseGroupingGUI. More...

+ Collaboration diagram for ilObjCourseGroupingGUI:

Public Member Functions

 __construct ($content_obj, $a_obj_id=0)
 Constructor @access public. More...
 
 executeCommand ()
 
 __initGroupingObject ()
 
 getContentType ()
 
 listGroupings ()
 
 askDeleteGrouping ()
 
 deleteGrouping ()
 
 create ($a_form=null)
 
 initForm ($a_create)
 
 add ()
 
 edit ($a_form=null)
 
 update ()
 
 selectCourse ()
 
 assignCourse ()
 

Data Fields

 $content_obj
 
 $tpl
 
 $ctrl
 
 $lng
 

Detailed Description

Class ilObjCourseGroupingGUI.

Author
your name <your email>
Version
$Id$

Definition at line 13 of file class.ilObjCourseGroupingGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjCourseGroupingGUI::__construct (   $content_obj,
  $a_obj_id = 0 
)

Constructor @access public.

Definition at line 24 of file class.ilObjCourseGroupingGUI.php.

25 {
26 global $tpl,$ilCtrl,$lng,$ilObjDataCache;
27
28 $this->tpl = $tpl;
29 $this->ctrl = $ilCtrl;
30 $this->lng = $lng;
31
32 $this->type = "crsg";
33 $this->content_obj = $content_obj;
34 $this->content_type = $ilObjDataCache->lookupType($this->content_obj->getId());
35
36 $this->id = $a_obj_id;
37 $this->ctrl->saveParameter($this,'obj_id');
38
39 $this->__initGroupingObject();
40
41 }
global $ilCtrl
Definition: ilias.php:18

References $content_obj, $ilCtrl, $lng, $tpl, and __initGroupingObject().

+ Here is the call graph for this function:

Member Function Documentation

◆ __initGroupingObject()

ilObjCourseGroupingGUI::__initGroupingObject ( )

Definition at line 58 of file class.ilObjCourseGroupingGUI.php.

59 {
60 include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
61
62 $this->grp_obj = new ilObjCourseGrouping($this->id);
63 }
Class ilObj<module_name>

Referenced by __construct().

+ Here is the caller graph for this function:

◆ add()

ilObjCourseGroupingGUI::add ( )

Definition at line 225 of file class.ilObjCourseGroupingGUI.php.

226 {
227 $form = $this->initForm(true);
228 if($form->checkInput())
229 {
230 $this->grp_obj->setTitle($form->getInput('title'));
231 $this->grp_obj->setDescription($form->getInput('description'));
232 $this->grp_obj->setUniqueField($form->getInput('unique'));
233
234 if($this->grp_obj->create($this->content_obj->getRefId(),$this->content_obj->getId()))
235 {
236 ilUtil::sendSuccess($this->lng->txt('crs_grp_added_grouping'), true);
237 }
238 else
239 {
240 ilUtil::sendFailure($this->lng->txt('crs_grp_err_adding_grouping'), true);
241 }
242
243 $this->ctrl->redirect($this, 'listGroupings');
244 }
245
246 $form->setValuesByPost();
247 $this->create($form);
248 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References create(), initForm(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ askDeleteGrouping()

ilObjCourseGroupingGUI::askDeleteGrouping ( )

Definition at line 88 of file class.ilObjCourseGroupingGUI.php.

89 {
90 global $ilErr,$ilAccess,$tpl;
91
92 if(!$ilAccess->checkAccess('write','',$this->content_obj->getRefId()))
93 {
94 $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
95 }
96
97 if(!count($_POST['grouping']))
98 {
99 ilUtil::sendFailure($this->lng->txt('crs_grouping_select_one'));
100 $this->listGroupings();
101
102 return false;
103 }
104
105 // display confirmation message
106 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
107 $cgui = new ilConfirmationGUI();
108 $cgui->setFormAction($this->ctrl->getFormAction($this));
109 $cgui->setHeaderText($this->lng->txt("crs_grouping_delete_sure"));
110 $cgui->setCancel($this->lng->txt("cancel"), "listGroupings");
111 $cgui->setConfirm($this->lng->txt("delete"), "deleteGrouping");
112
113 // list objects that should be deleted
114 foreach($_POST['grouping'] as $grouping_id)
115 {
116 $tmp_obj = new ilObjCourseGrouping($grouping_id);
117 $cgui->addItem("grouping[]", $grouping_id, $tmp_obj->getTitle());
118 }
119
120 $tpl->setContent($cgui->getHTML());
121 }
$_POST["username"]
Confirmation screen class.
global $ilErr
Definition: raiseError.php:16

References $_POST, $ilErr, $tpl, listGroupings(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ assignCourse()

ilObjCourseGroupingGUI::assignCourse ( )

Definition at line 323 of file class.ilObjCourseGroupingGUI.php.

324 {
325 global $ilErr,$ilAccess,$ilObjDataCache,$tree,$ilUser;
326
327 if(!$ilAccess->checkAccess('write','',$this->content_obj->getRefId()))
328 {
329 $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
330 }
331
332 if(!$_GET['obj_id'])
333 {
334 $this->listGroupings();
335 return false;
336 }
337
338 // delete all existing conditions
339 include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
340 $condh = new ilConditionHandler();
341 $condh->deleteByObjId((int)$_GET['obj_id']);
342
343 $added = 0;
344 $container_ids = is_array($_POST['crs_ids']) ? $_POST['crs_ids'] : array();
345 foreach($container_ids as $course_ref_id)
346 {
347 $tmp_crs = ilObjectFactory::getInstanceByRefId($course_ref_id);
348 $tmp_condh = new ilConditionHandler();
349 $tmp_condh->enableAutomaticValidation(false);
350
351 $tmp_condh->setTargetRefId($course_ref_id);
352 $tmp_condh->setTargetObjId($tmp_crs->getId());
353 $tmp_condh->setTargetType($this->getContentType());
354 $tmp_condh->setTriggerRefId(0);
355 $tmp_condh->setTriggerObjId($this->id);
356 $tmp_condh->setTriggerType('crsg');
357 $tmp_condh->setOperator('not_member');
358 $tmp_condh->setValue($this->grp_obj->getUniqueField());
359
360 if(!$tmp_condh->checkExists())
361 {
362 $tmp_condh->storeCondition();
363 ++$added;
364 }
365 }
366
367 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
368 $this->ctrl->redirect($this, 'edit');
369 }
$_GET["client_id"]
Handles conditions for accesses to different ILIAS objects.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
$ilUser
Definition: imgupload.php:18

References $_GET, $_POST, $ilErr, $ilUser, getContentType(), ilObjectFactory\getInstanceByRefId(), listGroupings(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ create()

ilObjCourseGroupingGUI::create (   $a_form = null)

Definition at line 142 of file class.ilObjCourseGroupingGUI.php.

143 {
144 global $ilErr,$ilAccess,$tpl;
145
146 if(!$ilAccess->checkAccess('write','',$this->content_obj->getRefId()))
147 {
148 $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
149 }
150
151 if(!$a_form)
152 {
153 $a_form = $this->initForm(true);
154 }
155
156 $tpl->setContent($a_form->getHTML());
157 }

References $ilErr, $tpl, and initForm().

Referenced by add().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteGrouping()

ilObjCourseGroupingGUI::deleteGrouping ( )

Definition at line 123 of file class.ilObjCourseGroupingGUI.php.

124 {
125 global $ilErr,$ilAccess;
126
127 if(!$ilAccess->checkAccess('write','',$this->content_obj->getRefId()))
128 {
129 $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
130 }
131
132 foreach($_POST['grouping'] as $grouping_id)
133 {
134 $tmp_obj = new ilObjCourseGrouping((int)$grouping_id);
135 $tmp_obj->delete();
136 }
137
138 ilUtil::sendSuccess($this->lng->txt('crs_grouping_deleted'), true);
139 $this->ctrl->redirect($this, 'listGroupings');
140 }

References $_POST, $ilErr, and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ edit()

ilObjCourseGroupingGUI::edit (   $a_form = null)

Definition at line 250 of file class.ilObjCourseGroupingGUI.php.

251 {
252 global $ilErr,$ilAccess,$tpl;
253
254 if(!$ilAccess->checkAccess('write','',$this->content_obj->getRefId()))
255 {
256 $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
257 }
258
259 if(!$a_form)
260 {
261 $a_form = $this->initForm(false);
262 }
263
264 $tpl->setContent($a_form->getHTML());
265 }

References $ilErr, $tpl, and initForm().

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilObjCourseGroupingGUI::executeCommand ( )

Definition at line 43 of file class.ilObjCourseGroupingGUI.php.

44 {
45 global $ilTabs;
46
47 $ilTabs->setTabActive('crs_groupings');
48
49 $cmd = $this->ctrl->getCmd();
50 if (!$cmd = $this->ctrl->getCmd())
51 {
52 $cmd = "edit";
53 }
54 $this->$cmd();
55 }
$cmd
Definition: sahs_server.php:35

References $cmd.

◆ getContentType()

ilObjCourseGroupingGUI::getContentType ( )

Definition at line 65 of file class.ilObjCourseGroupingGUI.php.

66 {
67 return $this->content_type;
68 }

Referenced by assignCourse().

+ Here is the caller graph for this function:

◆ initForm()

ilObjCourseGroupingGUI::initForm (   $a_create)

Definition at line 159 of file class.ilObjCourseGroupingGUI.php.

160 {
161 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
162 $form = new ilPropertyFormGUI();
163 $form->setFormAction($this->ctrl->getFormAction($this));
164
165 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
166 $title->setRequired(true);
167 $form->addItem($title);
168
169 $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
170 $form->addItem($desc);
171
172 $options = array('login' => 'login',
173 'email' => 'email',
174 'matriculation' => 'matriculation');
175
176 foreach($options as $value => $caption)
177 {
178 $options[$value] = $this->lng->txt($caption);
179 }
180 $uniq = new ilSelectInputGUI($this->lng->txt('unambiguousness'), 'unique');
181 $uniq->setRequired(true);
182 $uniq->setOptions($options);
183 $form->addItem($uniq);
184
185 if($a_create)
186 {
187 $form->setTitle($this->lng->txt('crs_add_grouping'));
188 $form->addCommandButton('add', $this->lng->txt('btn_add'));
189 }
190 else
191 {
192 $grouping = new ilObjCourseGrouping($_REQUEST['obj_id']);
193 $title->setValue($grouping->getTitle());
194 $desc->setValue($grouping->getDescription());
195 $uniq->setValue($grouping->getUniqueField());
196
197 $ass = new ilCustomInputGUI($this->lng->txt('groupings_assigned_obj_'.$this->getContentType()));
198 $form->addItem($ass);
199
200 // assignments
201 $items = array();
202 foreach($grouping->getAssignedItems() as $cond_data)
203 {
204 $items[] = ilObject::_lookupTitle($cond_data['target_obj_id']);
205 }
206 if(count($items))
207 {
208 $ass->setHtml(implode("<br />", $items));
209 }
210 else
211 {
212 $ass->setHtml($this->lng->txt('crs_grp_no_courses_assigned'));
213 }
214
215 $form->setTitle($this->lng->txt('edit_grouping'));
216 $form->addCommandButton('update', $this->lng->txt('save'));
217 $form->addCommandButton('selectCourse', $this->lng->txt('grouping_change_assignment'));
218 }
219
220 $form->addCommandButton('listGroupings', $this->lng->txt('cancel'));
221
222 return $form;
223 }
This class represents a custom property in a property form.
static _lookupTitle($a_id)
lookup object title
This class represents a property form user interface.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
if(!is_array($argv)) $options

References $options, $title, and ilObject\_lookupTitle().

Referenced by add(), create(), edit(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listGroupings()

ilObjCourseGroupingGUI::listGroupings ( )

Definition at line 70 of file class.ilObjCourseGroupingGUI.php.

71 {
72 global $ilErr, $ilAccess, $ilToolbar, $tpl;
73
74 if(!$ilAccess->checkAccess('write','',$this->content_obj->getRefId()))
75 {
76 $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
77 }
78
79 $ilToolbar->addButton($this->lng->txt('crs_add_grouping'),
80 $this->ctrl->getLinkTarget($this, 'create'));
81
82 include_once 'Modules/Course/classes/class.ilCourseGroupingTableGUI.php';
83 $table = new ilCourseGroupingTableGUI($this, 'listGroupings', $this->content_obj);
84
85 $tpl->setContent($table->getHTML());
86 }

References $ilErr, and $tpl.

Referenced by askDeleteGrouping(), assignCourse(), and selectCourse().

+ Here is the caller graph for this function:

◆ selectCourse()

ilObjCourseGroupingGUI::selectCourse ( )

Definition at line 293 of file class.ilObjCourseGroupingGUI.php.

294 {
295 global $ilErr,$ilAccess,$tpl,$ilTabs;
296
297 if(!$ilAccess->checkAccess('write','',$this->content_obj->getRefId()))
298 {
299 $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
300 }
301
302 if(!$_GET['obj_id'])
303 {
304 ilUtil::sendFailure($this->lng->txt('crs_grp_no_grouping_id_given'));
305 $this->listGroupings();
306 return false;
307 }
308
309 $ilTabs->clearTargets();
310 $ilTabs->setBackTarget($this->lng->txt('back'),
311 $this->ctrl->getLinkTarget($this, 'edit'));
312
313 $tmp_grouping = new ilObjCourseGrouping((int) $_GET['obj_id']);
314
315 include_once 'Modules/Course/classes/class.ilCourseGroupingAssignmentTableGUI.php';
316 $table = new ilCourseGroupingAssignmentTableGUI($this, 'selectCourse', $this->content_obj, $tmp_grouping);
317
318 $tpl->setContent($table->getHTML());
319
320 return true;
321 }

References $_GET, $ilErr, $tpl, listGroupings(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ update()

ilObjCourseGroupingGUI::update ( )

Definition at line 267 of file class.ilObjCourseGroupingGUI.php.

268 {
269 global $ilErr,$ilAccess,$ilObjDataCache;
270
271 if(!$ilAccess->checkAccess('write','',$this->content_obj->getRefId()))
272 {
273 $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
274 }
275
276 $form = $this->initForm(false);
277 if($form->checkInput())
278 {
279 $tmp_grouping = new ilObjCourseGrouping($_REQUEST['obj_id']);
280 $tmp_grouping->setTitle($form->getInput('title'));
281 $tmp_grouping->setDescription($form->getInput('description'));
282 $tmp_grouping->setUniqueField($form->getInput('unique'));
283 $tmp_grouping->update();
284
285 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
286 $this->ctrl->redirect($this, 'listGroupings');
287 }
288
289 $form->setValuesByPost();
290 $this->edit($form);
291 }

References $ilErr, edit(), initForm(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

Field Documentation

◆ $content_obj

ilObjCourseGroupingGUI::$content_obj

Definition at line 15 of file class.ilObjCourseGroupingGUI.php.

Referenced by __construct().

◆ $ctrl

ilObjCourseGroupingGUI::$ctrl

Definition at line 17 of file class.ilObjCourseGroupingGUI.php.

◆ $lng

ilObjCourseGroupingGUI::$lng

Definition at line 18 of file class.ilObjCourseGroupingGUI.php.

Referenced by __construct().

◆ $tpl

ilObjCourseGroupingGUI::$tpl

The documentation for this class was generated from the following file: