diff --git a/main/admin/settings.lib.php b/main/admin/settings.lib.php index 177cdd27fd..dd8c9f65f8 100755 --- a/main/admin/settings.lib.php +++ b/main/admin/settings.lib.php @@ -538,7 +538,8 @@ function handle_search() { $search_enabled = $formvalues['search_enabled']; Display::display_confirmation_message($SettingsStored); } - + $specific_fields = get_specific_field_list(); + if ($search_enabled == 'true') { // Search_show_unlinked_results. @@ -556,7 +557,7 @@ function handle_search() { // Search_prefilter_prefix. $form->addElement('header', null, get_lang('SearchPrefilterPrefix')); //$form->addElement('label', null, get_lang('SearchPrefilterPrefixComment')); - $specific_fields = get_specific_field_list(); + $sf_values = array(); foreach ($specific_fields as $sf) { $sf_values[$sf['code']] = $sf['name']; @@ -566,8 +567,9 @@ function handle_search() { $default_values['search_prefilter_prefix'] = api_get_setting('search_prefilter_prefix'); //$form->addElement('html', Display::url(get_lang('AddSpecificSearchField'), 'specific_fields.php' )); - //admin/specific_fields.php + //admin/specific_fields.php } + $default_values['search_enabled'] = $search_enabled; //$form->addRule('search_show_unlinked_results', get_lang('ThisFieldIsRequired'), 'required'); @@ -577,6 +579,43 @@ function handle_search() { echo '
'; $form->display(); echo '
'; + + if ($search_enabled == 'true') { + require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php'; + + $xapian_path = api_get_path(SYS_PATH).'searchdb'; + + $xapian_loaded = Display::return_icon('bullet_green.gif', get_lang('Ok')); + $dir_exists = Display::return_icon('bullet_green.gif', get_lang('Ok')); + $dir_is_writable = Display::return_icon('bullet_green.gif', get_lang('Ok')); + + $specific_fields_exists = Display::return_icon('bullet_green.gif', get_lang('Ok')); + + if (empty($specific_fields)) { + $specific_fields_exists = Display::return_icon('bullet_red.gif', get_lang('Error')); + } + + if (!extension_loaded('xapian')) { + $xapian_loaded = Display::return_icon('bullet_red.gif', get_lang('Error')); + } + if (!is_dir($xapian_path)) { + $dir_exists = Display::return_icon('bullet_red.gif', get_lang('Error')); + } + if (!is_writable($xapian_path)) { + $dir_is_writable = Display::return_icon('bullet_red.gif', get_lang('Error')); + } + + $data[] = array(get_lang('XapianModuleInstalled'),$xapian_loaded); + $data[] = array(get_lang('DirectoryExists').' - '.$xapian_path,$dir_exists); + $data[] = array(get_lang('IsWritable').' - '.$xapian_path,$dir_is_writable); + $data[] = array(get_lang('SpecificSearchFieldsAvailable') ,$specific_fields_exists); + + + $table = new SortableTableFromArray($data); + $table->set_header(0,get_lang('Setting'), false); + $table->set_header(1,get_lang('Value'), false); + echo $table->display(); + } } /** diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index a511b96d5b..8f51fca9a6 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -1217,12 +1217,12 @@ class CourseManager { } $course_code = Database::escape_string($course_code); - - $sql_result = Database::query("SELECT * + $sql = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE)." course LEFT JOIN ".Database::get_main_table(TABLE_MAIN_COURSE_USER)." course_user ON course.code = course_user.course_code - WHERE course.target_course_code = '$real_course_code' AND course_user.user_id = '$user_id' AND course_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." "); + WHERE course.target_course_code = '$real_course_code' AND course_user.user_id = '$user_id' AND course_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." "; + $sql_result = Database::query($sql); while ($result = Database::fetch_array($sql_result)) { $result_array[] = $result; diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index 9d997911d6..97c137dcec 100755 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -63,12 +63,13 @@ class Display { /** * Display simple html header of table. + * @deprecated */ - public static function display_table_header() { + /*public static function display_table_header() { $bgcolor = 'bgcolor="white"'; echo ''; return $bgcolor; - } + }*/ /** * Display html header of table with several options. @@ -81,6 +82,7 @@ class Display { * @param column_header, array with the header elements. * @author Roan Embrechts * @version 1.01 + * @todo remove this function, is only use in user.php * @return return type string, bgcolor */ public static function display_complex_table_header($properties, $column_header) { @@ -120,6 +122,7 @@ class Display { * @param $bgcolor the background colour for the table * @param $table_row an array with the row elements * @param $is_alternating true: the row colours alternate, false otherwise + * @todo remove this function, is only use in user.php */ public static function display_table_row($bgcolor, $table_row, $is_alternating = true) { echo ''; @@ -135,46 +138,8 @@ class Display { } } return $bgcolor; - } - - /** - * Displays a table row. - * This public function has more options and is easier to extend than display_table_row() - * - * @param $properties, array with properties: - * ["bgcolor"] - the background colour for the table - * ["is_alternating"] - true: the row colours alternate, false otherwise - * ["align_row"] - an array with, per cell, left|center|right - * @todo add valign property - */ - public static function display_complex_table_row($properties, $table_row) { - $bgcolor = $properties['bgcolor']; - $is_alternating = $properties['is_alternating']; - $align_row = $properties['align_row']; - echo ''; - $number_cells = count($table_row); - for ($i = 0; $i < $number_cells; $i++) { - $cell_data = $table_row[$i]; - $cell_align = $align_row[$i]; - echo ''; - } - echo "\n"; - if ($is_alternating) { - if ($bgcolor == 'bgcolor="'.HTML_WHITE.'"') { - $bgcolor = 'bgcolor="'.DOKEOSLIGHTGREY.'"'; - } elseif ($bgcolor == 'bgcolor="'.DOKEOSLIGHTGREY.'"') { - $bgcolor = 'bgcolor="'.HTML_WHITE.'"'; - } - } - return $bgcolor; - } + } - /** - * Displays html footer of table - */ - public static function display_table_footer() { - echo '
'.$cell_data.'
'; - } /** * Displays a table @@ -857,7 +822,19 @@ class Display { } /** - * Displays the html needed by the grid_js function + * In order to display a grid using jqgrid you have to: + * @example + * After your Display::display_header function you have to add the nex javascript code: * + * + * //Then you have to call the grid_html + * echo Display::grid_html('my_grid_name'); + * As you can see both function use the same "my_grid_name" this is very important otherwise nothing will work + * + * @param string the div id, this value must be the same with the first parameter of Display::grid_js() + * @return string html + * */ public static function grid_html($div_id){ $table = self::tag('table','',array('id'=>$div_id)); @@ -1005,6 +982,27 @@ class Display { } }); */ } + + public static function table($headers, $rows) { + /* + require_once api_get_path(LIBRARY_PATH).'pear/HTML/Table.php'; + $table = new HTML_Table(array('class' => 'data_table')); + $row = 0; + $column = 0; + + //Course headers + foreach ($headers as $item) { + $table->setHeaderContents($row, $column, $item); + $column++; + } + $row = 1; + $column = 0; + foreach($rows as $content) { + $table->setCellContents($row, $column, $content); + $column++; + } + return $table->toHtml();*/ + } /** diff --git a/main/inc/lib/search/search_widget.php b/main/inc/lib/search/search_widget.php index 6e017049c7..1ca6344664 100755 --- a/main/inc/lib/search/search_widget.php +++ b/main/inc/lib/search/search_widget.php @@ -1,8 +1,8 @@ $value) { - $temp[trim(stripslashes($value['name']))] = $key; + if (!empty($sf_term_array)) { + foreach ($sf_term_array as $key => $value) { + $temp[trim(stripslashes($value['name']))] = $key; + } } $temp = array_flip($temp); unset($sf_term_array); diff --git a/main/user/user.php b/main/user/user.php index 4f8b65604d..169f683ae7 100755 --- a/main/user/user.php +++ b/main/user/user.php @@ -17,7 +17,7 @@ * @todo convert normal table display to display function (refactor virtual course display function) * @todo display table functions need support for align and valign (e.g. to center text in cells) (this is now possible) * @author Roan Embrechts, refactoring + virtual courses support -* @author Julio Montoya Armas Several fixes +* @author Julio Montoya Armas, Several fixes * @package chamilo.user */ @@ -277,7 +277,7 @@ function show_users_in_virtual_courses() { } Display::display_table_row(null, $table_row, true); } - Display::display_table_footer(); + echo ''; } } @@ -307,28 +307,18 @@ if (isset($message)) { Display::display_confirmation_message($message); } -/* -============================================================================== - MAIN CODE -============================================================================== -*/ +/* MAIN CODE*/ //statistics event_access_tool(TOOL_USER); -/* --------------------------------------- - Setting the permissions for this page --------------------------------------- -*/ +/* Setting the permissions for this page */ $is_allowed_to_track = ($is_courseAdmin || $is_courseTutor) && $_configuration['tracking_enabled']; // Tool introduction Display::display_introduction_section(TOOL_USER, 'left'); - if ( api_is_allowed_to_edit(null, true)) { - echo "
"; // the action links @@ -365,9 +355,7 @@ if (1) // platform setting api_get_setting('subscribe_user_by_coach') { /* --------------------------------------- DISPLAY USERS LIST --------------------------------------- Also shows a "next page" button if there are more than 50 users. @@ -383,9 +371,7 @@ if (CourseManager::has_virtual_courses_from_code($course_id, $user_id)) { } /* -============================================================================== DISPLAY LIST OF USERS -============================================================================== */ /** * * Get the users to display on the current page. @@ -655,13 +641,10 @@ if (api_get_setting('allow_user_headings') == 'true' && $is_courseAdmin && api_i } //User list of the virtual courses linked to this course. -//show_users_in_virtual_courses($is_allowed_to_track); -/* -============================================================================== - FOOTER -============================================================================== -*/ +show_users_in_virtual_courses($is_allowed_to_track); + +/* FOOTER */ if ($origin != 'learnpath') { Display::display_footer(); -} +} \ No newline at end of file