Minor - Fixing group ordering

skala
Julio Montoya 13 years ago
parent 15f73cd1e7
commit 6c7540c478
  1. 2
      main/inc/lib/display.lib.php
  2. 18
      main/inc/lib/message.lib.php
  3. 26
      main/inc/lib/sortabletable.class.php
  4. 9
      main/social/group_topics.php

@ -228,6 +228,7 @@ class Display {
* @param mixed An array with bool values to know which columns show. i.e: $visibility_options= array(true, false) we will only show the first column * @param mixed An array with bool values to know which columns show. i.e: $visibility_options= array(true, false) we will only show the first column
* Can be also only a bool value. TRUE: show all columns, FALSE: show nothing * Can be also only a bool value. TRUE: show all columns, FALSE: show nothing
* @param bool true for sorting data or false otherwise * @param bool true for sorting data or false otherwise
* @param array grid classes
* @return string html grid * @return string html grid
*/ */
public static function return_sortable_grid($name, $header, $content, $paging_options = array(), $query_vars = null, $form_actions = array(), $visibility_options = true, $sort_data = true, $grid_class = array()) { public static function return_sortable_grid($name, $header, $content, $paging_options = array(), $query_vars = null, $form_actions = array(), $visibility_options = true, $sort_data = true, $grid_class = array()) {
@ -235,7 +236,6 @@ class Display {
$column = 0; $column = 0;
$default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20; $default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20;
$table = new SortableTableFromArray($content, $column, $default_items_per_page, $name); $table = new SortableTableFromArray($content, $column, $default_items_per_page, $name);
if (is_array($query_vars)) { if (is_array($query_vars)) {
$table->set_additional_parameters($query_vars); $table->set_additional_parameters($query_vars);
} }

@ -1003,9 +1003,8 @@ class MessageManager
$main_message = self::get_message_by_id($topic_id); $main_message = self::get_message_by_id($topic_id);
$group_info = GroupPortalManager::get_group_data($group_id); $group_info = GroupPortalManager::get_group_data($group_id);
$rows = self::get_messages_by_group_by_message($group_id, $topic_id); $rows = self::get_messages_by_group_by_message($group_id, $topic_id);
$rows = self::calculate_children($rows, $topic_id); $rows = self::calculate_children($rows, $topic_id);
$current_user_id = api_get_user_id(); $current_user_id = api_get_user_id();
@ -1014,8 +1013,7 @@ class MessageManager
$count_items = 0; $count_items = 0;
$html_messages = ''; $html_messages = '';
$query_vars = array('id'=>$group_id, 'topic_id'=>$topic_id , 'topics_page_nr'=>0); $query_vars = array('id' => $group_id, 'topic_id' => $topic_id , 'topics_page_nr' => 0);
// Main message // Main message
$html = ''; $html = '';
@ -1027,6 +1025,7 @@ class MessageManager
$items_page_nr = null; $items_page_nr = null;
echo Display::tag('h3', Security::remove_XSS($main_message['title'], STUDENT, true)); echo Display::tag('h3', Security::remove_XSS($main_message['title'], STUDENT, true));
$user_sender_info = UserManager::get_user_info_by_id($main_message['user_sender_id']); $user_sender_info = UserManager::get_user_info_by_id($main_message['user_sender_id']);
$files_attachments = self::get_links_message_attachment_files($main_message['id']); $files_attachments = self::get_links_message_attachment_files($main_message['id']);
$name = api_get_person_name($user_sender_info['firstname'], $user_sender_info['lastname']); $name = api_get_person_name($user_sender_info['firstname'], $user_sender_info['lastname']);
@ -1067,7 +1066,8 @@ class MessageManager
if (is_array($rows) && count($rows)> 0) { if (is_array($rows) && count($rows)> 0) {
$topics = $rows; $topics = $rows;
$array_html = array(); $array_html = array();
foreach ($topics as $index => $topic) { foreach ($topics as $index => $topic) {
if (empty($topic['id'])) { if (empty($topic['id'])) {
continue; continue;
@ -1123,12 +1123,12 @@ class MessageManager
$array_html_items[] = array($html_items); $array_html_items[] = array($html_items);
} }
// grids for items with paginations // grids for items with paginations
$options = array('hide_navigation'=>false, 'per_page' => $items_per_page); $options = array('hide_navigation' => false, 'per_page' => $items_per_page);
$order = array(true, true, true,false); $visibility = array(true, true, true, false);
$style_class = array('item' => array('class'=>'group_social_item'), 'main' => array('class'=>'group_social_grid')); $style_class = array('item' => array('class'=>'group_social_item'), 'main' => array('class'=>'group_social_grid'));
if (!empty($array_html_items)) { if (!empty($array_html_items)) {
$html .= Display::return_sortable_grid('items_'.$topic['id'], array(), $array_html_items, $options, $query_vars, false, $order, false, $style_class); $html .= Display::return_sortable_grid('items_'.$topic['id'], array(), $array_html_items, $options, $query_vars, null, $visibility, false, $style_class);
} }
} }
$html .= '</div>'; $html .= '</div>';

@ -482,10 +482,10 @@ class SortableTable extends HTML_Table {
} }
if ($hide_navigation) { if ($hide_navigation) {
$items = $this->table_data; // This is a faster way to get what we want $items = $this->table_data; // This is a faster way to get what we want
} else { } else {
// The normal way // The normal way
$items = $this->get_clean_html($sort_data); // Getting the items of the table $items = $this->get_clean_html($sort_data); // Getting the items of the table
} }
// Generation of style classes must be improved. Maybe we need a a table name to create style on the fly: // Generation of style classes must be improved. Maybe we need a a table name to create style on the fly:
@ -545,11 +545,13 @@ class SortableTable extends HTML_Table {
* Get the HTML-code with the data-table. * Get the HTML-code with the data-table.
*/ */
public function get_table_html () { public function get_table_html () {
$pager = $this->get_pager(); $pager = $this->get_pager();
$val = $pager->getOffsetByPageId(); $val = $pager->getOffsetByPageId();
$offset = $pager->getOffsetByPageId(); $offset = $pager->getOffsetByPageId();
$from = $offset[0] - 1; $from = $offset[0] - 1;
$table_data = $this->get_table_data($from); $table_data = $this->get_table_data($from);
if (is_array($table_data)) { if (is_array($table_data)) {
foreach ($table_data as $index => & $row) { foreach ($table_data as $index => & $row) {
$row = $this->filter_data($row); $row = $this->filter_data($row);
@ -576,8 +578,8 @@ class SortableTable extends HTML_Table {
$val = $pager->getOffsetByPageId(); $val = $pager->getOffsetByPageId();
$offset = $pager->getOffsetByPageId(); $offset = $pager->getOffsetByPageId();
$from = $offset[0] - 1; $from = $offset[0] - 1;
$table_data = $this->get_table_data($from, $sort); $table_data = $this->get_table_data($from, null, null, null, $sort);
$new_table_data = array(); $new_table_data = array();
if (is_array($table_data)) { if (is_array($table_data)) {
@ -868,7 +870,7 @@ class SortableTableFromArray extends SortableTable {
* Get table data to show on current page * Get table data to show on current page
* @see SortableTable#get_table_data * @see SortableTable#get_table_data
*/ */
public function get_table_data ($from = 1, $per_page = null, $column = null, $direction = null, $sort = true) { public function get_table_data($from = 1, $per_page = null, $column = null, $direction = null, $sort = true) {
if ($sort) { if ($sort) {
$content = TableSort :: sort_table($this->table_data, $this->column, $this->direction == 'ASC' ? SORT_ASC : SORT_DESC); $content = TableSort :: sort_table($this->table_data, $this->column, $this->direction == 'ASC' ? SORT_ASC : SORT_DESC);
} else { } else {
@ -937,7 +939,7 @@ class SortableTableFromArrayConfig extends SortableTable {
* Get table data to show on current page * Get table data to show on current page
* @see SortableTable#get_table_data * @see SortableTable#get_table_data
*/ */
public function get_table_data ($from = 1, $per_page = null, $column = null, $direction = null, $sort = true) { public function get_table_data ($from = 1, $per_page = null, $column = null, $direction = null, $sort = true) {
$content = TableSort :: sort_table_config($this->table_data, $this->column, $this->direction == 'ASC' ? SORT_ASC : SORT_DESC, $this->column_show, $this->column_order, SORT_REGULAR, $this->doc_filter); $content = TableSort :: sort_table_config($this->table_data, $this->column, $this->direction == 'ASC' ? SORT_ASC : SORT_DESC, $this->column_show, $this->column_order, SORT_REGULAR, $this->doc_filter);
return array_slice($content, $from, $this->per_page); return array_slice($content, $from, $this->per_page);
} }

@ -36,8 +36,6 @@ if (empty($group_id)) {
} }
} }
// save message group // save message group
if (isset($_POST['token']) && $_POST['token'] === $_SESSION['sec_token']) { if (isset($_POST['token']) && $_POST['token'] === $_SESSION['sec_token']) {
@ -166,13 +164,12 @@ $(document).ready(function() {
</script>'; </script>';
$this_section = SECTION_SOCIAL; $this_section = SECTION_SOCIAL;
$interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social')); $interbreadcrumb[]= array ('url' =>'home.php', 'name' => get_lang('Social'));
$interbreadcrumb[] = array('url' => 'groups.php','name' => get_lang('Groups')); $interbreadcrumb[] = array('url' => 'groups.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => '#','name' => get_lang('Thread')); $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Thread'));
Display::display_header($tool_name, 'Groups'); Display::display_header($tool_name, 'Groups');
echo '<div id="social-content">'; echo '<div id="social-content">';
echo '<div id="social-content-left">'; echo '<div id="social-content-left">';
//this include the social menu div //this include the social menu div

Loading…
Cancel
Save