/** * Is the user allowed to enrol to the course * @return boolean */ protected function isUnregistrationAllowed() { $coursePrivileges = new CourseUserPrivileges($this->course->courseId, $this->userAuthProfile->getUserId()); if (!$this->forceUnregOfManager && $coursePrivileges->isCourseManager() && $this->userAuthProfile->getUserId() == claro_get_current_user_id() && !claro_is_platform_admin()) { $this->status = self::STATUS_MANAGER_CANNOT_UNREGISTER_ITSELF; $this->errorMessage = get_lang('Course manager cannot unsubscribe himself'); // unless he is platform admin too return false; } // check if is thelast course manager if ($coursePrivileges->isCourseManager() && $this->onlyOneCourseManagerLeft()) { $this->status = self::STATUS_CANNOT_UNREGISTER_LASTMANAGER; $this->errorMessage = get_lang('You cannot unsubscribe the last course manager of the course'); // even if platform admin... return false; } if ($this->isSuperUser) { return true; } if ($this->userAuthProfile->isProfileAllowedToRegisterInCourse()) { return $this->isCourseUnregistrationAllowed(); } else { $this->status = self::STATUS_UNREGISTRATION_NOTAVAILABLE; $this->errorMessage = get_lang('Your profile does not allow you to unregister from this course.'); return false; } }
public function current() { $data = $this->collection[$this->key()]; if (!isset($data['courseId'])) { throw new Exception("Missing courseId in data"); } if ($this->userId) { return CourseUserPrivileges::fromArray($data['courseId'], $this->userId, $data); } else { return CourseAnonymousUserPrivileges::fromArray($data['courseId']); } }
} // end if cmd == unregister // Export users list if ($cmd == 'export' && $can_export_user_list) { require_once dirname(__FILE__) . '/lib/export.lib.php'; // contruction of XML flow $csv = export_user_list(claro_get_current_course_id()); if (!empty($csv)) { $courseData = claro_get_current_course_data(); claro_send_stream($csv, $courseData['officialCode'] . '_userlist.csv'); exit; } } // Validate a user (if this option is enable for the course) if ($cmd == 'validation' && $req['user_id']) { $courseUserPrivileges = new CourseUserPrivileges(claro_get_current_course_id(), $req['user_id']); $courseUserPrivileges->load(); $courseObject = new Claro_Course(claro_get_current_course_id()); $courseObject->load(); $validation = new UserCourseEnrolmentValidation($courseObject, $courseUserPrivileges); $validationChange = isset($_REQUEST['validation']) ? $_REQUEST['validation'] : null; if ($validation->isModifiable()) { if ('grant' == $validationChange && $validation->isPending()) { if ($validation->grant()) { $dialogBox->success(get_lang('This user account is now active in the course')); } else { $dialogBox->warning(get_lang('No change')); } } elseif ('revoke' == $validationChange && !$validation->isPending()) { if ($validation->revoke()) { $dialogBox->success(get_lang('This user account is not active anymore in this course'));