Fixing a SQL query + fixing PHP notice and minor fix in the group topic layout

skala
Julio Montoya 12 years ago
parent c4f2782c41
commit 60780e8f12
  1. 17
      main/inc/lib/message.lib.php
  2. 9
      main/inc/lib/usergroup.lib.php
  3. 47
      main/social/group_invitation.php
  4. 10
      main/social/group_topics.php
  5. 36
      main/social/invitations.php

@ -1100,8 +1100,6 @@ class MessageManager
$query_vars = array('id' => $group_id, 'topic_id' => $topic_id, 'topics_page_nr' => 0);
// Main message
$user_link = '';
$links = '';
$main_content = '';
@ -1116,7 +1114,7 @@ class MessageManager
'group_topics.php?action=delete&id='.$group_id.'&topic_id='.$topic_id
);
}
$html .= Display::page_subheader(Security::remove_XSS($main_message['title'].$delete_button, STUDENT, true));
$html .= Display::page_subheader2(Security::remove_XSS($main_message['title'].$delete_button, STUDENT, true));
$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']);
@ -1125,19 +1123,10 @@ class MessageManager
$topic_page_nr = isset($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : null;
$links .= '<div id="message-reply-link">';
if (($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR) || $main_message['user_sender_id'] == $current_user_id) {
$links .= '<a class="ajax btn" href="'.api_get_path(
WEB_CODE_PATH
).'social/message_for_group_form.inc.php?view_panel=1&height=390&width=610&&user_friend='.$current_user_id.'&group_id='.$group_id.'&message_id='.$main_message['id'].'&action=edit_message_group&anchor_topic=topic_'.$main_message['id'].'&topics_page_nr='.$topic_page_nr.'&items_page_nr='.$items_page_nr.'&topic_id='.$main_message['id'].'" class="group_message_popup" title="'.get_lang(
'Edit'
).'">';
$links .= '<a class="ajax btn" href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=390&width=610&&user_friend='.$current_user_id.'&group_id='.$group_id.'&message_id='.$main_message['id'].'&action=edit_message_group&anchor_topic=topic_'.$main_message['id'].'&topics_page_nr='.$topic_page_nr.'&items_page_nr='.$items_page_nr.'&topic_id='.$main_message['id'].'" class="group_message_popup" title="'.get_lang('Edit').'">';
$links .= get_lang('Edit').'</a>';
}
$links .= '&nbsp;&nbsp;<a class="ajax btn btn-primary" href="'.api_get_path(
WEB_CODE_PATH
).'social/message_for_group_form.inc.php?view_panel=1&height=390&width=610&&user_friend='.api_get_user_id(
).'&group_id='.$group_id.'&message_id='.$main_message['id'].'&action=reply_message_group&anchor_topic=topic_'.$main_message['id'].'&topics_page_nr='.$topic_page_nr.'&items_page_nr='.$items_page_nr.'&topic_id='.$main_message['id'].'" class="group_message_popup" title="'.get_lang(
'Reply'
).'">';
$links .= '&nbsp;&nbsp;<a class="ajax btn btn-primary" href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=390&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&message_id='.$main_message['id'].'&action=reply_message_group&anchor_topic=topic_'.$main_message['id'].'&topics_page_nr='.$topic_page_nr.'&items_page_nr='.$items_page_nr.'&topic_id='.$main_message['id'].'" class="group_message_popup" title="'.get_lang('Reply').'">';
$links .= get_lang('Reply').'</a>';
$links .= '</div>';

@ -816,7 +816,12 @@ class UserGroup extends Model
$where_relation_condition = "AND gu.relation_type = $relation_type ";
}
$sql = "SELECT g.picture, g.name, g.description, g.id , gu.relation_type
$sql = "SELECT
g.picture,
g.name,
g.description,
g.id ,
gu.relation_type
FROM $tbl_group g
INNER JOIN $table_group_rel_user gu
ON gu.usergroup_id = g.id
@ -824,7 +829,7 @@ class UserGroup extends Model
gu.user_id = $user_id $where_relation_condition
ORDER BY created_on desc ";
$result=Database::query($sql);
$result = Database::query($sql);
$array = array();
if (Database::num_rows($result) > 0) {
while ($row = Database::fetch_array($result, 'ASSOC')) {

@ -262,34 +262,53 @@ if ($ajax_search) {
}
} else {
$friends = SocialManager::get_friends(api_get_user_id());
$suggest_friends = false;
$Users = array();
if (!$friends) {
$suggest_friends = true;
} else {
foreach($friends as $friend) {
foreach ($friends as $friend) {
$group_friend_list = $usergroup->get_groups_by_user($friend['friend_user_id'], 0);
//var_dump($group_friend_list);
$friend_group_id = '';
if (isset($group_friend_list[$group_id]) && $group_friend_list[$group_id]['id'] == $group_id) {
$friend_group_id = $group_id;
}
//var_dump ($group_friend_list[$group_id]['relation_type']);
if ($group_friend_list[$group_id]['relation_type'] == '' ) {
$Users[$friend['friend_user_id']]=array('user_id' => $friend['friend_user_id'], 'firstname' =>$friend['firstName'], 'lastname' => $friend['lastName'], 'username' =>$friend['username'],'group_id'=>$friend_group_id );
}
if (!empty($group_friend_list)) {
$friend_group_id = '';
if (isset($group_friend_list[$group_id]) && $group_friend_list[$group_id]['id'] == $group_id) {
$friend_group_id = $group_id;
}
//var_dump ($group_friend_list[$group_id]['relation_type']);
if ($group_friend_list[$group_id]['relation_type'] == '' ) {
$Users[$friend['friend_user_id']]= array(
'user_id' => $friend['friend_user_id'],
'firstname' => $friend['firstName'],
'lastname' => $friend['lastName'],
'username' => $friend['username'],
'group_id' => $friend_group_id
);
}
} else {
$Users[$friend['friend_user_id']]= array(
'user_id' => $friend['friend_user_id'],
'firstname' =>$friend['firstName'],
'lastname' => $friend['lastName'],
'username' =>$friend['username'],
'group_id' => null
);
}
}
}
if (is_array($Users) && count($Users) > 0 ) {
foreach ($Users as $user) {
if($user['group_id'] != $group_id)
if ($user['group_id'] != $group_id) {
$nosessionUsersList[$user['user_id']] = $user ;
}
}
}
//deleting anonymous users
$user_anonymous = api_get_anonymous_id();
foreach($nosessionUsersList as $key_user_list =>$value_user_list) {
foreach ($nosessionUsersList as $key_user_list =>$value_user_list) {
if ($nosessionUsersList[$key_user_list]['user_id']==$user_anonymous) {
unset($nosessionUsersList[$key_user_list]);
}
@ -311,7 +330,7 @@ if (count($nosessionUsersList) == 0) {
if ($friends == 0) {
$social_right_content .= get_lang('YouNeedToHaveFriendsInYourSocialNetwork');
} else {
$social_right_content .= get_lang('YouAlreadyInviteAllYourContacts');
$social_right_content .= get_lang('YouAlreadyInviteAllYourContacts');
}
$social_right_content .= '<div>';
$social_right_content .= '<a href="search.php">'.get_lang('TryAndFindSomeFriends').'</a>';
@ -445,7 +464,7 @@ if (is_array($members) && count($members)>0) {
$member['image'] = '<img src="'.$picture['file'].'" width="50px" height="50px" />';
}
$social_right_content .= '<h3>'.get_lang('UsersAlreadyInvited').'</h3>';
$social_right_content .= Display::return_sortable_grid('invitation_profile', array(), $members, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, false, true,true));
$social_right_content .= Display::return_sortable_grid('invitation_profile', array(), $members, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, false, true,true));
}
$htmlHeadXtra[] = '<script>

@ -160,11 +160,11 @@ $(document).ready(function() {
url,
{},
function(responseText, textStatus, XMLHttpRequest) {
dialog.dialog({
modal : true,
width : 520,
height : 400,
});
dialog.dialog({
modal : true,
width : 520,
height : 400,
});
});
//prevent the browser to follow the link
return false;

@ -131,9 +131,9 @@ if ($number_loop != 0) {
'.get_lang('DateSend').' : '.$date.'
</div>
<div class="buttons">
<button class="save" name="btn_accepted" type="submit" id="btn_accepted_'.$sender_user_id.'" value="'.get_lang('Accept').' "onclick="javascript:register_friend(this)">
<button class="btn btn-primary" name="btn_accepted" type="submit" id="btn_accepted_'.$sender_user_id.'" value="'.get_lang('Accept').' "onclick="javascript:register_friend(this)">
'.get_lang('Accept').'</button>
<button class="cancel" name="btn_denied" type="submit" id="btn_deniedst_'.$sender_user_id.' " value="'.get_lang('Deny').' " onclick="javascript:denied_friend(this)" >
<button class="btn btn-danger" name="btn_denied" type="submit" id="btn_deniedst_'.$sender_user_id.' " value="'.get_lang('Deny').' " onclick="javascript:denied_friend(this)" >
'.get_lang('Deny').'</button>
</div>
</div>
@ -156,19 +156,15 @@ if (count($list_get_invitation_sent) > 0 ) {
$content = Security::remove_XSS($invitation['content'], STUDENT, true);
$date = api_convert_and_format_date($invitation['send_date'], DATE_TIME_FORMAT_LONG);
$social_right_content .= '
<div class="span2">
<a class="thumbnail" href="profile.php?u='.$sender_user_id.'">
<img src="'.$friends_profile['file'].'" /></a>
</div>
<div class="span3">
<a class="profile_link" href="profile.php?u='.$sender_user_id.'">'.api_get_person_name($user_info['firstName'], $user_info['lastName']).'</a>
<div>
'. $title.' : '.$content.'
</div>
<div>
'. get_lang('DateSend').' : '.$date.'
</div>
</div>
<div class="span2">
<a class="thumbnail" href="profile.php?u='.$sender_user_id.'">
<img src="'.$friends_profile['file'].'" /></a>
</div>
<div class="span3">
<a class="profile_link" href="profile.php?u='.$sender_user_id.'">'.$user_info['complete_name'].'</a>
<div>'. $title.' : '.$content.'</div>
<div>'. get_lang('DateSend').' : '.$date.'</div>
</div>
</div>';
}
}
@ -182,14 +178,16 @@ if (count($pending_invitations) > 0) {
$invitation['picture'] = '<a href="groups.php?id='.$invitation['id'].'">'.$img.'</a>';
$invitation['name'] = '<a href="groups.php?id='.$invitation['id'].'">'.Text::cut($invitation['name'],120,true).'</a>';
$invitation['join'] = '<a href="invitations.php?accept='.$invitation['id'].'">'.Display::return_icon('accept_invitation.png', get_lang('AcceptInvitation')).'&nbsp;&nbsp;'.get_lang('AcceptInvitation').'</a>';
$invitation['deny'] = '<a href="invitations.php?deny='.$invitation['id'].'">'.Display::return_icon('denied_invitation.png', get_lang('DenyInvitation')).'&nbsp;&nbsp;'.get_lang('DenyInvitation').'</a>';
$invitation['join'] = '<a class="btn btn-primary" href="invitations.php?accept='.$invitation['id'].'">'.get_lang('AcceptInvitation').'</a>';
$invitation['deny'] = '<a class="btn btn-danger" href="invitations.php?deny='.$invitation['id'].'">'.get_lang('DenyInvitation').'</a>';
$invitation['description'] = Text::cut($invitation['description'],220,true);
$new_invitation[]=$invitation;
$new_invitation[] = $invitation;
}
$social_right_content .= Display::return_sortable_grid('waiting_user', array(), $new_invitation, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false,false,true,true,true,true));
$social_right_content .= Display::return_sortable_grid('waiting_user', array(), $new_invitation, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,false,false,true,true,true,true));
}
$social_right_content = Display::div($social_right_content, array('class' => 'span9'));
$tpl = new Template(null);
$tpl->assign('social_left_content', $social_left_content);
$tpl->assign('social_right_content', $social_right_content);

Loading…
Cancel
Save