From d2b73c10f40ecdc970c29579d8b74378cc737871 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 15 Jan 2016 11:13:50 +0100 Subject: [PATCH] Fix mysql errors + minor format code --- main/admin/settings.php | 4 ++-- main/newscorm/learnpath.class.php | 27 ++++++++++++++++++++++---- main/survey/survey.lib.php | 8 ++++---- main/webservices/registration.soap.php | 7 ++++--- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/main/admin/settings.php b/main/admin/settings.php index 3fdcd993f1..c8a5dd014a 100755 --- a/main/admin/settings.php +++ b/main/admin/settings.php @@ -114,9 +114,9 @@ function get_settings($category = null) // One more validation if is changeable. if ($row['access_url_changeable'] == 1) { - $settings_by_access_list[$row['variable']] [$row['subkey']] [$row['category']] = $row; + $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = $row; } else { - $settings_by_access_list[$row['variable']] [$row['subkey']] [$row['category']] = array(); + $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = array(); } } } diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index daca1b9280..ac762e2842 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -216,9 +216,15 @@ class learnpath error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - NOT Found previous view', 0); } $this->attempt = 1; - $sql = "INSERT INTO $lp_table (c_id, lp_id, user_id, view_count, session_id) - VALUES ($course_id, $lp_id, $user_id, 1, $session_id)"; - Database::query($sql); + $params = [ + 'c_id' => $course_id, + 'lp_id' => $lp_id, + 'user_id' => $user_id, + 'view_count' => 1, + 'session_id' => $session_id, + 'last_item' => 0 + ]; + Database::insert($lp_table, $params); $this->lp_view_id = Database::insert_id(); if ($this->debug > 2) { @@ -821,9 +827,22 @@ class learnpath 'js_lib' => '', 'session_id' => $session_id, 'created_on' => api_get_utc_datetime(), + 'modified_on' => api_get_utc_datetime(), 'publicated_on' => $publicated_on, 'expired_on' => $expired_on, - 'category_id' => $categoryId + 'category_id' => $categoryId, + 'force_commit' => 0, + 'content_license' => '', + 'debug' => 0, + 'theme' => '', + 'preview_image' => '', + 'author' => '', + 'prerequisite' => 0, + 'hide_toc_frame' => 0, + 'seriousgame_mode' => 0, + 'autolaunch' => 0, + 'max_attempts' => 0, + 'subscribe_users' => 0 ]; $id = Database::insert($tbl_lp, $params); diff --git a/main/survey/survey.lib.php b/main/survey/survey.lib.php index 85bcf41bc2..5ff5f54599 100755 --- a/main/survey/survey.lib.php +++ b/main/survey/survey.lib.php @@ -668,7 +668,7 @@ class SurveyManager $sql = "UPDATE $table_survey SET survey_id = $new_survey_id WHERE iid = $new_survey_id"; Database::query($sql); - + // Insert into item_property api_item_property_update( api_get_course_info(), @@ -681,7 +681,7 @@ class SurveyManager } else { $new_survey_id = intval($new_survey_id); } - + $sql = "SELECT * FROM $table_survey_question_group WHERE c_id = $course_id AND survey_id='".$survey_id."'"; $res = Database::query($sql); @@ -723,14 +723,14 @@ class SurveyManager $insertId = Database::insert($table_survey_question, $params); $sql = "UPDATE $table_survey_question SET question_id = iid WHERE iid = $insertId"; Database::query($sql); - + $question_id[$row['question_id']] = $insertId; } // Get questions options $sql = "SELECT * FROM $table_survey_options WHERE c_id = $course_id AND survey_id='".$survey_id."'"; - + $res = Database::query($sql); while ($row = Database::fetch_array($res ,'ASSOC')) { $params = array( diff --git a/main/webservices/registration.soap.php b/main/webservices/registration.soap.php index 1ae8323911..c8de2bcf53 100755 --- a/main/webservices/registration.soap.php +++ b/main/webservices/registration.soap.php @@ -1298,8 +1298,8 @@ function WSCreateUserPasswordCrypted($params) UrlManager::add_user_to_url($return, $url_id); if ($debug) error_log("Adding user_id = $return to URL id $url_id "); - // Save new fieldlabel into user_field table. - $field_id = UserManager::create_extra_field( + // Create extra field for the original_user_id_name + UserManager::create_extra_field( $original_user_id_name, 1, $original_user_id_name, @@ -1312,12 +1312,13 @@ function WSCreateUserPasswordCrypted($params) $original_user_id_value ); + // Create extra fields if (is_array($extra_list) && count($extra_list) > 0) { foreach ($extra_list as $extra) { $extra_field_name = $extra['field_name']; $extra_field_value = $extra['field_value']; // save new fieldlabel into user_field table - $field_id = UserManager::create_extra_field( + UserManager::create_extra_field( $extra_field_name, 1, $extra_field_name,