Adding delete topic links see #5203

skala
Julio Montoya 13 years ago
parent 34f0dcca97
commit f33d9c855e
  1. 3
      main/css/base.css
  2. 85
      main/inc/lib/message.lib.php
  3. 6
      main/social/group_topics.php

@ -2548,7 +2548,8 @@ div.admin_section h4 {
}
.topics_grid_item {
/* margin-left:20px; */
border-bottom: 1px solid #CCCCCC;
margin-bottom: 20px;
}
#div_content_table {

@ -885,7 +885,8 @@ class MessageManager
* @param int group id
*/
public static function display_messages_for_group($group_id) {
global $my_group_role;
global $my_group_role;
$rows = self::get_messages_by_group($group_id);
$topics_per_page = 10;
$html_messages = '';
@ -904,7 +905,7 @@ class MessageManager
$new_topics = array();
foreach($topics as $id => $value) {
foreach ($topics as $id => $value) {
$rows = null;
$rows = self::get_messages_by_group_by_message($group_id, $value['id']);
if (!empty($rows)) {
@ -922,43 +923,59 @@ class MessageManager
foreach ($new_topics as $index => $topic) {
$html = '';
// topics
$indent = 0;
//$indent = 0;
$user_sender_info = UserManager::get_user_info_by_id($topic['user_sender_id']);
$files_attachments = self::get_links_message_attachment_files($topic['id']);
//$files_attachments = self::get_links_message_attachment_files($topic['id']);
$name = api_get_person_name($user_sender_info['firstname'], $user_sender_info['lastname']);
$html .= '<div class="topic_div">';
$html .= '<div class="row">';
$items = $topic['count'];
$reply_label = ($items == 1) ? get_lang('GroupReply'): get_lang('GroupReplies');
$html .= '<table width="100%"><tr><td width="20px" valign="top">';
$html .= Display::div(Display::tag('span', $items).$reply_label, array('class' =>'group_discussions_replies'));
$html .= '</td><td width="150px" valign="top">';
$topic['title'] = trim($topic['title']);
if (empty($topic['title'])) {
$topic['title'] = get_lang('Untitled');
}
$title = Display::tag('h4', Display::url(Security::remove_XSS($topic['title'], STUDENT, true), 'group_topics.php?id='.$group_id.'&topic_id='.$topic['id']));
$date = '';
$link = '';
if ($topic['send_date']!=$topic['update_date']) {
if (!empty($topic['update_date']) && $topic['update_date'] != '0000-00-00 00:00:00' ) {
$date .= '<div class="message-group-date" > <i>'.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']).'</i></div>';
}
} else {
$items = $topic['count'];
$reply_label = ($items == 1) ? get_lang('GroupReply'): get_lang('GroupReplies');
$html .= '<div class="span1">';
$html .= Display::div(Display::tag('span', $items).$reply_label, array('class' =>'group_discussions_replies'));
$html .= '</div>';
$topic['title'] = trim($topic['title']);
if (empty($topic['title'])) {
$topic['title'] = get_lang('Untitled');
}
$html .= '<div class="span4">';
$html .= Display::tag('h4', Display::url(Security::remove_XSS($topic['title'], STUDENT, true), 'group_topics.php?id='.$group_id.'&topic_id='.$topic['id']));
if ($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR) {
$actions = '<br />'.Display::url(get_lang('Delete'), api_get_path(WEB_CODE_PATH).'social/group_topics.php?action=delete&id='.$group_id.'&topic_id='.$topic['id'], array('class' => 'btn'));
}
$date = '';
if ($topic['send_date']!=$topic['update_date']) {
if (!empty($topic['update_date']) && $topic['update_date'] != '0000-00-00 00:00:00' ) {
$date .= '<div class="message-group-date" > <i>'.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']).'</i></div>';
}
} else {
$date .= '<div class="message-group-date"> <i>'.get_lang('Created').' '.date_to_str_ago($topic['send_date']).'</i></div>';
}
$image_path = UserManager::get_user_picture_path_by_id($topic['user_sender_id'], 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
$user_info = '<td valign="top"><a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$topic['user_sender_id'].'">'.$name.'&nbsp;</a>';
$user_info .= '<div class="message-group-author"><img src="'.$image_repository.$existing_image.'" alt="'.$name.'" width="32" height="32" title="'.$name.'" /></div>';
$user_info .= '<div class="message-group-author">'.$user.'</div></td>';
//$date.
$html .= Display::div($title.Security::remove_XSS(cut($topic['content'], 150), STUDENT, true).$user_info, array('class'=>'group_discussions_info')).'</td></table>';
}
$html .= $date.$actions;
$html .= '</div>';
$image_path = UserManager::get_user_picture_path_by_id($topic['user_sender_id'], 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
$user_info = '<td valign="top"><a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$topic['user_sender_id'].'">'.$name.'&nbsp;</a>';
$user_info .= '<div class="message-group-author"><img src="'.$image_repository.$existing_image.'" alt="'.$name.'" width="32" height="32" title="'.$name.'" /></div>';
$user_info .= '</td>';
$html .= '<div class="span2">';
$html .= $user_info;
$html .= '</div>';
//group_topics.php?action=delete&id=3&topic_id=6
//$date.
//$html .= Display::div($title.Security::remove_XSS(cut($topic['content'], 150), STUDENT, true).$user_info, array('class'=>'group_discussions_info')).' </tr> '.$actions.'</table>';
$html .= '</div>'; //rounded_div

@ -37,10 +37,12 @@ if (empty($group_id)) {
}
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') {
if (api_is_platform_admin()) {
$group_role = GroupPortalManager::get_user_group_role(api_get_user_id(), $group_id);
if (api_is_platform_admin() || in_array($group_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
GroupPortalManager::delete_topic($group_id, $topic_id);
header("Location: groups.php?id=$group_id&action=show_message&msg=topic_deleted");
}
}
}
// save message group

Loading…
Cancel
Save