WIP: Fix vchamilo plugin

ofaj
jmontoyaa 10 years ago
parent d8161fa528
commit bef26b2739
  1. 2
      plugin/vchamilo/views/editinstance.php
  2. 38
      plugin/vchamilo/views/manage.controller.php
  3. 12
      plugin/vchamilo/views/manage.php
  4. 1
      plugin/vchamilo/views/syncparams.php

@ -23,7 +23,7 @@ $course_real_root = vchamilo_get_config('vchamilo', 'course_real_root');
$homePath = vchamilo_get_config('vchamilo', 'home_real_root'); $homePath = vchamilo_get_config('vchamilo', 'home_real_root');
if (empty($course_real_root) || empty($homePath)) { 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 // security

@ -264,7 +264,7 @@ if ($action == 'clearcache') {
$vidlist = implode("','", $_REQUEST['vids']); $vidlist = implode("','", $_REQUEST['vids']);
$toclear = Database::select('*', 'vchamilo', array('where' => array("id IN ('$vidlist')" => array()))); $toclear = Database::select('*', 'vchamilo', array('where' => array("id IN ('$vidlist')" => array())));
} else { } else {
$vid = $_REQUEST['vid']; $vid = isset($_REQUEST['vid']) ? $_REQUEST['vid'] : 0;
if ($vid) { if ($vid) {
$vhosts = Database::select('*', 'vchamilo', array('where' => array('id = ?' => $vid))); $vhosts = Database::select('*', 'vchamilo', array('where' => array('id = ?' => $vid)));
$vhost = (object)array_pop($vhosts); $vhost = (object)array_pop($vhosts);
@ -284,31 +284,42 @@ if ($action == 'clearcache') {
foreach ($toclear as $fooid => $instance) { foreach ($toclear as $fooid => $instance) {
if ($fooid == 0) { if ($fooid == 0) {
Display::addFlash(Display::return_message("Clearing master template cache")); 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 { } 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') { if ($action == 'setconfigvalue') {
$select = '<select name="preset" onchange="setpreset(this.form, this)">'; $select = '<select name="preset" onchange="setpreset(this.form, this)">';
$vars = $DB->get_records('settings_current', array(), 'id,variable,subkey', 'variable,subkey'); $settings = api_get_settings();
foreach($vars as $setting) { foreach ($settings as $setting) {
$select .= '<option name="'.$setting->variable.'/'.$setting->subkey.'">'.$setting->variable.' / '.$setting->subkey.'</option>'; $select .= '<option name="'.$setting['variable'].'/'.$setting['subkey'].'">'.
$setting['variable'].' - '.$setting['subkey'].
'</option>';
} }
$select .= '</select>'; $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 '<h2>'.$plugininstance->get_lang('sendconfigvalue').'</h2>';
echo '<form name="setconfigform">'; echo '<form name="setconfigform">';
$vidlist = implode("','", $_REQUEST['vids']);
echo '<input type="hidden" name="vidlist" value="'.$vidlist.'" />'; echo '<input type="hidden" name="vidlist" value="'.$vidlist.'" />';
echo '<input type="hidden" name="confirm" value="1" />'; echo '<input type="hidden" name="confirm" value="1" />';
echo '<table>'; echo '<table>';
@ -316,7 +327,8 @@ if ($action == 'setconfigvalue') {
echo '<tr><td><input type="text" name="variable" value="" size="30" /></td>'; 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 '<td><input type="text" name="subkey" value="" size="30" /></td></tr>';
echo '<tr><td colspan="2">'.$select.'</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 '</table>';
echo '</form>'; echo '</form>';
Display::display_footer(); Display::display_footer();

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

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

Loading…
Cancel
Save