Browse Source

Adding smarty in the social tool + fixin the who is online in order to user pagination

Julio Montoya 13 years ago
parent
commit
af39549929

+ 11 - 0
main/css/base.css

@@ -4230,6 +4230,17 @@ a:active{
     margin-right: 4px;    
 }
 
+.offline_user_in_text {
+    background: url("offline.png") no-repeat scroll right center transparent;
+    float: left;
+    height: 16px;
+    left: 0;
+    width: 17px;
+    display:block;
+    margin-right: 4px;    
+}
+
+
 
 .hide_menu{
     display:none;

+ 2 - 2
main/inc/ajax/model.ajax.php

@@ -267,8 +267,8 @@ switch ($action) {
 //var_dump($result);
 
 //5. Creating an obj to return a json
-if (in_array($action, array('get_careers','get_promotions','get_usergroups','get_gradebooks', 'get_sessions','get_exercise_results'))) { 
-    $response = new stdClass();           
+if (in_array($action, array('get_careers', 'get_promotions', 'get_usergroups', 'get_gradebooks', 'get_sessions', 'get_exercise_results'))) { 
+    $response           = new stdClass();           
     $response->page     = $page; 
     $response->total    = $total_pages; 
     $response->records  = $count; 

+ 18 - 14
main/inc/ajax/online.ajax.php

@@ -11,20 +11,24 @@ $action = $_GET['a'];
 switch($action) {
     case 'load_online_user':
         $page = intval($_REQUEST['online_page_nr']);
-        if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
-            $user_list = who_is_online_in_this_course(api_get_user_id(), api_get_setting('time_limit_whosonline'), $_GET['cidReq']);
-        } else {
-            $user_list = who_is_online(api_get_setting('time_limit_whosonline'));		
-        }
-        if ($page == 2) {
-            $_SESSION['online_user_items'] = array();
-        }
-        $max_page =  round(count($user_list)/10);
-        if (!in_array($page, $_SESSION['online_user_items']) && $page <= $max_page) {              
-            $_SESSION['online_user_items'][] = $page;
-            echo SocialManager::display_user_list($user_list);
-        } else {
-            echo 'end';            
+        
+        $max_page = round(who_is_online_count()/10);
+        
+        if (!in_array($page, $_SESSION['online_user_items']) && $page <= $max_page) {                          
+            if (isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
+                $user_list = who_is_online_in_this_course(api_get_user_id(), api_get_setting('time_limit_whosonline'), $_GET['cidReq']);
+            } else {
+                $page_rows = $page*10;
+                $user_list = who_is_online($page_rows, $page_rows + 10);		
+            }        
+            if ($page == 1) {            
+                $_SESSION['online_user_items'] = array();
+            }           
+        
+            $_SESSION['online_user_items'][] = $page;         
+            if (!empty($user_list)) {
+                echo SocialManager::display_user_list($user_list);
+            }
         }
         break;
     default:

+ 9 - 9
main/inc/lib/group_portal_manager.lib.php

@@ -1025,8 +1025,8 @@ class GroupPortalManager {
 	 *
 	 */
 	public static function show_group_column_information($group_id, $user_id, $show = '') {
-
 		global $relation_group_title, $my_group_role;
+        $html = '';
 
 		$group_info 	= GroupPortalManager::get_group_data($group_id);
 		$picture		= GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],160,GROUP_IMAGE_SIZE_MEDIUM);
@@ -1039,7 +1039,7 @@ class GroupPortalManager {
 		$my_group_role = self::get_user_group_role($user_id, $group_id);
 
 		//@todo this must be move to default.css for dev use only
-		echo '<style>
+		$html .= '<style>
 				#group_members { width:270px; height:300px; overflow-x:none; overflow-y: auto;}
 				.group_member_item { width:100px; height:130px; float:left; margin:5px 5px 15px 5px; }
 				.group_member_picture { display:block;
@@ -1067,7 +1067,7 @@ class GroupPortalManager {
 				$links .=  '<li><a href="group_edit.php?id='.$group_id.'">'.			Display::return_icon('group_edit.png', get_lang('EditGroup'), array('hspace'=>'6')).'<span class="'.($show=='group_edit'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('EditGroup').'</span></a></li>';
 				//$links .=  '<li><a href="group_members.php?id='.$group_id.'">'.		Display::return_icon('member_list.png', get_lang('MemberList'), array('hspace'=>'6')).'<span class="'.($show=='member_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MemberList').'</span></a></li>';
 				//if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
-					$links .=  '<li><a href="group_waiting_list.php?id='.$group_id.'">'.	Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace'=>'6')).'<span class="'.($show=='waiting_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('WaitingList').'</span></a></li>';
+				$links .=  '<li><a href="group_waiting_list.php?id='.$group_id.'">'.	Display::return_icon('waiting_list.png', get_lang('WaitingList'), array('hspace'=>'6')).'<span class="'.($show=='waiting_list'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('WaitingList').'</span></a></li>';
 				//}
 				$links .=  '<li><a href="group_invitation.php?id='.$group_id.'">'.	Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).'<span class="'.($show=='invite_friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('InviteFriends').'</span></a></li>';
 				break;
@@ -1101,13 +1101,13 @@ class GroupPortalManager {
 		}
 
 		if (!empty($links)) {
-			echo '<ul class="social-menu-groups">';
+			$html .= '<ul class="social-menu-groups">';
 			if (!empty($group_info['description'])) {
-				echo Display::tag('li', Security::remove_XSS($group_info['description'], STUDENT, true), array('class'=>'group_description'));
+				$html .= Display::tag('li', Security::remove_XSS($group_info['description'], STUDENT, true), array('class'=>'group_description'));
 			}
-			echo $links;
-			echo '</ul>';
-		}
-		
+			$html .= $links;
+			$html .= '</ul>';
+		}		
+        return $html;
 	}
 }

+ 132 - 0
main/inc/lib/javascript/jquery-jplayer/jquery.endless-scroll.js

@@ -0,0 +1,132 @@
+/**
+ * Endless Scroll plugin for jQuery
+ *
+ * v1.4.8
+ *
+ * Copyright (c) 2008 Fred Wu
+ *
+ * Dual licensed under the MIT and GPL licenses:
+ *   http://www.opensource.org/licenses/mit-license.php
+ *   http://www.gnu.org/licenses/gpl.html
+ */
+
+/**
+ * Usage:
+ *
+ * // using default options
+ * $(document).endlessScroll();
+ *
+ * // using some custom options
+ * $(document).endlessScroll({
+ *   fireOnce: false,
+ *   fireDelay: false,
+ *   loader: "<div class=\"loading\"><div>",
+ *   callback: function(){
+ *     alert("test");
+ *   }
+ * });
+ *
+ * Configuration options:
+ *
+ * bottomPixels  integer          the number of pixels from the bottom of the page that triggers the event
+ * fireOnce      boolean          only fire once until the execution of the current event is completed
+ * fireDelay     integer          delay the subsequent firing, in milliseconds, 0 or false to disable delay
+ * loader        string           the HTML to be displayed during loading
+ * data          string|function  plain HTML data, can be either a string or a function that returns a string,
+ *                                when passed as a function it accepts one argument: fire sequence (the number
+ *                                of times the event triggered during the current page session)
+ * insertAfter   string           jQuery selector syntax: where to put the loader as well as the plain HTML data
+ * callback      function         callback function, accepts one argument: fire sequence (the number of times
+ *                                the event triggered during the current page session)
+ * resetCounter  function         resets the fire sequence counter if the function returns true, this function
+ *                                could also perform hook actions since it is applied at the start of the event
+ * ceaseFire     function         stops the event (no more endless scrolling) if the function returns true
+ *
+ * Usage tips:
+ *
+ * The plugin is more useful when used with the callback function, which can then make AJAX calls to retrieve content.
+ * The fire sequence argument (for the callback function) is useful for 'pagination'-like features.
+ */
+
+(function($){
+
+  $.fn.endlessScroll = function(options) {
+
+    var defaults = {
+      bottomPixels: 50,
+      fireOnce: true,
+      fireDelay: 150,
+      loader: "<br />Loading...<br />",
+      data: "",
+      insertAfter: "div:last",
+      resetCounter: function() { return false; },
+      callback: function() { return true; },
+      ceaseFire: function() { return false; }
+    };
+
+    var options = $.extend({}, defaults, options);
+
+    var firing       = true;
+    var fired        = false;
+    var fireSequence = 0;
+
+    if (options.ceaseFire.apply(this) === true) {
+      firing = false;
+    }
+
+    if (firing === true) {
+      $(this).scroll(function() {
+        if (options.ceaseFire.apply(this) === true) {
+          firing = false;
+          return; // Scroll will still get called, but nothing will happen
+        }
+
+        if (this == document || this == window) {
+          var is_scrollable = $(document).height() - $(window).height() <= $(window).scrollTop() + options.bottomPixels;
+        } else {
+          // calculates the actual height of the scrolling container
+          var inner_wrap = $(".endless_scroll_inner_wrap", this);
+          if (inner_wrap.length == 0) {
+            inner_wrap = $(this).wrapInner("<div class=\"endless_scroll_inner_wrap\" />").find(".endless_scroll_inner_wrap");
+          }
+          var is_scrollable = inner_wrap.length > 0 &&
+            (inner_wrap.height() - $(this).height() <= $(this).scrollTop() + options.bottomPixels);
+        }
+
+        if (is_scrollable && (options.fireOnce == false || (options.fireOnce == true && fired != true))) {
+          if (options.resetCounter.apply(this) === true) fireSequence = 0;
+
+          fired = true;
+          fireSequence++;
+
+          $(options.insertAfter).after("<div id=\"endless_scroll_loader\">" + options.loader + "</div>");
+
+          data = typeof options.data == 'function' ? options.data.apply(this, [fireSequence]) : options.data;
+
+          if (data !== false) {
+            $(options.insertAfter).after("<div id=\"endless_scroll_data\">" + data + "</div>");
+            $("div#endless_scroll_data").hide().fadeIn();
+            $("div#endless_scroll_data").removeAttr("id");
+
+            options.callback.apply(this, [fireSequence]);
+
+            if (options.fireDelay !== false || options.fireDelay !== 0) {
+              $("body").after("<div id=\"endless_scroll_marker\"></div>");
+              // slight delay for preventing event firing twice
+              $("div#endless_scroll_marker").fadeTo(options.fireDelay, 1, function() {
+                $(this).remove();
+                fired = false;
+              });
+            }
+            else {
+              fired = false;
+            }
+          }
+
+          $("div#endless_scroll_loader").remove();
+        }
+      });
+    }
+  };
+
+})(jQuery);

+ 38 - 40
main/inc/lib/message.lib.php

@@ -31,10 +31,11 @@ define('MESSAGE_STATUS_INVITATION_DENIED',	'7');
  */
 class MessageManager
 {
-	public static function get_online_user_list($current_user_id) {
-		$min=30;
+	public static function get_online_user_list($current_user_id) {		
 		global $_configuration;
-		$userlist = who_is_online($min, true);
+        //@todo this is a bad idea to parse all users online
+        $count = who_is_online_count();
+		$userlist = who_is_online(0, $count, null, null, 30, true);
 		$online_user_list = array();
 		foreach($userlist as $row) {
 			$receiver_id = $row[0];
@@ -67,7 +68,7 @@ class MessageManager
 				GetFullUserName($uid).
 				"</b>";
 		}
-		Display::display_confirmation_message(api_xml_http_response_encode($success), false);
+		return Display::return_message(api_xml_http_response_encode($success), 'confirmation', false);
 	}
 
 	/**
@@ -95,10 +96,10 @@ class MessageManager
 	/**
 	* Get the list of user_ids of users who are online.
 	*/
-	public static function users_connected_by_id() {
-		global $_configuration, $_user;
-		$minute=30;
-		$user_connect = who_is_online($minute, true);
+	public static function users_connected_by_id() {		
+		$count = who_is_online_count();
+		$user_connect = who_is_online(0, $count, null, null, 30, true);
+        $user_id_list = array(); 
 		for ($i=0; $i<count($user_connect); $i++) {
 			$user_id_list[$i]=$user_connect[$i][0];
 		}
@@ -1016,7 +1017,7 @@ class MessageManager
         $query_vars = array('id' => $group_id, 'topic_id' => $topic_id , 'topics_page_nr' => 0);        
         
         // Main message        
-        $html = '';              
+                    
         $user_link = '';
         $links = '';
         $main_content  = '';
@@ -1024,7 +1025,9 @@ class MessageManager
         //$items_page_nr = intval($_GET['items_'.$topic['id'].'_page_nr']);
         $items_page_nr = null;
         
-        echo Display::tag('h3', Security::remove_XSS($main_message['title'], STUDENT, true));
+        $html = '';
+        
+        $html .= Display::tag('h3', Security::remove_XSS($main_message['title'], 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']);
@@ -1058,8 +1061,6 @@ class MessageManager
         $main_content.= '<div class="message-group-content">'.$links.$user_link.' '.$date.$main_message['content'].$attachment.'</div>';
         $main_content = Security::remove_XSS($main_content, STUDENT, true);
 
-        $html = '';   
-        
         $html .= Display::div(Display::div(Display::div($main_content, array('class'=>'group_social_sub_item', 'style'=>'background-color:#fff;')), array('class' => 'group_social_item')), array('class' => 'group_social_grid'));
         
         $topic_id = $main_message['id'];
@@ -1241,9 +1242,9 @@ class MessageManager
 //@todo this functions should be in the message class
 
 function inbox_display() {
-	global $charset;
-	$table_message = Database::get_main_table(TABLE_MESSAGE);
+	global $charset;	
     $success = get_lang('SelectedMessagesDeleted');
+    $html = '';
     
 	if (isset ($_REQUEST['action'])) {
 		switch ($_REQUEST['action']) {
@@ -1252,23 +1253,21 @@ function inbox_display() {
     			foreach ($_POST['id'] as $index => $message_id) {
     				MessageManager::delete_message_by_user_receiver(api_get_user_id(), $message_id);
     			}
-    			Display::display_normal_message(api_xml_http_response_encode($success),false);
+    			$html .= Display::return_message(api_xml_http_response_encode($success), 'normal', false);
     			break;
 			case 'deleteone' :
     			MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_GET['id']);
-    			Display::display_confirmation_message(api_xml_http_response_encode($success),false);
-    			echo '<br />';
+    			$html .= Display::return_message(api_xml_http_response_encode($success),'confirmation', false);    			
     			break;
 		}
 	}
-	// display sortable table with messages of the current user
-	//$table = new SortableTable('messages', 'get_number_of_messages_mask', 'get_message_data_mask', 3, get_number_of_messages_mask(),'DESC');
+    
+	// display sortable table with messages of the current user	
 	$table = new SortableTable('message_inbox', array('MessageManager','get_number_of_messages'), array('MessageManager','get_message_data'),3,20,'DESC');
 	$table->set_header(0, '', false,array ('style' => 'width:15px;'));
 	$title=api_xml_http_response_encode(get_lang('Title'));
 	$action=api_xml_http_response_encode(get_lang('Modify'));
-	$table->set_header(1,api_xml_http_response_encode(get_lang('Messages')),false);
-	//$table->set_header(2,$title,true);
+	$table->set_header(1,api_xml_http_response_encode(get_lang('Messages')),false);	
 	$table->set_header(2,api_xml_http_response_encode(get_lang('Date')),true, array('style' => 'width:180px;'));
 	$table->set_header(3,$action,false,array ('style' => 'width:70px;'));
 	
@@ -1277,8 +1276,8 @@ function inbox_display() {
 		$table->set_additional_parameters($parameters);
 	}    
 	$table->set_form_actions(array ('delete' => get_lang('DeleteSelectedMessages')));
-
-	$table->display();
+    $html .= $table->return_table();
+	return $html;
 	
 }
 
@@ -1294,8 +1293,7 @@ function get_message_data_mask($from, $number_of_items, $column, $direction) {
 	return MessageManager::get_message_data($from, $number_of_items, $column, $direction);
 }
 
-function outbox_display() {
-	$table_message = Database::get_main_table(TABLE_MESSAGE);
+function outbox_display() {	
 	$request=api_is_xml_http_request();
 	global $charset;
 
@@ -1303,7 +1301,7 @@ function outbox_display() {
 	if ($_REQUEST['f']=='social') {
 		$social_link ='f=social';
 	}
-	$success= get_lang('SelectedMessagesDeleted').'&nbsp</b><br /><a href="outbox.php?'.$social_link.'">'.get_lang('BackToOutbox').'</a>';
+	$success = get_lang('SelectedMessagesDeleted').'&nbsp</b><br /><a href="outbox.php?'.$social_link.'">'.get_lang('BackToOutbox').'</a>';
 	
 	if (isset ($_REQUEST['action'])) {
 		switch ($_REQUEST['action']) {
@@ -1314,18 +1312,17 @@ function outbox_display() {
     					MessageManager::delete_message_by_user_receiver(api_get_user_id(), $message_id);
     				}
     			}
-    			Display::display_normal_message(api_xml_http_response_encode($success),false);
+    			$html .= Display::return_message(api_xml_http_response_encode($success),'normal', false);
     			break;
 			case 'deleteone' :
     			MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_GET['id']);
-    			Display::display_confirmation_message(api_xml_http_response_encode($success),false);
-                echo '<br/>';
+    			$html .=Display::return_message(api_xml_http_response_encode($success), 'normal', false);
+                $html .= '<br/>';
 			 break;
 		}
 	}
 
-	// display sortable table with messages of the current user
-	//$table = new SortableTable('messages', 'get_number_of_messages_send_mask', 'get_message_data_send_mask', 3, get_number_of_messages_send_mask(), 'DESC');
+	// display sortable table with messages of the current user	
 	$table = new SortableTable('message_outbox', array('MessageManager','get_number_of_messages_sent'), array('MessageManager','get_message_data_sent'),3,20,'DESC');
 
 	$parameters['f'] = Security::remove_XSS($_GET['f']);
@@ -1341,21 +1338,22 @@ function outbox_display() {
 
 	
 	if ($request===true) {
-		echo '<form name="form_send_out" id="form_send_out" action="" method="post">';
-		echo '<input type="hidden" name="action" value="delete" />';
-		$table->display();
-		echo '</form>';
+		$html .=  '<form name="form_send_out" id="form_send_out" action="" method="post">';
+		$html .=  '<input type="hidden" name="action" value="delete" />';
+		$html .= $table->return_table();
+		$html .=  '</form>';
 		if (get_number_of_messages_send_mask() > 0) {
-			echo '<a href="javascript:void(0)" onclick="selectall_cheks()">'.api_xml_http_response_encode(get_lang('SelectAll')).'</a>&nbsp;&nbsp;&nbsp;';
-			echo '<a href="javascript:void(0)" onclick="unselectall_cheks()">'.api_xml_http_response_encode(get_lang('UnSelectAll')).'</a>&nbsp;&nbsp;&nbsp;';
-			echo '<button class="save" name="delete" type="button" value="'.api_xml_http_response_encode(get_lang('DeleteSelectedMessages')).'" onclick="submit_form(\'outbox\')">'.api_xml_http_response_encode(get_lang('DeleteSelectedMessages')).'</button>';
+			$html .=  '<a href="javascript:void(0)" onclick="selectall_cheks()">'.api_xml_http_response_encode(get_lang('SelectAll')).'</a>&nbsp;&nbsp;&nbsp;';
+			$html .=  '<a href="javascript:void(0)" onclick="unselectall_cheks()">'.api_xml_http_response_encode(get_lang('UnSelectAll')).'</a>&nbsp;&nbsp;&nbsp;';
+			$html .=  '<button class="save" name="delete" type="button" value="'.api_xml_http_response_encode(get_lang('DeleteSelectedMessages')).'" onclick="submit_form(\'outbox\')">'.api_xml_http_response_encode(get_lang('DeleteSelectedMessages')).'</button>';
 		}
 	} else {
 		$table->set_form_actions(array ('delete' => get_lang('DeleteSelectedMessages')));
-		$table->display();
+		$html .= $table->return_table();
 	}
-	
+    return $html;	
 }
+
 function get_number_of_messages_send_mask() {
 	return MessageManager::get_number_of_messages_sent();
 }

+ 61 - 18
main/inc/lib/online.inc.php

@@ -143,23 +143,53 @@ function user_is_online($user_id) {
  * @param   bool		optionally if it's set to true shows who friends from social network is online otherwise just shows all users online
  * @return  array       For each line, a list of user IDs and login dates, or FALSE on error or empty results
  */
-function who_is_online($valid, $friends = false) {
-	$valid = (int) $valid;
+function who_is_online($from, $number_of_items, $column = null, $direction = null, $time_limit = null, $friends = false) {
+    
+    if (empty($time_limit)) {
+        $time_limit = api_get_setting('time_limit_whosonline');
+    } else {
+        $time_limit = intval($time_limit);
+    }
+    
+    $from            = intval($from);
+    $number_of_items = intval($number_of_items);
+    
+    if (empty($column)) {
+        $column = 'picture_uri';
+        if ($friends) {
+            $column = 'login_date';    
+        }
+        
+    }
+    
+    if (empty($direction)) {
+        $direction = 'DESC';
+    } else {
+        if (!in_array(strtolower($direction), array('asc', 'desc'))) {
+            $direction = 'DESC';
+        }
+    }
+    
 	$current_date		= date('Y-m-d H:i:s',time());
 	$track_online_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ONLINE);
 	$friend_user_table  = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
 	$table_user			= Database::get_main_table(TABLE_MAIN_USER);
-	$query = '';
+	$query              = '';    
     
 	if ($friends) {
 		// 	who friends from social network is online
-		$query = "SELECT DISTINCT login_user_id,login_date
+		$query = "SELECT DISTINCT login_user_id, login_date
 				  FROM $track_online_table INNER JOIN $friend_user_table ON (friend_user_id = login_user_id)
-				  WHERE DATE_ADD(login_date,INTERVAL $valid MINUTE) >= '".$current_date."' AND friend_user_id <> '".api_get_user_id()."'  AND relation_type='".USER_RELATION_TYPE_FRIEND."' AND user_id = '".api_get_user_id()."' ";
+				  WHERE DATE_ADD(login_date,INTERVAL $time_limit MINUTE) >= '".$current_date."' AND friend_user_id <> '".api_get_user_id()."' AND relation_type='".USER_RELATION_TYPE_FRIEND."' AND user_id = '".api_get_user_id()."' 
+                  ORDER BY $column $direction 
+                  LIMIT $from, $number_of_items";
 	} else {
 		// all users online
-		//$query = "SELECT login_user_id,login_date FROM ".$track_online_table ." WHERE DATE_ADD(login_date,INTERVAL $valid MINUTE) >= '".$current_date."'  "; //WHERE DATE_ADD(login_date,INTERVAL $valid MINUTE) >= '".$current_date."'
-		$query = "SELECT login_user_id,login_date FROM ".$track_online_table ." e INNER JOIN ".$table_user ." u ON (u.user_id=e.login_user_id)  WHERE DATE_ADD(login_date,INTERVAL $valid MINUTE) >= '".$current_date."' ORDER BY picture_uri DESC";
+		//$query = "SELECT login_user_id,login_date FROM ".$track_online_table ." WHERE DATE_ADD(login_date,INTERVAL $time_limit MINUTE) >= '".$current_date."'  "; //WHERE DATE_ADD(login_date,INTERVAL $time_limit MINUTE) >= '".$current_date."'
+		$query = "SELECT login_user_id, login_date FROM ".$track_online_table ." e INNER JOIN ".$table_user ." u ON (u.user_id=e.login_user_id)  
+                  WHERE DATE_ADD(login_date,INTERVAL $time_limit MINUTE) >= '".$current_date."' 
+                  ORDER BY $column $direction 
+                  LIMIT $from, $number_of_items";
 	}
 	
 	if (api_get_multiple_access_url()) {		
@@ -168,25 +198,31 @@ function who_is_online($valid, $friends = false) {
 			if ($friends) {
 				// 	friends from social network is online
 				$query = "SELECT distinct login_user_id,login_date
-							FROM $track_online_table track
-							INNER JOIN $friend_user_table ON (friend_user_id = login_user_id)
-							WHERE track.access_url_id =  $access_url_id AND DATE_ADD(login_date,INTERVAL $valid MINUTE) >= '".$current_date."' AND friend_user_id <> '".api_get_user_id()."' AND relation_type='".USER_RELATION_TYPE_FRIEND."'  ";
+							FROM $track_online_table track INNER JOIN $friend_user_table ON (friend_user_id = login_user_id)
+							WHERE track.access_url_id =  $access_url_id AND DATE_ADD(login_date,INTERVAL $time_limit MINUTE) >= '".$current_date."' AND friend_user_id <> '".api_get_user_id()."' AND relation_type='".USER_RELATION_TYPE_FRIEND."'  
+                            ORDER BY $column $direction 
+                            LIMIT $from, $number_of_items";                        
 			} else {
 				// all users online
 				$query = "SELECT login_user_id,login_date FROM ".$track_online_table ." track  INNER JOIN ".$table_user ." u ON (u.user_id=track.login_user_id)
-						  WHERE track.access_url_id =  $access_url_id AND DATE_ADD(login_date,INTERVAL $valid MINUTE) >= '".$current_date."' ORDER BY picture_uri DESC  ";
+						  WHERE track.access_url_id =  $access_url_id AND DATE_ADD(login_date,INTERVAL $time_limit MINUTE) >= '".$current_date."' 
+                          ORDER BY $column $direction  
+                          LIMIT $from, $number_of_items";
 			}
 		}
 	}	
 	
 	//This query will show all registered users. Only for dev purposes.
-	$query = "SELECT DISTINCT u.user_id as login_user_id, login_date FROM ".$track_online_table ."  e , $table_user u GROUP by u.user_id  ORDER BY picture_uri DESC";
-	
+	/*$query = "SELECT DISTINCT u.user_id as login_user_id, login_date FROM ".$track_online_table ."  e , $table_user u             
+            GROUP by u.user_id  
+            ORDER BY $column $direction  
+            LIMIT $from, $number_of_items";	
+    */
 	$result = Database::query($query);
 	if ($result) {
 		$rtime = time();
 		$rdate = date("Y-m-d H:i:s",$rtime);
-		$validtime = mktime(date("H"),date("i")-$valid,date("s"),date("m"),date("d"),date("Y"));
+		$validtime = mktime(date("H"),date("i")-$time_limit,date("s"),date("m"),date("d"),date("Y"));
 		$rarray = array();
 
 		while(list($login_user_id,$login_date)= Database::fetch_row($result)) {
@@ -214,8 +250,12 @@ function who_is_online($valid, $friends = false) {
 	}
 }
 
-function who_is_online_count($valid, $friends = false) {
-	$valid = (int) $valid;
+function who_is_online_count($valid = null, $friends = false) {	
+    if (empty($valid)) {
+        $valid = api_get_setting('time_limit_whosonline');        
+    } else {
+        $valid = intval($valid);
+    }
 	$current_date		= date('Y-m-d H:i:s',time());
 	$track_online_table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ONLINE);
 	$friend_user_table  = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
@@ -231,8 +271,7 @@ function who_is_online_count($valid, $friends = false) {
 		$query = "SELECT count(login_id) as count  FROM ".$track_online_table ." WHERE DATE_ADD(login_date,INTERVAL $valid MINUTE) >= '".$current_date."'  "; //WHERE DATE_ADD(login_date,INTERVAL $valid MINUTE) >= '".$current_date."'
 	}
 	
-	if (api_get_multiple_access_url()) {
-		$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
+	if (api_get_multiple_access_url()) {		
 		$access_url_id = api_get_current_access_url_id();
 		if ($access_url_id != -1) {
 			if ($friends) {
@@ -248,6 +287,10 @@ function who_is_online_count($valid, $friends = false) {
 			}
 		}
 	}
+    
+    //dev purposes    
+    //$query = "SELECT count(u.user_id)  as count FROM ".$track_online_table ."  e , $table_user u    ";
+    
 	$result = Database::query($query);
 	if (Database::num_rows($result) > 0) {
 		$row = Database::fetch_array($result);

+ 47 - 48
main/inc/lib/social.lib.php

@@ -576,9 +576,9 @@ class SocialManager extends UserManager {
 		$total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
 		$total_invitations = (!empty($total_invitations)?' ('.$total_invitations.')':'');
 		
-		echo '<div class="social-menu">';
+		$html = '<div class="social-menu">';
 		
-	    echo '<script type="text/javascript">      
+	    $html .= '<script type="text/javascript">      
             function show_icon_edit(element_html) { 
                 ident="#edit_image";
                 $(ident).show();
@@ -595,16 +595,16 @@ class SocialManager extends UserManager {
 			//--- Group image
 			$group_info = GroupPortalManager::get_group_data($group_id);
 			$big		= GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],160,GROUP_IMAGE_SIZE_BIG);
-			$original	= GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],'',GROUP_IMAGE_SIZE_ORIGINAL);            
+			//$original	= GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],'',GROUP_IMAGE_SIZE_ORIGINAL);            
 	
-			echo '<div class="social-content-image">';                
-				echo '<div class="social-background-content" onmouseout="hide_icon_edit()" onmouseover="show_icon_edit()"><center>';				
-				echo Display::url('<img src='.$big['file'].' class="social-groups-image" /> </a><br /><br />', api_get_path(WEB_PATH).'main/social/groups.php?id='.$group_id);
+			$html .= '<div class="social-content-image">';                
+				$html .= '<div class="social-background-content" onmouseout="hide_icon_edit()" onmouseover="show_icon_edit()"><center>';				
+				$html .= Display::url('<img src='.$big['file'].' class="social-groups-image" /> </a><br /><br />', api_get_path(WEB_PATH).'main/social/groups.php?id='.$group_id);
 				if (GroupPortalManager::is_group_admin($group_id, api_get_user_id())) {
-					echo '<div id="edit_image" class="hidden_message" style="display:none"><a href="'.api_get_path(WEB_PATH).'main/social/group_edit.php?id='.$group_id.'">'.get_lang('EditGroup').'</a></div>';
+					$html .= '<div id="edit_image" class="hidden_message" style="display:none"><a href="'.api_get_path(WEB_PATH).'main/social/group_edit.php?id='.$group_id.'">'.get_lang('EditGroup').'</a></div>';
 				}
-	    		echo '</center></div>';
-		  	echo '</div>';
+	    		$html .= '</center></div>';
+		  	$html .= '</div>';
 		  	
 	  	} else {
 	  		$img_array = UserManager::get_user_picture_path_by_id($user_id,'web',true,true);	  		
@@ -613,21 +613,20 @@ class SocialManager extends UserManager {
 			$normal_image = $img_array['dir'].$img_array['file'].'?'.uniqid();
 
 	  		//--- User image
-			echo '<div class="social-content-image">';
-				echo '<div class="social-background-content" onmouseout="hide_icon_edit()" onmouseover="show_icon_edit()"><center>';
+			$html .= '<div class="social-content-image">';
+				$html .= '<div class="social-background-content" onmouseout="hide_icon_edit()" onmouseover="show_icon_edit()"><center>';
 
 					if ($img_array['file'] != 'unknown.jpg') {
-		    	  		echo '<a class="thickbox" href="'.$big_image.'"><img src='.$normal_image.' /> </a>';
+		    	  		$html .= '<a class="thickbox" href="'.$big_image.'"><img src='.$normal_image.' /> </a>';
 					} else {
-						echo '<img src='.$normal_image.' width="110px" />';
+						$html .= '<img src='.$normal_image.' width="110px" />';
 					}
 					if (api_get_user_id() == $user_id) {
-						echo '<div id="edit_image" class="hidden_message" style="display:none">';
-						echo '<a href="'.api_get_path(WEB_PATH).'main/auth/profile.php">'.get_lang('EditProfile').'</a></div>';
+						$html .= '<div id="edit_image" class="hidden_message" style="display:none">';
+						$html .= '<a href="'.api_get_path(WEB_PATH).'main/auth/profile.php">'.get_lang('EditProfile').'</a></div>';
 					}
-
-	    	  	echo '</center></div>';
-		  	echo '</div>';
+	    	  	$html .= '</center></div>';
+		  	$html .= '</div>';
 	  	}
 
 		if (!in_array($show, array('shared_profile', 'groups', 'group_edit', 'member_list','waiting_list','invite_friends'))) {
@@ -636,64 +635,63 @@ class SocialManager extends UserManager {
 			echo '<span>'.get_lang('Option').'</span>';
 			echo '</div>';*/
 
-	        echo '<div class="social_menu_items"><ul>';	        	                	
-            echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/home.php">'.Display::return_icon('home.png',get_lang('Home'),array('hspace'=>'6')).'<span class="'.($show=='home'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Home').'</span></a></li>';
-            echo '<li><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('instant_message.png',get_lang('Messages'),array('hspace'=>'6')).'<span class="'.($show=='messages'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Messages').$count_unread_message.'</span></a></li>';
+	        $html .= '<div class="social_menu_items"><ul>';	        	                	
+            $html .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/home.php">'.Display::return_icon('home.png',get_lang('Home'),array('hspace'=>'6')).'<span class="'.($show=='home'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Home').'</span></a></li>';
+            $html .= '<li><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('instant_message.png',get_lang('Messages'),array('hspace'=>'6')).'<span class="'.($show=='messages'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Messages').$count_unread_message.'</span></a></li>';
 
 	        //Invitations
-	        echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitation.png',get_lang('Invitations'),array('hspace'=>'6')).'<span class="'.($show=='invitations'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Invitations').$total_invitations.'</span></a></li>';
+	        $html .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitation.png',get_lang('Invitations'),array('hspace'=>'6')).'<span class="'.($show=='invitations'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Invitations').$total_invitations.'</span></a></li>';
 			
 			//Shared profile and groups
-	        echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('my_shared_profile.png',get_lang('ViewMySharedProfile'),array('hspace'=>'6')).'<span class="'.($show=='shared_profile'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('ViewMySharedProfile').'</span></a></li>
+	        $html .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('my_shared_profile.png',get_lang('ViewMySharedProfile'),array('hspace'=>'6')).'<span class="'.($show=='shared_profile'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('ViewMySharedProfile').'</span></a></li>
 	        	  <li><a href="'.api_get_path(WEB_PATH).'main/social/friends.php">'.Display::return_icon('friend.png',get_lang('Friends'),array('hspace'=>'6')).'<span class="'.($show=='friends'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Friends').'</span></a></li>
 	              <li><a href="'.api_get_path(WEB_PATH).'main/social/groups.php">'.Display::return_icon('group.png',get_lang('SocialGroups'),array('hspace'=>'6')).'<span class="'.($show=='browse_groups'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('SocialGroups').'</span></a></li>';
 
 			//Search users
-	        echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/search.php">'.Display::return_icon('zoom.png',get_lang('Search'),array('hspace'=>'6')).'<span class="'.($show=='search'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Search').'</span></a></li>';
+	        $html .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/search.php">'.Display::return_icon('zoom.png',get_lang('Search'),array('hspace'=>'6')).'<span class="'.($show=='search'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Search').'</span></a></li>';
             		
 			//My files
-			echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/myfiles.php">'.Display::return_icon('briefcase.png',get_lang('MyFiles'),array('hspace'=>'6'),16).'<span class="'.($show=='myfiles'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MyFiles').'</span></a></li>';	
-	        echo'</ul>
+			$html .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/myfiles.php">'.Display::return_icon('briefcase.png',get_lang('MyFiles'),array('hspace'=>'6'),16).'<span class="'.($show=='myfiles'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MyFiles').'</span></a></li>';	
+	        $html .='</ul>
 				  </div>';	     
 		}
 		
         if (in_array($show, $show_groups) && !empty($group_id)) {
-            echo GroupPortalManager::show_group_column_information($group_id, api_get_user_id(), $show);
+            $html .= GroupPortalManager::show_group_column_information($group_id, api_get_user_id(), $show);
         }
 
         if ($show == 'shared_profile') {
 				//echo '<div align="center" class="social-menu-title" ><span class="social-menu-text1">'.get_lang('Menu').'</span></div>';
-	        	echo '<div class="social_menu_items">
+	        	$html .= '<div class="social_menu_items">
 	                	<ul>';
 
     	  	// My own profile
     	  	if ($show_full_profile && $user_id == intval(api_get_user_id())) {
-	        	echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/home.php">'.Display::return_icon('home.png',get_lang('Home'),array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('Home').'</span></a></li>
+	        	$html .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/home.php">'.Display::return_icon('home.png',get_lang('Home'),array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('Home').'</span></a></li>
 	                  <li><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('instant_message.png',get_lang('Messages'),array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('Messages').$count_unread_message.'</span></a></li>';
-	        	echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitation.png',get_lang('Invitations'),array('hspace'=>'6')).'<span class="'.($show=='invitations'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Invitations').$total_invitations.'</span></a></li>';
-	        	echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('my_shared_profile.png',get_lang('ViewMySharedProfile'),array('hspace'=>'6','style'=>'float:left')).'<span class="social-menu-text-active" >'.get_lang('ViewMySharedProfile').'</span></a></li>
+	        	$html .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitation.png',get_lang('Invitations'),array('hspace'=>'6')).'<span class="'.($show=='invitations'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Invitations').$total_invitations.'</span></a></li>';
+	        	$html .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('my_shared_profile.png',get_lang('ViewMySharedProfile'),array('hspace'=>'6','style'=>'float:left')).'<span class="social-menu-text-active" >'.get_lang('ViewMySharedProfile').'</span></a></li>
 	        		  <li><a href="'.api_get_path(WEB_PATH).'main/social/friends.php">'.Display::return_icon('friend.png',get_lang('Friends'),array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('Friends').'</span></a></li>
 	                  <li><a href="'.api_get_path(WEB_PATH).'main/social/groups.php">'.Display::return_icon('group.png',get_lang('SocialGroups'),array('hspace'=>'6')).'<span class="social-menu-text4" >'.get_lang('SocialGroups').'</span></a></li>';
-	        	echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/search.php">'.Display::return_icon('zoom.png',get_lang('Search'),array('hspace'=>'6')).'<span class="'.($show=='search'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Search').'</span></a></li>';
-				echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/myfiles.php">'.Display::return_icon('briefcase.png',get_lang('MyFiles'),array('hspace'=>'6'),16).'<span class="'.($show=='myfiles'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MyFiles').'</span></a></li>';
+	        	$html .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/search.php">'.Display::return_icon('zoom.png',get_lang('Search'),array('hspace'=>'6')).'<span class="'.($show=='search'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('Search').'</span></a></li>';
+				$html .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/myfiles.php">'.Display::return_icon('briefcase.png',get_lang('MyFiles'),array('hspace'=>'6'),16).'<span class="'.($show=='myfiles'?'social-menu-text-active':'social-menu-text4').'" >'.get_lang('MyFiles').'</span></a></li>';
     	  	}
 			
     	  	// My friend profile
-    	  	$html_actions = '';
-
+    	  	
 	  		if ($user_id != api_get_user_id()) {
-	  			echo  '<li><a href="'.api_get_path(WEB_PATH).'main/messages/send_message_to_userfriend.inc.php?height=300&width=470&user_friend='.$user_id.'&view=profile&view_panel=1" class="thickbox" title="'.get_lang('SendMessage').'">';
-	  			echo  Display::return_icon('compose_message.png',get_lang('SendMessage')).'&nbsp;&nbsp;'.get_lang('SendMessage').'</a></li>';						
+	  			$html .=  '<li><a href="'.api_get_path(WEB_PATH).'main/messages/send_message_to_userfriend.inc.php?height=300&width=470&user_friend='.$user_id.'&view=profile&view_panel=1" class="thickbox" title="'.get_lang('SendMessage').'">';
+	  			$html .=  Display::return_icon('compose_message.png',get_lang('SendMessage')).'&nbsp;&nbsp;'.get_lang('SendMessage').'</a></li>';						
 	  		}
 
 	  		//check if I already sent an invitation message
 	  		$invitation_sent_list = SocialManager::get_list_invitation_sent_by_user_id(api_get_user_id());
 
 	  		if (isset($invitation_sent_list[$user_id]) && is_array($invitation_sent_list[$user_id]) && count($invitation_sent_list[$user_id]) > 0 ) {
-	  			echo '<li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitation.png',get_lang('YouAlreadySentAnInvitation')).'&nbsp;&nbsp;'.get_lang('YouAlreadySentAnInvitation').'</a></li>';
+	  			$html .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.Display::return_icon('invitation.png',get_lang('YouAlreadySentAnInvitation')).'&nbsp;&nbsp;'.get_lang('YouAlreadySentAnInvitation').'</a></li>';
 	  		} else {
 	  			if (!$show_full_profile) {
-	  				echo  '<li><a href="'.api_get_path(WEB_PATH).'main/messages/send_message_to_userfriend.inc.php?view_panel=2&height=230&width=500&user_friend='.$user_id.'" class="thickbox" title="'.get_lang('SendInvitation').'">'.Display :: return_icon('invitation.png', get_lang('SocialInvitationToFriends')).'&nbsp;'.get_lang('SendInvitation').'</a></li>';
+	  				$html .=  '<li><a href="'.api_get_path(WEB_PATH).'main/messages/send_message_to_userfriend.inc.php?view_panel=2&height=230&width=500&user_friend='.$user_id.'" class="thickbox" title="'.get_lang('SendInvitation').'">'.Display :: return_icon('invitation.png', get_lang('SocialInvitationToFriends')).'&nbsp;'.get_lang('SendInvitation').'</a></li>';
 	  			}
 	  		}
 			
@@ -703,10 +701,10 @@ class SocialManager extends UserManager {
 					$user_name  = $user_info['complete_name'];                    
                     $options = array('onclick' => "javascript:chatWith('".$user_id."', '".Security::remove_XSS($user_name)."', '".$user_info['user_is_online']."')");
                     $chat_icon = $user_info['user_is_online'] ? Display::return_icon('online.png', get_lang('Online')) : Display::return_icon('offline.png', get_lang('Offline'));
-					echo  Display::tag('li', Display::url($chat_icon.'&nbsp;&nbsp;'.get_lang('Chat'),  'javascript:void(0);', $options));
+					$html .=   Display::tag('li', Display::url($chat_icon.'&nbsp;&nbsp;'.get_lang('Chat'),  'javascript:void(0);', $options));
 				}
 			}
-	  		echo '</ul></div>';
+	  		$html .= '</ul></div>';
 
         	/*
         	// ---- My Agenda Items
@@ -758,17 +756,18 @@ class SocialManager extends UserManager {
 	    	  	}
 	    	  	if (!empty($announcements)) {
 			    	//echo '<div align="center" class="social-menu-title" ><span class="social-menu-text1">'.get_lang('ToolAnnouncement').'</span></div>';
-					echo '<div class="social_menu_items">';
-					echo '<ul>';
+					$html .= '<div class="social_menu_items">';
+					$html .= '<ul>';
 						foreach ($announcements as $announcement) {
-							echo $announcement;
+							$html .= $announcement;
 						}
-					echo '</ul>';
-					echo '</div>';
+					$html .= '</ul>';
+					$html .= '</div>';
 	    	  	}
 			}
         }
-        echo '</div>';
+        $html .= '</div>';
+        return $html;
 	}
 
 	/**
@@ -837,7 +836,7 @@ class SocialManager extends UserManager {
                 $params['per_page'] = 10;                
             }            
             $params['hide_navigation'] = true;
-			echo Display::return_sortable_grid('online', $table_header, $table_data, $params, $query_vars);
+			return Display::return_sortable_grid('online', $table_header, $table_data, $params, $query_vars);
 			//Display::display_sortable_table($table_header, $table_data, array(), array('per_page' => 10), $extra_params, array(),'grid');
 		}
 	}

+ 11 - 11
main/inc/lib/sortabletable.class.php

@@ -166,9 +166,9 @@ class SortableTable extends HTML_Table {
 		$this->column_filters                      = array();
 		$this->form_actions                        = array();
 		$this->checkbox_name                       = null;
-		$this->td_attributes = array ();
-		$this->th_attributes = array ();
-		$this->other_tables = array();
+		$this->td_attributes                       = array();
+		$this->th_attributes                       = array();
+		$this->other_tables                        = array();
 	}
 
 	/**
@@ -482,7 +482,7 @@ class SortableTable extends HTML_Table {
 		}
 
 		if ($hide_navigation) {
-			$items = $this->table_data; // This is a faster way to get what we want			
+			$items = $this->table_data; // This is a faster way to get what we want			            
 		} else {		    
 			// The normal way			
 			$items = $this->get_clean_html($sort_data); // Getting the items of the table						
@@ -532,19 +532,19 @@ class SortableTable extends HTML_Table {
 	 * data-pages.
 	 */
 	public function get_navigation_html () {
-		$pager = $this->get_pager();
-		$pager_links = $pager->getLinks();
-		$showed_items = $pager->getOffsetByPageId();
-		$nav = $pager_links['first'].' '.$pager_links['back'];
-		$nav .= ' '.$pager->getCurrentPageId().' / '.$pager->numPages().' ';
-		$nav .= $pager_links['next'].' '.$pager_links['last'];
+		$pager          = $this->get_pager();
+		$pager_links    = $pager->getLinks();
+		$showed_items   = $pager->getOffsetByPageId();
+		$nav            = $pager_links['first'].' '.$pager_links['back'];
+		$nav            .= ' '.$pager->getCurrentPageId().' / '.$pager->numPages().' ';
+		$nav            .= $pager_links['next'].' '.$pager_links['last'];
 		return $nav;
 	}
 
 	/**
 	 * Get the HTML-code with the data-table.
 	 */
-	public function get_table_html () {
+	public function get_table_html() {
 		$pager    = $this->get_pager();
 		$val      = $pager->getOffsetByPageId();
 		$offset   = $pager->getOffsetByPageId();

+ 8 - 2
main/inc/lib/template.lib.php

@@ -9,6 +9,7 @@ class Template extends Smarty {
 	var $style = 'default'; //see the template folder 
 	var $show_header;
 	var $show_footer;
+    var $help;
 	
 	function __construct($title = '', $show_header = true, $show_footer = true) {
 		$this->title = $title;
@@ -53,6 +54,10 @@ class Template extends Smarty {
         
 		$this->assign('style', $this->style);
 	}
+    
+    function set_help($help) {
+        $this->help = $help;
+    }
 
     /*
      * Use smarty to parse the actions menu
@@ -183,8 +188,9 @@ class Template extends Smarty {
 		
 	}
 
-	private function set_header_parameters($help = null) {
-		$nameTools = $this->title;
+	private function set_header_parameters() {
+        $help       = $this->help;
+		$nameTools  = $this->title;
 		global $_plugins, $lp_theme_css, $mycoursetheme, $user_theme, $platform_theme;
 		global $httpHeadXtra, $htmlHeadXtra, $_course, $_user, $text_dir, $plugins, $_user, 
 				$_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF;		

+ 1 - 1
main/inc/lib/usermanager.lib.php

@@ -2823,7 +2823,7 @@ class UserManager {
 	 *
 	 */
 	public static function get_search_form($query) {
-		echo'<div class="social-groups-home-title"><b>'.get_lang('Search').'</b > ('.get_lang('UsersGroups').')</div>
+		return '<div class="social-groups-home-title"><b>'.get_lang('Search').'</b > ('.get_lang('UsersGroups').')</div>
 		<form method="GET" action="'.api_get_path(WEB_PATH).'main/social/search.php">
 		<table cellspacing="0" cellpadding="0">
 		<tr>

+ 52 - 59
main/messages/inbox.php

@@ -24,7 +24,6 @@ if (isset($_GET['messages_page_nr'])) {
 if (api_get_setting('allow_message_tool')!='true'){
 	api_not_allowed();	
 }
-//jquery thickbox already called from main/inc/header.inc.php
 
 $htmlHeadXtra[]='<script language="javascript">
 
@@ -81,13 +80,13 @@ if (isset($_GET['form_reply']) || isset($_GET['form_delete'])) {
 		}
 		if (isset($user_reply) && !is_null($user_id_by_email) && strlen($info_reply[0]) >0) {
 			MessageManager::send_message($user_id_by_email, $title, $content);
-			MessageManager::display_success_message($user_id_by_email);
-			inbox_display();
+			$show_message .= MessageManager::return_message($user_id_by_email,'confirmation');
+			$social_right_content .= inbox_display();
 			exit;
 		} elseif (is_null($user_id_by_email)) {
 			$message_box=get_lang('ErrorSendingMessage');
-			Display::display_error_message(api_xml_http_response_encode($message_box),false);
-			inbox_display();
+			$show_message .= Display::return_message(api_xml_http_response_encode($message_box),'error');
+			$social_right_content .= inbox_display();
 			exit;
 		}
 	} elseif (trim($info_delete[0])=='delete' ) {
@@ -95,18 +94,12 @@ if (isset($_GET['form_reply']) || isset($_GET['form_delete'])) {
 			MessageManager::delete_message_by_user_receiver(api_get_user_id(), $info_delete[$i]);
 		}
 		$message_box=get_lang('SelectedMessagesDeleted');
-		Display::display_normal_message(api_xml_http_response_encode($message_box),false);
-	   	inbox_display();
+		$show_message .= Display::return_message(api_xml_http_response_encode($message_box));
+	   	$social_right_content .= inbox_display();
 	    exit;
 	}
 }
 
-
-$link_ref="new_message.php";
-$table_message = Database::get_main_table(TABLE_MESSAGE);
-
-
-//api_display_tool_title(api_xml_http_response_encode(get_lang('Inbox')));
 if ($_GET['f']=='social') {
 	$this_section = SECTION_SOCIAL;
 	$interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('Social'));
@@ -117,63 +110,63 @@ if ($_GET['f']=='social') {
 	$interbreadcrumb[]= array ('url' => '#','name' => get_lang('Inbox'));
 }
 
-Display::display_header('');
+//Display::display_header('');
 $social_parameter = '';
 
 if ($_GET['f']=='social' || api_get_setting('allow_social_tool') == 'true') {
 	$social_parameter = '?f=social';	
 } else {
     
-	//Comes from normal profile	
-	echo '<div class="actions">';
+	//Comes from normal profile		
 	if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
-		echo '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'&nbsp;'.get_lang('ViewSharedProfile').'</a>';
+		$actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'&nbsp;'.get_lang('ViewSharedProfile').'</a>';
 	}
 	
-	if (api_get_setting('allow_message_tool') == 'true') {
-		//echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</a>';		
-		echo '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).get_lang('ComposeMessage').'</a>';
-		echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).get_lang('Inbox').'</a>';
-        echo '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).get_lang('Outbox').'</a>';            
+	if (api_get_setting('allow_message_tool') == 'true') {		
+		$actions .=  '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).get_lang('ComposeMessage').'</a>';
+		$actions .=  '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).get_lang('Inbox').'</a>';
+        $actions .=  '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).get_lang('Outbox').'</a>';            
 	}	
-	echo '</div>';
+}	
+
+//LEFT CONTENT			
+if (api_get_setting('allow_social_tool') == 'true') { 		
+    $social_left_content = SocialManager::show_social_menu('messages');
 }
 
-echo '<div id="social-content">';
-	$id_content_right = '';
-	//LEFT CONTENT			
-	if (api_get_setting('allow_social_tool') != 'true') { 
-		$id_content_right = 'inbox';		
-	} else {		
-		$id_content_right = 'social-content-right';
-		echo '<div id="social-content-left">';	
-			//this include the social menu div
-			SocialManager::show_social_menu('messages');
-		echo '</div>';		
-	}
+//Right content
+
+if (api_get_setting('allow_social_tool') == 'true') {
+    $social_right_content .=  '<div class="actions">';				
+        $social_right_content .=  '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?f=social">'.Display::return_icon('compose_message.png', get_lang('ComposeMessage'), array(), 32).'</a>';
+        $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php?f=social">'.Display::return_icon('outbox.png', get_lang('Outbox'), array(), 32).'</a>';                        
+    $social_right_content .=  '</div>';
 
-	echo '<div id="'.$id_content_right.'">';    
-    if (api_get_setting('allow_social_tool') == 'true') {
-    	echo '<div class="actions">';				
-    		echo '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?f=social">'.Display::return_icon('compose_message.png', get_lang('ComposeMessage'), array(), 32).'</a>';
-            echo '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php?f=social">'.Display::return_icon('outbox.png', get_lang('Outbox'), array(), 32).'</a>';                        
-    	echo '</div>';
-    		
-    }	
-    //MAIN CONTENT
-    if (!isset($_GET['del_msg'])) {
-    	inbox_display();
-    } else {
-    	$num_msg = intval($_POST['total']);
-    	for ($i=0;$i<$num_msg;$i++) {
-    		if($_POST[$i]) {
-    			//the user_id was necesarry to delete a message??
-    			MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_POST['_'.$i]);
-    		}
-    	}
-    	inbox_display();
-    }    
-	echo '</div>';	
-echo '</div>';
+}	
+//MAIN CONTENT
+if (!isset($_GET['del_msg'])) {
+    $social_right_content .= inbox_display();
+} else {
+    $num_msg = intval($_POST['total']);
+    for ($i=0;$i<$num_msg;$i++) {
+        if($_POST[$i]) {
+            //the user_id was necesarry to delete a message??
+            $show_message .= MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_POST['_'.$i]);
+        }
+    }
+    $social_right_content .= inbox_display();
+}    
+$social_right_content .=  '</div>';	
 
-Display::display_footer();
+$tpl = new Template($tool_name);
+if (api_get_setting('allow_social_tool') == 'true') {
+    $tpl->assign('social_left_content', $social_left_content);
+    $tpl->assign('social_left_menu', $social_left_menu);
+    $tpl->assign('social_right_content', $social_right_content);
+    $social_layout = $tpl->get_template('layout/social_layout.tpl');
+    $content = $tpl->fetch($social_layout);
+}
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 95 - 99
main/messages/new_message.php

@@ -45,7 +45,6 @@ function validate(form,list) {
 
 $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
 $htmlHeadXtra[] = '<link  href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/style.css" rel="stylesheet" type="text/css" />';
-
 $htmlHeadXtra[] = '<script type="text/javascript">
 $(document).ready(function () {
     $("#users").fcbkcomplete({
@@ -130,7 +129,8 @@ function show_compose_to_any ($user_id) {
 	$online_user_list = MessageManager::get_online_user_list($user_id);
 	$default['user_list'] = 0;
 	$online_user_list=null;
-	manage_form($default, $online_user_list);
+	$html = manage_form($default, $online_user_list);
+    return $html;
 }
 
 function show_compose_reply_to_message($message_id, $receiver_id) {
@@ -140,31 +140,29 @@ function show_compose_reply_to_message($message_id, $receiver_id) {
 	$result = Database::query($query);
 	$row = Database::fetch_array($result,'ASSOC');
 	if (!isset($row['user_sender_id'])) {
-		echo get_lang('InvalidMessageId');
-		exit;
+		$html = get_lang('InvalidMessageId');
+		return $html;
 	}
 	$pre_html = '<div class="row">
 				<div class="label">'.get_lang('SendMessageTo').': </div>
-				<div class="formw">';
-                
+				<div class="formw">';                
 	$post = '</div></div>';
-	$multi_select = '<select id="users" name="users">
-					 </select>';
-    echo $pre_html.'<strong>'.GetFullUserName($row['user_sender_id']).'</strong>'.$post;
+    $sent_to = $pre_html.'<strong>'.GetFullUserName($row['user_sender_id']).'</strong>'.$post;
 	$default['users'] = array($row['user_sender_id']);
-	manage_form($default);
+	$html .= manage_form($default, null, $sent_to);
+    return $html;
 }
 
 function show_compose_to_user ($receiver_id) {
 	global $charset;
-	echo get_lang('To').':&nbsp;<strong>'.	GetFullUserName($receiver_id).'</strong>';
+	$html = get_lang('To').':&nbsp;<strong>'.GetFullUserName($receiver_id).'</strong>';
 	$default['title'] = api_xml_http_response_encode(get_lang('EnterTitle'));
 	$default['users'] = array($receiver_id);
-	manage_form($default);
+	$html .= manage_form($default);
+    return $html;
 }
 
-function manage_form ($default, $select_from_user_list = null) {
-	$table_message = Database::get_main_table(TABLE_MESSAGE);
+function manage_form($default, $select_from_user_list = null, $sent_to = null) {	
 
 	$group_id 		= isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
 	$message_id 	= isset($_GET['message_id'])  ?  intval($_GET['message_id']) : null;	
@@ -178,12 +176,14 @@ function manage_form ($default, $select_from_user_list = null) {
 			$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 (!empty($sent_to)) {
+                $form->addElement('html',$sent_to);
+            }
 			if (empty($default['users'])) {
 				//the magic should be here
 				$pre_html = '<div class="row">
 							 <div class="label">'.get_lang('SendMessageTo').'</div>
-							<div class="formw">';
-                            
+							<div class="formw">';                            
 				$post = '</div></div>';
 				$multi_select = '<select id="users" name="users">
 	      						 </select>';
@@ -231,7 +231,7 @@ function manage_form ($default, $select_from_user_list = null) {
 		$default['title'] = get_lang('Re:').$message_info['title'];
 	}
 	$form->setDefaults($default);
-
+    $html = '';
 	if ($form->validate()) {
 		$check = Security::check_token('post');		
 		if ($check) {			
@@ -247,9 +247,9 @@ function manage_form ($default, $select_from_user_list = null) {
 					$res = MessageManager::send_message($user, $title, $content, $_FILES, $file_comments, $group_id, $parent_id);				
 					if ($res) {
 						if (is_string($res)) {
-							Display::display_error_message($res);
+							$html .= Display::return_message($res, 'error');
 						} else {
-							MessageManager::display_success_message($user);
+							$html .= MessageManager::display_success_message($user);
 						}
 					}
 				}       
@@ -262,8 +262,9 @@ function manage_form ($default, $select_from_user_list = null) {
 		$token = Security::get_token();
 		$form->addElement('hidden','sec_token');
 		$form->setConstants(array('sec_token' => $token));
-		$form->display();
+		$html .= $form->return_form();
 	}
+    return $html;
 }
 
 /* MAIN SECTION */
@@ -272,101 +273,96 @@ if ($_GET['f']=='social') {
 	$interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('Social'));	
 } else {
 	$this_section = SECTION_MYPROFILE;
-	$interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile'));
-	//$interbreadcrumb[]= array ('url' => '#','name' => get_lang('ComposeMessage'));
+	$interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile'));	
 }
 
-Display::display_header(get_lang('ComposeMessage'));
+//Display::display_header(get_lang('ComposeMessage'));
 
 $group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
 
 if ($group_id != 0) {
-	echo '<div class=actions>';
-	echo '<a href="'.api_get_path(WEB_PATH).'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="'.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>';
+	$social_right_content .= '<div class=actions>';
+	$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'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>';
+	$social_right_content .= '<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>';
+	$social_right_content .= '</div>';
 } else {
 	if ($_GET['f']=='social') {
-                
-
 	} else {
-		echo '<div class=actions>';
+		$social_right_content .= '<div class=actions>';
 		if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
-			echo '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'&nbsp;'.get_lang('ViewSharedProfile').'</a>';
+			$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'&nbsp;'.get_lang('ViewSharedProfile').'</a>';
 		}
 		if (api_get_setting('allow_message_tool') == 'true') {
-			echo '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).get_lang('ComposeMessage').'</a>';
-			echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).get_lang('Inbox').'</a>';
-            echo '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).get_lang('Outbox').'</a>';		    
+			$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).get_lang('ComposeMessage').'</a>';
+			$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).get_lang('Inbox').'</a>';
+            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).get_lang('Outbox').'</a>';		    
 		}
-		echo '</div>';
+		$social_right_content .= '</div>';
 	}
 }
 
-echo '<div id="social-content">';
-	$id_content_right = '';
-	//LEFT COLUMN
-	if (api_get_setting('allow_social_tool') != 'true') {
-		$id_content_right = 'inbox';		
-	} else {		
-		echo '<div id="social-content-left">';
-		//this include the social menu div
-		SocialManager::show_social_menu('messages');
-		echo '</div>';
-		$id_content_right = 'social-content-right';
-	}
-
-	echo '<div id="'.$id_content_right.'">';
 	
-		//MAIN CONTENT
-		if (api_get_setting('allow_social_tool') == 'true') {			
-            echo '<div class="actions">';              
-            echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
-            echo '</div>';
-		}
-		if (!isset($_POST['compose'])) {
-			if(isset($_GET['re_id'])) {
-				show_compose_reply_to_message($_GET['re_id'], api_get_user_id());
-			} elseif(isset($_GET['send_to_user'])) {
-				show_compose_to_user($_GET['send_to_user']);
-			} else {
-				show_compose_to_any($_user['user_id']);
-		  	}
-		} else {
-			$restrict = false;
-			if (isset($_POST['users'])) {
-				$restrict = true;
-			} elseif (isset($_POST['group_id'])) {
-				$restrict = true;
-			} elseif(isset($_POST['hidden_user'])) {
-				$restrict = true;
-			}
-
-			$default['title']	= $_POST['title'];
-			$default['content'] = $_POST['content'];
+//LEFT COLUMN	
 
-			// comes from a reply button
-			if (isset($_GET['re_id'])) {
-				manage_form($default);
-			} else {
-				// post
-				if ($restrict) {
-					if (!isset($_POST['group_id'])) {
-						$default['users']	 = $_POST['users'];
-					} else {
-						$default['group_id'] = $_POST['group_id'];
-					}
-					if (isset($_POST['hidden_user'])) {
-						$default['users']	 = array($_POST['hidden_user']);
-					}					
-					manage_form($default);
-				} else {
-					Display::display_error_message(get_lang('ErrorSendingMessage'));
-				}
-			}
-		}
-	echo '</div>';
-echo '</div>';
+if (api_get_setting('allow_social_tool') == 'true') {			
+    $social_left_content = SocialManager::show_social_menu('messages');				
+    $social_right_content .= '<div class="actions">';              
+    $social_right_content .=  '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
+    $social_right_content .=  '</div>';
+}
+//MAIN CONTENT
+if (!isset($_POST['compose'])) {
+    if(isset($_GET['re_id'])) {
+        $social_right_content .= show_compose_reply_to_message($_GET['re_id'], api_get_user_id());
+    } elseif(isset($_GET['send_to_user'])) {
+        $social_right_content .= show_compose_to_user($_GET['send_to_user']);
+    } else {
+        $social_right_content .= show_compose_to_any($_user['user_id']);
+    }
+} else {
+    $restrict = false;
+    if (isset($_POST['users'])) {
+        $restrict = true;
+    } elseif (isset($_POST['group_id'])) {
+        $restrict = true;
+    } elseif(isset($_POST['hidden_user'])) {
+        $restrict = true;
+    }
 
-/*		FOOTER */
-Display::display_footer();
+    $default['title']	= $_POST['title'];
+    $default['content'] = $_POST['content'];
+
+    // comes from a reply button
+    if (isset($_GET['re_id'])) {
+        $social_right_content .= manage_form($default);
+    } else {
+        // post
+        if ($restrict) {
+            if (!isset($_POST['group_id'])) {
+                $default['users']	 = $_POST['users'];
+            } else {
+                $default['group_id'] = $_POST['group_id'];
+            }
+            if (isset($_POST['hidden_user'])) {
+                $default['users']	 = array($_POST['hidden_user']);
+            }					
+            $social_right_content .= manage_form($default);
+        } else {
+            $social_right_content .= Display::return_message(get_lang('ErrorSendingMessage'),'error');
+        }
+    }
+}
+$social_right_content .=  '</div>';
+
+$tpl = new Template(get_lang('ComposeMessage'));
+if (api_get_setting('allow_social_tool') == 'true') {
+    $tpl->assign('social_left_content', $social_left_content);
+    $tpl->assign('social_left_menu', $social_left_menu);
+    $tpl->assign('social_right_content', $social_right_content);
+    $social_layout = $tpl->get_template('layout/social_layout.tpl');
+    $content = $tpl->fetch($social_layout);
+}
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 59 - 74
main/messages/outbox.php

@@ -73,28 +73,20 @@ if ($_GET['f']=='social') {
 	$interbreadcrumb[]= array ('url' => '#','name' => get_lang('Outbox'));
 }
 
-Display::display_header('');
-
 if ($_GET['f']=='social') {
 
-} else {
-	
-	if (api_get_setting('extended_profile') == 'true') {
-		echo '<div class="actions">';
+} else {	
+	if (api_get_setting('extended_profile') == 'true') {		
 		
 		if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
-			echo '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'&nbsp;'.get_lang('ViewSharedProfile').'</a>';
+			$actions .=  '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'&nbsp;'.get_lang('ViewSharedProfile').'</a>';
 		}
 		if (api_get_setting('allow_message_tool') == 'true') {
 			//echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</a>';
-			 echo '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).get_lang('ComposeMessage').'</a>';
-            echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).get_lang('Inbox').'</a>';
-            echo '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).get_lang('Outbox').'</a>';
-          
-            
-		}	
-		//echo '<a href="'.api_get_path(WEB_PATH).'main/auth/profile.php?type=reduced">'.Display::return_icon('edit.gif', get_lang('EditNormalProfile')).'&nbsp;'.get_lang('EditNormalProfile').'</a>';
-		echo '</div>';
+			$actions .=  '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).get_lang('ComposeMessage').'</a>';
+            $actions .=  '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).get_lang('Inbox').'</a>';
+            $actions .=  '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).get_lang('Outbox').'</a>';          
+		}			
 	}
 }
 
@@ -106,69 +98,62 @@ if( trim($info_delete_outbox[0])=='delete' ) {
 	for ($i=1;$i<=$count_delete_outbox;$i++) {
 		MessageManager::delete_message_by_user_sender(api_get_user_id(),$info_delete_outbox[$i]);
 	}
-		$message_box=get_lang('SelectedMessagesDeleted').
-			'&nbsp
-			<br><a href="../social/index.php?#remote-tab-3">'.
-			get_lang('BackToOutbox').
-			'</a>';
-		Display::display_normal_message(api_xml_http_response_encode($message_box),false);
-	    exit;
+    $message_box=get_lang('SelectedMessagesDeleted').
+        '&nbsp
+        <br><a href="../social/index.php?#remote-tab-3">'.
+        get_lang('BackToOutbox').
+        '</a>';
+    Display::display_normal_message(api_xml_http_response_encode($message_box),false);
+    exit;
 }
 
-$table_message = Database::get_main_table(TABLE_MESSAGE);
-
-$user_sender_id = api_get_user_id();
-
 $action = null;
 if (isset($_REQUEST['action'])) {
     $action = $_REQUEST['action'];
 }
 
-echo '<div id="social-content">';
-	$id_content_right = '';
-	//LEFT COLUMN	
-	if (api_get_setting('allow_social_tool') != 'true') { 
-		$id_content_right = 'outbox';				
-	} else {		
-		$id_content_right = 'social-content-right';
-		echo '<div id="social-content-left">';	
-			//this include the social menu div
-			SocialManager::show_social_menu('messages');
-		echo '</div>';			
-	}
-	
-	echo '<div id="'.$id_content_right.'">';
-			if (api_get_setting('allow_social_tool') == 'true') {				    
-                echo '<div class="actions">';              
-                echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
-                echo '</div>';
-			}	
-			//MAIN CONTENT
-			if ($action == 'delete') {
-				$delete_list_id=array();
-				if (isset($_POST['out'])) {
-					$delete_list_id=$_POST['out'];
-				}
-				if (isset($_POST['id'])) {
-					$delete_list_id=$_POST['id'];
-				}
-				for ($i=0;$i<count($delete_list_id);$i++) {
-					MessageManager::delete_message_by_user_sender(api_get_user_id(), $delete_list_id[$i]);
-				}
-				$delete_list_id=array();
-				outbox_display();
-				
-			} elseif($action =='deleteone') {
-				$delete_list_id=array();
-				$id=Security::remove_XSS($_GET['id']);
-				MessageManager::delete_message_by_user_sender(api_get_user_id(),$id);
-				$delete_list_id=array();
-				outbox_display();
-			} else {
-				outbox_display();
-			}
-	echo '</div>';
-echo '</div>';
-
-/*		FOOTER */
-Display::display_footer();
+if (api_get_setting('allow_social_tool') == 'true') {				    
+    $social_left_content = SocialManager::show_social_menu('messages');
+    $social_right_content .= '<div class="actions">';              
+    $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('back.png', get_lang('Back'), array(), 32).'</a>';
+    $social_right_content .= '</div>';
+}	
+//MAIN CONTENT
+if ($action == 'delete') {
+    $delete_list_id=array();
+    if (isset($_POST['out'])) {
+        $delete_list_id=$_POST['out'];
+    }
+    if (isset($_POST['id'])) {
+        $delete_list_id=$_POST['id'];
+    }
+    for ($i=0;$i<count($delete_list_id);$i++) {
+        MessageManager::delete_message_by_user_sender(api_get_user_id(), $delete_list_id[$i]);
+    }
+    $delete_list_id=array();
+    $social_right_content .= outbox_display();
+
+} elseif($action =='deleteone') {
+    $delete_list_id=array();
+    $id = Security::remove_XSS($_GET['id']);
+    MessageManager::delete_message_by_user_sender(api_get_user_id(),$id);
+    $delete_list_id=array();
+    $social_right_content .= outbox_display();
+} else {
+    $social_right_content .= outbox_display();
+}
+
+$tpl = new Template(get_lang('ComposeMessage'));
+if (api_get_setting('allow_social_tool') == 'true') {
+    $tpl->assign('social_left_content', $social_left_content);
+    $tpl->assign('social_left_menu', $social_left_menu);
+    $tpl->assign('social_right_content', $social_right_content);
+    $social_layout = $tpl->get_template('layout/social_layout.tpl');
+    $content = $tpl->fetch($social_layout);
+} else {
+    $content = $social_right_content;
+}
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 43 - 42
main/messages/view_message.php

@@ -25,64 +25,65 @@ if ($_REQUEST['f']=='social') {
 	$interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile'));	
 }
 
-Display::display_header(get_lang('View'));
-
 if ($_GET['f']=='social') {	
 	$social_parameter = '?f=social';
 } else {
 	if (api_get_setting('extended_profile') == 'true') {
-		echo '<div class="actions">';
+		$social_right_content .= '<div class="actions">';
 		
 		if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
-			echo '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'&nbsp;'.get_lang('ViewSharedProfile').'</a>';
+			$social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.Display::return_icon('shared_profile.png', get_lang('ViewSharedProfile')).'&nbsp;'.get_lang('ViewSharedProfile').'</a>';
 		}
 		if (api_get_setting('allow_message_tool') == 'true') {
 			//echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png').' '.get_lang('Messages').'</a>';
 			
-		    echo '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).get_lang('ComposeMessage').'</a>';
-            echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).get_lang('Inbox').'</a>';
-            echo '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).get_lang('Outbox').'</a>';
+		    $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php">'.Display::return_icon('message_new.png',get_lang('ComposeMessage')).get_lang('ComposeMessage').'</a>';
+            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php">'.Display::return_icon('inbox.png',get_lang('Inbox')).get_lang('Inbox').'</a>';
+            $social_right_content .= '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php">'.Display::return_icon('outbox.png',get_lang('Outbox')).get_lang('Outbox').'</a>';
 			
 		}	
 		//echo '<a href="'.api_get_path(WEB_PATH).'main/auth/profile.php?type=reduced">'.Display::return_icon('edit.gif', get_lang('EditNormalProfile')).'&nbsp;'.get_lang('EditNormalProfile').'</a>';
 		
-		echo '</div>';
+		$social_right_content .= '</div>';
 	}
 }
 
-echo '<div id="social-content">';	
-	if (empty($_GET['id'])) {
-		$id_message = $_GET['id_send'];
-		$source = 'outbox';
-		$show_menu = 'messages_outbox';
-	} else {
-		$id_message = $_GET['id'];
-		$source = 'inbox';
-		$show_menu = 'messages_inbox';
-	}
-	$id_content_right = '';
-	//LEFT COLUMN
-	if (api_get_setting('allow_social_tool') != 'true') { 
-		$id_content_right = 'inbox';	
-	} else {		
-		$id_content_right = 'social-content-right';
-		echo '<div id="social-content-left">';	
-			//this include the social menu div			
-			SocialManager::show_social_menu($show_menu);
-		echo '</div>';				
-	}
+if (empty($_GET['id'])) {
+    $id_message = $_GET['id_send'];
+    $source = 'outbox';
+    $show_menu = 'messages_outbox';
+} else {
+    $id_message = $_GET['id'];
+    $source = 'inbox';
+    $show_menu = 'messages_inbox';
+}
+
+//LEFT COLUMN
+if (api_get_setting('allow_social_tool') == 'true') { 
+    $social_left_content = SocialManager::show_social_menu($show_menu);        
+}	
+//MAIN CONTENT
+$message = MessageManager::show_message_box($id_message,$source);
 
-	echo '<div id="'.$id_content_right.'">';	
-	//MAIN CONTENT
-	$message = MessageManager::show_message_box($id_message,$source);
-	
-	if (!empty($message)) {
-		echo $message;
-	} else {
-		api_not_allowed();
-	}	
-	echo '</div>';
-echo '</div>';
+if (!empty($message)) {
+    $social_right_content .= $message;
+} else {
+    api_not_allowed();
+}	
+
+
+$tpl = new Template(get_lang('View'));
+if (api_get_setting('allow_social_tool') == 'true') {
+    $tpl->assign('social_left_content', $social_left_content);
+    $tpl->assign('social_left_menu', $social_left_menu);
+    $tpl->assign('social_right_content', $social_right_content);
+    $social_layout = $tpl->get_template('layout/social_layout.tpl');
+    $content = $tpl->fetch($social_layout);
+} else {
+    $content = $social_right_content;
+}
 
-/*		FOOTER */
-Display::display_footer();
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 5 - 10
main/mySpace/myStudents.php

@@ -297,16 +297,11 @@ if (!empty($student_id)) {
 	echo '</div>';	
 
 	// is the user online ?
-	$student_online = intval($_GET['student']);
-	$users_online = who_is_online(30);
-	foreach ($users_online as $online) {
-		if (in_array($_GET['student'], $online)) {
-			$online = get_lang('Yes');
-			break;
-		} else {
-			$online = get_lang('No');
-		}
-	}
+    if (user_is_online($_GET['student'])) {
+        $online = get_lang('Yes');
+    } else {
+        $online = get_lang('No');
+    }
 		
 	// get average of score and average of progress by student
 	$avg_student_progress = $avg_student_score = $nb_courses = 0;

+ 22 - 20
main/social/friends.php

@@ -85,20 +85,12 @@ function clear_form () {
 $interbreadcrumb[]= array ('url' =>'profile.php','name' => get_lang('Social'));
 $interbreadcrumb[]= array ('url' =>'#','name' => get_lang('Friends'));
 
-Display :: display_header($tool_name, 'Groups');
+//Display :: display_header($tool_name, 'Groups');
 
-echo '<div id="social-content">';
-
-	echo '<div id="social-content-left">';	
-		//this include the social menu div
-		SocialManager::show_social_menu('friends');	
-	echo '</div>';
-	echo '<div id="social-content-right">';
+$social_left_content = SocialManager::show_social_menu('friends');	
 	
-$language_variable	= api_xml_http_response_encode(get_lang('Contacts'));
 $user_id	= api_get_user_id();
 
-$list_path_friends	= array();
 $user_id	    = api_get_user_id();
 $name_search = isset($_POST['search_name_q']) ? $_POST['search_name_q']: null;
 $number_friends = 0;
@@ -109,14 +101,13 @@ if (isset($name_search) && $name_search!='undefined') {
 	$friends = SocialManager::get_friends($user_id);
 }
 
-
 if (count($friends) == 0 ) {
-	echo get_lang('NoFriendsInYourContactList').'<br /><br />';
-	echo '<a href="search.php">'.get_lang('TryAndFindSomeFriends').'</a>';	
+	$social_right_content = get_lang('NoFriendsInYourContactList').'<br /><br />';
+	$social_right_content .= '<a href="search.php">'.get_lang('TryAndFindSomeFriends').'</a>';	
 } else {
-	echo get_lang('Search') .'&nbsp;&nbsp; : &nbsp;&nbsp;'; ?>
-	<input class="social-search-image" type="text" id="id_search_image" name="id_search_image" onkeyup="search_image_social()" />
-	<?php				
+	$social_right_content = get_lang('Search') .'&nbsp;&nbsp; : &nbsp;&nbsp;';
+	$social_right_content .= '<input class="social-search-image" type="text" id="id_search_image" name="id_search_image" onkeyup="search_image_social()" />';
+    
 		$friend_html = '';
 		$number_of_images = 8;
 		
@@ -141,8 +132,19 @@ if (count($friends) == 0 ) {
 			$friend_html.='</td></tr>';
 		}
 		$friend_html.='<br/></table>';
-		echo $friend_html;
+		$social_right_content .=  $friend_html;
 	}
-	echo '</div>';
-	echo '</div>';	
-Display :: display_footer();
+	$social_right_content .=  '</div>';
+	$social_right_content .=  '</div>';	
+    $social_right_content .=  '</div>';	
+
+$tpl = new Template(get_lang('Social'));
+$tpl->assign('social_left_content', $social_left_content);
+$tpl->assign('social_left_menu', $social_left_menu);
+$tpl->assign('social_right_content', $social_right_content);
+$social_layout = $tpl->get_template('layout/social_layout.tpl');
+$content = $tpl->fetch($social_layout);
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 21 - 12
main/social/group_add.php

@@ -102,15 +102,24 @@ $this_section = SECTION_SOCIAL;
 $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
 $interbreadcrumb[]= array ('url' =>'groups.php','name' => get_lang('Groups'));
 $interbreadcrumb[]= array ('url' =>'#','name' => $nameTools);
-Display :: display_header($tool_name, 'Groups');
-
-echo '<div id="social-content">';
-	echo '<div id="social-content-left">';
-		//show the action menu
-		SocialManager::show_social_menu('group_add');
-	echo '</div>';
-	echo '<div id="social-content-right">';	
-    $form->display();	
-    echo '</div>';
-echo '</div>';
-Display :: display_footer();
+//Display :: display_header($tool_name, 'Groups');
+
+$social_left_content = SocialManager::show_social_menu('group_add');
+
+$social_right_content .= $form->return_form();	
+
+
+
+
+
+$tpl = new Template($tool_name);
+$tpl->set_help('Groups');
+$tpl->assign('social_left_content', $social_left_content);
+$tpl->assign('social_left_menu', $social_left_menu);
+$tpl->assign('social_right_content', $social_right_content);
+$social_layout = $tpl->get_template('layout/social_layout.tpl');
+$content = $tpl->fetch($social_layout);
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 15 - 18
main/social/group_edit.php

@@ -127,8 +127,6 @@ if ( $form->validate()) {
 	exit();
 }
 
-Display::display_header($tool_name);
-
 // Group picture
 $image_path = GroupPortalManager::get_group_picture_path_by_id($group_id,'web');
 $image_dir = $image_path['dir'];
@@ -143,19 +141,18 @@ $big_image_width = $big_image_size['width'];
 $big_image_height = $big_image_size['height'];
 $url_big_image = $big_image.'?rnd='.time();
 
-//Shows left column
-//echo GroupPortalManager::show_group_column_information($group_id, api_get_user_id());
-
-echo '<div id="social-content">';
-	echo '<div id="social-content-left">';
-	//this include the social menu div
-	SocialManager::show_social_menu('group_edit',$group_id);
-	echo '</div>';
-	echo '<div id="social-content-right">';
-	// Display form
-	$form->display();						
-	echo '</div>';
-echo '</div>';
-
-// Footer
-Display::display_footer();
+$social_left_content = SocialManager::show_social_menu('group_edit',$group_id);
+$social_right_content = $form->return_form();						
+
+
+$tpl = new Template($tool_name);
+$tpl->set_help('Groups');
+$tpl->assign('social_left_content', $social_left_content);
+$tpl->assign('social_left_menu', $social_left_menu);
+$tpl->assign('social_right_content', $social_right_content);
+$social_layout = $tpl->get_template('layout/social_layout.tpl');
+$content = $tpl->fetch($social_layout);
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 113 - 153
main/social/group_invitation.php

@@ -144,7 +144,6 @@ function search_users($needle,$type) {
 	            	$return .= '...<br />';
 	            }
 			}
-
 			$xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));
 
 		} else {
@@ -158,7 +157,6 @@ function search_users($needle,$type) {
 			$xajax_response -> addAssign('ajax_list_users_multiple','innerHTML',api_utf8_encode($return));
 		}
 	}
-
 	return $xajax_response;
 }
 
@@ -202,14 +200,13 @@ $errorMsg=$firstLetterUser=$firstLetterSession='';
 $UserList=$SessionList=array();
 $users=$sessions=array();
 
-Display :: display_header($tool_name, 'Groups');
+//Display :: display_header($tool_name, 'Groups');
 
-if($_POST['form_sent']) {
+if ($_POST['form_sent']) {
 	$form_sent			= $_POST['form_sent'];
 	$firstLetterUser	= $_POST['firstLetterUser'];
 	$firstLetterSession	= $_POST['firstLetterSession'];
 	$user_list			= $_POST['sessionUsersList'];
-
 	$group_id			= intval($_POST['id']);
 
 	if(!is_array($user_list)) {
@@ -307,50 +304,36 @@ if ($add_type == 'multiple') {
 	$link_add_type_unique = Display::return_icon('single.gif').get_lang('SessionAddTypeUnique');
 	$link_add_type_multiple = '<a href="'.api_get_self().'?id='.$group_id.'&add='.Security::remove_XSS($_GET['add']).'&add_type=multiple">'.Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple').'</a>';
 }
-	/* <?php $link_add_type_unique ?>&nbsp;|&nbsp;<?php $link_add_type_multiple ?> */
-
-	//Shows left column
-	//echo GroupPortalManager::show_group_column_information($group_id, api_get_user_id());
-
-	echo '<div id="social-content">';
-		echo '<div id="social-content-left">';
-			//this include the social menu div
-			SocialManager::show_social_menu('invite_friends',$group_id);
-		echo '</div>';
 
-	echo '<div id="social-content-right">';	
-    echo '<h2>'.Security::remove_XSS($group_info['name'], STUDENT, true).'</h2>';
+$social_left_content = SocialManager::show_social_menu('invite_friends',$group_id);
+$social_right_content .=  '<h2>'.Security::remove_XSS($group_info['name'], STUDENT, true).'</h2>';
     
-	if (count($nosessionUsersList) == 0) {
-			$friends = SocialManager::get_friends(api_get_user_id());
-			if ($friends == 0) {
-				echo get_lang('YouNeedToHaveFriendsInYourSocialNetwork');
-			} else {
-				echo get_lang('YouAlreadyInviteAllYourContacts');
-			}
-			echo '<div>';
-			echo '<a href="search.php">'.get_lang('TryAndFindSomeFriends').'</a>';
-			echo '</div>';
-
-			echo '</div>'; // end layout right
-		echo '</div>'; //
-		Display::display_footer();
-		exit;
-	}
-?>
+if (count($nosessionUsersList) == 0) {
+        $friends = SocialManager::get_friends(api_get_user_id());
+        if ($friends == 0) {
+            $social_right_content .=  get_lang('YouNeedToHaveFriendsInYourSocialNetwork');
+        } else {
+            $social_right_content .=   get_lang('YouAlreadyInviteAllYourContacts');
+        }
+        $social_right_content .=   '<div>';
+        $social_right_content .=   '<a href="search.php">'.get_lang('TryAndFindSomeFriends').'</a>';
+        $social_right_content .=   '</div>';    
+}
 
-<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $group_id; ?><?php if(!empty($_GET['add'])) echo '&add=true' ; ?>" style="margin:0px;" <?php if($ajax_search){echo ' onsubmit="valide();"';}?>>
+if (!empty($_GET['add'])) $add_true = '&add=true';
+if ($ajax_search) $ajax = 'onsubmit="valide();"';
+
+$form = '<form name="formulaire" method="post" action="'.api_get_self().'?id='.$group_id.$add_true.'" style="margin:0px;" '.$ajax.'>';
 
-<?php
 if ($add_type=='multiple') {
 	if (is_array($extra_field_list)) {
 		if (is_array($new_field_list) && count($new_field_list)>0 ) {
-			echo '<h3>'.get_lang('FilterUsers').'</h3>';
+			$form .= '<h3>'.get_lang('FilterUsers').'</h3>';
 			foreach ($new_field_list as $new_field) {
-				echo $new_field['name'];
+				$form .= $new_field['name'];
 				$varname = 'field_'.$new_field['variable'];
-				echo '&nbsp;<select name="'.$varname.'">';
-				echo '<option value="0">--'.get_lang('Select').'--</option>';
+				$form .= '&nbsp;<select name="'.$varname.'">';
+				$form .= '<option value="0">--'.get_lang('Select').'--</option>';
 				foreach	($new_field['data'] as $option) {
 					$checked='';
 					if (isset($_POST[$varname])) {
@@ -358,126 +341,99 @@ if ($add_type=='multiple') {
 							$checked = 'selected="true"';
 						}
 					}
-					echo '<option value="'.$option[1].'" '.$checked.'>'.$option[1].'</option>';
+					$form .= '<option value="'.$option[1].'" '.$checked.'>'.$option[1].'</option>';
 				}
-				echo '</select>';
-				echo '&nbsp;&nbsp;';
+				$form .= '</select>';
+				$form .= '&nbsp;&nbsp;';
 			}
-			echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
-			echo '<br /><br />';
+			$form .= '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
+			$form .= '<br /><br />';
 		}
 	}
 }
-?>
 
-<input type="hidden" name="form_sent" value="1" />
-<input type="hidden" name="id" value="<?php echo $group_id?>" />
-<input type="hidden" name="add_type"  />
+$form .=  '<input type="hidden" name="form_sent" value="1" />';
+$form .=  '<input type="hidden" name="id" value="'.$group_id.'">';
+$form .=  '<input type="hidden" name="add_type"  />';
 
-<?php
 if(!empty($errorMsg)) {
-	Display::display_error_message($errorMsg); //main API
+	$form .= Display::return_message($errorMsg,'error'); //main API
 }
-	
-?>
 
-<table border="0" cellpadding="5" cellspacing="0" width="100%">
-<!-- Users -->
+$form .= '<table border="0" cellpadding="5" cellspacing="0" width="100%">
 <tr>
-  <td align="center"><b><?php echo get_lang('Friends') ?> :</b>
+  <td align="center"><b>'.get_lang('Friends').' :</b>
   </td>
   <td></td>
-  <td align="center"><b><?php echo get_lang('SendInvitationTo') ?> :</b></td>
-</tr>
-
-<?php if ($add_type=='no') { ?>
-<tr>
-<td align="center">
-
-<?php echo get_lang('FirstLetterUser'); ?> :
-     <select name="firstLetterUser" onchange = "xajax_search_users(this.value,'multiple')" >
-      <option value = "%">--</option>
-      <?php
-        echo Display :: get_alphabet_options();
-      ?>
-     </select>
-</td>
-<td align="center">&nbsp;</td>
-</tr>
-<?php } ?>
-
+  <td align="center"><b>'.get_lang('SendInvitationTo').':</b></td></tr>';
+
+if ($add_type=='no') {
+    $form .='    
+    <tr>
+    <td align="center">'.get_lang('FirstLetterUser').' :
+        <select name="firstLetterUser" onchange = "xajax_search_users(this.value,\'multiple\')" >
+        <option value = "%">--</option>      
+            '.Display :: get_alphabet_options().'      
+        </select>
+    </td>
+    <td align="center">&nbsp;</td>
+    </tr>';
+}
 
+$form .= '
 <tr>
   <td align="center">
-  <div id="content_source">
-  	  <?php
-  	  if (!($add_type=='multiple')) {
-  	  	?>
-		<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,'single')" />
-		<div id="ajax_list_users_single"></div>
-		<?php
-  	  } else {  	      
-  	  ?>
-  	  <div id="ajax_list_users_multiple">
-	  <select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:290px;">
-		<?php
-		foreach($nosessionUsersList as $enreg) { 
-		?>
-			<option value="<?php echo $enreg['user_id']; ?>" <?php if(in_array($enreg['user_id'],$UserList)) echo 'selected="selected"'; ?>><?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')'; ?></option>
-		<?php
-		}
-		?>
-	  </select>
-	  </div>
-	<?php
-  	  }
-  	  unset($nosessionUsersList);
-  	 ?>
-  </div>
-  </td>
-  <td width="10%" valign="middle" align="center">
-  <?php
-  if ($ajax_search) {
-  ?>
-  	<button class="arrowl" type="button" onclick="remove_item(document.getElementById('destination_users'))" ></button>
-  <?php
-  } else {
-  ?>
-  	<button class="arrowr" type="button" onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))" ></button>
-	<br /><br />
-	<button class="arrowl" type="button" onclick="moveItem(document.getElementById('destination_users'), document.getElementById('origin_users'))" ></button>
-	<br /><br />
-  	<?php
-  }  
-  ?>
-	<br /><br /><br /><br /><br />
+  <div id="content_source">';  	  
+
+if (!($add_type=='multiple')) {    
+    $form .='<input type="text" id="user_to_add" onkeyup="xajax_search_users(this.value,\'single\')" /><div id="ajax_list_users_single"></div>';
+} else {  	        	  
+    $form .= '<div id="ajax_list_users_multiple">
+    <select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:290px;">';
+
+    foreach($nosessionUsersList as $enreg) { 		
+        $selected = '';
+        if(in_array($enreg['user_id'],$UserList)) $selected  = 'selected="selected"';        
+        $form .= '<option value="'.$enreg['user_id'].'" '.$selected.'>'.api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].') </option>';
+    }		
+    $form .= '</select>';
+    $form .= '</div>';
+}
+
+unset($nosessionUsersList);
+$form .= '</div>'; 
+$form .= '</td><td width="10%" valign="middle" align="center">';
+  
+if ($ajax_search) {  
+  	$form .= '<button class="arrowl" type="button" onclick="remove_item(document.getElementById(\'destination_users\'))" ></button>';  
+} else {
+    $form .= '<button class="arrowr" type="button" onclick="moveItem(document.getElementById(\'origin_users\'), document.getElementById(\'destination_users\'))" ></button>
+    <br /><br />
+    <button class="arrowl" type="button" onclick="moveItem(document.getElementById(\'destination_users\'), document.getElementById(\'origin_users\'))" ></button>
+    <br /><br />';  	
+}
+  
+ $form .= '	<br /><br /><br /><br /><br />
   </td>
   <td align="center">
-  <select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" style="width:290px;">
-
-<?php
+  <select id="destination_users" name="sessionUsersList[]" multiple="multiple" size="15" style="width:290px;">';
+ 
 foreach($sessionUsersList as $enreg) {
-?>
-	<option value="<?php echo $enreg['user_id']; ?>"><?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')'; ?></option>
-
-<?php
+	$form .= ' <option value="'.$enreg['user_id'].'">'.api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')</option>';
 }
 unset($sessionUsersList);
-?>
-
-  </select></td>
+$form .= '</select></td>
 </tr>
 <tr>
 	<td colspan="3" align="center">
-		<br />
-		<?php
-		echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('InviteUsersToGroup').'</button>';
-		?>
+		<br />		
+		<button class="save" type="button" value="" onclick="valide()" >'.get_lang('InviteUsersToGroup').'</button>
 	</td>
 </tr>
 </table>
-</form>
-<?php
+</form>';
+
+$social_right_content .= $form;
 
 //current group members
 $members = GroupPortalManager::get_users_by_group($group_id, false, array(GROUP_USER_PERMISSION_PENDING_INVITATION));
@@ -487,13 +443,11 @@ if (is_array($members) && count($members)>0) {
 		$picture = UserManager::get_picture_user($member['user_id'], $image_path['file'],80);
 		$member['image'] = '<img src="'.$picture['file'].'"  width="50px" height="50px"  />';
 	}
-	echo '<span class="social-groups-text1"><strong>'.get_lang('UsersAlreadyInvited').'</strong></span>';
-	Display::display_sortable_grid('invitation_profile', array(), $members, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, false, true,true));
+	$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));
 }		
-	echo '</div>'; // end layout right
-echo '</div>';
-?>
 
+$htmlHeadXtra[] = '
 <script type="text/javascript">
 <!--
 function moveItem(origin , destination) {
@@ -532,7 +486,7 @@ function mysort(a, b){
 }
 
 function valide(){
-	var options = document.getElementById('destination_users').options;
+	var options = document.getElementById(\'destination_users\').options;
 	for (i = 0 ; i<options.length ; i++)
 		options[i].selected = true;
 	document.forms.formulaire.submit();
@@ -550,21 +504,18 @@ function loadUsersInSelect(select){
 	else  // XMLHttpRequest non supporté par le navigateur
 	alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
 
-	//xhr_object.open("GET", "loadUsersInSelect.ajax.php?id_session=<?php echo $id_session ?>&letter="+select.options[select.selectedIndex].text, false);
 	xhr_object.open("POST", "loadUsersInSelect.ajax.php");
-
 	xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 
-
-	nosessionUsers = makepost(document.getElementById('origin_users'));
-	sessionUsers = makepost(document.getElementById('destination_users'));
-	nosessionClasses = makepost(document.getElementById('origin_classes'));
-	sessionClasses = makepost(document.getElementById('destination_classes'));
+	nosessionUsers = makepost(document.getElementById("origin_users"));
+	sessionUsers = makepost(document.getElementById("destination_users"));
+	nosessionClasses = makepost(document.getElementById("origin_classes"));
+	sessionClasses = makepost(document.getElementById("destination_classes"));
 	xhr_object.send("nosessionusers="+nosessionUsers+"&sessionusers="+sessionUsers+"&nosessionclasses="+nosessionClasses+"&sessionclasses="+sessionClasses);
 
 	xhr_object.onreadystatechange = function() {
 		if(xhr_object.readyState == 4) {
-			document.getElementById('content_source').innerHTML = result = xhr_object.responseText;
+			document.getElementById("content_source").innerHTML = result = xhr_object.responseText;
 			//alert(xhr_object.responseText);
 		}
 	}
@@ -574,12 +525,21 @@ function makepost(select) {
 	var options = select.options;
 	var ret = "";
 	for (i = 0 ; i<options.length ; i++)
-		ret = ret + options[i].value +'::'+options[i].text+";;";
+		ret = ret + options[i].value +\'::\'+options[i].text+";;";
 	return ret;
-
 }
 -->
-</script>
-<?php
-/* 		FOOTER */
-Display::display_footer();
+</script>';
+
+
+$tpl = new Template($tool_name);
+$tpl->set_help('Groups');
+$tpl->assign('social_left_content', $social_left_content);
+$tpl->assign('social_left_menu', $social_left_menu);
+$tpl->assign('social_right_content', $social_right_content);
+$social_layout = $tpl->get_template('layout/social_layout.tpl');
+$content = $tpl->fetch($social_layout);
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 56 - 55
main/social/group_members.php

@@ -39,11 +39,6 @@ if (empty($group_id)) {
 	}
 }
 
-
-Display :: display_header($tool_name, 'Groups');
-$user_online_list = who_is_online(api_get_setting('time_limit_whosonline'), true);
-$user_online_count = count($user_online_list); 
-
 $show_message	= ''; 
 //if i'm a moderator
 if (isset($_GET['action']) && $_GET['action']=='add') {
@@ -91,54 +86,60 @@ if (isset($_GET['action']) && $_GET['action']=='delete_moderator') {
 $users	= GroupPortalManager::get_users_by_group($group_id, false, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR), 0 , 1000);
 $new_member_list = array();
 
-echo '<div id="social-content">';
-	echo '<div id="social-content-left">';	
-	//this include the social menu div
-	SocialManager::show_social_menu('member_list',$group_id);
-	echo '</div>';
-	echo '<div id="social-content-right">';
-	
-	     echo '<h2>'.$group_info['name'].'</h2>';
+$social_left_content = SocialManager::show_social_menu('member_list',$group_id);
+
+$social_right_content = '<h2>'.$group_info['name'].'</h2>';
 	 
-		echo '<div style="width:90%">';
-			
-		if (! empty($show_message)){
-			Display :: display_confirmation_message($show_message);
-		}	
-		foreach($users as $user) {		
-				switch ($user['relation_type']) {
-					case  GROUP_USER_PERMISSION_ADMIN:
-						$user['link'] = Display::return_icon('social_group_admin.png', get_lang('Admin'));
-					break;
-					case  GROUP_USER_PERMISSION_READER:
-						if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
-						$user['link'] = '<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=delete">'.Display::return_icon('delete.png', get_lang('DeleteFromGroup')).'</a>'.
-										'<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=set_moderator">'.Display::return_icon('social_moderator_add.png', get_lang('AddModerator')).'</a>';
-						}
-					break;		
-					case  GROUP_USER_PERMISSION_PENDING_INVITATION:
-						$user['link'] = '<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=add">'.Display::return_icon('pending_invitation.png', get_lang('PendingInvitation')).'</a>';					
-					break;
-					case  GROUP_USER_PERMISSION_MODERATOR:
-						$user['link'] = Display::return_icon('social_group_moderator.png', get_lang('Moderator'));
-						//only group admin can manage moderators 
-						if ($user_role == GROUP_USER_PERMISSION_ADMIN) {
-							$user['link'] .='<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=delete_moderator">'.Display::return_icon('social_moderator_delete.png', get_lang('DeleteModerator')).'</a>';
-						}
-					break;				
-				}
-				
-				$image_path = UserManager::get_user_picture_path_by_id($user['user_id'], 'web', false, true);												
-				$picture = UserManager::get_picture_user($user['user_id'], $image_path['file'],80);										
-				$user['image'] = '<img src="'.$picture['file'].'"  width="50px" height="50px"  />';
-				
-			$new_member_list[] = $user;
-		}		
-		if (count($new_member_list) > 0) {			
-			Display::display_sortable_grid('list_members', array(), $new_member_list, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, false, true,true,false,true,true));		
-		}
-	echo '</div>';	
-	echo '</div>';
-echo '</div>';
-
-Display :: display_footer();
+$social_right_content .= '<div style="width:90%">';
+
+if (! empty($show_message)){
+    $social_right_content .= Display :: return_message($show_message,'confirmation', false);
+}
+
+foreach($users as $user) {		
+    switch ($user['relation_type']) {
+        case  GROUP_USER_PERMISSION_ADMIN:
+            $user['link'] = Display::return_icon('social_group_admin.png', get_lang('Admin'));
+        break;
+        case  GROUP_USER_PERMISSION_READER:
+            if (in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
+            $user['link'] = '<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=delete">'.Display::return_icon('delete.png', get_lang('DeleteFromGroup')).'</a>'.
+                            '<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=set_moderator">'.Display::return_icon('social_moderator_add.png', get_lang('AddModerator')).'</a>';
+            }
+        break;		
+        case  GROUP_USER_PERMISSION_PENDING_INVITATION:
+            $user['link'] = '<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=add">'.Display::return_icon('pending_invitation.png', get_lang('PendingInvitation')).'</a>';					
+        break;
+        case  GROUP_USER_PERMISSION_MODERATOR:
+            $user['link'] = Display::return_icon('social_group_moderator.png', get_lang('Moderator'));
+            //only group admin can manage moderators 
+            if ($user_role == GROUP_USER_PERMISSION_ADMIN) {
+                $user['link'] .='<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=delete_moderator">'.Display::return_icon('social_moderator_delete.png', get_lang('DeleteModerator')).'</a>';
+            }
+        break;				
+    }
+
+    $image_path = UserManager::get_user_picture_path_by_id($user['user_id'], 'web', false, true);												
+    $picture = UserManager::get_picture_user($user['user_id'], $image_path['file'],80);										
+    $user['image'] = '<img src="'.$picture['file'].'"  width="50px" height="50px"  />';
+
+    $new_member_list[] = $user;
+}		
+if (count($new_member_list) > 0) {			
+    $social_right_content .= Display::return_sortable_grid('list_members', array(), $new_member_list, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, false, true,true,false,true,true));		
+}
+$social_right_content .= '</div>';
+
+
+
+$tpl = new Template($tool_name);
+$tpl->set_help('Groups');
+$tpl->assign('social_left_content', $social_left_content);
+$tpl->assign('social_left_menu', $social_left_menu);
+$tpl->assign('social_right_content', $social_right_content);
+$social_layout = $tpl->get_template('layout/social_layout.tpl');
+$content = $tpl->fetch($social_layout);
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 20 - 20
main/social/group_topics.php

@@ -60,7 +60,7 @@ if (isset($_POST['token']) && $_POST['token'] === $_SESSION['sec_token']) {
 
 		// display error messages
 		if (!$res) {
-			Display::display_error_message(get_lang('Error'));
+			$social_right_content .= Display::return_message(get_lang('Error'),'error');
 		}
 		$topic_id = intval($_GET['topic_id']);
 		if ($_POST['action'] == 'add_message_group') {
@@ -164,26 +164,26 @@ $(document).ready(function() {
 </script>';
 
 $this_section = SECTION_SOCIAL;
-$interbreadcrumb[]= array ('url' =>'home.php',      'name' => get_lang('Social'));
+$interbreadcrumb[] = array ('url' =>'home.php',      'name' => get_lang('Social'));
 $interbreadcrumb[] = array('url' => 'groups.php',   'name' => get_lang('Groups'));
 $interbreadcrumb[] = array('url' => '#',            'name' => get_lang('Thread'));
 
-Display::display_header($tool_name, 'Groups');
-
-echo '<div id="social-content">';
-    echo '<div id="social-content-left">';  
-    //this include the social menu div
-    SocialManager::show_social_menu('member_list', $group_id);
-    echo '</div>';
-    echo '<div id="social-content-right">';
-         echo '<h2><a href="groups.php?id='.$group_id.'">'.Security::remove_XSS($group_info['name'], STUDENT, true).'</a> &raquo; <a href="groups.php?id='.$group_id.'#tabs_2">'.get_lang('Discussions').'</a></h2>';
+$social_left_content = SocialManager::show_social_menu('member_list', $group_id);    
+$social_right_content .= '<h2><a href="groups.php?id='.$group_id.'">'.Security::remove_XSS($group_info['name'], STUDENT, true).'</a> &raquo; <a href="groups.php?id='.$group_id.'#tabs_2">'.get_lang('Discussions').'</a></h2>';
          
-        if (!empty($show_message)){
-            Display::display_confirmation_message($show_message);
-        }
-        $content = MessageManager::display_message_for_group($group_id, $topic_id, $is_member, $message_id);
-        echo $content;
-    echo '</div>';
-echo '</div>';
-
-Display :: display_footer();
+if (!empty($show_message)){
+    $social_right_content .= Display::return_message($show_message, 'confirmation');
+}
+$social_right_content .= MessageManager::display_message_for_group($group_id, $topic_id, $is_member, $message_id);
+
+$tpl = new Template($tool_name);
+$tpl->set_help('Groups');
+$tpl->assign('social_left_content', $social_left_content);
+$tpl->assign('social_left_menu', $social_left_menu);
+$tpl->assign('social_right_content', $social_right_content);
+$social_layout = $tpl->get_template('layout/social_layout.tpl');
+$content = $tpl->fetch($social_layout);
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 34 - 37
main/social/group_waiting_list.php

@@ -41,9 +41,6 @@ if (empty($group_id)) {
 	}
 }
 
-
-Display :: display_header($tool_name, 'Groups');
-
 // Group information
 $admins		= GroupPortalManager::get_users_by_group($group_id, true, array(GROUP_USER_PERMISSION_ADMIN), 0, 1000);
 $show_message = ''; 
@@ -82,37 +79,37 @@ if (isset($_GET['action']) && $_GET['action']=='set_moderator') {
 $users	= GroupPortalManager::get_users_by_group($group_id, true, array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER), 0, 1000);
 $new_member_list = array();
 
-//Shows left column
-//echo GroupPortalManager::show_group_column_information($group_id, api_get_user_id());	
-echo '<div id="social-content">';
-	echo '<div id="social-content-left">';	
-	//this include the social menu div
-	SocialManager::show_social_menu('waiting_list',$group_id);	
-	echo '</div>';
-	echo '<div id="social-content-right">';			
-		if (!empty($show_message)){
-			Display :: display_normal_message($show_message);
-		}		
-		// Display form
-		foreach($users as $user) {	 
-			switch ($user['relation_type']) {			
-				case  GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER:
-				$user['link']  = '<a href="group_waiting_list.php?id='.$group_id.'&u='.$user['user_id'].'&action=accept">'.Display::return_icon('invitation_friend.png', get_lang('AddNormalUser')).'</a>';
-				$user['link'] .= '<a href="group_waiting_list.php?id='.$group_id.'&u='.$user['user_id'].'&action=set_moderator">'.Display::return_icon('social_moderator_add.png', get_lang('AddModerator')).'</a>';
-				$user['link'] .= '<a href="group_waiting_list.php?id='.$group_id.'&u='.$user['user_id'].'&action=deny">'.Display::return_icon('user_delete.png', get_lang('DenyEntry')).'</a>';
-				break;				
-			}
-			$new_member_list[] = $user;
-		}
-		
-		if (count($new_member_list) > 0) {			
-			Display::display_sortable_grid('search_users', array(), $new_member_list, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, false, true,true,false,true,true));		
-		} else {
-			Display :: display_normal_message(get_lang('ThereAreNotUsersInTheWaitingList'));
-		}				
-	echo '</div>';
-echo '</div>';
-
-	
-Display :: display_footer();
-?>
+$social_left_content = SocialManager::show_social_menu('waiting_list',$group_id);	
+
+if (!empty($show_message)){
+    $social_right_content .= Display :: return_message($show_message);
+}		
+// Display form
+foreach($users as $user) {	 
+    switch ($user['relation_type']) {			
+        case  GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER:
+        $user['link']  = '<a href="group_waiting_list.php?id='.$group_id.'&u='.$user['user_id'].'&action=accept">'.Display::return_icon('invitation_friend.png', get_lang('AddNormalUser')).'</a>';
+        $user['link'] .= '<a href="group_waiting_list.php?id='.$group_id.'&u='.$user['user_id'].'&action=set_moderator">'.Display::return_icon('social_moderator_add.png', get_lang('AddModerator')).'</a>';
+        $user['link'] .= '<a href="group_waiting_list.php?id='.$group_id.'&u='.$user['user_id'].'&action=deny">'.Display::return_icon('user_delete.png', get_lang('DenyEntry')).'</a>';
+        break;				
+    }
+    $new_member_list[] = $user;
+}
+
+if (count($new_member_list) > 0) {			
+    $social_right_content .= Display::return_sortable_grid('search_users', array(), $new_member_list, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, false, true,true,false,true,true));		
+} else {
+    $social_right_content .= Display :: return_message(get_lang('ThereAreNotUsersInTheWaitingList'));
+}				
+
+$tpl = new Template($tool_name);
+$tpl->set_help('Groups');
+$tpl->assign('social_left_content', $social_left_content);
+$tpl->assign('social_left_menu', $social_left_menu);
+$tpl->assign('social_right_content', $social_right_content);
+$social_layout = $tpl->get_template('layout/social_layout.tpl');
+$content = $tpl->fetch($social_layout);
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 57 - 50
main/social/groups.php

@@ -140,12 +140,13 @@ if (isset($_GET['view']) && in_array($_GET['view'],$allowed_views)) {
 	}
 }
 
-Display :: display_header($tool_name, 'Groups');
+//Display :: display_header($tool_name, 'Groups');
 
 // getting group information
 $group_id	= isset($_GET['id']) ? intval($_GET['id']) : null;
 $relation_group_title = '';
 $my_group_role = 0;
+
 if ($group_id != 0 ) {
 	$user_leave_message = false;
 	$user_added_group_message = false;
@@ -177,21 +178,15 @@ if ($group_id != 0 ) {
 }
 $create_thread_link = '';
 
-echo '<div id="social-content">';
-	echo '<div id="social-content-left">';
-		//this include the social menu div
-		if ($group_id != 0 ) {									
-			SocialManager::show_social_menu('groups',$group_id);
-		} else {
-			$show_menu = 'browse_groups';
-			if (isset($_GET['view']) && $_GET['view'] == 'mygroups') {
-				$show_menu = $_GET['view'];
-			}
-			SocialManager::show_social_menu($show_menu);
-		}
-	echo '</div>';
-
-	echo '<div id="social-content-right">';
+if ($group_id != 0 ) {									
+    $social_left_content = SocialManager::show_social_menu('groups',$group_id);
+} else {
+    $show_menu = 'browse_groups';
+    if (isset($_GET['view']) && $_GET['view'] == 'mygroups') {
+        $show_menu = $_GET['view'];
+    }
+    $social_left_content = SocialManager::show_social_menu($show_menu);
+}
 
 if ($group_id != 0 ) {
 
@@ -199,47 +194,47 @@ if ($group_id != 0 ) {
 
 	//Loading group information
 	if (isset($_GET['status']) && $_GET['status']=='sent') {
-		Display::display_confirmation_message(get_lang('MessageHasBeenSent'), false);
+		$social_right_content .= Display::return_message(get_lang('MessageHasBeenSent'), 'confirmation', false);
 	}
 
 	if ($user_leave_message) {
-		Display::display_confirmation_message(get_lang('UserIsNotSubscribedToThisGroup'), false);
+		$social_right_content .= Display::return_message(get_lang('UserIsNotSubscribedToThisGroup'), 'confirmation', false);
 	}
 
 	if ($user_added_group_message) {
-		Display::display_confirmation_message(get_lang('UserIsSubscribedToThisGroup'), false);
+		$social_right_content .= Display::return_message(get_lang('UserIsSubscribedToThisGroup'), 'confirmation', false);
 	}
 	
     if ($user_invitation_sent) {
-        Display::display_confirmation_message(get_lang('InvitationSent'), false);
+        $social_right_content .= Display::return_message(get_lang('InvitationSent'), 'confirmation', false);
     }
     
     $is_group_member = GroupPortalManager::is_group_member($group_id);    
 
 	// details about the current group
-	echo '<div class="head_group">';    
-		echo '<div id="social-group-details">';
+	$social_right_content = '<div class="head_group">';    
+		$social_right_content .=  '<div id="social-group-details">';
 				//Group's title
-				echo Display::tag('h2', Security::remove_XSS($group_info['name'], STUDENT, true));
+				$social_right_content .=  Display::tag('h2', Security::remove_XSS($group_info['name'], STUDENT, true));
 				
 				//echo '<div class="social-group-details-info"><a target="_blank" href="'.$group_info['url'].'">'.$group_info['url'].'</a></div>';
 				
 				//Privacy
 				if (!$is_group_member) {
-    				echo '<div class="social-group-details-info">';
-    					echo '<span>'.get_lang('Privacy').' : </span>';
+    				$social_right_content .=  '<div class="social-group-details-info">';
+    					$social_right_content .=  '<span>'.get_lang('Privacy').' : </span>';
     					if ($group_info['visibility']== GROUP_PERMISSION_OPEN) {
-    						echo get_lang('ThisIsAnOpenGroup');
+    						$social_right_content .=  get_lang('ThisIsAnOpenGroup');
     					} elseif ($group_info['visibility']== GROUP_PERMISSION_CLOSED) {
-    						echo get_lang('ThisIsACloseGroup');
+    						$social_right_content .=  get_lang('ThisIsACloseGroup');
     					}
-    				echo '</div>';
+    				$social_right_content .=  '</div>';
 				}
 				
 				if (!$is_group_member && $group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
 				    $role = GroupPortalManager::get_user_group_role(api_get_user_id(), $group_id);				    
 				    if ($role == GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER) {
-				        echo Display::display_normal_message(get_lang('YouAlreadySentAnInvitation'));
+				        $social_right_content .=  Display::return_message(get_lang('YouAlreadySentAnInvitation'));
 				    }
 				}
 				 
@@ -252,23 +247,23 @@ if ($group_id != 0 ) {
 				}
 				//Group's tags
 				if (!empty($tags)) {
-					echo '<div id="social-group-details-info"><span>'.get_lang('Tags').' : </span>'.$tags.'</div>';
+					$social_right_content .=  '<div id="social-group-details-info"><span>'.get_lang('Tags').' : </span>'.$tags.'</div>';
 				}
-		echo '</div>';
-	echo '</div>';
-	echo '<div class="clear"></div>';
+		$social_right_content .=  '</div>';
+	$social_right_content .=  '</div>';
+	$social_right_content .=  '<div class="clear"></div>';
 
 	//-- Show message groups
-	echo '<div class="messages" style="width:700px">';	    
+	$social_right_content .=  '<div class="messages" style="width:700px">';	    
 	     
 		if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) {
 		    if (!$is_group_member) {		        
     		    if (!in_array($my_group_role, array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER, GROUP_USER_PERMISSION_PENDING_INVITATION))) {
-                    echo '<a class="a_button white medium" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>';
+                    $social_right_content .=  '<a class="a_button white medium" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>';
                 } elseif ($my_group_role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
-                    echo '<a class="a_button white medium" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('YouHaveBeenInvitedJoinNow').'</a>';
+                    $social_right_content .=  '<a class="a_button white medium" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('YouHaveBeenInvitedJoinNow').'</a>';
                 }
-                echo '<br /><br />';
+                $social_right_content .=  '<br /><br />';
 		    }            
 			
 			$content = MessageManager::display_messages_for_group($group_id);
@@ -276,11 +271,10 @@ if ($group_id != 0 ) {
     			if (empty($content)) {		
     				$create_thread_link =  '<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="a_button white medium thickbox" title="'.get_lang('ComposeMessage').'">'.get_lang('YouShouldCreateATopic').'</a></li>';
     			} else {
-    			    $create_thread_link = '<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="a_button white medium thickbox" title="'.get_lang('ComposeMessage').'">'.get_lang('NewTopic').'</a>';
-    			     			    
+    			    $create_thread_link = '<a href="'.api_get_path(WEB_CODE_PATH).'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend='.api_get_user_id().'&group_id='.$group_id.'&action=add_message_group" class="a_button white medium thickbox" title="'.get_lang('ComposeMessage').'">'.get_lang('NewTopic').'</a>';    			     			    
     			}			
 			}
-			$members		= GroupPortalManager::get_users_by_group($group_id);
+			$members = GroupPortalManager::get_users_by_group($group_id);
             $member_content = '';
             
     		//Members
@@ -318,16 +312,16 @@ if ($group_id != 0 ) {
     		//$updates = 
     		//get_lang('Updates'), 
     		$headers = array(get_lang('Discussions'), get_lang('Members'));
-			echo Display::tabs($headers, array($create_thread_link.$content, $member_content),'tabs');			
+			$social_right_content .= Display::tabs($headers, array($create_thread_link.$content, $member_content),'tabs');			
 		} else {
 			// if I already sent an invitation message
 			if (!in_array($my_group_role, array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER, GROUP_USER_PERMISSION_PENDING_INVITATION))) {
-				echo '<a class="a_button white medium" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>';
+				$social_right_content .=  '<a class="a_button white medium" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('JoinGroup').'</a>';
 			} elseif ($my_group_role == GROUP_USER_PERMISSION_PENDING_INVITATION) {
-				echo '<a class="a_button white medium" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('YouHaveBeenInvitedJoinNow').'</a>';
+				$social_right_content .=  '<a class="a_button white medium" href="groups.php?id='.$group_id.'&action=join&u='.api_get_user_id().'">'.get_lang('YouHaveBeenInvitedJoinNow').'</a>';
 			}
 		}
-	echo '</div>'; // end layout messages
+	$social_right_content .=  '</div>'; // end layout messages
 
 } else {
 		// My groups -----
@@ -531,11 +525,24 @@ if ($group_id != 0 ) {
 	   	}
 	   	
 	   	if (!empty($create_group_item)) {
-	   		echo Display::div($create_group_item, array('style'=>'padding-top:12px;height:30px'));
+	   		$social_right_content .=  Display::div($create_group_item, array('style'=>'padding-top:12px;height:30px'));
 	   	}	   	
-	   	$headers = array(get_lang('MyGroups'), get_lang('Newest'), get_lang('Popular'));	   	
-		echo Display::tabs($headers, array($my_group_content, $newest_content, $popular_content),'tab_browse');
+	   	$headers = array(get_lang('Newest'), get_lang('Popular'), get_lang('MyGroups'));	   	
+		$social_right_content .=  Display::tabs($headers, array($newest_content, $popular_content, $my_group_content),'tab_browse');
     }
-	echo '</div>';
-echo '</div>';
-Display :: display_footer();
+	$social_right_content .=  '</div>';
+
+//Display :: display_footer();
+
+
+$tpl = new Template($tool_name);
+$tpl->set_help('Groups');
+$tpl->assign('social_left_content', $social_left_content);
+$tpl->assign('social_left_menu', $social_left_menu);
+$tpl->assign('social_right_content', $social_right_content);
+$social_layout = $tpl->get_template('layout/social_layout.tpl');
+$content = $tpl->fetch($social_layout);
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 30 - 44
main/social/home.php

@@ -21,7 +21,6 @@ $this_section = SECTION_SOCIAL;
 unset($_SESSION['this_section']);//for hmtl editor repository
 
 api_block_anonymous_users();
-
 if (api_get_setting('allow_social_tool') !='true' ){
     api_not_allowed();
 }
@@ -66,27 +65,16 @@ if (api_get_setting('profile', 'picture') == 'true') {
 	}
 }
 
-Display :: display_header(get_lang('Social'));
 $user_info = UserManager :: get_user_info_by_id(api_get_user_id());
-$user_online_list = who_is_online(api_get_setting('time_limit_whosonline'),true);
-$user_online_count = count($user_online_list);
-
-echo '<div id="social-content">';
 
-	echo '<div id="social-content-left">';
-	//this include the social menu div
-	SocialManager::show_social_menu('home');
-	echo '</div>';
-    
-    
-	echo '<div id="social-content-right">';
-		
-        echo '<div class="social_user_information" style="width:280px">';
+$social_left_content = SocialManager::show_social_menu('home');
+	
+        $social_right_content .= '<div class="social_user_information" style="width:280px">';
             
-            echo '<div class="social-groups-home-title">'.get_lang('ContactInformation').'</div>';
+            $social_right_content .= '<div class="social-groups-home-title">'.get_lang('ContactInformation').'</div>';
 			
 		    // information current user		       
-            echo '<div>
+            $social_right_content .= '<div>
                     <p><strong>'.get_lang('Name').'</strong><br />
                     <span class="social-groups-text4">'.api_get_person_name($user_info['firstname'], $user_info['lastname']).'</span></p>
                   </div>
@@ -102,31 +90,26 @@ echo '<div id="social-content">';
             $skill = new Skill();
             $skills =  $skill->get_user_skills(api_get_user_id(), true);
             
-            echo '<div class="left" style="width:280px">';            
-                echo '<div class="social-groups-home-title">'.get_lang('Skills').'</div>';
+            $social_right_content .= '<div class="left" style="width:280px">';            
+                $social_right_content .= '<div class="social-groups-home-title">'.get_lang('Skills').'</div>';
                 $lis = '';
                 if (!empty($skills)) {
                     foreach($skills as $skill) {
                         $lis .= Display::tag('li', Display::span($skill['name'], array('class'=>'label_tag skill')));
                     }                
-                    echo Display::tag('ul', $lis);
+                    $social_right_content .= Display::tag('ul', $lis);
                 }
                 $url = api_get_path(WEB_CODE_PATH).'social/skills_tree.php';            
-                echo Display::url(get_lang('ViewSkillsTree'), $url);                
-            echo '</div>';
-        
-            
-        echo '</div>'; // end social_user_information
-        
+                $social_right_content .= Display::url(get_lang('ViewSkillsTree'), $url);                
+            $social_right_content .= '</div>';
+        $social_right_content .= '</div>'; // end social_user_information
         
-                       
-            
                  
             //Search box
-			echo '<div class="social-box-right">';	
+			$social_right_content .= '<div class="social-box-right">';	
 					
-    			echo UserManager::get_search_form('');
-    			echo '<br />';
+    			$social_right_content .= UserManager::get_search_form('');
+    			$social_right_content .= '<br />';
     			
     			//Group box by age
     			$results = GroupPortalManager::get_groups_by_age(1,false);
@@ -171,22 +154,25 @@ echo '<div id="social-content">';
     				$actions = '<div class="box_description_group_actions" ><a href="groups.php?#tab_browse-3">'.get_lang('SeeMore').'</a></div>';
     				$groups_pop[]= array(Display::url($result['picture_uri'], $group_url) , $result['name'], cut($result['description'],120,true).$actions);
     			}
-    
+                
     			if (count($groups_newest) > 0) {
-    				echo '<div class="social-groups-home-title">'.get_lang('Newest').'</div>';
-    				Display::display_sortable_grid('home_group', array(), $groups_newest, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,false));				
+    				$social_right_content .= '<div class="social-groups-home-title">'.get_lang('Newest').'</div>';
+    				$social_right_content .= Display::return_sortable_grid('home_group', array(), $groups_newest, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,false));				
     			}
     
     			if (count($groups_pop) > 0) {
-    				echo '<div class="social-groups-home-title">'.get_lang('Popular').'</div>';
-    				Display::display_sortable_grid('home_group', array(), $groups_pop, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,true,true));
+    				$social_right_content .= '<div class="social-groups-home-title">'.get_lang('Popular').'</div>';
+    				$social_right_content .= Display::return_sortable_grid('home_group', array(), $groups_pop, array('hide_navigation'=>true, 'per_page' => 100), array(), false, array(true, true, true,true,true));
     			}
-
-			echo '</div>';
+			$social_right_content .= '</div>';
             
-                
-		
-	echo '</div>';
-echo '</div>';
-
-Display :: display_footer();
+$tpl = new Template(get_lang('Social'));
+$tpl->assign('social_left_content', $social_left_content);
+$tpl->assign('social_left_menu', $social_left_menu);
+$tpl->assign('social_right_content', $social_right_content);
+$social_layout = $tpl->get_template('layout/social_layout.tpl');
+$content = $tpl->fetch($social_layout);
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 21 - 25
main/social/invitations.php

@@ -67,7 +67,7 @@ function register_friend(element_input) {
 </script>';
 
 api_block_anonymous_users();
-Display :: display_header($tool_name, 'Groups');
+//Display :: display_header($tool_name, 'Groups');
 
 // easy links
 if (is_array($_GET) && count($_GET)>0) {
@@ -92,25 +92,11 @@ if (is_array($_GET) && count($_GET)>0) {
 		}		
 	}
 }
+$social_left_content = SocialManager::show_social_menu('invitations');
 
-$language_variable = get_lang('PendingInvitations');
-$language_comment  = get_lang('SocialInvitesComment');
+$social_right_content =  '<div id="id_response" align="center"></div>';
 
-echo '<div id="social-content">';
-
-	echo '<div id="social-content-left">';	
-		//this include the social menu div
-		SocialManager::show_social_menu('invitations');
-	echo '</div>';
-
-	echo '<div id="social-content-right">';
-    
-		if (!empty($show_message)) {
-			Display :: display_normal_message($show_message);
-		}		
-		
-		echo '<div id="id_response" align="center"></div>';
-		$list_get_invitation=array();
+		$list_get_invitation = array();
 		$user_id = api_get_user_id();
 		
 		$list_get_invitation		= SocialManager::get_list_invitation_of_friends_by_user_id($user_id);
@@ -121,11 +107,11 @@ echo '<div id="social-content">';
 		$total_invitations = $number_loop + count($list_get_invitation_sent) + count($pending_invitations);
 		
 		if ($total_invitations == 0 && count($_GET) <= 0) {
-			echo '<a href="search.php">'.get_lang('TryAndFindSomeFriends').'</a><br /><br />';
+			$social_right_content .= '<a href="search.php">'.get_lang('TryAndFindSomeFriends').'</a><br /><br />';
 		} 		
 		
 		if ($number_loop != 0) {
-			echo '<h2>'.get_lang('InvitationReceived').'</h2>';	
+			$social_right_content .= '<h2>'.get_lang('InvitationReceived').'</h2>';	
 			
 			foreach ($list_get_invitation as $invitation) {				
 				$sender_user_id = $invitation['user_sender_id']
@@ -209,7 +195,7 @@ echo '<div id="social-content">';
 		}
 		
 		if (count($pending_invitations) > 0) {					
-			echo '<h2>'.get_lang('GroupsWaitingApproval').'</h2>';
+			$social_right_content .= '<h2>'.get_lang('GroupsWaitingApproval').'</h2>';
 			$new_invitation = array();				
 			foreach ($pending_invitations as $invitation) {					
 				$picture = GroupPortalManager::get_picture_group($invitation['id'], $invitation['picture_uri'],80);							
@@ -222,8 +208,18 @@ echo '<div id="social-content">';
 				$invitation['description'] = cut($invitation['description'],220,true);
 				$new_invitation[]=$invitation;
 			}
-			Display::display_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::display_return_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));
 		}		
-	echo '</div>';
-echo '</div>';
-Display::display_footer();
+	$social_right_content .= '</div>';
+
+
+$tpl = new Template($tool_name);
+$tpl->assign('social_left_content', $social_left_content);
+$tpl->assign('social_left_menu', $social_left_menu);
+$tpl->assign('social_right_content', $social_right_content);
+$social_layout = $tpl->get_template('layout/social_layout.tpl');
+$content = $tpl->fetch($social_layout);
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 18 - 15
main/social/myfiles.php

@@ -67,7 +67,7 @@ function register_friend(element_input) {
 </script>';
 
 
-Display :: display_header($tool_name, 'Groups');
+//Display :: display_header($tool_name, 'Groups');
 
 // easy links
 if (is_array($_GET) && count($_GET)>0) {
@@ -93,19 +93,22 @@ if (is_array($_GET) && count($_GET)>0) {
 	}
 }
 
-$language_variable = get_lang('PendingInvitations');
-$language_comment  = get_lang('SocialInvitesComment');
+$social_left_content = SocialManager::show_social_menu('myfiles');
+		$social_right_content .=  '<a href=""></a>';//TODO: hack and delete this line
+		$social_right_content .= '<br />';								
+        $social_right_content .= '<table><tr><td><iframe name="fileManager" id="fileManager" src="'.api_get_path(WEB_PATH).'main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php?editor=stand_alone" scrolling="no" noresize="noresize" frameborder="no" style="height:450px; width:700px; float:left"></iframe></td></tr></table>';
+	$social_right_content .= '</div>';
+$social_right_content .=  '</div>';	
 
-echo '<div id="social-content">';
-	echo '<div id="social-content-left">';	
-		//this include the social menu div
-		SocialManager::show_social_menu('myfiles');
-	echo '</div>';
 
-	echo '<div id="social-content-right>';
-		echo '<a href=""></a>';//TODO: hack and delete this line
-		echo '<br />';								
-        echo '<table><tr><td><iframe name="fileManager" id="fileManager" src="'.api_get_path(WEB_PATH).'main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php?editor=stand_alone" scrolling="no" noresize="noresize" frameborder="no" style="height:450px; width:700px; float:left"></iframe></td></tr></table>';
-	echo '</div>';
-echo '</div>';	
-Display::display_footer();
+
+$tpl = new Template(get_lang('Social'));
+$tpl->assign('social_left_content', $social_left_content);
+$tpl->assign('social_left_menu', $social_left_menu);
+$tpl->assign('social_right_content', $social_right_content);
+$social_layout = $tpl->get_template('layout/social_layout.tpl');
+$content = $tpl->fetch($social_layout);
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 99 - 103
main/social/profile.php

@@ -206,8 +206,6 @@ $_SESSION['social_user_id'] = intval($user_id);
  * Display
  */
 
-Display :: display_header($nametool);
-
 //Setting some course info
 $my_user_id=isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id();
 $personal_course_list = UserManager::get_personal_session_course_list($my_user_id);
@@ -228,52 +226,41 @@ if (is_array($personal_course_list)) {
 	$course_list_code = array_unique_dimensional($course_list_code);
 }
 
-$user_online_list = who_is_online(api_get_setting('time_limit_whosonline'), true);
-$user_online_count = count($user_online_list);
-
-echo '<div id="social-content">';
-
-echo '<div id="social-content-left">';
-//this include the social menu div
-SocialManager::show_social_menu('shared_profile', null, $user_id, $show_full_profile);
-echo '</div>';
-
-echo '<div id="social-content-right">';
-
-echo '<div class="rounded_div" style="width:280px">';
+$social_left_content = SocialManager::show_social_menu('shared_profile', null, $user_id, $show_full_profile);
+$social_right_content = '<div class="rounded_div" style="width:280px">';
 
 if (!empty($user_info['firstname']) || !empty($user_info['lastname'])) {
-	echo '<div><h3>'.api_get_person_name($user_info['firstname'], $user_info['lastname']).'</h3></div>';
+	$social_right_content .= '<div><h3>'.api_get_person_name($user_info['firstname'], $user_info['lastname']).'</h3></div>';
 } else {
 	//--- Basic Information
-	echo '<div><h3>'.get_lang('Profile').'</h3></div>';
+	$social_right_content .=  '<div><h3>'.get_lang('Profile').'</h3></div>';
 }
 
 if ($show_full_profile) {
-	echo '<div class="social-profile-info">';
-	echo '<dl>';
-	echo '<dt>'.get_lang('UserName').'</dt><dd>'. $user_info['username'].'	</dd>';
+	$social_right_content .=  '<div class="social-profile-info">';
+	$social_right_content .=  '<dl>';
+	$social_right_content .=  '<dt>'.get_lang('UserName').'</dt><dd>'. $user_info['username'].'	</dd>';
 	if (!empty($user_info['firstname']) || !empty($user_info['lastname']))
-		echo '<dt>'.get_lang('Name').'</dt><dd>'. api_get_person_name($user_info['firstname'], $user_info['lastname']).'</dd>';
+		$social_right_content .=  '<dt>'.get_lang('Name').'</dt><dd>'. api_get_person_name($user_info['firstname'], $user_info['lastname']).'</dd>';
 	if (!empty($user_info['official_code']))
-		echo '<dt>'.get_lang('OfficialCode').'</dt><dd>'.$user_info['official_code'].'</dd>';
+		$social_right_content .=  '<dt>'.get_lang('OfficialCode').'</dt><dd>'.$user_info['official_code'].'</dd>';
 	if (!empty($user_info['email']))
 		if (api_get_setting('show_email_addresses')=='true')
-			echo '<dt>'.get_lang('Email').'</dt><dd>'.$user_info['email'].'</dd>';
+			$social_right_content .=  '<dt>'.get_lang('Email').'</dt><dd>'.$user_info['email'].'</dd>';
 		if (!empty($user_info['phone']))
-			echo '<dt>'.get_lang('Phone').'</dt><dd>'. $user_info['phone'].'</dd>';
-		echo '</dl>';
-	echo '</div>';
+			$social_right_content .=  '<dt>'.get_lang('Phone').'</dt><dd>'. $user_info['phone'].'</dd>';
+		$social_right_content .=  '</dl>';
+	$social_right_content .=  '</div>';
 } else {
-	echo '<div class="social-profile-info">';
-	echo '<dl>';
+	$social_right_content .=  '<div class="social-profile-info">';
+	$social_right_content .=  '<dl>';
 	if (!empty($user_info['username']))
-		echo '<dt>'.get_lang('UserName').'</dt><dd>'. $user_info['username'].'</dd>';
-	echo '</dl>';
-	echo '</div>';
+		$social_right_content .=  '<dt>'.get_lang('UserName').'</dt><dd>'. $user_info['username'].'</dd>';
+	$social_right_content .=  '</dl>';
+	$social_right_content .=  '</div>';
 }
 
-echo '<div class="clear"></div>';
+$social_right_content .=  '<div class="clear"></div>';
 
 // Extra information
 if ($show_full_profile) {
@@ -346,15 +333,15 @@ if ($show_full_profile) {
 		$extra_information .= '</div>'; //social-profile-info
 	}
 	// 	if there are information to show
-	if (!empty($extra_information_value)) echo $extra_information;
+	if (!empty($extra_information_value)) $social_right_content .=  $extra_information;
 }
 
-echo '</div>';	// close div tag rounded 
+$social_right_content .=  '</div>';	// close div tag rounded 
 
 
 if ($show_full_profile) {
 
-	echo '<div class="rounded_div" style="width:288px">';	
+	$social_right_content .=  '<div class="rounded_div" style="width:288px">';	
 	$list_path_friends= $list_path_normal_friends = $list_path_parents = array();
 
 	//SOCIALGOODFRIEND , USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_PARENT
@@ -429,8 +416,8 @@ if ($show_full_profile) {
 		$friend_html.= '</div>'; // close div friend-header
 	}
 	$friend_html.= '</div>';
-	echo $friend_html;	
-	echo '</div>'; // close div tag rounded 
+	$social_right_content .=  $friend_html;	
+	$social_right_content .=  '</div>'; // close div tag rounded 
 }
 
 if ($show_full_profile) {
@@ -478,47 +465,47 @@ if ($show_full_profile) {
 	}
 
     if (count($grid_my_groups) > 0) {
-		echo '<div class="rounded_div" style="width:90%">';    		
+		$social_right_content .=  '<div class="rounded_div" style="width:90%">';    		
     		$count_groups = 0;
     		if (count($results) == 1 ) {
     			$count_groups = count($results);
     		} else {
     			$count_groups = count($results);
     		}
-    		echo '<div><h3>'.get_lang('MyGroups').' ('.$count_groups.') </h3></div>';
+    		$social_right_content .=  '<div><h3>'.get_lang('MyGroups').' ('.$count_groups.') </h3></div>';
     		
     		if ($i > $max_numbers_of_group) {
     			if (api_get_user_id() == $user_id) {
-    				echo '<div class="box_shared_profile_group_actions"><a href="groups.php?#tab_browse-1">'.get_lang('SeeAllMyGroups').'</a></div>';
+    				$social_right_content .=  '<div class="box_shared_profile_group_actions"><a href="groups.php?#tab_browse-1">'.get_lang('SeeAllMyGroups').'</a></div>';
     			} else {
-    				echo '<div class="box_shared_profile_group_actions"><a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php?view=mygroups&height=390&width=610&&user_id='.$user_id.'" class="thickbox" title="'.get_lang('SeeAll').'" >'.get_lang('SeeAllMyGroups').'</a></div>';
+    				$social_right_content .=  '<div class="box_shared_profile_group_actions"><a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php?view=mygroups&height=390&width=610&&user_id='.$user_id.'" class="thickbox" title="'.get_lang('SeeAll').'" >'.get_lang('SeeAllMyGroups').'</a></div>';
     			}
     		}
     		//Display::display_sortable_grid('shared_profile_mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false));
     		$total = count($grid_my_groups);
     		$i = 1;
     		foreach($grid_my_groups as $group) {
-    		    echo $group[0];    			    
+    		    $social_right_content .=  $group[0];    			    
     		    if ($i < $total) {
-    		        echo ', ';
+    		        $social_right_content .=  ', ';
     		    }
     		    $i++;
     		}
-		echo '<br /><br /></div>';	//close rounded	
+		$social_right_content .=  '<br /><br /></div>';	//close rounded	
 	}
 
 	// COURSES LIST
 	if ( is_array($list) ) {
-		echo '<div class="rounded_div" style="width:90%">';			
-			echo '<div><h3>'.api_ucfirst(get_lang('MyCourses')).'</h3></div>';
-			echo '<div class="social-content-training">';
+		$social_right_content .=  '<div class="rounded_div" style="width:90%">';			
+			$social_right_content .=  '<div><h3>'.api_ucfirst(get_lang('MyCourses')).'</h3></div>';
+			$social_right_content .=  '<div class="social-content-training">';
 			//Courses whithout sessions
 			$old_user_category = 0;
 			$i=1;
 			foreach($list as $key=>$value) {
 				if ( empty($value[2]) ) { //if out of any session
-					echo $value[1];
-					echo '<div id="social_content'.$i.'" class="course_social_content" style="display:none" ></div>';					
+					$social_right_content .=  $value[1];
+					$social_right_content .=  '<div id="social_content'.$i.'" class="course_social_content" style="display:none" ></div>';					
 					$i++;
 				}
 			}
@@ -530,16 +517,16 @@ if ($show_full_profile) {
 					$listInactives[] = $value;
 				}
 			}
-			echo '</div>';		//social-content-training		
-		echo '</div>'; //close rounded
+			$social_right_content .=  '</div>';		//social-content-training		
+		$social_right_content .=  '</div>'; //close rounded
 	}
 	// user feeds
 	$user_feeds = SocialManager::get_user_feeds($user_id);
 	if (!empty($user_feeds)) {
-		echo '<div class="rounded_div" style="width:90%">';				
-			echo '<div><h3>'.get_lang('RSSFeeds').'</h3></div>';
-			echo '<div class="social-content-training">'.$user_feeds.'</div>';	
-		echo '</div>';
+		$social_right_content .=  '<div class="rounded_div" style="width:90%">';				
+			$social_right_content .=  '<div><h3>'.get_lang('RSSFeeds').'</h3></div>';
+			$social_right_content .=  '<div class="social-content-training">'.$user_feeds.'</div>';	
+		$social_right_content .=  '</div>';
 	}
 
 	//--Productions
@@ -560,34 +547,34 @@ if ($show_full_profile) {
 		$count_pending_invitations = count($pending_invitations);
 	}
 
-	echo '<div class="social-box-main1">';	
+	$social_right_content .=  '<div class="social-box-main1">';	
 
 	if (!empty($production_list) || !empty($file_list) || $count_pending_invitations > 0) {
 		
 		//Pending invitations
 		if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u']==api_get_user_id())) {
 			if ($count_pending_invitations > 0) {				
-				echo '<div class="rounded_div" style="width:280px">';
-				echo '<div><h3>'.get_lang('PendingInvitations').'</h3></div>';
+				$social_right_content .=  '<div class="rounded_div" style="width:280px">';
+				$social_right_content .=  '<div><h3>'.get_lang('PendingInvitations').'</h3></div>';
 				for ($i=0;$i<$count_pending_invitations;$i++) {
 					$user_invitation_id = $pending_invitations[$i]['user_sender_id'];
-					echo '<div id="dpending_'.$user_invitation_id.'" class="friend_invitations">';
-    					echo '<div style="float:left;width:60px;" >';
-    					   echo '<img style="margin-bottom:5px;" src="'.$list_get_path_web[$i]['dir'].'/'.$list_get_path_web[$i]['file'].'" width="60px">';
-    					echo '</div>';
+					$social_right_content .=  '<div id="dpending_'.$user_invitation_id.'" class="friend_invitations">';
+    					$social_right_content .=  '<div style="float:left;width:60px;" >';
+    					   $social_right_content .=  '<img style="margin-bottom:5px;" src="'.$list_get_path_web[$i]['dir'].'/'.$list_get_path_web[$i]['file'].'" width="60px">';
+    					$social_right_content .=  '</div>';
     
-    					echo '<div style="padding-left:70px;">';
+    					$social_right_content .=  '<div style="padding-left:70px;">';
         					$user_invitation_info = api_get_user_info($user_invitation_id);
-        					echo '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_invitation_id.'">'.api_get_person_name($user_invitation_info['firstname'], $user_invitation_info['lastname']).'</a>';
-        					echo '<br />';
-        					echo Security::remove_XSS(cut($pending_invitations[$i]['content'], 50), STUDENT, true);
-        					echo '<br />';
-        					echo '<a id="btn_accepted_'.$user_invitation_id.'" onclick="register_friend(this)" href="javascript:void(0)">'.get_lang('SocialAddToFriends').'</a>';
-        					echo '<div id="id_response"></div>';
-					    echo '</div>';
-				    echo '</div>';								
+        					$social_right_content .=  '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_invitation_id.'">'.api_get_person_name($user_invitation_info['firstname'], $user_invitation_info['lastname']).'</a>';
+        					$social_right_content .=  '<br />';
+        					$social_right_content .=  Security::remove_XSS(cut($pending_invitations[$i]['content'], 50), STUDENT, true);
+        					$social_right_content .=  '<br />';
+        					$social_right_content .=  '<a id="btn_accepted_'.$user_invitation_id.'" onclick="register_friend(this)" href="javascript:void(0)">'.get_lang('SocialAddToFriends').'</a>';
+        					$social_right_content .=  '<div id="id_response"></div>';
+					    $social_right_content .=  '</div>';
+				    $social_right_content .=  '</div>';								
 				}
-				echo '</div>'; //close rounded     				
+				$social_right_content .=  '</div>'; //close rounded     				
 			}
 		}
 				
@@ -609,51 +596,60 @@ if ($show_full_profile) {
 			$product_content .=  '</div>';
 		}
 		if (!empty($product_content)) {
-			echo '<div class="rounded_div" style="width:280px">';
-			echo $product_content;
-			echo '</div>'; // close rounded
+			$social_right_content .=  '<div class="rounded_div" style="width:280px">';
+			$social_right_content .=  $product_content;
+			$social_right_content .=  '</div>'; // close rounded
 		}				
 	}
 	
 	 
 	if (!empty($user_info['competences']) || !empty($user_info['diplomas']) || !empty($user_info['openarea']) || !empty($user_info['teach']) ) {
 		
-		echo '<div class="rounded_div" style="width:280px">';
-		echo '<div><h3>'.get_lang('MoreInformation').'</h3></div>';		
+		$social_right_content .=  '<div class="rounded_div" style="width:280px">';
+		$social_right_content .=  '<div><h3>'.get_lang('MoreInformation').'</h3></div>';		
 		$cut_size = 220;
 		if (!empty($user_info['competences'])) {
-			echo '<br />';
-			echo '<div class="social-background-content" style="width:100%;">';
-    			echo '<div class="social-actions-message"><strong>'.get_lang('MyCompetences').'</strong></div>';
-    			echo '<div class="social-profile-extended">'.$user_info['competences'].'</div>';
-			echo '</div>';
-			echo '<br />';
+			$social_right_content .=  '<br />';
+			$social_right_content .=  '<div class="social-background-content" style="width:100%;">';
+    			$social_right_content .=  '<div class="social-actions-message"><strong>'.get_lang('MyCompetences').'</strong></div>';
+    			$social_right_content .=  '<div class="social-profile-extended">'.$user_info['competences'].'</div>';
+			$social_right_content .=  '</div>';
+			$social_right_content .=  '<br />';
 		}
 		if (!empty($user_info['diplomas'])) {
-			echo '<div class="social-background-content" style="width:100%;" >';
-    			echo '<div class="social-actions-message"><strong>'.get_lang('MyDiplomas').'</strong></div>';
-    			echo '<div class="social-profile-extended">'.$user_info['diplomas'].'</div>';
-			echo '</div>';
-			echo '<br />';
+			$social_right_content .=  '<div class="social-background-content" style="width:100%;" >';
+    			$social_right_content .=  '<div class="social-actions-message"><strong>'.get_lang('MyDiplomas').'</strong></div>';
+    			$social_right_content .=  '<div class="social-profile-extended">'.$user_info['diplomas'].'</div>';
+			$social_right_content .=  '</div>';
+			$social_right_content .=  '<br />';
 		}
 		if (!empty($user_info['openarea'])) {
-			echo '<div class="social-background-content" style="width:100%;" >';
-    			echo '<div class="social-actions-message"><strong>'.get_lang('MyPersonalOpenArea').'</strong></div>';
-    			echo '<div class="social-profile-extended">'.$user_info['openarea'].'</div>';
-			echo '</div>';
-			echo '<br />';
+			$social_right_content .=  '<div class="social-background-content" style="width:100%;" >';
+    			$social_right_content .=  '<div class="social-actions-message"><strong>'.get_lang('MyPersonalOpenArea').'</strong></div>';
+    			$social_right_content .=  '<div class="social-profile-extended">'.$user_info['openarea'].'</div>';
+			$social_right_content .=  '</div>';
+			$social_right_content .=  '<br />';
 		}
 		if (!empty($user_info['teach'])) {
-			echo '<div class="social-background-content" style="width:100%;" >';
-    			echo '<div class="social-actions-message"><strong>'.get_lang('MyTeach').'</strong></div>';
-    			echo '<div class="social-profile-extended">'.$user_info['teach'].'</div>';
-			echo '</div>';
-			echo '<br />';
+			$social_right_content .=  '<div class="social-background-content" style="width:100%;" >';
+    			$social_right_content .=  '<div class="social-actions-message"><strong>'.get_lang('MyTeach').'</strong></div>';
+    			$social_right_content .=  '<div class="social-profile-extended">'.$user_info['teach'].'</div>';
+			$social_right_content .=  '</div>';
+			$social_right_content .=  '<br />';
 		}		
-		echo '</div>'; //rounded     
+		$social_right_content .=  '</div>'; //rounded     
 	}	
-	echo '</div>'; // close social-box-main1
+	$social_right_content .=  '</div>'; // close social-box-main1
 }
-echo '</div>';
-echo '</div>';
-Display :: display_footer();
+
+
+$tpl = new Template(get_lang('Social'));
+$tpl->assign('social_left_content', $social_left_content);
+$tpl->assign('social_left_menu', $social_left_menu);
+$tpl->assign('social_right_content', $social_right_content);
+$social_layout = $tpl->get_template('layout/social_layout.tpl');
+$content = $tpl->fetch($social_layout);
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 144 - 143
main/social/search.php

@@ -26,149 +26,150 @@ $query_vars = array();
 
 $query  = isset($_GET['q']) ? $_GET['q'] : null;
 
-Display :: display_header($tool_name);
-
-echo '<div id="social-content">';
-	echo '<div id="social-content-left">';
-		//show the action menu			
-		SocialManager::show_social_menu('search');
-	echo '</div>';
-	echo '<div id="social-content-right">';
+$social_left_content = SocialManager::show_social_menu('search');
 		
-		echo UserManager::get_search_form($query);
+$social_right_content = UserManager::get_search_form($query);
 			
-		//I'm searching something
-		if ($query !='') {	
-			//get users from tags
-			$users  = UserManager::get_all_user_tags($_GET['q'], 0, 0, 5);
-			$groups = GroupPortalManager::get_all_group_tags($_GET['q']);
-						
-			if (empty($users) && empty($groups)) {
-				echo get_lang('SorryNoResults');	
-			}
-						
-			$results = array();
-			if (is_array($users) && count($users)> 0) {
-				echo '<h2>'.get_lang('Users').'</h2>';			
-				foreach($users as $user) {
-                    $user_info = api_get_user_info($user['user_id'], true);
-					$url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$user['user_id'];
-					    
-					if (empty($user['picture_uri'])) {
-                    	$picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_180_100.jpg';
-                        $img = Display::url('<img title class="social-home-anonymous-online" src="'.$picture['file'].'">', $url); 
-					} else {
-                    	$picture = UserManager::get_picture_user($user['user_id'], $user['picture_uri'], 80, USER_IMAGE_SIZE_ORIGINAL );
-                            
-                        $img = '<img src="'.$picture['file'].'">';                        
-                        $clip = 'clip_vertical';                    
-                        if ($picture['original_height'] > $picture['original_width']) {
-                        	$clip = 'clip_horizontal';    
-                        }                    
-                        $img = Display::url(Display::div(Display::div($img, array('class'=>$clip)), array('class'=>'clip-wrapper')) , $url);
-                    }                             
-                    if ($user_info['user_is_online']) {
-                        $status_icon = Display::span('', array('class' => 'online_user'));
-                    } else {
-                        $status_icon = Display::span('', array('class' => 'offline_user'));    
+    //I'm searching something
+    if ($query !='') {	
+        //get users from tags
+        $users  = UserManager::get_all_user_tags($_GET['q'], 0, 0, 5);
+        $groups = GroupPortalManager::get_all_group_tags($_GET['q']);
+
+        if (empty($users) && empty($groups)) {
+            $social_right_content .= get_lang('SorryNoResults');	
+        }
+
+        $results = array();
+        if (is_array($users) && count($users)> 0) {
+            $social_right_content .=  '<h2>'.get_lang('Users').'</h2>';			
+            foreach($users as $user) {
+                $user_info = api_get_user_info($user['user_id'], true);
+                $url = api_get_path(WEB_PATH).'main/social/profile.php?u='.$user['user_id'];
+
+                if (empty($user['picture_uri'])) {
+                    $picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_180_100.jpg';
+                    $img = Display::url('<img title class="social-home-anonymous-online" src="'.$picture['file'].'">', $url); 
+                } else {
+                    $picture = UserManager::get_picture_user($user['user_id'], $user['picture_uri'], 80, USER_IMAGE_SIZE_ORIGINAL );
+
+                    $img = '<img src="'.$picture['file'].'">';                        
+                    $clip = 'clip_vertical';                    
+                    if ($picture['original_height'] > $picture['original_width']) {
+                        $clip = 'clip_horizontal';    
                     }                    
-                    $img = $status_icon.$img;
-                    
-					$user['firstname'] = Display::url($user['firstname'], $url);
-					$user['lastname'] = Display::url($user['lastname'], $url);
-					$user['tag'] = isset($user['tag']) ? $user['tag'] : null;
-					$results[] = array($img, $user['firstname'], $user['lastname'], $user['tag']);			
-				}					
-					
-				echo '<div id="div_content_table">';				
-					Display::display_sortable_grid('online', array(), $results, array('hide_navigation'=>true, 'per_page' => 5), $query_vars, false ,true);
-				echo '</div>';											
-			}
-								
-			//Get users from tags this loop does not make sense for now ... 
-			/*
-			if (is_array($results) && count($results) > 0) {				
-				foreach ($results as $result) {
-							
-					$id = $result['id'];					
-					$url_open  = '<a href="groups.php?id='.$id.'">';
-					$url_close = '</a>';
-						
-					$name = api_strtoupper(cut($result['name'],25,true));				
-					if (isset($result['relation_type']) && $result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {		 	
-						$name .= Display::return_icon('social_group_admin.png', get_lang('Admin'), array('style'=>'vertical-align:middle'));
-					} elseif (isset($result['relation_type'])  && $result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {			
-						$name .= Display::return_icon('social_group_moderator.png', get_lang('Moderator'), array('style'=>'vertical-align:middle'));
-					}
-					$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');	
-					} else {
-						$count_users_group = $count_users_group.' '.get_lang('Members');
-					}					
-					
-					$picture = GroupPortalManager::get_picture_group($id, $result['picture_uri'],80);	
-											
-					$result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';			
-					$grid_item_1 = Display::return_icon('boxmygroups.jpg');				
-					$item_1 = '<div>'.$url_open.$result['picture_uri'].'<strong>'.$name.'<br />('.$count_users_group.')</strong>'.$url_close.'</div>';
-				
-					if ($result['description'] != '') {
-						$item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2">'.get_lang('Description').'</span></div>';
-						$item_3 = '<div class="box_description_group_content" >'.cut($result['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_actions" >'.$url_open.get_lang('SeeMore').$url_close.'</div>';			
-					$grid_item_2 = $item_1.$item_2.$item_3.$item_4;				
-					$grid_my_groups[]= array($grid_item_1,$grid_item_2);
-				}
-			}*/
-				
-			$grid_groups = array();
-			if (is_array($groups) && count($groups)>0) {
-				echo '<h2>'.get_lang('Groups').'</h2>';
-				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_close = '</a>';						
-					$name = cut($group['name'],25,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');	
-					} else {
-						$count_users_group = $count_users_group.' '.get_lang('Members');
-					}				
-				    $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" />';			
-					
-
-        			$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_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);
-				}		
-			}
-			$visibility = array(true,true,true,true,true);
-			Display::display_sortable_grid('mygroups', array(), $grid_groups, array('hide_navigation'=>true, 'per_page' => 5), $query_vars, false, $visibility);
-		}		
-							
-	echo '</div>';
-echo '</div>';
-Display :: display_footer();
+                    $img = Display::url(Display::div(Display::div($img, array('class'=>$clip)), array('class'=>'clip-wrapper')) , $url);
+                }                             
+                if ($user_info['user_is_online']) {
+                    $status_icon = Display::span('', array('class' => 'online_user_in_text'));
+                } else {
+                    $status_icon = Display::span('', array('class' => 'offline_user_in_text'));    
+                }                    
+                $img = $img;
+                
+                $user['tag'] = isset($user['tag']) ? $user['tag'] : null;
+                $user_info['complete_name'] = Display::url($user_info['complete_name'], $url).'<br >'.$user['tag'];                
+                
+                $results[] = array($img, $status_icon.$user_info['complete_name'], $user['tag']);			
+            }					
+
+            $social_right_content .=  '<div id="div_content_table">';				
+            $social_right_content .= Display::return_sortable_grid('online', array(), $results, array('hide_navigation'=>true, 'per_page' => 5), $query_vars, false ,true);
+            $social_right_content .=  '</div>';											
+        }
+
+        //Get users from tags this loop does not make sense for now ... 
+        /*
+        if (is_array($results) && count($results) > 0) {				
+            foreach ($results as $result) {
+
+                $id = $result['id'];					
+                $url_open  = '<a href="groups.php?id='.$id.'">';
+                $url_close = '</a>';
+
+                $name = api_strtoupper(cut($result['name'],25,true));				
+                if (isset($result['relation_type']) && $result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {		 	
+                    $name .= Display::return_icon('social_group_admin.png', get_lang('Admin'), array('style'=>'vertical-align:middle'));
+                } elseif (isset($result['relation_type'])  && $result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {			
+                    $name .= Display::return_icon('social_group_moderator.png', get_lang('Moderator'), array('style'=>'vertical-align:middle'));
+                }
+                $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');	
+                } else {
+                    $count_users_group = $count_users_group.' '.get_lang('Members');
+                }					
+
+                $picture = GroupPortalManager::get_picture_group($id, $result['picture_uri'],80);	
+
+                $result['picture_uri'] = '<img class="social-groups-image" src="'.$picture['file'].'" hspace="4" height="50" border="2" align="left" width="50" />';			
+                $grid_item_1 = Display::return_icon('boxmygroups.jpg');				
+                $item_1 = '<div>'.$url_open.$result['picture_uri'].'<strong>'.$name.'<br />('.$count_users_group.')</strong>'.$url_close.'</div>';
+
+                if ($result['description'] != '') {
+                    $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2">'.get_lang('Description').'</span></div>';
+                    $item_3 = '<div class="box_description_group_content" >'.cut($result['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_actions" >'.$url_open.get_lang('SeeMore').$url_close.'</div>';			
+                $grid_item_2 = $item_1.$item_2.$item_3.$item_4;				
+                $grid_my_groups[]= array($grid_item_1,$grid_item_2);
+            }
+        }*/
+
+        $grid_groups = array();
+        if (is_array($groups) && count($groups)>0) {
+            $social_right_content .=  '<h2>'.get_lang('Groups').'</h2>';
+            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_close = '</a>';						
+                $name = cut($group['name'],25,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');	
+                } else {
+                    $count_users_group = $count_users_group.' '.get_lang('Members');
+                }				
+                $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" />';			
+
+
+                $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_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);
+            }		
+        }
+        $visibility = array(true,true,true,true,true);
+        $social_right_content .= Display::return_sortable_grid('mygroups', array(), $grid_groups, array('hide_navigation'=>true, 'per_page' => 5), $query_vars, false, $visibility);
+    }									
+$social_right_content .= '</div>';
+
+$tpl = new Template($tool_name);
+$tpl->assign('social_left_content', $social_left_content);
+$tpl->assign('social_left_menu', $social_left_menu);
+$tpl->assign('social_right_content', $social_right_content);
+$social_layout = $tpl->get_template('layout/social_layout.tpl');
+$content = $tpl->fetch($social_layout);
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();

+ 15 - 0
main/template/default/layout/social_layout.tpl

@@ -0,0 +1,15 @@
+<div id="social-content">    
+    <div id="social-content-left">
+        {$social_left_content}
+    </div>
+    
+    <div class="social-menu">
+        {$social_left_menu}
+    </div>
+    
+    <div id="social-content-right">
+        {$social_right_content}        
+    </div>
+</div>
+
+<div class="clear">&nbsp;</div>

+ 5 - 11
main/user/userInfo.php

@@ -446,17 +446,11 @@ elseif ($displayMode == "viewContentEdit") {
 		echo '<input type="image" src="'.$image_array['dir'].$image_array['file'].'" onclick="return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/>';
 		}
 
-		// is the user online ?			
-		$users_online = who_is_online(30);
-		foreach ($users_online as $online) {
-			if (in_array($userIdViewed, $online)) {	
-				$online = Display::return_icon('online.gif', get_lang('OnLine'),array('style'=>'with="8"; height="8"'));
-				break;
-			} else {
-				$online ='';
-			}
-				
-		}
+		// is the user online?		
+        $online ='';
+        if (user_is_online($userIdViewed)) {
+            $online = Display::return_icon('online.gif', get_lang('OnLine'),array('style'=>'with="8"; height="8"'));
+        }
 
 		//DISPLAY TABLE HEADING
 		if ($origin == 'learnpath') { $allowedToEditDef=false; $is_allowedToTrack=false; }

+ 47 - 46
whoisonline.php

@@ -106,18 +106,21 @@ function hide_icon_edit(element_html)  {
 }       
 
 
-$(document).ready(function() {
+
+$(document).ready(function() {    
     $(document).endlessScroll({
         fireOnce: false,
         fireDelay: false,
         loader: "<div class=\'loading\'>Loading<div>",
         callback: function(page) {    
-        page = page + 1;
-          $.ajax({                
+            page = page;            
+                
+            $.ajax({                
                 beforeSend: function(objeto) {
-                    $("#display_response_id").html("Loading"); },
+                    $("#display_response_id").html("Loading"); 
+                },
                 type: "GET",
-                    url: "main/inc/ajax/online.ajax.php?a=load_online_user",
+                url: "main/inc/ajax/online.ajax.php?a=load_online_user",
                 data: "online_page_nr="+page,
                 success: function(data) {   
                     if (data != "end") {
@@ -126,12 +129,10 @@ $(document).ready(function() {
                     }
                 }
             });
-        }
+          
+       }    
     });
-});
-
-
-        
+});        
 </script>';
 
 if ($_GET['chatid'] != '') {
@@ -155,57 +156,57 @@ if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) ||
 	if(isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
 		$user_list = who_is_online_in_this_course(api_get_user_id(), api_get_setting('time_limit_whosonline'), $_GET['cidReq']);
 	} else {
-		$user_list = who_is_online(api_get_setting('time_limit_whosonline'));		
+		$user_list = who_is_online(0, 10);		
 	}
-
-	$total = count($user_list);
-	if (!isset($_GET['id'])) {
-	    $header_title  = get_lang('UsersOnLineList');
-        if (!api_get_user_id()) { 
-            $header_title = null;
-        }
-		Display::display_header($header_title);
+    
+	if (!isset($_GET['id'])) {	    		
 		if (api_get_setting('allow_social_tool') == 'true') {
-			if (!api_is_anonymous()) {
-				echo '<div id="social-content-left">';
+			if (!api_is_anonymous()) {				
 				//this include the social menu div
-				SocialManager::show_social_menu('whoisonline');
-				echo '</div>';
+				$social_left_content = SocialManager::show_social_menu('whoisonline');				
 			}			
 		} else {
-			echo '<div class="actions-title">';
-			echo get_lang('UsersOnLineList');
-			echo '</div>';
+			$social_right_content .= '<div class="actions-title">';
+			$social_right_content .= get_lang('UsersOnLineList');
+			$social_right_content .= '</div>';
 		}
 	}
 
 	if ($user_list) {
 		if (!isset($_GET['id'])) {
-			if (api_get_setting('allow_social_tool') == 'true') {
-				echo '<div id="social-content-right">';			
-				//this include the social menu div
+			if (api_get_setting('allow_social_tool') == 'true') {				
 				if (!api_is_anonymous()) {
 				    $query = isset($_GET['q']) ? $_GET['q']: null;				    
-					echo UserManager::get_search_form($query);
+					$social_right_content .= UserManager::get_search_form($query);
 				}
 			}
-			echo Display::tag('h2', get_lang('UsersOnLineList'));
-			SocialManager::display_user_list($user_list);			
-			if (api_get_setting('allow_social_tool') == 'true') {				
-				echo '</div>';
-			}			
-		} else {
-			//individual user information - also displays header info
-			SocialManager::display_individual_user($_GET['id']);
+			$social_right_content .= Display::tag('h2', get_lang('UsersOnLineList'));
+			$social_right_content .= SocialManager::display_user_list($user_list);							
 		}
-	} elseif (isset($_GET['id'])) {
-		Display::display_header(get_lang('UsersOnLineList'));
-		echo '<div class="actions-title">';
-		echo get_lang('UsersOnLineList');
-		echo '</div>';
 	}
+    
+    if (isset($_GET['id'])) {
+        //SocialManager::display_individual_user($_GET['id']);
+        header("Location: ".api_get_path(WEB_CODE_PATH)."social/profile.php?u=?".$_GET['id']);
+        exit;            
+    }
+} else {	
+	api_not_allowed();
+    exit;
+}
+
+$tpl = new Template(get_lang('UsersOnLineList'));
+if (api_get_setting('allow_social_tool') == 'true') {
+    $tpl->assign('social_left_content', $social_left_content);
+    $tpl->assign('social_left_menu', $social_left_menu);
+    $tpl->assign('social_right_content', $social_right_content);
+    $social_layout = $tpl->get_template('layout/social_layout.tpl');
+    $content = $tpl->fetch($social_layout);
 } else {
-	Display::display_header(get_lang('UsersOnLineList'));
-	Display::display_error_message(get_lang('AccessNotAllowed'));
+    $content = $social_right_content;
 }
-Display::display_footer();
+
+$tpl->assign('actions', $actions);
+$tpl->assign('message', $show_message);
+$tpl->assign('content', $content);
+$tpl->display_one_col_template();