Public Member Functions | Data Fields

ilCourseMembers Class Reference

Public Member Functions

 ilCourseMembers (&$course_obj)
 addDesktopItem ($a_usr_id)
 dropDesktopItem ($a_usr_id)
 add (&$user_obj, $a_role, $a_status=0, $a_passed=0)
 update ($a_usr_id, $a_role, $a_status, $a_passed)
 deleteAllEntries ()
 deleteMembers ($a_usr_ids)
 delete ($a_usr_id)
 _deleteUser ($a_usr_id)
 getAssignedUsers ()
 getUserData ($a_usr_id)
 getCountMembers ()
 getMembers ($a_all=true)
 getAdmins ()
 getTutors ()
 isAdmin ($a_usr_id)
 isMember ($a_usr_id)
 isTutor ($a_usr_id)
 isAssigned ($a_usr_id)
 isBlocked ($a_usr_id)
 _isBlocked ($a_obj_id, $a_usr_id)
 Static version of isBlocked() to avoid instantiation of course object.
 hasAccess ($a_usr_id)
 getCountPassed ()
 checkLastAdmin ($a_usr_ids)
 getSubscribers ()
 getCountSubscribers ()
 getSubscriberData ($a_usr_id)
 assignSubscribers ($a_usr_ids)
 assignSubscriber ($a_usr_id, $a_role=0, $a_status=0)
 autoFillSubscribers ()
 addSubscriber ($a_usr_id)
 updateSubscriptionTime ($a_usr_id, $a_subtime)
 deleteSubscriber ($a_usr_id)
 deleteSubscribers ($a_usr_ids)
 isSubscriber ($a_usr_id)
 _isSubscriber ($a_obj_id, $a_usr_id)
 sendNotification ($a_type, $a_usr_id)
 sendNotificationToAdmins ($a_usr_id)
 sendSubscriptionRequestToAdmins ($a_usr_id)
 sendUnsubscribeNotificationToAdmins ($a_usr_id)
 __getDefaultAdminStatus ()
 __getDefaultMemberStatus ()
 __getDefaultTutorStatus ()
 __createMemberEntry ($a_usr_id, $a_role, $a_status, $a_passed)
 __read ($a_usr_id)
 __readSubscribers ()
 __readSubscriberData ($a_usr_id)
 _hasPassed ($a_obj_id, $a_usr_id)
 _setPassed ($a_obj_id, $a_usr_id)
 _updatePassed ($a_obj_id, $a_usr_id, $a_passed)
 _updateStatus ($a_obj_id, $a_usr_id, $a_status)
 __buildStatusBody (&$user_obj)
 _isMember ($a_usr_id, $a_course_id, $a_field= '')
 check Membership by given field
 _getMembers ($a_obj_id)
 __purgeDeleted ()

Data Fields

 $course_obj
 $ilErr
 $ilDB
 $lng
 $member_data
 $subscribers

Detailed Description

Definition at line 35 of file class.ilCourseMembers.php.


Member Function Documentation

ilCourseMembers::__buildStatusBody ( &$  user_obj  ) 

Definition at line 996 of file class.ilCourseMembers.php.

References __read().

Referenced by sendNotification().

        {
                $this->__read($user_obj->getId());

                $body = $this->lng->txt('crs_status_changed_body').':<br />';
                $body .= $this->lng->txt('login').': '.$user_obj->getLogin().'<br />';
                $body .= $this->lng->txt('role').': ';

                switch($this->member_data['role'])
                {
                        case $this->ROLE_MEMBER:
                                $body .= $this->lng->txt('crs_member').'<br />';
                                break;

                        case $this->ROLE_TUTOR:
                                $body .= $this->lng->txt('crs_tutor').'<br />';
                                break;

                        case $this->ROLE_ADMIN:
                                $body .= $this->lng->txt('crs_admin').'<br />';
                                break;
                }
                $body .= $this->lng->txt('status').': ';
                switch($this->member_data['status'])
                {
                        case $this->STATUS_NOTIFY:
                                $body .= $this->lng->txt("crs_notify").'<br />';
                                break;

                        case $this->STATUS_NO_NOTIFY:
                                $body .= $this->lng->txt("crs_no_notify").'<br />';
                                break;

                        case $this->STATUS_BLOCKED:
                                $body .= $this->lng->txt("crs_blocked").'<br />';
                                break;

                        case $this->STATUS_UNBLOCKED:
                                $body .= $this->lng->txt("crs_unblocked").'<br />';
                                break;
                }
                $passed = $this->member_data['passed'] ? $this->lng->txt('yes') : $this->lng->txt('no');
                $body .= $this->lng->txt('crs_passed').': '.$passed.'<br />';

                return $body;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::__createMemberEntry ( a_usr_id,
a_role,
a_status,
a_passed 
)

Definition at line 864 of file class.ilCourseMembers.php.

References $query, and $res.

Referenced by add().

        {
                $query = "INSERT INTO crs_members ".
                        "SET usr_id = '".$a_usr_id."', ".
                        "obj_id = '".$this->course_obj->getId()."', ".
                        "status = '".$a_status."', ".
                        "role = '".$a_role."', ".
                        "passed = '".$a_passed."'";

                $res = $this->ilDB->query($query);

                return true;
        }

Here is the caller graph for this function:

ilCourseMembers::__getDefaultAdminStatus (  ) 

Definition at line 851 of file class.ilCourseMembers.php.

Referenced by add().

        {
                return $this->STATUS_NOTIFY;
        }

Here is the caller graph for this function:

ilCourseMembers::__getDefaultMemberStatus (  ) 

Definition at line 855 of file class.ilCourseMembers.php.

Referenced by add().

        {
                return $this->STATUS_UNBLOCKED;
        }

Here is the caller graph for this function:

ilCourseMembers::__getDefaultTutorStatus (  ) 

Definition at line 859 of file class.ilCourseMembers.php.

Referenced by add().

        {
                return $this->STATUS_NO_NOTIFY;
        }

Here is the caller graph for this function:

ilCourseMembers::__purgeDeleted (  ) 

Definition at line 1103 of file class.ilCourseMembers.php.

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

Referenced by ilCourseMembers().

        {
                global $ilDB;

                $query = "SELECT cs.usr_id as id FROM crs_members as cs ".
                        "LEFT JOIN usr_data as ud ".
                        "ON cs.usr_id = ud.usr_id ".
                        "WHERE obj_id = '".$this->course_obj->getId()."' ".
                        "AND ud.usr_id IS NULL";

                $res = $ilDB->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $query = "DELETE FROM crs_members ".
                                "WHERE usr_id = '".$row->id."'";
                        $ilDB->query($query);
                }
        }

Here is the caller graph for this function:

ilCourseMembers::__read ( a_usr_id  ) 

Definition at line 878 of file class.ilCourseMembers.php.

References $query, $res, $row, and ilObjUser::_lookupLogin().

Referenced by __buildStatusBody(), delete(), getUserData(), isAdmin(), isBlocked(), isMember(), isTutor(), and update().

        {
                if(!ilObjUser::_lookupLogin($a_usr_id))
                {
                        return false;
                }

                $query = "SELECT * FROM crs_members ".
                        "WHERE usr_id = '".$a_usr_id."' ".
                        "AND obj_id = '".$this->course_obj->getId()."'";

                $res = $this->ilDB->query($query);

                $this->member_data = array();
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $this->member_data["usr_id"]    = $row->usr_id;
                        $this->member_data["role"]              = $row->role;
                        $this->member_data["status"]    = $row->status;
                        $this->member_data['passed']    = $row->passed;
                }
                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::__readSubscriberData ( a_usr_id  ) 

Definition at line 924 of file class.ilCourseMembers.php.

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

Referenced by getSubscriberData().

        {
                $query = "SELECT * FROM crs_subscribers ".
                        "WHERE obj_id = '".$this->course_obj->getId()."' ".
                        "AND usr_id = '".$a_usr_id."'";

                $res = $this->ilDB->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $data["time"] = $row->sub_time;
                        $data["usr_id"] = $row->usr_id;
                }
                return $data ? $data : array();
        }

Here is the caller graph for this function:

ilCourseMembers::__readSubscribers (  ) 

Definition at line 903 of file class.ilCourseMembers.php.

References $query, $res, $row, deleteSubscriber(), and ilObjectFactory::getInstanceByObjId().

Referenced by autoFillSubscribers(), and getSubscribers().

        {
                $this->subscribers = array();

                $query = "SELECT usr_id FROM crs_subscribers ".
                        "WHERE obj_id = '".$this->course_obj->getId()."' ".
                        "ORDER BY sub_time ";

                $res = $this->ilDB->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        // DELETE SUBSCRIPTION IF USER HAS BEEN DELETED
                        if(!ilObjectFactory::getInstanceByObjId($a_usr_id,false))
                        {
                                $this->deleteSubscriber($a_usr_id);
                        }
                        $this->subscribers[] = $row->usr_id;
                }
                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::_deleteUser ( a_usr_id  ) 

Definition at line 343 of file class.ilCourseMembers.php.

References $ilDB, and $query.

        {
                global $ilDB;

                $query = "DELETE FROM crs_members WHERE usr_id = '".$a_usr_id."'";
                $ilDB->query($query);

                $query = "DELETE FROM crs_subscribers WHERE usr_id = '".$a_usr_id."'";
                $ilDB->query($query);

                include_once './course/classes/class.ilCourseWaitingList.php';
                ilCourseWaitingList::_deleteUser($a_usr_id);
        }

ilCourseMembers::_getMembers ( a_obj_id  ) 

Definition at line 1086 of file class.ilCourseMembers.php.

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

Referenced by ilLPStatusManual::__getCourseInProgress(), ilLPStatusCollection::_getCompleted(), ilLPStatusCollection::_getFailed(), ilLPStatusObjectives::_getInProgress(), ilLPStatusCollection::_getInProgress(), ilLPStatusObjectives::_getNotAttempted(), ilLPStatusManual::_getNotAttempted(), ilLPStatusEvent::_getNotAttempted(), and ilLPStatusCollection::_getNotAttempted().

        {
                global $ilDB;
                // In the moment all users that have entries in crs_members
                
                $query = "SELECT DISTINCT(crs_members.usr_id) AS usr_id FROM crs_members JOIN usr_data ".
                        "WHERE crs_members.usr_id = usr_data.usr_id ".
                        "AND obj_id = '".$a_obj_id."'";

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

Here is the caller graph for this function:

ilCourseMembers::_hasPassed ( a_obj_id,
a_usr_id 
)

Definition at line 939 of file class.ilCourseMembers.php.

References $ilDB, $query, and $res.

Referenced by ilObjCourse::_checkCondition(), and _setPassed().

        {
                global $ilDB;

                $query = "SELECT * FROM crs_members ".
                        "WHERE obj_id = '".$a_obj_id."' ".
                        "AND usr_id = '".$a_usr_id."' ".
                        "AND passed = 1";

                
                $res = $ilDB->query($query);
                
                return $res->numRows() ? true : false;
        }

Here is the caller graph for this function:

ilCourseMembers::_isBlocked ( a_obj_id,
a_usr_id 
)

Static version of isBlocked() to avoid instantiation of course object.

Parameters:
int id of user
Returns:
boolean

Definition at line 455 of file class.ilCourseMembers.php.

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

Referenced by ilObjCourseAccess::_checkAccess(), ilObjCourseListGUI::getProperties(), and ilRepositoryExplorer::isClickable().

        {
                global $ilDB;

                $query = "SELECT * FROM crs_members ".
                        "WHERE usr_id = '".$a_usr_id."' ".
                        "AND obj_id = '".$a_obj_id."'";

                $res = $ilDB->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        return $row->status == 3 ? true : false;
                }
                return false;
        }

Here is the caller graph for this function:

ilCourseMembers::_isMember ( a_usr_id,
a_course_id,
a_field = '' 
)

check Membership by given field

Parameters:
int usr_id
int obj_id
string field (login,email or matriculation) public

Definition at line 1051 of file class.ilCourseMembers.php.

References $ilDB, $query, $res, $tmp_user, and ilObjectFactory::getInstanceByObjId().

Referenced by ilObjCourseGUI::__showWaitingList(), ilObjCourseAccess::_checkAccess(), ilObjCourseGrouping::_checkGroupingDependencies(), ilFeedbackGUI::_isRequiredFeedbackOnLogin(), ilFeedback::canVote(), and ilObjCourseGUI::getTabs().

        {
                global $ilUser,$ilDB;

                // get specific user data
                $tmp_user =& ilObjectFactory::getInstanceByObjId($a_usr_id);
                switch($a_field)
                {
                        case 'login':
                                $and = "AND login = '".$tmp_user->getLogin()."' ";
                                break;
                        case 'email':
                                $and = "AND email = '".$tmp_user->getEmail()."' ";
                                break;
                        case 'matriculation':
                                $and = "AND matriculation = '".$tmp_user->getMatriculation()."' ";
                                break;

                        default:
                                $and = "AND cm.usr_id = '".$a_usr_id."'";
                                break;
                }

                // check if entry exists
                $query = "SELECT * FROM crs_members as cm, usr_data as ud ".
                        "WHERE cm.usr_id = ud.usr_id ".
                        "AND cm.obj_id = '".$a_course_id."' ".
                        $and;


                $res = $ilDB->query($query);

                return $res->numRows() ? true : false;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::_isSubscriber ( a_obj_id,
a_usr_id 
)

Definition at line 675 of file class.ilCourseMembers.php.

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

Referenced by ilObjCourseListGUI::getProperties().

        {
                global $ilDB;

                $query = "SELECT * FROM crs_subscribers ".
                        "WHERE usr_id = '".$a_usr_id."' ".
                        "AND obj_id = '".$a_obj_id."'";

                $res = $ilDB->query($query);

                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        return true;
                }
                return false;
        }

Here is the caller graph for this function:

ilCourseMembers::_setPassed ( a_obj_id,
a_usr_id 
)

Definition at line 954 of file class.ilCourseMembers.php.

References $ilDB, $query, and _hasPassed().

Referenced by ilCourseContentInterface::__readStatus().

        {
                global $ilDB;

                if(!ilCourseMembers::_hasPassed($a_obj_id,$a_usr_id))
                {
                        $query = "UPDATE crs_members ".
                                "SET passed = 1 WHERE usr_id = '".$a_usr_id."' ".
                                "AND obj_id = '".$a_obj_id."'";
                        
                        $ilDB->query($query);
                        
                        return true;
                }
                return false;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::_updatePassed ( a_obj_id,
a_usr_id,
a_passed 
)

Definition at line 971 of file class.ilCourseMembers.php.

References $ilDB, and $query.

Referenced by ilObjCourseGUI::updateMembersObject().

        {
                global $ilDB;

                $query = "UPDATE crs_members ".
                        "SET passed = '".(int) $a_passed."' ".
                        "WHERE obj_id = '".(int) $a_obj_id."' ".
                        "AND usr_id = '".(int) $a_usr_id."'";

                $ilDB->query($query);
        }

Here is the caller graph for this function:

ilCourseMembers::_updateStatus ( a_obj_id,
a_usr_id,
a_status 
)

Definition at line 983 of file class.ilCourseMembers.php.

References $ilDB, and $query.

Referenced by ilObjCourseGUI::updateMembersObject().

        {
                global $ilDB;

                $query = "UPDATE crs_members ".
                        "SET status = '".(int) $a_status."' ".
                        "WHERE obj_id = '".(int) $a_obj_id."' ".
                        "AND usr_id = '".(int) $a_usr_id."'";

                $ilDB->query($query);
        }               

Here is the caller graph for this function:

ilCourseMembers::add ( &$  user_obj,
a_role,
a_status = 0,
a_passed = 0 
)

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

References $rbacadmin, __createMemberEntry(), __getDefaultAdminStatus(), __getDefaultMemberStatus(), __getDefaultTutorStatus(), addDesktopItem(), and ilObjUser::updateActiveRoles().

Referenced by assignSubscriber().

        {
                global $rbacadmin;

                switch($a_role)
                {
                        case $this->ROLE_MEMBER:
                                if($a_status and ($a_status == $this->STATUS_BLOCKED or $a_status == $this->STATUS_UNBLOCKED))
                                {
                                        $status = $a_status;
                                }
                                else if($a_status)
                                {
                                        $this->ilErr->raiseError($this->lng->txt("crs_status_not_allowed",$this->ilErr->MESSAGE));
                                }
                                else
                                {
                                        $status = $this->__getDefaultMemberStatus();
                                }
                                $role = $this->course_obj->getDefaultMemberRole();
                                $passed = $a_passed;

                                $this->addDesktopItem($user_obj->getId());
                                break;

                        case $this->ROLE_ADMIN:
                                if($a_status and ($a_status == $this->STATUS_NOTIFY or $a_status == $this->STATUS_NO_NOTIFY))
                                {
                                        $status = $a_status;
                                }
                                else if($a_status)
                                {
                                        $this->ilErr->raiseError($this->lng->txt("crs_status_not_allowed",$this->ilErr->MESSAGE));
                                }
                                else
                                {
                                        $status = $this->__getDefaultAdminStatus();
                                }
                                $role = $this->course_obj->getDefaultAdminRole();
                                $passed = $a_passed;
                                $this->addDesktopItem($user_obj->getId());
                                break;

                        case $this->ROLE_TUTOR:
                                if($a_status and ($a_status == $this->STATUS_NOTIFY or $a_status == $this->STATUS_NO_NOTIFY))
                                {
                                        $status = $a_status;
                                }
                                else if($a_status)
                                {
                                        $this->ilErr->raiseError($this->lng->txt("crs_status_not_allowed",$this->ilErr->MESSAGE));
                                }
                                else
                                {
                                        $status = $this->__getDefaultTutorStatus();
                                }
                                $role = $this->course_obj->getDefaultTutorRole();
                                $passed = $a_passed;
                                $this->addDesktopItem($user_obj->getId());
                                break;
                                
                }
                // 1. create entry
                $this->__createMemberEntry($user_obj->getId(),$a_role,$status,$passed);

                $rbacadmin->assignUser($role,$user_obj->getId());
                ilObjUser::updateActiveRoles($user_obj->getId());

                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::addDesktopItem ( a_usr_id  ) 

Definition at line 82 of file class.ilCourseMembers.php.

References ilObjectFactory::getInstanceByObjId().

Referenced by add(), and update().

        {
                $user_obj =& ilObjectFactory::getInstanceByObjId($a_usr_id);

                if(!$user_obj->isDesktopItem($this->course_obj->getRefId(),'crs'))
                {
                        $user_obj->addDesktopItem($this->course_obj->getRefId(),'crs');
                }
                unset($user_obj);

                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::addSubscriber ( a_usr_id  ) 

Definition at line 604 of file class.ilCourseMembers.php.

References $query, and $res.

        {
                $query = "INSERT INTO crs_subscribers ".
                        " VALUES ('".$a_usr_id."','".$this->course_obj->getId()."','".time()."')";

                $res = $this->ilDB->query($query);

                return true;
        }

ilCourseMembers::assignSubscriber ( a_usr_id,
a_role = 0,
a_status = 0 
)

Definition at line 543 of file class.ilCourseMembers.php.

References add(), deleteSubscriber(), ilObjectFactory::getInstanceByObjId(), isAssigned(), and isSubscriber().

Referenced by assignSubscribers(), and autoFillSubscribers().

        {
                $a_role = $a_role ? $a_role : $this->ROLE_MEMBER;
                $a_status = $a_status ? $a_status : $this->STATUS_UNBLOCKED;

                $this->course_obj->setMessage("");


                if(!$this->isSubscriber($a_usr_id))
                {
                        $this->course_obj->appendMessage($this->lng->txt("crs_user_notsubscribed"));

                        return false;
                }
                if($this->isAssigned($a_usr_id))
                {
                        $tmp_obj = ilObjectFactory::getInstanceByObjId($a_usr_id);
                        $this->course_obj->appendMessage($tmp_obj->getLogin().": ".$this->lng->txt("crs_user_already_assigned"));
                        
                        return false;
                }

                if(!$tmp_obj =& ilObjectFactory::getInstanceByObjId($a_usr_id))
                {
                        $this->course_obj->appendMessage($this->lng->txt("crs_user_not_exists"));

                        return false;
                }

                $this->add($tmp_obj,$a_role,$a_status);
                $this->deleteSubscriber($a_usr_id);

                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::assignSubscribers ( a_usr_ids  ) 

Definition at line 527 of file class.ilCourseMembers.php.

References $id, and assignSubscriber().

        {
                if(!is_array($a_usr_ids) or !count($a_usr_ids))
                {
                        return false;
                }
                foreach($a_usr_ids as $id)
                {
                        if(!$this->assignSubscriber($id))
                        {
                                return false;
                        }
                }
                return true;
        }

Here is the call graph for this function:

ilCourseMembers::autoFillSubscribers (  ) 

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

References $counter, __readSubscribers(), assignSubscriber(), getCountMembers(), and sendNotification().

        {
                $this->__readSubscribers();

                $counter = 0;
                foreach($this->subscribers as $subscriber)
                {
                        if($this->course_obj->getSubscriptionMaxMembers() and
                           $this->course_obj->getSubscriptionMaxMembers() <= $this->getCountMembers())
                        {
                                return $counter;
                        }
                        if(!$this->assignSubscriber($subscriber))
                        {
                                continue;
                        }
                        else
                        {
                                $this->sendNotification($this->NOTIFY_ACCEPT_SUBSCRIBER,$subscriber);
                        }
                        ++$counter;
                }
                
                return $counter;
        }

Here is the call graph for this function:

ilCourseMembers::checkLastAdmin ( a_usr_ids  ) 

Definition at line 495 of file class.ilCourseMembers.php.

References getAdmins().

        {
                foreach($this->getAdmins() as $admin_id)
                {
                        if(!in_array($admin_id,$a_usr_ids))
                        {
                                return true;
                        }
                }
                return false;
        }

Here is the call graph for this function:

ilCourseMembers::delete ( a_usr_id  ) 

Definition at line 300 of file class.ilCourseMembers.php.

References $query, $rbacadmin, $res, __read(), dropDesktopItem(), and ilObjUser::updateActiveRoles().

        {
                global $rbacadmin;

                if(!$this->__read($a_usr_id))
                {
                        return true;
                }

                switch($this->member_data["role"])
                {
                        case $this->ROLE_ADMIN:
                                $role = $this->course_obj->getDefaultAdminRole();
                                break;


                        case $this->ROLE_TUTOR:
                                $role = $this->course_obj->getDefaultTutorRole();
                                break;
                                
                        case $this->ROLE_MEMBER:
                                $role = $this->course_obj->getDefaultMemberRole();
                                break;
                }

                $this->dropDesktopItem($a_usr_id);
                $rbacadmin->deassignUser($role,$a_usr_id);
                ilObjUser::updateActiveRoles($a_usr_id);

                
                $query = "DELETE FROM crs_members ".
                        "WHERE usr_id = '".$a_usr_id."' ".
                        "AND obj_id = '".$this->course_obj->getId()."'";

                $res = $this->ilDB->query($query);

                return true;
        }

Here is the call graph for this function:

ilCourseMembers::deleteAllEntries (  ) 

Definition at line 264 of file class.ilCourseMembers.php.

References $query.

        {
                $query = "DELETE FROM crs_members ".
                        "WHERE obj_id = '".$this->course_obj->getId()."'";

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

                $query = "DELETE FROM crs_subscribers ".
                        "WHERE obj_id = '".$this->course_obj->getId()."'";

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

                return true;
        }

ilCourseMembers::deleteMembers ( a_usr_ids  ) 

Definition at line 279 of file class.ilCourseMembers.php.

References $id.

        {
                if(!is_array($a_usr_ids) or !count($a_usr_ids))
                {
                        $this->course_obj->setMessage("");
                        $this->course_obj->appendMessage($this->lng->txt("no_usr_ids_given"));
                        
                        return false;
                }
                foreach($a_usr_ids as $id)
                {
                        if(!$this->delete($id))
                        {
                                $this->course_obj->appendMessage($this->lng->txt("error_delete_member"));
                                        
                                return false;
                        }
                }
                return true;
        }

ilCourseMembers::deleteSubscriber ( a_usr_id  ) 

Definition at line 626 of file class.ilCourseMembers.php.

References $query, and $res.

Referenced by __readSubscribers(), assignSubscriber(), and deleteSubscribers().

        {
                $query = "DELETE FROM crs_subscribers ".
                        "WHERE usr_id = '".$a_usr_id."' ".
                        "AND obj_id = '".$this->course_obj->getId()."'";

                $res = $this->ilDB->query($query);

                return true;
        }

Here is the caller graph for this function:

ilCourseMembers::deleteSubscribers ( a_usr_ids  ) 

Definition at line 637 of file class.ilCourseMembers.php.

References $id, and deleteSubscriber().

        {
                if(!is_array($a_usr_ids) or !count($a_usr_ids))
                {
                        $this->course_obj->setMessage("");
                        $this->course_obj->appendMessage($this->lng->txt("no_usr_ids_given"));
                        
                        return false;
                }
                foreach($a_usr_ids as $id)
                {
                        if(!$this->deleteSubscriber($id))
                        {
                                $this->course_obj->appendMessage($this->lng->txt("error_delete_subscriber"));
                                        
                                return false;
                        }
                }
                return true;
        }

Here is the call graph for this function:

ilCourseMembers::dropDesktopItem ( a_usr_id  ) 

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

References ilObjectFactory::getInstanceByObjId().

Referenced by delete().

        {
                $user_obj =& ilObjectFactory::getInstanceByObjId($a_usr_id);

                if($user_obj->isDesktopItem($this->course_obj->getRefId(),'crs'))
                {
                        $user_obj->dropDesktopItem($this->course_obj->getRefId(),'crs');
                }
                unset($user_obj);

                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::getAdmins (  ) 

Definition at line 394 of file class.ilCourseMembers.php.

References $query, $res, and $row.

Referenced by checkLastAdmin(), and getAssignedUsers().

        {
                $query = "SELECT cs.usr_id FROM crs_members as cs ".
                        "WHERE obj_id = '".$this->course_obj->getId()."' ".
                        "AND role = '".$this->ROLE_ADMIN."'";

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

Here is the caller graph for this function:

ilCourseMembers::getAssignedUsers (  ) 

Definition at line 357 of file class.ilCourseMembers.php.

References getAdmins(), getMembers(), and getTutors().

        {
                // ALL MEMBERS AND ADMINS
                return array_merge($this->getMembers(),$this->getAdmins(),$this->getTutors());
        }

Here is the call graph for this function:

ilCourseMembers::getCountMembers (  ) 

Definition at line 371 of file class.ilCourseMembers.php.

References getMembers().

Referenced by autoFillSubscribers().

        {
                return count($this->getMembers(false));
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::getCountPassed (  ) 

Definition at line 484 of file class.ilCourseMembers.php.

References $query, and $res.

        {
                $query = "SELECT * FROM crs_members ".
                        "WHERE obj_id = '".$this->course_obj->getId()."' ".
                        "AND passed = 1";

                $res = $this->ilDB->query($query);
                
                return $res->numRows() ? $res->numRows() : 0;
        }

ilCourseMembers::getCountSubscribers (  ) 

Definition at line 515 of file class.ilCourseMembers.php.

References getSubscribers().

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

Here is the call graph for this function:

ilCourseMembers::getMembers ( a_all = true  ) 

Definition at line 376 of file class.ilCourseMembers.php.

References $query, $res, and $row.

Referenced by getAssignedUsers(), and getCountMembers().

        {
                $query = "SELECT cs.usr_id FROM crs_members as cs ".
                        "WHERE obj_id = '".$this->course_obj->getId()."' ".
                        "AND role = '".$this->ROLE_MEMBER."'";

                if(!$a_all)
                {
                        $query .= " AND status = '".$this->STATUS_UNBLOCKED."'";
                }

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

Here is the caller graph for this function:

ilCourseMembers::getSubscriberData ( a_usr_id  ) 

Definition at line 520 of file class.ilCourseMembers.php.

References __readSubscriberData().

        {
                return $this->__readSubscriberData($a_usr_id);
        }

Here is the call graph for this function:

ilCourseMembers::getSubscribers (  ) 

Definition at line 508 of file class.ilCourseMembers.php.

References __readSubscribers().

Referenced by getCountSubscribers().

        {
                $this->__readSubscribers();

                return $this->subscribers;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::getTutors (  ) 

Definition at line 407 of file class.ilCourseMembers.php.

References $query, $res, and $row.

Referenced by getAssignedUsers().

        {
                $query = "SELECT cs.usr_id FROM crs_members as cs ".
                        "WHERE obj_id = '".$this->course_obj->getId()."' ".
                        "AND role = '".$this->ROLE_TUTOR."'";

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

Here is the caller graph for this function:

ilCourseMembers::getUserData ( a_usr_id  ) 

Definition at line 362 of file class.ilCourseMembers.php.

References __read().

        {
                if(!$this->__read($a_usr_id))
                {
                        return $a_usr_id;
                }
                return $this->member_data;
        }

Here is the call graph for this function:

ilCourseMembers::hasAccess ( a_usr_id  ) 

Definition at line 472 of file class.ilCourseMembers.php.

References $rbacsystem, isAssigned(), and isBlocked().

        {
                global $rbacsystem;

                #if($rbacsystem->checkAccess('write',$this->course_obj->getRefId()))
                #{
                #       return true;
                #}

                return $this->isAssigned($a_usr_id) && !$this->isBlocked($a_usr_id) ? true : false;
        }

Here is the call graph for this function:

ilCourseMembers::ilCourseMembers ( &$  course_obj  ) 

Definition at line 45 of file class.ilCourseMembers.php.

References $course_obj, $ilDB, $ilErr, $lng, and __purgeDeleted().

        {
                global $ilErr,$lng,$ilDB;

                $this->STATUS_NOTIFY = 1;
                $this->STATUS_NO_NOTIFY = 2;
                $this->STATUS_BLOCKED = 3;
                $this->STATUS_UNBLOCKED = 4;

                $this->NOTIFY_DISMISS_SUBSCRIBER = 1;
                $this->NOTIFY_ACCEPT_SUBSCRIBER = 2;
                $this->NOTIFY_DISMISS_MEMBER = 3;
                $this->NOTIFY_BLOCK_MEMBER = 4;
                $this->NOTIFY_UNBLOCK_MEMBER = 5;
                $this->NOTIFY_ACCEPT_USER = 6;
                $this->NOTIFY_ADMINS = 7;
                $this->NOTIFY_STATUS_CHANGED = 8;
                $this->NOTIFY_SUBSCRIPTION_REQUEST = 9;


                $this->ROLE_ADMIN = 1;
                $this->ROLE_MEMBER = 2;
                $this->ROLE_TUTOR = 3;

                $this->ilErr =& $ilErr;
                $this->ilDB =& $ilDB;
                $this->db =& $ilDB;

                $this->lng =& $lng;
                $this->lng->loadLanguageModule("search");

                $this->course_obj =& $course_obj;

                $this->__purgeDeleted();

        }

Here is the call graph for this function:

ilCourseMembers::isAdmin ( a_usr_id  ) 

Definition at line 421 of file class.ilCourseMembers.php.

References __read().

Referenced by isAssigned().

        {
                $this->__read($a_usr_id);

                return $this->member_data["role"] == $this->ROLE_ADMIN ? true : false;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::isAssigned ( a_usr_id  ) 

Definition at line 439 of file class.ilCourseMembers.php.

References isAdmin(), isMember(), and isTutor().

Referenced by assignSubscriber(), and hasAccess().

        {
                return $this->isAdmin($a_usr_id) || $this->isMember($a_usr_id) || $this->isTutor($a_usr_id);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::isBlocked ( a_usr_id  ) 

Definition at line 443 of file class.ilCourseMembers.php.

References __read().

Referenced by hasAccess().

        {
                $this->__read($a_usr_id);
                
                return $this->member_data["status"] == $this->STATUS_BLOCKED ? true : false;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::isMember ( a_usr_id  ) 

Definition at line 427 of file class.ilCourseMembers.php.

References __read().

Referenced by isAssigned().

        {
                $this->__read($a_usr_id);

                return $this->member_data["role"] == $this->ROLE_MEMBER ? true : false;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::isSubscriber ( a_usr_id  ) 

Definition at line 657 of file class.ilCourseMembers.php.

References $query, $res, and $row.

Referenced by assignSubscriber().

        {
                $query = "SELECT * FROM crs_subscribers ".
                        "WHERE usr_id = '".$a_usr_id."' ".
                        "AND obj_id = '".$this->course_obj->getId()."'";

                $res = $this->ilDB->query($query);

                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        return true;
                }
                return false;
        }

Here is the caller graph for this function:

ilCourseMembers::isTutor ( a_usr_id  ) 

Definition at line 433 of file class.ilCourseMembers.php.

References __read().

Referenced by isAssigned().

        {
                $this->__read($a_usr_id);

                return $this->member_data["role"] == $this->ROLE_TUTOR ? true : false;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::sendNotification ( a_type,
a_usr_id 
)

Definition at line 692 of file class.ilCourseMembers.php.

References $_SESSION, $tmp_user, __buildStatusBody(), ilObjectFactory::getInstanceByObjId(), sendNotificationToAdmins(), and sendSubscriptionRequestToAdmins().

Referenced by autoFillSubscribers().

        {
                $tmp_user =& ilObjectFactory::getInstanceByObjId($a_usr_id,false);

                $link = ("\n\n".$this->lng->txt('crs_mail_permanent_link'));
                $link .= ("\n\n".ILIAS_HTTP_PATH."/goto.php?target=crs_".$this->course_obj->getRefId()."&client_id=".CLIENT_ID);
                

                switch($a_type)
                {
                        case $this->NOTIFY_DISMISS_SUBSCRIBER:
                                $subject = $this->lng->txt("crs_reject_subscriber");
                                $body = $this->lng->txt("crs_reject_subscriber_body");
                                break;
                                
                        case $this->NOTIFY_ACCEPT_SUBSCRIBER:
                                $subject = $this->lng->txt("crs_accept_subscriber");
                                $body = $this->lng->txt("crs_accept_subscriber_body");
                                $body .= $link;
                                break;
                        case $this->NOTIFY_DISMISS_MEMBER:
                                $subject = $this->lng->txt("crs_dismiss_member");
                                $body = $this->lng->txt("crs_dismiss_member_body");
                                break;
                        case $this->NOTIFY_BLOCK_MEMBER:
                                $subject = $this->lng->txt("crs_blocked_member");
                                $body = $this->lng->txt("crs_blocked_member_body");
                                break;
                        case $this->NOTIFY_UNBLOCK_MEMBER:
                                $subject = $this->lng->txt("crs_unblocked_member");
                                $body = $this->lng->txt("crs_unblocked_member_body");
                                $body .= $link;
                                break;
                        case $this->NOTIFY_ACCEPT_USER:
                                $subject = $this->lng->txt("crs_added_member");
                                $body = $this->lng->txt("crs_added_member_body");
                                $body .= $link;
                                break;
                        case $this->NOTIFY_STATUS_CHANGED:
                                $subject = $this->lng->txt("crs_status_changed");
                                $body = $this->__buildStatusBody($tmp_user);
                                $body .= $link;
                                break;

                        case $this->NOTIFY_SUBSCRIPTION_REQUEST:
                                $this->sendSubscriptionRequestToAdmins($a_usr_id);
                                return true;
                                break;

                        case $this->NOTIFY_ADMINS:
                                $this->sendNotificationToAdmins($a_usr_id);

                                return true;
                                break;
                }
                $subject = sprintf($subject, $this->course_obj->getTitle());
                $body = sprintf($body, $this->course_obj->getTitle());

                include_once("./classes/class.ilFormatMail.php");

                $mail = new ilFormatMail($_SESSION["AccountId"]);
                $mail->sendMail($tmp_user->getLogin(),'','',$subject,$body,array(),array('normal'));

                unset($tmp_user);
                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::sendNotificationToAdmins ( a_usr_id  ) 

Definition at line 759 of file class.ilCourseMembers.php.

References $query, $res, $row, $tmp_user, and ilObjectFactory::getInstanceByObjId().

Referenced by sendNotification().

        {
                if(!$this->course_obj->getSubscriptionNotify())
                {
                        return true;
                }


                include_once("./classes/class.ilFormatMail.php");

                $mail =& new ilFormatMail($a_usr_id);
                $subject = sprintf($this->lng->txt("crs_new_subscription"),$this->course_obj->getTitle());
                $body = sprintf($this->lng->txt("crs_new_subscription_body"),$this->course_obj->getTitle());

                $query = "SELECT usr_id FROM crs_members ".
                        "WHERE status = '".$this->STATUS_NOTIFY."' ".
                        "AND obj_id = '".$this->course_obj->getId()."'";

                $res = $this->ilDB->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $tmp_user =& ilObjectFactory::getInstanceByObjId($row->usr_id,false);

                        $message = $mail->sendMail($tmp_user->getLogin(),'','',$subject,$body,array(),array('normal'));
                        unset($tmp_user);
                }
                unset($mail);

                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::sendSubscriptionRequestToAdmins ( a_usr_id  ) 

Definition at line 789 of file class.ilCourseMembers.php.

References $query, $res, $row, $tmp_user, and ilObjectFactory::getInstanceByObjId().

Referenced by sendNotification().

        {
                if(!$this->course_obj->getSubscriptionNotify())
                {
                        return true;
                }


                include_once("./classes/class.ilFormatMail.php");

                $mail =& new ilFormatMail($a_usr_id);
                $subject = sprintf($this->lng->txt("crs_new_subscription_request"),$this->course_obj->getTitle());
                $body = sprintf($this->lng->txt("crs_new_subscription_request_body"),$this->course_obj->getTitle());
                $body .= ("\n\n".$this->lng->txt('crs_new_subscription_request_body2'));
                $body .= ("\n\n".ILIAS_HTTP_PATH."/goto.php?target=crs_".$this->course_obj->getRefId()."&client_id=".CLIENT_ID);

                $query = "SELECT usr_id FROM crs_members ".
                        "WHERE status = '".$this->STATUS_NOTIFY."' ".
                        "AND obj_id = '".$this->course_obj->getId()."'";

                $res = $this->ilDB->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $tmp_user =& ilObjectFactory::getInstanceByObjId($row->usr_id,false);
                        $message = $mail->sendMail($tmp_user->getLogin(),'','',$subject,$body,array(),array('normal'));
                        unset($tmp_user);
                }
                unset($mail);

                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseMembers::sendUnsubscribeNotificationToAdmins ( a_usr_id  ) 

Definition at line 820 of file class.ilCourseMembers.php.

References $query, $res, $row, $tmp_user, and ilObjectFactory::getInstanceByObjId().

        {
                if(!$this->course_obj->getSubscriptionNotify())
                {
                        return true;
                }

                include_once("./classes/class.ilFormatMail.php");

                $mail =& new ilFormatMail($a_usr_id);
                $subject = sprintf($this->lng->txt("crs_cancel_subscription"), $this->course_obj->getTitle());
                $body = sprintf($this->lng->txt("crs_cancel_subscription_body"), $this->course_obj->getTitle());

                $query = "SELECT usr_id FROM crs_members ".
                        "WHERE status = '".$this->STATUS_NOTIFY."' ".
                        "AND obj_id = '".$this->course_obj->getId()."'";

                $res = $this->ilDB->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $tmp_user =& ilObjectFactory::getInstanceByObjId($row->usr_id,false);

                        $message = $mail->sendMail($tmp_user->getLogin(),'','',$subject,$body,array(),array('normal'));
                        unset($tmp_user);
                }
                unset($mail);

                return true;
        }

Here is the call graph for this function:

ilCourseMembers::update ( a_usr_id,
a_role,
a_status,
a_passed 
)

Definition at line 178 of file class.ilCourseMembers.php.

References $query, $rbacadmin, $res, __read(), addDesktopItem(), and ilObjUser::updateActiveRoles().

        {
                global $rbacadmin;

                $this->__read($a_usr_id);

                switch($a_role)
                {
                        case $this->ROLE_ADMIN:
                                if($a_status != $this->STATUS_NOTIFY and $a_status != $this->STATUS_NO_NOTIFY)
                                {
                                        $this->ilErr->raiseError($this->lng->txt("crs_status_not_allowed",$this->ilErr->MESSAGE));
                                }
                                break;

                        case $this->ROLE_TUTOR:
                                if($a_status != $this->STATUS_NOTIFY and $a_status != $this->STATUS_NO_NOTIFY)
                                {
                                        $this->ilErr->raiseError($this->lng->txt("crs_status_not_allowed",$this->ilErr->MESSAGE));
                                }
                                break;

                        case $this->ROLE_MEMBER:
                                if($a_status != $this->STATUS_BLOCKED and $a_status != $this->STATUS_UNBLOCKED)
                                {
                                        $this->ilErr->raiseError($this->lng->txt("crs_status_not_allowed",$this->ilErr->MESSAGE));
                                }
                                $this->addDesktopItem($a_usr_id);
                                break;
                                
                        default:
                                $this->ilErr->raiseError($this->lng->txt("crs_role_not_allowed",$this->ilErr->MESSAGE));
                                break;
                }

                // UPDATE RBAC ROLES

                // deassign old roles
                switch($this->member_data["role"])
                {
                        case $this->ROLE_ADMIN:
                                $rbacadmin->deassignUser($this->course_obj->getDefaultAdminRole(),$a_usr_id);
                                break;

                        case $this->ROLE_TUTOR:
                                $rbacadmin->deassignUser($this->course_obj->getDefaultTutorRole(),$a_usr_id);
                                break;

                        case $this->ROLE_MEMBER:
                                $rbacadmin->deassignUser($this->course_obj->getDefaultMemberRole(),$a_usr_id);
                                break;
                }
                // assign new role
                switch($a_role)
                {
                        case $this->ROLE_ADMIN:
                                $rbacadmin->assignUser($this->course_obj->getDefaultAdminRole(),$a_usr_id);
                                break;

                        case $this->ROLE_TUTOR:
                                $rbacadmin->assignUser($this->course_obj->getDefaultTutorRole(),$a_usr_id);
                                break;
                                
                        case $this->ROLE_MEMBER:
                                if($a_status != $this->STATUS_BLOCKED)
                                {
                                        $rbacadmin->assignUser($this->course_obj->getDefaultMemberRole(),$a_usr_id);
                                }
                                break;
                }

                // Update active roles
                ilObjUser::updateActiveRoles($a_usr_id);

                $query = "UPDATE crs_members ".
                        "SET role = '".$a_role."', ".
                        "status = '".$a_status."', ".
                        "passed = '".$a_passed."' ".
                        "WHERE obj_id = '".$this->course_obj->getId()."' ".
                        "AND usr_id = '".$a_usr_id."'";
                $res = $this->ilDB->query($query);

                return true;
        }

Here is the call graph for this function:

ilCourseMembers::updateSubscriptionTime ( a_usr_id,
a_subtime 
)

Definition at line 614 of file class.ilCourseMembers.php.

References $query.

        {
                $query = "UPDATE crs_subscribers ".
                        "SET sub_time = '".ilUtil::prepareDBString($a_subtime)."' ".
                        "WHERE usr_id = '".ilUtil::prepareDBString($a_usr_id)."' ".
                        "AND obj_id = '".$this->course_obj->getId()."'";

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

                return true;
        }


Field Documentation

ilCourseMembers::$course_obj

Definition at line 37 of file class.ilCourseMembers.php.

Referenced by ilCourseMembers().

ilCourseMembers::$ilDB
ilCourseMembers::$ilErr

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

Referenced by ilCourseMembers().

ilCourseMembers::$lng

Definition at line 40 of file class.ilCourseMembers.php.

Referenced by ilCourseMembers().

ilCourseMembers::$member_data

Definition at line 42 of file class.ilCourseMembers.php.

ilCourseMembers::$subscribers

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


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