Fix course paths.

1.10.x
Julio Montoya 11 years ago
parent 1196819ce1
commit adc6f96c75
  1. 2
      .gitignore
  2. 2
      .travis.yml
  3. 6
      main/document/document.php
  4. 2
      main/inc/lib/document.lib.php
  5. 36
      main/inc/lib/group_portal_manager.lib.php
  6. 2
      main/inc/lib/internationalization.lib.php
  7. 2
      main/inc/lib/search/tool_processors/document_processor.class.php
  8. 2
      main/inc/lib/statistics.lib.php
  9. 2
      main/install/install.lib.php
  10. 2
      plugin/search_course/lib/search_course_widget.class.php
  11. 2
      robots.txt
  12. 15
      src/Chamilo/CoreBundle/Entity/Course.php

2
.gitignore vendored

@ -12,10 +12,12 @@ app/logs/*
# Courses # Courses
app/courses/*
courses/* courses/*
!courses/index.html !courses/index.html
# Home # Home
app/home/*
home/* home/*
# User images # User images

@ -40,7 +40,7 @@ before_script:
- cp chamilo-cli-install/chamilo-cli-installer.php main/install/ - cp chamilo-cli-install/chamilo-cli-installer.php main/install/
- mysql -u root -e 'create database chamilo' - mysql -u root -e 'create database chamilo'
# install Chamilo with Chash - see reference https://github.com/sonnym/travis-ci-drupal-module-example/blob/master/.travis.yml # install Chamilo with Chash - see reference https://github.com/sonnym/travis-ci-drupal-module-example/blob/master/.travis.yml
- sudo chmod -R 0777 app/cache courses home main/upload/ main/default_course_document/images main/inc/conf searchdb main/lang main/css - sudo chmod -R 0777 app/cache courses home app/upload/ main/default_course_document/images main/inc/conf searchdb main/lang main/css
- cd main/install/ - cd main/install/
- sudo php5 chamilo-cli-installer.php -l admin -p admin -U travis -u 'http://localhost/' -X travis -L english -z 'admin@example.com' -f 'John' -g 'Doe' -b '555-5555' -c 'Test campus' -y 'Chamilo' -x 'https://chamilo.org' - sudo php5 chamilo-cli-installer.php -l admin -p admin -U travis -u 'http://localhost/' -X travis -L english -z 'admin@example.com' -f 'John' -g 'Doe' -b '555-5555' -c 'Test campus' -y 'Chamilo' -x 'https://chamilo.org'
- cd ../.. - cd ../..

@ -1373,9 +1373,9 @@ if ($is_allowed_to_edit ||
$user_id = api_get_user_id(); $user_id = api_get_user_id();
// Create the template_thumbnails folder in the upload folder (if needed) // Create the template_thumbnails folder in the upload folder (if needed)
if (!is_dir(api_get_path(SYS_PATH).'courses/'.$courseInfo['directory'].'/upload/template_thumbnails/')) { if (!is_dir(api_get_path(SYS_COURSE_PATH).$courseInfo['directory'].'/upload/template_thumbnails/')) {
@mkdir( @mkdir(
api_get_path(SYS_PATH).'courses/'.$courseInfo['directory'].'/upload/template_thumbnails/', api_get_path(SYS_COURSE_PATH).$courseInfo['directory'].'/upload/template_thumbnails/',
api_get_permissions_for_new_directories() api_get_permissions_for_new_directories()
); );
} }
@ -1392,7 +1392,7 @@ if ($is_allowed_to_edit ||
); );
// Upload dir // Upload dir
$upload_dir = api_get_path(SYS_PATH).'courses/'.$courseInfo['directory'].'/upload/template_thumbnails/'; $upload_dir = api_get_path(SYS_COURSE_PATH).$courseInfo['directory'].'/upload/template_thumbnails/';
// Resize image to max default and end upload // Resize image to max default and end upload
$temp = new Image($_FILES['template_image']['tmp_name']); $temp = new Image($_FILES['template_image']['tmp_name']);

@ -2406,7 +2406,7 @@ class DocumentManager
$orig_course_info_path = $origin_course_info_path; $orig_course_info_path = $origin_course_info_path;
} }
} else { } else {
$orig_course_path = api_get_path(SYS_PATH).'courses/'.$orig_course_info['path'] . '/'; $orig_course_path = api_get_path(SYS_COURSE_PATH).$orig_course_info['path'] . '/';
$orig_course_info_path = $orig_course_info['path']; $orig_course_info_path = $orig_course_info['path'];
} }

@ -867,6 +867,7 @@ class GroupPortalManager
// User-reserved directory where photos have to be placed. // User-reserved directory where photos have to be placed.
$path_info = self::get_group_picture_path_by_id($group_id, 'system', true); $path_info = self::get_group_picture_path_by_id($group_id, 'system', true);
$path = $path_info['dir']; $path = $path_info['dir'];
// If this directory does not exist - we create it. // If this directory does not exist - we create it.
if (!file_exists($path)) { if (!file_exists($path)) {
@ -984,14 +985,14 @@ class GroupPortalManager
if (api_get_setting('split_users_upload_directory') === 'true') { if (api_get_setting('split_users_upload_directory') === 'true') {
if (!empty($picture_filename)) { if (!empty($picture_filename)) {
$dir = $base.'upload/users/groups/'.substr($picture_filename, 0, 1).'/'.$id.'/'; $dir = $base.'upload/groups/'.substr($picture_filename, 0, 1).'/'.$id.'/';
} elseif ($preview) { } elseif ($preview) {
$dir = $base.'upload/users/groups/'.substr((string) $id, 0, 1).'/'.$id.'/'; $dir = $base.'upload/groups/'.substr((string) $id, 0, 1).'/'.$id.'/';
} else { } else {
$dir = $base.'upload/users/groups/'.$id.'/'; $dir = $base.'upload/groups/'.$id.'/';
} }
} else { } else {
$dir = $base.'upload/users/groups/'.$id.'/'; $dir = $base.'upload/groups/'.$id.'/';
} }
if (empty($picture_filename) && $anonymous) { if (empty($picture_filename) && $anonymous) {
@ -1160,8 +1161,8 @@ class GroupPortalManager
/** /**
* Shows the left column of the group page * Shows the left column of the group page
* @param int group id * @param int $group_id
* @param int user id * @param int $user_id
* *
*/ */
public static function show_group_column_information($group_id, $user_id, $show = '') public static function show_group_column_information($group_id, $user_id, $show = '')
@ -1252,7 +1253,8 @@ class GroupPortalManager
$table_message = Database::get_main_table(TABLE_MESSAGE); $table_message = Database::get_main_table(TABLE_MESSAGE);
$topic_id = intval($topic_id); $topic_id = intval($topic_id);
$group_id = intval($group_id); $group_id = intval($group_id);
$sql = "UPDATE $table_message SET msg_status=3 WHERE group_id = $group_id AND (id = '$topic_id' OR parent_id = $topic_id) "; $sql = "UPDATE $table_message SET msg_status=3
WHERE group_id = $group_id AND (id = '$topic_id' OR parent_id = $topic_id) ";
Database::query($sql); Database::query($sql);
} }
@ -1291,23 +1293,34 @@ class GroupPortalManager
/** /**
* @param FormValidator $form * @param FormValidator $form
* @param array * @param array
*
* @return FormValidator
*/ */
public static function setGroupForm($form, $groupData = array()) public static function setGroupForm($form, $groupData = array())
{ {
// Name // Name
$form->addElement('text', 'name', get_lang('Name'), array('class'=>'span5', 'maxlength'=>120)); $form->addElement('text', 'name', get_lang('Name'), array('maxlength'=>120));
$form->applyFilter('name', 'html_filter'); $form->applyFilter('name', 'html_filter');
$form->applyFilter('name', 'trim'); $form->applyFilter('name', 'trim');
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
// Description // Description
$form->addElement('textarea', 'description', get_lang('Description'), array('class'=>'span5', 'cols'=>58, 'onKeyDown' => "textarea_maxlength()", 'onKeyUp' => "textarea_maxlength()")); $form->addElement(
'textarea',
'description',
get_lang('Description'),
array(
'cols' => 58,
'onKeyDown' => "textarea_maxlength()",
'onKeyUp' => "textarea_maxlength()",
)
);
$form->applyFilter('description', 'html_filter'); $form->applyFilter('description', 'html_filter');
$form->applyFilter('description', 'trim'); $form->applyFilter('description', 'trim');
$form->addRule('name', '', 'maxlength',255); $form->addRule('name', '', 'maxlength', 255);
// Url // Url
$form->addElement('text', 'url', get_lang('URL'), array('class'=>'span5')); $form->addElement('text', 'url', 'URL');
$form->applyFilter('url', 'html_filter'); $form->applyFilter('url', 'html_filter');
$form->applyFilter('url', 'trim'); $form->applyFilter('url', 'trim');
@ -1335,6 +1348,7 @@ class GroupPortalManager
// Set default values // Set default values
$form->setDefaults($groupData); $form->setDefaults($groupData);
} }
return $form; return $form;
} }

@ -1151,7 +1151,7 @@ function api_html_entity_decode($string, $quote_style = ENT_COMPAT, $encoding =
* @param string $from_encoding (optional) The encoding that $string is being converted from. If it is omited, the platform character set is assumed. * @param string $from_encoding (optional) The encoding that $string is being converted from. If it is omited, the platform character set is assumed.
* @return string Returns the converted string. * @return string Returns the converted string.
*/ */
function api_xml_http_response_encode($string, $from_encoding = null) { function api_xml_http_response_encode($string, $from_encoding = 'UTF8') {
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
if (empty($from_encoding)) { if (empty($from_encoding)) {
$from_encoding = _api_mb_internal_encoding(); $from_encoding = _api_mb_internal_encoding();

@ -87,7 +87,7 @@ class document_processor extends search_processor {
$name = ''; $name = '';
if ($row = Database::fetch_array($dk_result)) { if ($row = Database::fetch_array($dk_result)) {
$name = $row['title']; $name = $row['title'];
$url = api_get_path(WEB_PATH) . 'courses/%s/document%s'; $url = api_get_path(WEB_COURSE_PATH).'%s/document%s';
$url = sprintf($url, $course_path, $row['path']); $url = sprintf($url, $course_path, $row['path']);
// Get the image path // Get the image path
$icon = choose_image(basename($row['path'])); $icon = choose_image(basename($row['path']));

@ -697,7 +697,7 @@ class Statistics
while ($obj = Database::fetch_object($res)) { while ($obj = Database::fetch_object($res)) {
$courseInfo = api_get_course_info_by_id($obj->c_id); $courseInfo = api_get_course_info_by_id($obj->c_id);
$course = array (); $course = array ();
$course[]= '<a href="'.api_get_path(WEB_PATH).'courses/'.$courseInfo['code'].'">'.$courseInfo['code'].' <a>'; $course[]= '<a href="'.api_get_path(WEB_COURSE_PATH).$courseInfo['code'].'">'.$courseInfo['code'].' <a>';
// Allow sort by date hiding the numerical date // Allow sort by date hiding the numerical date
$course[] = '<span style="display:none;">'.$obj->access_date.'</span>'.api_convert_and_format_date($obj->access_date); $course[] = '<span style="display:none;">'.$obj->access_date.'</span>'.api_convert_and_format_date($obj->access_date);
$courses[] = $course; $courses[] = $course;

@ -289,7 +289,7 @@ function write_courses_htaccess_file($url_append)
{ {
$content = file_get_contents(dirname(__FILE__).'/'.COURSES_HTACCESS_FILENAME); $content = file_get_contents(dirname(__FILE__).'/'.COURSES_HTACCESS_FILENAME);
$content = str_replace('{CHAMILO_URL_APPEND_PATH}', $url_append, $content); $content = str_replace('{CHAMILO_URL_APPEND_PATH}', $url_append, $content);
$fp = @fopen(api_get_path(SYS_PATH).'courses/.htaccess', 'w'); $fp = @fopen(api_get_path(SYS_COURSE_PATH).'.htaccess', 'w');
if ($fp) { if ($fp) {
fwrite($fp, $content); fwrite($fp, $content);
return fclose($fp); return fclose($fp);

@ -245,7 +245,7 @@ EOT;
$details = implode(' - ', $details); $details = implode(' - ', $details);
$title = $course['title']; $title = $course['title'];
$href = api_get_path(WEB_PATH) . 'courses/' . $course['code'] .'/index.php'; $href = api_get_path(WEB_COURSE_PATH).$course['code'] .'/index.php';
echo '<tr><td><b><a href="' . $href . '">' . "$title</a></b><br/>$details</td><td>"; echo '<tr><td><b><a href="' . $href . '">' . "$title</a></b><br/>$details</td><td>";
if (!api_is_anonymous()) if (!api_is_anonymous())
{ {

@ -18,8 +18,10 @@ User-Agent: *
# Directories # Directories
Disallow: /app/cache/ Disallow: /app/cache/
Disallow: /app/logs/ Disallow: /app/logs/
Disallow: /app/courses/
Disallow: /courses/ Disallow: /courses/
Disallow: /documentation/ Disallow: /documentation/
Disallow: /app/home/
Disallow: /home/ Disallow: /home/
Disallow: /main/ Disallow: /main/
Disallow: /plugin/ Disallow: /plugin/

@ -4,13 +4,13 @@
namespace Chamilo\CoreBundle\Entity; namespace Chamilo\CoreBundle\Entity;
//use Chamilo\CourseBundle\Entity\CTool; //use Chamilo\CourseBundle\Entity\CTool;
use Chamilo\UserBundle\Entity\User;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria; use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Gedmo\Mapping\Annotation as Gedmo; use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Chamilo\UserBundle\Entity\User; use Symfony\Component\Validator\Constraints as Assert;
/** /**
* Class Course * Class Course
@ -947,6 +947,7 @@ class Course
* Set targetCourseCode * Set targetCourseCode
* *
* @param string $targetCourseCode * @param string $targetCourseCode
*
* @return Course * @return Course
*/ */
public function setTargetCourseCode($targetCourseCode) public function setTargetCourseCode($targetCourseCode)
@ -970,6 +971,7 @@ class Course
* Set subscribe * Set subscribe
* *
* @param boolean $subscribe * @param boolean $subscribe
*
* @return Course * @return Course
*/ */
public function setSubscribe($subscribe) public function setSubscribe($subscribe)
@ -993,6 +995,7 @@ class Course
* Set unsubscribe * Set unsubscribe
* *
* @param boolean $unsubscribe * @param boolean $unsubscribe
*
* @return Course * @return Course
*/ */
public function setUnsubscribe($unsubscribe) public function setUnsubscribe($unsubscribe)
@ -1016,6 +1019,7 @@ class Course
* Set registrationCode * Set registrationCode
* *
* @param string $registrationCode * @param string $registrationCode
*
* @return Course * @return Course
*/ */
public function setRegistrationCode($registrationCode) public function setRegistrationCode($registrationCode)
@ -1039,6 +1043,7 @@ class Course
* Set legal * Set legal
* *
* @param string $legal * @param string $legal
*
* @return Course * @return Course
*/ */
public function setLegal($legal) public function setLegal($legal)
@ -1062,6 +1067,7 @@ class Course
* Set activateLegal * Set activateLegal
* *
* @param integer $activateLegal * @param integer $activateLegal
*
* @return Course * @return Course
*/ */
public function setActivateLegal($activateLegal) public function setActivateLegal($activateLegal)
@ -1085,6 +1091,7 @@ class Course
* Set courseTypeId * Set courseTypeId
* *
* @param integer $courseTypeId * @param integer $courseTypeId
*
* @return Course * @return Course
*/ */
public function setCourseTypeId($courseTypeId) public function setCourseTypeId($courseTypeId)
@ -1109,7 +1116,7 @@ class Course
*/ */
public function getAbsoluteSysCoursePath() public function getAbsoluteSysCoursePath()
{ {
return realpath(__DIR__.'/../../../data/courses/'.$this->getDirectory()).'/'; return realpath(__DIR__.'/../../../app/courses/'.$this->getDirectory()).'/';
} }
/** /**

Loading…
Cancel
Save