ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjCourseGrouping Class Reference

Class ilObj<module_name> More...

+ Collaboration diagram for ilObjCourseGrouping:

Public Member Functions

 ilObjCourseGrouping ($a_id=0)
 Constructor public. More...
 
 setId ($a_id)
 
 getId ()
 
 setContainerRefId ($a_ref_id)
 
 getContainerRefId ()
 
 setContainerObjId ($a_obj_id)
 
 getContainerObjId ()
 
 getContainerType ()
 
 setContainerType ($a_type)
 
 setType ($a_type)
 
 getType ()
 
 setTitle ($a_title)
 
 getTitle ()
 
 setDescription ($a_desc)
 
 getDescription ()
 
 setUniqueField ($a_uni)
 
 getUniqueField ()
 
 getCountAssignedItems ()
 
 getAssignedItems ()
 
 delete ()
 
 create ($a_course_ref_id, $a_course_id)
 
 update ()
 
 isAssigned ($a_course_id)
 
 read ()
 
 _checkAccess ($grouping_id)
 
 _getVisibleGroupings ($a_obj_id)
 Returns a list of all groupings for which the current user hast write permission on all assigned objects. More...
 
 assign ($a_crs_ref_id, $a_course_id)
 
 deassign ($a_crs_ref_id, $a_course_id)
 
 __addCondition ($a_target_ref_id, $a_target_obj_id)
 
 _deleteAll ($a_course_id)
 
 _getGroupings ($a_course_id)
 
 _checkCondition ($trigger_obj_id, $operator,$value, $a_usr_id=0)
 
 _getGroupingCourseIds ($a_course_ref_id, $a_course_id)
 Get all ids of courses that are grouped with another course static. More...
 
 _checkGroupingDependencies (&$container_obj, $a_user_id=null)
 
 _getGroupingItems ($container_obj)
 Get courses/groups that are assigned to the same membership limitation. More...
 

Static Public Member Functions

static getAssignedObjects ()
 Alway call checkGroupingDependencies before. More...
 

Data Fields

 $db
 

Static Protected Attributes

static $assignedObjects = array()
 

Detailed Description

Class ilObj<module_name>

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 34 of file class.ilObjCourseGrouping.php.

Member Function Documentation

◆ __addCondition()

ilObjCourseGrouping::__addCondition (   $a_target_ref_id,
  $a_target_obj_id 
)

Definition at line 392 of file class.ilObjCourseGrouping.php.

References getId(), and getUniqueField().

Referenced by assign().

393  {
394  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
395 
396  $tmp_condh =& new ilConditionHandler();
397  $tmp_condh->enableAutomaticValidation(false);
398 
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');
406  $tmp_condh->setValue($this->getUniqueField());
407 
408  if(!$tmp_condh->checkExists())
409  {
410  $tmp_condh->storeCondition();
411 
412  return true;
413  }
414  return false;
415  }
Handles conditions for accesses to different ILIAS objects.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _checkAccess()

ilObjCourseGrouping::_checkAccess (   $grouping_id)

Definition at line 282 of file class.ilObjCourseGrouping.php.

References ilObjCourseGrouping().

283  {
284  global $ilAccess,$tree;
285 
286  $tmp_grouping_obj = new ilObjCourseGrouping($grouping_id);
287 
288  $found_invisible = false;
289  foreach($tmp_grouping_obj->getAssignedItems() as $condition)
290  {
291  if(!$ilAccess->checkAccess('write','',$condition['target_ref_id']))
292  {
293  $found_invisible = true;
294  break;
295  }
296  }
297  return $found_invisible ? false : true;
298  }
ilObjCourseGrouping($a_id=0)
Constructor public.
+ Here is the call graph for this function:

◆ _checkCondition()

ilObjCourseGrouping::_checkCondition (   $trigger_obj_id,
  $operator,
  $value,
  $a_usr_id = 0 
)

Definition at line 453 of file class.ilObjCourseGrouping.php.

Referenced by ilConditionHandler\_checkCondition().

454  {
455  // in the moment i alway return true, there are some problems with presenting the condition if it fails,
456  // only course register class check manually if this condition is fullfilled
457  return true;
458  }
+ Here is the caller graph for this function:

◆ _checkGroupingDependencies()

ilObjCourseGrouping::_checkGroupingDependencies ( $container_obj,
  $a_user_id = null 
)

Definition at line 502 of file class.ilObjCourseGrouping.php.

References $ilUser, $lng, ilConditionHandler\_getConditionsOfTarget(), ilConditionHandler\_getConditionsOfTrigger(), ilGroupParticipants\_getInstanceByObjId(), ilCourseParticipants\_getInstanceByObjId(), ilObjGroup\_isMember(), and ilObjUser\lookupMatriculation().

Referenced by ilRegistrationGUI\fillMembershipLimitation(), ilSubscriberTableGUI\fillRow(), and ilWaitingListTableGUI\fillRow().

503  {
504  global $ilUser,$lng,$tree;
505 
506  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
507 
508  $user_id = is_null($a_user_id) ? $ilUser->getId() : $a_user_id;
509 
510 
511  $trigger_ids = array();
512  foreach(ilConditionHandler::_getConditionsOfTarget($container_obj->getRefId(),
513  $container_obj->getId(),
514  $container_obj->getType()) as $condition)
515  {
516  if($condition['operator'] == 'not_member')
517  {
518  $trigger_ids[] = $condition['trigger_obj_id'];
519  break;
520  }
521  }
522  if(!count($trigger_ids))
523  {
524  return true;
525  }
526  $matriculation_message = $assigned_message = '';
527  self::$assignedObjects = array();
528  foreach($trigger_ids as $trigger_id)
529  {
530  foreach(ilConditionHandler::_getConditionsOfTrigger('crsg',$trigger_id) as $condition)
531  {
532  // Handle deleted items
533  if($tree->isDeleted($condition['target_ref_id']))
534  {
535  continue;
536  }
537  if($condition['operator'] == 'not_member')
538  {
539  switch($condition['value'])
540  {
541  case 'matriculation':
542  if(!strlen(ilObjUser::lookupMatriculation($user_id)))
543  {
544  if(!$matriculation_message)
545  {
546  $matriculation_message = $lng->txt('crs_grp_matriculation_required');
547  }
548  }
549  }
550  if($container_obj->getType() == 'crs')
551  {
552  include_once('Modules/Course/classes/class.ilCourseParticipants.php');
553  $members = ilCourseParticipants::_getInstanceByObjId($condition['target_obj_id']);
554  if($members->isGroupingMember($user_id,$condition['value']))
555  {
556  if(!$assigned_message)
557  {
558  self::$assignedObjects[] = $condition['target_obj_id'];
559  $assigned_message = $lng->txt('crs_grp_already_assigned');
560  }
561  }
562  }
563  elseif($container_obj->getType() == 'grp')
564  {
565  include_once('Modules/Group/classes/class.ilGroupParticipants.php');
566  $members = ilGroupParticipants::_getInstanceByObjId($condition['target_obj_id']);
567  if($members->isGroupingMember($user_id,$condition['value']))
568  {
569  if(!$assigned_message)
570  {
571  self::$assignedObjects[] = $condition['target_obj_id'];
572  $assigned_message = $lng->txt('crs_grp_already_assigned');
573  }
574  }
575 
576  }
577  else
578  {
579  if(ilObjGroup::_isMember($user_id,$condition['target_ref_id'],$condition['value']))
580  {
581  if(!$assigned_message)
582  {
583  self::$assignedObjects[] = $condition['target_obj_id'];
584  $assigned_message = $lng->txt('crs_grp_already_assigned');
585  }
586  }
587 
588  }
589  }
590  }
591  }
592  if($matriculation_message)
593  {
594  $container_obj->appendMessage($matriculation_message);
595  return false;
596  }
597  elseif($assigned_message)
598  {
599  $container_obj->appendMessage($assigned_message);
600  return false;
601  }
602  return true;
603  }
_getConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
get all conditions of trigger object
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 _getInstanceByObjId($a_obj_id)
Get singleton instance.
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
_isMember($a_user_id, $a_ref_id, $a_field='')
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _deleteAll()

ilObjCourseGrouping::_deleteAll (   $a_course_id)

Definition at line 418 of file class.ilObjCourseGrouping.php.

References $query, $res, and _getGroupings().

Referenced by ilObjCourse\delete().

419  {
420  global $ilDB;
421 
422  // DELETE CONDITIONS
423  foreach($groupings = ilObjCourseGrouping::_getGroupings($a_course_id) as $grouping_id)
424  {
425  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
426 
427  $condh =& new ilConditionHandler();
428  $condh->deleteByObjId($grouping_id);
429  }
430 
431  $query = "DELETE FROM crs_groupings ".
432  "WHERE crs_id = ".$ilDB->quote($a_course_id,'integer')." ";
433  $res = $ilDB->manipulate($query);
434 
435  return true;
436  }
Handles conditions for accesses to different ILIAS objects.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getGroupingCourseIds()

ilObjCourseGrouping::_getGroupingCourseIds (   $a_course_ref_id,
  $a_course_id 
)

Get all ids of courses that are grouped with another course static.

Parameters
integerobject_id of one course
arrayinteger ids of courses or empty array if course is not in grouping

Definition at line 467 of file class.ilObjCourseGrouping.php.

References ilConditionHandler\_getConditionsOfTarget(), and ilConditionHandler\_getConditionsOfTrigger().

Referenced by ilObjCourseGUI\__showWaitingList().

468  {
469  global $tree;
470 
471  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
472 
473  // get all grouping ids the course is assigned to
474  foreach(ilConditionHandler::_getConditionsOfTarget($a_course_ref_id,$a_course_id,'crs') as $condition)
475  {
476  if($condition['trigger_type'] == 'crsg')
477  {
478  foreach(ilConditionHandler::_getConditionsOfTrigger('crsg',$condition['trigger_obj_id']) as $target_condition)
479  {
480  if($tree->isDeleted($target_condition['target_ref_id']))
481  {
482  continue;
483  }
484  $course_ids[] = array('id' => $target_condition['target_obj_id'],
485  'unique' => $target_condition['value']);
486  }
487  }
488  }
489  return $course_ids ? $course_ids : array();
490  }
_getConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
get all conditions of trigger object
static _getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all conditions of target object
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getGroupingItems()

ilObjCourseGrouping::_getGroupingItems (   $container_obj)

Get courses/groups that are assigned to the same membership limitation.

Parameters
objectcontainer object
Returns
array array of reference ids

Definition at line 612 of file class.ilObjCourseGrouping.php.

References ilConditionHandler\_getConditionsOfTarget(), and ilConditionHandler\_getConditionsOfTrigger().

Referenced by ilRegistrationGUI\fillMembershipLimitation().

613  {
614  global $tree,$ilObjDataCache,$ilAccess,$tree;
615 
616  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
617 
618  $trigger_ids = array();
619  foreach(ilConditionHandler::_getConditionsOfTarget($container_obj->getRefId(),
620  $container_obj->getId(),
621  $container_obj->getType()) as $condition)
622  {
623  if($condition['operator'] == 'not_member')
624  {
625  $trigger_ids[] = $condition['trigger_obj_id'];
626  }
627  }
628  if(!count($trigger_ids))
629  {
630  return false;
631  }
632  $hash_table = array();
633  foreach($trigger_ids as $trigger_id)
634  {
635  foreach(ilConditionHandler::_getConditionsOfTrigger('crsg',$trigger_id) as $condition)
636  {
637  // Continue if trigger is deleted
638  if($tree->isDeleted($condition['target_ref_id']))
639  {
640  continue;
641  }
642 
643  if($condition['operator'] == 'not_member')
644  {
645  if(!$hash_table[$condition['target_ref_id']])
646  {
647  $items[] = $condition['target_ref_id'];
648  }
649  $hash_table[$condition['target_ref_id']] = true;
650  }
651  }
652  }
653  return $items ? $items : array();
654  }
_getConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
get all conditions of trigger object
static _getConditionsOfTarget($a_target_ref_id, $a_target_obj_id, $a_target_type="")
get all conditions of target object
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getGroupings()

ilObjCourseGrouping::_getGroupings (   $a_course_id)

Definition at line 438 of file class.ilObjCourseGrouping.php.

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by _deleteAll().

439  {
440  global $ilDB;
441 
442  $query = "SELECT * FROM crs_groupings ".
443  "WHERE crs_id = ".$ilDB->quote($a_course_id,'integer')." ";
444 
445  $res = $ilDB->query($query);
446  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
447  {
448  $groupings[] = $row->crs_grp_id;
449  }
450  return $groupings ? $groupings : array();
451  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ _getVisibleGroupings()

ilObjCourseGrouping::_getVisibleGroupings (   $a_obj_id)

Returns a list of all groupings for which the current user hast write permission on all assigned objects.

Or groupings the given object id is assigned to.

Definition at line 305 of file class.ilObjCourseGrouping.php.

References $query, $res, $row, DB_FETCHMODE_OBJECT, and ilObjCourseGrouping().

Referenced by ilCourseGroupingTableGUI\getItems().

306  {
307  global $ilObjDataCache,$ilAccess,$ilDB;
308 
309  $container_type = $ilObjDataCache->lookupType($a_obj_id) == 'grp' ? 'grp' : 'crs';
310 
311 
312  // First get all groupings
313  $query = "SELECT * FROM object_data WHERE type = 'crsg' ORDER BY title";
314  $res = $ilDB->query($query);
315  $groupings = array();
316  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
317  {
318  $groupings[] = $row->obj_id;
319  }
320 
321  //check access
322  foreach($groupings as $grouping_id)
323  {
324  $tmp_grouping_obj = new ilObjCourseGrouping($grouping_id);
325 
326  // Check container type
327  if($tmp_grouping_obj->getContainerType() != $container_type)
328  {
329  continue;
330  }
331  // Check if container is current container
332  if($tmp_grouping_obj->getContainerObjId() == $a_obj_id)
333  {
334  $visible_groupings[] = $grouping_id;
335  continue;
336  }
337  // check if items are assigned
338  if(count($items = $tmp_grouping_obj->getAssignedItems()))
339  {
340  foreach($items as $condition_data)
341  {
342  if($ilAccess->checkAccess('write','',$condition_data['target_ref_id']))
343  {
344  $visible_groupings[] = $grouping_id;
345  break;
346  }
347  }
348 
349  }
350  }
351  return $visible_groupings ? $visible_groupings : array();
352  }
ilObjCourseGrouping($a_id=0)
Constructor public.
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assign()

ilObjCourseGrouping::assign (   $a_crs_ref_id,
  $a_course_id 
)

Definition at line 354 of file class.ilObjCourseGrouping.php.

References __addCondition(), getContainerObjId(), and getContainerRefId().

355  {
356  // Add the parent course of grouping
357  $this->__addCondition($this->getContainerRefId(),$this->getContainerObjId());
358  $this->__addCondition($a_crs_ref_id,$a_course_id);
359 
360  return true;
361  }
__addCondition($a_target_ref_id, $a_target_obj_id)
+ Here is the call graph for this function:

◆ create()

ilObjCourseGrouping::create (   $a_course_ref_id,
  $a_course_id 
)

Definition at line 175 of file class.ilObjCourseGrouping.php.

References $ilUser, $query, $res, getDescription(), getId(), getTitle(), getUniqueField(), and setId().

176  {
177  global $ilUser,$ilDB;
178 
179  // INSERT IN object_data
180  $this->setId($ilDB->nextId("object_data"));
181  $query = "INSERT INTO object_data ".
182  "(obj_id, type,title,description,owner,create_date,last_update) ".
183  "VALUES ".
184  "(".
185  $ilDB->quote($this->getId(), "integer").",".
186  $ilDB->quote($this->type, "text").",".
187  $ilDB->quote($this->getTitle(), "text").",".
188  $ilDB->quote($this->getDescription(), "text").",".
189  $ilDB->quote($ilUser->getId(), "integer").",".
190  $ilDB->now().",".
191  $ilDB->now().
192  ')';
193 
194  $ilDB->manipulate($query);
195 
196  // INSERT in crs_groupings
197  $query = "INSERT INTO crs_groupings (crs_grp_id,crs_ref_id,crs_id,unique_field) ".
198  "VALUES (".
199  $ilDB->quote($this->getId(),'integer').", ".
200  $ilDB->quote($a_course_ref_id,'integer').", ".
201  $ilDB->quote($a_course_id,'integer').", ".
202  $ilDB->quote($this->getUniqueField(),'text')." ".
203  ")";
204  $res = $ilDB->manipulate($query);
205 
206  return $this->getId();
207  }
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:

◆ deassign()

ilObjCourseGrouping::deassign (   $a_crs_ref_id,
  $a_course_id 
)

Definition at line 363 of file class.ilObjCourseGrouping.php.

References ilConditionHandler\_getConditionsOfTrigger(), and getId().

364  {
365  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
366 
367 
368  $condh =& new ilConditionHandler();
369 
370  // DELETE also original course if its the last
371  if($this->getCountAssignedCourses() == 2)
372  {
373  $condh->deleteByObjId($this->getId());
374 
375  return true;
376  }
377 
378  foreach(ilConditionHandler::_getConditionsOfTrigger('crsg',$this->getId()) as $cond_data)
379  {
380 
381  if($cond_data['target_ref_id'] == $a_crs_ref_id and
382  $cond_data['target_obj_id'] == $a_course_id)
383  {
384  $condh->deleteCondition($cond_data['id']);
385  }
386  }
387 
388  return true;
389 
390  }
_getConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
get all conditions of trigger object
Handles conditions for accesses to different ILIAS objects.
+ Here is the call graph for this function:

◆ delete()

ilObjCourseGrouping::delete ( )

Definition at line 151 of file class.ilObjCourseGrouping.php.

References $query, $res, getId(), and getType().

152  {
153  global $ilDB;
154 
155  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
156 
157  if($this->getId() and $this->getType() === 'crsg')
158  {
159  $query = "DELETE FROM object_data WHERE obj_id = ".$ilDB->quote($this->getId(),'integer')." ";
160  $res = $ilDB->manipulate($query);
161 
162  $query = "DELETE FROM crs_groupings ".
163  "WHERE crs_grp_id = ".$ilDB->quote($this->getId(),'integer')." ";
164  $res = $ilDB->manipulate($query);
165 
166  // Delete conditions
167  $condh =& new ilConditionHandler();
168  $condh->deleteByObjId($this->getId());
169 
170  return true;
171  }
172  return false;
173  }
Handles conditions for accesses to different ILIAS objects.
+ Here is the call graph for this function:

◆ getAssignedItems()

ilObjCourseGrouping::getAssignedItems ( )

Definition at line 133 of file class.ilObjCourseGrouping.php.

References ilConditionHandler\_getConditionsOfTrigger(), getId(), and getType().

Referenced by getCountAssignedItems(), and isAssigned().

134  {
135  global $tree;
136 
137  include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
138  $condition_data = ilConditionHandler::_getConditionsOfTrigger($this->getType(),$this->getId());
139  $conditions = array();
140  foreach($condition_data as $condition)
141  {
142  if($tree->isDeleted($condition['target_ref_id']))
143  {
144  continue;
145  }
146  $conditions[] = $condition;
147  }
148  return count($conditions) ? $conditions : array();
149  }
_getConditionsOfTrigger($a_trigger_obj_type, $a_trigger_id)
get all conditions of trigger object
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAssignedObjects()

static ilObjCourseGrouping::getAssignedObjects ( )
static

Alway call checkGroupingDependencies before.

Returns
array Assigned objects

Definition at line 497 of file class.ilObjCourseGrouping.php.

Referenced by ilSubscriberTableGUI\fillRow(), and ilWaitingListTableGUI\fillRow().

498  {
499  return self::$assignedObjects ? self::$assignedObjects : array();
500  }
+ Here is the caller graph for this function:

◆ getContainerObjId()

ilObjCourseGrouping::getContainerObjId ( )

Definition at line 81 of file class.ilObjCourseGrouping.php.

Referenced by assign().

82  {
83  return $this->obj_id;
84  }
+ Here is the caller graph for this function:

◆ getContainerRefId()

ilObjCourseGrouping::getContainerRefId ( )

Definition at line 73 of file class.ilObjCourseGrouping.php.

References $ref_id.

Referenced by assign().

74  {
75  return $this->ref_id;
76  }
$ref_id
Definition: sahs_server.php:39
+ Here is the caller graph for this function:

◆ getContainerType()

ilObjCourseGrouping::getContainerType ( )

Definition at line 85 of file class.ilObjCourseGrouping.php.

86  {
87  return $this->container_type;
88  }

◆ getCountAssignedItems()

ilObjCourseGrouping::getCountAssignedItems ( )

Definition at line 128 of file class.ilObjCourseGrouping.php.

References getAssignedItems().

129  {
130  return count($this->getAssignedItems());
131  }
+ Here is the call graph for this function:

◆ getDescription()

ilObjCourseGrouping::getDescription ( )

Definition at line 115 of file class.ilObjCourseGrouping.php.

Referenced by create(), and update().

116  {
117  return $this->description;
118  }
+ Here is the caller graph for this function:

◆ getId()

ilObjCourseGrouping::getId ( )

Definition at line 64 of file class.ilObjCourseGrouping.php.

Referenced by __addCondition(), create(), deassign(), delete(), getAssignedItems(), read(), and update().

65  {
66  return $this->id;
67  }
+ Here is the caller graph for this function:

◆ getTitle()

ilObjCourseGrouping::getTitle ( )

Definition at line 107 of file class.ilObjCourseGrouping.php.

Referenced by create(), and update().

108  {
109  return $this->title;
110  }
+ Here is the caller graph for this function:

◆ getType()

ilObjCourseGrouping::getType ( )

Definition at line 98 of file class.ilObjCourseGrouping.php.

Referenced by delete(), getAssignedItems(), and update().

99  {
100  return $this->type;
101  }
+ Here is the caller graph for this function:

◆ getUniqueField()

ilObjCourseGrouping::getUniqueField ( )

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

Referenced by __addCondition(), create(), and update().

124  {
125  return $this->unique_field;
126  }
+ Here is the caller graph for this function:

◆ ilObjCourseGrouping()

ilObjCourseGrouping::ilObjCourseGrouping (   $a_id = 0)

Constructor public.

Parameters
integerreference_id or object_id
booleantreat the id as reference_id (true) or object_id (false)

Definition at line 46 of file class.ilObjCourseGrouping.php.

References read(), setId(), and setType().

Referenced by _checkAccess(), and _getVisibleGroupings().

47  {
48  global $ilDB;
49 
50  $this->setType('crsg');
51  $this->db =& $ilDB;
52 
53  $this->setId($a_id);
54 
55  if($a_id)
56  {
57  $this->read();
58  }
59  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAssigned()

ilObjCourseGrouping::isAssigned (   $a_course_id)

Definition at line 241 of file class.ilObjCourseGrouping.php.

References getAssignedItems().

242  {
243  foreach($this->getAssignedItems() as $condition_data)
244  {
245  if($a_course_id == $condition_data['target_obj_id'])
246  {
247  return true;
248  }
249  }
250  return false;
251  }
+ Here is the call graph for this function:

◆ read()

ilObjCourseGrouping::read ( )

Definition at line 253 of file class.ilObjCourseGrouping.php.

References $query, $res, $row, DB_FETCHMODE_OBJECT, getId(), setContainerObjId(), setContainerRefId(), setContainerType(), setDescription(), setTitle(), and setUniqueField().

Referenced by ilObjCourseGrouping().

254  {
255  global $ilObjDataCache,$ilDB;
256 
257  $query = "SELECT * FROM object_data ".
258  "WHERE obj_id = ".$ilDB->quote($this->getId() ,'integer')." ";
259 
260  $res = $this->db->query($query);
261  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
262  {
263  $this->setTitle($row->title);
264  $this->setDescription($row->description);
265  }
266 
267  $query = "SELECT * FROM crs_groupings ".
268  "WHERE crs_grp_id = ".$ilDB->quote($this->getId(),'integer')." ";
269  $res = $ilDB->query($query);
270 
271  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
272  {
273  $this->setUniqueField($row->unique_field);
274  $this->setContainerRefId($row->crs_ref_id);
275  $this->setContainerObjId($row->crs_id);
276  $this->setContainerType($ilObjDataCache->lookupType($this->getContainerObjId()));
277  }
278 
279  return true;
280  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setContainerObjId()

ilObjCourseGrouping::setContainerObjId (   $a_obj_id)

Definition at line 77 of file class.ilObjCourseGrouping.php.

Referenced by read().

78  {
79  $this->obj_id = $a_obj_id;
80  }
+ Here is the caller graph for this function:

◆ setContainerRefId()

ilObjCourseGrouping::setContainerRefId (   $a_ref_id)

Definition at line 69 of file class.ilObjCourseGrouping.php.

Referenced by read().

70  {
71  $this->ref_id = $a_ref_id;
72  }
+ Here is the caller graph for this function:

◆ setContainerType()

ilObjCourseGrouping::setContainerType (   $a_type)

Definition at line 89 of file class.ilObjCourseGrouping.php.

Referenced by read().

90  {
91  $this->container_type = $a_type;
92  }
+ Here is the caller graph for this function:

◆ setDescription()

ilObjCourseGrouping::setDescription (   $a_desc)

Definition at line 111 of file class.ilObjCourseGrouping.php.

Referenced by read().

112  {
113  $this->description = $a_desc;
114  }
+ Here is the caller graph for this function:

◆ setId()

ilObjCourseGrouping::setId (   $a_id)

Definition at line 60 of file class.ilObjCourseGrouping.php.

Referenced by create(), and ilObjCourseGrouping().

61  {
62  $this->id = $a_id;
63  }
+ Here is the caller graph for this function:

◆ setTitle()

ilObjCourseGrouping::setTitle (   $a_title)

Definition at line 103 of file class.ilObjCourseGrouping.php.

Referenced by read().

104  {
105  $this->title = $a_title;
106  }
+ Here is the caller graph for this function:

◆ setType()

ilObjCourseGrouping::setType (   $a_type)

Definition at line 94 of file class.ilObjCourseGrouping.php.

Referenced by ilObjCourseGrouping().

95  {
96  $this->type = $a_type;
97  }
+ Here is the caller graph for this function:

◆ setUniqueField()

ilObjCourseGrouping::setUniqueField (   $a_uni)

Definition at line 119 of file class.ilObjCourseGrouping.php.

Referenced by read().

120  {
121  $this->unique_field = $a_uni;
122  }
+ Here is the caller graph for this function:

◆ update()

ilObjCourseGrouping::update ( )

Definition at line 209 of file class.ilObjCourseGrouping.php.

References $query, $res, getDescription(), getId(), getTitle(), getType(), and getUniqueField().

210  {
211  global $ilDB;
212 
213  if($this->getId() and $this->getType() === 'crsg')
214  {
215  // UPDATe object_data
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')." ";
221  $res = $ilDB->manipulate($query);
222 
223  // UPDATE crs_groupings
224  $query = "UPDATE crs_groupings ".
225  "SET unique_field = ".$ilDB->quote($this->getUniqueField(),'text')." ".
226  "WHERE crs_grp_id = ".$ilDB->quote($this->getId(),'integer')." ";
227  $res = $ilDB->manipulate($query);
228 
229  // UPDATE conditions
230  $query = "UPDATE conditions ".
231  "SET value = ".$ilDB->quote($this->getUniqueField(),'text')." ".
232  "WHERE trigger_obj_id = ".$ilDB->quote($this->getId(),'integer')." ".
233  "AND trigger_type = 'crsg'";
234  $res = $ilDB->manipulate($query);
235 
236  return true;
237  }
238  return false;
239  }
+ Here is the call graph for this function:

Field Documentation

◆ $assignedObjects

ilObjCourseGrouping::$assignedObjects = array()
staticprotected

Definition at line 38 of file class.ilObjCourseGrouping.php.

◆ $db

ilObjCourseGrouping::$db

Definition at line 36 of file class.ilObjCourseGrouping.php.


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