|
@@ -74,62 +74,6 @@ class WSCMCourse extends WSCM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Edits a course.
|
|
|
- *
|
|
|
- * @param string API secret key
|
|
|
- * @param string Course id field name
|
|
|
- * @param string Course id value
|
|
|
- * @param string Title
|
|
|
- * @param string Category code
|
|
|
- * @param string Department name
|
|
|
- * @param string Department url
|
|
|
- * @param string Course language
|
|
|
- * @param int Visibility
|
|
|
- * @param int Subscribe (0 = denied, 1 = allowed)
|
|
|
- * @param int Unsubscribe (0 = denied, 1 = allowed)
|
|
|
- * @param string Visual code
|
|
|
- * @param array Course extra fields
|
|
|
- */
|
|
|
- public function EditCourse(
|
|
|
- $secret_key,
|
|
|
- $course_id_field_name,
|
|
|
- $course_id_value,
|
|
|
- $title,
|
|
|
- $category_code,
|
|
|
- $department_name,
|
|
|
- $department_url,
|
|
|
- $language,
|
|
|
- $visibility,
|
|
|
- $subscribe,
|
|
|
- $unsubscribe,
|
|
|
- $visual_code,
|
|
|
- $extras
|
|
|
- ) {
|
|
|
- $verifKey = $this->verifyKey($secret_key);
|
|
|
- if ($verifKey instanceof WSCMError) {
|
|
|
- $this->handleError($verifKey);
|
|
|
- } else {
|
|
|
- $result = $this->editCourseHelper(
|
|
|
- $course_id_field_name,
|
|
|
- $course_id_value,
|
|
|
- $title,
|
|
|
- $category_code,
|
|
|
- $department_name,
|
|
|
- $department_url,
|
|
|
- $language,
|
|
|
- $visibility,
|
|
|
- $subscribe,
|
|
|
- $unsubscribe,
|
|
|
- $visual_code,
|
|
|
- $extras
|
|
|
- );
|
|
|
- if ($result instanceof WSCMError) {
|
|
|
- $this->handleError($result);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* List courses.
|
|
|
*
|
|
@@ -406,88 +350,6 @@ class WSCMCourse extends WSCM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Edits a course (helper method).
|
|
|
- *
|
|
|
- * @param string Course id field name
|
|
|
- * @param string Course id value
|
|
|
- * @param string Title
|
|
|
- * @param string Category code
|
|
|
- * @param string Department name
|
|
|
- * @param string Department url
|
|
|
- * @param string Course language
|
|
|
- * @param int Visibility
|
|
|
- * @param int Subscribe (0 = denied, 1 = allowed)
|
|
|
- * @param int Unsubscribe (0 = denied, 1 = allowed)
|
|
|
- * @param string Visual code
|
|
|
- * @param array Course extra fields
|
|
|
- *
|
|
|
- * @return mixed True in case of success, WSError otherwise
|
|
|
- */
|
|
|
- protected function editCourseHelper(
|
|
|
- $course_id_field_name,
|
|
|
- $course_id_value,
|
|
|
- $title,
|
|
|
- $category_code,
|
|
|
- $department_name,
|
|
|
- $department_url,
|
|
|
- $language,
|
|
|
- $visibility,
|
|
|
- $subscribe,
|
|
|
- $unsubscribe,
|
|
|
- $visual_code,
|
|
|
- $extras
|
|
|
- ) {
|
|
|
- $course_id = $this->getCourseId($course_id_field_name, $course_id_value);
|
|
|
- if ($course_id instanceof WSCMError) {
|
|
|
- return $course_id;
|
|
|
- } else {
|
|
|
- $attributes = [];
|
|
|
- if (!empty($title)) {
|
|
|
- $attributes['title'] = $title;
|
|
|
- }
|
|
|
- if (!empty($category_code)) {
|
|
|
- $attributes['category_code'] = $category_code;
|
|
|
- }
|
|
|
- if (!empty($department_name)) {
|
|
|
- $attributes['department_name'] = $department_name;
|
|
|
- }
|
|
|
- if (!empty($department_url)) {
|
|
|
- $attributes['department_url'] = $department_url;
|
|
|
- }
|
|
|
- if (!empty($language)) {
|
|
|
- $attributes['course_language'] = $language;
|
|
|
- }
|
|
|
- if ($visibility != '') {
|
|
|
- $attributes['visibility'] = (int) $visibility;
|
|
|
- }
|
|
|
- if ($subscribe != '') {
|
|
|
- $attributes['subscribe'] = (int) $subscribe;
|
|
|
- }
|
|
|
- if ($unsubscribe != '') {
|
|
|
- $attributes['unsubscribe'] = (int) $unsubscribe;
|
|
|
- }
|
|
|
- if (!empty($visual_code)) {
|
|
|
- $attributes['visual_code'] = $visual_code;
|
|
|
- }
|
|
|
- if (!empty($attributes)) {
|
|
|
- CourseManager::update_attributes($course_id, $attributes);
|
|
|
- }
|
|
|
- if (!empty($extras)) {
|
|
|
- $course_code = CourseManager::get_course_code_from_course_id($course_id);
|
|
|
- $extras_associative = [];
|
|
|
- foreach ($extras as $extra) {
|
|
|
- $extras_associative[$extra['field_name']] = $extra['field_value'];
|
|
|
- }
|
|
|
- foreach ($extras_associative as $fname => $fvalue) {
|
|
|
- CourseManager::update_extra_field_value($course_code, $fname, $fvalue);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Subscribe or unsubscribe user to a course (helper method).
|
|
|
*
|