Removing use of the api_get_setting('use_document_title') setting see #3781

skala
Julio Montoya 13 years ago
parent 7c02aa60fa
commit 3f7c75f67a
  1. 3
      documentation/changelog.html
  2. 3
      main/admin/settings.php
  3. 6
      main/coursecopy/classes/Document.class.php
  4. 6
      main/coursecopy/classes/ScormDocument.class.php
  5. 121
      main/document/create_document.php
  6. 50
      main/document/document.inc.php
  7. 6
      main/document/document.php
  8. 6
      main/document/document_lite.php
  9. 8
      main/document/edit_document.php
  10. 6
      main/document/upload.php
  11. 9
      main/inc/course_document.inc.php
  12. 5
      main/install/db_main.sql
  13. 3
      main/install/install.lib.php
  14. 5
      main/install/migrate-db-1.8.8-1.9.0-pre.sql
  15. 1
      main/newscorm/lp_add_item.php
  16. 7
      main/upload/upload.document.php

@ -198,6 +198,9 @@ This version of Chamilo only includes new features:
</ul>
<h3>Known issues</h3>
<ul>
<li>
<b>Document title:</b> The option to NOT use a document title different than the filename in the documents tool has been removed. This means that if this setting was not set to the default option in your Chamilo option or if you have a very old installation that you have been upgrading over the years, you might experience problems accessing the documents. In this case, we recommend contacting an official provider of Chamilo to take this migration in charge.
</li>
</ul>
<h3>Third-Party Libraries additions/updates</h3>

@ -43,8 +43,7 @@ api_protect_admin_script();
// Settings to avoid
$settings_to_avoid = array(
'gradebook_enable' => 'false',
'use_document_title' => 'true',
'gradebook_enable' => 'false',
'example_material_course_creation' => 'true' // ON by default - now we have this option when we create a course
);

@ -49,10 +49,8 @@ class Document extends Resource
{
parent::show();
echo preg_replace('@^document@', '', $this->path);
if (!empty($this->title) && (api_get_setting('use_document_title') == 'true'))
{
if (strpos($this->path, $this->title) === false)
{
if (!empty($this->title)) {
if (strpos($this->path, $this->title) === false) {
echo " - ".$this->title;
}
}

@ -39,10 +39,8 @@ class ScormDocument extends Resource
parent::show();
$path = preg_replace('@^scorm/@', '', $this->path);
echo $path;
if (!empty($this->title) && (api_get_setting('use_document_title') == 'true'))
{
if (strpos($path, $this->title) === false)
{
if (!empty($this->title)) {
if (strpos($path, $this->title) === false) {
echo " - ".$this->title;
}
}

@ -58,8 +58,7 @@ function InnerDialogLoaded() {
};
var temp=false;
var temp2=false;
var use_document_title='.api_get_setting('use_document_title').';
var temp2=false;
var load_default_template = '. ((isset($_POST['submit']) || empty($_SERVER['QUERY_STRING'])) ? 'false' : 'true' ) .';
function launch_templates() {
@ -125,10 +124,7 @@ function InnerDialogLoaded() {
// comment see FS#3335
// if(document.getElementById(\'title_edited\').value == "false")
// {
// document.getElementById(\'filename\').value = bestandsnaamNieuw;
// if(use_document_title){
// document.getElementById(\'title\').value = bestandsnaamNieuw;
// }
// document.getElementById(\'filename\').value = bestandsnaamNieuw;
// }
}
@ -349,9 +345,15 @@ function document_exists($filename) {
$filename_template = str_replace('{element}', '{element}', $renderer->_elementTemplate); // TODO: What is the point of this statement?
$renderer->setElementTemplate($filename_template, 'filename');
// Initialize group array
$group = array();
$group[] = $form->createElement('text','title',get_lang('Title'),'class="input_titles" id="document_title"');
// Added by Ivan Tcholakov, 10-OCT-2009.
$form->addElement('hidden', 'filename', '', array('id' => 'filename'));
/*
// If allowed, add element for document title
if (api_get_setting('use_document_title') == 'true') {
$group[]=$form->createElement('text','title',get_lang('Title'),'class="input_titles" id="document_title"');
@ -365,6 +367,7 @@ if (api_get_setting('use_document_title') == 'true') {
// Added by Ivan Tcholakov, 10-OCT-2009.
$form->addElement('hidden', 'title', '', array('id' => 'title'));
}
*/
// Show read-only box only in groups
if (!empty($_SESSION['_gid'])) {
@ -375,25 +378,16 @@ if (!empty($_SESSION['_gid'])) {
if ($is_certificate_mode)
$form->addGroup($group, 'filename_group', get_lang('CertificateName') ,'&nbsp;&nbsp;&nbsp;', false);
else
$form->addGroup($group, 'filename_group', api_get_setting('use_document_title') == 'true' ? get_lang('Title') : get_lang('FileName') ,'&nbsp;&nbsp;&nbsp;', false);
$form->addGroup($group, 'filename_group', get_lang('Title'), false);
$form->addRule('filename_group', get_lang('ThisFieldIsRequired'), 'required');
if (api_get_setting('use_document_title') == 'true') {
$form->addGroupRule('filename_group', array(
'title' => array(
array(get_lang('ThisFieldIsRequired'), 'required'),
array(get_lang('FileExists'),'callback', 'document_exists')
)
));
} else {
$form->addGroupRule('filename_group', array(
'filename' => array(
array(get_lang('ThisFieldIsRequired'), 'required'),
array(get_lang('FileExists'),'callback', 'document_exists')
)
));
}
$form->addGroupRule('filename_group', array(
'title' => array(
array(get_lang('ThisFieldIsRequired'), 'required'),
array(get_lang('FileExists'),'callback', 'document_exists')
)
));
$current_session_id = api_get_session_id();
@ -415,45 +409,39 @@ if (!$is_certificate_mode && !is_my_shared_folder($_user['user_id'], $dir, $curr
// Following two conditions copied from document.inc.php::build_directory_selector()
$folder_titles = array();
if (api_get_setting('use_document_title') == 'true') {
if (is_array($folders)) {
$escaped_folders = array();
foreach ($folders as $key => & $val) {
//Hide some folders
if ($val=='/HotPotatoes_files' || $val=='/certificates' || basename($val)=='css'){
continue;
}
//Admin setting for Hide/Show the folders of all users
if (api_get_setting('show_users_folders') == 'false' && (strstr($val, '/shared_folder') || strstr($val, 'shared_folder_session_'))){
continue;
}
//Admin setting for Hide/Show Default folders to all users
if (api_get_setting('show_default_folders') == 'false' && ($val=='/images' || $val=='/flash' || $val=='/audio' || $val=='/video' || strstr($val, '/images/gallery') || $val=='/video/flv')){
continue;
}
//Admin setting for Hide/Show chat history folder
if (api_get_setting('show_chat_folder') == 'false' && $val=='/chat_files'){
continue;
}
$escaped_folders[$key] = Database::escape_string($val);
}
$folder_sql = implode("','", $escaped_folders);
$sql = "SELECT * FROM $doc_table WHERE c_id = $course_id AND filetype='folder' AND path IN ('".$folder_sql."')";
$res = Database::query($sql);
$folder_titles = array();
while ($obj = Database::fetch_object($res)) {
$folder_titles[$obj->path] = $obj->title;
}
}
} else {
if (is_array($folders)) {
foreach ($folders as & $folder) {
$folder_titles[$folder] = basename($folder);
}
}
}
if (is_array($folders)) {
$escaped_folders = array();
foreach ($folders as $key => & $val) {
//Hide some folders
if ($val=='/HotPotatoes_files' || $val=='/certificates' || basename($val)=='css'){
continue;
}
//Admin setting for Hide/Show the folders of all users
if (api_get_setting('show_users_folders') == 'false' && (strstr($val, '/shared_folder') || strstr($val, 'shared_folder_session_'))){
continue;
}
//Admin setting for Hide/Show Default folders to all users
if (api_get_setting('show_default_folders') == 'false' && ($val=='/images' || $val=='/flash' || $val=='/audio' || $val=='/video' || strstr($val, '/images/gallery') || $val=='/video/flv')){
continue;
}
//Admin setting for Hide/Show chat history folder
if (api_get_setting('show_chat_folder') == 'false' && $val=='/chat_files'){
continue;
}
$escaped_folders[$key] = Database::escape_string($val);
}
$folder_sql = implode("','", $escaped_folders);
$sql = "SELECT * FROM $doc_table WHERE c_id = $course_id AND filetype='folder' AND path IN ('".$folder_sql."')";
$res = Database::query($sql);
$folder_titles = array();
while ($obj = Database::fetch_object($res)) {
$folder_titles[$obj->path] = $obj->title;
}
}
if (empty($group_dir)) {
$parent_select -> addOption(get_lang('HomeDirectory'), '/');
@ -527,18 +515,11 @@ if ($form->validate()) {
if ($dir[strlen($dir) - 1] != '/') {
$dir .= '/';
}
if (api_get_setting('use_document_title') != 'true') {
$values['title'] = $values['filename'];
} else {
$values['filename'] = $values['title'];
}
$values['title'] = $values['filename'];
$values['filename'] = addslashes(trim($values['filename']));
$values['filename'] = Security::remove_XSS($values['filename']);
$values['filename'] = replace_dangerous_char($values['filename']);
$values['filename'] = disable_dangerous_file($values['filename']);
$values['filename'] = disable_dangerous_file($values['filename']);
$filename = $values['filename'];
$title = $values['title'];

@ -20,28 +20,22 @@ function build_directory_selector($folders, $document_id, $group_dir = '', $chan
$doc_table = Database::get_course_table(TABLE_DOCUMENT);
$course_id = api_get_course_int_id();
$folder_titles = array();
if (api_get_setting('use_document_title') == 'true') {
if (is_array($folders)) {
$escaped_folders = array();
foreach ($folders as $key => & $val) {
$escaped_folders[$key] = Database::escape_string($val);
}
$folder_sql = implode("','", $escaped_folders);
$sql = "SELECT * FROM $doc_table WHERE filetype = 'folder' AND c_id = $course_id AND path IN ('".$folder_sql."')";
$res = Database::query($sql);
$folder_titles = array();
while ($obj = Database::fetch_object($res)) {
$folder_titles[$obj->path] = $obj->title;
}
if (is_array($folders)) {
$escaped_folders = array();
foreach ($folders as $key => & $val) {
$escaped_folders[$key] = Database::escape_string($val);
}
} else {
if (is_array($folders)) {
foreach ($folders as & $folder) {
$folder_titles[$folder] = basename($folder);
}
$folder_sql = implode("','", $escaped_folders);
$sql = "SELECT * FROM $doc_table WHERE filetype = 'folder' AND c_id = $course_id AND path IN ('".$folder_sql."')";
$res = Database::query($sql);
$folder_titles = array();
while ($obj = Database::fetch_object($res)) {
$folder_titles[$obj->path] = $obj->title;
}
}
$form = new FormValidator('selector', 'GET', api_get_self().'?'.api_get_cidreq());
$form->addElement('hidden', 'cidReq', api_get_course_id());
@ -111,10 +105,9 @@ function create_document_link($document_data, $show_as_icon = false, $counter =
}
$course_info = api_get_course_info();
$www = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/document';
$use_document_title = api_get_setting('use_document_title');
// Get the title or the basename depending on what we're using
if ($use_document_title == 'true' && $document_data['title'] != '') {
if ($document_data['title'] != '') {
$title = $document_data['title'];
} else {
$title = basename($document_data['path']);
@ -683,10 +676,9 @@ function build_move_to_selector($folders, $curdirpath, $move_file, $group_dir =
// 3. inside a subfolder of the folder you want to move
if (($curdirpath != $folder) && ($folder != $move_file) && (substr($folder, 0, strlen($move_file) + 1) != $move_file.'/')) {
$path_displayed = $folder;
// If document title is used, we have to display titles instead of real paths...
if (api_get_setting('use_document_title')) {
$path_displayed = get_titles_of_path($folder);
}
// If document title is used, we have to display titles instead of real paths...
$path_displayed = get_titles_of_path($folder);
if (empty($path_displayed)) {
$path_displayed = get_lang('Untitled');
}
@ -696,10 +688,8 @@ function build_move_to_selector($folders, $curdirpath, $move_file, $group_dir =
}
} else {
foreach ($folders as $folder) {
if (($curdirpath != $folder) && ($folder != $move_file) && (substr($folder, 0, strlen($move_file) + 1) != $move_file.'/')) { // Cannot copy dir into his own subdir
if (api_get_setting('use_document_title')) {
$path_displayed = get_titles_of_path($folder);
}
if (($curdirpath != $folder) && ($folder != $move_file) && (substr($folder, 0, strlen($move_file) + 1) != $move_file.'/')) { // Cannot copy dir into his own subdir
$path_displayed = get_titles_of_path($folder);
$display_folder = substr($path_displayed,strlen($group_dir));
$display_folder = ($display_folder == '') ? get_lang('Documents') : $display_folder;
$form .= '<option value="'.$folder.'">'.$display_folder.'</option>';

@ -921,10 +921,6 @@ $table_footer = '';
$total_size = 0;
if (isset($docs_and_folders) && is_array($docs_and_folders)) {
// Do we need the title field for the document name or not?
// We get the setting here, so we only have to do it once
$use_document_title = api_get_setting('use_document_title');
// Create a sortable table with our data
$sortable_data = array();
@ -946,7 +942,7 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) {
$size = $document_data['filetype'] == 'folder' ? get_total_folder_size($document_data['path'], $is_allowed_to_edit) : $document_data['size'];
// Get the title or the basename depending on what we're using
if ($use_document_title == 'true' && $document_data['title'] != '') {
if ($document_data['title'] != '') {
$document_name = $document_data['title'];
} else {
$document_name = basename($document_data['path']);

@ -717,10 +717,6 @@ $table_footer = '';
$total_size = 0;
if (isset($docs_and_folders) && is_array($docs_and_folders)) {
// Do we need the title field for the document name or not?
// We get the setting here, so we only have to do it once
$use_document_title = api_get_setting('use_document_title');
// Create a sortable table with our data
$sortable_data = array();
@ -744,7 +740,7 @@ if (isset($docs_and_folders) && is_array($docs_and_folders)) {
$row['size'] = format_file_size($size);
// Get the title or the basename depending on what we're using
if ($use_document_title == 'true' && $document_data['title'] != '') {
if ($document_data['title'] != '') {
$document_name = $document_data['title'];
} else {
$document_name = basename($document_data['path']);

@ -153,8 +153,6 @@ if ($is_certificate_mode) {
}
$is_allowed_to_edit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights']|| is_my_shared_folder(api_get_user_id(), $dir, $current_session_id);
$use_document_title = api_get_setting('use_document_title') == 'true';
$noPHP_SELF = true;
/* Other initialization code */
@ -371,11 +369,7 @@ if ($owner_id == api_get_user_id() || api_is_platform_admin() || $is_allowed_to_
$form->add_textfield('title', get_lang('Title'));
if ($use_document_title) {
$defaults['title'] = $document_data['title'];
} else {
$form->addElement('hidden', 'renameTo');
}
$defaults['title'] = $document_data['title'];
$form->addElement('hidden', 'formSent');
$defaults['formSent'] = 1;

@ -228,10 +228,8 @@ $label = get_lang('MaxFileSize').': '.ini_get('upload_max_filesize').'<br/>'.get
$form->addElement('file', 'file', array(get_lang('File'), $label), 'id="user_upload" size="45"');
if (api_get_setting('use_document_title') == 'true') {
$form->addElement('text', 'title', get_lang('Title'), array('size' => '20', 'style' => 'width:300px', 'id' => 'title_file'));
$form->addElement('textarea', 'comment', get_lang('Comment'), 'wrap="virtual" style="width:300px;"');
}
$form->addElement('text', 'title', get_lang('Title'), array('size' => '20', 'style' => 'width:300px', 'id' => 'title_file'));
$form->addElement('textarea', 'comment', get_lang('Comment'), 'wrap="virtual" style="width:300px;"');
$advanced = '<a href="javascript://" onclick=" return advanced_parameters()"><span id="img_plus_and_minus"><div style="vertical-align:top;" ><img style="vertical-align:middle;" src="../img/div_show.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'</div></span></a>';
// Advanced parameters

@ -176,10 +176,7 @@ if ($is_allowed_to_edit) { // TEACHER ONLY
$docs_and_folders = getlist ($base_work_dir.'/');
if ($docs_and_folders) {
//do we need the title field for the document name or not?
//we get the setting here, so we only have to do it once
$use_document_title = api_get_setting('use_document_title');
if ($docs_and_folders) {
//create a sortable table with our data
$sortable_data = array();
while (list ($key, $id) = each($docs_and_folders)) {
@ -196,8 +193,8 @@ if ($docs_and_folders) {
//size (or total size of a directory)
$size = $id['filetype'] == 'folder' ? get_total_folder_size($id['path'], $is_allowed_to_edit) : $id[size];
//get the title or the basename depending on what we're using
if ($use_document_title == 'true' AND $id['title'] != '') {
$document_name=$id['title'];
if ($id['title'] != '') {
$document_name = $id['title'];
} else {
$document_name = basename($id['path']);
}

@ -626,7 +626,6 @@ VALUES
('allow_personal_agenda',NULL,'radio','User','true','AllowPersonalAgendaTitle','AllowPersonalAgendaComment',NULL,NULL, 0),
('display_coursecode_in_courselist',NULL,'radio','Platform','false','DisplayCourseCodeInCourselistTitle','DisplayCourseCodeInCourselistComment',NULL,NULL, 0),
('display_teacher_in_courselist',NULL,'radio','Platform','true','DisplayTeacherInCourselistTitle','DisplayTeacherInCourselistComment',NULL,NULL, 0),
('use_document_title',NULL,'radio','Tools','true','UseDocumentTitleTitle','UseDocumentTitleComment',NULL,NULL, 0),
('permanently_remove_deleted_files',NULL,'radio','Tools','false','PermanentlyRemoveFilesTitle','PermanentlyRemoveFilesComment',NULL,NULL, 0),
('dropbox_allow_overwrite',NULL,'radio','Tools','true','DropboxAllowOverwriteTitle','DropboxAllowOverwriteComment',NULL,NULL, 0),
('dropbox_max_filesize',NULL,'textfield','Tools','100000000','DropboxMaxFilesizeTitle','DropboxMaxFilesizeComment',NULL,NULL, 0),
@ -863,7 +862,7 @@ VALUES
('gradebook_ranking_8', 'ranking', 'gradebook_ranking', 'Gradebook', '', '', '', NULL, NULL, 1),
('gradebook_ranking_9', 'ranking', 'gradebook_ranking', 'Gradebook', '', '', '', NULL, NULL, 1),
('gradebook_ranking_10', 'ranking', 'gradebook_ranking', 'Gradebook', '', '', '', NULL, NULL, 1),
('chamilo_database_version',NULL,'textfield',NULL, '1.9.0.17631','DatabaseVersion','', NULL, NULL, 0);
('chamilo_database_version',NULL,'textfield',NULL, '1.9.0.17705','DatabaseVersion','', NULL, NULL, 0);
/*
('show_tabs', 'custom_tab_1', 'checkbox', 'Platform', 'true', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom1', 1),
@ -943,8 +942,6 @@ VALUES
('display_coursecode_in_courselist','false','No'),
('display_teacher_in_courselist','true','Yes'),
('display_teacher_in_courselist','false','No'),
('use_document_title','true','Yes'),
('use_document_title','false','No'),
('permanently_remove_deleted_files','true','YesWillDeletePermanently'),
('permanently_remove_deleted_files','false','NoWillDeletePermanently'),
('dropbox_allow_overwrite','true','Yes'),

@ -2016,8 +2016,7 @@ function get_countries_list_from_array($combo = false) {
*/
function locking_settings() {
$access_url_locked_settings = array(
'server_type',
'use_document_title',
'server_type',
'permanently_remove_deleted_files',
'account_valid_duration',
'service_visio',

@ -191,9 +191,12 @@ INSERT INTO settings_options(variable,value,display_text) VALUES ('page_after_lo
ALTER TABLE settings_current ADD COLUMN access_url_locked INTEGER NOT NULL DEFAULT 0;
-- Removing use_document_title
DELETE FROM settings_current WHERE variable = 'use_document_title';
DELETE FROM settings_options WHERE variable = 'use_document_title';
-- Do not move this query
UPDATE settings_current SET selected_value = '1.9.0.17631' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.9.0.17705' WHERE variable = 'chamilo_database_version';
-- xxSTATSxx
ALTER TABLE track_e_exercices ADD COLUMN questions_to_check TEXT NOT NULL DEFAULT '';

@ -27,7 +27,6 @@ $htmlHeadXtra[] = '
<script type="text/javascript">
var temp = false;
var use_document_title='.api_get_setting('use_document_title').';
var load_default_template = '. ((isset($_POST['submit']) || empty($_SERVER['QUERY_STRING'])) ? 'false' : 'true' ) .';
function FCKeditor_OnComplete( editorInstance ) {

@ -157,17 +157,10 @@ else { //give them a link to create a directory
<input type="file" name="user_upload"/>
</td>
</tr>
<?php
if(api_get_setting('use_document_title')=='true')
{
?>
<tr>
<td><?php echo get_lang('Title');?></td>
<td><input type="text" size="20" name="title" style="width:300px;"></td>
</tr>
<?php
}
?>
<tr>
<td valign="top"><?php echo get_lang('Comment');?></td>
<td><textarea rows="3" cols="20" name="comment" wrap="virtual" style="width:300px;"></textarea></td>

Loading…
Cancel
Save