Browse Source

Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x

Yannick Warnier 8 years ago
parent
commit
88fc04a42a

+ 2 - 2
composer.json

@@ -48,7 +48,6 @@
         "ext-xml": "*",
         "ext-json": "*",
         "ext-mbstring": "*",
-
         "twig/twig": "1.*",
         "twig/extensions": "~1.0",
         "doctrine/orm": "~2.4",
@@ -104,7 +103,8 @@
         "facebook/php-sdk-v4" : "~5.0",
         "kigkonsult/icalcreator" : "0.1.0",
         "essence/essence": "2.6.1",
-        "pclzip/pclzip": "2.8.2"
+        "pclzip/pclzip": "2.8.2",
+        "chamilo/chash": "dev-master"
     },
     "require-dev": {
         "behat/behat": "@stable",

+ 7 - 4
main/survey/survey.lib.php

@@ -1958,11 +1958,13 @@ class SurveyUtil
         $table_survey = Database:: get_course_table(TABLE_SURVEY);
 
         $course_id = api_get_course_int_id();
+        $survey_id = (int) $survey_id;
+        $user_id = Database::escape_string($user_id);
 
         if (!empty($survey_id) && !empty($user_id)) {
             // delete data from survey_answer by user_id and survey_id
             $sql = "DELETE FROM $table_survey_answer
-			        WHERE c_id = $course_id AND survey_id = '".(int)$survey_id."' AND user = '".(int)$user_id."'";
+			        WHERE c_id = $course_id AND survey_id = '".$survey_id."' AND user = '".$user_id."'";
             Database::query($sql);
             // update field answered from survey_invitation by user_id and survey_id
             $sql = "UPDATE $table_survey_invitation SET answered = '0'
@@ -1972,15 +1974,16 @@ class SurveyUtil
                             SELECT code FROM $table_survey
                             WHERE
                                 c_id = $course_id AND
-                                survey_id = '".(int)$survey_id."'
+                                survey_id = '".$survey_id."'
                         ) AND
-			            user = '".(int)$user_id."'";
+			            user = '".$user_id."'";
             $result = Database::query($sql);
         }
 
         if ($result !== false) {
             $message = get_lang('SurveyUserAnswersHaveBeenRemovedSuccessfully').'<br />
-					<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&survey_id='.intval($survey_id).'">'.get_lang('GoBack').'</a>';
+					<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&survey_id='.$survey_id.'">'.
+                get_lang('GoBack').'</a>';
             Display::display_confirmation_message($message, false);
         }
     }

+ 6 - 2
main/work/work.lib.php

@@ -2097,17 +2097,21 @@ function get_work_user_list(
                             '.addslashes(get_lang('ClickOrDropOneFileHere')).'
                             '.Display::return_icon('upload_file.png', get_lang('Correction'), [], ICON_SIZE_TINY).'
                         </div>
-
                         <input id="file_'.$item_id.'" type="file" name="file" class="" multiple>
                         </form>
                     ';
 
                     $correction .= "<script>
                     $(document).ready(function() {
+                        $('.work_correction_file_upload').each(function () {
+                            $(this).fileupload({
+                                dropZone: $(this)
+                            });
+                        });
                         $('#file_upload_".$item_id."').fileupload({
                             add: function (e, data) {
                                 $('#progress_$item_id').html();
-                                $('#file_$item_id').remove();
+                                //$('#file_$item_id').remove();
                                 data.context = $('#progress_$item_id').html('$loadingText <br /> <em class=\"fa fa-spinner fa-pulse fa-fw\"></em>');
                                 data.submit();
                             },

+ 2 - 2
plugin/vchamilo/README.md

@@ -19,8 +19,8 @@ How to setup
 You need :
 
 1. Install the vchamilo package into the <chamiloroot>/plugin directory
-2. Install the plugin in chamilo administration
-3. Insert the virtualisation hook into the chamilo master configuration file:
+2. Install the plugin in Chamilo administration
+3. Insert the virtualization hook into the Chamilo master configuration file:
 
 ```
 <chamiloroot>/app/config/configuration.php

+ 38 - 28
plugin/vchamilo/views/syncparams.controller.php

@@ -5,10 +5,11 @@ api_protect_admin_script();
 
 $sql = "SELECT * FROM vchamilo";
 $result = Database::query($sql);
-$vchamilos = Database::store_result($result);
+$vchamilos = Database::store_result($result, 'ASSOC');
 
 // propagate in all known vchamilos a setting
 if ($action == 'syncall') {
+    exit;
     $keys = array_keys($_REQUEST);
     $selection = preg_grep('/sel_.*/', $keys);
 
@@ -72,35 +73,44 @@ if ($action == 'syncthis') {
 
         $errors = '';
         foreach ($vchamilos as $vcid => $chm) {
-            $table = $chm['main_database'].".settings_current";
-            if ($delifempty && empty($value)) {
-                $sql = "DELETE FROM $table 
-                        WHERE  
-                            selected_value = '$value' AND   
-                            variable = '{{$setting['variable']}}' AND 
-                            access_url = '{$setting['access_url']}'
-                ";
-                Database::query($sql);
-
-                //$res = $DB->delete_records('settings_current', $params, $chm->main_database);
-                $case = "delete";
-            } else {
-
-                $sql = " SELECT * FROM $table 
-                         WHERE 
-                            variable = '".$setting['variable']."' AND 
-                            access_url = '{$setting['access_url']}'
-                        ";
-                $result = Database::query($sql);
-
-                if (Database::num_rows($result)) {
-                    $sql = "UPDATE $table SET 
-                            selected_value = '$value'
-                      WHERE id = $settingId";
-                    Database::query($sql);
+            $table = "settings_current";
+
+            $config = new \Doctrine\DBAL\Configuration();
+            $connectionParams = array(
+                'dbname' => $chm['main_database'],
+                'user' => $chm['db_user'],
+                'password' => $chm['db_password'],
+                'host' => $chm['db_host'],
+                'driver' => 'pdo_mysql',
+            );
+            $connection = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
+            try {
+                if ($delifempty && empty($value)) {
+                    $sql = "DELETE FROM $table 
+                            WHERE  
+                                selected_value = '$value' AND   
+                                variable = '{{$setting['variable']}}' AND 
+                                access_url = '{$setting['access_url']}'
+                    ";
+                    $connection->executeQuery($sql);
+                    $case = "delete";
                 } else {
-                    Database::insert($table, $params, true);
+                    $sql = " SELECT * FROM $table 
+                             WHERE 
+                                variable = '".$setting['variable']."' AND 
+                                access_url = '{$setting['access_url']}'
+                            ";
+                    $result = $connection->fetchAll($sql);
+
+                    if (!empty($result)) {
+                        $sql = "UPDATE $table SET selected_value = '$value' WHERE id = $settingId";
+                        $connection->executeQuery($sql);
+                    } else {
+                        $connection->insert($table, $params);
+                    }
                 }
+            } catch (Exception $e) {
+                echo $e->getMessage();
             }
         }
         return $errors;

+ 21 - 14
plugin/vchamilo/views/syncparams.php

@@ -21,8 +21,6 @@ $settings = api_get_settings();
 $table = new HTML_Table(array('class' => 'data_table', 'width' => '100%'));
 $column = 0;
 $row = 0;
-
-// $table->set_additional_parameters($parameters);
 $headers = array(
     '',
     $plugin->get_lang('variable').' ['.$plugin->get_lang('subkey').']',
@@ -35,24 +33,22 @@ $attrs = array('center' => 'left');
 $table->addRow($headers, $attrs, 'th');
 
 foreach ($settings as $param) {
-
     if ($param['subkey'] == 'vchamilo') {
         continue;
     }
-    // $check = '<input type="checkbox" name="sync_'.$param->id.'" value="'.$param->selected_value.'" />';
-    //<input type="checkbox" name="del_'.$param['id'].'" value="1" title="'.$plugin->get_lang('deleteifempty').'" />
     $check = '';
     $attrs = array('center' => 'left');
-    $syncthisbutton = '<input type="button" name="syncthis" value="'.$plugin->get_lang('syncthis').'" onclick="ajax_sync_setting(\''.$_configuration['root_web'].'\', \''.$param['id'].'\')" /> 
-         <span id="res_'.$param['id'].'"></span>';
+    $syncButton = '
+        <input class="btn btn-default" type="button" name="syncthis" value="'.$plugin->get_lang('syncthis').'" onclick="ajax_sync_setting(\''.$param['id'].'\')" />
+        <span id="res_'.$param['id'].'"></span>';
     $data = array(
         $check,
         isset($param['subkey']) && !empty($param['subkey']) ? $param['variable'].' ['.$param['subkey'].']' : $param['variable'],
         $param['category'],
         $param['access_url'],
-        '<input type="text" name="value_'.$param['id'].'" value="'.htmlspecialchars($param['selected_value'], ENT_COMPAT, 'UTF-8' ).'" />'.
+        '<input type="text" disabled name="value_'.$param['id'].'" value="'.htmlspecialchars($param['selected_value'], ENT_COMPAT, 'UTF-8' ).'" />'.
         '<br />Master value: '.$param['selected_value'],
-        $syncthisbutton,
+        $syncButton,
     );
     $row = $table->addRow($data, $attrs, 'td');
     $table->setRowAttributes($row, array('id' => 'row_'.$param['id']), true);
@@ -61,18 +57,29 @@ foreach ($settings as $param) {
 $content  = '<form name="settingsform" action="'.$thisurl.'">';
 $content .= '<input type="hidden" name="what" value="" />';
 $content .=  $table->toHtml();
-// $content .=  '<div class"vchamilo-right"><div></div><div><input type="button" name="syncall" value="'.$plugin->get_lang('syncall').'" onclick="this.form.what.value=\'syncall\';this.form.submit();">';
 $content .=  '</form>';
 $actions = '';
 
 Display::addFlash(Display::return_message($plugin->get_lang('Sync your master settings to all instances.')));
 
-$message = require_js('ajax.js', 'vchamilo', true);
-
 $interbreadcrumb[] = array('url' => 'manage.php', 'name' => get_lang('VChamilo'));
+$htmlHeadXtra[] = "<script>
+function ajax_sync_setting(settingid) {
+    var webUrl = '".api_get_path(WEB_PATH)."';
+    var spare = $('#row_'+settingid).html();
+    var formobj = document.forms['settingsform'];
+    var url = webUrl + 'plugin/vchamilo/ajax/service.php?what=syncthis&settingid='+settingid+'&value='+encodeURIComponent(formobj.elements['value_'+settingid].value);
+    
+    $('#row_'+settingid).html('<td colspan=\"7\"><img src=\"'+webUrl+'plugin/vchamilo/pix/ajax_waiter.gif\" /></td>');
+
+    $.get(url, function (data) {
+        $('#row_'+settingid).html(spare);
+        $('#res_'+settingid).html(data);
+    });
+}
+</script>";
 
-$tpl = new Template($plugin->get_lang('sync_settings'), true, true, false, true, false);
+$tpl = new Template($plugin->get_lang('SyncSettings'), true, true, false, true, false);
 $tpl->assign('actions', $actions);
-$tpl->assign('message', $message);
 $tpl->assign('content', $content);
 $tpl->display_one_col_template();