@ -19,10 +19,10 @@ use Symfony\Component\Filesystem\Filesystem;
* This function allows easy activating and inactivating of regions
* This function allows easy activating and inactivating of regions
* @author Julio Montoya < gugli100 @ gmail . com > Beeznest 2012
* @author Julio Montoya < gugli100 @ gmail . com > Beeznest 2012
*/
*/
function handle_r egions()
function handleR egions()
{
{
if (isset($_POST['submit_plugins'])) {
if (isset($_POST['submit_plugins'])) {
store_r egions();
storeR egions();
// Add event to the system log.
// Add event to the system log.
$user_id = api_get_user_id();
$user_id = api_get_user_id();
$category = $_GET['category'];
$category = $_GET['category'];
@ -93,7 +93,7 @@ function handle_regions()
echo '< button class = "btn btn-success" type = "submit" name = "submit_plugins" > '.get_lang('EnablePlugins').'< / button > < / form > ';
echo '< button class = "btn btn-success" type = "submit" name = "submit_plugins" > '.get_lang('EnablePlugins').'< / button > < / form > ';
}
}
function handle_e xtensions()
function handleE xtensions()
{
{
echo Display::page_subheader(get_lang('ConfigureExtensions'));
echo Display::page_subheader(get_lang('ConfigureExtensions'));
echo '< a class = "btn btn-success" href = "configure_extensions.php?display=ppt2lp" role = "button" > '.get_lang('Ppt2lp').'< / a > ';
echo '< a class = "btn btn-success" href = "configure_extensions.php?display=ppt2lp" role = "button" > '.get_lang('Ppt2lp').'< / a > ';
@ -106,12 +106,12 @@ function handle_extensions()
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University
* @author Julio Montoya < gugli100 @ gmail . com > Beeznest 2012
* @author Julio Montoya < gugli100 @ gmail . com > Beeznest 2012
*/
*/
function handle_p lugins()
function handleP lugins()
{
{
$plugin_obj = new AppPlugin();
$plugin_obj = new AppPlugin();
$token = Security::get_token();
$token = Security::get_token();
if (isset($_POST['submit_plugins'])) {
if (isset($_POST['submit_plugins'])) {
store_p lugins();
storeP lugins();
// Add event to the system log.
// Add event to the system log.
$user_id = api_get_user_id();
$user_id = api_get_user_id();
$category = $_GET['category'];
$category = $_GET['category'];
@ -222,24 +222,14 @@ function handle_plugins()
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University
* @author Julio Montoya < gugli100 @ gmail . com > , Chamilo
* @author Julio Montoya < gugli100 @ gmail . com > , Chamilo
*/
*/
function handle_s tylesheets()
function handleS tylesheets()
{
{
global $_configuration;
global $_configuration;
// Current style.
// Current style.
$currentstyle = api_get_setting('stylesheets');
$currentstyle = api_get_setting('stylesheets');
$is_style_changeable = false;
$is_style_changeable = isStyleChangeable();
if ($_configuration['access_url'] != 1) {
$style_info = api_get_settings('stylesheets', '', 1, 0);
$url_info = api_get_access_url($_configuration['access_url']);
if ($style_info[0]['access_url_changeable'] == 1 & & $url_info['active'] == 1) {
$is_style_changeable = true;
}
} else {
$is_style_changeable = true;
}
$form = new FormValidator(
$form = new FormValidator(
'stylesheet_upload',
'stylesheet_upload',
@ -250,21 +240,7 @@ function handle_stylesheets()
array('size' => '40', 'maxlength' => '40'));
array('size' => '40', 'maxlength' => '40'));
$form->addRule('name_stylesheet', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('name_stylesheet', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('file', 'new_stylesheet', get_lang('UploadNewStylesheet'));
$form->addElement('file', 'new_stylesheet', get_lang('UploadNewStylesheet'));
$allowed_file_types = array(
$allowed_file_types = getAllowedFileTypes();
'css',
'zip',
'jpeg',
'jpg',
'png',
'gif',
'ico',
'psd',
'xcf',
'svg',
'webp',
'woff',
'woff2'
);
$form->addRule('new_stylesheet', get_lang('InvalidExtension') . ' (' . implode(',', $allowed_file_types) . ')',
$form->addRule('new_stylesheet', get_lang('InvalidExtension') . ' (' . implode(',', $allowed_file_types) . ')',
'filetype', $allowed_file_types);
'filetype', $allowed_file_types);
@ -293,7 +269,7 @@ function handle_stylesheets()
$values = $form->exportValues();
$values = $form->exportValues();
$picture_element = $form->getElement('new_stylesheet');
$picture_element = $form->getElement('new_stylesheet');
$picture = $picture_element->getValue();
$picture = $picture_element->getValue();
$result = upload_s tylesheet($values, $picture);
$result = uploadS tylesheet($values, $picture);
// Add event to the system log.
// Add event to the system log.
$user_id = api_get_user_id();
$user_id = api_get_user_id();
@ -375,22 +351,11 @@ function handle_stylesheets()
if ($form_change->validate()) {
if ($form_change->validate()) {
// Submit stylesheets.
// Submit stylesheets.
if (isset($_POST['save'])) {
if (isset($_POST['save'])) {
store_s tylesheets();
storeS tylesheets();
Display::display_normal_message(get_lang('Saved'));
Display::display_normal_message(get_lang('Saved'));
}
}
if (isset($_POST['download'])) {
if (isset($_POST['download'])) {
$arch = api_get_path(SYS_ARCHIVE_PATH).$safe_style_dir.'.zip';
generateCSSDownloadLink($safe_style_dir);
$dir = api_get_path(SYS_CSS_PATH).'themes/'.$safe_style_dir;
if (is_dir($dir)) {
$zip = new PclZip($arch);
// Remove path prefix except the style name and put file on disk
$zip->create($dir, PCLZIP_OPT_REMOVE_PATH, substr($dir,0,-strlen($safe_style_dir)));
//@TODO: use more generic script to download.
$str = '< a class = "btn btn-primary btn-large" href = "' . api_get_path(WEB_CODE_PATH) . 'course_info/download.php?archive=' . str_replace(api_get_path(SYS_ARCHIVE_PATH), '', $arch) . '" > '.get_lang('ClickHereToDownloadTheFile').'< / a > ';
Display::display_normal_message($str, false);
} else {
Display::addFlash(Display::return_message(get_lang('FileNotFound'), 'warning'));
}
}
}
}
}
@ -502,15 +467,14 @@ function handle_stylesheets()
/**
/**
* Creates the folder (if needed) and uploads the stylesheet in it
* Creates the folder (if needed) and uploads the stylesheet in it
*
* @param array $values the values of the form
* @param array $values the values of the form
* @param array $picture the values of the uploaded file
* @param array $picture the values of the uploaded file
*
* @return bool
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @version May 2008
* @version May 2008
* @since Dokeos 1.8.5
* @since v 1.8.5
*/
*/
function upload_s tylesheet($values, $picture)
function uploadS tylesheet($values, $picture)
{
{
$result = false;
$result = false;
// Valid name for the stylesheet folder.
// Valid name for the stylesheet folder.
@ -535,20 +499,7 @@ function upload_stylesheet($values, $picture)
$single_directory = true;
$single_directory = true;
$invalid_files = array();
$invalid_files = array();
$allowedFiles = array(
$allowedFiles = getAllowedFileTypes();
'jpg',
'jpeg',
'png',
'gif',
'css',
'ico',
'psd',
'woff',
'woff2',
'xcf',
'svg',
'webp'
);
for ($i = 0; $i < $num_files; $i++) {
for ($i = 0; $i < $num_files; $i++) {
$file = $zip->statIndex($i);
$file = $zip->statIndex($i);
@ -632,7 +583,7 @@ function upload_stylesheet($values, $picture)
/**
/**
* Store plugin regions.
* Store plugin regions.
*/
*/
function store_r egions()
function storeR egions()
{
{
$plugin_obj = new AppPlugin();
$plugin_obj = new AppPlugin();
@ -670,7 +621,7 @@ function store_regions()
* This function allows easy activating and inactivating of plugins
* This function allows easy activating and inactivating of plugins
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University
*/
*/
function store_p lugins()
function storeP lugins()
{
{
$appPlugin = new AppPlugin();
$appPlugin = new AppPlugin();
@ -701,10 +652,10 @@ function store_plugins()
* This function allows the platform admin to choose which should be the default stylesheet
* This function allows the platform admin to choose which should be the default stylesheet
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University
*/
*/
function store_s tylesheets()
function storeS tylesheets()
{
{
// Insert the stylesheet.
// Insert the stylesheet.
if (is_s tyle($_POST['style'])) {
if (isS tyle($_POST['style'])) {
api_set_setting(
api_set_setting(
'stylesheets',
'stylesheets',
$_POST['style'],
$_POST['style'],
@ -722,7 +673,7 @@ function store_stylesheets()
* @param string Style
* @param string Style
* @return bool True if this style is recognized, false otherwise
* @return bool True if this style is recognized, false otherwise
*/
*/
function is_s tyle($style)
function isS tyle($style)
{
{
$dir = CSS_UPLOAD_PATH;
$dir = CSS_UPLOAD_PATH;
$dirs = scandir($dir);
$dirs = scandir($dir);
@ -738,7 +689,7 @@ function is_style($style)
* TODO: support for multiple site. aka $_configuration['access_url'] == 1
* TODO: support for multiple site. aka $_configuration['access_url'] == 1
* @author Marco Villegas < marvil07 @ gmail . com >
* @author Marco Villegas < marvil07 @ gmail . com >
*/
*/
function handle_s earch()
function handleS earch()
{
{
global $SettingsStored, $_configuration;
global $SettingsStored, $_configuration;
@ -749,37 +700,25 @@ function handle_search()
$values = api_get_settings_options('search_enabled');
$values = api_get_settings_options('search_enabled');
$form->addElement('header', null, get_lang('SearchEnabledTitle'));
$form->addElement('header', null, get_lang('SearchEnabledTitle'));
$group = array ();
$group = formGenerateElementsGroup($form, $values, 'search_enabled');
if (is_array($values)) {
foreach ($values as $key => $value) {
$element = & $form->createElement('radio', 'search_enabled', '', $value['display_text'], $value['value']);
$group[] = $element;
}
}
//SearchEnabledComment
//SearchEnabledComment
$form->addGroup($group, 'search_enabled', array(get_lang('SearchEnabledTitle'), get_lang('SearchEnabledComment')), '< br / > ', false);
$form->addGroup($group, 'search_enabled', array(get_lang('SearchEnabledTitle'), get_lang('SearchEnabledComment')), '< br / > ', false);
$search_enabled = api_get_setting('search_enabled');
$search_enabled = api_get_setting('search_enabled');
if ($form->validate()) {
if ($form->validate()) {
$formvalues = $form->exportValues();
$formValues = $form->exportValues();
$r = api_set_settings_category('Search', 'false', $_configuration['access_url']);
setConfigurationSettingsInDatabase($formValues, $_configuration['access_url']);
// Save the settings.
$search_enabled = $formValues['search_enabled'];
foreach ($formvalues as $key => $value) {
$result = api_set_setting($key, $value, null, null);
}
$search_enabled = $formvalues['search_enabled'];
Display::display_confirmation_message($SettingsStored);
Display::display_confirmation_message($SettingsStored);
}
}
$specific_fields = get_specific_field_list();
$specific_fields = get_specific_field_list();
if ($search_enabled == 'true') {
if ($search_enabled == 'true') {
$values = api_get_settings_options('search_show_unlinked_results');
$values = api_get_settings_options('search_show_unlinked_results');
$group = array ();
foreach ($values as $key => $value) {
$group = formGenerateElementsGroup($form, $values, 'search_show_unlinked_results');
$element = & $form->createElement('radio', 'search_show_unlinked_results', '', $value['display_text'], $value['value']);
$group[] = $element;
}
$form->addGroup($group, 'search_show_unlinked_results', array(get_lang('SearchShowUnlinkedResultsTitle'),get_lang('SearchShowUnlinkedResultsComment')), '', false);
$form->addGroup($group, 'search_show_unlinked_results', array(get_lang('SearchShowUnlinkedResultsTitle'),get_lang('SearchShowUnlinkedResultsComment')), '', false);
$default_values['search_show_unlinked_results'] = api_get_setting('search_show_unlinked_results');
$default_values['search_show_unlinked_results'] = api_get_setting('search_show_unlinked_results');
@ -787,7 +726,6 @@ function handle_search()
foreach ($specific_fields as $sf) {
foreach ($specific_fields as $sf) {
$sf_values[$sf['code']] = $sf['name'];
$sf_values[$sf['code']] = $sf['name'];
}
}
$group = array();
$url = Display::div(Display::url(get_lang('AddSpecificSearchField'), 'specific_fields.php'), array('class'=>'sectioncomment'));
$url = Display::div(Display::url(get_lang('AddSpecificSearchField'), 'specific_fields.php'), array('class'=>'sectioncomment'));
if (empty($sf_values)) {
if (empty($sf_values)) {
$form->addElement('label', [get_lang('SearchPrefilterPrefix'), $url]);
$form->addElement('label', [get_lang('SearchPrefilterPrefix'), $url]);
@ -807,33 +745,33 @@ function handle_search()
echo '< / div > ';
echo '< / div > ';
if ($search_enabled == 'true') {
if ($search_enabled == 'true') {
$xapian_p ath = api_get_path(SYS_UPLOAD_PATH).'plugins/xapian/searchdb';
$xapianP ath = api_get_path(SYS_UPLOAD_PATH).'plugins/xapian/searchdb';
/*
/*
@todo Test the Xapian connection
@todo Test the Xapian connection
if (extension_loaded('xapian')) {
if (extension_loaded('xapian')) {
require_once 'xapian.php';
require_once 'xapian.php';
try {
try {
$db = new XapianDatabase($xapian_p ath.'/');
$db = new XapianDatabase($xapianP ath.'/');
} catch (Exception $e) {
} catch (Exception $e) {
var_dump($e->getMessage());
var_dump($e->getMessage());
}
}
require_once api_get_path(LIBRARY_PATH) . 'search/Dokeos Indexer.class.php';
require_once api_get_path(LIBRARY_PATH) . 'search/Chamilo Indexer.class.php';
require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php';
require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
$indexable = new IndexableChunk();
$indexable = new IndexableChunk();
$indexable->addValue("content", 'Test');
$indexable->addValue("content", 'Test');
$di = new Dokeos Indexer();
$di = new Chamilo Indexer();
$di->connectDb(NULL, NULL, 'english');
$di->connectDb(NULL, NULL, 'english');
$di->addChunk($indexable);
$di->addChunk($indexable);
$did = $di->index();
$did = $di->index();
}
}
*/
*/
$xapian_l oaded = Display::return_icon('bullet_green.png', get_lang('Ok'));
$xapianL oaded = Display::return_icon('bullet_green.png', get_lang('Ok'));
$dir_exists = Display::return_icon('bullet_green.png', get_lang('Ok'));
$dir_exists = Display::return_icon('bullet_green.png', get_lang('Ok'));
$dir_is_writable = Display::return_icon('bullet_green.png', get_lang('Ok'));
$dir_is_writable = Display::return_icon('bullet_green.png', get_lang('Ok'));
$specific_fields_exists = Display::return_icon('bullet_green.png', get_lang('Ok'));
$specific_fields_exists = Display::return_icon('bullet_green.png', get_lang('Ok'));
@ -844,58 +782,25 @@ function handle_search()
}
}
//Testing xapian extension
//Testing xapian extension
if (!extension_loaded('xapian')) {
if (!extension_loaded('xapian')) {
$xapian_l oaded = Display::return_icon('bullet_red.png', get_lang('Error'));
$xapianL oaded = Display::return_icon('bullet_red.png', get_lang('Error'));
}
}
//Testing xapian searchdb path
//Testing xapian searchdb path
if (!is_dir($xapian_p ath)) {
if (!is_dir($xapianP ath)) {
$dir_exists = Display::return_icon('bullet_red.png', get_lang('Error'));
$dir_exists = Display::return_icon('bullet_red.png', get_lang('Error'));
}
}
//Testing xapian searchdb path is writable
//Testing xapian searchdb path is writable
if (!is_writable($xapian_p ath)) {
if (!is_writable($xapianP ath)) {
$dir_is_writable = Display::return_icon('bullet_red.png', get_lang('Error'));
$dir_is_writable = Display::return_icon('bullet_red.png', get_lang('Error'));
}
}
$data[] = array(get_lang('XapianModuleInstalled'),$xapian_loaded);
$data = array();
$data[] = array(get_lang('DirectoryExists').' - '.$xapian_path,$dir_exists);
$data[] = array(get_lang('XapianModuleInstalled'), $xapianLoaded);
$data[] = array(get_lang('IsWritable').' - '.$xapian_path,$dir_is_writable);
$data[] = array(get_lang('DirectoryExists').' - '.$xapianPath, $dir_exists);
$data[] = array(get_lang('SpecificSearchFieldsAvailable') ,$specific_fields_exists);
$data[] = array(get_lang('IsWritable').' - '.$xapianPath, $dir_is_writable);
$data[] = array(get_lang('SpecificSearchFieldsAvailable'), $specific_fields_exists);
echo Display::tag('h3', get_lang('Settings'));
$table = new SortableTableFromArray($data);
$table->set_header(0, get_lang('Setting'), false);
$table->set_header(1, get_lang('Status'), false);
echo $table->display();
//@todo windows support
if (api_is_windows_os() == false) {
$list_of_programs = array('pdftotext','ps2pdf', 'catdoc','html2text','unrtf', 'catppt', 'xls2csv');
foreach($list_of_programs as $program) {
$output = [];
$ret_val = null;
exec("which $program", $output, $ret_val);
if (!$output) {
$output[] = '';
}
$icon = Display::return_icon('bullet_red.png', get_lang('NotInstalled'));
showSearchSettingsTable($data);
if (!empty($output[0])) {
showSearchToolsStatusTable();
$icon = Display::return_icon('bullet_green.png', get_lang('Installed'));
}
$data2[]= array($program, $output[0], $icon);
}
echo Display::tag('h3', get_lang('ProgramsNeededToConvertFiles'));
$table = new SortableTableFromArray($data2);
$table->set_header(0, get_lang('Program'), false);
$table->set_header(1, get_lang('Path'), false);
$table->set_header(2, get_lang('Status'), false);
echo $table->display();
} else {
Display::display_warning_message(
get_lang('YouAreUsingChamiloInAWindowsPlatformSadlyYouCantConvertDocumentsInOrderToSearchTheContentUsingThisTool')
);
}
}
}
}
}
@ -905,9 +810,9 @@ function handle_search()
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @author Julio Montoya.
* @author Julio Montoya.
* @version August 2008
* @version August 2008
* @since Dokeos 1.8.6
* @since v 1.8.6
*/
*/
function handle_t emplates()
function handleT emplates()
{
{
/* Drive-by fix to avoid undefined var warnings, without repeating
/* Drive-by fix to avoid undefined var warnings, without repeating
* isset() combos all over the place. */
* isset() combos all over the place. */
@ -921,7 +826,7 @@ function handle_templates()
}
}
if ($action == 'add' || ($action == 'edit' & & is_numeric($_GET['id']))) {
if ($action == 'add' || ($action == 'edit' & & is_numeric($_GET['id']))) {
add_edit_t emplate();
addEditT emplate();
// Add event to the system log.
// Add event to the system log.
$user_id = api_get_user_id();
$user_id = api_get_user_id();
@ -935,7 +840,7 @@ function handle_templates()
);
);
} else {
} else {
if ($action == 'delete' & & is_numeric($_GET['id'])) {
if ($action == 'delete' & & is_numeric($_GET['id'])) {
delete_t emplate($_GET['id']);
deleteT emplate($_GET['id']);
// Add event to the system log
// Add event to the system log
$user_id = api_get_user_id();
$user_id = api_get_user_id();
@ -948,7 +853,7 @@ function handle_templates()
$user_id
$user_id
);
);
}
}
display_t emplates();
displayT emplates();
}
}
}
}
@ -957,17 +862,17 @@ function handle_templates()
*
*
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @version August 2008
* @version August 2008
* @since Dokeos 1.8.6
* @since v 1.8.6
*/
*/
function display_t emplates()
function displayT emplates()
{
{
$table = new SortableTable('templates', 'get_number_of_templates', 'get_template_d ata', 1);
$table = new SortableTable('templates', 'getNumberOfTemplates', 'getTemplateD ata', 1);
$table->set_additional_parameters(array('category' => Security::remove_XSS($_GET['category'])));
$table->set_additional_parameters(array('category' => Security::remove_XSS($_GET['category'])));
$table->set_header(0, get_lang('Image'), true, array('style' => 'width: 101px;'));
$table->set_header(0, get_lang('Image'), true, array('style' => 'width: 101px;'));
$table->set_header(1, get_lang('Title'));
$table->set_header(1, get_lang('Title'));
$table->set_header(2, get_lang('Actions'), false, array('style' => 'width:50px;'));
$table->set_header(2, get_lang('Actions'), false, array('style' => 'width:50px;'));
$table->set_column_filter(2, 'actions_f ilter');
$table->set_column_filter(2, 'actionsF ilter');
$table->set_column_filter(0, 'image_f ilter');
$table->set_column_filter(0, 'searchImageF ilter');
$table->display();
$table->display();
}
}
@ -978,9 +883,9 @@ function display_templates()
*
*
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @version August 2008
* @version August 2008
* @since Dokeos 1.8.6
* @since v 1.8.6
*/
*/
function get_number_of_t emplates()
function getNumberOfT emplates()
{
{
// Database table definition.
// Database table definition.
$table_system_template = Database :: get_main_table('system_template');
$table_system_template = Database :: get_main_table('system_template');
@ -1005,9 +910,9 @@ function get_number_of_templates()
*
*
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @version August 2008
* @version August 2008
* @since Dokeos 1.8.6
* @since v 1.8.6
*/
*/
function get_template_d ata($from, $number_of_items, $column, $direction)
function getTemplateD ata($from, $number_of_items, $column, $direction)
{
{
// Database table definition.
// Database table definition.
$table_system_template = Database :: get_main_table('system_template');
$table_system_template = Database :: get_main_table('system_template');
@ -1034,9 +939,9 @@ function get_template_data($from, $number_of_items, $column, $direction)
*
*
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @version August 2008
* @version August 2008
* @since Dokeos 1.8.6
* @since v 1.8.6
*/
*/
function actions_f ilter($id) {
function actionsF ilter($id) {
$return = '< a href = "settings.php?category=Templates&action=edit&id='.Security::remove_XSS($id).'" > '.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'< / a > ';
$return = '< a href = "settings.php?category=Templates&action=edit&id='.Security::remove_XSS($id).'" > '.Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL).'< / a > ';
$return .= '< a href = "settings.php?category=Templates&action=delete&id='.Security::remove_XSS($id).'" onClick = "javascript:if(!confirm('." ' " . get_lang ( ' ConfirmYourChoice ' ) . " ' " . ' ) ) return false ; " > '.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'< / a > ';
$return .= '< a href = "settings.php?category=Templates&action=delete&id='.Security::remove_XSS($id).'" onClick = "javascript:if(!confirm('." ' " . get_lang ( ' ConfirmYourChoice ' ) . " ' " . ' ) ) return false ; " > '.Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL).'< / a > ';
return $return;
return $return;
@ -1050,9 +955,9 @@ function actions_filter($id) {
*
*
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @version August 2008
* @version August 2008
* @since Dokeos 1.8.6
* @since v 1.8.6
*/
*/
function image_f ilter($image)
function searchImageF ilter($image)
{
{
if (!empty($image)) {
if (!empty($image)) {
return '< img src = "'.api_get_path(WEB_APP_PATH).'home/default_platform_document/template_thumb/'.$image.'" alt = "'.get_lang('TemplatePreview').'" / > ';
return '< img src = "'.api_get_path(WEB_APP_PATH).'home/default_platform_document/template_thumb/'.$image.'" alt = "'.get_lang('TemplatePreview').'" / > ';
@ -1067,9 +972,9 @@ function image_filter($image)
*
*
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @version August 2008
* @version August 2008
* @since Dokeos 1.8.6
* @since v 1.8.6
*/
*/
function add_edit_t emplate()
function addEditT emplate()
{
{
// Initialize the object.
// Initialize the object.
$id = isset($_GET['id']) ? '& id='.Security::remove_XSS($_GET['id']) : '';
$id = isset($_GET['id']) ? '& id='.Security::remove_XSS($_GET['id']) : '';
@ -1195,7 +1100,7 @@ function add_edit_template()
}
}
}
}
Security::clear_token();
Security::clear_token();
display_t emplates();
displayT emplates();
} else {
} else {
$token = Security::get_token();
$token = Security::get_token();
$form->addElement('hidden','sec_token');
$form->addElement('hidden','sec_token');
@ -1212,9 +1117,9 @@ function add_edit_template()
*
*
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Belgium
* @version August 2008
* @version August 2008
* @since Dokeos 1.8.6
* @since v 1.8.6
*/
*/
function delete_t emplate($id)
function deleteT emplate($id)
{
{
// First we remove the image.
// First we remove the image.
$table_system_template = Database :: get_main_table('system_template');
$table_system_template = Database :: get_main_table('system_template');
@ -1257,45 +1162,37 @@ function select_gradebook_number_decimals() {
return array('0', '1', '2');
return array('0', '1', '2');
}
}
/**
* Get the options for a select element to select gradebook default grade model
* @return array
*/
function select_gradebook_default_grade_model_id()
function select_gradebook_default_grade_model_id()
{
{
$grade_model = new GradeModel();
$grade_model = new GradeModel();
$models = $grade_model->get_all();
$models = $grade_model->get_all();
$options = array();
$options = array();
$options[-1] = get_lang('None');
$options[-1] = get_lang('None');
if (!empty($models)) {
if (!empty($models)) {
foreach ($models as $model) {
foreach ($models as $model) {
$options[$model['id']] = $model['name'];
$options[$model['id']] = $model['name'];
}
}
}
}
return $options;
return $options;
}
}
/**
/**
* Updates the gradebook score custom values using the scoredisplay class of the
* @param array $settings
* gradebook module
* @param array $settings_by_access_list
*
*
* @param array List of gradebook score custom values
* @return FormValidator
*
*
* @author Guillaume Viguier < guillaume.viguier @ beeznest . com >
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
* @throws \Doctrine\ORM\TransactionRequiredException
*/
*/
function update_gradebook_score_display_custom_values($values)
function generateSettingsForm($settings, $settings_by_access_list)
{
$scoredisplay = ScoreDisplay::instance();
$scores = $values['gradebook_score_display_custom_values_endscore'];
$displays = $values['gradebook_score_display_custom_values_displaytext'];
$nr_displays = count($displays);
$final = array();
for ($i = 1; $i < $nr_displays; $i++) {
if (!empty($scores[$i]) & & !empty($displays[$i])) {
$final[$i]['score'] = $scores[$i];
$final[$i]['display'] = $displays[$i];
}
}
$scoredisplay->update_custom_score_display_settings($final);
}
function generate_settings_form($settings, $settings_by_access_list)
{
{
global $_configuration, $settings_to_avoid, $convert_byte_to_mega_list;
global $_configuration, $settings_to_avoid, $convert_byte_to_mega_list;
$em = Database::getManager();
$em = Database::getManager();
@ -1303,8 +1200,11 @@ function generate_settings_form($settings, $settings_by_access_list)
$form = new FormValidator('settings', 'post', 'settings.php?category='.Security::remove_XSS($_GET['category']));
$form = new FormValidator('settings', 'post', 'settings.php?category='.Security::remove_XSS($_GET['category']));
$form->addElement('hidden', 'search_field',
$form->addElement(
(!empty($_GET['search_field']) ? Security::remove_XSS($_GET['search_field']) : null));
'hidden',
'search_field',
(!empty($_GET['search_field']) ? Security::remove_XSS($_GET['search_field']) : null)
);
$url_id = api_get_current_access_url_id();
$url_id = api_get_current_access_url_id();
@ -1335,19 +1235,31 @@ function generate_settings_form($settings, $settings_by_access_list)
if ($row['access_url_locked'] == 0) {
if ($row['access_url_locked'] == 0) {
if ($url_id == 1) {
if ($url_id == 1) {
if ($row['access_url_changeable'] == '1') {
if ($row['access_url_changeable'] == '1') {
$form->addElement('html', '< div style = "float: right;" > < a class = "share_this_setting" data_status = "0" data_to_send = "'.$row['variable'].'" href = "javascript:void(0);" > '.
$form->addElement(
Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting')).'< / a > < / div > ');
'html',
'< div style = "float: right;" > < a class = "share_this_setting" data_status = "0" data_to_send = "'.$row['variable'].'" href = "javascript:void(0);" > '.
Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting')).'< / a > < / div > '
);
} else {
} else {
$form->addElement('html', '< div style = "float: right;" > < a class = "share_this_setting" data_status = "1" data_to_send = "'.$row['variable'].'" href = "javascript:void(0);" > '.
$form->addElement(
Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting')).'< / a > < / div > ');
'html',
'< div style = "float: right;" > < a class = "share_this_setting" data_status = "1" data_to_send = "'.$row['variable'].'" href = "javascript:void(0);" > '.
Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting')).'< / a > < / div > '
);
}
}
} else {
} else {
if ($row['access_url_changeable'] == '1') {
if ($row['access_url_changeable'] == '1') {
$form->addElement('html', '< div style = "float: right;" > '.
$form->addElement(
Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting')).'< / div > ');
'html',
'< div style = "float: right;" > '.
Display::return_icon('shared_setting.png', get_lang('ChangeSharedSetting')).'< / div > '
);
} else {
} else {
$form->addElement('html', '< div style = "float: right;" > '.
$form->addElement(
Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting')).'< / div > ');
'html',
'< div style = "float: right;" > '.
Display::return_icon('shared_setting_na.png', get_lang('ChangeSharedSetting')).'< / div > '
);
}
}
}
}
}
}
@ -1393,7 +1305,7 @@ function generate_settings_form($settings, $settings_by_access_list)
array(
array(
get_lang($row['title']),
get_lang($row['title']),
get_lang($row['comment']),
get_lang($row['comment']),
get_lang('MB'),
get_lang('MB')
),
),
array('maxlength' => '8')
array('maxlength' => '8')
);
);
@ -1422,7 +1334,7 @@ function generate_settings_form($settings, $settings_by_access_list)
$row['variable'],
$row['variable'],
array(
array(
get_lang($row['title']),
get_lang($row['title']),
get_lang($row['comment']),
get_lang($row['comment'])
),
),
$hideme
$hideme
);
);
@ -1461,7 +1373,7 @@ function generate_settings_form($settings, $settings_by_access_list)
'radio',
'radio',
$row['variable'],
$row['variable'],
'',
'',
$value['display_text'],
get_lang( $value['display_text']) ,
$value['value']
$value['value']
);
);
if ($hide_element) {
if ($hide_element) {
@ -1479,7 +1391,7 @@ function generate_settings_form($settings, $settings_by_access_list)
);
);
$default_values[$row['variable']] = $row['selected_value'];
$default_values[$row['variable']] = $row['selected_value'];
break;
break;
case 'checkbox';
case 'checkbox':
// 1. We collect all the options of this variable.
// 1. We collect all the options of this variable.
$sql = "SELECT * FROM $table_settings_current
$sql = "SELECT * FROM $table_settings_current
WHERE variable='".$row['variable']."' AND access_url = 1";
WHERE variable='".$row['variable']."' AND access_url = 1";
@ -1489,13 +1401,13 @@ function generate_settings_form($settings, $settings_by_access_list)
while ($rowkeys = Database::fetch_array($result)) {
while ($rowkeys = Database::fetch_array($result)) {
// Profile tab option should be hidden when the social tool is enabled.
// Profile tab option should be hidden when the social tool is enabled.
if (api_get_setting('allow_social_tool') == 'true') {
if (api_get_setting('allow_social_tool') == 'true') {
if ($rowkeys['variable'] == 'show_tabs' & & $rowkeys['subkey'] == 'my_profile') {
if ($rowkeys['variable'] === 'show_tabs' & & $rowkeys['subkey'] = == 'my_profile') {
continue;
continue;
}
}
}
}
// Hiding the gradebook option.
// Hiding the gradebook option.
if ($rowkeys['variable'] == 'show_tabs' & & $rowkeys['subkey'] == 'my_gradebook') {
if ($rowkeys['variable'] === 'show_tabs' & & $rowkeys['subkey'] = == 'my_gradebook') {
continue;
continue;
}
}
@ -1520,11 +1432,11 @@ function generate_settings_form($settings, $settings_by_access_list)
access_url = $access_url";
access_url = $access_url";
$result_access = Database::query($sql);
$result_access = Database::query($sql);
$row_access = Database::fetch_array($result_access);
$row_access = Database::fetch_array($result_access);
if ($row_access['selected_value'] == 'true' & & !$form->isSubmitted()) {
if ($row_access['selected_value'] === 'true' & & !$form->isSubmitted()) {
$element->setChecked(true);
$element->setChecked(true);
}
}
} else {
} else {
if ($rowkeys['selected_value'] == 'true' & & !$form->isSubmitted()) {
if ($rowkeys['selected_value'] === 'true' & & !$form->isSubmitted()) {
$element->setChecked(true);
$element->setChecked(true);
}
}
}
}
@ -1536,7 +1448,7 @@ function generate_settings_form($settings, $settings_by_access_list)
$form->addGroup(
$form->addGroup(
$group,
$group,
$row['variable'],
$row['variable'],
array(get_lang($row['title']), get_lang($row['comment'])),
array(get_lang($row['title']), get_lang($row['comment']) . 'aaaaaa' ),
''
''
);
);
break;
break;
@ -1549,7 +1461,13 @@ function generate_settings_form($settings, $settings_by_access_list)
* To populate the list of options, the select type dynamically calls a function that must be called select_ + the name of the variable being displayed.
* To populate the list of options, the select type dynamically calls a function that must be called select_ + the name of the variable being displayed.
* The functions being called must be added to the file settings.lib.php.
* The functions being called must be added to the file settings.lib.php.
*/
*/
$form->addElement('select', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), call_user_func('select_'.$row['variable']), $hideme);
$form->addElement(
'select',
$row['variable'],
array(get_lang($row['title']), get_lang($row['comment'])),
call_user_func('select_'.$row['variable']),
$hideme
);
$default_values[$row['variable']] = $row['selected_value'];
$default_values[$row['variable']] = $row['selected_value'];
break;
break;
case 'custom':
case 'custom':
@ -1612,7 +1530,7 @@ function generate_settings_form($settings, $settings_by_access_list)
* @param string $search
* @param string $search
* @return array
* @return array
*/
*/
function search_s etting($search)
function searchS etting($search)
{
{
if (empty($search)) {
if (empty($search)) {
return array();
return array();
@ -1655,3 +1573,146 @@ function search_setting($search)
}
}
return $settings;
return $settings;
}
}
/**
* Helper function to generates a form elements group
* @param object $form The form where the elements group has to be added
* @param array $values Values to browse through
* @return array
*/
function formGenerateElementsGroup($form, $values = array(), $elementName)
{
$group = array();
if (is_array($values)) {
foreach ($values as $key => $value) {
$element = & $form->createElement('radio', $elementName, '', get_lang($value['display_text']), $value['value']);
$group[] = $element;
}
}
return $group;
}
/**
* Helper function with allowed file types for CSS
* @return array Array of file types (no indexes)
*/
function getAllowedFileTypes()
{
$allowedFiles = array(
'css',
'zip',
'jpeg',
'jpg',
'png',
'gif',
'ico',
'psd',
'xcf',
'svg',
'webp',
'woff',
'woff2'
);
return $allowedFiles;
}
/**
* Helper function to set settings in the database
* @param array $parameters List of values
* @param int $accessUrl The current access URL
* @return void
*/
function setConfigurationSettingsInDatabase($parameters, $accessUrl)
{
$r = api_set_settings_category('Search', 'false', $accessUrl);
// Save the settings.
foreach ($parameters as $key => $value) {
$result = api_set_setting($key, $value, null, null);
}
}
/**
* Helper function to show the status of the search settings table
* @param array $data Data to show
* @return void
*/
function showSearchSettingsTable($data)
{
echo Display::tag('h3', get_lang('Settings'));
$table = new SortableTableFromArray($data);
$table->set_header(0, get_lang('Setting'), false);
$table->set_header(1, get_lang('Status'), false);
echo $table->display();
}
/**
* Helper function to show status table for each command line tool installed
* @return void
*/
function showSearchToolsStatusTable()
{
//@todo windows support
if (api_is_windows_os() == false) {
$list_of_programs = array('pdftotext', 'ps2pdf', 'catdoc', 'html2text', 'unrtf', 'catppt', 'xls2csv');
foreach($list_of_programs as $program) {
$output = [];
$ret_val = null;
exec("which $program", $output, $ret_val);
if (!$output) {
$output[] = '';
}
$icon = Display::return_icon('bullet_red.png', get_lang('NotInstalled'));
if (!empty($output[0])) {
$icon = Display::return_icon('bullet_green.png', get_lang('Installed'));
}
$data2[]= array($program, $output[0], $icon);
}
echo Display::tag('h3', get_lang('ProgramsNeededToConvertFiles'));
$table = new SortableTableFromArray($data2);
$table->set_header(0, get_lang('Program'), false);
$table->set_header(1, get_lang('Path'), false);
$table->set_header(2, get_lang('Status'), false);
echo $table->display();
} else {
Display::display_warning_message(
get_lang('YouAreUsingChamiloInAWindowsPlatformSadlyYouCantConvertDocumentsInOrderToSearchTheContentUsingThisTool')
);
}
}
/**
* Helper function to generate and show CSS Zip download message
* @param string $style Style path
* @return void
*/
function generateCSSDownloadLink($style)
{
$arch = api_get_path(SYS_ARCHIVE_PATH).$style.'.zip';
$dir = api_get_path(SYS_CSS_PATH).'themes/'.$style;
if (is_dir($dir)) {
$zip = new PclZip($arch);
// Remove path prefix except the style name and put file on disk
$zip->create($dir, PCLZIP_OPT_REMOVE_PATH, substr($dir,0,-strlen($style)));
//@TODO: use more generic script to download.
$str = '< a class = "btn btn-primary btn-large" href = "' . api_get_path(WEB_CODE_PATH) . 'course_info/download.php?archive=' . str_replace(api_get_path(SYS_ARCHIVE_PATH), '', $arch) . '" > '.get_lang('ClickHereToDownloadTheFile').'< / a > ';
Display::display_normal_message($str, false);
} else {
Display::addFlash(Display::return_message(get_lang('FileNotFound'), 'warning'));
}
}
/**
* Helper function to tell if the style is changeable in the current URL
* @return bool $changeable Whether the style can be changed in this URL or not
*/
function isStyleChangeable() {
global $_configuration;
$changeable = false;
if ($_configuration['access_url'] != 1) {
$style_info = api_get_settings('stylesheets', '', 1, 0);
$url_info = api_get_access_url($_configuration['access_url']);
if ($style_info[0]['access_url_changeable'] == 1 & & $url_info['active'] == 1) {
$changeable = true;
}
} else {
$changeable = true;
}
return $changeable;
}