manage.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. $cidReset = true;
  3. require_once '../../../main/inc/global.inc.php';
  4. require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/lib.php';
  5. require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/lib/vchamilo_plugin.class.php';
  6. // security
  7. api_protect_admin_script();
  8. vchamilo_check_settings();
  9. $action = isset($_GET['what']) ? $_GET['what'] : '';
  10. define('CHAMILO_INTERNAL', true);
  11. $plugininstance = VChamiloPlugin::create();
  12. $thisurl = api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php';
  13. require_js('host_list.js', 'vchamilo');
  14. if ($action) {
  15. require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/views/manage.controller.php';
  16. }
  17. $query = "SELECT * FROM vchamilo";
  18. $result = Database::query($query);
  19. $instances = array();
  20. while ($instance = Database::fetch_object($result)) {
  21. $instances[$instance->id] = $instance;
  22. }
  23. $templates = vchamilo_get_available_templates(false);
  24. if (empty($templates)) {
  25. $url = api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php?what=snapshotinstance';
  26. $url = Display::url($url, $url);
  27. Display::addFlash(
  28. Display::return_message('You need to create a snapshot of master first here:'.$url, 'info', false)
  29. );
  30. }
  31. $table = new HTML_Table(array('class' => 'data_table'));
  32. $column = 0;
  33. $row = 0;
  34. // $table->set_additional_parameters($parameters);
  35. $headers = array(
  36. '',
  37. $plugininstance->get_lang('sitename'),
  38. $plugininstance->get_lang('institution'),
  39. $plugininstance->get_lang('dbhost').' - '.get_lang('Database'),
  40. $plugininstance->get_lang('coursefolder'),
  41. $plugininstance->get_lang('enabled'),
  42. $plugininstance->get_lang('lastcron'),
  43. '',
  44. );
  45. $attrs = array('center' => 'left');
  46. $table->addRow($headers, $attrs, 'th');
  47. $i = 0;
  48. foreach ($instances as $instance) {
  49. $checkbox = '<input type="checkbox" class="vnodessel" name="vids[]" value="'.$instance->id.'" />';
  50. //$sitelink = '<a href="'.$instance->root_web.'" target="_blank">'.$instance->sitename.'</a>';
  51. $sitelink = $instance->sitename;
  52. if ($instance->visible) {
  53. $status = '<a href="'.$thisurl.'?what=disableinstances&vids[]='.$instance->id.'" >
  54. <img src="'.$plugininstance->pix_url('enabled').'" /></a>';
  55. } else {
  56. $status = '<a href="'.$thisurl.'?what=enableinstances&vids[]='.$instance->id.'" >
  57. <img src="'.$plugininstance->pix_url('disabled').'" /></a>';
  58. }
  59. $cmd = '&nbsp;<a href="'.$thisurl.'?what=editinstance&vid='.$instance->id.'" title="'.$plugininstance->get_lang('edit').'">
  60. <img src="'.$plugininstance->pix_url('edit').'" /></a>';
  61. $cmd .= '&nbsp;<a href="'.$thisurl.'?what=snapshotinstance&vid='.$instance->id.'" title="'.$plugininstance->get_lang('snapshotinstance').'">
  62. <img src="'.$plugininstance->pix_url('snapshot').'" /></a>';
  63. if (!$instance->visible) {
  64. $cmd .= '<a href="'.$thisurl.'?what=fulldeleteinstances&vids[]='.$instance->id.'" title="'.$plugininstance->get_lang('destroyinstances').'">
  65. <img src="'.$plugininstance->pix_url('delete').'" /></a>';
  66. } else {
  67. $cmd .= '<a href="'.$thisurl.'?what=deleteinstances&vids[]='.$instance->id.'" title="'.$plugininstance->get_lang('deleteinstances').'">
  68. <img src="'.$plugininstance->pix_url('delete').'" /></a>';
  69. }
  70. $crondate = ($instance->lastcron) ? date('r', $instance->lastcron) : '';
  71. $data = array(
  72. $checkbox,
  73. $sitelink.' ('.Display::url($instance->root_web, $instance->root_web).')',
  74. $instance->institution,
  75. $instance->db_host.' - '.$instance->main_database,
  76. $instance->slug,
  77. $status,
  78. $crondate,
  79. $cmd,
  80. );
  81. $attrs = array('center' => 'left');
  82. $table->addRow($data, $attrs, 'td');
  83. $i++;
  84. }
  85. $items = [
  86. [
  87. 'url' => $thisurl.'?what=newinstance',
  88. 'content' => $plugininstance->get_lang('newinstance')
  89. ],
  90. [
  91. 'url' => $thisurl.'?what=instance&registeronly=1',
  92. 'content' => $plugininstance->get_lang('registerinstance')
  93. ],
  94. [
  95. 'url' => $thisurl.'?what=snapshotinstance&vid=0',
  96. 'content' => $plugininstance->get_lang('snapshotmaster')
  97. ],
  98. [
  99. 'url' => $thisurl.'?what=clearcache&vid=0',
  100. 'content' => $plugininstance->get_lang('clearmastercache')
  101. ],
  102. [
  103. 'url' => api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/syncparams.php',
  104. 'content' => $plugininstance->get_lang('sync_settings')
  105. ],
  106. [
  107. 'url' => api_get_path(WEB_CODE_PATH).'admin/configure_plugin.php?name=vchamilo',
  108. 'content' => get_lang('Settings')
  109. ]
  110. ];
  111. $content = Display::page_header('VChamilo Instances');
  112. $content .= Display::actions($items);
  113. $content .= '<form action="'.$thisurl.'">';
  114. $content .= $table->toHtml();
  115. $selectionoptions = array('<option value="0" selected="selected">'.$plugininstance->get_lang('choose').'</option>');
  116. $selectionoptions[] = '<option value="deleteinstances">'.$plugininstance->get_lang('deleteinstances').'</option>';
  117. $selectionoptions[] = '<option value="enableinstances">'.$plugininstance->get_lang('enableinstances').'</option>';
  118. $selectionoptions[] = '<option value="fulldeleteinstances">'.$plugininstance->get_lang(
  119. 'destroyinstances'
  120. ).'</option>';
  121. $selectionoptions[] = '<option value="clearcache">'.$plugininstance->get_lang('clearcache').'</option>';
  122. $selectionoptions[] = '<option value="setconfigvalue">'.$plugininstance->get_lang('setconfigvalue').'</option>';
  123. $selectionaction = '<select name="what" onchange="this.form.submit()">'.implode('', $selectionoptions).'</select>';
  124. $content .= '<div class"vchamilo-right"><div></div><div>
  125. <a href="javascript:selectallhosts()">'.$plugininstance->get_lang('selectall').'</a> -
  126. <a href="javascript:deselectallhosts()">'.$plugininstance->get_lang('selectnone').'</a> -
  127. &nbsp; - '.$plugininstance->get_lang('withselection').' '.$selectionaction.'</div></div>';
  128. $content .= '</form>';
  129. if (empty($templates)) {
  130. $content = '';
  131. }
  132. $tpl = new Template(get_lang('VChamilo'), true, true, false, true, false);
  133. $tpl->assign('content', $content);
  134. $tpl->display_one_col_template();