/**
  * Handle an event in a listener.
  *
  * @param	string	$a_component	component, e.g. "Modules/Forum" or "Services/User"
  * @param	string	$a_event		event e.g. "createUser", "updateUser", "deleteUser", ...
  * @param	array	$a_parameter	parameter array (assoc), array("name" => ..., "phone_office" => ...)
  */
 static function handleEvent($a_component, $a_event, $a_parameter)
 {
     global $ilUser;
     if ($a_component == "Services/Tracking" && $a_event == "updateStatus") {
         // #13905
         include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
         if (!ilObjUserTracking::_enabledLearningProgress()) {
             return;
         }
         $obj_id = $a_parameter["obj_id"];
         $user_id = $a_parameter["usr_id"];
         $status = $a_parameter["status"];
         if ($obj_id && $user_id) {
             if (ilObject::_lookupType($obj_id) != "crs") {
                 return;
             }
             // determine couse setting only once
             if (!isset(self::$course_mode[$obj_id])) {
                 include_once "./Modules/Course/classes/class.ilObjCourse.php";
                 $crs = new ilObjCourse($obj_id, false);
                 if ($crs->getStatusDetermination() == ilObjCourse::STATUS_DETERMINATION_LP) {
                     include_once './Services/Object/classes/class.ilObjectLP.php';
                     $olp = ilObjectLP::getInstance($obj_id);
                     $mode = $olp->getCurrentMode();
                 } else {
                     $mode = false;
                 }
                 self::$course_mode[$obj_id] = $mode;
             }
             $is_completed = $status == ilLPStatus::LP_STATUS_COMPLETED_NUM;
             // we are NOT using the members object because of performance issues
             switch (self::$course_mode[$obj_id]) {
                 case ilLPObjSettings::LP_MODE_MANUAL_BY_TUTOR:
                     // #11600
                     include_once "Modules/Course/classes/class.ilCourseParticipants.php";
                     ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed, true);
                     break;
                 case ilLPObjSettings::LP_MODE_COLLECTION:
                 case ilLPObjSettings::LP_MODE_OBJECTIVES:
                     // overwrites course passed status if it was set automatically (full sync)
                     // or toggle manually set passed status to completed (1-way-sync)
                     $do_update = $is_completed;
                     include_once "Modules/Course/classes/class.ilCourseParticipants.php";
                     if (!$do_update) {
                         $part = new ilCourseParticipants($obj_id);
                         $passed = $part->getPassedInfo($user_id);
                         if (!is_array($passed) || $passed["user_id"] == -1) {
                             $do_update = true;
                         }
                     }
                     if ($do_update) {
                         ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed);
                     }
                     break;
             }
         }
     }
 }
 public function subscribeEmail($email)
 {
     $user_id = $this->getUserIdByEmail($email);
     if ($user_id) {
         $this->courseParticipants->add($user_id, IL_CRS_MEMBER);
         $this->emailsFound[] = $email;
     } else {
         $this->emailsNotFound[] = $email;
     }
 }
 /**
  * Get instance by obj type
  * 
  * @param int $a_obj_id
  * @return ilParticipants
  */
 public static function getInstanceByObjId($a_obj_id)
 {
     $type = ilObject::_lookupType($a_obj_id);
     switch ($type) {
         case 'crs':
             include_once './Modules/Course/classes/class.ilCourseParticipants.php';
             return ilCourseParticipants::_getInstanceByObjId($a_obj_id);
         case 'grp':
             include_once './Modules/Group/classes/class.ilGroupParticipants.php';
             return ilGroupParticipants::_getInstanceByObjId($a_obj_id);
     }
     // @todo proper error handling
     return null;
 }
 /**
  * Constructor
  *
  * @param	object		$a_content_object	must be of type ilObjContentObject
  *											ilObjTest or ilObjQuestionPool
  * @param	string		$a_xml_file			xml file
  * @param	string		$a_subdir			subdirectory in import directory
  * @access	public
  */
 function ilCourseXMLParser($a_course_obj, $a_xml_file = '')
 {
     global $lng, $ilLog;
     parent::ilMDSaxParser($a_xml_file);
     $this->sax_controller = new ilSaxController();
     $this->log =& $ilLog;
     $this->course_obj = $a_course_obj;
     $this->course_members = ilCourseParticipants::_getInstanceByObjId($this->course_obj->getId());
     $this->course_waiting_list = new ilCourseWaitingList($this->course_obj->getId());
     // flip the array so we can use array_key_exists
     $this->course_members_array = array_flip($this->course_members->getParticipants());
     $this->md_obj = new ilMD($this->course_obj->getId(), 0, 'crs');
     $this->setMDObject($this->md_obj);
     $this->lng =& $lng;
 }
示例#5
0
 /**
  *  
  * @param
  * @return
  */
 public function testSubscription()
 {
     include_once './Services/Membership/classes/class.ilParticipants.php';
     include_once './Modules/Course/classes/class.ilCourseParticipants.php';
     $part = ilCourseParticipants::_getInstanceByObjId(999999);
     $part->addSubscriber(111111);
     $part->updateSubscriptionTime(111111, time());
     $part->updateSubject(111111, 'hallo');
     $is = $part->isSubscriber(111111);
     $this->assertEquals($is, true);
     $is = ilParticipants::_isSubscriber(999999, 111111);
     $this->assertEquals($is, true);
     $part->deleteSubscriber(111111);
     $is = $part->isSubscriber(111111);
     $this->assertEquals($is, false);
 }
 /**
  * @param int $a_obj_id
  * @return ilParticipants|mixed|null|object
  */
 public static function getInstanceByObjId($a_obj_id)
 {
     $type = ilObject::_lookupType($a_obj_id);
     switch ($type) {
         case 'crs':
             include_once './Modules/Course/classes/class.ilCourseParticipants.php';
             return ilCourseParticipants::_getInstanceByObjId($a_obj_id);
         case 'grp':
             include_once './Modules/Group/classes/class.ilGroupParticipants.php';
             return ilGroupParticipants::_getInstanceByObjId($a_obj_id);
         case 'sess':
             include_once './Modules/Session/classes/class.ilSessionParticipants.php';
             return ilSessionParticipants::_getInstanceByObjId($a_obj_id);
         default:
             include_once 'class.ilAdobeConnectParticipantsNullObject.php';
             return new ilAdobeConnectParticipantsNullObject();
     }
 }
示例#7
0
 /**
  * Get instance by obj type
  * 
  * @param int $a_obj_id
  * @return ilParticipants
  * @throws InvalidArgumentException
  */
 public static function getInstanceByObjId($a_obj_id)
 {
     $type = ilObject::_lookupType($a_obj_id);
     switch ($type) {
         case 'crs':
             include_once './Modules/Course/classes/class.ilCourseParticipants.php';
             return ilCourseParticipants::_getInstanceByObjId($a_obj_id);
         case 'grp':
             include_once './Modules/Group/classes/class.ilGroupParticipants.php';
             return ilGroupParticipants::_getInstanceByObjId($a_obj_id);
         case 'sess':
             include_once './Modules/Session/classes/class.ilSessionParticipants.php';
             return ilSessionParticipants::_getInstanceByObjId($a_obj_id);
         default:
             $GLOBALS['ilLog']->logStack();
             $GLOBALS['ilLog']->write(__METHOD__ . ': Invalid obj_id given: ' . $a_obj_id);
             throw new InvalidArgumentException('Invalid obj id given');
     }
 }
 /**
  * Handle an event in a listener.
  *
  * @param	string	$a_component	component, e.g. "Modules/Forum" or "Services/User"
  * @param	string	$a_event		event e.g. "createUser", "updateUser", "deleteUser", ...
  * @param	array	$a_parameter	parameter array (assoc), array("name" => ..., "phone_office" => ...)
  */
 static function handleEvent($a_component, $a_event, $a_parameter)
 {
     global $ilUser;
     if ($a_component == "Services/Tracking" && $a_event == "updateStatus") {
         $obj_id = $a_parameter["obj_id"];
         $user_id = $a_parameter["usr_id"];
         $status = $a_parameter["status"];
         if ($obj_id && $user_id) {
             if (ilObject::_lookupType($obj_id) != "crs") {
                 return;
             }
             // determine couse setting only once
             if (!isset(self::$course_mode[$obj_id])) {
                 include_once "./Modules/Course/classes/class.ilObjCourse.php";
                 $crs = new ilObjCourse($obj_id, false);
                 if ($crs->getStatusDetermination() == ilObjCourse::STATUS_DETERMINATION_LP) {
                     include_once './Services/Tracking/classes/class.ilLPObjSettings.php';
                     $lp_settings = new ilLPObjSettings($obj_id);
                     $mode = $lp_settings->getMode();
                 } else {
                     $mode = false;
                 }
                 self::$course_mode[$obj_id] = $mode;
             }
             $is_completed = $status == LP_STATUS_COMPLETED_NUM;
             // we are NOT using the members object because of performance issues
             switch (self::$course_mode[$obj_id]) {
                 case LP_MODE_MANUAL_BY_TUTOR:
                     include_once "Modules/Course/classes/class.ilCourseParticipants.php";
                     ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed, $ilUser->getId());
                     break;
                 case LP_MODE_COLLECTION:
                 case LP_MODE_OBJECTIVES:
                     if ($is_completed) {
                         include_once "Modules/Course/classes/class.ilCourseParticipants.php";
                         ilCourseParticipants::_updatePassed($obj_id, $user_id, $is_completed, -1);
                     }
                     break;
             }
         }
     }
 }
 /**
  * Constructor
  *
  * @access public
  * @param object parent gui object
  * @return void
  */
 public function __construct($a_parent_obj)
 {
     global $lng, $ilCtrl;
     $this->lng = $lng;
     $this->lng->loadLanguageModule('crs');
     $this->ctrl = $ilCtrl;
     $this->container = $a_parent_obj;
     include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
     $this->privacy = ilPrivacySettings::_getInstance();
     $this->participants = ilCourseParticipants::_getInstanceByObjId($a_parent_obj->object->getId());
     parent::__construct($a_parent_obj, 'editMembers');
     $this->setFormName('participants');
     $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
     $this->addColumn($this->lng->txt('lastname'), 'lastname', '20%');
     $this->addColumn($this->lng->txt('login'), 'login', '25%');
     if ($this->privacy->enabledCourseAccessTimes()) {
         $this->addColumn($this->lng->txt('last_access'), 'access_time');
     }
     $this->addColumn($this->lng->txt('crs_passed'), 'passed');
     $this->addColumn($this->lng->txt('crs_blocked'), 'blocked');
     $this->addColumn($this->lng->txt('crs_notification'), 'notification');
     $this->addColumn($this->lng->txt('objs_role'), 'roles');
     $this->addCommandButton('updateMembers', $this->lng->txt('save'));
     $this->addCommandButton('members', $this->lng->txt('cancel'));
     $this->setRowTemplate("tpl.edit_participants_row.html", "Modules/Course");
     $this->disable('sort');
     $this->enable('header');
     $this->enable('numinfo');
     $this->disable('select_all');
     // Performance improvement: We read the local course roles
     // only once, instead of reading them for each row in method fillRow().
     $this->localCourseRoles = array();
     foreach ($this->container->object->getLocalCourseRoles(false) as $title => $role_id) {
         $this->localCourseRoles[ilObjRole::_getTranslation($title)] = array('role_id' => $role_id, 'title' => $title);
     }
 }
 /**
  * Get all completed tests
  */
 protected function getItems()
 {
     global $ilUser;
     $data = array();
     include_once "Modules/Course/classes/class.ilObjCourse.php";
     include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
     $obj_ids = ilCourseParticipants::_getMembershipByType($ilUser->getId(), "crs");
     if ($obj_ids) {
         include_once "./Services/Certificate/classes/class.ilCertificate.php";
         include_once "./Modules/Course/classes/class.ilCourseCertificateAdapter.php";
         ilCourseCertificateAdapter::_preloadListData($ilUser->getId(), $obj_ids);
         foreach ($obj_ids as $crs_id) {
             // #11210 - only available certificates!
             if (ilCourseCertificateAdapter::_hasUserCertificate($ilUser->getId(), $crs_id)) {
                 $crs = new ilObjCourse($crs_id, false);
                 $adapter = new ilCourseCertificateAdapter($crs);
                 if (ilCertificate::_isComplete($adapter)) {
                     $data[] = array("id" => $crs_id, "title" => ilObject::_lookupTitle($crs_id), "passed" => true);
                 }
             }
         }
     }
     $this->setData($data);
 }
 public static function checkParentNodeTree($ref_id)
 {
     global $tree;
     $parent_ref_id = $tree->getParentId($ref_id);
     $parent_obj = ilObjectFactory::getInstanceByRefId($parent_ref_id);
     if ($parent_obj->getType() == 'crs') {
         include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
         $oParticipants = ilCourseParticipants::_getInstanceByObjId($parent_obj->getId());
     } else {
         if ($parent_obj->getType() == 'grp') {
             include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
             $oParticipants = ilGroupParticipants::_getInstanceByObjId($parent_obj->getId());
         }
     }
     $result = array();
     if ($parent_obj->getType() == 'crs' || $parent_obj->getType() == 'grp') {
         $moderator_ids = self::_getModerators($ref_id);
         $admin_ids = $oParticipants->getAdmins();
         $tutor_ids = $oParticipants->getTutors();
         $result = array_unique(array_merge($moderator_ids, $admin_ids, $tutor_ids));
     }
     return $result;
 }
 /**
  * Get members for object
  * @param int $a_obj_id
  * @param bool $a_is_crs_id
  * @return array
  */
 protected static function getMembers($a_obj_id, $a_is_crs_id = false)
 {
     // find course in path
     if (!$a_is_crs_id) {
         $references = ilObject::_getAllReferences($a_obj_id);
         $ref_id = end($references);
         $course_ref_id = $tree->checkForParentType($ref_id, 'crs');
         $course_obj_id = ilObject::_lookupObjId($course_ref_id);
     } else {
         $course_obj_id = $a_obj_id;
     }
     include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
     $member_obj = ilCourseParticipants::_getInstanceByObjId($course_obj_id);
     return $member_obj->getMembers();
 }
 function __updatePassed($a_user_id, $objective_ids)
 {
     global $ilDB;
     $passed = array();
     $query = "SELECT COUNT(t1.crs_id) num,t1.crs_id FROM crs_objectives t1 " . "JOIN crs_objectives t2 WHERE t1.crs_id = t2.crs_id and  " . $ilDB->in('t1.objective_id', $objective_ids, false, 'integer') . " " . "GROUP BY t1.crs_id";
     $res = $ilDB->query($query);
     $crs_ids = array();
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $query = "SELECT COUNT(cs.objective_id) num_passed FROM crs_objective_status cs " . "JOIN crs_objectives co ON cs.objective_id = co.objective_id " . "WHERE crs_id = " . $ilDB->quote($row->crs_id, 'integer') . " " . "AND user_id = " . $ilDB->quote($a_user_id, 'integer') . " ";
         $user_res = $ilDB->query($query);
         while ($user_row = $user_res->fetchRow(DB_FETCHMODE_OBJECT)) {
             if ($user_row->num_passed == $row->num) {
                 $passed[] = $row->crs_id;
             }
         }
         $crs_ids[$row->crs_id] = $row->crs_id;
     }
     if (count($passed)) {
         foreach ($passed as $crs_id) {
             include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
             $members = ilCourseParticipants::_getInstanceByObjId($crs_id);
             $members->updatePassed($a_user_id, true);
         }
     }
     // update tracking status
     foreach ($crs_ids as $cid) {
         include_once "./Services/Tracking/classes/class.ilLPStatusWrapper.php";
         ilLPStatusWrapper::_updateStatus($cid, $a_user_id);
     }
 }
 /**
  * Refresh status of course member assignments
  * @param object $course_member
  * @param int $obj_id
  */
 protected function refreshAssignmentStatus($course_member, $obj_id, $sub_id, $assigned)
 {
     include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseMemberAssignment.php';
     $type = ilObject::_lookupType($obj_id);
     if ($type == 'crs') {
         include_once './Modules/Course/classes/class.ilCourseParticipants.php';
         $part = ilCourseParticipants::_getInstanceByObjId($obj_id);
     } else {
         include_once './Modules/Group/classes/class.ilGroupParticipants.php';
         $part = ilGroupParticipants::_getInstanceByObjId($obj_id);
     }
     $course_id = (int) $course_member->lectureID;
     $usr_ids = ilECSCourseMemberAssignment::lookupUserIds($course_id, $sub_id, $obj_id);
     // Delete remote deleted
     foreach ((array) $usr_ids as $usr_id) {
         if (!isset($assigned[$usr_id])) {
             $ass = ilECSCourseMemberAssignment::lookupAssignment($course_id, $sub_id, $obj_id, $usr_id);
             if ($ass instanceof ilECSCourseMemberAssignment) {
                 $acc = ilObjUser::_checkExternalAuthAccount(ilECSSetting::lookupAuthMode(), (string) $usr_id);
                 if ($il_usr_id = ilObjUser::_lookupId($acc)) {
                     // this removes also admin, tutor roles
                     $part->delete($il_usr_id);
                     $GLOBALS['ilLog']->write(__METHOD__ . ': Deassigning user ' . $usr_id . ' ' . 'from course ' . ilObject::_lookupTitle($obj_id));
                 } else {
                     $GLOBALS['ilLog']->write(__METHOD__ . ': Deassigning unknown ILIAS user ' . $usr_id . ' ' . 'from course ' . ilObject::_lookupTitle($obj_id));
                 }
                 $ass->delete();
             }
         }
     }
     // Assign new participants
     foreach ((array) $assigned as $person_id => $person) {
         $role = $this->lookupRole($person['role']);
         $role_info = ilECSMappingUtils::getRoleMappingInfo($role);
         $acc = ilObjUser::_checkExternalAuthAccount(ilECSSetting::lookupAuthMode(), (string) $person_id);
         $GLOBALS['ilLog']->write(__METHOD__ . ': Handling user ' . (string) $person_id);
         if (in_array($person_id, $usr_ids)) {
             if ($il_usr_id = ilObjUser::_lookupId($acc)) {
                 $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($role, true));
                 $part->updateRoleAssignments($il_usr_id, array($role));
                 // Nothing to do, user is member or is locally deleted
             }
         } else {
             if ($il_usr_id = ilObjUser::_lookupId($acc)) {
                 if ($role) {
                     // Add user
                     $GLOBALS['ilLog']->write(__METHOD__ . ': Assigning new user ' . $person_id . ' ' . 'to ' . ilObject::_lookupTitle($obj_id));
                     $part->add($il_usr_id, $role);
                 }
             } else {
                 if ($role_info['create']) {
                     $this->createMember($person_id);
                     $GLOBALS['ilLog']->write(__METHOD__ . ': Added new user ' . $person_id);
                 }
             }
             $assignment = new ilECSCourseMemberAssignment();
             $assignment->setServer($this->getServer()->getServerId());
             $assignment->setMid($this->mid);
             $assignment->setCmsId($course_id);
             $assignment->setCmsSubId($sub_id);
             $assignment->setObjId($obj_id);
             $assignment->setUid($person_id);
             $assignment->save();
         }
     }
     return true;
 }
 protected function share()
 {
     global $ilToolbar, $tpl, $ilUser, $ilSetting;
     $options = array();
     $options["user"] = $this->lng->txt("wsp_set_permission_single_user");
     include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
     $grp_ids = ilGroupParticipants::_getMembershipByType($ilUser->getId(), 'grp');
     if (sizeof($grp_ids)) {
         $options["group"] = $this->lng->txt("wsp_set_permission_group");
     }
     include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
     $crs_ids = ilCourseParticipants::_getMembershipByType($ilUser->getId(), 'crs');
     if (sizeof($crs_ids)) {
         $options["course"] = $this->lng->txt("wsp_set_permission_course");
     }
     if (!$this->getAccessHandler()->hasRegisteredPermission($this->node_id)) {
         $options["registered"] = $this->lng->txt("wsp_set_permission_registered");
     }
     if ($ilSetting->get("enable_global_profiles")) {
         if (!$this->getAccessHandler()->hasGlobalPasswordPermission($this->node_id)) {
             $options["password"] = $this->lng->txt("wsp_set_permission_all_password");
         }
         if (!$this->getAccessHandler()->hasGlobalPermission($this->node_id)) {
             $options["all"] = $this->lng->txt("wsp_set_permission_all");
         }
     }
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $actions = new ilSelectInputGUI("", "action");
     $actions->setOptions($options);
     $ilToolbar->addInputItem($actions);
     $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
     $ilToolbar->addFormButton($this->lng->txt("add"), "addpermissionhandler");
     include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessTableGUI.php";
     $table = new ilWorkspaceAccessTableGUI($this, "share", $this->node_id, $this->getAccessHandler());
     $tpl->setContent($table->getHTML() . $this->footer);
 }
 /**
  * Build item rows for given object and filter(s)
  */
 function getItems()
 {
     if ($this->groups) {
         include_once './Modules/Course/classes/class.ilCourseParticipants.php';
         $part = ilCourseParticipants::_getInstanceByObjId($this->obj_id);
         $members = $part->getMembers();
         if (count($members)) {
             include_once './Services/User/classes/class.ilUserUtil.php';
             $usr_data = array();
             foreach ($members as $usr_id) {
                 $name = ilObjUser::_lookupName($usr_id);
                 // #9984
                 $user_groups = array("members" => array(), "admins" => array());
                 $user_groups_number = 0;
                 foreach (array_keys($this->participants) as $group_id) {
                     if (in_array($usr_id, $this->participants[$group_id]["members"])) {
                         $user_groups["members"][$group_id] = $this->groups[$group_id];
                         $user_groups_number++;
                     } else {
                         if (in_array($usr_id, $this->participants[$group_id]["admins"])) {
                             $user_groups["admins"][$group_id] = $this->groups[$group_id];
                             $user_groups_number++;
                         }
                     }
                 }
                 if ((!$this->filter["name"] || stristr(implode("", $name), $this->filter["name"])) && (!$this->filter["group"] || array_key_exists($this->filter["group"], $user_groups["members"]) || array_key_exists($this->filter["group"], $user_groups["admins"]))) {
                     $usr_data[] = array("usr_id" => $usr_id, "name" => $name["lastname"] . ", " . $name["firstname"], "groups" => $user_groups, "groups_number" => $user_groups_number, "login" => $name["login"]);
                 }
             }
             // ???
             $usr_data = array_slice($usr_data, (int) $this->getOffset(), (int) $this->getLimit());
             $this->setMaxCount(sizeof($members));
             $this->setData($usr_data);
         }
         return $titles;
     }
 }
示例#17
0
 /**
  * Assign users as course members
  *
  */
 function assignUsersAsCourseMembers($a_user_login_base = "learner", $a_start = 1, $a_end = 100)
 {
     global $ilDB;
     $this->log("Assigning Course Members");
     $set = $ilDB->query("SELECT usr_id, login FROM usr_data WHERE " . " login LIKE " . $ilDB->quote($a_user_login_base . "%", "text"));
     $user_ids = array();
     while ($rec = $ilDB->fetchAssoc($set)) {
         $rest = substr($rec["login"], strlen($a_user_login_base));
         if (is_numeric($rest) && ((int) $rest >= $a_start && (int) $rest <= $a_end)) {
             $user_ids[] = $rec["usr_id"];
         }
     }
     $cnt = 1;
     $crs_ref_ids = ilUtil::_getObjectsByOperations("crs", "read", 0, $limit = 1000000);
     include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
     foreach ($crs_ref_ids as $r) {
         $crs_id = ilObject::_lookupObjId($r);
         $mem_obj = ilCourseParticipants::_getInstanceByObjId($crs_id);
         foreach ($user_ids as $u) {
             $this->log("{$cnt}: add user {$u} as member to course " . $crs_id);
             $mem_obj->add($u, 1);
             $cnt++;
         }
     }
 }
 public function confirmedUnsubscribe()
 {
     global $ilCtrl, $ilAccess, $ilUser;
     if (!sizeof($_POST["ref_id"])) {
         $ilCtrl->redirect($this, "manage");
     }
     foreach ($_POST["ref_id"] as $ref_id) {
         if ($ilAccess->checkAccess("leave", "", $ref_id)) {
             switch (ilObject::_lookupType($ref_id, true)) {
                 case "crs":
                     // see ilObjCourseGUI:performUnsubscribeObject()
                     include_once "Modules/Course/classes/class.ilCourseParticipants.php";
                     $members = new ilCourseParticipants(ilObject::_lookupObjId($ref_id));
                     $members->delete($ilUser->getId());
                     $members->sendUnsubscribeNotificationToAdmins($ilUser->getId());
                     $members->sendNotification($members->NOTIFY_UNSUBSCRIBE, $ilUser->getId());
                     break;
                 case "grp":
                     // see ilObjGroupGUI:performUnsubscribeObject()
                     include_once "Modules/Group/classes/class.ilGroupParticipants.php";
                     $members = new ilGroupParticipants(ilObject::_lookupObjId($ref_id));
                     $members->delete($ilUser->getId());
                     include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
                     $members->sendNotification(ilGroupMembershipMailNotification::TYPE_UNSUBSCRIBE_MEMBER, $ilUser->getId());
                     $members->sendNotification(ilGroupMembershipMailNotification::TYPE_NOTIFICATION_UNSUBSCRIBE, $ilUser->getId());
                     break;
                 default:
                     // do nothing
                     continue;
             }
             include_once './Modules/Forum/classes/class.ilForumNotification.php';
             ilForumNotification::checkForumsExistsDelete($ref_id, $ilUser->getId());
         }
     }
     ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
     $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
 }
 /**
  * Get course status body
  * @param int $a_usr_id
  * @return string
  */
 protected function createCourseStatus($a_usr_id)
 {
     $part = ilCourseParticipants::_getInstanceByObjId($this->getObjId());
     $body = $this->getLanguageText('crs_new_status') . "\n";
     $body .= $this->getLanguageText('role') . ': ';
     if ($part->isAdmin($a_usr_id)) {
         $body .= $this->getLanguageText('crs_admin') . "\n";
     } elseif ($part->isTutor($a_usr_id)) {
         $body .= $this->getLanguageText('crs_tutor') . "\n";
     } else {
         $body .= $this->getLanguageText('crs_member') . "\n";
     }
     if ($part->isAdmin($a_usr_id) or $part->isTutor($a_usr_id)) {
         $body .= $this->getLanguageText('crs_status') . ': ';
         if ($part->isNotificationEnabled($a_usr_id)) {
             $body .= $this->getLanguageText('crs_notify') . "\n";
         } else {
             $body .= $this->getLanguageText('crs_no_notify') . "\n";
         }
     } else {
         $body .= $this->getLanguageText('crs_access') . ': ';
         if ($part->isBlocked($a_usr_id)) {
             $body .= $this->getLanguageText('crs_blocked') . "\n";
         } else {
             $body .= $this->getLanguageText('crs_unblocked') . "\n";
         }
     }
     $body .= $this->getLanguageText('crs_passed') . ': ';
     if ($part->hasPassed($a_usr_id)) {
         $body .= $this->getLanguageText('yes');
     } else {
         $body .= $this->getLanguageText('no');
     }
     return $body;
 }
 /**
  * Show course members
  */
 public function showMembers()
 {
     global $lng, $ilUser, $ilObjDataCache;
     include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
     if ($_GET["search_crs"] != "") {
         $_POST["search_crs"] = explode(",", $_GET["search_crs"]);
         $_GET["search_crs"] = "";
     } else {
         if ($_SESSION["search_crs"] != "") {
             $_POST["search_crs"] = explode(",", $_SESSION["search_crs"]);
             $_SESSION["search_crs"] = "";
         }
     }
     if (!is_array($_POST["search_crs"]) || count($_POST["search_crs"]) == 0) {
         ilUtil::sendInfo($lng->txt("mail_select_course"));
         $this->showMyCourses();
     } else {
         foreach ($_POST['search_crs'] as $crs_id) {
             $oTmpCrs = ilObjectFactory::getInstanceByObjId($crs_id);
             if ($oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED) {
                 unset($_POST['search_crs']);
                 ilUtil::sendInfo($lng->txt('mail_crs_list_members_not_available_for_at_least_one_crs'));
                 return $this->showMyCourses();
             }
             unset($oTmpCrs);
         }
         $this->tpl->setTitle($this->lng->txt("mail_addressbook"));
         $this->ctrl->setParameter($this, "view", "crs_members");
         if ($_GET["ref"] != "") {
             $this->ctrl->setParameter($this, "ref", $_GET["ref"]);
         }
         if (is_array($_POST["search_crs"])) {
             $this->ctrl->setParameter($this, "search_crs", implode(",", $_POST["search_crs"]));
         }
         $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
         $this->ctrl->clearParameters($this);
         $lng->loadLanguageModule('crs');
         include_once 'Services/Contact/classes/class.ilMailSearchCoursesMembersTableGUI.php';
         $context = $_GET["ref"] ? $_GET["ref"] : "mail";
         $table = new ilMailSearchCoursesMembersTableGUI($this, 'crs', $context);
         $table->setId('show_crs_mmbrs_tbl');
         $tableData = array();
         $searchTpl = new ilTemplate('tpl.mail_search_template.html', true, true, 'Services/Contact');
         foreach ($_POST["search_crs"] as $crs_id) {
             $members_obj = ilCourseParticipants::_getinstanceByObjId($crs_id);
             $tmp_members = $members_obj->getParticipants();
             $course_members = ilUtil::_sortIds($tmp_members, 'usr_data', 'lastname', 'usr_id');
             foreach ($course_members as $member) {
                 $tmp_usr = new ilObjUser($member);
                 if ($tmp_usr->checkTimeLimit() == false || $tmp_usr->getActive() == false) {
                     unset($tmp_usr);
                     continue;
                 }
                 unset($tmp_usr);
                 $name = ilObjUser::_lookupName($member);
                 $login = ilObjUser::_lookupLogin($member);
                 $fullname = "";
                 if (in_array(ilObjUser::_lookupPref($member, 'public_profile'), array("g", 'y'))) {
                     $fullname = $name['lastname'] . ', ' . $name['firstname'];
                 }
                 $rowData = array('members_id' => $member, 'members_login' => $login, 'members_name' => $fullname, 'members_crs_grp' => $ilObjDataCache->lookupTitle($crs_id), 'members_in_addressbook' => $this->abook->checkEntryByLogin($login) ? $lng->txt("yes") : $lng->txt("no"), 'search_crs' => $crs_id);
                 $tableData[] = $rowData;
             }
         }
         $table->setData($tableData);
         if (count($tableData)) {
             $searchTpl->setVariable("TXT_MARKED_ENTRIES", $lng->txt("marked_entries"));
         }
         $searchTpl->setVariable('TABLE', $table->getHtml());
         $this->tpl->setContent($searchTpl->get());
         if ($_GET["ref"] != "wsp") {
             $this->tpl->show();
         }
     }
 }
 /**
  * checks wether a user may invoke a command or not
  * (this method is called by ilAccessHandler::checkAccess)
  *
  * @param	string		$a_cmd		command (not permission!)
  * @param	string		$a_permission	permission
  * @param	int			$a_ref_id	reference id
  * @param	int			$a_obj_id	object id
  * @param	int			$a_user_id	user id (if not provided, current user is taken)
  *
  * @return	boolean		true, if everything is ok
  */
 function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "")
 {
     global $ilUser, $lng, $rbacsystem, $ilAccess, $ilias;
     if ($a_user_id == "") {
         $a_user_id = $ilUser->getId();
     }
     if ($ilUser->getId() == $a_user_id) {
         $participants = ilCourseParticipant::_getInstanceByObjId($a_obj_id, $a_user_id);
     } else {
         $participants = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
     }
     switch ($a_cmd) {
         case "view":
             if ($participants->isBlocked($a_user_id) and $participants->isAssigned($a_user_id)) {
                 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("crs_status_blocked"));
                 return false;
             }
             break;
         case 'leave':
             // Regular member
             if ($a_permission == 'leave') {
                 include_once './Modules/Course/classes/class.ilCourseParticipants.php';
                 if (!$participants->isAssigned($a_user_id)) {
                     return false;
                 }
             }
             // Waiting list
             if ($a_permission == 'join') {
                 include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
                 if (!ilCourseWaitingList::_isOnList($a_user_id, $a_obj_id)) {
                     return false;
                 }
                 return true;
             }
             break;
     }
     switch ($a_permission) {
         case 'visible':
             $visible = null;
             $active = self::_isActivated($a_obj_id, $visible);
             $tutor = $rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id);
             if (!$active) {
                 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
             }
             if (!$tutor and !$active && !$visible) {
                 return false;
             }
             break;
         case 'read':
             $tutor = $rbacsystem->checkAccessOfUser($a_user_id, 'write', $a_ref_id);
             if ($tutor) {
                 return true;
             }
             $active = self::_isActivated($a_obj_id);
             if (!$active) {
                 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("offline"));
                 return false;
             }
             if ($participants->isBlocked($a_user_id) and $participants->isAssigned($a_user_id)) {
                 $ilAccess->addInfoItem(IL_NO_OBJECT_ACCESS, $lng->txt("crs_status_blocked"));
                 return false;
             }
             break;
         case 'join':
             if (!self::_registrationEnabled($a_obj_id)) {
                 return false;
             }
             include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
             if (ilCourseWaitingList::_isOnList($a_user_id, $a_obj_id)) {
                 return false;
             }
             if ($participants->isAssigned($a_user_id)) {
                 return false;
             }
             break;
     }
     return true;
 }
 protected function initContainer($a_init_participants = false)
 {
     global $tree;
     $is_course = $is_group = false;
     $this->container_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs');
     if ($this->container_ref_id) {
         $is_course = true;
     }
     if (!$this->container_ref_id) {
         $this->container_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp');
         if ($this->container_ref_id) {
             $is_group = true;
         }
     }
     if (!$this->container_ref_id) {
         ilUtil::sendFailure('No container object found. Aborting');
         return true;
     }
     $this->container_obj_id = ilObject::_lookupObjId($this->container_ref_id);
     if ($a_init_participants && $this->container_obj_id) {
         if ($is_course) {
             include_once './Modules/Course/classes/class.ilCourseParticipants.php';
             return ilCourseParticipants::_getInstanceByObjId($this->container_obj_id);
         } else {
             if ($is_group) {
                 include_once './Modules/Group/classes/class.ilGroupParticipants.php';
                 return ilGroupParticipants::_getInstanceByObjId($this->container_obj_id);
             }
         }
     }
 }
 /**
  * Get bloch HTML code.
  */
 function getHTML()
 {
     global $ilCtrl, $lng, $ilUser, $ilAccess;
     if ($this->getCurrentDetailLevel() == 0) {
         return "";
     }
     // add edit commands
     #if ($this->getEnableEdit())
     if ($this->mode == ilCalendarCategories::MODE_PERSONAL_DESKTOP_ITEMS or $this->mode == ilCalendarCategories::MODE_PERSONAL_DESKTOP_MEMBERSHIP) {
         include_once "./Services/News/classes/class.ilRSSButtonGUI.php";
         $this->addBlockCommand($this->ctrl->getLinkTarget($this, 'showCalendarSubscription'), $lng->txt('ical_export'), "", "", true, false, ilRSSButtonGUI::get(ilRSSButtonGUI::ICON_ICAL));
     }
     if ($this->mode == ilCalendarCategories::MODE_REPOSITORY) {
         if (!isset($_GET["bkid"])) {
             if ($ilAccess->checkAccess('edit_event', '', (int) $_GET['ref_id'])) {
                 $ilCtrl->setParameter($this, "add_mode", "block");
                 $this->addBlockCommand($ilCtrl->getLinkTargetByClass("ilCalendarAppointmentGUI", "add"), $lng->txt("add_appointment"));
                 $ilCtrl->setParameter($this, "add_mode", "");
             }
             global $ilObjDataCache;
             include_once "Modules/Course/classes/class.ilCourseParticipants.php";
             $obj_id = $ilObjDataCache->lookupObjId((int) $_GET['ref_id']);
             $participants = ilCourseParticipants::_getInstanceByObjId($obj_id);
             $users = array_unique(array_merge($participants->getTutors(), $participants->getAdmins()));
             //$users = $participants->getParticipants();
             include_once 'Services/Booking/classes/class.ilBookingEntry.php';
             //$users = ilBookingEntry::isBookable($users, $obj_id);
             $users = ilBookingEntry::lookupBookableUsersForObject($obj_id, $users);
             if ($users) {
                 foreach ($users as $user_id) {
                     if (!isset($_GET["bkid"])) {
                         $ilCtrl->setParameter($this, "bkid", $user_id);
                         $this->addBlockCommand($ilCtrl->getLinkTargetByClass("ilCalendarMonthGUI", ""), $lng->txt("cal_consultation_hours_for") . ' ' . ilObjUser::_lookupFullname($user_id));
                         $this->cal_footer[] = array('link' => $ilCtrl->getLinkTargetByClass('ilCalendarMonthGUI', ''), 'txt' => $lng->txt("cal_consultation_hours_for") . ' ' . ilObjUser::_lookupFullname($user_id));
                     }
                 }
                 $ilCtrl->setParameter($this, "bkid", "");
             }
         } else {
             $ilCtrl->setParameter($this, "bkid", "");
             $this->addBlockCommand($ilCtrl->getLinkTarget($this), $lng->txt("back"));
             $ilCtrl->setParameter($this, "bkid", (int) $_GET["bkid"]);
         }
     }
     if ($this->getProperty("settings") == true) {
         $this->addBlockCommand($ilCtrl->getLinkTarget($this, "editSettings"), $lng->txt("settings"));
     }
     $ilCtrl->setParameterByClass("ilcolumngui", "seed", isset($_GET["seed"]) ? $_GET["seed"] : "");
     $ret = parent::getHTML();
     $ilCtrl->setParameterByClass("ilcolumngui", "seed", "");
     return $ret;
 }
 /**
  * Returns the parent object of the role folder object which contains the specified role.
  */
 function getCourseMembersObjectForRole($a_role_id)
 {
     global $rbacreview, $rbacadmin, $tree;
     if (array_key_exists($a_role_id . '_courseMembersObject', $this->localRoleCache)) {
         return $this->localRoleCache[$a_role_id . '_courseMembersObject'];
     } else {
         require_once "Modules/Course/classes/class.ilObjCourse.php";
         require_once "Modules/Course/classes/class.ilCourseParticipants.php";
         $rolf_refs = $rbacreview->getFoldersAssignedToRole($a_role_id, true);
         $course_ref = $tree->getParentId($rolf_refs[0]);
         $course_obj = new ilObjCourse($course_ref, true);
         $crsmembers_obj = ilCourseParticipants::_getInstanceByObjId($course_obj->getId());
         $this->localRoleCache[$a_role_id . '_courseMembersObject'] = $crsmembers_obj;
         return $crsmembers_obj;
     }
 }
 /**
  * Get item properties
  *
  * @return	array		array of property arrays:
  *						"alert" (boolean) => display as an alert property (usually in red)
  *						"property" (string) => property name
  *						"value" (string) => property value
  */
 function getProperties()
 {
     global $lng, $ilUser;
     $props = parent::getProperties();
     // offline
     include_once 'Modules/Course/classes/class.ilObjCourseAccess.php';
     if (ilObjCourseAccess::_isOffline($this->obj_id)) {
         $showRegistrationInfo = false;
         $props[] = array("alert" => true, "property" => $lng->txt("status"), "value" => $lng->txt("offline"));
     }
     // blocked
     include_once 'Modules/Course/classes/class.ilCourseParticipant.php';
     $members = ilCourseParticipant::_getInstanceByObjId($this->obj_id, $ilUser->getId());
     if ($members->isBlocked($ilUser->getId()) and $members->isAssigned($ilUser->getId())) {
         $props[] = array("alert" => true, "property" => $lng->txt("member_status"), "value" => $lng->txt("crs_status_blocked"));
     }
     // pending subscription
     include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
     if (ilCourseParticipants::_isSubscriber($this->obj_id, $ilUser->getId())) {
         $props[] = array("alert" => true, "property" => $lng->txt("member_status"), "value" => $lng->txt("crs_status_pending"));
     }
     include_once './Modules/Course/classes/class.ilObjCourseAccess.php';
     $info = ilObjCourseAccess::lookupRegistrationInfo($this->obj_id);
     if ($info['reg_info_list_prop']) {
         $props[] = array('alert' => false, 'newline' => true, 'property' => $info['reg_info_list_prop']['property'], 'value' => $info['reg_info_list_prop']['value']);
     }
     if ($info['reg_info_list_prop_limit']) {
         $props[] = array('alert' => false, 'newline' => false, 'property' => $info['reg_info_list_prop_limit']['property'], 'propertyNameVisible' => strlen($info['reg_info_list_prop_limit']['property']) ? true : false, 'value' => $info['reg_info_list_prop_limit']['value']);
     }
     // waiting list
     include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
     if (ilCourseWaitingList::_isOnList($ilUser->getId(), $this->obj_id)) {
         $props[] = array("alert" => true, "property" => $lng->txt('member_status'), "value" => $lng->txt('on_waiting_list'));
     }
     // check for certificates
     include_once "./Modules/Course/classes/class.ilCourseCertificateAdapter.php";
     if (ilCourseCertificateAdapter::_hasUserCertificate($ilUser->getId(), $this->obj_id)) {
         $lng->loadLanguageModule('certificate');
         $cmd_link = "ilias.php?baseClass=ilRepositoryGUI&amp;ref_id=" . $this->ref_id . "&amp;cmd=deliverCertificate";
         $props[] = array("alert" => false, "property" => $lng->txt("passed"), "value" => '<a href="' . $cmd_link . '">' . $lng->txt("download_certificate") . '</a>');
     }
     return $props;
 }
 /**
  * Get participant ids for given object
  *
  * @param	int		$a_ref_id
  * @return	array
  */
 public static function getParticipantsForObject($a_ref_id)
 {
     global $tree;
     $obj_id = ilObject::_lookupObjectId($a_ref_id);
     $obj_type = ilObject::_lookupType($obj_id);
     // try to get participants from (parent) course/group
     switch ($obj_type) {
         case "crs":
             include_once "Modules/Course/classes/class.ilCourseParticipants.php";
             $member_obj = ilCourseParticipants::_getInstanceByObjId($obj_id);
             return $member_obj->getMembers();
         case "grp":
             include_once "Modules/Group/classes/class.ilGroupParticipants.php";
             $member_obj = ilGroupParticipants::_getInstanceByObjId($obj_id);
             return $member_obj->getMembers();
         default:
             // walk path to find course or group object and use members of that object
             $path = $tree->getPathId($a_ref_id);
             array_pop($path);
             foreach (array_reverse($path) as $path_ref_id) {
                 $type = ilObject::_lookupType($path_ref_id, true);
                 if ($type == "crs" || $type == "grp") {
                     return self::getParticipantsForObject($path_ref_id);
                 }
             }
             break;
     }
     $a_users = null;
     // no participants possible: use tracking/object data where possible
     switch ($obj_type) {
         case "sahs":
             include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
             $subtype = ilObjSAHSLearningModule::_lookupSubType($obj_id);
             if ($subtype == "scorm2004") {
                 // based on cmi_node/cp_node, used for scorm tracking data views
                 include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php";
                 $mod = new ilObjSCORM2004LearningModule($obj_id, false);
                 $all = $mod->getTrackedUsers("");
                 if ($all) {
                     $a_users = array();
                     foreach ($all as $item) {
                         $a_users[] = $item["user_id"];
                     }
                 }
             } else {
                 include_once "./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php";
                 $a_users = ilObjSCORMTracking::_getTrackedUsers($obj_id);
             }
             break;
         case "exc":
             include_once "./Modules/Exercise/classes/class.ilExerciseMembers.php";
             include_once "./Modules/Exercise/classes/class.ilObjExercise.php";
             $exc = new ilObjExercise($obj_id, false);
             $members = new ilExerciseMembers($exc);
             $a_users = $members->getMembers();
             break;
         case "tst":
             include_once "./Services/Tracking/classes/class.ilLPStatusTestFinished.php";
             $a_users = ilLPStatusTestFinished::getParticipants($obj_id);
             break;
         default:
             // no sensible data: return null
             break;
     }
     return $a_users;
 }
示例#27
0
 public static function _deassignPurchasedCourseMemberRole($a_ref_id, $a_user_id)
 {
     include_once './Modules/Course/classes/class.ilCourseParticipants.php';
     $obj_id = ilObject::_lookupObjectId($a_ref_id);
     $participants = ilCourseParticipants::_getInstanceByObjId($obj_id);
     $res = $participants->delete($a_user_id, IL_CRS_MEMBER);
 }
示例#28
0
 protected function getNotificationTargetUserIds()
 {
     global $tree;
     if ($this->getTutorNotificationTarget() == self::NOTIFICATION_INVITED_USERS) {
         $user_ids = $this->getInvitedUsers();
     } else {
         $parent_grp_ref_id = $tree->checkForParentType($this->getRefId(), "grp");
         if ($parent_grp_ref_id) {
             include_once "Modules/Group/classes/class.ilGroupParticipants.php";
             $part = new ilGroupParticipants(ilObject::_lookupObjId($parent_grp_ref_id));
             $user_ids = $part->getMembers();
         } else {
             $parent_crs_ref_id = $tree->checkForParentType($this->getRefId(), "crs");
             if ($parent_crs_ref_id) {
                 include_once "Modules/Course/classes/class.ilCourseParticipants.php";
                 $part = new ilCourseParticipants(ilObject::_lookupObjId($parent_crs_ref_id));
                 $user_ids = $part->getMembers();
             }
         }
     }
     return $user_ids;
 }
示例#29
0
 /**
  * @see ilMembershipRegistrationCodes::register()
  * @param int user_id
  * @param int role
  * @param bool force registration and do not check registration constraints.
  */
 public function register($a_user_id, $a_role = ilCourseConstants::CRS_MEMBER, $a_force_registration = false)
 {
     global $ilCtrl, $tree;
     include_once './Services/Membership/exceptions/class.ilMembershipRegistrationException.php';
     include_once "./Modules/Course/classes/class.ilCourseParticipants.php";
     $part = ilCourseParticipants::_getInstanceByObjId($this->getId());
     if ($part->isAssigned($a_user_id)) {
         return true;
     }
     if (!$a_force_registration) {
         // Availability
         if ($this->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_DEACTIVATED) {
             include_once './Modules/Group/classes/class.ilObjGroupAccess.php';
             if (!ilObjCourseAccess::_usingRegistrationCode()) {
                 throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() . ', course subscription is deactivated.', '456');
             }
         }
         // Time Limitation
         if ($this->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_LIMITED) {
             if (!$this->inSubscriptionTime()) {
                 throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() . ', course is out of registration time.', '789');
             }
         }
         // Max members
         if ($this->isSubscriptionMembershipLimited()) {
             $free = max(0, $this->getSubscriptionMaxMembers() - $part->getCountMembers());
             include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
             $waiting_list = new ilCourseWaitingList($this->getId());
             if ($this->enabledWaitingList() and (!$free or $waiting_list->getCountUsers())) {
                 $waiting_list->addToList($a_user_id);
                 $this->lng->loadLanguageModule("crs");
                 $info = sprintf($this->lng->txt('crs_added_to_list'), $waiting_list->getPosition($a_user_id));
                 include_once './Modules/Course/classes/class.ilCourseParticipants.php';
                 $participants = ilCourseParticipants::_getInstanceByObjId($this->getId());
                 $participants->sendNotification($participants->NOTIFY_WAITING_LIST, $a_user_id);
                 throw new ilMembershipRegistrationException($info, '124');
             }
             if (!$this->enabledWaitingList() && !$free) {
                 throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() . ', membership is limited.', '123');
             }
         }
     }
     $part->add($a_user_id, $a_role);
     $part->sendNotification($part->NOTIFY_ACCEPT_USER, $a_user_id);
     $part->sendNotification($part->NOTIFY_ADMINS, $a_user_id);
     include_once './Modules/Forum/classes/class.ilForumNotification.php';
     ilForumNotification::checkForumsExistsInsert($this->getRefId(), $a_user_id);
     return true;
 }
示例#30
0
 public function purchase($tid)
 {
     global $lng;
     $this->getDebtor();
     $this->deb->createInvoice();
     $products = array();
     foreach ($this->sc as $i) {
         $pod = ilPaymentObject::_getObjectData($i['pobject_id']);
         $bo = new ilPaymentBookings($this->ilUser->getId());
         $ilias_tid = $this->ilUser->getId() . "_" . $tid;
         // psc_id, pobject_id, obj_id, typ, betrag_string
         $bo->setTransaction($ilias_tid);
         $bo->setPobjectId(isset($i['pobject_id']) ? $i['pobject_id'] : 0);
         $bo->setCustomerId($this->ilUser->getId());
         $bo->setVendorId($pod['vendor_id']);
         $bo->setPayMethod($this->paytype);
         $bo->setOrderDate(time());
         // $bo->setDuration($i['dauer']); // duration
         // $bo->setPrice(  $i['betrag'] ); // amount
         //$bo->setPrice( ilPaymentPrices::_getPriceString( $i['price_id'] ));
         $bo->setDuration($i['duration']);
         $bo->setPrice($i['price_string']);
         $bo->setDiscount(0);
         $bo->setVoucher('');
         $bo->setVatRate($i['vat_rate']);
         $bo->setVatUnit($i['vat_unit']);
         $bo->setTransactionExtern($tid);
         // $product_name = $i['buchungstext'];
         //$duration = $i['dauer'];
         //$amount = $i['betrag'];
         $product_name = $i['object_title'];
         $duration = $i['duration'];
         $amount = $i['price'];
         // -> ? $i['price_string']
         include_once './Services/Payment/classes/class.ilPayMethods.php';
         $save_adr = (int) ilPaymethods::_EnabledSaveUserAddress($this->paytype) ? 1 : 0;
         //if($save_adr == 1)
         //{
         $bo->setStreet($this->ilUser->getStreet(), '');
         $bo->setPoBox('');
         //$this->ilUser->);
         $bo->setZipcode($this->ilUser->getZipcode());
         $bo->setCity($this->ilUser->getCity());
         $bo->setCountry($this->ilUser->getCountry());
         //}
         $bo->setPayed(1);
         $bo->setAccess(1);
         $bo->setAccessExtension($this->sc['extension']);
         $boid = $bo->add();
         //$bo->update();
         if ($i['typ'] == 'crs') {
             include_once './Modules/Course/classes/class.ilCourseParticipants.php';
             $this->deb->createInvoiceLine(0, $product_name . " (" . $duration . ")", 1, $amount);
             $products[] = $product_name;
             $obj_id = ilObject::_lookupObjId($pod["ref_id"]);
             $cp = ilCourseParticipants::_getInstanceByObjId($obj_id);
             $cp->add($this->ilUser->getId(), IL_CRS_MEMBER);
             $cp->sendNotification($cp->NOTIFY_ACCEPT_SUBSCRIBER, $this->ilUser->getId());
         }
     }
     $inv = $this->deb->bookInvoice();
     $invoice_number = $this->deb->getInvoiceNumber();
     $attach = $this->deb->getInvoicePDF($inv);
     $this->deb->saveInvoice($attach, false);
     $lng->loadLanguageModule('payment');
     $this->deb->sendInvoice($lng->txt('pay_order_paid_subject'), $this->ilUser->getFullName() . ",\n" . str_replace('%products%', implode(", ", $products), $lng->txt('pay_order_paid_body')), $this->ilUser->getEmail(), $attach, $lng->txt('pays_invoice') . "-" . $invoice_number);
     $this->cart->emptyShoppingCart();
 }