Moving courses to data/courses see #5871

skala
Julio Montoya 13 years ago
parent c31f054d15
commit 6cc22982ff
  1. 166
      main/admin/configure_homepage.php
  2. 1
      main/course_home/activity.php
  3. 85
      main/inc/global.inc.php
  4. 14
      main/inc/lib/course.lib.php
  5. 16
      main/inc/lib/document.lib.php
  6. 42
      main/inc/lib/main_api.lib.php
  7. 7
      main/inc/local.inc.php
  8. 2
      main/install/index.php
  9. 60
      main/install/install.lib.php
  10. 50
      src/ChamiloLMS/Controller/CourseHomeController.php

@ -19,8 +19,6 @@ api_protect_admin_script();
require_once api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php';
global $_configuration;
$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null;
$tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
$tool_name = get_lang('ConfigureHomePage');
@ -82,6 +80,7 @@ if (!empty($_SESSION['user_language_choice'])) {
}
// Ensuring availability of main files in the corresponding language
$homePath = api_get_path(SYS_DATA_PATH).'home/';
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
@ -92,9 +91,8 @@ if (api_is_multiple_url_enabled()) {
$clean_url = str_replace('/', '-', $clean_url);
$clean_url .= '/';
$homep = api_get_path(SYS_PATH).'home/'; //homep for Home Path
$homep_new = api_get_path(SYS_PATH).'home/'.$clean_url; //homep for Home Path added the url
$new_url_dir = api_get_path(SYS_PATH).'home/'.$clean_url;
$homep_new = $homePath.$clean_url; //homep for Home Path added the url
$new_url_dir = $homePath.$clean_url;
//we create the new dir for the new sites
if (!is_dir($new_url_dir)) {
mkdir($new_url_dir, api_get_permissions_for_new_directories());
@ -102,7 +100,7 @@ if (api_is_multiple_url_enabled()) {
}
} else {
$homep_new = '';
$homep = api_get_path(SYS_PATH).'home/'; //homep for Home Path
//$homep = api_get_path(SYS_PATH).'home/'; //homep for Home Path
}
$menuf = 'home_menu'; //menuf for Menu File
@ -118,16 +116,16 @@ $homef = array($menuf, $newsf, $topf, $noticef, $menutabs);
foreach ($homef as $my_file) {
if (api_is_multiple_url_enabled()) {
if (!file_exists($homep_new.$my_file.'_'.$lang.$ext)) {
copy($homep.$my_file.$ext, $homep_new.$my_file.'_'.$lang.$ext);
copy($homePath.$my_file.$ext, $homep_new.$my_file.'_'.$lang.$ext);
}
} else {
if (!file_exists($homep.$my_file.'_'.$lang.$ext)) {
copy($homep.$my_file.$ext, $homep.$my_file.'_'.$lang.$ext);
if (!file_exists($homePath.$my_file.'_'.$lang.$ext)) {
copy($homePath.$my_file.$ext, $homePath.$my_file.'_'.$lang.$ext);
}
}
}
if (api_is_multiple_url_enabled()) {
$homep = $homep_new;
$homePath = $homep_new;
}
// Check WCAG settings and prepare edition using WCAG
@ -164,9 +162,9 @@ if (!empty($action)) {
}
// Write
if (file_exists($homep.$topf.'_'.$lang.$ext)) {
if (is_writable($homep.$topf.'_'.$lang.$ext)) {
$fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
if (file_exists($homePath.$topf.'_'.$lang.$ext)) {
if (is_writable($homePath.$topf.'_'.$lang.$ext)) {
$fp = fopen($homePath.$topf.'_'.$lang.$ext, 'w');
fputs($fp, $home_top);
fclose($fp);
} else {
@ -174,7 +172,7 @@ if (!empty($action)) {
}
} else {
//File does not exist
$fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
$fp = fopen($homePath.$topf.'_'.$lang.$ext, 'w');
fputs($fp, $home_top);
fclose($fp);
}
@ -204,9 +202,9 @@ if (!empty($action)) {
$errorMsg = get_lang('NoticeWillBeNotDisplayed');
}
// Write
if (file_exists($homep.$noticef.'_'.$lang.$ext)) {
if (is_writable($homep.$noticef.'_'.$lang.$ext)) {
$fp = fopen($homep.$noticef.'_'.$lang.$ext, 'w');
if (file_exists($homePath.$noticef.'_'.$lang.$ext)) {
if (is_writable($homePath.$noticef.'_'.$lang.$ext)) {
$fp = fopen($homePath.$noticef.'_'.$lang.$ext, 'w');
if ($errorMsg == '') {
fputs($fp, "<b>$notice_title</b><br />\n$notice_text");
} else {
@ -218,7 +216,7 @@ if (!empty($action)) {
}
} else {
//File does not exist
$fp = fopen($homep.$noticef.'_'.$lang.$ext, 'w');
$fp = fopen($homePath.$noticef.'_'.$lang.$ext, 'w');
fputs($fp, "<b>$notice_title</b><br />\n$notice_text");
fclose($fp);
}
@ -240,9 +238,9 @@ if (!empty($action)) {
}
//Write
if ($s_languages_news != 'all') {
if (file_exists($homep.$newsf.'_'.$s_languages_news.$ext)) {
if (is_writable($homep.$newsf.'_'.$s_languages_news.$ext)) {
$fp = fopen($homep.$newsf.'_'.$s_languages_news.$ext, 'w');
if (file_exists($homePath.$newsf.'_'.$s_languages_news.$ext)) {
if (is_writable($homePath.$newsf.'_'.$s_languages_news.$ext)) {
$fp = fopen($homePath.$newsf.'_'.$s_languages_news.$ext, 'w');
fputs($fp, $home_news);
fclose($fp);
} else {
@ -250,7 +248,7 @@ if (!empty($action)) {
}
} else {
// File does not exist
$fp = fopen($homep.$newsf.'_'.$s_languages_news.$ext, 'w');
$fp = fopen($homePath.$newsf.'_'.$s_languages_news.$ext, 'w');
fputs($fp, $home_news);
fclose($fp);
}
@ -259,9 +257,9 @@ if (!empty($action)) {
$_languages = api_get_languages();
foreach ($_languages['name'] as $key => $value) {
$english_name = $_languages['folder'][$key];
if (file_exists($homep.$newsf.'_'.$english_name.$ext)) {
if (is_writable($homep.$newsf.'_'.$english_name.$ext)) {
$fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w');
if (file_exists($homePath.$newsf.'_'.$english_name.$ext)) {
if (is_writable($homePath.$newsf.'_'.$english_name.$ext)) {
$fp = fopen($homePath.$newsf.'_'.$english_name.$ext, 'w');
fputs($fp, $home_news);
fclose($fp);
} else {
@ -269,7 +267,7 @@ if (!empty($action)) {
}
} else {
// File does not exist
$fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w');
$fp = fopen($homePath.$newsf.'_'.$english_name.$ext, 'w');
fputs($fp, $home_news);
fclose($fp);
}
@ -309,7 +307,7 @@ if (!empty($action)) {
$link_url = 'http://'.$link_url;
}
$menuf = ($action == 'insert_tabs' || $action == 'edit_tabs') ? $menutabs : $menuf;
if (!is_writable($homep.$menuf.'_'.$lang.$ext)) {
if (!is_writable($homePath.$menuf.'_'.$lang.$ext)) {
$errorMsg = get_lang('HomePageFilesNotWritable');
} elseif (empty($link_name)) {
$errorMsg = get_lang('PleaseEnterLinkName');
@ -333,7 +331,7 @@ if (!empty($action)) {
}
// Get the contents of home_menu_en.html (or active menu language
// version) into $home_menu as an array of one entry per line
$home_menu = file($homep.$menuf.'_'.$lang.$ext);
$home_menu = file($homePath.$menuf.'_'.$lang.$ext);
$home_menu = implode("\n", $home_menu);
$home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
$home_menu = explode("\n", $home_menu);
@ -355,7 +353,7 @@ if (!empty($action)) {
// If the file doesn't exist, then create it and
// fill it with default text
$fp = @fopen($homep.$filename, 'w');
$fp = @fopen($homePath.$filename, 'w');
if ($fp) {
if (empty($link_html)) {
fputs($fp, get_lang('MyTextHere'));
@ -368,7 +366,7 @@ if (!empty($action)) {
// If the requested action is to edit a link, open the file and
// write to it (if the file doesn't exist, create it)
if (in_array($action, array('edit_link')) && !empty($link_html)) {
$fp = @fopen($homep.$filename, 'w');
$fp = @fopen($homePath.$filename, 'w');
if ($fp) {
fputs($fp, $link_html);
fclose($fp);
@ -401,14 +399,14 @@ if (!empty($action)) {
// Re-build the file from the home_menu array
$home_menu = implode("\n", $home_menu);
// Write
if (file_exists($homep.$menuf.'_'.$lang.$ext)) {
if (is_writable($homep.$menuf.'_'.$lang.$ext)) {
$fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
if (file_exists($homePath.$menuf.'_'.$lang.$ext)) {
if (is_writable($homePath.$menuf.'_'.$lang.$ext)) {
$fp = fopen($homePath.$menuf.'_'.$lang.$ext, 'w');
fputs($fp, $home_menu);
fclose($fp);
if (file_exists($homep.$menuf.$ext)) {
if (is_writable($homep.$menuf.$ext)) {
$fpo = fopen($homep.$menuf.$ext, 'w');
if (file_exists($homePath.$menuf.$ext)) {
if (is_writable($homePath.$menuf.$ext)) {
$fpo = fopen($homePath.$menuf.$ext, 'w');
fputs($fpo, $home_menu);
fclose($fpo);
}
@ -418,7 +416,7 @@ if (!empty($action)) {
}
} else {
//File does not exist
$fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
$fp = fopen($homePath.$menuf.'_'.$lang.$ext, 'w');
fputs($fp, $home_menu);
fclose($fp);
}
@ -450,7 +448,7 @@ if (!empty($action)) {
// link and re-writing the array to the file
$link_index = intval($_GET['link_index']);
$menuf = ($action == 'delete_tabs') ? $menutabs : $menuf;
$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
$home_menu = @file($homePath.$menuf.'_'.$lang.$ext);
if (empty($home_menu)) {
$home_menu = array();
}
@ -464,12 +462,12 @@ if (!empty($action)) {
$home_menu = implode("\n", $home_menu);
$home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
$fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
$fp = fopen($homePath.$menuf.'_'.$lang.$ext, 'w');
fputs($fp, $home_menu);
fclose($fp);
if (file_exists($homep.$menuf.$ext)) {
if (is_writable($homep.$menuf.$ext)) {
$fpo = fopen($homep.$menuf.$ext, 'w');
if (file_exists($homePath.$menuf.$ext)) {
if (is_writable($homePath.$menuf.$ext)) {
$fpo = fopen($homePath.$menuf.$ext, 'w');
fputs($fpo, $home_menu);
fclose($fpo);
}
@ -480,10 +478,10 @@ if (!empty($action)) {
case 'edit_top':
// This request is only the preparation for the update of the home_top
$home_top = '';
if (is_file($homep.$topf.'_'.$lang.$ext) && is_readable($homep.$topf.'_'.$lang.$ext)) {
$home_top = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
} elseif (is_file($homep.$topf.$lang.$ext) && is_readable($homep.$topf.$lang.$ext)) {
$home_top = @(string)file_get_contents($homep.$topf.$lang.$ext);
if (is_file($homePath.$topf.'_'.$lang.$ext) && is_readable($homePath.$topf.'_'.$lang.$ext)) {
$home_top = @(string)file_get_contents($homePath.$topf.'_'.$lang.$ext);
} elseif (is_file($homePath.$topf.$lang.$ext) && is_readable($homePath.$topf.$lang.$ext)) {
$home_top = @(string)file_get_contents($homePath.$topf.$lang.$ext);
} else {
$errorMsg = get_lang('HomePageFilesNotReadable');
}
@ -492,10 +490,10 @@ if (!empty($action)) {
case 'edit_notice':
// This request is only the preparation for the update of the home_notice
$home_notice = '';
if (is_file($homep.$noticef.'_'.$lang.$ext) && is_readable($homep.$noticef.'_'.$lang.$ext)) {
$home_notice = @file($homep.$noticef.'_'.$lang.$ext);
} elseif (is_file($homep.$noticef.$lang.$ext) && is_readable($homep.$noticef.$lang.$ext)) {
$home_notice = @file($homep.$noticef.$lang.$ext);
if (is_file($homePath.$noticef.'_'.$lang.$ext) && is_readable($homePath.$noticef.'_'.$lang.$ext)) {
$home_notice = @file($homePath.$noticef.'_'.$lang.$ext);
} elseif (is_file($homePath.$noticef.$lang.$ext) && is_readable($homePath.$noticef.$lang.$ext)) {
$home_notice = @file($homePath.$noticef.$lang.$ext);
} else {
$errorMsg = get_lang('HomePageFilesNotReadable');
}
@ -510,10 +508,10 @@ if (!empty($action)) {
case 'edit_news':
// This request is the preparation for the update of the home_news page
$home_news = '';
if (is_file($homep.$newsf.'_'.$lang.$ext) && is_readable($homep.$newsf.'_'.$lang.$ext)) {
$home_news = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
} elseif (is_file($homep.$newsf.$lang.$ext) && is_readable($homep.$newsf.$lang.$ext)) {
$home_news = @(string)file_get_contents($homep.$newsf.$lang.$ext);
if (is_file($homePath.$newsf.'_'.$lang.$ext) && is_readable($homePath.$newsf.'_'.$lang.$ext)) {
$home_news = @(string)file_get_contents($homePath.$newsf.'_'.$lang.$ext);
} elseif (is_file($homePath.$newsf.$lang.$ext) && is_readable($homePath.$newsf.$lang.$ext)) {
$home_news = @(string)file_get_contents($homePath.$newsf.$lang.$ext);
} else {
$errorMsg = get_lang('HomePageFilesNotReadable');
}
@ -523,10 +521,10 @@ if (!empty($action)) {
// This request is the preparation for the addition of an item in home_menu
$home_menu = '';
$menuf = ($action == 'edit_tabs') ? $menutabs : $menuf;
if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
} elseif (is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
$home_menu = @file($homep.$menuf.$lang.$ext);
if (is_file($homePath.$menuf.'_'.$lang.$ext) && is_readable($homePath.$menuf.'_'.$lang.$ext)) {
$home_menu = @file($homePath.$menuf.'_'.$lang.$ext);
} elseif (is_file($homePath.$menuf.$lang.$ext) && is_readable($homePath.$menuf.$lang.$ext)) {
$home_menu = @file($homePath.$menuf.$lang.$ext);
} else {
$errorMsg = get_lang('HomePageFilesNotReadable');
}
@ -543,10 +541,10 @@ if (!empty($action)) {
case 'insert_tabs':
// This request is the preparation for the addition of an item in home_menu
$home_menu = '';
if (is_file($homep.$menutabs.'_'.$lang.$ext) && is_readable($homep.$menutabs.'_'.$lang.$ext)) {
$home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
} elseif (is_file($homep.$menutabs.$lang.$ext) && is_readable($homep.$menutabs.$lang.$ext)) {
$home_menu = @file($homep.$menutabs.$lang.$ext);
if (is_file($homePath.$menutabs.'_'.$lang.$ext) && is_readable($homePath.$menutabs.'_'.$lang.$ext)) {
$home_menu = @file($homePath.$menutabs.'_'.$lang.$ext);
} elseif (is_file($homePath.$menutabs.$lang.$ext) && is_readable($homePath.$menutabs.$lang.$ext)) {
$home_menu = @file($homePath.$menutabs.$lang.$ext);
} else {
$errorMsg = get_lang('HomePageFilesNotReadable');
}
@ -565,10 +563,10 @@ if (!empty($action)) {
// This request is the preparation for the edition of the links array
$home_menu = '';
$menuf = ($action == 'edit_tabs') ? $menutabs : $menuf;
if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
} elseif (is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
$home_menu = @file($homep.$menuf.$lang.$ext);
if (is_file($homePath.$menuf.'_'.$lang.$ext) && is_readable($homePath.$menuf.'_'.$lang.$ext)) {
$home_menu = @file($homePath.$menuf.'_'.$lang.$ext);
} elseif (is_file($homePath.$menuf.$lang.$ext) && is_readable($homePath.$menuf.$lang.$ext)) {
$home_menu = @file($homePath.$menuf.$lang.$ext);
} else {
$errorMsg = get_lang('HomePageFilesNotReadable');
}
@ -635,7 +633,7 @@ if (!empty($action)) {
if (!strstr($filename, '/') && strstr($filename, '.html')) {
// Get oonly the contents of the link file
$link_html = @file($homep.$filename);
$link_html = @file($homePath.$filename);
$link_html = implode('', $link_html);
$link_url = '';
} else {
@ -665,7 +663,7 @@ switch ($action) {
case 'open_link':
if (!empty($link)) {
// $link is only set in case of action=open_link and is filtered
$open = @(string)file_get_contents($homep.$link);
$open = @(string)file_get_contents($homePath.$link);
$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
echo $open;
}
@ -820,7 +818,7 @@ switch ($action) {
$open = $home_top;
} else {
$name = $newsf;
$open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
$open = @(string)file_get_contents($homePath.$newsf.'_'.$lang.$ext);
}
$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
@ -898,10 +896,10 @@ switch ($action) {
<td colspan="2">
<?php
//print home_top contents
if (file_exists($homep.$topf.'_'.$lang.$ext)) {
$home_top_temp = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
if (file_exists($homePath.$topf.'_'.$lang.$ext)) {
$home_top_temp = @(string)file_get_contents($homePath.$topf.'_'.$lang.$ext);
} else {
$home_top_temp = @(string)file_get_contents($homep.$topf.$ext);
$home_top_temp = @(string)file_get_contents($homePath.$topf.$ext);
}
$open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
@ -954,12 +952,12 @@ switch ($action) {
</td>
<!--<td width="50%" valign="top">
<?php
if (file_exists($homep.$newsf.'_'.$lang.$ext)) {
$open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
if (file_exists($homePath.$newsf.'_'.$lang.$ext)) {
$open = @(string)file_get_contents($homePath.$newsf.'_'.$lang.$ext);
$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
echo $open;
} else {
$open = @(string)file_get_contents($homep.$newsf.$ext);
$open = @(string)file_get_contents($homePath.$newsf.$ext);
$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
echo $open;
}
@ -972,10 +970,10 @@ switch ($action) {
// Add new page
$home_menu = '';
if (file_exists($homep.$menutabs.'_'.$lang.$ext)) {
$home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
if (file_exists($homePath.$menutabs.'_'.$lang.$ext)) {
$home_menu = @file($homePath.$menutabs.'_'.$lang.$ext);
} else {
$home_menu = @file($homep.$menutabs.$ext);
$home_menu = @file($homePath.$menutabs.$ext);
}
if (empty($home_menu)) {
$home_menu = array();
@ -1077,10 +1075,10 @@ switch ($action) {
</h4>
<?php
$home_notice = '';
if (file_exists($homep.$noticef.'_'.$lang.$ext)) {
$home_notice = @(string)file_get_contents($homep.$noticef.'_'.$lang.$ext);
if (file_exists($homePath.$noticef.'_'.$lang.$ext)) {
$home_notice = @(string)file_get_contents($homePath.$noticef.'_'.$lang.$ext);
} else {
$home_notice = @(string)file_get_contents($homep.$noticef.$ext);
$home_notice = @(string)file_get_contents($homePath.$noticef.$ext);
}
$home_notice = api_to_system_encoding(
$home_notice,
@ -1106,10 +1104,10 @@ switch ($action) {
<ul class="menulist">
<?php
$home_menu = '';
if (file_exists($homep.$menuf.'_'.$lang.$ext)) {
$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
if (file_exists($homePath.$menuf.'_'.$lang.$ext)) {
$home_menu = @file($homePath.$menuf.'_'.$lang.$ext);
} else {
$home_menu = @file($homep.$menuf.$ext);
$home_menu = @file($homePath.$menuf.$ext);
}
if (empty($home_menu)) {
$home_menu = array();

@ -30,7 +30,6 @@ if (api_is_allowed_to_edit(null, true)) {
// REACTIVATE
$sql = "UPDATE $tool_table SET visibility=1 WHERE c_id = $course_id AND id=".$id;
Database::query($sql);
//$show_message = Display::return_message(get_lang('ToolIsNowVisible'),'confirmation');
}
}

@ -29,6 +29,7 @@
require_once __DIR__.'../../../vendor/autoload.php';
use Silex\Application;
use \ChamiloSession as Session;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
@ -554,7 +555,7 @@ if (!($conn_return = @Database::connect(
'server' => $app['configuration']['db_host'],
'username' => $app['configuration']['db_user'],
'password' => $app['configuration']['db_password'],
'persistent' => $app['configuration']['db_persistent_connection']
'persistent' => isset($app['configuration']['db_persistent_connection']) ? $app['configuration']['db_persistent_connection'] : null
// When $app['configuration']['db_persistent_connection'] is set, it is expected to be a boolean type.
)
))
@ -570,6 +571,7 @@ if (!$app['configuration']['db_host']) {
$charset = 'UTF-8';
$checkConnection = false;
if (isset($app['configuration']['main_database'])) {
// The system has not been designed to use special SQL modes that were introduced since MySQL 5.
Database::query("set session sql_mode='';");
@ -672,7 +674,6 @@ $app->register(new Silex\Provider\SwiftmailerServiceProvider(), array(
'auth_mode' => null
)
));
//if (isset($platform_email['SMTP_MAILER']) && $platform_email['SMTP_MAILER'] == 'smtp') {
$app['mailer'] = $app->share(function ($app) {
return new \Swift_Mailer($app['swiftmailer.transport']);
@ -875,7 +876,7 @@ $app->before(
}
if (!is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
$app->abort(500, "temp folder must be writeable");
$app->abort(500, "temp folder must be writable");
}
// Check and modify the date of user in the track.e.online table
@ -905,8 +906,6 @@ $app->finish(
}
);
// The global variable $charset has been defined in a language file too (trad4all.inc.php), this is legacy situation.
// So, we have to reassign this variable again in order to keep its value right.
$charset = $charset_initial_value;
@ -1016,6 +1015,7 @@ $app['news.controller'] = $app->share(function () use ($app) {
return new ChamiloLMS\Controller\NewsController();
});
/*
class PostController
{
@ -1035,12 +1035,59 @@ $app['posts.controller'] = $app->share(function() use ($app) {
});
$app->mount('/', "posts.controller");*/
//@todo move this in a permission class
$checkCourse = function (Request $request) use ($app) {
$courseCode = $request->get('courseCode');
$sessionId = $request->get('sessionId');
$_course = api_get_course_info($courseCode);
if (!empty($_course)) {
//@TODO real_cid should be cid, for working with numeric course id
$_real_cid = $_course['real_id'];
$_cid = $_course['code'];
Session::write('_real_cid', $_real_cid);
Session::write('_cid', $_cid);
Session::write('_course', $_course);
}
$sessionId = intval($sessionId);
if (!empty($sessionId)) {
$sessionInfo = api_get_session_info($sessionId);
if (empty($sessionInfo)) {
$app->abort(404, 'Session not available');
}
Session::write('id_session', $sessionId);
} else {
Session::write('id_session', 0);
}
};
$courseAccessConditions = function (Request $request) use ($app) {
$courseCode = $request->get('cidReq');
};
$userAccessPermissions = function (Request $request) use ($app) {
$courseCode = $request->get('cidReq');
};
//End legacy befores
//All calls made in Chamilo are manage in the src/ChamiloLMS/Controller/LegacyController.php file function classicAction
$app->get('/', 'legacy.controller:classicAction');
$app->post('/', 'legacy.controller:classicAction');
$app->get('/', 'legacy.controller:classicAction')
->before($courseAccessConditions)
->before($userAccessPermissions);
$app->post('/', 'legacy.controller:classicAction')
->before($courseAccessConditions)
->before($userAccessPermissions);
//index.php
$app->get('/index', 'index.controller:indexAction')->bind('index');
$app->get('/index', 'index.controller:indexAction')
->bind('index');
//user_portal.php
$app->get('/userportal', 'userPortal.controller:indexAction');
@ -1049,14 +1096,23 @@ $app->get('/userportal/{type}/{filter}/{page}', 'userPortal.controller:indexActi
->value('filter', 'current')
->value('page', '1')
->bind('userportal');
//->assert('type', '.+'); //allowing slash "/"
//->assert('type', '.+'); //allowing slash "/"
//Logout page
$app->get('/logout', 'index.controller:logoutAction')->bind('logout');
$app->get('/logout', 'index.controller:logoutAction')
->bind('logout');
//Course home
$app->match('/courses/{courseCode}/{sessionId}/', 'course_home.controller:indexAction', 'GET|POST')
->assert('type', '.+')
->before($checkCourse);
$app->match('/courses/{courseCode}/', 'course_home.controller:indexAction', 'GET|POST')
->assert('type', '.+')
->before($checkCourse); //allowing slash "/"
//Courses
$app->match('/courses/{courseCode}/index.php', 'course_home.controller:indexAction', 'GET|POST');
$app->match('/courses/{courseCode}', 'course_home.controller:indexAction', 'GET|POST');
//$app->match('/courses/{courseCode}/document/{fileName}', 'course_home.controller:getFileAction', 'GET|POST');
//Certificates
$app->match('/certificates/{id}', 'certificate.controller:indexAction', 'GET');
@ -1072,6 +1128,7 @@ $app->match('/users/online-in-session', 'user.controller:onlineInSessionAction',
$app->match('/news/{id}', 'news.controller:indexAction', 'GET');
//LP controller
$app->match('/learnpath/subscribe_users/{lpId}', 'learnpath.controller:indexAction', 'GET|POST')->bind('subscribe_users');
$app->match('/learnpath/subscribe_users/{lpId}', 'learnpath.controller:indexAction', 'GET|POST')
->bind('subscribe_users');
return $app;

@ -2739,7 +2739,7 @@ class CourseManager {
}
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED || $course['status'] == COURSEMANAGER) {
$course_title = '<a href="'.api_get_path(WEB_COURSE_PATH).$course_info['path'].'/?id_session=0&amp;autoreg=1">'.$course_info['title'].'</a>';
$course_title = '<a href="'.api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?id_session=0&amp;autoreg=1">'.$course_info['title'].'</a>';
} else {
$course_title = $course_info['title']." ".Display::tag('span',get_lang('CourseClosed'), array('class'=>'item_closed'));
}
@ -2754,7 +2754,7 @@ class CourseManager {
$course_title .= Display::return_icon('klipper.png', get_lang('CourseAutoRegister'));
$params['title'] = $course_title;
$params['link'] = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/?id_session=0&amp;autoreg=1';
$params['link'] = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?id_session=0&amp;autoreg=1';
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) {
$params['notifications'] = $show_notification;
@ -2891,7 +2891,7 @@ class CourseManager {
$course_title_url = '';
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED || $course['status'] == COURSEMANAGER) {
$course_title_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/?id_session=0';
$course_title_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?id_session=0';
$course_title = Display::url($course_info['title'], $course_title_url);
} else {
$course_title = $course_info['title']." ".Display::tag('span',get_lang('CourseClosed'), array('class'=>'item_closed'));
@ -3048,7 +3048,7 @@ class CourseManager {
$course_title_url = '';
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED || $course['status'] == COURSEMANAGER) {
$course_title_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/?id_session=0';
$course_title_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?id_session=0';
$course_title = Display::url($course_info['title'], $course_title_url);
} else {
$course_title = $course_info['title']." ".Display::tag('span',get_lang('CourseClosed'), array('class'=>'item_closed'));
@ -3221,7 +3221,7 @@ class CourseManager {
$course_title_url = '';
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED || $course['status'] == COURSEMANAGER) {
$course_title_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/?id_session=0';
$course_title_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?id_session=0';
$course_title = Display::url($course_info['title'], $course_title_url);
} else {
$course_title = $course_info['title']." ".Display::tag('span',get_lang('CourseClosed'), array('class'=>'item_closed'));
@ -3321,8 +3321,8 @@ class CourseManager {
$session_url = '';
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED || $course_info['user_status_in_course'] == COURSEMANAGER) {
$session_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/?id_session='.$course_info['id_session'];
$session_title = '<a href="'.api_get_path(WEB_COURSE_PATH).$course_info['path'].'/?id_session='.$course_info['id_session'].'">'.$course_info['name'].'</a>';
$session_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?id_session='.$course_info['id_session'];
$session_title = '<a href="'.api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?id_session='.$course_info['id_session'].'">'.$course_info['name'].'</a>';
} else {
$session_title = $course_info['name'].' '.Display::tag('span',get_lang('CourseClosed'), array('class'=>'item_closed'));
}

@ -290,7 +290,7 @@ class DocumentManager
//$doc_url = addslashes($doc_url);
$query = "SELECT 1 FROM $tbl_document AS docs,$tbl_item_property AS props
WHERE props.tool = 'document' AND docs.id=props.ref AND props.visibility <> '1' AND docs.path = '$doc_url'";
//echo $query;
$result = Database::query($query);
return (Database::num_rows($result) == 0);
@ -1106,6 +1106,7 @@ class DocumentManager
$TABLE_DOCUMENT = Database :: get_course_table(TABLE_DOCUMENT);
$id = intval($id);
$sql = "SELECT * FROM $TABLE_DOCUMENT WHERE c_id = $course_id AND id = $id ";
$result = Database::query($sql);
if ($result && Database::num_rows($result) == 1) {
$row = Database::fetch_array($result, 'ASSOC');
@ -2348,7 +2349,7 @@ class DocumentManager
} else {
$destination = $destiny_path.'/'.$file_name;
}
//var_dump("From $original ", "to $destination");
$original_count = count(explode('/', $original));
$destination_count = count(explode('/', $destination));
if ($original_count == $destination_count) {
@ -2362,7 +2363,7 @@ class DocumentManager
} else {
$mode = 'inside';
}
//echo $original_count.' '.$destination_count; var_dump($mode);
//We do not select the $original_path becayse the file was already moved
$content_html = file_get_contents($destiny_path.'/'.$file_name);
$destination_file = $destiny_path.'/'.$file_name;
@ -2408,7 +2409,7 @@ class DocumentManager
if ($count_pre_destination_levels == 0) {
$count_pre_destination_levels = 1;
}
//echo '$count_pre_destination_levels '. $count_pre_destination_levels;
$pre_remove = '';
for ($i = 1; $i <= $count_pre_destination_levels; $i++) {
$pre_remove .= '..\/';
@ -2446,7 +2447,7 @@ class DocumentManager
$document_file = strstr($real_orig_path, 'document');
if (strpos($real_orig_path, $document_file) !== false) {
echo 'continue1';
//echo 'continue1';
continue;
} else {
$real_orig_url_temp = '';
@ -2465,7 +2466,7 @@ class DocumentManager
$content_html = str_replace($real_orig_url, $destination_url, $content_html);
}
} else {
echo 'continue3';
//echo 'continue3';
continue;
}
}
@ -3180,7 +3181,6 @@ class DocumentManager
if (empty($title)) {
$title = $key;
}
//echo '<pre>'; print_r($resource);
if (isset($resource['id']) && is_int($resource['id'])) {
// It's a folder.
//hide some folders
@ -3393,7 +3393,7 @@ class DocumentManager
//TODO: mime_content_type is deprecated, fileinfo php extension is enabled by default as of PHP 5.3.0
// now versions of PHP on Debian testing(5.2.6-5) and Ubuntu(5.2.6-2ubuntu) are lower, so wait for a while
$doc_mime = mime_content_type($doc_path);
//echo $doc_mime;
$allowed_mime_types = self::file_get_mime_type(true);
// mime_content_type does not detect correctly some formats that are going to be supported for index, so an extensions array is used for the moment

@ -235,6 +235,8 @@ define('REL_PATH', 'REL_PATH');
define('WEB_SERVER_ROOT_PATH', 'WEB_SERVER_ROOT_PATH');
define('SYS_SERVER_ROOT_PATH', 'SYS_SERVER_ROOT_PATH');
define('WEB_COURSE_PATH', 'WEB_COURSE_PATH');
define('WEB_DATA_COURSE_PATH', 'WEB_DATA_COURSE_PATH');
define('SYS_COURSE_PATH', 'SYS_COURSE_PATH');
define('REL_COURSE_PATH', 'REL_COURSE_PATH');
define('REL_CODE_PATH', 'REL_CODE_PATH');
@ -451,7 +453,7 @@ define ('SKILL_TYPE_BOTH', 'both');
* api_get_path(SYS_DATA_PATH) /var/www/chamilo/data/
* api_get_path(SYS_CONFIG_PATH) /var/www/chamilo/config/
* api_get_path(SYS_COURSE_PATH) /var/www/chamilo/courses/
* api_get_path(SYS_COURSE_PATH) /var/www/chamilo/data/courses/
* api_get_path(SYS_CODE_PATH) /var/www/chamilo/main/
* api_get_path(SYS_CSS_PATH) /var/www/chamilo/main/css
* api_get_path(INCLUDE_PATH) /var/www/chamilo/main/inc/
@ -502,7 +504,8 @@ function api_get_path($path_type, $path = null) {
WEB_SERVER_ROOT_PATH => '',
SYS_SERVER_ROOT_PATH => '',
WEB_COURSE_PATH => '',
SYS_COURSE_PATH => '',
WEB_DATA_COURSE_PATH => 'data/',
SYS_COURSE_PATH => 'data/',
REL_COURSE_PATH => '',
REL_CODE_PATH => '',
WEB_CODE_PATH => '',
@ -604,7 +607,6 @@ function api_get_path($path_type, $path = null) {
$root_web = $server_protocol.'://'.$server_name.$root_rel;
$root_sys = str_replace('\\', '/', realpath(dirname(__FILE__).'/../../../')).'/';
$code_folder = 'main/';
$course_folder = 'courses/';
//}
// Here we give up, so we don't touch anything.
}
@ -634,7 +636,9 @@ function api_get_path($path_type, $path = null) {
$paths[WEB_SERVER_ROOT_PATH] = $server_base_web.'/';
$paths[SYS_SERVER_ROOT_PATH] = $server_base_sys.'/';
$paths[WEB_COURSE_PATH] = $root_web.$course_folder;
$paths[SYS_COURSE_PATH] = $root_sys.$course_folder;
$paths[WEB_DATA_COURSE_PATH] = $paths[WEB_PUBLIC_PATH].$course_folder;
$paths[SYS_COURSE_PATH] = $paths[SYS_DATA_PATH].$course_folder;
$paths[REL_COURSE_PATH] = $root_rel.$course_folder;
$paths[REL_CODE_PATH] = $root_rel.$code_folder;
$paths[WEB_CODE_PATH] = $root_web.$code_folder;
@ -966,7 +970,7 @@ function api_valid_email($address) {
* @author Roan Embrechts
*/
function api_protect_course_script($print_headers = false, $allow_session_admins = false, $allow_drh = false) {
global $is_allowed_in_course;
$is_allowed_in_course = Session::read('is_allowed_in_course');
$is_visible = false;
$course_info = api_get_course_info();
@ -1339,7 +1343,7 @@ function api_get_user_info_from_username($username = '') {
* Returns the current course code (string)
*/
function api_get_course_id() {
return isset($GLOBALS['_cid']) ? $GLOBALS['_cid'] : null;
return isset($_SESSION['_cid']) ? $_SESSION['_cid'] : null;
}
/**
@ -1414,24 +1418,25 @@ function api_get_anonymous_id() {
/**
* Returns the cidreq parameter name + current course id taken from
* $GLOBALS['_cid'] and returns a string like 'cidReq=ABC&id_session=123
* api_get_course_id() and returns a string like 'cidReq=ABC&id_session=123
* @return string Course & session references to add to a URL
*
* @see Uri.course_params
*/
function api_get_cidreq($add_session_id = true, $add_group_id = true) {
$url = empty($GLOBALS['_cid']) ? '' : 'cidReq='.htmlspecialchars($GLOBALS['_cid']);
if ($add_session_id) {
if (!empty($url)) {
$courseCode = api_get_course_id();
$url = empty($courseCode) || $courseCode == -1 ? '' : 'cidReq='.htmlspecialchars($courseCode);
if ($add_session_id) {
if (!empty($url)) {
$url .= api_get_session_id() == 0 ? '&id_session=0' : '&id_session='.api_get_session_id();
}
}
if ($add_group_id) {
}
if ($add_group_id) {
if (!empty($url)) {
$url .= api_get_group_id() == 0 ? '&gidReq=0' : '&gidReq='.api_get_group_id();
}
}
return $url;
}
}
return $url;
}
/**
* Returns the current course info array.
@ -1477,7 +1482,7 @@ function api_get_course_info($course_code = null, $add_extra_values = false) {
}
return $_course;
}
global $_course;
$_course = Session::read('_course');
if ($_course == '-1') {
$_course = array();
}
@ -1519,7 +1524,6 @@ function api_get_course_info_by_id($id = null, $add_extra_values = false) {
}
function api_format_course_array($course_data) {
global $_configuration;
if (empty($course_data)) {
return array();
@ -5965,9 +5969,9 @@ function api_get_course_url($course_code = null, $session_id = null) {
$course_info = api_get_course_info($course_code);
}
if (empty($session_id)) {
$session_url = '?id_session='.api_get_session_id();
$session_url = 'index.php?id_session='.api_get_session_id();
} else {
$session_url = '?id_session='.intval($session_id);
$session_url = 'index.php?id_session='.intval($session_id);
}
/*
if (empty($group_id)) {

@ -623,10 +623,11 @@ if (isset($cidReset) && $cidReset) {
}
if (empty($_SESSION['_course']) OR empty($_SESSION['_cid'])) { //no previous values...
$_cid = -1; //set default values that will be caracteristic of being unset
//set default values that will be caracteristic of being unset
$_cid = -1;
$_course = -1;
} else {
$_cid = $_SESSION['_cid' ];
$_cid = $_SESSION['_cid'];
$_course = $_SESSION['_course'];
// these lines are usefull for tracking. Indeed we can have lost the id_session and not the cid.
@ -943,6 +944,7 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) {
Session::write('is_courseCoach', $is_courseCoach);
Session::write('is_allowed_in_course', $is_allowed_in_course);
Session::write('is_sessionAdmin', $is_sessionAdmin);
} else { // continue with the previous values
if (isset($_SESSION['_courseUser'])) {
@ -954,7 +956,6 @@ if ((isset($uidReset) && $uidReset) || (isset($cidReset) && $cidReset)) {
$is_courseCoach = isset($_SESSION ['is_courseCoach']) ? $_SESSION ['is_courseCoach'] : false;
$is_courseMember = isset($_SESSION ['is_courseMember']) ? $_SESSION ['is_courseMember'] : false;
$is_allowed_in_course = isset($_SESSION ['is_allowed_in_course']) ? $_SESSION ['is_allowed_in_course'] : false;
}
//set variable according to student_view_enabled choices

@ -945,7 +945,7 @@ if (@$_POST['step2']) {
default:
break;
}
movingFilesInAppFolder();
movingFilesInDataFolder();
} else {
set_file_folder_permissions();
database_server_connect();

@ -1245,7 +1245,7 @@ function display_requirements(
if ($file_course_test_was_created == true) {
break;
}
$r = @touch($course_dir.'/test.php',$perm);
$r = touch($course_dir.'/test.php', $perm);
if ($r === true) {
$fil_perm_verified = $perm;
if (check_course_script_interpretation($course_dir, $course_attempt_name, 'test.php')) {
@ -1264,7 +1264,7 @@ function display_requirements(
$dir_perm = Display::label('0'.decoct($dir_perm_verified), 'info');
$file_perm = Display::label('0'.decoct($fil_perm_verified), 'info');
$course_test_was_created = ($course_test_was_created == true && $file_course_test_was_created == true) ? Display::label(get_lang('Yes'), 'success') : Display::label(get_lang('No'), 'warning');
$course_test_was_created = ($course_test_was_created == true && $file_course_test_was_created == true) ? Display::label(get_lang('Yes'), 'success') : Display::label(get_lang('No'), 'important');
echo '<table class="table">
<tr>
@ -1361,13 +1361,13 @@ function display_requirements(
$notwritable = array();
$curdir = getcwd();
$checked_writable = api_get_path(CONFIGURATION_PATH);
$checked_writable = api_get_path(SYS_CONFIG_PATH);
if (!is_writable($checked_writable)) {
$notwritable[] = $checked_writable;
@chmod($checked_writable, $perm);
}
$checked_writable = api_get_path(SYS_CODE_PATH).'upload/users/';
$checked_writable = api_get_path(SYS_DATA_PATH);
if (!is_writable($checked_writable)) {
$notwritable[] = $checked_writable;
@chmod($checked_writable, $perm);
@ -1385,32 +1385,38 @@ function display_requirements(
@chmod($checked_writable, $perm);
}
$checked_writable = api_get_path(SYS_COURSE_PATH);
$checked_writable = api_get_path(SYS_LOG_PATH);
if (!is_writable($checked_writable)) {
$notwritable[] = $checked_writable;
@chmod($checked_writable, $perm);
}
/*$checked_writable = api_get_path(SYS_COURSE_PATH);
if (!is_writable($checked_writable)) {
$notwritable[] = $checked_writable;
@chmod($checked_writable, $perm);
}*/
if ($course_test_was_created == false || $file_course_test_was_created == false) {
$error = true;
}
$checked_writable = api_get_path(SYS_PATH).'home/';
/*$checked_writable = api_get_path(SYS_PATH).'home/';
if (!is_writable($checked_writable)) {
$notwritable[] = realpath($checked_writable);
@chmod($checked_writable, $perm);
}
}*/
$checked_writable = api_get_path(CONFIGURATION_PATH).'configuration.php';
/*$checked_writable = api_get_path(CONFIGURATION_PATH).'configuration.php';
if (file_exists($checked_writable) && !is_writable($checked_writable)) {
$notwritable[] = $checked_writable;
@chmod($checked_writable, $perm_file);
}
}*/
// Second, if this fails, report an error
//--> The user would have to adjust the permissions manually
// The user would have to adjust the permissions manually
if (count($notwritable) > 0) {
$error = true;
echo '<div class="error-message">';
@ -1441,8 +1447,7 @@ function display_requirements(
<p align="center" style="padding-top:15px">
<button type="submit" name="step1" class="back" onclick="javascript: window.location='index.php'; return false;"
value="&lt; <?php echo get_lang('Previous'); ?>"><?php echo get_lang('Previous'); ?></button>
<button type="submit" name="step2_install" class="add"
value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) {
<button type="submit" name="step2_install" class="add"value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) {
echo 'disabled="disabled"';
} ?> ><?php echo get_lang('NewInstallation'); ?></button>
<input type="hidden" name="is_executable" id="is_executable" value="-"/>
@ -2053,7 +2058,7 @@ function display_configuration_settings_form(
echo "<h2>".display_step_sequence().get_lang("CfgSetting")."</h2>";
echo '</div>';
echo '<div class="RequirementContent">';
echo '<p>'.get_lang('ConfigSettingsInfo').' <strong>main/inc/conf/configuration.php</strong></p>';
echo '<p>'.get_lang('ConfigSettingsInfo').' '.Display::label('config/configuration.php', 'info').'</p>';
echo '</div>';
echo '<fieldset>';
@ -2533,8 +2538,18 @@ function check_course_script_interpretation($course_dir, $course_attempt_name, $
if ($handler = @fopen($file_name, "w")) {
//write content
if (fwrite($handler , $content)) {
$sock_errno = ''; $sock_errmsg = '';
$url = api_get_path(WEB_COURSE_PATH).'/'.$course_attempt_name.'/'.$file;
$file = api_get_path(SYS_COURSE_PATH).$course_attempt_name.'/'.$file;
if (file_exists($file)) {
return true;
}
//You can't access to a course file like this. You will be prompted to the installation process.
//If you access
$sock_errno = '';
$sock_errmsg = '';
$url = api_get_path(WEB_COURSE_PATH).$course_attempt_name.'/'.$file;
$parsed_url = parse_url($url);
//$scheme = isset($parsedUrl['scheme']) ? $parsedUrl['scheme'] : ''; //http
@ -2598,19 +2613,24 @@ function drop_course_tables()
}
}
function movingFilesInAppFolder()
/**
* Copy users files in the new data directory
*/
function movingFilesInDataFolder()
{
$sysPath = api_get_path(SYS_PATH);
$moveDirs = array(
$sysPath.'searchdb' => api_get_path(SYS_DATA_PATH).'searchdb',
$sysPath.'home' => api_get_path(SYS_DATA_PATH).'home',
$sysPath.'courses' => api_get_path(SYS_DATA_PATH).'courses',
$sysPath.'main/upload/users' => api_get_path(SYS_DATA_PATH).'upload/users',
);
error_log("Copying files to the new data folder");
foreach ($moveDirs as $from => $to) {
if (is_dir($from)) {
$copy = "cp -r $from/* $to";
error_log($copy);
system($copy);
}
}
}
}

@ -5,6 +5,7 @@ namespace ChamiloLMS\Controller;
use Silex\Application;
use Symfony\Component\HttpFoundation\Response;
/**
* Class LearnpathController
* @package ChamiloLMS\Controller
@ -14,20 +15,49 @@ class CourseHomeController
{
public $language_files = array('course_home','courses');
public function indexAction(Application $app, $courseCode)
public function indexAction(Application $app, $courseCode, $sessionId = null)
{
$list = api_get_tool_urls();
$content = null;
foreach ($list as $tool) {
$content .= \Display::url($tool, $tool.'?cidReq='.$courseCode);
}
//Needed because of this script:
$course_code = $courseCode;
$app['template']->assign('content', $content);
$result = require_once api_get_path(SYS_CODE_PATH).'course_home/course_home.php';
$response = $app['template']->render_layout('layout_2_col.tpl');
$app['template']->assign('content', $result['content']);
$app['template']->assign('message', $result['message']);
//return new Response($response, 200, array('Cache-Control' => 's-maxage=3600, public'));
$response = $app['template']->render_layout('layout_1_col.tpl');
return new Response($response, 200, array());
}
/**
* @param Application $app
* @param $courseCode
* @param $fileName
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public function getFileAction(Application $app, $courseCode, $fileName)
{
api_protect_course_script();
$courseInfo = api_get_course_info($courseCode);
$sessionId = $app['request']->get('id_session');
//$groupId = $app['request']->get('gidReq');
$docId = \DocumentManager::get_document_id($courseInfo, "/".$fileName);
$filePath = null;
if ($docId) {
$isVisible = \DocumentManager::is_visible_by_id($docId, $courseInfo, $sessionId, api_get_user_id());
$documentData = \DocumentManager::get_document_data_by_id($docId, $courseCode);
$filePath = $documentData['absolute_path'];
event_download($filePath);
}
if (!api_is_allowed_to_edit() && !$isVisible) {
$app->abort(500);
}
//DocumentManager::file_send_for_download($full_file_name);
return $app->sendFile($filePath);
}
}
Loading…
Cancel
Save