protected function getItems($a_content_obj) { $items = ilObjCourseGrouping::_getVisibleGroupings($a_content_obj->getId()); $data = array(); foreach ($items as $grouping_id) { $tmp_obj = new ilObjCourseGrouping($grouping_id); $data[$grouping_id]['id'] = $grouping_id; $data[$grouping_id]['title'] = $tmp_obj->getTitle(); $data[$grouping_id]['unique'] = $this->lng->txt($tmp_obj->getUniqueField()); // Description if (strlen($tmp_obj->getDescription())) { $data[$grouping_id]['description'] = $tmp_obj->getDescription(); } // Assigned items $assigned_items = $tmp_obj->getAssignedItems(); foreach ($assigned_items as $condition) { $data[$grouping_id]['assigned'][] = ilObject::_lookupTitle($condition['target_obj_id']); } } $this->setData($data); }
/** * delete course and all related data * * @access public * @return boolean true if all object data were removed; false if only a references were removed */ function delete() { global $ilAppEventHandler; // always call parent delete function first!! if (!parent::delete()) { return false; } // delete meta data $this->deleteMetaData(); // put here course specific stuff $this->__deleteSettings(); include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; ilCourseParticipants::_deleteAllEntries($this->getId()); $this->initCourseArchiveObject(); $this->archives_obj->deleteAll(); include_once './Modules/Course/classes/class.ilCourseObjective.php'; ilCourseObjective::_deleteAll($this->getId()); include_once './Modules/Course/classes/class.ilObjCourseGrouping.php'; ilObjCourseGrouping::_deleteAll($this->getId()); include_once './Modules/Course/classes/class.ilCourseFile.php'; ilCourseFile::_deleteByCourse($this->getId()); include_once 'Modules/Course/classes/Export/class.ilCourseDefinedFieldDefinition.php'; ilCourseDefinedFieldDefinition::_deleteByContainer($this->getId()); $ilAppEventHandler->raise('Modules/Course', 'delete', array('object' => $this, 'obj_id' => $this->getId(), 'appointments' => $this->prepareAppointments('delete'))); return true; }
/** * fill row * * @access public * @param * @return */ public function fillRow($a_set) { global $ilUser; include_once './Modules/Course/classes/class.ilObjCourseGrouping.php'; if (!ilObjCourseGrouping::_checkGroupingDependencies($this->getParentObject()->object, $a_set['usr_id']) and $ids = ilObjCourseGrouping::getAssignedObjects()) { $prefix = $this->getParentObject()->object->getType(); $this->tpl->setVariable('ALERT_MSG', sprintf($this->lng->txt($prefix . '_lim_assigned'), ilObject::_lookupTitle(current($ids)))); } $this->tpl->setVariable('VAL_ID', $a_set['usr_id']); $this->tpl->setVariable('VAL_NAME', $a_set['lastname'] . ', ' . $a_set['firstname']); foreach ($this->getSelectedColumns() as $field) { switch ($field) { case 'gender': $a_set['gender'] = $a_set['gender'] ? $this->lng->txt('gender_' . $a_set['gender']) : ''; $this->tpl->setCurrentBlock('custom_fields'); $this->tpl->setVariable('VAL_CUST', $a_set[$field]); $this->tpl->parseCurrentBlock(); break; case 'birthday': $a_set['birthday'] = $a_set['birthday'] ? ilDatePresentation::formatDate(new ilDate($a_set['birthday'], IL_CAL_DATE)) : $this->lng->txt('no_date'); $this->tpl->setCurrentBlock('custom_fields'); $this->tpl->setVariable('VAL_CUST', $a_set[$field]); $this->tpl->parseCurrentBlock(); break; case 'odf_last_update': $this->tpl->setVariable('VAL_CUST', (string) $a_set['odf_info_txt']); break; default: $this->tpl->setCurrentBlock('custom_fields'); $this->tpl->setVariable('VAL_CUST', isset($a_set[$field]) ? (string) $a_set[$field] : ''); $this->tpl->parseCurrentBlock(); break; } } $this->tpl->setVariable('VAL_SUBTIME', ilDatePresentation::formatDate(new ilDateTime($a_set['sub_time'], IL_CAL_UNIX))); $this->showActionLinks($a_set); if ($this->getShowSubject()) { if (strlen($a_set['subject'])) { $this->tpl->setCurrentBlock('subject'); $this->tpl->setVariable('VAL_SUBJECT', '"' . $a_set['subject'] . '"'); $this->tpl->parseCurrentBlock(); } else { $this->tpl->touchBlock('subject'); } } }
/** * Show membership limitations * * @access protected * @return */ protected function fillMembershipLimitation() { global $ilAccess, $ilCtrl; include_once 'Modules/Course/classes/class.ilObjCourseGrouping.php'; if (!($items = ilObjCourseGrouping::_getGroupingItems($this->container))) { return true; } $mem = new ilCustomInputGUI($this->lng->txt('groupings')); $tpl = new ilTemplate('tpl.membership_limitation_form.html', true, true, 'Services/Membership'); $tpl->setVariable('LIMIT_INTRO', $this->lng->txt($this->type . '_grp_info_reg')); foreach ($items as $ref_id) { $obj_id = ilObject::_lookupObjId($ref_id); $type = ilObject::_lookupType($obj_id); $title = ilObject::_lookupTitle($obj_id); if ($ilAccess->checkAccess('visible', '', $ref_id, $type)) { include_once './Services/Link/classes/class.ilLink.php'; $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id); $tpl->setVariable('LINK_ITEM', $ilCtrl->getLinkTargetByClass("ilrepositorygui", "")); $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]); $tpl->setVariable('ITEM_LINKED_TITLE', $title); } else { $tpl->setVariable('ITEM_TITLE'); } $tpl->setCurrentBlock('items'); $tpl->setVariable('TYPE_ICON', ilObject::_getIcon($obj_id, tiny, $type)); $tpl->setVariable('ALT_ICON', $this->lng->txt('obj_' . $type)); $tpl->parseCurrentBlock(); } $mem->setHtml($tpl->get()); if (!ilObjCourseGrouping::_checkGroupingDependencies($this->container)) { $mem->setAlert($this->container->getMessage()); $this->enableRegistration(false); } $this->form->addItem($mem); }
/** * fill row * * @access public * @param * @return */ public function fillRow($a_set) { global $ilUser; include_once './Modules/Course/classes/class.ilObjCourseGrouping.php'; if (!ilObjCourseGrouping::_checkGroupingDependencies($this->getParentObject()->object, $a_set['id']) and $ids = ilObjCourseGrouping::getAssignedObjects()) { $prefix = $this->getParentObject()->object->getType(); $this->tpl->setVariable('ALERT_MSG', sprintf($this->lng->txt($prefix . '_lim_assigned'), ilObject::_lookupTitle(current($ids)))); } $this->tpl->setVariable('VAL_ID', $a_set['id']); $this->tpl->setVariable('VAL_NAME', $a_set['name']); $this->tpl->setVariable('VAL_SUBTIME', ilDatePresentation::formatDate(new ilDateTime($a_set['sub_time'], IL_CAL_UNIX))); $this->tpl->setVariable('VAL_LOGIN', $a_set['login']); $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'member_id', $a_set['id']); $link = $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()), 'sendMailToSelectedUsers'); $this->tpl->setVariable('MAIL_LINK', $link); $this->tpl->setVariable('MAIL_TITLE', $this->lng->txt('crs_mem_send_mail')); if (strlen($a_set['subject'])) { $this->tpl->setVariable('VAL_SUBJECT', '"' . $a_set['subject'] . '"'); } }
function __showWaitingList() { include_once './Modules/Course/classes/class.ilObjCourseGrouping.php'; $this->object->initWaitingList(); if ($this->object->waiting_list_obj->getCountUsers()) { $counter = 0; $f_result = array(); foreach ($this->object->waiting_list_obj->getAllUsers() as $waiting_data) { // GET USER OBJ if ($tmp_obj = ilObjectFactory::getInstanceByObjId($waiting_data['usr_id'], false)) { $waiting_list_ids[] = $waiting_data['usr_id']; $message = ''; // Check if user is member in course grouping foreach (ilObjCourseGrouping::_getGroupingCourseIds($this->object->getRefId(), $this->object->getId()) as $course_data) { $tmp_members = ilCourseParticipants::_getInstanceByObjId($course_data['id']); if ($course_data['id'] != $this->object->getId() and $tmp_members->isGroupingMember($tmp_obj->getId(), $course_data['unique'])) { $message .= '<br /><span class="ilAlert">' . $this->lng->txt('crs_member_of') . ' '; $message .= ilObject::_lookupTitle($course_data['id']) . "</span>"; } } $f_result[$counter][] = ilUtil::formCheckbox(0, "waiting_list[]", $waiting_data['usr_id']); $f_result[$counter][] = $tmp_obj->getLastname() . ', ' . $tmp_obj->getFirstname() . $message; $f_result[$counter][] = $tmp_obj->getLogin(); $f_result[$counter][] = ilDatePresentation::formatDate(new ilDateTime($waiting_data['time'], IL_CAL_UNIX)); unset($tmp_obj); ++$counter; } } $this->__showWaitingListTable($f_result, $waiting_list_ids); } // END waiting list }
function update() { global $ilErr, $ilAccess, $ilObjDataCache; if (!$ilAccess->checkAccess('write', '', $this->content_obj->getRefId())) { $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->MESSAGE); } $form = $this->initForm(false); if ($form->checkInput()) { $tmp_grouping = new ilObjCourseGrouping($_REQUEST['obj_id']); $tmp_grouping->setTitle($form->getInput('title')); $tmp_grouping->setDescription($form->getInput('description')); $tmp_grouping->setUniqueField($form->getInput('unique')); $tmp_grouping->update(); ilUtil::sendSuccess($this->lng->txt('settings_saved'), true); $this->ctrl->redirect($this, 'listGroupings'); } $form->setValuesByPost(); $this->edit($form); }
function _checkGroupingDependencies(&$container_obj, $a_user_id = null) { global $ilUser, $lng, $tree; include_once './Services/AccessControl/classes/class.ilConditionHandler.php'; $user_id = is_null($a_user_id) ? $ilUser->getId() : $a_user_id; $trigger_ids = array(); foreach (ilConditionHandler::_getConditionsOfTarget($container_obj->getRefId(), $container_obj->getId(), $container_obj->getType()) as $condition) { if ($condition['operator'] == 'not_member') { $trigger_ids[] = $condition['trigger_obj_id']; break; } } if (!count($trigger_ids)) { return true; } $matriculation_message = $assigned_message = ''; self::$assignedObjects = array(); foreach ($trigger_ids as $trigger_id) { foreach (ilConditionHandler::_getConditionsOfTrigger('crsg', $trigger_id) as $condition) { // Handle deleted items if ($tree->isDeleted($condition['target_ref_id'])) { continue; } if ($condition['operator'] == 'not_member') { switch ($condition['value']) { case 'matriculation': if (!strlen(ilObjUser::lookupMatriculation($user_id))) { if (!$matriculation_message) { $matriculation_message = $lng->txt('crs_grp_matriculation_required'); } } } if ($container_obj->getType() == 'crs') { include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $members = ilCourseParticipants::_getInstanceByObjId($condition['target_obj_id']); if ($members->isGroupingMember($user_id, $condition['value'])) { if (!$assigned_message) { self::$assignedObjects[] = $condition['target_obj_id']; $assigned_message = $lng->txt('crs_grp_already_assigned'); } } } elseif ($container_obj->getType() == 'grp') { include_once 'Modules/Group/classes/class.ilGroupParticipants.php'; $members = ilGroupParticipants::_getInstanceByObjId($condition['target_obj_id']); if ($members->isGroupingMember($user_id, $condition['value'])) { if (!$assigned_message) { self::$assignedObjects[] = $condition['target_obj_id']; $assigned_message = $lng->txt('crs_grp_already_assigned'); } } } else { if (ilObjGroup::_isMember($user_id, $condition['target_ref_id'], $condition['value'])) { if (!$assigned_message) { self::$assignedObjects[] = $condition['target_obj_id']; $assigned_message = $lng->txt('crs_grp_already_assigned'); } } } } } } if ($matriculation_message) { $container_obj->appendMessage($matriculation_message); return false; } elseif ($assigned_message) { $container_obj->appendMessage($assigned_message); return false; } return true; }
/** * checks wether a single condition is fulfilled * every trigger object type must implement a static method * _checkCondition($a_operator, $a_value) */ function _checkCondition($a_id, $a_usr_id = 0) { global $ilUser; $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId(); $condition = ilConditionHandler::_getCondition($a_id); switch ($condition['trigger_type']) { case "tst": include_once './Modules/Test/classes/class.ilObjTestAccess.php'; return ilObjTestAccess::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id); case "crs": include_once './Modules/Course/classes/class.ilObjCourse.php'; return ilObjCourse::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id); case 'exc': include_once './Modules/Exercise/classes/class.ilObjExercise.php'; return ilObjExercise::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id); case 'crsg': include_once './Modules/Course/classes/class.ilObjCourseGrouping.php'; return ilObjCourseGrouping::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id); case 'sahs': include_once './Services/Tracking/classes/class.ilLPStatus.php'; return ilLPStatus::_lookupStatus($condition['trigger_obj_id'], $a_usr_id) == LP_STATUS_COMPLETED_NUM; case 'svy': include_once './Modules/Survey/classes/class.ilObjSurvey.php'; return ilObjSurvey::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id); default: return false; } }
/** * checks wether a single condition is fulfilled * every trigger object type must implement a static method * _checkCondition($a_operator, $a_value) */ function _checkCondition($a_id, $a_usr_id = 0) { global $ilUser, $objDefinition; $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId(); $condition = ilConditionHandler::_getCondition($a_id); // check lp if ($condition['operator'] == self::OPERATOR_LP) { include_once './Services/Tracking/classes/class.ilLPStatus.php'; return ilLPStatus::_hasUserCompleted($condition['trigger_obj_id'], $a_usr_id); } switch ($condition['trigger_type']) { case 'crsg': include_once './Modules/Course/classes/class.ilObjCourseGrouping.php'; return ilObjCourseGrouping::_checkCondition($condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id); } $class = $objDefinition->getClassName($condition['trigger_type']); $location = $objDefinition->getLocation($condition['trigger_type']); $full_class = "ilObj" . $class . "Access"; include_once $location . "/class." . $full_class . ".php"; $fullfilled = call_user_func(array($full_class, 'checkCondition'), $condition['trigger_obj_id'], $condition['operator'], $condition['value'], $a_usr_id); return $fullfilled; }