Fix course paths.

1.10.x
Julio Montoya 10 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. 40
      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
app/courses/*
courses/*
!courses/index.html
# Home
app/home/*
home/*
# User images

@ -40,7 +40,7 @@ before_script:
- cp chamilo-cli-install/chamilo-cli-installer.php main/install/
- 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
- 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/
- 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 ../..

@ -1373,9 +1373,9 @@ if ($is_allowed_to_edit ||
$user_id = api_get_user_id();
// 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(
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()
);
}
@ -1392,7 +1392,7 @@ if ($is_allowed_to_edit ||
);
// 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
$temp = new Image($_FILES['template_image']['tmp_name']);

@ -2406,7 +2406,7 @@ class DocumentManager
$orig_course_info_path = $origin_course_info_path;
}
} 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'];
}

@ -867,6 +867,7 @@ class GroupPortalManager
// User-reserved directory where photos have to be placed.
$path_info = self::get_group_picture_path_by_id($group_id, 'system', true);
$path = $path_info['dir'];
// If this directory does not exist - we create it.
if (!file_exists($path)) {
@ -984,14 +985,14 @@ class GroupPortalManager
if (api_get_setting('split_users_upload_directory') === 'true') {
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) {
$dir = $base.'upload/users/groups/'.substr((string) $id, 0, 1).'/'.$id.'/';
$dir = $base.'upload/groups/'.substr((string) $id, 0, 1).'/'.$id.'/';
} else {
$dir = $base.'upload/users/groups/'.$id.'/';
$dir = $base.'upload/groups/'.$id.'/';
}
} else {
$dir = $base.'upload/users/groups/'.$id.'/';
$dir = $base.'upload/groups/'.$id.'/';
}
if (empty($picture_filename) && $anonymous) {
@ -1160,8 +1161,8 @@ class GroupPortalManager
/**
* Shows the left column of the group page
* @param int group id
* @param int user id
* @param int $group_id
* @param int $user_id
*
*/
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);
$topic_id = intval($topic_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);
}
@ -1291,23 +1293,34 @@ class GroupPortalManager
/**
* @param FormValidator $form
* @param array
*
* @return FormValidator
*/
public static function setGroupForm($form, $groupData = array())
{
// 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', 'trim');
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
// 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', 'trim');
$form->addRule('name', '', 'maxlength',255);
$form->addRule('name', '', 'maxlength', 255);
// Url
$form->addElement('text', 'url', get_lang('URL'), array('class'=>'span5'));
$form->addElement('text', 'url', 'URL');
$form->applyFilter('url', 'html_filter');
$form->applyFilter('url', 'trim');
@ -1324,8 +1337,8 @@ class GroupPortalManager
// Status
$status = array();
$status[GROUP_PERMISSION_OPEN] = get_lang('Open');
$status[GROUP_PERMISSION_CLOSED] = get_lang('Closed');
$status[GROUP_PERMISSION_OPEN] = get_lang('Open');
$status[GROUP_PERMISSION_CLOSED] = get_lang('Closed');
$form->addElement('select', 'visibility', get_lang('GroupPermissions'), $status, array());
if (!empty($groupData)) {
@ -1335,6 +1348,7 @@ class GroupPortalManager
// Set default values
$form->setDefaults($groupData);
}
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.
* @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 (empty($from_encoding)) {
$from_encoding = _api_mb_internal_encoding();

@ -87,7 +87,7 @@ class document_processor extends search_processor {
$name = '';
if ($row = Database::fetch_array($dk_result)) {
$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']);
// Get the image path
$icon = choose_image(basename($row['path']));

@ -697,7 +697,7 @@ class Statistics
while ($obj = Database::fetch_object($res)) {
$courseInfo = api_get_course_info_by_id($obj->c_id);
$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
$course[] = '<span style="display:none;">'.$obj->access_date.'</span>'.api_convert_and_format_date($obj->access_date);
$courses[] = $course;

@ -289,7 +289,7 @@ function write_courses_htaccess_file($url_append)
{
$content = file_get_contents(dirname(__FILE__).'/'.COURSES_HTACCESS_FILENAME);
$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) {
fwrite($fp, $content);
return fclose($fp);

@ -245,7 +245,7 @@ EOT;
$details = implode(' - ', $details);
$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>";
if (!api_is_anonymous())
{

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

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

Loading…
Cancel
Save