Fix E_NOTICEs when search_enabled is true - refs BT#10979

ofaj
Angel Fernando Quiroz Campos 9 years ago
parent 2eca06a3f7
commit fa5f19be0e
  1. 10
      main/admin/settings.lib.php
  2. 14
      main/admin/specific_fields.php
  3. 15
      main/admin/specific_fields_add.php
  4. 4
      main/document/upload.php
  5. 7
      main/exercice/exercise.class.php
  6. 2
      main/inc/lib/api.lib.php
  7. 10
      main/inc/lib/search/search_widget.php
  8. 25
      main/newscorm/lp_list_search.php

@ -758,7 +758,7 @@ function handle_search()
$group = array();
$url = Display::div(Display::url(get_lang('AddSpecificSearchField'), 'specific_fields.php'), array('class'=>'sectioncomment'));
if (empty($sf_values)) {
$form->addElement('html', get_lang('SearchPrefilterPrefix').$url);
$form->addElement('label', [get_lang('SearchPrefilterPrefix'), $url]);
} else {
$form->addElement('select', 'search_prefilter_prefix', array(get_lang('SearchPrefilterPrefix'), $url), $sf_values, '');
$default_values['search_prefilter_prefix'] = api_get_setting('search_prefilter_prefix');
@ -839,8 +839,14 @@ function handle_search()
$list_of_programs = array('pdftotext','ps2pdf', 'catdoc','html2text','unrtf', 'catppt', 'xls2csv');
foreach($list_of_programs as $program) {
$output = $ret_val = null;
$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'));

@ -17,7 +17,6 @@ api_protect_admin_script();
// Breadcrumb
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array ('url' => 'settings.php?category=Search', 'name' => get_lang('PlatformConfigSettings'));
$interbreadcrumb[] = array ('url' => 'specific_fields.php', 'name' => get_lang('SpecificSearchFields'));
$libpath = api_get_path(LIBRARY_PATH);
@ -30,16 +29,16 @@ $renderer->setCustomElementTemplate('<span>{element}</span> ');
$form->addElement('static','search_advanced_link',null,'<a href="specific_fields_add.php">'.Display::return_icon('fieldadd.gif').get_lang('AddSpecificSearchField').'</a>');
// Create a sortable table with specific fields data
$column_show = array(1,1,1,1);
$column_order = array(3,2,1,4);
$column_show = array(1,1,1);
$column_order = array(3,2,1);
$extra_fields = get_specific_field_list();
$number_of_extra_fields = count($extra_fields);
$table = new SortableTableFromArrayConfig($extra_fields,2,50,'',$column_show,$column_order);
$table->set_header(0, '', false,null,'width="2%"', 'style="display:none"');
$table->set_header(0, '&nbsp;', false,null,'width="2%"', 'style="display:none"');
$table->set_header(1, get_lang('Code'), TRUE, 'width="10%"');
$table->set_header(2, get_lang('Name'));
$table->set_header(3, get_lang('Modify'),true,'width="10%"');
$table->set_header(3, get_lang('Modify'),false,'width="10%"');
$table->set_column_filter(3, 'edit_filter');
function edit_filter($id,$url_params,$row) {
@ -49,15 +48,16 @@ function edit_filter($id,$url_params,$row) {
return $return;
}
if ($_REQUEST['action'] == 'delete') {
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
delete_specific_field($_REQUEST['field_id']);
header('Location: specific_fields.php?message='.get_lang('FieldRemoved'));
exit;
}
// Start output
// Displaying the header
Display::display_header($nameTools);
Display::display_header(get_lang('SpecificSearchFields'));
echo Display::display_normal_message(get_lang('SpecificSearchFieldsIntro'));
if(!empty($_GET['message'])) {

@ -18,18 +18,21 @@ $this_section = SECTION_PLATFORM_ADMIN;
// user permissions
api_protect_admin_script();
$fieldId = isset($_REQUEST['field_id']) ? intval($_REQUEST['field_id']) : 0;
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'settings.php?category=Search', 'name' => get_lang('PlatformConfigSettings'));
$interbreadcrumb[] = array('url' => 'specific_fields.php', 'name' => get_lang('SpecificSearchFields'));
if ($_GET['action']<>'edit') {
$tool_name = get_lang('AddSpecificSearchField');
} else {
$tool_name = get_lang('AddSpecificSearchField');
if (isset($_GET['action']) && $_GET['action'] === 'edit') {
$tool_name = get_lang('EditSpecificSearchField');
}
// Create the form
$form = new FormValidator('specific_fields_add');
// Field variable name
$form->addElement('hidden','field_id',(int)$_REQUEST['field_id']);
$form->addElement('hidden','field_id', $fieldId);
$form->addElement('text','field_name',get_lang('FieldName'));
$form->applyFilter('field_name','html_filter');
$form->applyFilter('field_name','trim');
@ -39,8 +42,8 @@ $form->addRule('field_name', '', 'maxlength',20);
// Set default values (only not empty when editing)
$defaults = array();
if (is_numeric($_REQUEST['field_id'])) {
$form_information = get_specific_field_list(array( 'id' => (int)$_GET['field_id'] ));
if ($fieldId) {
$form_information = get_specific_field_list(array( 'id' => $fieldId ));
$defaults['field_name'] = $form_information[0]['name'];
}
$form->setDefaults($defaults);

@ -259,11 +259,11 @@ if (api_get_setting('search_enabled') == 'true') {
$form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument').'<div style="font-size: 80%" >'.$supported_formats.'</div>');
$form->addElement('html', '<br /><div class="sub-form">');
$form->addElement('html', '<div class="label">'.get_lang('SearchFeatureDocumentLanguage').'</div>');
$form->addElement('html', '<div>' . api_get_languages_combo(null) . '</div>');
$form->addLabel(get_lang('Language'), api_get_languages_combo());
$form->addElement('html', '</div><div class="sub-form">');
$specific_fields = get_specific_field_list();
foreach ($specific_fields as $specific_field) {
$form->addElement('text', $specific_field['code'], $specific_field['name'].' : ');
$form->addElement('text', $specific_field['code'], $specific_field['name']);
}
$form->addElement('html', '</div>');
}

@ -1315,7 +1315,12 @@ class Exercise
foreach ($specific_fields as $specific_field) {
$form->addElement ('text', $specific_field['code'], $specific_field['name']);
$filter = array('c_id'=> "'". api_get_course_int_id() ."'", 'field_id' => $specific_field['id'], 'ref_id' => $this->id, 'tool_id' => '\''. TOOL_QUIZ .'\'');
$filter = array(
'c_id' => api_get_course_int_id(),
'field_id' => $specific_field['id'],
'ref_id' => $this->id,
'tool_id' => "'" . TOOL_QUIZ . "'"
);
$values = get_specific_field_values_list($filter, array('value'));
if ( !empty($values) ) {
$arr_str_values = array();

@ -4178,7 +4178,7 @@ function api_get_languages_combo($name = 'language')
$languages = $language_list['name'];
$folder = $language_list['folder'];
$ret .= '<select name="' . $name . '" id="language_chosen">';
$ret .= '<select name="' . $name . '" id="language_chosen" class="selectpicker show-tick form-control">';
foreach ($languages as $key => $value) {
if ($folder[$key] == $default) {
$selected = ' selected="selected"';

@ -67,7 +67,7 @@ function format_specific_fields_selects($sf_terms, $op, $prefilter_prefix='') {
// Process each prefix type term
$i = 0;
$max = count($sf_terms);
$multiple_selects .='';
$multiple_selects ='';
foreach ($sf_terms as $prefix => $sf_term_array) {
if ($prefix == $prefilter_prefix) continue;
$multiple_select = '';
@ -91,7 +91,7 @@ function format_specific_fields_selects($sf_terms, $op, $prefilter_prefix='') {
// get specific field name
$sf_value = get_specific_field_list(array( 'code' => "'$prefix'" ));
$sf_value = array_shift($sf_value);
$multiple_select .= '<td><label class="sf-select-multiple-title" for="sf_'. $prefix .'[]">'.$icons_for_search_terms[$prefix].' '.$sf_value['name'].'</label><br />';
$multiple_select .= '<td><label class="sf-select-multiple-title" for="sf_'. $prefix .'[]">' . $sf_value['name'].'</label><br />';
$multiple_select .= format_one_specific_field_select($prefix, $sf_term_array, $op, 'multiple="multiple" size="7" class="sf-select-multiple"');
$multiple_select .= '</td>';
$multiple_selects .= $multiple_select;
@ -134,8 +134,10 @@ function search_widget_normal_form($action, $show_thesaurus, $sf_terms, $op) {
$reset_button = '<button class="save" type="submit" id="tags-clean" value="'. get_lang('SearchResetKeywords') .'" />'. get_lang('SearchResetKeywords') .'</button> ';
}
$query = isset($_REQUEST['query']) ? Security::remove_XSS($_REQUEST['query']) : null;
$form = '<form id="chamilo_search" action="'. $action .'" method="GET">
<input type="text" id="query" name="query" size="40" value="'.stripslashes(Security::remove_XSS($_REQUEST['query'])).'" />
<input type="text" id="query" name="query" size="40" value="' . $query . '" />
<input type="hidden" name="mode" value="'. $mode .'"/>
<input type="hidden" name="type" value="'. $type .'"/>
<input type="hidden" name="tablename_page_nr" value="1" />
@ -357,7 +359,7 @@ function search_widget_show($action='index.php')
//check if URL params are defined (to see if we show the thesaurus or not)
$show_thesaurus = false;
foreach ($url_params as $param) {
if (is_array($_REQUEST[$param])) {
if (isset($_REQUEST[$param]) && is_array($_REQUEST[$param])) {
$thesaurus_decided = FALSE;
foreach ($_REQUEST[$param] as $term) {
if (!empty($term)) {

@ -49,10 +49,14 @@ if (!empty($_REQUEST['operator']) && in_array($op, array('or', 'and'))) {
$op = $_REQUEST['operator'];
}
$query = stripslashes(htmlspecialchars_decode($_REQUEST['query'], ENT_QUOTES));
$query = null;
if (isset($_REQUEST['query'])) {
$query = stripslashes(htmlspecialchars_decode($_REQUEST['query'], ENT_QUOTES));
}
$mode = 'default';
if (in_array($_GET['mode'], array('gallery', 'default'))) {
if (isset($_GET['mode']) && in_array($_GET['mode'], array('gallery', 'default'))) {
$mode = $_GET['mode'];
}
@ -111,12 +115,17 @@ if (count($term_array)) {
}
}
list($count, $results) = chamilo_query_query(
api_convert_encoding($query, 'UTF-8', $charset),
0,
1000,
$fixed_queries
);
if ($query) {
list($count, $results) = chamilo_query_query(
api_convert_encoding($query, 'UTF-8', $charset),
0,
1000,
$fixed_queries
);
} else {
$count = 0;
$results = [];
}
// Prepare blocks to show.
$blocks = array();

Loading…
Cancel
Save