added messages with replay for group into social network - partial DT#5611

skala
Cristian Fasanando 16 years ago
parent 69dbac9fc2
commit 1836a9ff0f
  1. 5
      main/install/dokeos_main.sql
  2. 6
      main/install/migrate-db-1.8.6.1-1.8.6.2-pre.sql
  3. 211
      main/messages/message.class.php
  4. 127
      main/messages/new_message.php
  5. 40
      main/social/groups.php

@ -2168,12 +2168,15 @@ CREATE TABLE message(
send_date datetime not null default '0000-00-00 00:00:00',
title varchar(255) not null,
content text not null,
group_id int unsigned not null default 0,
parent_id int unsigned not null default 0,
PRIMARY KEY(id)
);
ALTER TABLE message ADD INDEX idx_message_user_sender(user_sender_id);
ALTER TABLE message ADD INDEX idx_message_user_receiver(user_receiver_id);
ALTER TABLE message ADD INDEX idx_message_user_sender_user_receiver(user_sender_id,user_receiver_id);
ALTER TABLE message ADD INDEX idx_message_msg_status(msg_status);
ALTER TABLE message ADD INDEX idx_message_group(group_id);
ALTER TABLE message ADD INDEX idx_message_parent(parent_id);
INSERT INTO user_friend_relation_type (id,title)
VALUES

@ -79,4 +79,8 @@ ALTER TABLE group_info ADD COLUMN chat_state TINYINT DEFAULT 1, ADD INDEX (chat_
ALTER TABLE group_category ADD COLUMN chat_state TINYINT DEFAULT 1, ADD INDEX (chat_state);
ALTER TABLE student_publication ADD COLUMN weight float(6,2) UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE course_description ADD COLUMN description_type TINYINT NOT NULL DEFAULT 0;
ALTER TABLE dropbox_category ADD COLUMN session_id smallint NOT NULL DEFAULT 0, ADD INDEX (session_id);
ALTER TABLE dropbox_category ADD COLUMN session_id smallint NOT NULL DEFAULT 0, ADD INDEX (session_id);
ALTER TABLE message ADD COLUMN group_id INT NOT NULL DEFAULT 0;
ALTER TABLE message ADD COLUMN parent_id INT NOT NULL DEFAULT 0;
ALTER TABLE message ADD INDEX idx_message_group(group_id);
ALTER TABLE message ADD INDEX idx_message_parent(parent_id);

@ -154,26 +154,29 @@ class MessageManager
return $message_list;
}
public static function send_message ($receiver_user_id, $title, $content, $file_attachments, $file_comments) {
public static function send_message ($receiver_user_id, $title, $content, $file_attachments = array(), $file_comments = '', $group_id = 0, $parent_id = 0) {
global $charset;
if (is_numeric($receiver_user_id)) {
$table_message = Database::get_main_table(TABLE_MESSAGE);
$table_message = Database::get_main_table(TABLE_MESSAGE);
$group_id = intval($group_id);
$receiver_user_id = intval($receiver_user_id);
$parent_id = intval($parent_id);
if (is_numeric($receiver_user_id)) {
$title = api_convert_encoding($title,$charset,'UTF-8');
$content = api_convert_encoding($content,$charset,'UTF-8');
//message in inbox
$sql = "SELECT COUNT(*) as count FROM $table_message WHERE user_sender_id = ".api_get_user_id()." AND user_receiver_id='".Database::escape_string($receiver_user_id)."' AND title = '".Database::escape_string($title)."' AND content ='".Database::escape_string($content)."' ";
$content = api_convert_encoding($content,$charset,'UTF-8');
$sql = "SELECT COUNT(*) as count FROM $table_message WHERE user_sender_id = ".api_get_user_id()." AND user_receiver_id='$receiver_user_id' AND title = '".Database::escape_string($title)."' AND content ='".Database::escape_string($content)."' AND group_id='$group_id' AND parent_id='$parent_id'";
$res_exist = Database::query($sql,__FILE__,__LINE__);
$row_exist = Database::fetch_array($res_exist,'ASSOC');
if ($row_exist['count'] ==0) {
if ($row_exist['count'] ==0) {
//message in outbox
$sql = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content ) ".
$sql = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id) ".
" VALUES (".
"'".api_get_user_id()."', '".Database::escape_string($receiver_user_id)."', '4', '".date('Y-m-d H:i:s')."','".Database::escape_string($title)."','".Database::escape_string($content)."'".
"'".api_get_user_id()."', '".Database::escape_string($receiver_user_id)."', '4', '".date('Y-m-d H:i:s')."','".Database::escape_string($title)."','".Database::escape_string($content)."','$group_id','$parent_id'".
")";
$rs = Database::query($sql,__FILE__,__LINE__);
$outbox_last_id = Database::insert_id();
$outbox_last_id = Database::insert_id();
// save attachment file for outbox messages
if (is_array($file_attachments)) {
$o = 0;
@ -184,15 +187,13 @@ class MessageManager
$o++;
}
}
//message in inbox
$query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content ) ".
//message in inbox
$query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id ) ".
" VALUES (".
"'".api_get_user_id()."', '".Database::escape_string($receiver_user_id)."', '1', '".date('Y-m-d H:i:s')."','".Database::escape_string($title)."','".Database::escape_string($content)."'".
"'".api_get_user_id()."', '".Database::escape_string($receiver_user_id)."', '1', '".date('Y-m-d H:i:s')."','".Database::escape_string($title)."','".Database::escape_string($content)."','$group_id','$parent_id'".
")";
$result = Database::query($query,__FILE__,__LINE__);
$inbox_last_id = Database::insert_id();
// save attachment file for inbox messages
if (is_array($file_attachments)) {
$i = 0;
@ -205,8 +206,6 @@ class MessageManager
}
return $result;
}
} else {
return false;
}
return false;
@ -262,66 +261,71 @@ class MessageManager
return false;
}
/**
* Save message attachment file
* @param array contain info about uploaded file
* @param string a comment about the file
* @param int message id
* @param int receiver user id
* @param int sender user id
* @return void
*/
public static function save_message_attachment_file($file_attach,$file_comment,$message_id,$receiver_user_id=0,$sender_user_id=0) {
$tbl_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT);
// Try to add an extension to the file if it hasn't one
$new_file_name = add_ext_on_mime(stripslashes($file_attach['name']), $file_attach['type']);
$new_file_name = add_ext_on_mime(stripslashes($file_attach['name']), $file_attach['type']);
// user's file name
$file_name =$file_attach['name'];
$file_name =$file_attach['name'];
if (!filter_extension($new_file_name)) {
Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
} else {
$new_file_name = uniqid('');
$message_user_id = '';
if (!empty($receiver_user_id)) {
$message_user_id = $receiver_user_id;
} else {
$message_user_id = $sender_user_id;
}
}
// User-reserved directory where photos have to be placed.
$path_user_info = UserManager::get_user_picture_path_by_id($message_user_id, 'system', true);
$path_message_attach = $path_user_info['dir'].'message_attachments/';
$path_message_attach = $path_user_info['dir'].'message_attachments/';
// If this directory does not exist - we create it.
if (!file_exists($path_message_attach)) {
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm) ? $perm : '0770');
@mkdir($path_message_attach, $perm, true);
}
$new_path=$path_message_attach.$new_file_name;
if (!empty($receiver_user_id)) {
$result= @copy($file_attach['tmp_name'], $new_path);
} else {
$result= @move_uploaded_file($file_attach['tmp_name'], $new_path);
}
$safe_file_comment= Database::escape_string($file_comment);
$safe_file_name = Database::escape_string($file_name);
$safe_new_file_name = Database::escape_string($new_file_name);
$safe_new_file_name = Database::escape_string($new_file_name);
// Storing the attachments if any
$sql="INSERT INTO $tbl_message_attach(filename,comment, path,message_id,size)
VALUES ( '$safe_file_name', '$safe_file_comment', '$safe_new_file_name' , '$message_id', '".$file_attach['size']."' )";
$result=Database::query($sql, __LINE__, __FILE__);
$message.=' / '.get_lang('FileUploadSucces').'<br />';
$result=Database::query($sql, __LINE__, __FILE__);
}
}
/**
* Delete message attachment file (logicaly updating the row with a suffix _DELETE_id)
* @param int message id
* @param int message user id (receiver user id or sender user id)
* @return void
*/
public static function delete_message_attachment_file($message_id,$message_uid) {
$message_id = intval($message_id);
$message_uid = intval($message_uid);
$table_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT);
$sql= "SELECT * FROM $table_message_attach WHERE message_id = '$message_id'";
$rs = Database::query($sql,__FILE__,__LINE__);
$rs = Database::query($sql,__FILE__,__LINE__);
$new_paths = array();
while ($row = Database::fetch_array($rs)) {
$path = $row['path'];
@ -352,6 +356,22 @@ class MessageManager
$result = Database::query($query,__FILE__,__LINE__);
return $row = Database::fetch_array($result);
}
public static function get_messages_by_group($group_id) {
if ($group_id != strval(intval($group_id))) return false;
$table_message = Database::get_main_table(TABLE_MESSAGE);
$group_id = intval($group_id);
$query = "SELECT * FROM $table_message WHERE group_id='$group_id' AND msg_status <> 4 ORDER BY id";
$rs = Database::query($query,__FILE__,__LINE__);
$data = array();
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs)) {
$data[] = $row;
}
}
return $data;
}
/**
* Gets information about if exist messages
* @author Isaac FLores Paz <isaac.flores@dokeos.com>
@ -425,7 +445,7 @@ class MessageManager
$i++;
}
return $message_list;
}
}
/**
* Gets information about number messages sent
* @author Isaac FLores Paz <isaac.flores@dokeos.com>
@ -440,6 +460,10 @@ class MessageManager
return $result['number_messages'];
}
/**
* display message box in the inbox
* @return void
*/
public static function show_message_box() {
global $charset;
@ -532,10 +556,13 @@ class MessageManager
</TABLE>';
}
public static function show_message_box_sent () {
global $charset;
/**
* display message box sent showing it into outbox
* @return void
*/
public static function show_message_box_sent () {
global $charset;
$table_message = Database::get_main_table(TABLE_MESSAGE);
$tbl_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT);
@ -564,7 +591,6 @@ class MessageManager
}
}
}
$row = Database::fetch_array($result);
$user_con = self::users_connected_by_id();
$band=0;
@ -608,6 +634,7 @@ class MessageManager
</TR>
</TABLE>';
}
/**
* get user id by user email
* @param string $user_email
@ -624,5 +651,99 @@ class MessageManager
return null;
}
}
/**
* display messages for group with nested view
* @param int group id
* @return void
*/
public static function display_messages_for_group($group_id) {
global $origin;
$rows = self::get_messages_by_group($group_id);
$rows = self::calculate_children($rows);
$group_info = GroupPortalManager::get_group_data($group_id);
$count=0;
foreach ($rows as $message) {
$indent = $message['indent_cnt']*'20';
$user_sender_info = UserManager::get_user_info_by_id($message['user_sender_id']);
if (!empty($message['parent_id'])) {
$message_parent_info = self::get_message_by_id($message['parent_id']);
$user_parent_info = UserManager::get_user_info_by_id($message_parent_info['user_sender_id']);
$name_user_parent = api_get_person_name($user_parent_info['firstname'], $user_parent_info['lastname']);
}
$name=api_get_person_name($user_sender_info['firstname'], $user_sender_info['lastname']);
echo "<div style=\"margin-left: ".$indent."px;padding:5px;border:1pt dotted black\">";
echo '<div id="message-title">'.$message['title'].'&nbsp;(&nbsp;'.$message['send_date'].'&nbsp;)&nbsp;</div>';
echo '<div id="message-author">'.get_lang('From').'&nbsp;'.$name.'&nbsp;'.get_lang('ToGroup').'&nbsp;'.(!empty($message['parent_id'])?$name_user_parent:$group_info['name']).'</div>';
echo '<div id="message-content">'.$message['content'].'</div>';
echo '<div id="actions">';
if (!isset($message['children'])) {
echo '<a href="/main/messages/new_message.php?group_id='.$group_id.'&message_id='.$message['id'].'">'.Display::return_icon('forumthread_new.gif',api_xml_http_response_encode(get_lang('Reply'))).'&nbsp;'.api_xml_http_response_encode(get_lang('Reply')).'</a>';
}
echo '</div>';
echo '</div>';
$count++;
}
}
/**
* Add children to messages by id is used for nested view messages
* @param array rows of messages
* @return array new list adding the item children
*/
public static function calculate_children($rows) {
foreach($rows as $row) {
$rows_with_children[$row["id"]]=$row;
$rows_with_children[$row["parent_id"]]["children"][]=$row["id"];
}
$rows=$rows_with_children;
$sorted_rows=array(0=>array());
self::message_recursive_sort($rows, $sorted_rows);
unset($sorted_rows[0]);
return $sorted_rows;
}
/**
* Sort recursively the messages, is used for for nested view messages
* @param array original rows of messages
* @param array list recursive of messages
* @param int seed for calculate the indent
* @param int indent for nested view
* @return void
*/
public static function message_recursive_sort($rows, &$messages, $seed=0, $indent=0) {
if($seed>0) {
$messages[$rows[$seed]["id"]]=$rows[$seed];
$messages[$rows[$seed]["id"]]["indent_cnt"]=$indent;
$indent++;
}
if(isset($rows[$seed]["children"])) {
foreach($rows[$seed]["children"] as $child) {
self::message_recursive_sort($rows, $messages, $child, $indent);
}
}
}
/**
* Get message list by id
* @param int message id
* @return array
*/
public static function get_message_by_id($message_id) {
$tbl_message = Database::get_main_table(TABLE_MESSAGE);
$message_id = intval($message_id);
$sql = "SELECT * FROM $tbl_message WHERE id = '$message_id'";
$res = Database::query($sql, __FILE__, __LINE__);
$item = array();
if (Database::num_rows($res)>0) {
$item = Database::fetch_array($res,'ASSOC');
}
return $item;
}
}
?>

@ -5,7 +5,7 @@
Copyright (c) 2009 Dokeos SPRL
Copyright (c) 2009 Julio Montoya Armas <gugli100@gmail.com>
Copyright (c) Facultad de Matematicas, UADY (México)
Copyright (c) Facultad de Matematicas, UADY (México)
Copyright (c) Evie, Free University of Brussels (Belgium)
Copyright (c) 2009 Isaac Flores Paz <isaac.flores.paz@gmail.com>
For a full list of contributors, see "credits.txt".
@ -47,9 +47,10 @@ if (api_get_setting('allow_message_tool')!='true'){
}
require_once'../messages/message.class.php';
require_once api_get_path(LIBRARY_PATH).'/text.lib.php';
require_once api_get_path(LIBRARY_PATH).'/formvalidator/FormValidator.class.php';
require_once api_get_path(SYS_CODE_PATH).'messages/message.class.php';
require_once api_get_path(LIBRARY_PATH).'text.lib.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
$request=api_is_xml_http_request();
$nameTools = api_xml_http_response_encode(get_lang('Messages'));
/*
@ -165,59 +166,65 @@ function manage_form ($default, $select_from_user_list = null) {
global $charset;
$table_message = Database::get_main_table(TABLE_MESSAGE);
$request=api_is_xml_http_request();
/*
if ($request===true) {
$form = new FormValidator('compose_message','post','index.php?sendform=true#remote-tab-2',null,array('enctype'=>'multipart/form-data'));
} else {
$form = new FormValidator('compose_message');
}
*/
$form = new FormValidator('compose_message',null,null,null,array('enctype'=>'multipart/form-data'));
if (isset($select_from_user_list)) {
$form->add_textfield('id_text_name', api_xml_http_response_encode(get_lang('SendMessageTo')),true,array('size' => 40,'id'=>'id_text_name','onkeyup'=>'send_request_and_search()','autocomplete'=>'off','style'=>'padding:0px'));
$form->addRule('id_text_name', api_xml_http_response_encode(get_lang('ThisFieldIsRequired')), 'required');
$form->addElement('html','<div id="id_div_search" style="padding:0px" class="message-select-box" >&nbsp;</div>');
$form->addElement('hidden','user_list',0,array('id'=>'user_list'));
} else {
if ($default['user_list']==0) {
$group_id = intval($_REQUEST['group_id']);
$message_id = intval($_GET['message_id']);
$form = new FormValidator('compose_message',null,null,null,array('enctype'=>'multipart/form-data'));
if (empty($group_id)) {
if (isset($select_from_user_list)) {
$form->add_textfield('id_text_name', api_xml_http_response_encode(get_lang('SendMessageTo')),true,array('size' => 40,'id'=>'id_text_name','onkeyup'=>'send_request_and_search()','autocomplete'=>'off','style'=>'padding:0px'));
$form->addRule('id_text_name', api_xml_http_response_encode(get_lang('ThisFieldIsRequired')), 'required');
$form->addElement('html','<div id="id_div_search" style="padding:0px" class="message-select-box" >&nbsp;</div>');
$form->addElement('hidden','user_list',0,array('id'=>'user_list'));
} else {
if ($default['user_list']==0) {
$form->add_textfield('id_text_name', api_xml_http_response_encode(get_lang('SendMessageTo')),true,array('size' => 40,'id'=>'id_text_name','onkeyup'=>'send_request_and_search()','autocomplete'=>'off','style'=>'padding:0px'));
$form->addRule('id_text_name', api_xml_http_response_encode(get_lang('ThisFieldIsRequired')), 'required');
$form->addElement('html','<div id="id_div_search" style="padding:0px" class="message-select-box" >&nbsp;</div>');
}
$form->addElement('hidden','user_list',0,array('id'=>'user_list'));
}
$form->addElement('hidden','user_list',0,array('id'=>'user_list'));
} else {
$group_info = GroupPortalManager::get_group_data($group_id);
$form->addElement('html','<div class="row"><div class="label">'.get_lang('ToGroup').'</div><div class="formw">'.api_xml_http_response_encode($group_info['name']).'</div></div>');
$form->addElement('hidden','group_id',$group_id);
$form->addElement('hidden','parent_id',$message_id);
}
$form->add_textfield('title', api_xml_http_response_encode(get_lang('Title')));
$form->add_textfield('title', api_xml_http_response_encode(get_lang('Title')));
$form->add_html_editor('content', '', false, false, array('ToolbarSet' => 'Messages', 'Width' => '95%', 'Height' => '250'));
if (isset($_GET['re_id'])) {
$form->addElement('hidden','re_id',Security::remove_XSS($_GET['re_id']));
$form->addElement('hidden','save_form','save_form');
}
if (empty($group_id)) {
$form->addElement('html','<div class="row"><div class="label">'.get_lang('FilesAttachment').'</div><div class="formw">
<span id="filepaths">
<div id="filepath_1">
<input type="file" name="attach_1" size="28" />
<input type="text" name="legend[]" size="28" />
</div></span></div></div>');
$form->addElement('html','<div class="row"><div class="formw"><a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a>&nbsp;('.get_lang('MaximunFileSizeXMB').')</div></div>');
}
$form->addElement('html','<div class="row"><div class="label">'.get_lang('FilesAttachment').'</div><div class="formw">
<span id="filepaths">
<div id="filepath_1">
<input type="file" name="attach_1" size="28" />
<input type="text" name="legend[]" size="28" />
</div></span></div></div>
');
$form->addElement('html','<div class="row"><div class="formw"><a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a>&nbsp;('.get_lang('MaximunFileSizeXMB').')</div></div>');
$form->addElement('style_submit_button','compose',api_xml_http_response_encode(get_lang('SendMessage')),'class="save"');
$form->setRequiredNote(api_xml_http_response_encode('<span class="form_required">*</span> <small>'.get_lang('ThisFieldIsRequired').'</small>'));
$form->setRequiredNote(api_xml_http_response_encode('<span class="form_required">*</span> <small>'.get_lang('ThisFieldIsRequired').'</small>'));
if (!empty($group_id) && !empty($message_id)) {
$message_info = MessageManager::get_message_by_id($message_id);
$default['title']=get_lang('Re:').api_html_entity_decode($message_info['title'],ENT_QUOTES,$charset);
}
$form->setDefaults($default);
if ($form->validate()) {
$values = $form->exportValues();
if ($form->validate()) {
$values = $form->exportValues();
$receiver_user_id = $values['user_list'];
$title = $values['title'];
$content = $values['content'];
$file_comments = $_POST['legend'];
$group_id = $values['group_id'];
$parent_id = $values['parent_id'];
//all is well, send the message
MessageManager::send_message($receiver_user_id, $title, $content, $_FILES, $file_comments);
MessageManager::display_success_message($receiver_user_id);
MessageManager::send_message($receiver_user_id, $title, $content, $_FILES, $file_comments, $group_id, $parent_id);
MessageManager::display_success_message($receiver_user_id);
} else {
$form->display();
}
@ -251,12 +258,20 @@ if (isset($_GET['rs'])) {
Display::display_header('');
$group_id = intval($_REQUEST['group_id']);
echo '<div class=actions>';
echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',api_xml_http_response_encode(get_lang('Inbox'))).api_xml_http_response_encode(get_lang('Inbox')).'</a>';
echo '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).api_xml_http_response_encode(get_lang('ComposeMessage')).'</a>';
echo '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',api_xml_http_response_encode(get_lang('Outbox'))).api_xml_http_response_encode(get_lang('Outbox')).'</a>';
echo '</div>';
if ($group_id != 0) {
echo '<a href="/main/social/groups.php?id='.$group_id.'">'.Display::return_icon('back.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).api_xml_http_response_encode(get_lang('BackToGroup')).'</a>';
echo '<a href="/main/messages/new_message.php?group_id='.$group_id.'">'.Display::return_icon('message_new.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).api_xml_http_response_encode(get_lang('ComposeMessage')).'</a>';
} else {
echo '<a href="/main/messages/inbox.php">'.Display::return_icon('inbox.png',api_xml_http_response_encode(get_lang('Inbox'))).api_xml_http_response_encode(get_lang('Inbox')).'</a>';
echo '<a href="/main/messages/new_message.php">'.Display::return_icon('message_new.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).api_xml_http_response_encode(get_lang('ComposeMessage')).'</a>';
echo '<a href="/main/messages/outbox.php">'.Display::return_icon('outbox.png',api_xml_http_response_encode(get_lang('Outbox'))).api_xml_http_response_encode(get_lang('Outbox')).'</a>';
}
echo '</div>';
if (!isset($_POST['compose'])) {
if(isset($_GET['re_id'])) {
$message_id = $_GET['re_id'];
@ -268,10 +283,14 @@ if (!isset($_POST['compose'])) {
show_compose_to_any($_user['user_id']);
}
} else {
$restrict=isset($_POST['id_text_name']) ? $_POST['id_text_name'] : false;
if ($restrict===false && isset($_GET['re_id'])) {
}
$restrict = false;
if (isset($_POST['id_text_name'])) {
$restrict = $_POST['id_text_name'];
} else if (isset($_POST['group_id'])) {
$restrict = $_POST['group_id'];
}
if (isset($_GET['re_id'])) {
$default['title'] = api_xml_http_response_encode($_POST['title']);
$default['content'] = api_xml_http_response_encode($_POST['content']);
@ -279,9 +298,13 @@ if (!isset($_POST['compose'])) {
manage_form($default);
} else {
if ($restrict) {
$default['title'] = api_xml_http_response_encode($_POST['title']);
$default['id_text_name'] = api_xml_http_response_encode($_POST['id_text_name']);
$default['user_list'] = $_POST['user_list'];
$default['title'] = api_xml_http_response_encode($_POST['title']);
if (!isset($_POST['group_id'])) {
$default['id_text_name'] = api_xml_http_response_encode($_POST['id_text_name']);
$default['user_list'] = $_POST['user_list'];
} else {
$default['group_id'] = $_POST['group_id'];
}
manage_form($default);
} else {
Display::display_error_message(api_xml_http_response_encode(get_lang('ErrorSendingMessage')));

@ -2,8 +2,9 @@
/* For licensing terms, see /dokeos_license.txt */
$language_file = array('admin');
require '../inc/global.inc.php';
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(SYS_CODE_PATH).'messages/message.class.php';
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
require_once api_get_path(LIBRARY_PATH).'social.lib.php';
@ -22,16 +23,17 @@ $group_id = intval($_GET['id']);
if ($group_id != 0 ) {
if (isset($_GET['status']) && $_GET['status']=='sent') {
Display::display_confirmation_message(api_xml_http_response_encode(get_lang('MessageHasBeenSent')), false);
}
if (isset($_GET['action']) && $_GET['action']=='leave') {
$user_leaved = intval($_GET['u']);
GroupPortalManager::delete_user_rel_group($user_leaved, $group_id);
}
}
if (isset($_GET['action']) && $_GET['action']=='join') {
$user_join = intval($_GET['u']);
GroupPortalManager::add_user_to_group($user_join, $group_id);
}
}
$group_info = GroupPortalManager::get_group_data($group_id);
$picture = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],160,'medium_');
$tags = GroupPortalManager::get_group_tags($group_id,true);
@ -43,8 +45,8 @@ if ($group_id != 0 ) {
.group_member_item { width:80px; float:left;}
</style>';
echo '<div id="layout-left" style="float: left; width: 280px; height: 100%;">';
//Group's title
echo '<h1>'.$group_info['name'].'</h1>';
@ -75,21 +77,21 @@ if ($group_id != 0 ) {
echo '</div>';
}
echo '<div id="actions" style="margin:10px">';
echo '<a href="/main/messages/new_message.php?group_id='.$group_id.'">'.Display::return_icon('message_new.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).api_xml_http_response_encode(get_lang('ComposeMessage')).'</a>';
echo '</div>';
echo get_lang('Members').' : ';
echo '<div id="group_members">';
foreach($users as $user) {
echo '<div class="group_member_item">'.$user['picture_uri'].$user['firstname'].$user['lastname'].'</div>';
echo '<div class="group_member_item">'.$user['picture_uri'].'<br />'.$user['firstname'].'&nbsp;'.$user['lastname'].'</div>';
}
echo '</div>';
echo '<div id="group_permissions">';
echo '<div id="group_permissions">';
if (is_array($users[api_get_user_id()]) && count($users[api_get_user_id()]) > 0) {
//im a member
if ($users[api_get_user_id()]['relation_type']!='') {
if ($users[api_get_user_id()]['relation_type']!='') {
$my_group_role = $users[api_get_user_id()]['relation_type'];
// I'm just a reader
if ($my_group_role == GROUP_USER_PERMISSION_READER) {
@ -109,11 +111,15 @@ if ($group_id != 0 ) {
//im not a member
echo '<a href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>';
}
echo '</div>';
echo '</div>'; // end layout permissions
echo '</div>'; // end layout left
echo '<div id="layout_right" style="margin-left: 282px;">';
echo '<div class="messages">';
MessageManager::display_messages_for_group($group_id);
echo '</div>'; // end layout messages
echo '</div>'; // end layout right
} else {
// Newest groups ----------------
$results = GroupPortalManager::get_groups_by_age(10 , true);
$groups = array();

Loading…
Cancel
Save