Browse Source

Fix social tools, update settings.

Julio Montoya 9 years ago
parent
commit
b340fe8f51
51 changed files with 500 additions and 400 deletions
  1. 1 1
      main/inc/ajax/chat.ajax.php
  2. 8 2
      main/inc/ajax/message.ajax.php
  3. 5 2
      main/inc/ajax/online.ajax.php
  4. 1 1
      main/inc/lib/api.lib.php
  5. 1 1
      main/inc/lib/banner.lib.php
  6. 18 6
      main/inc/lib/message.lib.php
  7. 0 171
      main/inc/lib/online.inc.php
  8. 18 12
      main/inc/lib/social.lib.php
  9. 190 0
      main/inc/lib/usermanager.lib.php
  10. 15 15
      main/messages/inbox.php
  11. 2 3
      main/messages/index.php
  12. 16 11
      main/messages/new_message.php
  13. 9 11
      main/messages/outbox.php
  14. 11 10
      main/messages/view_message.php
  15. 9 6
      main/social/friends.php
  16. 10 8
      main/social/group_add.php
  17. 9 10
      main/social/group_edit.php
  18. 7 7
      main/social/group_invitation.php
  19. 18 9
      main/social/group_members.php
  20. 8 7
      main/social/group_topics.php
  21. 12 10
      main/social/group_view.php
  22. 12 8
      main/social/group_waiting_list.php
  23. 18 15
      main/social/groups.php
  24. 2 0
      main/social/home.php
  25. 8 8
      main/social/invitations.php
  26. 12 5
      main/social/message_for_group_form.inc.php
  27. 9 8
      main/social/myfiles.php
  28. 19 14
      main/social/search.php
  29. 1 1
      plugin/ticket/src/new_ticket.php
  30. 9 1
      plugin/ticket/src/ticket_details.php
  31. 1 0
      src/Chamilo/CoreBundle/Framework/Container.php
  32. 2 2
      src/Chamilo/CoreBundle/Resources/views/default/social/add_groups.html.twig
  33. 5 2
      src/Chamilo/CoreBundle/Resources/views/default/social/avatar_block.html.twig
  34. 2 2
      src/Chamilo/CoreBundle/Resources/views/default/social/edit_profile.html.twig
  35. 1 1
      src/Chamilo/CoreBundle/Resources/views/default/social/form_modals.html.twig
  36. 2 2
      src/Chamilo/CoreBundle/Resources/views/default/social/friends.html.twig
  37. 2 0
      src/Chamilo/CoreBundle/Resources/views/default/social/group_block.html.twig
  38. 2 3
      src/Chamilo/CoreBundle/Resources/views/default/social/group_view.html.twig
  39. 2 2
      src/Chamilo/CoreBundle/Resources/views/default/social/group_waiting_list.html.twig
  40. 2 2
      src/Chamilo/CoreBundle/Resources/views/default/social/groups.html.twig
  41. 3 3
      src/Chamilo/CoreBundle/Resources/views/default/social/home.html.twig
  42. 2 2
      src/Chamilo/CoreBundle/Resources/views/default/social/inbox.html.twig
  43. 2 2
      src/Chamilo/CoreBundle/Resources/views/default/social/invitations.html.twig
  44. 2 2
      src/Chamilo/CoreBundle/Resources/views/default/social/myfiles.html.twig
  45. 2 2
      src/Chamilo/CoreBundle/Resources/views/default/social/profile.html.twig
  46. 3 5
      src/Chamilo/CoreBundle/Resources/views/default/social/search.html.twig
  47. 0 0
      src/Chamilo/CoreBundle/Resources/views/default/social/skills_block.html.twig
  48. 3 3
      src/Chamilo/CoreBundle/Resources/views/default/social/user_block.html.twig
  49. 2 2
      src/Chamilo/CoreBundle/Resources/views/default/social/whoisonline.html.twig
  50. 1 0
      src/Chamilo/CoreBundle/Resources/views/layout_one_col.html.twig
  51. 1 0
      src/Chamilo/ThemeBundle/Resources/views/Layout/base-layout.html.twig

+ 1 - 1
main/inc/ajax/chat.ajax.php

@@ -29,7 +29,7 @@ if ($action == 'preview') {
     );
 }
 
-if (api_get_setting('allow_global_chat') == 'false') {
+if (api_get_setting('chat.allow_global_chat') == 'false') {
     exit;
 }
 

+ 8 - 2
main/inc/ajax/message.ajax.php

@@ -56,7 +56,10 @@ switch ($action) {
             ) == 'true'
         ) {
             // All users
-            if (api_get_setting('allow_send_message_to_all_platform_users') == 'true' || api_is_platform_admin() ) {
+            if (api_get_setting(
+                    'message.allow_send_message_to_all_platform_users'
+                ) == 'true' || api_is_platform_admin()
+            ) {
                 if ($access_url_id != 0) {
                     $sql = "SELECT DISTINCT u.user_id as id, u.firstname, u.lastname, u.email
                             FROM $tbl_user u LEFT JOIN $tbl_access_url_rel_user r ON u.user_id = r.user_id
@@ -108,7 +111,10 @@ switch ($action) {
                 'message.allow_message_tool'
             ) == 'true'
         ) {
-            if (api_get_setting('allow_send_message_to_all_platform_users') == 'true') {
+            if (api_get_setting(
+                    'message.allow_send_message_to_all_platform_users'
+                ) == 'true'
+            ) {
                 $sql = "SELECT DISTINCT u.user_id as id, u.firstname, u.lastname, u.email
                         FROM $tbl_user u LEFT JOIN $tbl_access_url_rel_user r ON u.user_id = r.user_id
                         WHERE

+ 5 - 2
main/inc/ajax/online.ajax.php

@@ -15,7 +15,7 @@ switch($action) {
         $images_to_show = 9;
 
         $page = intval($_REQUEST['online_page_nr']);
-        $max_page = ceil(who_is_online_count()/$images_to_show);
+        $max_page = ceil(UserManager::whoIsOnlineCount() / $images_to_show);
         $page_rows = ($page-1)*9;
 
         if (!empty($max_page) && $page <= $max_page) {
@@ -28,7 +28,10 @@ switch($action) {
                     $_GET['cidReq']
                 );
             } else {
-                $user_list = who_is_online($page_rows, $images_to_show);
+                $user_list = UserManager::whoIsOnline(
+                    $page_rows,
+                    $images_to_show
+                );
             }
             if (!empty($user_list)) {
                 echo SocialManager::display_user_list($user_list, false);

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

@@ -7048,7 +7048,7 @@ function api_is_global_chat_enabled()
 {
     return
         !api_is_anonymous() &&
-        api_get_setting('allow_global_chat') == 'true' &&
+        api_get_setting('chat.allow_global_chat') == 'true' &&
         api_get_setting('social.allow_social_tool') == 'true';
 }
 

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

@@ -218,7 +218,7 @@ function return_notification_menu()
         (api_get_setting('showonline', 'users') == 'true' && $user_id) ||
         (api_get_setting('showonline', 'course') == 'true' && $user_id && $course_id)
     ) {
-        $number = who_is_online_count(
+        $number = UserManager::whoIsOnlineCount(
             api_get_setting('display.time_limit_whosonline')
         );
 

+ 18 - 6
main/inc/lib/message.lib.php

@@ -18,8 +18,8 @@ class MessageManager
     public static function get_online_user_list($current_user_id)
     {
         //@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);
+        $count = UserManager::whoIsOnlineCount();
+        $userlist = UserManager::whoIsOnline(0, $count, null, null, 30, true);
         $online_user_list = array();
         foreach ($userlist as $user_id) {
             $online_user_list[$user_id] = GetFullUserName($user_id).($current_user_id == $user_id ? ("&nbsp;(".get_lang('Myself').")") : (""));
@@ -86,8 +86,15 @@ class MessageManager
      */
     public static function users_connected_by_id()
     {
-        $count = who_is_online_count();
-        $user_connect = who_is_online(0, $count, null, null, 30, true);
+        $count = UserManager::whoIsOnlineCount();
+        $user_connect = UserManager::whoIsOnline(
+            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];
@@ -238,10 +245,15 @@ class MessageManager
         if (empty($subject) && empty($group_id)) {
             Display::addFlash(Display::return_message(get_lang('YouShouldWriteASubject'), 'warning'));
             return false;
-        } else if ($total_filesize > intval(api_get_setting('message_max_upload_filesize'))) {
+        } else if ($total_filesize > intval(
+                api_get_setting('message.message_max_upload_filesize')
+            )
+        ) {
             $warning = sprintf(
                 get_lang("FilesSizeExceedsX"),
-                format_file_size(api_get_setting('message_max_upload_filesize'))
+                format_file_size(
+                    api_get_setting('message.message_max_upload_filesize')
+                )
             );
 
             Display::addFlash(Display::return_message($warning , 'warning'));

+ 0 - 171
main/inc/lib/online.inc.php

@@ -172,178 +172,7 @@ function LoginDelete($user_id)
 	Database::query($query);
 }
 
-/**
- * Gives a list of people online now (and in the last $valid minutes)
- * @return  array       For each line, a list of user IDs and login dates, or FALSE on error or empty results
- */
-function who_is_online($from, $number_of_items, $column = null, $direction = null, $time_limit = null, $friends = false)
-{
-    // Time limit in seconds?
-    if (empty($time_limit)) {
-		$time_limit = api_get_setting('display.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';
-        }
-    }
-
-    $online_time = time() - $time_limit * 60;
-    $current_date = api_get_utc_datetime($online_time);
-	$track_online_table = Database::get_main_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);
-
-	if ($friends) {
-		// 	who friends from social network is online
-		$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
-				    login_date >= '".$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 {
-		$query = "SELECT DISTINCT login_user_id, login_date
-                    FROM ".$track_online_table ." e
-		            INNER JOIN ".$table_user ." u ON (u.id = e.login_user_id)
-                  WHERE u.status != ".ANONYMOUS." AND login_date >= '".$current_date."'
-                  ORDER BY $column $direction
-                  LIMIT $from, $number_of_items";
-	}
-
-	if (api_get_multiple_access_url()) {
-		$access_url_id = api_get_current_access_url_id();
-		if ($access_url_id != -1) {
-			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
-                                    login_date >= '".$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.id=track.login_user_id)
-						  WHERE u.status != ".ANONYMOUS." AND track.access_url_id =  $access_url_id AND
-                                login_date >= '".$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.id as login_user_id, login_date FROM ".$track_online_table ."  e , $table_user u
-            GROUP by u.id
-            ORDER BY $column $direction
-            LIMIT $from, $number_of_items";*/
-
-	$result = Database::query($query);
-	if ($result) {
-		$users_online = array();
-		while (list($login_user_id, $login_date) = Database::fetch_row($result)) {
-            $users_online[] = $login_user_id;
-		}
-		return $users_online;
-	} else {
-		return false;
-	}
-}
-
-function who_is_online_count($time_limit = null, $friends = false)
-{
-    if (empty($time_limit)) {
-		$time_limit = api_get_setting('display.time_limit_whosonline');
-    } else {
-        $time_limit = intval($time_limit);
-    }
-	$track_online_table = Database::get_main_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);
-	$online_time = time() - $time_limit * 60;
-	$current_date = api_get_utc_datetime($online_time);
-
-	if ($friends) {
-		// 	who friends from social network is online
-		$query = "SELECT DISTINCT count(login_user_id) as count
-				  FROM $track_online_table INNER JOIN $friend_user_table
-                  ON (friend_user_id = login_user_id)
-				  WHERE
-				        login_date >= '$current_date' AND
-				        friend_user_id <> '".api_get_user_id()."' AND
-				        relation_type='".USER_RELATION_TYPE_FRIEND."' AND
-				        user_id = '".api_get_user_id()."' ";
-	} else {
-		// All users online
-		$query = "SELECT count(login_id) as count
-                  FROM $track_online_table track INNER JOIN $table_user u
-                  ON (u.id=track.login_user_id)
-                  WHERE u.status != ".ANONYMOUS." AND login_date >= '$current_date'  ";
-	}
-
-	if (api_get_multiple_access_url()) {
-		$access_url_id = api_get_current_access_url_id();
-		if ($access_url_id != -1) {
-			if ($friends) {
-				// 	friends from social network is online
-				$query = "SELECT DISTINCT count(login_user_id) as count
-							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
-							    login_date >= '".$current_date."' AND
-							    friend_user_id <> '".api_get_user_id()."' AND
-							    relation_type='".USER_RELATION_TYPE_FRIEND."'  ";
-			} else {
-				// all users online
-				$query = "SELECT count(login_id) as count FROM $track_online_table  track
-                          INNER JOIN $table_user u ON (u.id=track.login_user_id)
-						  WHERE
-						    u.status != ".ANONYMOUS." AND
-						    track.access_url_id =  $access_url_id AND
-						    login_date >= '$current_date' ";
-			}
-		}
-	}
-
-    // Dev purposes show all users online
-    /*$table_user = Database::get_main_table(TABLE_MAIN_USER);
-    $query = "SELECT count(*)  as count FROM ".$table_user;*/
-
-	$result = Database::query($query);
-	if (Database::num_rows($result) > 0) {
-		$row = Database::fetch_array($result);
-		return $row['count'];
-	} else {
-		return false;
-	}
-}
 
 
 /**

+ 18 - 12
main/inc/lib/social.lib.php

@@ -1,6 +1,8 @@
 <?php
 /* For licensing terms, see /license.txt */
 
+use Chamilo\CoreBundle\Framework\Container;
+
 /**
  * Class SocialManager
  *
@@ -591,7 +593,7 @@ class SocialManager extends UserManager
             'browse_groups'
         );
 
-        $template = new Template(null, false, false, false, false, false);
+        $template = Container::getTwig();
 
         if (in_array($show, $show_groups) && !empty($group_id)) {
             // Group image
@@ -606,11 +608,11 @@ class SocialManager extends UserManager
                 GROUP_IMAGE_SIZE_BIG
             );
 
-            $template->assign('show_group', true);
-            $template->assign('group_id', $group_id);
-            $template->assign('user_group_image', $userGroupImage);
-            $template->assign('user_group', $group_info);
-            $template->assign(
+            $template->addGlobal('show_group', true);
+            $template->addGlobal('group_id', $group_id);
+            $template->addGlobal('user_group_image', $userGroupImage);
+            $template->addGlobal('user_group', $group_info);
+            $template->addGlobal(
                 'user_is_group_admin',
                 $userGroup->is_group_admin(
                     $group_id,
@@ -618,8 +620,9 @@ class SocialManager extends UserManager
                 )
             );
         } else {
-            $template->assign('show_user', true);
-            $template->assign(
+            $template->addGlobal('show_group', false);
+            $template->addGlobal('show_user', true);
+            $template->addGlobal(
                 'user_image',
                 [
                     'big' => UserManager::getUserPicture(
@@ -634,10 +637,11 @@ class SocialManager extends UserManager
             );
         }
 
-        $skillBlock = $template->get_template('social/avatar_block.tpl');
-
+        $content = $template->render(
+            '@template_style/social/avatar_block.html.twig'
+        );
 
-        return $template->fetch($skillBlock);
+        return $content;
     }
 
     /**
@@ -1697,7 +1701,9 @@ class SocialManager extends UserManager
         $templateName = $template->render('@template_style/social/user_block.html.twig');
 
         if (in_array($groupBlock, ['groups', 'group_edit', 'member_list'])) {
-            $templateName = $template->renders('@template_style/social/group_block.html.twig');
+            $templateName = $template->render(
+                '@template_style/social/group_block.html.twig'
+            );
         }
 
         $template->addGlobal(

+ 190 - 0
main/inc/lib/usermanager.lib.php

@@ -5097,7 +5097,197 @@ SQL;
         }
 
         return false;
+    }
+
+
+    public static function whoIsOnlineCount(
+        $time_limit = null,
+        $friends = false
+    ) {
+        if (empty($time_limit)) {
+            $time_limit = api_get_setting('display.time_limit_whosonline');
+        } else {
+            $time_limit = intval($time_limit);
+        }
+        $track_online_table = Database::get_main_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);
+        $online_time = time() - $time_limit * 60;
+        $current_date = api_get_utc_datetime($online_time);
+
+        if ($friends) {
+            // 	who friends from social network is online
+            $query = "SELECT DISTINCT count(login_user_id) as count
+				  FROM $track_online_table INNER JOIN $friend_user_table
+                  ON (friend_user_id = login_user_id)
+				  WHERE
+				        login_date >= '$current_date' AND
+				        friend_user_id <> '".api_get_user_id()."' AND
+				        relation_type='".USER_RELATION_TYPE_FRIEND."' AND
+				        user_id = '".api_get_user_id()."' ";
+        } else {
+            // All users online
+            $query = "SELECT count(login_id) as count
+                  FROM $track_online_table track INNER JOIN $table_user u
+                  ON (u.id=track.login_user_id)
+                  WHERE u.status != ".ANONYMOUS." AND login_date >= '$current_date'  ";
+        }
+
+        if (api_get_multiple_access_url()) {
+            $access_url_id = api_get_current_access_url_id();
+            if ($access_url_id != -1) {
+                if ($friends) {
+                    // 	friends from social network is online
+                    $query = "SELECT DISTINCT count(login_user_id) as count
+							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
+							    login_date >= '".$current_date."' AND
+							    friend_user_id <> '".api_get_user_id()."' AND
+							    relation_type='".USER_RELATION_TYPE_FRIEND."'  ";
+                } else {
+                    // all users online
+                    $query = "SELECT count(login_id) as count FROM $track_online_table  track
+                          INNER JOIN $table_user u ON (u.id=track.login_user_id)
+						  WHERE
+						    u.status != ".ANONYMOUS." AND
+						    track.access_url_id =  $access_url_id AND
+						    login_date >= '$current_date' ";
+                }
+            }
+        }
 
+        // Dev purposes show all users online
+        /*$table_user = Database::get_main_table(TABLE_MAIN_USER);
+        $query = "SELECT count(*)  as count FROM ".$table_user;*/
+
+        $result = Database::query($query);
+        if (Database::num_rows($result) > 0) {
+            $row = Database::fetch_array($result);
+
+            return $row['count'];
+        } else {
+            return false;
+        }
     }
 
+    /**
+     * Gives a list of people online now (and in the last $valid minutes)
+     * @return  array       For each line, a list of user IDs and login dates, or FALSE on error or empty results
+     */
+    public static function whoIsOnline(
+        $from,
+        $number_of_items,
+        $column = null,
+        $direction = null,
+        $time_limit = null,
+        $friends = false
+    ) {
+        // Time limit in seconds?
+        if (empty($time_limit)) {
+            $time_limit = api_get_setting('display.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';
+            }
+        }
+
+        $online_time = time() - $time_limit * 60;
+        $current_date = api_get_utc_datetime($online_time);
+        $track_online_table = Database::get_main_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);
+
+        if ($friends) {
+            // 	who friends from social network is online
+            $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
+				    login_date >= '".$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 {
+            $query = "SELECT DISTINCT login_user_id, login_date
+                    FROM ".$track_online_table." e
+		            INNER JOIN ".$table_user." u ON (u.id = e.login_user_id)
+                  WHERE u.status != ".ANONYMOUS." AND login_date >= '".$current_date."'
+                  ORDER BY $column $direction
+                  LIMIT $from, $number_of_items";
+        }
+
+        if (api_get_multiple_access_url()) {
+            $access_url_id = api_get_current_access_url_id();
+            if ($access_url_id != -1) {
+                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
+                                    login_date >= '".$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.id=track.login_user_id)
+						  WHERE u.status != ".ANONYMOUS." AND track.access_url_id =  $access_url_id AND
+                                login_date >= '".$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.id as login_user_id, login_date FROM ".$track_online_table ."  e , $table_user u
+                GROUP by u.id
+                ORDER BY $column $direction
+                LIMIT $from, $number_of_items";*/
+
+        $result = Database::query($query);
+        if ($result) {
+            $users_online = array();
+            while (list($login_user_id, $login_date) = Database::fetch_row(
+                $result
+            )) {
+                $users_online[] = $login_user_id;
+            }
+
+            return $users_online;
+        } else {
+            return false;
+        }
+    }
+
+
 }

+ 15 - 15
main/messages/inbox.php

@@ -44,7 +44,6 @@ function hide_icon_edit(element_html)  {
  */
 $nameTools = get_lang('Messages');
 $request = api_is_xml_http_request();
-$show_message = null;
 if (isset($_GET['form_reply']) || isset($_GET['form_delete'])) {
     $info_reply = array();
     $info_delete = array();
@@ -81,12 +80,14 @@ 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);
-            $show_message .= MessageManager::return_message($user_id_by_email, 'confirmation');
+            Display::addFlash(
+                MessageManager::return_message($user_id_by_email, 'confirmation')
+            );
             $social_right_content .= MessageManager::inbox_display();
             exit;
         } elseif (is_null($user_id_by_email)) {
             $message_box = get_lang('ErrorSendingMessage');
-            $show_message .= Display::return_message(api_xml_http_response_encode($message_box), 'error');
+            Display::return_message(api_xml_http_response_encode($message_box), 'error');
             $social_right_content .= MessageManager::inbox_display();
             exit;
         }
@@ -95,7 +96,7 @@ 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');
-        $show_message .= Display::return_message(api_xml_http_response_encode($message_box));
+        Display::return_message(api_xml_http_response_encode($message_box));
         $social_right_content .= MessageManager::inbox_display();
         exit;
     }
@@ -164,7 +165,9 @@ if (!isset($_GET['del_msg'])) {
     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]);
+            Display::addFlash(
+                MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_POST['_'.$i])
+            );
         }
     }
     $social_right_content .= MessageManager::inbox_display();
@@ -174,18 +177,15 @@ if (api_get_setting('social.allow_social_tool') == 'true') {
     $social_right_content .= '</div>';
 }
 
-$tpl = new Template(null);
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
 // Block Social Avatar
-SocialManager::setSocialUserBlock($tpl, $user_id, 'messages');
+SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
 if (api_get_setting('social.allow_social_tool') == 'true') {
-    $tpl->assign('social_menu_block', $social_menu_block);
-    $tpl->assign('social_right_content', $social_right_content);
-    $social_layout = $tpl->get_template('social/inbox.tpl');
-    $tpl->display($social_layout);
+    $tpl->addGlobal('social_menu_block', $social_menu_block);
+    $tpl->addGlobal('social_right_content', $social_right_content);
+    echo $tpl->render('@template_style/social/inbox.html.twig');
 } else {
     $content = $social_right_content;
-    $tpl->assign('actions', $actions);
-    $tpl->assign('message', $show_message);
-    $tpl->assign('content', $content);
-    $tpl->display_one_col_template();
+    echo $actions;
+    echo $content;
 }

+ 2 - 3
main/messages/index.php

@@ -4,9 +4,8 @@
 *	@package chamilo.messages
 */
 //require_once '../inc/global.inc.php';
-if (api_get_setting('social.allow_social_tool') == 'true' && api_get_setting(
-				'allow_message_tool'
-		) == 'true'
+if (api_get_setting('social.allow_social_tool') == 'true' &&
+	api_get_setting('message.allow_message_tool') == 'true'
 ) {
 	header('Location:inbox.php?f=social');
 } elseif (api_get_setting('message.allow_message_tool') == 'true') {

+ 16 - 11
main/messages/new_message.php

@@ -195,7 +195,13 @@ function manage_form($default, $select_from_user_list = null, $sent_to = null)
                 </div>'
         );
 
-        $form->addElement('label', '', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">'.get_lang('AddOneMoreFile').'</a></span>&nbsp;('.sprintf(get_lang('MaximunFileSizeX'),format_file_size(api_get_setting('message_max_upload_filesize'))).')');
+        $form->addElement(
+            'label',
+            '',
+            '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">'.
+            get_lang('AddOneMoreFile').'</a></span>&nbsp;('.
+            sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message.message_max_upload_filesize'))).')'
+        );
     }
 
     $form->addButtonSend(get_lang('SendMessage'), 'compose');
@@ -363,19 +369,18 @@ if (api_get_setting('social.allow_social_tool') == 'true') {
     $social_right_content .=  '</div>';
 }
 
-$tpl = new Template(get_lang('ComposeMessage'));
+//$tpl = new Template(get_lang('ComposeMessage'));
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
 // Block Social Avatar
-SocialManager::setSocialUserBlock($tpl, $user_id, 'messages');
 
+SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
 if (api_get_setting('social.allow_social_tool') == 'true') {
-    $tpl->assign('social_menu_block', $social_menu_block);
-    $tpl->assign('social_right_content', $social_right_content);
-    $social_layout = $tpl->get_template('social/inbox.tpl');
-    $tpl->display($social_layout);
+    $tpl->addGlobal('social_menu_block', $social_menu_block);
+    $tpl->addGlobal('social_right_content', $social_right_content);
+    echo $tpl->render('@template_style/social/inbox.html.twig');
 } else {
     $content = $social_right_content;
-    //$tpl->assign('actions', $actions);
-    //$tpl->assign('message', $show_message);
-    $tpl->assign('content', $content);
-    $tpl->display_one_col_template();
+    echo $actions;
+    echo $content;
 }
+

+ 9 - 11
main/messages/outbox.php

@@ -137,19 +137,17 @@ if ($action == 'delete') {
     $social_right_content .= MessageManager::outbox_display();
 }
 
-$tpl = new Template(get_lang('ComposeMessage'));
+//$tpl = new Template(get_lang('ComposeMessage'));
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
 // Block Social Avatar
-SocialManager::setSocialUserBlock($tpl, $user_id, 'messages');
+SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
 if (api_get_setting('social.allow_social_tool') == 'true') {
-
-    $tpl->assign('social_menu_block', $social_menu_block);
-    $tpl->assign('social_right_content', $social_right_content);
-    $social_layout = $tpl->get_template('social/inbox.tpl');
-    $tpl->display($social_layout);
+    $tpl->addGlobal('social_menu_block', $social_menu_block);
+    $tpl->addGlobal('social_right_content', $social_right_content);
+    echo $tpl->render('@template_style/social/inbox.html.twig');
 } else {
     $content = $social_right_content;
-    $tpl->assign('actions', $actions);
-    //$tpl->assign('message', $show_message);
-    $tpl->assign('content', $content);
-    $tpl->display_one_col_template();
+    echo $actions;
+    echo $content;
 }
+

+ 11 - 10
main/messages/view_message.php

@@ -73,18 +73,19 @@ if (!empty($message)) {
 } else {
     api_not_allowed();
 }
-$tpl = new Template(get_lang('View'));
-// Block Social Avatar
-SocialManager::setSocialUserBlock($tpl, $user_id, $show_menu);
+//$tpl = new Template(get_lang('View'));
 
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
+// Block Social Avatar
+SocialManager::setSocialUserBlock($tpl, api_get_user_id(), $show_menu);
 if (api_get_setting('social.allow_social_tool') == 'true') {
-    $tpl->assign('social_menu_block', $social_menu_block);
-    $tpl->assign('social_right_content', $social_right_content);
-    $social_layout = $tpl->get_template('social/inbox.tpl');
-    $tpl->display($social_layout);
+    $tpl->addGlobal('social_menu_block', $social_menu_block);
+    $tpl->addGlobal('social_right_content', $social_right_content);
+    echo $tpl->render('@template_style/social/inbox.html.twig');
 } else {
     $content = $social_right_content;
-
-    $tpl->assign('content', $content);
-    $tpl->display_one_col_template();
+    echo $actions;
+    echo $content;
 }
+
+

+ 9 - 6
main/social/friends.php

@@ -156,11 +156,14 @@ if (count($friends) == 0) {
 }
 $social_right_content .= '</div>';
 
-$tpl = new Template(get_lang('Social'));
-SocialManager::setSocialUserBlock($tpl, $user_id, 'friends');
+//$tpl = new Template(get_lang('Social'));
 
-$tpl->assign('social_menu_block', $social_menu_block);
-$tpl->assign('social_right_content', $social_right_content);
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
+SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'friends');
+$tpl->addGlobal('social_menu_block', $social_menu_block);
+$tpl->addGlobal('social_right_content', $social_right_content);
+$tpl->addGlobal('social_auto_extend_link', '');
+$tpl->addGlobal('social_right_information', '');
 
-$social_layout = $tpl->get_template('social/friends.tpl');
-$tpl->display($social_layout);
+
+echo $tpl->render('@template_style/social/friends.html.twig');

+ 10 - 8
main/social/group_add.php

@@ -15,7 +15,10 @@ if (api_get_setting('social.allow_social_tool') != 'true') {
     api_not_allowed();
 }
 
-if (api_get_setting('allow_students_to_create_groups_in_social') == 'false' && !api_is_allowed_to_edit()) {
+if (api_get_setting(
+        'social.allow_students_to_create_groups_in_social'
+    ) == 'false' && !api_is_allowed_to_edit()
+) {
     api_not_allowed();
 }
 
@@ -46,11 +49,10 @@ $social_avatar_block = SocialManager::show_social_avatar_block('group_add');
 $social_menu_block = SocialManager::show_social_menu('group_add');
 $social_right_content = $form->returnForm();
 
-$tpl = new Template(null);
-SocialManager::setSocialUserBlock($tpl, $user_id, null, null);
-$tpl->setHelp('Groups');
-$tpl->assign('social_menu_block', $social_menu_block);
-$tpl->assign('social_right_content', $social_right_content);
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
+SocialManager::setSocialUserBlock($tpl, api_get_user_id(), null, null);
+//$tpl->setHelp('Groups');
+$tpl->addGlobal('social_menu_block', $social_menu_block);
+$tpl->addGlobal('social_right_content', $social_right_content);
 
-$social_layout = $tpl->get_template('social/add_groups.tpl');
-$tpl->display($social_layout);
+echo $tpl->render('@template_style/social/add_groups.html.twig');

+ 9 - 10
main/social/group_edit.php

@@ -59,13 +59,12 @@ if ($form->validate()) {
 $social_left_content = SocialManager::show_social_menu('group_edit', $group_id);
 $social_right_content = $form->returnForm();
 
-$tpl = new Template(get_lang('Edit'));
-
-SocialManager::setSocialUserBlock($tpl, $user_id, 'groups', $group_id);
-
-$tpl->setHelp('Groups');
-$tpl->assign('social_menu_block', $social_left_content);
-$tpl->assign('social_right_content', $social_right_content);
-
-$social_layout = $tpl->get_template('social/add_groups.tpl');
-$tpl->display($social_layout);
+//$tpl = new Template(get_lang('Edit'));
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
+//$tpl->setHelp('Groups');
+SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'groups', $group_id);
+//$tpl->setHelp('Groups');
+$tpl->addGlobal('social_menu_block', $social_left_content);
+$tpl->addGlobal('social_right_content', $social_right_content);
+
+echo $tpl->render('@template_style/social/add_groups.html.twig');

+ 7 - 7
main/social/group_invitation.php

@@ -196,11 +196,11 @@ if (is_array($members) && count($members)>0) {
     );
 }
 
-$tpl = new Template(null);
-SocialManager::setSocialUserBlock($tpl, $user_id, 'groups', $group_id);
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
+
+SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'groups', $group_id);
 $social_menu_block = SocialManager::show_social_menu('member_list', $group_id);
-$tpl->assign('social_menu_block', $social_menu_block);
-$tpl->setHelp('Groups');
-$tpl->assign('social_right_content', $social_right_content);
-$social_layout = $tpl->get_template('social/add_groups.tpl');
-$tpl->display($social_layout);
+$tpl->addGlobal('social_menu_block', $social_menu_block);
+//$tpl->setHelp('Groups');
+$tpl->addGlobal('social_right_content', $social_right_content);
+echo $tpl->render('@template_style/social/add_groups.html.twig');

+ 18 - 9
main/social/group_members.php

@@ -171,10 +171,14 @@ foreach ($users as $user) {
             break;
     }
 
-    $userPicture = UserManager::getUserPicture($user['user_id']);
-    $user['image'] = '<img src="' . $userPicture . '"  width="50px" height="50px"  />';
+    if (isset($user['user_id'])) {
+        $userPicture = UserManager::getUserPicture($user['user_id']);
+        $user['image'] = '<img src="'.$userPicture.'"  width="50px" height="50px"  />';
+    }
     $new_member_list[] = $user;
 }
+
+
 if (count($new_member_list) > 0) {
     $social_right_content .= Display::return_sortable_grid(
         'list_members',
@@ -187,11 +191,16 @@ if (count($new_member_list) > 0) {
     );
 }
 
-$tpl = new Template(null);
-$tpl->setHelp('Groups');
-$tpl->assign('social_avatar_block', $social_avatar_block);
-$tpl->assign('social_menu_block', $social_menu_block);
-$tpl->assign('social_right_content', $social_right_content);
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
+//$tpl->setHelp('Groups');
+$tpl->addGlobal('social_avatar_block', $social_avatar_block);
+$tpl->addGlobal('social_menu_block', $social_menu_block);
+$tpl->addGlobal('social_right_content', $social_right_content);
+$tpl->addGlobal('social_search_block', '');
+$tpl->addGlobal('social_skill_block', '');
+$tpl->addGlobal('social_group_block', '');
+$tpl->addGlobal('social_auto_extend_link', '');
+$tpl->addGlobal('social_friend_block', '');
+
+echo $tpl->render('@template_style/social/home.html.twig');
 
-$social_layout = $tpl->get_template('social/home.tpl');
-$tpl->display($social_layout);

+ 8 - 7
main/social/group_topics.php

@@ -212,12 +212,13 @@ $social_right_content .= MessageManager::display_message_for_group(
 
 $social_menu_block = SocialManager::show_social_menu('member_list', $group_id);
 
-$tpl = new Template(null);
-$tpl->setHelp('Groups');
+//$tpl = new Template(null);
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
+//$tpl->setHelp('Groups');
 // Block Social Avatar
 SocialManager::setSocialUserBlock($tpl, $user_id, 'groups', $group_id);
-$tpl->assign('social_menu_block', $social_menu_block);
-$tpl->assign('social_right_content', $social_right_content);
-$tpl->assign('content', $content);
-$social_layout = $tpl->get_template('social/home.tpl');
-$tpl->display($social_layout);
+$tpl->addGlobal('social_menu_block', $social_menu_block);
+$tpl->addGlobal('social_right_content', $social_right_content);
+$tpl->addGlobal('content', $content);
+echo $tpl->render('@template_style/social/home.html.twig');
+

+ 12 - 10
main/social/group_view.php

@@ -286,17 +286,19 @@ if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) {
     }
 }
 
-$tpl = new Template(null);
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
 
 // Block Social Avatar
-SocialManager::setSocialUserBlock($tpl, $user_id, 'groups', $group_id);
+SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'groups', $group_id);
 //Block Social Menu
 $social_menu_block = SocialManager::show_social_menu('groups', $group_id);
-$tpl->setHelp('Groups');
-$tpl->assign('create_link', $create_thread_link);
-$tpl->assign('is_group_member', $is_group_member);
-$tpl->assign('group_info', $group_info);
-$tpl->assign('social_menu_block', $social_menu_block);
-$tpl->assign('social_right_content', $social_right_content);
-$social_layout = $tpl->get_template('social/group_view.tpl');
-$tpl->display($social_layout);
+//$tpl->setHelp('Groups');
+$tpl->addGlobal('create_link', $create_thread_link);
+$tpl->addGlobal('social_auto_extend_link', '');
+
+$tpl->addGlobal('is_group_member', $is_group_member);
+$tpl->addGlobal('group_info', $group_info);
+$tpl->addGlobal('social_menu_block', $social_menu_block);
+$tpl->addGlobal('social_right_content', $social_right_content);
+echo $tpl->render('@template_style/social/group_view.html.twig');
+

+ 12 - 8
main/social/group_waiting_list.php

@@ -110,15 +110,19 @@ if (empty($new_member_list) > 0) {
     $social_right_content = Display :: return_message(get_lang('ThereAreNotUsersInTheWaitingList'));
 }
 
-$tpl = new Template(null);
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
+
+SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'groups', $group_id);
 
-SocialManager::setSocialUserBlock($tpl, $user_id, 'groups', $group_id);
 $social_menu_block = SocialManager::show_social_menu('member_list', $group_id);
-$tpl->assign('social_menu_block', $social_menu_block);
-$tpl->setHelp('Groups');
-$tpl->assign('members', $new_member_list);
-$tpl->assign('social_right_content', $social_right_content);
+$tpl->addGlobal('social_menu_block', $social_menu_block);
+//$tpl->setHelp('Groups');
+$tpl->addGlobal('members', $new_member_list);
+$tpl->addGlobal('social_right_content', $social_right_content);
+$tpl->addGlobal('social_auto_extend_link', '');
+$tpl->addGlobal('social_right_information', '');
+
+
+echo $tpl->render('@template_style/social/group_waiting_list.html.twig');
 
-$social_layout = $tpl->get_template('social/group_waiting_list.tpl');
-$tpl->display($social_layout);
 

+ 18 - 15
main/social/groups.php

@@ -11,6 +11,7 @@ $language_file = array('userInfo');
 //require_once '../inc/global.inc.php';
 
 api_block_anonymous_users();
+$join_url = '';
 
 if (api_get_setting('social.allow_social_tool') != 'true') {
     api_not_allowed();
@@ -153,7 +154,6 @@ foreach ($results as $result) {
     $html .= '</div>';
     $html .= '</div>';
 
-
     $grid_item_2 = $html;
 
     $grid_newest_groups[]= array($grid_item_2);
@@ -223,7 +223,10 @@ if (isset($_GET['view']) && in_array($_GET['view'], $allowed_views)) {
             if (count($grid_my_groups) > 0) {
                 $my_group_content = Display::return_sortable_grid('mygroups', array(), $grid_my_groups, array('hide_navigation'=>true, 'per_page' => 2), $query_vars, false, array(true, true, true,false));
             }
-            if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
+            if (api_get_setting(
+                    'social.allow_students_to_create_groups_in_social'
+                ) == 'true'
+            ) {
                 $create_group_item =  '<a class="btn btn-default" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.
                     get_lang('CreateASocialGroup').'</a>';
             } else {
@@ -251,7 +254,10 @@ if (isset($_GET['view']) && in_array($_GET['view'], $allowed_views)) {
     } else {
         $my_group_content = '<span class="muted">'.get_lang('GroupNone').'</span>';
     }
-    if (api_get_setting('allow_students_to_create_groups_in_social') == 'true') {
+    if (api_get_setting(
+            'social.allow_students_to_create_groups_in_social'
+        ) == 'true'
+    ) {
         $create_group_item =  '<a class="btn btn-default" href="'.api_get_path(WEB_PATH).'main/social/group_add.php">'.
             get_lang('CreateASocialGroup').'</a>';
     } else {
@@ -277,26 +283,23 @@ if (!empty($create_group_item)) {
 $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');
 
-$show_message = null;
 if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'show_message' && isset($_REQUEST['msg']) && $_REQUEST['msg'] == 'topic_deleted') {
-    $show_message = Display::return_message(get_lang('Deleted'), 'success');
+    Display::return_message(get_lang('Deleted'), 'success');
 }
 
-$tpl = new Template(null);
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
 
 // Block Social Avatar
-SocialManager::setSocialUserBlock($tpl, $user_id, $show_menu);
+SocialManager::setSocialUserBlock($tpl, api_get_user_id(), $show_menu);
 $show_menu = 'browse_groups';
 if (isset($_GET['view']) && $_GET['view'] == 'mygroups') {
     $show_menu = $_GET['view'];
 }
 
 $social_menu_block = SocialManager::show_social_menu($show_menu);
-$templateName = 'social/groups.tpl';
-
-$tpl->setHelp('Groups');
-$tpl->assign('message', $show_message);
-$tpl->assign('social_menu_block', $social_menu_block);
-$tpl->assign('social_right_content', $social_right_content);
-$social_layout = $tpl->get_template($templateName);
-$tpl->display($social_layout);
+
+//$tpl->setHelp('Groups');
+$tpl->addGlobal('social_menu_block', $social_menu_block);
+$tpl->addGlobal('social_right_content', $social_right_content);
+echo $tpl->render('@template_style/social/groups.html.twig');
+

+ 2 - 0
main/social/home.php

@@ -218,6 +218,8 @@ $tpl->addGlobal('sessionList', $social_session_block);
 $tpl->addGlobal('social_search_block', $social_search_block);
 $tpl->addGlobal('social_skill_block', SocialManager::getSkillBlock($user_id));
 $tpl->addGlobal('social_group_block', $social_group_block);
+$tpl->addGlobal('social_right_content', '');
+$tpl->addGlobal('social_auto_extend_link', '');
 
 echo $tpl->render('@template_style/social/home.html.twig');
 

+ 8 - 8
main/social/invitations.php

@@ -182,11 +182,11 @@ if (count($pending_invitations) > 0) {
     $socialInvitationsBlock .= Display::panel($waitingInvitation, get_lang('GroupsWaitingApproval'));
 }
 
-$tpl = new Template(null);
-SocialManager::setSocialUserBlock($tpl, $user_id, 'invitations');
-$tpl->assign('social_menu_block', $social_menu_block);
-$tpl->assign('social_invitations_block',$socialInvitationsBlock);
-$tpl->assign('message', $show_message);
-$tpl->assign('content', $content);
-$social_layout = $tpl->get_template('social/invitations.tpl');
-$tpl->display($social_layout);
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
+SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'invitations');
+$tpl->addGlobal('social_menu_block', $social_menu_block);
+$tpl->addGlobal('social_invitations_block', $socialInvitationsBlock);
+$tpl->addGlobal('message', $show_message);
+$tpl->addGlobal('content', $content);
+echo $tpl->render('@template_style/social/invitations.html.twig');
+

+ 12 - 5
main/social/message_for_group_form.inc.php

@@ -8,6 +8,7 @@
 
 $cidReset = true;
 //require_once '../inc/global.inc.php';
+\Chamilo\CoreBundle\Framework\Container::$legacyTemplate = 'layout_one_col_no_content.html.twig';
 
 api_block_anonymous_users();
 if (api_get_setting('social.allow_social_tool') != 'true') {
@@ -64,15 +65,19 @@ $anchor_topic  = isset($_GET['anchor_topic']) ? Security::remove_XSS($_GET['anch
 
 $url = api_get_path(WEB_CODE_PATH).'social/group_topics.php?id='.$group_id.'&anchor_topic='.$anchor_topic.'&topics_page_nr='.$page_topic.$param_item_page;
 
-$form = new FormValidator('form', 'post', $url, null, array('enctype' => 'multipart/form-data'));
+$form = new FormValidator(
+    'form',
+    'post',
+    $url,
+    null,
+    array('enctype' => 'multipart/form-data')
+);
 $form->addElement('hidden', 'action', $allowed_action);
 $form->addElement('hidden', 'group_id', $group_id);
 $form->addElement('hidden', 'parent_id', $message_id);
 $form->addElement('hidden', 'message_id', $message_id);
 $form->addElement('hidden', 'token', $tok);
 
-$tpl = new Template(get_lang('Groups'));
-
 if (api_get_setting('message.allow_message_tool') == 'true') {
     // Normal message
     $user_info = api_get_user_info($userfriend_id);
@@ -101,11 +106,13 @@ if (api_get_setting('message.allow_message_tool') == 'true') {
         'file',
         'attach_1',
         sprintf(get_lang('MaximunFileSizeX'),
-        format_file_size(api_get_setting('message_max_upload_filesize')))
+            format_file_size(
+                api_get_setting('message.message_max_upload_filesize')
+            )
+        )
     );
     $form->addButtonSend(get_lang('SendMessage'));
 
     $form->setDefaults(['content' => $message, 'title' => $subject]);
     $form->display();
 }
-$tpl->display_blank_template();

+ 9 - 8
main/social/myfiles.php

@@ -98,14 +98,15 @@ if (isset($_GET['cidReq'])) {
             ) . ')'
         ) . '</a>';
 }
-$tpl = new Template();
-SocialManager::setSocialUserBlock($tpl, $user_id, 'myfiles');
+
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
+SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'myfiles');
 $editor = new \Chamilo\CoreBundle\Component\Editor\Editor();
-$editor = $tpl->fetch('default/'.$editor->getEditorStandAloneTemplate());
+$editor = $tpl->render('default/'.$editor->getEditorStandAloneTemplate());
+
+$tpl->addGlobal('social_right_content', $editor);
+$tpl->addGlobal('social_menu_block', $social_menu_block);
+$tpl->addGlobal('actions', $actions);
 
-$tpl->assign('social_right_content', $editor);
-$tpl->assign('social_menu_block', $social_menu_block);
-$tpl->assign('actions', $actions);
+echo $tpl->render('@template_style/social/myfiles.html.twig');
 
-$social_layout = $tpl->get_template('social/myfiles.tpl');
-$tpl->display($social_layout);

+ 19 - 14
main/social/search.php

@@ -18,6 +18,7 @@ if (api_get_setting('social.allow_social_tool') != 'true') {
 
 $this_section = SECTION_SOCIAL;
 $tool_name = get_lang('Search');
+$user_id = api_get_user_id();
 $interbreadcrumb[] = array('url' => 'profile.php', 'name' => get_lang('SocialNetwork'));
 
 $query = isset($_GET['q']) ? Security::remove_XSS($_GET['q']): null;
@@ -221,22 +222,26 @@ if ($query != '' || ($query_vars['search_type']=='1' && count($query_vars)>2) )
         $totalGroups
     );
 
-    $block_search .= Display:: panelCollapse(get_lang('Groups'), $block_groups, 'search-groups', null, 'groups-acorderon', 'groups-collapse');
+    $block_search .= Display:: panelCollapse(
+        get_lang('Groups'),
+        $block_groups,
+        'search-groups',
+        null,
+        'groups-acorderon',
+        'groups-collapse'
+    );
 }
 
-$tpl = new Template($tool_name);
+$tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
 // Block Social Avatar
-SocialManager::setSocialUserBlock($tpl, $user_id, 'search');
-$tpl->assign('social_menu_block', $social_menu_block);
-$tpl->assign('social_search', $block_search);
-$tpl->assign('search_form', $searchForm);
-
-$formModalTpl =  new Template();
-//$formModalTpl->assign('message_form', MessageManager::generate_message_form('send_message'));
-$formModalTpl->assign('invitation_form', MessageManager::generate_invitation_form('send_invitation'));
-$formModals = $formModalTpl->fetch('default/social/form_modals.tpl');
+SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'search');
+$tpl->addGlobal('social_menu_block', $social_menu_block);
+$tpl->addGlobal('social_search', $block_search);
+$tpl->addGlobal('search_form', $searchForm);
+$tpl->addGlobal(
+    'invitation_form',
+    MessageManager::generate_invitation_form('send_invitation')
+);
 
-$tpl->assign('form_modals', $formModals);
+echo $tpl->render('@template_style/social/search.html.twig');
 
-$social_layout = $tpl->get_template('social/search.tpl');
-$tpl->display($social_layout);

+ 1 - 1
plugin/ticket/src/new_ticket.php

@@ -405,7 +405,7 @@ function show_form_send_ticket()
     $form->addElement('html', '<span id="link-more-attach" >');
     $form->addElement('html', '<span class="label label-info" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</span>');
     $form->addElement('html', '</span>');
-    $form->addElement('html', '(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')');
+    $form->addElement('html', '(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message.message_max_upload_filesize'))) . ')');
 
     $form->addElement('html', '<br/>');
     $form->addElement(

+ 9 - 1
plugin/ticket/src/ticket_details.php

@@ -448,7 +448,15 @@ function show_form_send_message()
     $form->addElement('html', '<span id="link-more-attach" >');
     $form->addElement('html', '<span class="label label-info" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</span>');
     $form->addElement('html', '</span>');
-    $form->addElement('html', '(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')');
+    $form->addElement(
+        'html',
+        '('.sprintf(
+            get_lang('MaximunFileSizeX'),
+            format_file_size(
+                api_get_setting('message.message_max_upload_filesize')
+            )
+        ).')'
+    );
 
     $form->addElement('html', '<br/>');
     $form->addElement(

+ 1 - 0
src/Chamilo/CoreBundle/Framework/Container.php

@@ -46,6 +46,7 @@ class Container
     public static $htmlEditor;
     public static $twig;
     public static $roles;
+    /** @var  string  */
     public static $legacyTemplate;
 
     /**

+ 2 - 2
src/Chamilo/CoreBundle/Resources/views/default/social/add_groups.tpl → src/Chamilo/CoreBundle/Resources/views/default/social/add_groups.html.twig

@@ -1,6 +1,5 @@
-{% extends template ~ "/layout/layout_1_col.tpl" %}
-
 {% block content %}
+    {% autoescape false %}
     <div class="row">
         <div class="col-md-3">
             <div class="social-network-menu">
@@ -12,4 +11,5 @@
             {{ social_right_content }}
         </div>
     </div>
+    {% endautoescape %}
 {% endblock %}

+ 5 - 2
src/Chamilo/CoreBundle/Resources/views/default/social/avatar_block.tpl → src/Chamilo/CoreBundle/Resources/views/default/social/avatar_block.html.twig

@@ -1,17 +1,18 @@
+{% autoescape false %}
 <div class="social-profile text-center">
     {% if show_group %}
         <img src="{{ user_group_image.file }}"
              class="img-profile img-responsive img-circle">
         <div class="caption">
             <h4 class="group-title">
-                <a href="{{ _p.web_main ~ 'social/group_view.php?id=' ~ group_id }}">{{ user_group.name }}</a>
+                <a href="{{ url('web.main') ~ 'social/group_view.php?id=' ~ group_id }}">{{ user_group.name }}</a>
             </h4>
 
             <p class="group-description">{{ user_group.description }}</p>
             {% if user_is_group_admin %}
                 <div id="edit_image">
                     <a class="btn btn-default"
-                       href="{{ _p.web_main ~ 'social/group_edit.php?id=' ~ group_id }}">
+                       href="{{ url('web.main') ~ 'social/group_edit.php?id=' ~ group_id }}">
                         {{ 'EditGroup'|trans }}
                     </a>
                 </div>
@@ -24,3 +25,5 @@
         </a>
     {% endif %}
 </div>
+
+{% endautoescape %}

+ 2 - 2
src/Chamilo/CoreBundle/Resources/views/default/social/groups.tpl → src/Chamilo/CoreBundle/Resources/views/default/social/edit_profile.html.twig

@@ -1,6 +1,5 @@
-{% extends template ~ "/layout/layout_1_col.tpl" %}
-
 {% block content %}
+    {% autoescape false %}
     <div class="row">
         <div class="col-md-3">
             <div class="social-network-menu">
@@ -12,4 +11,5 @@
             {{ social_right_content }}
         </div>
     </div>
+    {% endautoescape %}
 {% endblock %}

+ 1 - 1
src/Chamilo/CoreBundle/Resources/views/default/social/form_modals.tpl → src/Chamilo/CoreBundle/Resources/views/default/social/form_modals.html.twig

@@ -39,7 +39,7 @@
             e.preventDefault();
 
             var $frmSendInvitation = $sendInvitationModal.find('.modal-body form'),
-                    url = '{{ _p.web_ajax }}message.ajax.php?a=send_invitation&user_id=' + sendToUser;
+                    url = '{{ url('web.ajax') }}message.ajax.php?a=send_invitation&user_id=' + sendToUser;
 
             $.get(url, $frmSendInvitation.serialize(), function () {
                 $frmSendInvitation[0].reset();

+ 2 - 2
src/Chamilo/CoreBundle/Resources/views/default/social/friends.tpl → src/Chamilo/CoreBundle/Resources/views/default/social/friends.html.twig

@@ -1,6 +1,5 @@
-{% extends template ~ "/layout/layout_1_col.tpl" %}
-
 {% block content %}
+    {% autoescape false %}
     <div class="row">
         <div class="col-md-3">
             <div class="social-network-menu">
@@ -26,4 +25,5 @@
             </div>
         </div>
     </div>
+    {% endautoescape %}
 {% endblock %}

+ 2 - 0
src/Chamilo/CoreBundle/Resources/views/default/social/group_block.html.twig

@@ -1 +1,3 @@
+{% autoescape false %}
 {{ social_avatar_block }}
+{% endautoescape %}

+ 2 - 3
src/Chamilo/CoreBundle/Resources/views/default/social/group_view.tpl → src/Chamilo/CoreBundle/Resources/views/default/social/group_view.html.twig

@@ -1,6 +1,5 @@
-{% extends template ~ "/layout/layout_1_col.tpl" %}
-
 {% block content %}
+    {% autoescape false %}
     <div class="row" xmlns="http://www.w3.org/1999/html">
         <div class="col-md-3">
             <div class="sm-groups">
@@ -27,6 +26,6 @@
             <div id="display_response_id" class="col-md-5"></div>
             {{ social_auto_extend_link }}
         </div>
-
     </div>
+    {% endautoescape %}
 {% endblock %}

+ 2 - 2
src/Chamilo/CoreBundle/Resources/views/default/social/group_waiting_list.tpl → src/Chamilo/CoreBundle/Resources/views/default/social/group_waiting_list.html.twig

@@ -1,6 +1,5 @@
-{% extends template ~ "/layout/layout_1_col.tpl" %}
-
 {% block content %}
+    {% autoescape false %}
     <div class="row">
         <div class="col-md-3">
             <div class="social-network-menu">
@@ -42,4 +41,5 @@
             </div>
         </div>
     </div>
+    {% endautoescape %}
 {% endblock %}

+ 2 - 2
src/Chamilo/CoreBundle/Resources/views/default/social/edit_profile.tpl → src/Chamilo/CoreBundle/Resources/views/default/social/groups.html.twig

@@ -1,6 +1,5 @@
-{% extends template ~ "/layout/layout_1_col.tpl" %}
-
 {% block content %}
+    {% autoescape false %}
     <div class="row">
         <div class="col-md-3">
             <div class="social-network-menu">
@@ -12,4 +11,5 @@
             {{ social_right_content }}
         </div>
     </div>
+    {% endautoescape %}
 {% endblock %}

+ 3 - 3
src/Chamilo/CoreBundle/Resources/views/default/social/home.html.twig

@@ -1,6 +1,5 @@
-{% extends template ~ "/layout/layout_1_col.tpl" %}
-
 {% block content %}
+    {% autoescape false %}
     <div class="row">
         <div class="col-md-3">
             {{ social_avatar_block }}
@@ -45,7 +44,7 @@
             </div>
 
             <!-- Block session list -->
-            {% if sessionList != null %}
+            {% if sessionList is defined %}
                 <div class="panel-group" id="session-block" role="tablist"
                      aria-multiselectable="true">
                     <div class="panel panel-default">
@@ -81,4 +80,5 @@
 
         </div>
     </div>
+    {% endautoescape %}
 {% endblock %}

+ 2 - 2
src/Chamilo/CoreBundle/Resources/views/default/social/inbox.tpl → src/Chamilo/CoreBundle/Resources/views/default/social/inbox.html.twig

@@ -1,6 +1,5 @@
-{% extends template ~ "/layout/layout_1_col.tpl" %}
-
 {% block content %}
+    {% autoescape false %}
     <div class="row">
         <div class="col-md-3">
             <div class="social-network-menu">
@@ -12,4 +11,5 @@
             {{ social_right_content }}
         </div>
     </div>
+    {% endautoescape %}
 {% endblock %}

+ 2 - 2
src/Chamilo/CoreBundle/Resources/views/default/social/invitations.tpl → src/Chamilo/CoreBundle/Resources/views/default/social/invitations.html.twig

@@ -1,6 +1,5 @@
-{% extends template ~ "/layout/layout_1_col.tpl" %}
-
 {% block content %}
+    {% autoescape false %}
     <div class="row">
         <div class="col-md-3">
             <div class="social-network-menu">
@@ -12,4 +11,5 @@
             {{ social_invitations_block }}
         </div>
     </div>
+    {% endautoescape %}
 {% endblock %}

+ 2 - 2
src/Chamilo/CoreBundle/Resources/views/default/social/myfiles.tpl → src/Chamilo/CoreBundle/Resources/views/default/social/myfiles.html.twig

@@ -1,6 +1,5 @@
-{% extends template ~ "/layout/layout_1_col.tpl" %}
-
 {% block content %}
+    {% autoescape false %}
     <div class="row">
         <div class="col-md-3">
             <div class="social-network-menu">
@@ -21,4 +20,5 @@
             {{ social_auto_extend_link }}
         </div>
     </div>
+    {% endautoescape %}
 {% endblock %}

+ 2 - 2
src/Chamilo/CoreBundle/Resources/views/default/social/profile.tpl → src/Chamilo/CoreBundle/Resources/views/default/social/profile.html.twig

@@ -1,6 +1,5 @@
-{% extends template ~ "/layout/layout_1_col.tpl" %}
-
 {% block content %}
+    {% autoescape false %}
     <div class="row">
         <div class="col-md-3">
             {{ social_avatar_block }}
@@ -118,4 +117,5 @@
     {% if form_modals is defined %}
         {{ form_modals }}
     {% endif %}
+    {% endautoescape %}
 {% endblock %}

+ 3 - 5
src/Chamilo/CoreBundle/Resources/views/default/social/search.tpl → src/Chamilo/CoreBundle/Resources/views/default/social/search.html.twig

@@ -1,6 +1,5 @@
-{% extends template ~ "/layout/layout_1_col.tpl" %}
-
 {% block content %}
+    {% autoescape false %}
     <div class="row">
         <div class="col-md-3">
             <div class="social-network-menu">
@@ -20,7 +19,6 @@
         </div>
     </div>
 
-    {% if form_modals is defined %}
-        {{ form_modals }}
-    {% endif %}
+        {% include '@template_style/social/form_modals.html.twig' %}
+    {% endautoescape %}
 {% endblock %}

+ 0 - 0
src/Chamilo/CoreBundle/Resources/views/default/social/skills_block.tpl → src/Chamilo/CoreBundle/Resources/views/default/social/skills_block.html.twig


+ 3 - 3
src/Chamilo/CoreBundle/Resources/views/default/social/user_block.html.twig

@@ -1,3 +1,4 @@
+{% autoescape false %}
 <div class="sidebar-avatar">
     <div class="panel-group" id="sn-avatar" role="tablist"
          aria-multiselectable="true">
@@ -23,7 +24,7 @@
                         </li>
                         {% if vcard_user_link %}
                             <li class="item">
-                                <a href="{{ _p.web }}main/messages/new_message.php">
+                                <a href="{{ url('web.main') }}messages/new_message.php">
                                     <img src="{{ "instant_message.png" | icon }}"
                                          alt="{{ "Email" | trans }}">
                                     {{ user.email }}
@@ -75,5 +76,4 @@
         </div>
     </div>
 </div>
-
-
+{% endautoescape %}

+ 2 - 2
src/Chamilo/CoreBundle/Resources/views/default/social/whoisonline.tpl → src/Chamilo/CoreBundle/Resources/views/default/social/whoisonline.html.twig

@@ -1,6 +1,5 @@
-{% extends template ~ "/layout/layout_1_col.tpl" %}
-
 {% block content %}
+    {% autoescape false %}
     <div class="row">
         <div class="col-md-12">
             <div class="search-user">
@@ -18,4 +17,5 @@
             </div>
         </div>
     </div>
+    {% endautoescape %}
 {% endblock %}

+ 1 - 0
src/Chamilo/CoreBundle/Resources/views/layout_one_col.html.twig

@@ -17,3 +17,4 @@
     </div>
 {% endblock %}
 
+

+ 1 - 0
src/Chamilo/ThemeBundle/Resources/views/Layout/base-layout.html.twig

@@ -208,6 +208,7 @@
 
     {% block page_content %}
     {% endblock %}
+
 {% endblock %}
 
 {#<div class="col-md-3 menu-column">#}