Browse Source

WIP: Fix vchamilo plugin

jmontoyaa 9 years ago
parent
commit
bef26b2739

+ 1 - 1
plugin/vchamilo/views/editinstance.php

@@ -23,7 +23,7 @@ $course_real_root = vchamilo_get_config('vchamilo', 'course_real_root');
 $homePath = vchamilo_get_config('vchamilo', 'home_real_root');
 
 if (empty($course_real_root) || empty($homePath)) {
-    api_not_allowed('You have to setup the course real root');
+    api_not_allowed(true, 'You have to setup the course real root');
 }
 
 // security

+ 25 - 13
plugin/vchamilo/views/manage.controller.php

@@ -264,7 +264,7 @@ if ($action == 'clearcache') {
             $vidlist = implode("','", $_REQUEST['vids']);
             $toclear = Database::select('*', 'vchamilo', array('where' => array("id IN ('$vidlist')" => array())));
         } else {
-            $vid = $_REQUEST['vid'];
+            $vid = isset($_REQUEST['vid']) ? $_REQUEST['vid'] : 0;
             if ($vid) {
                 $vhosts = Database::select('*', 'vchamilo', array('where' => array('id = ?' => $vid)));
                 $vhost = (object)array_pop($vhosts);
@@ -284,31 +284,42 @@ if ($action == 'clearcache') {
     foreach ($toclear as $fooid => $instance) {
         if ($fooid == 0) {
             Display::addFlash(Display::return_message("Clearing master template cache"));
+            $templatepath = api_get_path(SYS_ARCHIVE_PATH).'twig';
+            Display::addFlash(Display::return_message("Deleting cache $templatepath \n"));
+            removeDir($templatepath);
         } else {
-            Display::addFlash(Display::return_message("Clearing instance template cache"));
+            $coursePath = vchamilo_get_config('vchamilo', 'course_real_root');
+            $homePath = vchamilo_get_config('vchamilo', 'home_real_root');
+            $archivePath = vchamilo_get_config('vchamilo', 'archive_real_root');
+
+            // Get instance archive
+            $archivepath = api_get_path(SYS_ARCHIVE_PATH, (array)$instance);
+            $templatepath = $archivePath.'/'.$instance['slug'].'/twig';
+            Display::addFlash(Display::return_message("Deleting cache $templatepath \n"));
+            removeDir($templatepath);
         }
 
-        // Get instance archive
-        $archivepath = api_get_path(SYS_ARCHIVE_PATH, (array)$instance);
-        $templatepath = $archivepath.'twig';
-        Display::addFlash(Display::return_message("Deleting $templatepath \n"));
-        removeDir($templatepath);
     }
 }
 
 if ($action == 'setconfigvalue') {
     $select = '<select name="preset" onchange="setpreset(this.form, this)">';
-    $vars = $DB->get_records('settings_current', array(), 'id,variable,subkey', 'variable,subkey');
-    foreach($vars as $setting) {
-        $select .= '<option name="'.$setting->variable.'/'.$setting->subkey.'">'.$setting->variable.' / '.$setting->subkey.'</option>';
+    $settings = api_get_settings();
+    foreach ($settings as $setting) {
+        $select .= '<option name="'.$setting['variable'].'/'.$setting['subkey'].'">'.
+            $setting['variable'].' - '.$setting['subkey'].
+        '</option>';
     }
     $select .= '</select>';
 
-    Display::display_header();
+    $vidlist = isset($_REQUEST['vids']) ? implode("','", $_REQUEST['vids']) : '';
+    if (empty($vidlist)) {
+        api_not_allowed(true, 'No virtual chamilo selected');
+    }
 
+    Display::display_header();
     echo '<h2>'.$plugininstance->get_lang('sendconfigvalue').'</h2>';
     echo '<form name="setconfigform">';
-    $vidlist = implode("','", $_REQUEST['vids']);
     echo '<input type="hidden" name="vidlist" value="'.$vidlist.'" />';
     echo '<input type="hidden" name="confirm" value="1" />';
     echo '<table>';
@@ -316,7 +327,8 @@ if ($action == 'setconfigvalue') {
     echo '<tr><td><input type="text" name="variable" value="" size="30" /></td>';
     echo '<td><input type="text" name="subkey" value="" size="30" /></td></tr>';
     echo '<tr><td colspan="2">'.$select.'</td></tr>';
-    echo '<tr><td colspan="2"><input type="submit" name="go_btn" value="'.$plugininstance->get_lang('distributevalue').'"</td></tr>';
+    echo '<tr><td colspan="2">';
+    echo '<input class="btn btn-primary" type="submit" name="go_btn" value="'.$plugininstance->get_lang('distributevalue').'"</td></tr>';
     echo '</table>';
     echo '</form>';
     Display::display_footer();

+ 5 - 7
plugin/vchamilo/views/manage.php

@@ -16,13 +16,12 @@ api_protect_admin_script();
 require_js('host_list.js', 'vchamilo');
 
 if ($action) {
-    require_once(api_get_path(SYS_PLUGIN_PATH).'vchamilo/views/manage.controller.php');
+    require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/views/manage.controller.php';
 }
 
 $content = Display::page_header('VChamilo Instances');
 
-$table = 'vchamilo';
-$query = "SELECT * FROM $table";
+$query = "SELECT * FROM vchamilo";
 $result = Database::query($query);
 $instances = array();
 while ($instance = Database::fetch_object($result)) {
@@ -74,7 +73,6 @@ foreach ($instances as $instance) {
         $cmd .= '<a href="'.$thisurl.'?what=deleteinstances&vids[]='.$instance->id.'" title="'.$plugininstance->get_lang('deleteinstances').'">
         <img src="'.$plugininstance->pix_url('delete').'" /></a>';
     }
-    
 
     $crondate = ($instance->lastcron) ? date('r', $instance->lastcron) : '';
     $data = array(
@@ -120,9 +118,9 @@ $items = [
     ]
 ];
 
-$content .=  Display::actions($items);
-$content .=  '<form action="'.$thisurl.'">';
-$content .=  $table->toHtml();
+$content .= Display::actions($items);
+$content .= '<form action="'.$thisurl.'">';
+$content .= $table->toHtml();
 
 $selectionoptions = array('<option value="0" selected="selected">'.$plugininstance->get_lang('choose').'</option>');
 $selectionoptions[] = '<option value="deleteinstances">'.$plugininstance->get_lang('deleteinstances').'</option>';

+ 1 - 0
plugin/vchamilo/views/syncparams.php

@@ -1,5 +1,6 @@
 <?php
 
+$cidReset = true;
 require_once '../../../main/inc/global.inc.php';
 
 require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/lib.php';