/** * 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; }
/** * * @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(); } }
/** * 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'); } }
/** * 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); } }
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); } }
/** * 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; } }
/** * 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 assignCourses() { if (count($this->getAssignedCourses()) == 0) { return false; } foreach ($this->getAssignedCourses() as $crs_obj_id) { if (ilObject2::_lookupType($crs_obj_id) != 'crs') { continue; } $part = ilCourseParticipants::_getInstanceByObjId($crs_obj_id); $usr_id = $this->getUsrObject()->getId(); $part->add($usr_id, ilCourseConstants::CRS_MEMBER); $all_refs = ilObject2::_getAllReferences($crs_obj_id); $first = array_shift(array_values($all_refs)); ilObjUser::_dropDesktopItem($usr_id, $first, 'crs'); } }
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(); }
/** * Get members for object * @param int $a_obj_id * @return array */ protected static function getMembers($a_obj_id) { global $ilObjDataCache, $tree; switch ($ilObjDataCache->lookupType($a_obj_id)) { case 'crs': include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $member_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id); return $member_obj->getMembers(); case 'grp': include_once 'Modules/Group/classes/class.ilGroupParticipants.php'; $member_obj = ilGroupParticipants::_getInstanceByObjId($a_obj_id); return $member_obj->getMembers(); case 'fold': $folder_ref_ids = ilObject::_getAllReferences($a_obj_id); $folder_ref_id = current($folder_ref_ids); if ($crs_id = $tree->checkForParentType($folder_ref_id, 'crs')) { include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $member_obj = ilCourseParticipants::_getInstanceByObjId(ilObject::_lookupObjId($crs_id)); return $member_obj->getMembers(); } break; } return array(); }
/** * 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; }
/** * 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; }
public function getMembers($a_search = true) { include_once "Modules/Course/classes/class.ilCourseParticipants.php"; $member_obj = ilCourseParticipants::_getInstanceByObjId($this->obj_id); return $member_obj->getMembers(); }
/** * 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++; } } }
/** * Init member object * @return */ protected function initMembers() { if ($this->getType() == 'crs') { $this->members = ilCourseParticipants::_getInstanceByObjId($this->getObjId()); } if ($this->getType() == 'grp') { $this->members = ilGroupParticipants::_getInstanceByObjId($this->getObjId()); } return true; }
/** * 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; } }
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 members for object * @param int $a_obj_id * @return array */ protected static function getMembers($a_obj_id) { include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $member_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id); return $member_obj->getMembers(); }
/** * 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(); }
/** * @return ilParticipants for course or group */ public function getParticipantsObject() { global $tree, $ilErr; $grp_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp'); $crs_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs'); if ($this->isParentObjectCrsOrGrp() == false) { $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE); } /** * @var $oParticipants ilParticipants */ $oParticipants = null; if ($grp_ref_id > 0) { $parent_obj = ilObjectFactory::getInstanceByRefId($grp_ref_id); include_once 'Modules/Group/classes/class.ilGroupParticipants.php'; $oParticipants = ilGroupParticipants::_getInstanceByObjId($parent_obj->getId()); return $oParticipants; } else { if ($crs_ref_id > 0) { $parent_obj = ilObjectFactory::getInstanceByRefId($crs_ref_id); include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $oParticipants = ilCourseParticipants::_getInstanceByObjId($parent_obj->getId()); return $oParticipants; } } return $oParticipants; }
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; }
/** * @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) { 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 (!self::_registrationEnabled($this->getId())) { $this->lng->loadLanguageModule('crs'); throw new ilMembershipRegistrationException($this->lng->txt('crs_info_reg_deactivated'), $this->getRefId()); } // 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())) { throw new ilMembershipRegistrationException('', $this->getRefId()); } } } $part->add($a_user_id, $a_role); $part->sendNotification($part->NOTIFY_ACCEPT_USER, $a_user_id); include_once './Modules/Forum/classes/class.ilForumNotification.php'; ilForumNotification::checkForumsExistsInsert($this->getRefId(), $a_user_id); return true; }
/** * 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; }
/** * 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; }
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); }
function isAssignedToCourse($sid, $course_id, $user_id) { $this->initAuth($sid); $this->initIlias(); if (!$this->__checkSession($sid)) { return $this->__raiseError($this->__getMessage(), $this->__getMessageCode()); } if (!is_numeric($course_id)) { return $this->__raiseError('No valid course id given. Please choose an existing reference id of an ILIAS course', 'Client'); } global $rbacsystem; if (($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs') { $course_id = end($ref_ids = ilObject::_getAllReferences($course_id)); if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs') { return $this->__raiseError('Invalid course id. Object with id "' . $course_id . '" is not of type "course"', 'Client'); } } if (ilObject::_lookupType($user_id) != 'usr') { return $this->__raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client'); } if (!($tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false))) { return $this->__raiseError('Cannot create course instance!', 'Server'); } if (!$rbacsystem->checkAccess('write', $course_id)) { return $this->__raiseError('Check access failed. No permission to write to course', 'Server'); } include_once './Modules/Course/classes/class.ilCourseParticipants.php'; $crs_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId()); if ($crs_members->isAdmin($user_id)) { return IL_CRS_ADMIN; } if ($crs_members->isTutor($user_id)) { return IL_CRS_TUTOR; } if ($crs_members->isMember($user_id)) { return IL_CRS_MEMBER; } return "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; }
/** * Show user's courses */ public function showMyCourses() { global $lng, $ilUser, $ilObjDataCache, $tree, $tpl, $rbacsystem; include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $this->tpl->setTitle($this->lng->txt('mail_addressbook')); $searchTpl = new ilTemplate('tpl.mail_search_template.html', true, true, 'Services/Contact'); $_GET['view'] = 'mycourses'; $lng->loadLanguageModule('crs'); include_once 'Services/Contact/classes/class.ilMailSearchCoursesTableGUI.php'; $table = new ilMailSearchCoursesTableGUI($this, "crs", $_GET["ref"]); $table->setId('search_crs_tbl'); include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $crs_ids = ilCourseParticipants::_getMembershipByType($ilUser->getId(), 'crs'); $counter = 0; $tableData = array(); if (is_array($crs_ids) && count($crs_ids) > 0) { $num_courses_hidden_members = 0; include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php"; foreach ($crs_ids as $crs_id) { /** * @var $oTmpCrs ilObjCourse */ $oTmpCrs = ilObjectFactory::getInstanceByObjId($crs_id); $isOffline = !$oTmpCrs->isActivated(); $hasUntrashedReferences = ilObject::_hasUntrashedReference($crs_id); $showMemberListEnabled = (bool) $oTmpCrs->getShowMembers(); $ref_ids = array_keys(ilObject::_getAllReferences($crs_id)); $isPrivilegedUser = $rbacsystem->checkAccess('write', $ref_ids[0]); if ($hasUntrashedReferences && (!$isOffline && $showMemberListEnabled || $isPrivilegedUser)) { $oCrsParticipants = ilCourseParticipants::_getInstanceByObjId($crs_id); $crs_members = $oCrsParticipants->getParticipants(); foreach ($crs_members as $key => $member) { $tmp_usr = new ilObjUser($member); if ($tmp_usr->checkTimeLimit() == false || $tmp_usr->getActive() == false) { unset($crs_members[$key]); } } unset($tmp_usr); $hiddenMembers = false; if ((int) $oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED) { ++$num_courses_hidden_members; $hiddenMembers = true; } unset($oTmpCrs); $ref_ids = ilObject::_getAllReferences($crs_id); $ref_id = current($ref_ids); $path_arr = $tree->getPathFull($ref_id, $tree->getRootId()); $path_counter = 0; $path = ''; foreach ($path_arr as $data) { if ($path_counter++) { $path .= " -> "; } $path .= $data['title']; } $path = $this->lng->txt('path') . ': ' . $path; $current_selection_list = new ilAdvancedSelectionListGUI(); $current_selection_list->setListTitle($this->lng->txt("actions")); $current_selection_list->setId("act_" . $counter); $this->ctrl->setParameter($this, 'search_crs', $crs_id); $this->ctrl->setParameter($this, 'view', 'mycourses'); if ($_GET["ref"] == "mail") { if ($this->mailing_allowed) { $current_selection_list->addItem($this->lng->txt("mail_members"), '', $this->ctrl->getLinkTarget($this, "mail")); } } else { if ($_GET["ref"] == "wsp") { $current_selection_list->addItem($this->lng->txt("wsp_share_with_members"), '', $this->ctrl->getLinkTarget($this, "share")); } } $current_selection_list->addItem($this->lng->txt("mail_list_members"), '', $this->ctrl->getLinkTarget($this, "showMembers")); $this->ctrl->clearParameters($this); $rowData = array("CRS_ID" => $crs_id, "CRS_NAME" => $ilObjDataCache->lookupTitle($crs_id), "CRS_NO_MEMBERS" => count($crs_members), "CRS_PATH" => $path, 'COMMAND_SELECTION_LIST' => $current_selection_list->getHTML(), "hidden_members" => $hiddenMembers); $counter++; $tableData[] = $rowData; } } //if((int)$counter) //{ // $table->addCommandButton('mail',$lng->txt('mail_members')); // $table->addCommandButton('showMembers',$lng->txt('mail_list_members')); //} if ($num_courses_hidden_members > 0) { $searchTpl->setCurrentBlock('caption_block'); $searchTpl->setVariable('TXT_LIST_MEMBERS_NOT_AVAILABLE', $this->lng->txt('mail_crs_list_members_not_available')); $searchTpl->parseCurrentBlock(); } } $searchTpl->setVariable('TXT_MARKED_ENTRIES', $lng->txt('marked_entries')); $table->setData($tableData); if ($_GET['ref'] == 'mail') { $this->tpl->setVariable('BUTTON_CANCEL', $lng->txt('cancel')); } $searchTpl->setVariable('TABLE', $table->getHtml()); $tpl->setContent($searchTpl->get()); if ($_GET["ref"] != "wsp") { $tpl->show(); } }