|
@@ -23,14 +23,7 @@ if ($action == 'deleteinstances' || $action == 'disableinstances') {
|
|
|
Display::addFlash(Display::return_message("Disabling instance"));
|
|
|
// Make it not visible.
|
|
|
$vidlist = implode("','", $_REQUEST['vids']);
|
|
|
- $sql = "
|
|
|
- UPDATE
|
|
|
- {$table}
|
|
|
- SET
|
|
|
- visible = 0
|
|
|
- WHERE
|
|
|
- id IN ('$vidlist')
|
|
|
- ";
|
|
|
+ $sql = "UPDATE $table SET visible = 0 WHERE id IN ('$vidlist')";
|
|
|
Database::query($sql);
|
|
|
vchamilo_redirect(api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php');
|
|
|
}
|
|
@@ -38,22 +31,13 @@ if ($action == 'enableinstances') {
|
|
|
|
|
|
Display::addFlash(Display::return_message("Enabling instance"));
|
|
|
$vidlist = implode("','", $_REQUEST['vids']);
|
|
|
- $sql = "
|
|
|
- UPDATE
|
|
|
- {$table}
|
|
|
- SET
|
|
|
- visible = 1
|
|
|
- WHERE
|
|
|
- id IN ('$vidlist')
|
|
|
- ";
|
|
|
+ $sql = " UPDATE $table SET visible = 1 WHERE id IN ('$vidlist') ";
|
|
|
Database::query($sql);
|
|
|
vchamilo_redirect(api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php');
|
|
|
}
|
|
|
|
|
|
if ($action == 'fulldeleteinstances') {
|
|
|
|
|
|
- Display::addFlash(Display::return_message("Destroying instance"));
|
|
|
-
|
|
|
// Removes everything.
|
|
|
if (empty($automation)) {
|
|
|
$vidlist = implode("','", $_REQUEST['vids']);
|
|
@@ -61,38 +45,39 @@ if ($action == 'fulldeleteinstances') {
|
|
|
} else {
|
|
|
$todelete = Database::select('*', 'vchamilo', array('where' => array("root_web = '{$n->root_web}' " => array())));
|
|
|
}
|
|
|
+ if ($todelete) {
|
|
|
+ foreach ($todelete as $fooid => $instance) {
|
|
|
+ $slug = $instance['slug'];
|
|
|
|
|
|
- foreach ($todelete as $fooid => $instance) {
|
|
|
- $slug = $instance['slug'];
|
|
|
+ Display::addFlash(Display::return_message("Removing instance: ".$instance->root_web));
|
|
|
|
|
|
- Display::addFlash(Display::return_message("Dropping instance databases"));
|
|
|
- vchamilo_drop_databases($instance);
|
|
|
+ vchamilo_drop_databases($instance);
|
|
|
|
|
|
- // Remove all files and eventual symlinks
|
|
|
+ // Remove all files and eventual symlinks
|
|
|
|
|
|
- $absalternatecourse = vchamilo_get_config('vchamilo', 'course_real_root');
|
|
|
- $coursedir = $absalternatecourse.$slug;
|
|
|
+ $absalternatecourse = vchamilo_get_config('vchamilo', 'course_real_root');
|
|
|
+ $coursedir = $absalternatecourse.$slug;
|
|
|
|
|
|
- Display::addFlash(Display::return_message("Deleting $coursedir"));
|
|
|
+ Display::addFlash(Display::return_message("Deleting $coursedir"));
|
|
|
|
|
|
- if ($absalternatehome = vchamilo_get_config('vchamilo', 'home_real_root')) {
|
|
|
- $homedir = str_replace('//', '/', $absalternatehome.'/'.$slug);
|
|
|
+ if ($absalternatehome = vchamilo_get_config('vchamilo', 'home_real_root')) {
|
|
|
+ $homedir = str_replace('//', '/', $absalternatehome.'/'.$slug);
|
|
|
|
|
|
- Display::addFlash(Display::return_message("Deleting $homedir"));
|
|
|
- removeDir($homedir);
|
|
|
- }
|
|
|
+ Display::addFlash(Display::return_message("Deleting $homedir"));
|
|
|
+ removeDir($homedir);
|
|
|
+ }
|
|
|
|
|
|
- // delete archive
|
|
|
- if ($absalternatearchive = vchamilo_get_config('vchamilo', 'archive_real_root')){
|
|
|
- $archivedir = str_replace('//', '/', $absalternatearchive.'/'.$slug);
|
|
|
+ // delete archive
|
|
|
+ if ($absalternatearchive = vchamilo_get_config('vchamilo', 'archive_real_root')) {
|
|
|
+ $archivedir = str_replace('//', '/', $absalternatearchive.'/'.$slug);
|
|
|
|
|
|
- Display::addFlash(Display::return_message("Deleting $archivedir"));
|
|
|
- removeDir($archivedir);
|
|
|
- }
|
|
|
+ Display::addFlash(Display::return_message("Deleting $archivedir"));
|
|
|
+ removeDir($archivedir);
|
|
|
+ }
|
|
|
|
|
|
- Display::addFlash(Display::return_message("Removing vchamilo record"));
|
|
|
- $sql = "DELETE FROM {$table} WHERE id = {$instance->id}";
|
|
|
- Database::query($sql);
|
|
|
+ $sql = "DELETE FROM {$table} WHERE id = {$instance->id}";
|
|
|
+ Database::query($sql);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -122,6 +107,9 @@ if ($action == 'snapshotinstance') {
|
|
|
$absolute_sqldir = $backupDir.'dump.sql';
|
|
|
|
|
|
if (!is_dir($backupDir)) {
|
|
|
+ Display::addFlash(
|
|
|
+ Display::return_message('Directory created: '.$backupDir)
|
|
|
+ );
|
|
|
mkdir($backupDir, 0777, true);
|
|
|
}
|
|
|
|
|
@@ -145,7 +133,7 @@ if ($action == 'snapshotinstance') {
|
|
|
|
|
|
$tpl = new Template(get_lang('Snapshot'), true, true, false, true, false);
|
|
|
$tpl->assign('actions', '');
|
|
|
- $tpl->assign('message', $plugininstance->get_lang('vchamilosnapshot1'));
|
|
|
+ $tpl->assign('message', '<h4>'.$plugininstance->get_lang('vchamilosnapshot1').'</h4>');
|
|
|
$tpl->assign('content', $content);
|
|
|
$tpl->display_one_col_template();
|
|
|
|
|
@@ -180,14 +168,11 @@ if ($action == 'snapshotinstance') {
|
|
|
if ($vchamilostep == 1) {
|
|
|
// Auto dump the databases in a master template folder.
|
|
|
// this will create three files : dump.sql
|
|
|
- $errors = vchamilo_dump_databases($vchamilo, $absolute_sqldir);
|
|
|
+ $result = vchamilo_dump_databases($vchamilo, $absolute_sqldir);
|
|
|
|
|
|
if (empty($fullautomation)) {
|
|
|
- if(!empty($errors)) {
|
|
|
+ if (!$result) {
|
|
|
$actionurl = $_configuration['root_web'].'/plugin/vchamilo/views/manage.php';
|
|
|
-
|
|
|
- $message = vchamilo_print_error($errors, true);
|
|
|
-
|
|
|
$content .= '<p><form name"single" action="'.$actionurl.'">';
|
|
|
$content .= '<input type="submit" name="go_btn" value="'.$plugininstance->get_lang('cancel').'" />';
|
|
|
$content .= '</form></p>';
|
|
@@ -197,7 +182,7 @@ if ($action == 'snapshotinstance') {
|
|
|
$message = $plugininstance->get_lang('vchamilosnapshot2');
|
|
|
|
|
|
Display::addFlash(
|
|
|
- Display::return_message('mysql dump: '.$absolute_sqldir)
|
|
|
+ Display::return_message('Database file created: '.$absolute_sqldir)
|
|
|
);
|
|
|
|
|
|
$content .= '<form name"single" action="'.$actionurl.'">';
|
|
@@ -210,7 +195,7 @@ if ($action == 'snapshotinstance') {
|
|
|
|
|
|
$tpl = new Template(get_lang('Snapshot'), true, true, false, true, false);
|
|
|
$tpl->assign('actions', '');
|
|
|
- $tpl->assign('message', $message);
|
|
|
+ $tpl->assign('message', '<h4>'.$message.'</h4>');
|
|
|
$tpl->assign('content', $content);
|
|
|
$tpl->display_one_col_template();
|
|
|
|
|
@@ -218,10 +203,10 @@ if ($action == 'snapshotinstance') {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Display::addFlash(Display::return_message("Copying from $homePath to {$absolute_datadir}/home "));
|
|
|
+ Display::addFlash(Display::return_message("Copying from '$homePath' to '{$absolute_datadir}/home' "));
|
|
|
copyDirTo($homePath, $absolute_datadir.'/home/', false);
|
|
|
|
|
|
- Display::addFlash(Display::return_message("Copying from $coursePath to $absolute_datadir/courses "));
|
|
|
+ Display::addFlash(Display::return_message("Copying from '$coursePath' to '$absolute_datadir/courses' "));
|
|
|
copyDirTo($coursePath, $absolute_datadir.'/courses/', false);
|
|
|
/*Display::addFlash(Display::return_message("Copying from $archivePath to {$absolute_datadir}/archive "));
|
|
|
copyDirTo($varchivepath, $absolute_datadir.'/archive', false);*/
|
|
@@ -239,6 +224,25 @@ if ($action == 'snapshotinstance') {
|
|
|
if (empty($fullautomation)) {
|
|
|
Display::addFlash(Display::return_message($plugininstance->get_lang('successfinishedcapture'), 'success'));
|
|
|
|
|
|
+ if (empty($vid)) {
|
|
|
+ $template = vchamilo_get_config('vchamilo', 'default_template');
|
|
|
+ if (empty($template)) {
|
|
|
+ Display::addFlash(Display::return_message('Set default template as <b>'.$vhost->slug.'</b>', 'success', false));
|
|
|
+ $params = [
|
|
|
+ 'subkey' => 'vchamilo',
|
|
|
+ 'title' => 'default_template',
|
|
|
+ 'type' => 'setting',
|
|
|
+ 'category' => 'Plugins',
|
|
|
+ 'variable' => 'vchamilo_default_template',
|
|
|
+ 'selected_value' => $vhost->slug,
|
|
|
+ 'access_url_changeable' => 0
|
|
|
+ ];
|
|
|
+ api_set_setting_simple($params);
|
|
|
+ } else {
|
|
|
+ Display::addFlash(Display::return_message('Default template is: <b>'.$vhost->slug.'</b>', 'success', false));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$actionurl = $_configuration['root_web'].'/plugin/vchamilo/views/manage.php';
|
|
|
$content .= '<form name"single" action="'.$actionurl.'">';
|
|
|
$content .= '<input class="btn btn-primary" type="submit" name="go_btn" value="'.$plugininstance->get_lang('backtoindex').'" />';
|