Fixing group view

1.9.x
Julio Montoya 11 years ago
parent fc2e5c847e
commit 6063904fe5
  1. 75
      main/inc/lib/group_portal_manager.lib.php
  2. 1
      main/inc/lib/sortable_table.class.php
  3. 80
      main/social/search.php

@ -655,15 +655,21 @@ class GroupPortalManager
$result = Database::query($sql);
}
public static function get_all_group_tags($tag, $from = 0, $number_of_items = 10) {
/**
* @param $tag
* @param int $from
* @param int $number_of_items
* @param bool $getCount
* @return array
*/
public static function get_all_group_tags($tag, $from = 0, $number_of_items = 10, $getCount = false)
{
// database table definition
$group_table = Database::get_main_table(TABLE_MAIN_GROUP);
$table_tag = Database::get_main_table(TABLE_MAIN_TAG);
$table_group_tag_values = Database::get_main_table(TABLE_MAIN_GROUP_REL_TAG);
//default field_id == 1
$field_id = 5;
$tag = Database::escape_string($tag);
@ -671,58 +677,35 @@ class GroupPortalManager
$number_of_items = intval($number_of_items);
// all the information of the field
$sql = "SELECT g.id, g.name, g.description, g.picture_uri FROM $table_tag t INNER JOIN $table_group_tag_values tv ON (tv.tag_id=t.id)
INNER JOIN $group_table g ON(tv.group_id =g.id)
WHERE tag LIKE '$tag%' AND field_id= $field_id ORDER BY tag";
if ($getCount) {
$select = "SELECT count(DISTINCT g.id) count";
} else {
$select = " SELECT DISTINCT g.id, g.name, g.description, g.picture_uri ";
}
$sql = " $select
FROM $group_table g
LEFT JOIN $table_group_tag_values tv ON (g.id AND tv.group_id)
LEFT JOIN $table_tag t ON (tv.tag_id = t.id)
WHERE
tag LIKE '$tag%' AND field_id= $field_id OR
(
g.name LIKE '%".$tag."%' OR g.description LIKE '%".$tag."%' OR g.url LIKE '%".$tag."%'
$sql .= " LIMIT $from,$number_of_items";
)";
$sql .= " LIMIT $from, $number_of_items";
$result = Database::query($sql);
$return = array();
if (Database::num_rows($result) > 0) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
$return[$row['id']] = $row;
}
}
$keyword = $tag;
$sql = "SELECT g.id, g.name, g.description, g.url, g.picture_uri FROM $group_table g";
//@todo implement groups + multiple urls
/*
global $_configuration;
if ($_configuration['multiple_access_urls'] && api_get_current_access_url_id()!=-1) {
$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
} */
//@todo implement visibility
if (isset($keyword)) {
$sql .= " WHERE (g.name LIKE '%".$keyword."%' OR g.description LIKE '%".$keyword."%' OR g.url LIKE '%".$keyword."%' )";
}
$direction = 'ASC';
if (!in_array($direction, array('ASC', 'DESC'))) {
$direction = 'ASC';
if ($getCount) {
$row = Database::fetch_array($result, 'ASSOC');
return $row['count'];
}
//$column = intval($column);
$from = intval($from);
$number_of_items = intval($number_of_items);
//$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
while ($row = Database::fetch_array($res, 'ASSOC')) {
if (!in_array($row['id'], $return)) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
$return[$row['id']] = $row;
}
}
}
return $return;
}

@ -467,6 +467,7 @@ class SortableTable extends HTML_Table {
$empty_table = false;
$total = $this->get_total_number_of_items();
if ($this->get_total_number_of_items() == 0) {
$cols = $this->getColCount();
//$this->setCellAttributes(1, 0, 'style="font-style: italic;text-align:center;" colspan='.$cols);

@ -147,13 +147,19 @@ $social_right_content = '<div class="span9">'.UserManager::get_search_form($quer
if ($query != '') {
$itemPerPage = 9;
$page = isset($_GET['groups_page_nr']) ? intval($_GET['groups_page_nr']) : 1;
$total = UserManager::get_all_user_tags($_GET['q'], 0, 0, $itemPerPage, true);
$page = isset($_GET['users_page_nr']) ? intval($_GET['users_page_nr']) : 1;
$totalUsers = UserManager::get_all_user_tags($_GET['q'], 0, 0, $itemPerPage, true);
$from = intval(($page - 1) * $itemPerPage);
// Get users from tags
$users = UserManager::get_all_user_tags($_GET['q'], 0, $from, $itemPerPage);
$groups = GroupPortalManager::get_all_group_tags($_GET['q']);
$pageGroup = isset($_GET['groups_page_nr']) ? intval($_GET['groups_page_nr']) : 1;
// Groups
$fromGroups = intval(($pageGroup - 1) * $itemPerPage);
$totalGroups = GroupPortalManager::get_all_group_tags($_GET['q'], 0, $itemPerPage, true);
$groups = GroupPortalManager::get_all_group_tags($_GET['q'], $fromGroups, $itemPerPage);
if (empty($users) && empty($groups)) {
$social_right_content .= get_lang('SorryNoResults');
@ -169,7 +175,8 @@ if ($query != '') {
$relation_type = intval(SocialManager::get_relation_between_contacts(api_get_user_id(), $user['user_id']));
$user_info = api_get_user_info($user['user_id'], true);
$url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$user['user_id'];
//Show send invitation icon if they are not friends yet
// Show send invitation icon if they are not friends yet
if ($relation_type != 3 && $relation_type != 4 && $user['user_id'] != api_get_user_id()) {
$send_inv = '<a href="javascript:void(0);" onclick="javascript:send_invitation_to_user(\''.$user['user_id'].'\');"/>
<button class="btn btn-mini"><i class="icon-user"></i> '.get_lang('SendInvitation').'</button></a><br /><br />';
@ -225,17 +232,34 @@ if ($query != '') {
$social_right_content .= $results;
}
$visibility = array(true, true, true, true, true);
$social_right_content .= Display::return_sortable_grid(
'users',
null,
null,
array('hide_navigation' => false, 'per_page' => $itemPerPage),
$query_vars,
false,
$visibility,
true,
array(),
$totalUsers
);
$grid_groups = array();
if (is_array($groups) && count($groups) > 0) {
$social_right_content .= '<div class="span9">';
$social_right_content .= Display::page_subheader(get_lang('Groups'));
$social_right_content .= '<ul class="thumbnails">';
foreach ($groups as $group) {
$group['name'] = Security::remove_XSS($group['name'], STUDENT, true);
$group['description'] = Security::remove_XSS($group['description'], STUDENT, true);
$id = $group['id'];
$url_open = '<a href="groups.php?id='.$id.'" >';
$url_open = '<a href="groups.php?id='.$id.'">';
$url_close = '</a>';
$name = cut($group['name'], 25, true);
$name = cut($group['name'], 60, true);
$count_users_group = count(GroupPortalManager::get_all_users_by_group($id));
if ($count_users_group == 1) {
$count_users_group = $count_users_group.' '.get_lang('Member');
@ -244,30 +268,34 @@ if ($query != '') {
}
$picture = GroupPortalManager::get_picture_group($group['id'], $group['picture_uri'], 80);
$tags = GroupPortalManager::get_group_tags($group['id']);
$group['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';
$group['picture_uri'] = '<img src="'.$picture['file'].'" width="50" />';
$item_0 = Display::div($group['picture_uri'], array('class' => 'box_description_group_image'));
$members = Display::span($count_users_group, array('class' => 'box_description_group_member'));
$item_1 = Display::div(
Display::tag('h3', $url_open.$name.$url_close).$members,
array('class' => 'box_description_group_title')
);
$item_0 = Display::div($group['picture_uri']);
$members = Display::span($count_users_group);
$item_1 = Display::tag('h3', $url_open.$name.$url_close).$members;
$social_right_content .= '
<li class="span8">
<div class="row-fluid">
<div class="span1">
<div class="media">
'.$item_0.'
</div>
</div>
<div class="span6">
'.$item_1.'
<p>'.$group['description'].'</p>
<p>'.$tags.'</p>
<p>'.$url_open.get_lang('SeeMore').$url_close.'</p>
</div>
</div>
</li>';
$item_2 = '';
$item_3 = '';
if ($group['description'] != '') {
$item_3 = '<div class="box_description_group_content" >'.cut($group['description'], 100, true).'</div>';
} else {
$item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>';
$item_3 = '<div class="box_description_group_content" ></div>';
}
$item_4 = '<div class="box_description_group_tags">'.$tags.'</div>';
$item_5 = '<div class="box_description_group_actions" >'.$url_open.get_lang('SeeMore').$url_close.'</div>';
$grid_item_2 = $item_0.$item_1.$item_2.$item_3.$item_4.$item_5;
$grid_groups[] = array('', $grid_item_2);
}
$social_right_content .= '</ul></div></div>';
}
$visibility = array(true, true, true, true, true);
$social_right_content .= Display::return_sortable_grid(
'groups',
@ -279,7 +307,7 @@ if ($query != '') {
$visibility,
true,
array(),
$total
$totalGroups
);
}
$social_right_content .= MessageManager::generate_message_form('send_message');

Loading…
Cancel
Save