Browse Source

Added attachment files for message group - partial CT#190

Cristian Fasanando 15 years ago
parent
commit
818e460d72
3 changed files with 282 additions and 79 deletions
  1. 136 78
      main/inc/lib/message.lib.php
  2. 57 1
      main/social/groups.php
  3. 89 0
      main/social/message_for_group_form.inc.php

+ 136 - 78
main/inc/lib/message.lib.php

@@ -15,6 +15,7 @@ require_once api_get_path(LIBRARY_PATH).'online.inc.php';
 require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
 require_once api_get_path(LIBRARY_PATH).'fileDisplay.lib.php';
 require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
+require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
 
 /* 
  * @todo use constants!
@@ -182,21 +183,22 @@ class MessageManager
 		$group_id = intval($group_id);
         $receiver_user_id = intval($receiver_user_id);
         $parent_id = intval($parent_id);
+		$user_sender_id = api_get_user_id();
 
-        if (is_numeric($receiver_user_id)) {
-			$table_message = Database::get_main_table(TABLE_MESSAGE);
+        if (!empty($receiver_user_id) || !empty($group_id)) {
+        	// message for user friend
 	        $title = api_convert_encoding($title,$charset,'UTF-8');
+	        $title = Database::escape_string($title);
 	        $content = api_convert_encoding($content,$charset,'UTF-8');
+	        $content = Database::escape_string($content);
 			//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)."' ";
+			$sql = "SELECT COUNT(*) as count FROM $table_message WHERE user_sender_id = ".$user_sender_id." AND user_receiver_id='$receiver_user_id' AND title = '$title' AND content ='$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) {								 		 
-				//message in outbox
-				$sql = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content ) ".
-						 " 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)."'".
-				 		 ")";
+			if ($row_exist['count'] == 0) {
+				//message in outbox for user friend or group
+				$sql = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id ) ".
+						 " VALUES ('$user_sender_id', '$receiver_user_id', '4', '".date('Y-m-d H:i:s')."','$title','$content', '$group_id', '$parent_id')";
 				$rs = Database::query($sql,__FILE__,__LINE__);
 				$outbox_last_id = Database::insert_id();
 				
@@ -205,37 +207,90 @@ class MessageManager
 					$o = 0;
 					foreach ($file_attachments as $file_attach) {						
 						if ($file_attach['error'] == 0) {
-							self::save_message_attachment_file($file_attach,$file_comments[$o],$outbox_last_id,api_get_user_id());
+							self::save_message_attachment_file($file_attach,$file_comments[$o],$outbox_last_id,$user_sender_id);
 						}
-						$o++;	
+						$o++;
 					}
 				}
-				//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)."','$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;
-					foreach ($file_attachments as $file_attach) {						
-						if ($file_attach['error'] == 0) {
-							self::save_message_attachment_file($file_attach,$file_comments[$i],$inbox_last_id,null,$receiver_user_id);
-						}
-						$i++;	
+				if (!empty($group_id)) {
+					//message in inbox for group										
+					$users_by_group = GroupPortalManager::get_users_by_group($group_id);
+					$users_ids = array_keys($users_by_group);					
+					foreach ($users_ids as $user_id) {
+						$receiver_user_id = $user_id;														 
+						$query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id ) ".
+								 " VALUES ('$user_sender_id', '$receiver_user_id', '1', '".date('Y-m-d H:i:s')."','$title','$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;
+							foreach ($file_attachments as $file_attach) {						
+								if ($file_attach['error'] == 0) {
+									self::save_message_attachment_file($file_attach,$file_comments[$i],$inbox_last_id,null,$receiver_user_id);
+								}
+								$i++;
+							}
+						}						
+						// update parent id for other receiver users belongs the group						
+						if (!empty($parent_id)) {
+							self::update_parent_ids_from_reply($parent_id, $receiver_user_id, $inbox_last_id);
+						}													
 					}
-				}																				
+				} else {		
+								
+					//message in inbox for user friend								 
+					$query = "INSERT INTO $table_message(user_sender_id, user_receiver_id, msg_status, send_date, title, content, group_id, parent_id ) ".
+							 " VALUES ('$user_sender_id', '$receiver_user_id', '1', '".date('Y-m-d H:i:s')."','$title','$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;
+						foreach ($file_attachments as $file_attach) {						
+							if ($file_attach['error'] == 0) {
+								self::save_message_attachment_file($file_attach,$file_comments[$i],$inbox_last_id,null,$receiver_user_id);
+							}
+							$i++;	
+						}
+					}					
+				}														
 				return $result;
 			}
-        } else {
-        	return false;
-        }
-
+        }         
 		return false;
 	}
+
+	/**
+	 * Update parent ids for other receiver user from current message in groups
+	 * @author Christian Fasanando Flores 
+	 * @param  int	parent id
+	 * @param  int	receiver user id
+	 * @param  int	message id
+	 * @return void
+	 */
+	public static function update_parent_ids_from_reply($parent_id,$receiver_user_id,$message_id) {
+		
+		$table_message = Database::get_main_table(TABLE_MESSAGE);
+		$parent_id = intval($parent_id);		
+		$receiver_user_id = intval($receiver_user_id);
+		$message_id = intval($message_id);
+		// first get data from message id (parent)
+		$sql_message= "SELECT * FROM $table_message WHERE id = '$parent_id'";	
+		$rs_message	= Database::query($sql_message,__FILE__,__LINE__);
+		$row_message= Database::fetch_array($rs_message);
+		
+		// get message id from data found early for other receiver user
+		$sql_msg_id	= " SELECT id FROM $table_message WHERE user_sender_id ='{$row_message[user_sender_id]}' 
+				 		AND title='{$row_message[title]}' AND content='{$row_message[content]}' AND group_id='{$row_message[group_id]}' AND user_receiver_id='$receiver_user_id'";									
+		$rs_msg_id	= Database::query($sql_msg_id,__FILE__,__LINE__);
+		$row = Database::fetch_array($rs_msg_id);			
+		
+		// update parent_id for other user receiver
+		$sql_upd = "UPDATE $table_message SET parent_id = '{$row[id]}' WHERE id = '$message_id'";		
+		Database::query($sql_upd,__FILE__,__LINE__);			
+	}
 	
 	public static function delete_message_by_user_receiver ($user_receiver_id,$id) {
 		$table_message = Database::get_main_table(TABLE_MESSAGE);
@@ -319,14 +374,10 @@ class MessageManager
 				$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);	
-			}
-
+			$new_path=$path_message_attach.$new_file_name;						
+			if (is_uploaded_file($file_attach['tmp_name'])) {
+				$result= @copy($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);						
@@ -387,8 +438,9 @@ class MessageManager
 	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);
+	 	$current_uid = api_get_user_id();
 	 	$group_id = intval($group_id);	 			
-		$query = "SELECT * FROM $table_message WHERE group_id='$group_id' AND msg_status <> 4 ORDER BY id";		
+		$query = "SELECT * FROM $table_message WHERE group_id='$group_id' AND msg_status <> 4 AND user_receiver_id = '$current_uid' ORDER BY id";		
 		$rs = Database::query($query,__FILE__,__LINE__);		
 		$data = array();
 		if (Database::num_rows($rs) > 0) {
@@ -517,22 +569,7 @@ class MessageManager
 		$row = Database::fetch_array($result);
 		
 		// get file attachments by message id
-		$files_attachments = '';
-		if (!empty($message_id)) {
-			$sql = "SELECT * FROM $tbl_message_attach WHERE message_id = '$message_id'";
-			$rs_file = Database::query($sql,__FILE__,__LINE__);				
-			if (Database::num_rows($rs_file) > 0) {
-				$attach_icon = Display::return_icon('attachment.gif');						
-				$archiveURL=api_get_path(WEB_CODE_PATH).'messages/download.php?type=inbox&file=';				
-				while ($row_file = Database::fetch_array($rs_file)) {				
-					$archiveFile = $row_file['path'];
-					$filename = $row_file['filename'];
-					$filesize = format_file_size($row_file['size']);
-					$filecomment = $row_file['comment'];
-					$files_attachments .= $attach_icon.'&nbsp;<a href="'.$archiveURL.$archiveFile.'">'.$filename.'</a>&nbsp;('.$filesize.')'.(!empty($filecomment)?'&nbsp;-&nbsp;'.$filecomment:'').'<br />'; 
-				}
-			}						
-		}
+		$files_attachments = self::get_links_message_attachment_files($message_id);
 		
 		$user_con = self::users_connected_by_id();
 		$band=0;
@@ -576,7 +613,7 @@ class MessageManager
 		            </TR>
 		          </TBODY>
 		        </TABLE>
-		        '.$files_attachments.'				        		
+		        <div id="message-attach">'.(!empty($files_attachments)?implode('&nbsp;|&nbsp;',$files_attachments):'').'</div>				        		
 		        <DIV class=HT style="PADDING-BOTTOM: 5px"> </DIV></TD>
 		      <TD width=10>&nbsp;</TD>
 		    </TR>
@@ -602,23 +639,8 @@ class MessageManager
 		$path='outbox.php';
 
 		// get file attachments by message id
-		$files_attachments = '';
-		if (!empty($message_id)) {
-			$sql = "SELECT * FROM $tbl_message_attach WHERE message_id = '$message_id'";
-			$rs_file = Database::query($sql,__FILE__,__LINE__);				
-			if (Database::num_rows($rs_file) > 0) {
-				$attach_icon = Display::return_icon('attachment.gif');						
-				$archiveURL=api_get_path(WEB_CODE_PATH).'messages/download.php?type=outbox&file=';				
-				while ($row_file = Database::fetch_array($rs_file)) {				
-					$archiveFile = $row_file['path'];
-					$filename = $row_file['filename'];
-					$filesize = format_file_size($row_file['size']);
-					$filecomment = $row_file['comment'];
-					$files_attachments .= $attach_icon.'&nbsp;<a href="'.$archiveURL.$archiveFile.'">'.$filename.'</a>&nbsp;('.$filesize.')'.(!empty($filecomment)?'&nbsp;-&nbsp;'.$filecomment:'').'<br />'; 
-				}
-			}						
-		}
-
+		$files_attachments = self::get_links_message_attachment_files($message_id);
+	
 		$row = Database::fetch_array($result);
 		$user_con = self::users_connected_by_id();
 		$band=0;
@@ -656,7 +678,7 @@ class MessageManager
 		            </TR>
 		          </TBODY>
 		        </TABLE>
-		        '.$files_attachments.'		
+		        <div id="message-attach">'.(!empty($files_attachments)?implode('&nbsp;|&nbsp;',$files_attachments):'').'</div>		
 		        <DIV class=HT style="PADDING-BOTTOM: 5px"> </DIV></TD>
 		      <TD width=10>&nbsp;</TD>
 		    </TR>
@@ -687,8 +709,8 @@ class MessageManager
 	 */
 	public static function display_messages_for_group($group_id) {
 				
-		global $origin;				
-		$rows = self::get_messages_by_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;
@@ -701,15 +723,21 @@ class MessageManager
 				$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']);
 			}
+			
+			// get file attachments by message id
+			$files_attachments = self::get_links_message_attachment_files($message['id']);
+						
 			$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="message-attach">'.(!empty($files_attachments)?implode('&nbsp;|&nbsp;',$files_attachments):'').'</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 '<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=365&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&message_id='.$message['id'].'" class="thickbox" title="'.api_xml_http_response_encode(get_lang('Reply')).'">'.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 '<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>';
@@ -756,6 +784,36 @@ class MessageManager
 		}
 	}
 	
+	/**
+	 * Get array of links (download) for message attachment files    
+	 * @param int  		message id 
+	 * @return array 
+	 */	
+	public static function get_links_message_attachment_files($message_id) {
+		
+		$tbl_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT);
+		$message_id = intval($message_id);
+		
+		// get file attachments by message id
+		$links_attach_file = array();
+		if (!empty($message_id)) {
+			$sql = "SELECT * FROM $tbl_message_attach WHERE message_id = '$message_id'";
+			$rs_file = Database::query($sql,__FILE__,__LINE__);				
+			if (Database::num_rows($rs_file) > 0) {
+				$attach_icon = Display::return_icon('attachment.gif');						
+				$archiveURL=api_get_path(WEB_CODE_PATH).'messages/download.php?type=inbox&file=';				
+				while ($row_file = Database::fetch_array($rs_file)) {
+					$archiveFile= $row_file['path'];
+					$filename 	= $row_file['filename'];
+					$filesize 	= format_file_size($row_file['size']);
+					$filecomment= $row_file['comment'];
+					$links_attach_file[] = $attach_icon.'&nbsp;<a href="'.$archiveURL.$archiveFile.'">'.$filename.'</a>&nbsp;('.$filesize.')'.(!empty($filecomment)?'&nbsp;-&nbsp;'.$filecomment:''); 
+				}
+			}						
+		}		
+		return $links_attach_file;		
+	}
+	
 	/**
 	 * Get message list by id    
 	 * @param int  message id 

+ 57 - 1
main/social/groups.php

@@ -10,9 +10,64 @@ require_once api_get_path(LIBRARY_PATH).'message.lib.php';
 
 $this_section = SECTION_SOCIAL;
 
+$htmlHeadXtra[] = '<script type="text/javascript" src="/main/inc/lib/javascript/jquery.js"></script>';
+$htmlHeadXtra[] = '<script type="text/javascript" src="/main/inc/lib/javascript/thickbox.js"></script>';
+//$htmlHeadXtra[] = '<script type="text/javascript" src="/main/inc/lib/javascript/ajaxfileupload.js"></script>';
+$htmlHeadXtra[] = '<link rel="stylesheet" href="/main/inc/lib/javascript/thickbox.css" type="text/css" media="projection, screen">';
+
+$htmlHeadXtra[] = '<script type="text/javascript">
+
+var counter_image = 1;	
+function remove_image_form(id_elem1) {
+	var elem1 = document.getElementById(id_elem1);
+	elem1.parentNode.removeChild(elem1);
+	counter_image--;
+	var filepaths = document.getElementById("filepaths");		
+	if (filepaths.childNodes.length < 3) {		
+		var link_attach = document.getElementById("link-more-attach");		
+		if (link_attach) {
+			link_attach.innerHTML=\'<a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a>&nbsp;('.get_lang('MaximunFileSizeXMB').')\';
+		}			
+	}				        
+}
+		
+function add_image_form() {    														
+	// Multiple filepaths for image form					
+	var filepaths = document.getElementById("filepaths");	
+	if (document.getElementById("filepath_"+counter_image)) {
+		counter_image = counter_image + 1;				
+	}  else {
+		counter_image = counter_image; 
+	}
+	var elem1 = document.createElement("div");			
+	elem1.setAttribute("id","filepath_"+counter_image);							
+	filepaths.appendChild(elem1);	
+	id_elem1 = "filepath_"+counter_image;		
+	id_elem1 = "\'"+id_elem1+"\'";
+	document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\"  size=\"20\" />&nbsp;<a href=\"javascript:remove_image_form("+id_elem1+")\"><img src=\"'.api_get_path(WEB_CODE_PATH).'img/delete.gif\"></a>";						
+
+	if (filepaths.childNodes.length == 3) {		
+		var link_attach = document.getElementById("link-more-attach");		
+		if (link_attach) {
+			link_attach.innerHTML="";
+		}
+	}
+}	
+			
+	</script>';
+
 $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
 Display :: display_header($tool_name, 'Groups');
 
+// save message group
+if (isset($_POST['action']) && $_POST['action']=='send_message_group') {	
+	$title = $_POST['title'];
+	$content = $_POST['content'];
+	$group_id = $_POST['group_id'];
+	$parent_id = $_POST['parent_id'];	
+	MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id);
+}
+
 //show the action menu
 SocialManager::show_social_menu();
 echo '<div class="actions-title">';
@@ -111,7 +166,8 @@ if ($group_id != 0 ) {
 		
 	if (in_array($my_group_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER,GROUP_USER_PERMISSION_MODERATOR))) { 
 		echo '<div id="actions" style="margin:10px">';
-		echo '<a href="'.api_get_path(WEB_PATH).'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 '<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=365&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'" class="thickbox" title="'.get_lang('ComposeMessage').'">'.Display :: return_icon('message_new.png', get_lang('ComposeMessage')).'&nbsp;'.get_lang('ComposeMessage').'</a>';
+		//echo '<a href="'.api_get_path(WEB_PATH).'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>';
 	}
 	

+ 89 - 0
main/social/message_for_group_form.inc.php

@@ -0,0 +1,89 @@
+<?php
+/* For licensing terms, see /dokeos_license.txt */
+$language_file = array('registration','messages','userInfo','admin');
+$cidReset=true;
+require_once '../inc/global.inc.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
+require_once api_get_path(LIBRARY_PATH).'message.lib.php';
+require_once api_get_path(LIBRARY_PATH).'social.lib.php';
+require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
+
+if (api_is_anonymous()) {
+	api_not_allowed();
+}
+
+if (api_get_setting('allow_message_tool') != 'true' && api_get_setting('allow_social_tool') != 'true') {
+	api_not_allowed();
+}
+
+if ( isset($_REQUEST['user_friend']) ) {
+	$info_user_friend=array();
+	$info_path_friend=array();
+ 	$userfriend_id=Security::remove_XSS($_REQUEST['user_friend']);
+ 	// panel=1  send message
+ 	// panel=2  send invitation
+ 	$panel=Security::remove_XSS($_REQUEST['view_panel']);
+ 	$info_user_friend=api_get_user_info($userfriend_id);
+ 	$info_path_friend=UserManager::get_user_picture_path_by_id($userfriend_id,'web',false,true);
+}
+
+$group_id = intval($_GET['group_id']);
+$message_id = intval($_GET['message_id']);
+$to_group = '';
+$title_group = '';
+if (!empty($group_id)) {
+	$group_info = GroupPortalManager::get_group_data($group_id);
+	$to_group   = $group_info['name'];
+	if (!empty($message_id)) {
+		$message_info = MessageManager::get_message_by_id($message_id);		
+		$title_group  = get_lang('Re:').api_html_entity_decode($message_info['title'],ENT_QUOTES,$charset);	
+	} 	
+}
+
+?>
+
+<form name="form" action="groups.php?id=<?php echo $group_id ?>" method="POST" enctype="multipart/form-data">
+<input type="hidden" name="action" value="send_message_group" />
+<input type="hidden" name="group_id" value="<?php echo $group_id ?>" />
+<input type="hidden" name="parent_id" value="<?php echo $message_id ?>" />
+<table width="600" border="0" height="220">
+    <tr height="180">
+        <td align="center">
+        <div class="message-content-body-left">
+			<img class="message-image-info" src="<?php echo $info_path_friend['dir'].$info_path_friend['file']; ?>"/>
+			<?php
+			if ($panel != 1) {
+				echo '<br /><center>'.api_xml_http_response_encode(api_get_person_name($info_user_friend['firstName'], $info_user_friend['lastName'])).'</center>';
+			}
+			?>
+		</div>
+<div class="message-content-body-right">
+<div id="id_content_panel_init">
+	<dl>
+<?php
+		if (api_get_setting('allow_message_tool')=='true') {		
+            //normal message
+	   		 $user_info=api_get_user_info($userfriend_id);
+	  		 echo api_xml_http_response_encode(get_lang('To')); ?> :&nbsp;&nbsp;&nbsp;&nbsp;<?php echo api_xml_http_response_encode($to_group); ?>
+	  		 <br />
+	 		 <br /><?php echo api_xml_http_response_encode(get_lang('Subject')); ?> :<br /><input id="txt_subject_id" name="title" type="text" style="width:300px;" value="<?php echo $title_group ?>"><br/>
+	   		 <br /><?php echo api_xml_http_response_encode(get_lang('Message')); ?> :<br /><textarea id="txt_area_invite" name="content" rows="3" cols="41"></textarea><br/>
+	   		 <br /><?php echo api_xml_http_response_encode(get_lang('AttachmentFiles')); ?> :<br />
+
+			<span id="filepaths"><div id="filepath_1"><input type="file" name="attach_1" size="20" /></div></span>
+			<div id="link-more-attach"><a href="javascript://" onclick="return add_image_form()"><?php echo get_lang('AddOneMoreFile') ?></a>&nbsp;(<?php echo get_lang('MaximunFileSizeXMB') ?>)</div>
+	   		<!--button class="save" type="button" value="<?php echo api_xml_http_response_encode(get_lang('SendMessage')); ?>" onclick="return ajaxFileUpload()"><?php echo api_xml_http_response_encode(get_lang('SendMessage')) ?></button-->
+	   		<button class="save" type="submit" value="<?php echo api_xml_http_response_encode(get_lang('SendMessage')); ?>"><?php echo api_xml_http_response_encode(get_lang('SendMessage')) ?></button>
+<?php } ?>
+	</dl>
+</div>
+</td>
+</tr>
+</div>
+<tr>
+	<td>
+		<div id="display_response_id" style="position:relative"></div>
+	</td>
+</tr>
+</table>
+</form>