Public Member Functions | Data Fields

ilObjCourseGrouping Class Reference

Public Member Functions

 ilObjCourseGrouping ($a_id=0)
 Constructor public.
 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.
 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)
 _isInGrouping ($a_crs_id)
 _checkCondition ($trigger_obj_id, $operator, $value)
 _getGroupingCourseIds ($a_course_id)
 Get all ids of courses that are grouped with another course static.
 _checkGroupingDependencies (&$container_obj)
 _getGroupingItemsAsString (&$container_obj)

Data Fields

 $db

Detailed Description

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


Member Function Documentation

ilObjCourseGrouping::__addCondition ( a_target_ref_id,
a_target_obj_id 
)

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

References getId(), and getUniqueField().

Referenced by assign().

        {
                include_once './classes/class.ilConditionHandler.php';

                $tmp_condh =& new ilConditionHandler();
                $tmp_condh->enableAutomaticValidation(false);

                $tmp_condh->setTargetRefId($a_target_ref_id);
                $tmp_condh->setTargetObjId($a_target_obj_id);
                $tmp_condh->setTargetType('crs');
                $tmp_condh->setTriggerRefId(0);
                $tmp_condh->setTriggerObjId($this->getId());
                $tmp_condh->setTriggerType('crsg');
                $tmp_condh->setOperator('not_member');
                $tmp_condh->setValue($this->getUniqueField());

                if(!$tmp_condh->checkExists())
                {
                        $tmp_condh->storeCondition();

                        return true;
                }
                return false;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjCourseGrouping::_checkAccess ( grouping_id  ) 

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

References $tree, and ilObjCourseGrouping().

Referenced by ilObjCourseGroupingGUI::listGroupings().

        {
                global $ilAccess,$tree;

                $tmp_grouping_obj = new ilObjCourseGrouping($grouping_id);

                $found_invisible = false;
                foreach($tmp_grouping_obj->getAssignedItems() as $condition)
                {
                        if(!$ilAccess->checkAccess('write','',$condition['target_ref_id']))
                        {
                                $found_invisible = true;
                                break;
                        }
                }
                return $found_invisible ? false : true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjCourseGrouping::_checkCondition ( trigger_obj_id,
operator,
value 
)

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

        {
                // in the moment i alway return true, there are some problems with presenting the condition if it fails,
                // only course register class check manually if this condition is fullfilled
                return true;
        }

ilObjCourseGrouping::_checkGroupingDependencies ( &$  container_obj  ) 

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

References $lng, $tree, ilConditionHandler::_getConditionsOfTarget(), ilConditionHandler::_getConditionsOfTrigger(), ilObjGroup::_isMember(), and ilCourseMembers::_isMember().

Referenced by ilCourseRegisterGUI::__validateStatus(), and ilRegisterGUI::showRegistrationForm().

        {
                global $ilUser,$lng,$tree;

                include_once './classes/class.ilConditionHandler.php';

                $trigger_ids = array();
                foreach(ilConditionHandler::_getConditionsOfTarget($container_obj->getId(),$container_obj->getType()) as $condition)
                {
                        if($condition['operator'] == 'not_member')
                        {
                                $trigger_ids[] = $condition['trigger_obj_id'];
                                break;
                        }
                }
                if(!count($trigger_ids))
                {
                        return true;
                }

                foreach($trigger_ids as $trigger_id)
                {
                        foreach(ilConditionHandler::_getConditionsOfTrigger('crsg',$trigger_id) as $condition)
                        {
                                // Handle deleted items
                                if($tree->isDeleted($condition['target_ref_id']))
                                {
                                        continue;
                                }
                                if($condition['operator'] == 'not_member')
                                {
                                        switch($condition['value'])
                                        {
                                                case 'matriculation':
                                                        if(!strlen($ilUser->getMatriculation()))
                                                        {
                                                                if(!$matriculation_message)
                                                                {
                                                                        $matriculation_message = $lng->txt('crs_grp_matriculation_required');
                                                                }
                                                        }
                                        }
                                        if($container_obj->getType() == 'crs')
                                        {
                                                if(ilCourseMembers::_isMember($ilUser->getId(),$condition['target_obj_id'],$condition['value']))
                                                {
                                                        if(!$assigned_message)
                                                        {
                                                                $assigned_message = $lng->txt('crs_grp_already_assigned');
                                                        }
                                                }
                                        }
                                        else
                                        {
                                                if(ilObjGroup::_isMember($ilUser->getId(),$condition['target_ref_id'],$condition['value']))
                                                {
                                                        if(!$assigned_message)
                                                        {
                                                                $assigned_message = $lng->txt('crs_grp_already_assigned');
                                                        }
                                                }

                                        }
                                }
                        }
                }
                if($matriculation_message)
                {
                        $container_obj->appendMessage($matriculation_message);
                        return false;
                }
                elseif($assigned_message)
                {
                        $container_obj->appendMessage($assigned_message);
                        return false;
                }
                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjCourseGrouping::_deleteAll ( a_course_id  ) 

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

References $query, and _getGroupings().

Referenced by ilObjCourse::delete().

        {
                global $ilDB;

                // DELETE CONDITIONS
                foreach($groupings = ilObjCourseGrouping::_getGroupings($a_course_id) as $grouping_id)
                {
                        include_once './classes/class.ilConditionHandler.php';

                        $condh =& new ilConditionHandler();
                        $condh->deleteByObjId($grouping_id);
                }

                $query = "DELETE FROM crs_groupings ".
                        "WHERE crs_id = '".$a_course_id."'";

                $ilDB->query($query);

                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjCourseGrouping::_getGroupingCourseIds ( a_course_id  ) 

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

Parameters:
integer object_id of one course
array integer ids of courses or empty array if course is not in grouping

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

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

Referenced by ilObjCourseGUI::__showWaitingList().

        {
                include_once './classes/class.ilConditionHandler.php';

                // get all grouping ids the course is assigned to
                foreach(ilConditionHandler::_getConditionsOfTarget($a_course_id,'crs') as $condition)
                {
                        if($condition['trigger_type'] == 'crsg')
                        {
                                foreach(ilConditionHandler::_getConditionsOfTrigger('crsg',$condition['trigger_obj_id']) as $target_condition)
                                {
                                        $course_ids[] = array('id'                      => $target_condition['target_obj_id'],
                                                                                  'unique'              => $target_condition['value']);
                                }
                        }
                }
                return $course_ids ? $course_ids : array();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjCourseGrouping::_getGroupingItemsAsString ( &$  container_obj  ) 

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

References $tree, ilConditionHandler::_getConditionsOfTarget(), and ilConditionHandler::_getConditionsOfTrigger().

Referenced by ilCourseRegisterGUI::showRegistrationForm(), and ilRegisterGUI::showRegistrationForm().

        {
                global $tree,$ilObjDataCache,$ilAccess,$tree;

                include_once './classes/class.ilConditionHandler.php';

                $trigger_ids = array();
                foreach(ilConditionHandler::_getConditionsOfTarget($container_obj->getId(),$container_obj->getType()) as $condition)
                {
                        if($condition['operator'] == 'not_member')
                        {
                                $trigger_ids[] = $condition['trigger_obj_id'];
                        }
                }
                if(!count($trigger_ids))
                {
                        return false;
                }
                foreach($trigger_ids as $trigger_id)
                {
                        foreach(ilConditionHandler::_getConditionsOfTrigger('crsg',$trigger_id) as $condition)
                        {
                                // Continue if trigger is deleted
                                if($tree->isDeleted($condition['target_ref_id']))
                                {
                                        continue;
                                }

                                if($condition['operator'] == 'not_member')
                                {
                                        if(!$hash_table[$condition['target_ref_id']])
                                        {
                                                $courses .= (' <br/>'.$ilObjDataCache->lookupTitle($condition['target_obj_id']));
                                        }
                                        $hash_table[$condition['target_ref_id']] = true;
                                }
                        }
                }
                return $courses;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjCourseGrouping::_getGroupings ( a_course_id  ) 

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

References $query, $res, and $row.

Referenced by _deleteAll().

        {
                global $ilDB;

                $query = "SELECT * FROM crs_groupings ".
                        "WHERE crs_id = '".$a_course_id."'";

                $res = $ilDB->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $groupings[] = $row->crs_grp_id;
                }
                return $groupings ? $groupings : array();
        }

Here is the caller graph for this function:

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 303 of file class.ilObjCourseGrouping.php.

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

Referenced by ilObjCourseGroupingGUI::listGroupings().

        {
                global $ilObjDataCache,$ilAccess,$ilDB;

                $container_type = $ilObjDataCache->lookupType($a_obj_id) == 'grp' ? 'grp' : 'crs';


                // First get all groupings
                $query = "SELECT * FROM object_data WHERE type = 'crsg' ORDER BY title";
                $res = $ilDB->query($query);
                $groupings = array();
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $groupings[] = $row->obj_id;
                }

                //check access
                foreach($groupings as $grouping_id)
                {
                        $tmp_grouping_obj = new ilObjCourseGrouping($grouping_id);

                        // Check container type
                        if($tmp_grouping_obj->getContainerType() != $container_type)
                        {
                                continue;
                        }
                        // Check if container is current container
                        if($tmp_grouping_obj->getContainerObjId() == $a_obj_id)
                        {
                                $visible_groupings[] = $grouping_id;
                                continue;
                        }
                        // check if items are assigned
                        if(count($items = $tmp_grouping_obj->getAssignedItems()))
                        {
                                foreach($items as $condition_data)
                                {
                                        if($ilAccess->checkAccess('write','',$condition_data['target_ref_id']))
                                        {
                                                $visible_groupings[] = $grouping_id;
                                                break;
                                        }
                                }
                                
                        }                               
                }
                return $visible_groupings ? $visible_groupings : array();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjCourseGrouping::_isInGrouping ( a_crs_id  ) 

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

References ilConditionHandler::_getConditionsOfTarget().

        {
                include_once './classes/class.ilConditionHandler.php';

                foreach(ilConditionHandler::_getConditionsOfTarget($a_crs_id,'crs') as $cond)
                {
                        if($cond['operator'] == 'not_member')
                        {
                                return true;
                        }
                }
                return false;
        }

Here is the call graph for this function:

ilObjCourseGrouping::assign ( a_crs_ref_id,
a_course_id 
)

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

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

        {
                // Add the parent course of grouping
                $this->__addCondition($this->getContainerRefId(),$this->getContainerObjId());
                $this->__addCondition($a_crs_ref_id,$a_course_id);

                return true;
        }

Here is the call graph for this function:

ilObjCourseGrouping::create ( a_course_ref_id,
a_course_id 
)

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

References $query, $res, $row, getDescription(), getId(), getTitle(), ilUtil::prepareDBString(), and setId().

        {
                global $ilUser;

                // INSERT IN object_data
                $query = "INSERT INTO object_data ".
                        "(type,title,description,owner,create_date,last_update,import_id) ".
                        "VALUES ".
                        "('".$this->type."',".$this->db->quote($this->getTitle()).",'".ilUtil::prepareDBString($this->getDescription())."',".
                        "'".$ilUser->getId()."',now(),now(),'')";
                        
                $this->db->query($query);

                // READ this id
                $query = "SELECT LAST_INSERT_ID() as last";
                $res = $this->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $this->setId($row->last);
                }


                // INSERT in crs_groupings
                $query = "INSERT INTO crs_groupings ".
                        "SET crs_ref_id = '".$a_course_ref_id."', ".
                        "crs_id = '".$a_course_id."',".
                        "crs_grp_id = '".$this->getId()."', ".
                        "unique_field = '".$this->getUniqueField()."'";

                $this->db->query($query);

                return $this->getId();
        }

Here is the call graph for this function:

ilObjCourseGrouping::deassign ( a_crs_ref_id,
a_course_id 
)

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

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

        {
                include_once './classes/class.ilConditionHandler.php';


                $condh =& new ilConditionHandler();

                // DELETE also original course if its the last
                if($this->getCountAssignedCourses() == 2)
                {
                        $condh->deleteByObjId($this->getId());

                        return true;
                }
                
                foreach(ilConditionHandler::_getConditionsOfTrigger('crsg',$this->getId()) as $cond_data)
                {

                        if($cond_data['target_ref_id'] == $a_crs_ref_id and
                           $cond_data['target_obj_id'] == $a_course_id)
                        {
                                $condh->deleteCondition($cond_data['id']);
                        }
                }

                return true;
                        
        }

Here is the call graph for this function:

ilObjCourseGrouping::delete (  ) 

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

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

        {
                include_once './classes/class.ilConditionHandler.php';

                if($this->getId() and $this->getType() === 'crsg')
                {
                        $query = "DELETE FROM object_data WHERE obj_id = '".$this->getId()."'";
                        $this->db->query($query);

                        $query = "DELETE FROM crs_groupings ".
                                "WHERE crs_grp_id = '".$this->getId()."'";
                        $this->db->query($query);

                        // Delete conditions
                        $condh =& new ilConditionHandler();
                        $condh->deleteByObjId($this->getId());

                        return true;
                }
                return false;
        }

Here is the call graph for this function:

ilObjCourseGrouping::getAssignedItems (  ) 

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

References $tree, ilConditionHandler::_getConditionsOfTrigger(), getId(), and getType().

Referenced by getCountAssignedItems(), and isAssigned().

        {
                global $tree;

                include_once './classes/class.ilConditionHandler.php';
                $condition_data = ilConditionHandler::_getConditionsOfTrigger($this->getType(),$this->getId());
                $conditions = array();
                foreach($condition_data as $condition)
                {
                        if($tree->isDeleted($condition['target_ref_id']))
                        {
                                continue;
                        }
                        $conditions[] = $condition;
                }
                return count($conditions) ? $conditions : array();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjCourseGrouping::getContainerObjId (  ) 

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

Referenced by assign().

        {
                return $this->obj_id;
        }

Here is the caller graph for this function:

ilObjCourseGrouping::getContainerRefId (  ) 

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

Referenced by assign().

        {
                return $this->ref_id;
        }

Here is the caller graph for this function:

ilObjCourseGrouping::getContainerType (  ) 

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

        {
                return $this->container_type;
        }

ilObjCourseGrouping::getCountAssignedItems (  ) 

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

References getAssignedItems().

        {
                return count($this->getAssignedItems());
        }

Here is the call graph for this function:

ilObjCourseGrouping::getDescription (  ) 

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

Referenced by create(), and update().

        {
                return $this->description;
        }

Here is the caller graph for this function:

ilObjCourseGrouping::getId (  ) 

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

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

        {
                return $this->id;
        }

Here is the caller graph for this function:

ilObjCourseGrouping::getTitle (  ) 

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

Referenced by create(), and update().

        {
                return $this->title;
        }

Here is the caller graph for this function:

ilObjCourseGrouping::getType (  ) 

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

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

        {
                return $this->type;
        }

Here is the caller graph for this function:

ilObjCourseGrouping::getUniqueField (  ) 

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

Referenced by __addCondition().

        {
                return $this->unique_field;
        }

Here is the caller graph for this function:

ilObjCourseGrouping::ilObjCourseGrouping ( a_id = 0  ) 

Constructor public.

Parameters:
integer reference_id or object_id
boolean treat 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().

        {
                global $ilDB;

                $this->setType('crsg');
                $this->db =& $ilDB;

                $this->setId($a_id);

                if($a_id)
                {
                        $this->read();
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjCourseGrouping::isAssigned ( a_course_id  ) 

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

References getAssignedItems().

        {
                foreach($this->getAssignedItems() as $condition_data)
                {
                        if($a_course_id == $condition_data['target_obj_id'])
                        {
                                return true;
                        }
                }
                return false;
        }

Here is the call graph for this function:

ilObjCourseGrouping::read (  ) 

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

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

Referenced by ilObjCourseGrouping().

        {
                global $ilObjDataCache;

                $query = "SELECT * FROM object_data ".
                        "WHERE obj_id = '".$this->getId()."'";

                $res = $this->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $this->setTitle($row->title);
                        $this->setDescription($row->description);
                }

                $query = "SELECT * FROM crs_groupings ".
                        "WHERE crs_grp_id = '".$this->getId()."'";
                $res = $this->db->query($query);

                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $this->setUniqueField($row->unique_field);
                        $this->setContainerRefId($row->crs_ref_id);
                        $this->setContainerObjId($row->crs_id);
                        $this->setContainerType($ilObjDataCache->lookupType($this->getContainerObjId()));
                }

                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjCourseGrouping::setContainerObjId ( a_obj_id  ) 

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

Referenced by read().

        {
                $this->obj_id = $a_obj_id;
        }

Here is the caller graph for this function:

ilObjCourseGrouping::setContainerRefId ( a_ref_id  ) 

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

Referenced by read().

        {
                $this->ref_id = $a_ref_id;
        }

Here is the caller graph for this function:

ilObjCourseGrouping::setContainerType ( a_type  ) 

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

Referenced by read().

        {
                $this->container_type = $a_type;
        }

Here is the caller graph for this function:

ilObjCourseGrouping::setDescription ( a_desc  ) 

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

Referenced by read().

        {
                $this->description = $a_desc;
        }

Here is the caller graph for this function:

ilObjCourseGrouping::setId ( a_id  ) 

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

Referenced by create(), and ilObjCourseGrouping().

        {
                $this->id = $a_id;
        }

Here is the caller graph for this function:

ilObjCourseGrouping::setTitle ( a_title  ) 

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

Referenced by read().

        {
                $this->title = $a_title;
        }

Here is the caller graph for this function:

ilObjCourseGrouping::setType ( a_type  ) 

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

Referenced by ilObjCourseGrouping().

        {
                $this->type = $a_type;
        }

Here is the caller graph for this function:

ilObjCourseGrouping::setUniqueField ( a_uni  ) 

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

Referenced by read().

        {
                $this->unique_field = $a_uni;
        }

Here is the caller graph for this function:

ilObjCourseGrouping::update (  ) 

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

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

        {
                if($this->getId() and $this->getType() === 'crsg')
                {
                        // UPDATe object_data
                        $query = "UPDATE object_data ".
                                "SET title = '".ilUtil::prepareDBString($this->getTitle())."', ".
                                "description = '".ilUtil::prepareDBString($this->getDescription())."' ".
                                "WHERE obj_id = '".$this->getId()."' ".
                                "AND type = '".$this->getType()."'";

                        $this->db->query($query);

                        // UPDATE crs_groupings
                        $query = "UPDATE crs_groupings ".
                                "SET unique_field = '".$this->getUniqueField()."' ".
                                "WHERE crs_grp_id = '".$this->getId()."'";

                        $this->db->query($query);

                        // UPDATE conditions
                        $query = "UPDATE conditions ".
                                "SET value = '".$this->getUniqueField()."' ".
                                "WHERE trigger_obj_id = '".$this->getId()."' ".
                                "AND trigger_type = 'crsg'";
                        $this->db->query($query);

                        return true;
                }
                return false;
        }

Here is the call graph for this function:


Field Documentation

ilObjCourseGrouping::$db

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


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