/** * Parse data * @return * * @global ilRbacReview $rbacreview */ public function parse() { global $rbacreview; $this->determineOffsetAndOrder(); include_once './Services/User/classes/class.ilUserQuery.php'; $additional_fields = $this->getSelectedColumns(); unset($additional_fields["firstname"]); unset($additional_fields["lastname"]); unset($additional_fields["last_login"]); unset($additional_fields["access_until"]); unset($additional_fields['consultation_hour']); unset($additional_fields['prtf']); $udf_ids = $usr_data_fields = $odf_ids = array(); foreach ($additional_fields as $field) { if (substr($field, 0, 3) == 'udf') { $udf_ids[] = substr($field, 4); continue; } if (substr($field, 0, 3) == 'odf') { $odf_ids[] = substr($field, 4); continue; } $usr_data_fields[] = $field; } $usr_data = ilUserQuery::getUserListData($this->getOrderField(), $this->getOrderDirection(), $this->getOffset(), $this->getLimit(), '', '', null, false, false, 0, $this->getRoleId(), null, $usr_data_fields, $part); foreach ((array) $usr_data['set'] as $user) { $usr_ids[] = $user['usr_id']; } // merge course data $course_user_data = $this->getParentObject()->readMemberData($usr_ids, $this->type == 'admin', $this->getSelectedColumns()); $a_user_data = array(); foreach ((array) $usr_data['set'] as $ud) { $a_user_data[$ud['usr_id']] = array_merge($ud, $course_user_data[$ud['usr_id']]); if ($this->show_lp_status_sync) { // #9912 / #13208 $passed_info = ""; if ($a_user_data[$ud['usr_id']]["passed_info"]) { $pinfo = $a_user_data[$ud['usr_id']]["passed_info"]; if ($pinfo["user_id"]) { if ($pinfo["user_id"] < 0) { $passed_info = $this->lng->txt("crs_passed_status_system"); } else { if ($pinfo["user_id"] > 0) { $name = ilObjUser::_lookupName($pinfo["user_id"]); $passed_info = $this->lng->txt("crs_passed_status_manual_by") . ": " . $name["login"]; } } } if ($pinfo["timestamp"]) { $passed_info .= "<br />" . ilDatePresentation::formatDate($pinfo["timestamp"]); } } $a_user_data[$ud['usr_id']]["passed_info"] = $passed_info; } } // Custom user data fields if ($udf_ids) { include_once './Services/User/classes/class.ilUserDefinedData.php'; $data = ilUserDefinedData::lookupData($usr_ids, $udf_ids); foreach ($data as $usr_id => $fields) { if (!$this->checkAcceptance($usr_id)) { continue; } foreach ($fields as $field_id => $value) { $a_user_data[$usr_id]['udf_' . $field_id] = $value; } } } // Object specific user data fields if ($odf_ids) { include_once './Modules/Course/classes/Export/class.ilCourseUserData.php'; $data = ilCourseUserData::_getValuesByObjId($this->getParentObject()->object->getId()); foreach ($data as $usr_id => $fields) { // #7264: as we get data for all course members filter against user data if (!$this->checkAcceptance($usr_id) || !in_array($usr_id, $usr_ids)) { continue; } foreach ($fields as $field_id => $value) { $a_user_data[$usr_id]['odf_' . $field_id] = $value; } } // add last edit date include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php'; foreach (ilObjectCustomUserFieldHistory::lookupEntriesByObjectId($this->getParentObject()->object->getId()) as $usr_id => $edit_info) { if (!isset($a_user_data[$usr_id])) { continue; } include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php'; if ($usr_id == $edit_info['update_user']) { $a_user_data[$usr_id]['odf_last_update'] = ''; $a_user_data[$usr_id]['odf_info_txt'] = $GLOBALS['lng']->txt('cdf_edited_by_self'); if (ilPrivacySettings::_getInstance()->enabledAccessTimesByType($this->getParentObject()->object->getType())) { $a_user_data[$usr_id]['odf_last_update'] .= '_' . $edit_info['editing_time']->get(IL_CAL_UNIX); $a_user_data[$usr_id]['odf_info_txt'] .= ', ' . ilDatePresentation::formatDate($edit_info['editing_time']); } } else { $a_user_data[$usr_id]['odf_last_update'] = $edit_info['update_user']; $a_user_data[$usr_id]['odf_last_update'] .= '_' . $edit_info['editing_time']->get(IL_CAL_UNIX); $name = ilObjUser::_lookupName($edit_info['update_user']); $a_user_data[$usr_id]['odf_info_txt'] = $name['firstname'] . ' ' . $name['lastname'] . ', ' . ilDatePresentation::formatDate($edit_info['editing_time']); } } } foreach ($usr_data['set'] as $user) { // Check acceptance if (!$this->checkAcceptance($user['usr_id'])) { continue; } // DONE: accepted foreach ($usr_data_fields as $field) { $a_user_data[$user['usr_id']][$field] = $user[$field] ? $user[$field] : ''; } } // consultation hours if ($this->isColumnSelected('consultation_hour')) { include_once './Services/Booking/classes/class.ilBookingEntry.php'; foreach (ilBookingEntry::lookupManagedBookingsForObject($this->getParentObject()->object->getId(), $GLOBALS['ilUser']->getId()) as $buser => $booking) { if (isset($a_user_data[$buser])) { $a_user_data[$buser]['consultation_hour'] = $booking[0]['dt']; $a_user_data[$buser]['consultation_hour_end'] = $booking[0]['dtend']; $a_user_data[$buser]['consultation_hours'] = $booking; } } } $this->setMaxCount($usr_data['cnt'] ? $usr_data['cnt'] : 0); return $this->setData($a_user_data); }
/** * read data * * @access protected * @param * @return */ public function readSubscriberData() { include_once './Services/Membership/classes/class.ilParticipants.php'; $sub_data = ilParticipants::lookupSubscribersData($this->getParentObject()->object->getId()); $sub_ids = array(); foreach ($sub_data as $usr_id => $usr_data) { $sub_ids[] = $usr_id; } $this->determineOffsetAndOrder(); include_once './Services/User/classes/class.ilUserQuery.php'; $additional_fields = $this->getSelectedColumns(); unset($additional_fields["firstname"]); unset($additional_fields["lastname"]); unset($additional_fields["last_login"]); unset($additional_fields["access_until"]); $udf_ids = $usr_data_fields = $odf_ids = array(); foreach ($additional_fields as $field) { if (substr($field, 0, 3) == 'udf') { $udf_ids[] = substr($field, 4); continue; } if (substr($field, 0, 3) == 'odf') { $odf_ids[] = substr($field, 4); continue; } $usr_data_fields[] = $field; } $usr_data = ilUserQuery::getUserListData($this->getOrderField(), $this->getOrderDirection(), $this->getOffset(), $this->getLimit(), '', '', null, false, false, 0, 0, null, $usr_data_fields, $sub_ids); foreach ((array) $usr_data['set'] as $user) { $usr_ids[] = $user['usr_id']; } // merge course data $course_user_data = $this->getParentObject()->readMemberData($usr_ids, $this->type == 'admin'); $a_user_data = array(); foreach ((array) $usr_data['set'] as $ud) { $a_user_data[$ud['usr_id']] = array_merge($ud, (array) $course_user_data[$ud['usr_id']]); } // Custom user data fields if ($udf_ids) { include_once './Services/User/classes/class.ilUserDefinedData.php'; $data = ilUserDefinedData::lookupData($usr_ids, $udf_ids); foreach ($data as $usr_id => $fields) { if (!$this->checkAcceptance($usr_id)) { continue; } foreach ($fields as $field_id => $value) { $a_user_data[$usr_id]['udf_' . $field_id] = $value; } } } // Object specific user data fields if ($odf_ids) { include_once './Modules/Course/classes/Export/class.ilCourseUserData.php'; $data = ilCourseUserData::_getValuesByObjId($this->getParentObject()->object->getId()); foreach ($data as $usr_id => $fields) { // #7264: as we get data for all course members filter against user data if (!$this->checkAcceptance($usr_id) || !in_array($usr_id, $usr_ids)) { continue; } foreach ($fields as $field_id => $value) { $a_user_data[$usr_id]['odf_' . $field_id] = $value; } } // add last edit date include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php'; foreach (ilObjectCustomUserFieldHistory::lookupEntriesByObjectId($this->getParentObject()->object->getId()) as $usr_id => $edit_info) { if (!isset($a_user_data[$usr_id])) { continue; } include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php'; if ($usr_id == $edit_info['update_user']) { $a_user_data[$usr_id]['odf_last_update'] = ''; $a_user_data[$usr_id]['odf_info_txt'] = $GLOBALS['lng']->txt('cdf_edited_by_self'); if (ilPrivacySettings::_getInstance()->enabledAccessTimesByType($this->getParentObject()->object->getType())) { $a_user_data[$usr_id]['odf_last_update'] .= '_' . $edit_info['editing_time']->get(IL_CAL_UNIX); $a_user_data[$usr_id]['odf_info_txt'] .= ', ' . ilDatePresentation::formatDate($edit_info['editing_time']); } } else { $a_user_data[$usr_id]['odf_last_update'] = $edit_info['update_user']; $a_user_data[$usr_id]['odf_last_update'] .= '_' . $edit_info['editing_time']->get(IL_CAL_UNIX); $name = ilObjUser::_lookupName($edit_info['update_user']); $a_user_data[$usr_id]['odf_info_txt'] = $name['firstname'] . ' ' . $name['lastname'] . ', ' . ilDatePresentation::formatDate($edit_info['editing_time']); } } } foreach ($usr_data['set'] as $user) { // Check acceptance if (!$this->checkAcceptance($user['usr_id'])) { continue; } // DONE: accepted foreach ($usr_data_fields as $field) { $a_user_data[$user['usr_id']][$field] = $user[$field] ? $user[$field] : ''; } } // Waiting list subscription foreach ($sub_data as $usr_id => $usr_data) { if (!in_array($usr_id, $usr_ids)) { continue; } $a_user_data[$usr_id]['sub_time'] = $usr_data['time']; $a_user_data[$usr_id]['subject'] = $usr_data['subject']; } $this->setMaxCount(count($sub_ids)); return $this->setData($a_user_data); }
/** * Save * * @access private * @param * */ private function save() { global $ilUser; $form = $this->initFormAgreement(); // #14715 - checkInput() does not work for checkboxes if ($this->checkAgreement() && $form->checkInput()) { self::saveCourseDefinedFields($form, $this->obj_id); $this->getAgreement()->setAccepted(true); $this->getAgreement()->setAcceptanceTime(time()); $this->getAgreement()->save(); include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php'; $history = new ilObjectCustomUserFieldHistory($this->obj_id, $ilUser->getId()); $history->setUpdateUser($ilUser->getId()); $history->setEditingTime(new ilDateTime(time(), IL_CAL_UNIX)); $history->save(); $this->ctrl->returnToParent($this); } elseif (!$this->checkAgreement()) { ilUtil::sendFailure($this->lng->txt($this->type . '_agreement_required')); $form->setValuesByPost(); $this->showAgreement($form); return false; } else { ilUtil::sendFailure($this->lng->txt('fill_out_all_required_fields')); $form->setValuesByPost(); $this->showAgreement($form); return false; } }
protected function saveMember() { global $ilUser; $GLOBALS['ilCtrl']->saveParameter($this, 'member_id'); $form = $this->initMemberForm(); if ($form->checkInput()) { // save history include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php'; $history = new ilObjectCustomUserFieldHistory($this->getObjId(), (int) $_REQUEST['member_id']); $history->setEditingTime(new ilDateTime(time(), IL_CAL_UNIX)); $history->setUpdateUser($ilUser->getId()); $history->save(); ilMemberAgreementGUI::saveCourseDefinedFields($form, $this->getObjId(), (int) $_REQUEST['member_id']); ilUtil::sendSuccess($this->lng->txt('settings_saved'), TRUE); $GLOBALS['ilCtrl']->returnToParent($this); return TRUE; } $form->setValuesByPost(); ilUtil::sendFailure($this->lng->txt('err_check_input')); return $this->editMember($form); }
/** * Parse user data * @param array $a_user_data * @return */ public function parse($a_user_data) { include_once './Services/User/classes/class.ilUserQuery.php'; $additional_fields = $this->getSelectedColumns(); unset($additional_fields["firstname"]); unset($additional_fields["lastname"]); unset($additional_fields["last_login"]); unset($additional_fields["access_until"]); unset($additional_fields['consultation_hour']); unset($additional_fields['prtf']); switch ($this->type) { case 'admin': $part = ilGroupParticipants::_getInstanceByObjId($this->getParentObject()->object->getId())->getAdmins(); break; case 'member': $part = $GLOBALS['rbacreview']->assignedUsers($this->getRole()); break; case 'role': $part = $GLOBALS['rbacreview']->assignedUsers($this->getRole()); break; } $udf_ids = $usr_data_fields = $odf_ids = array(); foreach ($additional_fields as $field) { if (substr($field, 0, 3) == 'udf') { $udf_ids[] = substr($field, 4); continue; } if (substr($field, 0, 3) == 'odf') { $odf_ids[] = substr($field, 4); continue; } $usr_data_fields[] = $field; } $usr_data = ilUserQuery::getUserListData('login', 'ASC', 0, 9999, '', '', null, false, false, 0, 0, null, $usr_data_fields, $part); // Custom user data fields if ($udf_ids) { include_once './Services/User/classes/class.ilUserDefinedData.php'; $data = ilUserDefinedData::lookupData($part, $udf_ids); foreach ($data as $usr_id => $fields) { if (!$this->checkAcceptance($usr_id)) { continue; } foreach ($fields as $field_id => $value) { $a_user_data[$usr_id]['udf_' . $field_id] = $value; } } } // Object specific user data fields if ($odf_ids) { include_once './Modules/Course/classes/Export/class.ilCourseUserData.php'; $data = ilCourseUserData::_getValuesByObjId($this->getParentObject()->object->getId()); foreach ($data as $usr_id => $fields) { if (!$this->checkAcceptance($usr_id)) { continue; } foreach ($fields as $field_id => $value) { if ($a_user_data[$usr_id]) { $a_user_data[$usr_id]['odf_' . $field_id] = $value; } } } // add last edit date include_once './Services/Membership/classes/class.ilObjectCustomUserFieldHistory.php'; foreach (ilObjectCustomUserFieldHistory::lookupEntriesByObjectId($this->getParentObject()->object->getId()) as $usr_id => $edit_info) { if (!isset($a_user_data[$usr_id])) { continue; } include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php'; if ($usr_id == $edit_info['update_user']) { $a_user_data[$usr_id]['odf_last_update'] = ''; $a_user_data[$usr_id]['odf_info_txt'] = $GLOBALS['lng']->txt('cdf_edited_by_self'); if (ilPrivacySettings::_getInstance()->enabledAccessTimesByType($this->getParentObject()->object->getType())) { $a_user_data[$usr_id]['odf_last_update'] .= '_' . $edit_info['editing_time']->get(IL_CAL_UNIX); $a_user_data[$usr_id]['odf_info_txt'] .= ', ' . ilDatePresentation::formatDate($edit_info['editing_time']); } } else { $a_user_data[$usr_id]['odf_last_update'] = $edit_info['edit_user']; $a_user_data[$usr_id]['odf_last_update'] .= '_' . $edit_info['editing_time']->get(IL_CAL_UNIX); $name = ilObjUser::_lookupName($edit_info['update_user']); $a_user_data[$usr_id]['odf_info_txt'] = $name['firstname'] . ' ' . $name['lastname'] . ', ' . ilDatePresentation::formatDate($edit_info['editing_time']); } } } foreach ($usr_data['set'] as $user) { // Check acceptance if (!$this->checkAcceptance($user['usr_id'])) { continue; } // DONE: accepted foreach ($usr_data_fields as $field) { $a_user_data[$user['usr_id']][$field] = $user[$field] ? $user[$field] : ''; } } // consultation hours if ($this->isColumnSelected('consultation_hour')) { include_once './Services/Booking/classes/class.ilBookingEntry.php'; foreach (ilBookingEntry::lookupManagedBookingsForObject($this->getParentObject()->object->getId(), $GLOBALS['ilUser']->getId()) as $buser => $booking) { if (isset($a_user_data[$buser])) { $a_user_data[$buser]['consultation_hour'] = $booking[0]['dt']; $a_user_data[$buser]['consultation_hour_end'] = $booking[0]['dtend']; $a_user_data[$buser]['consultation_hours'] = $booking; } } } return $this->setData($a_user_data); }