skala
Julio Montoya 16 years ago
commit fce13088b0
  1. 8
      main/css/blue_lagoon/default.css
  2. BIN
      main/img/moderator_star.png
  3. 98
      main/inc/lib/group_portal_manager.lib.php
  4. 68
      main/inc/lib/message.lib.php
  5. 23
      main/inc/lib/social.lib.php
  6. 1
      main/inc/lib/usermanager.lib.php
  7. 3
      main/messages/inbox.php
  8. 17
      main/messages/index.php
  9. 3
      main/messages/message.class.php
  10. 24
      main/messages/messages.css
  11. 3
      main/messages/new_message.php
  12. 25
      main/messages/send_message_to_userfriend.inc.php
  13. 63
      main/messages/view_message.php
  14. 4
      main/social/contacts.inc.php
  15. 6
      main/social/data_personal.inc.php
  16. 10
      main/social/friends.php
  17. 8
      main/social/group_add.php
  18. 7
      main/social/group_contact.inc.php
  19. 15
      main/social/group_edit.php
  20. 222
      main/social/group_invitation.php
  21. 52
      main/social/group_members.php
  22. 28
      main/social/groups.php
  23. 9
      main/social/home.php
  24. 6
      main/social/index.php
  25. 55
      main/social/invitations.php
  26. 68
      main/social/profile.php
  27. 6
      main/social/qualify_contact.inc.php
  28. 6
      main/social/register_friend.php
  29. 8
      main/social/search.php
  30. 6
      main/social/select_friend_response.php
  31. 7
      main/social/select_options.php
  32. 53
      main/social/show_search_image.inc.php
  33. 32
      tests/main/inc/lib/social.lib.test.php
  34. 19
      user_portal.php
  35. 21
      whoisonline.php

@ -2665,3 +2665,11 @@ input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
#maincontent .courseslist li { #maincontent .courseslist li {
margin-bottom:8px; margin-bottom:8px;
} }
a.read {
font-weight:normal;
}
a.unread {
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

@ -15,9 +15,11 @@ define('GROUP_PERMISSION_CLOSED', '2');
// Group user permissions // Group user permissions
define('GROUP_USER_PERMISSION_ADMIN' ,'1'); // the admin of a group define('GROUP_USER_PERMISSION_ADMIN' ,'1'); // the admin of a group
define('GROUP_USER_PERMISSION_READER' ,'2'); // a normal user define('GROUP_USER_PERMISSION_READER' ,'2'); // a normal user
define('GROUP_USER_PERMISSION_PENDING_INVITATION' ,'3'); // user pending invitation to a group define('GROUP_USER_PERMISSION_PENDING_INVITATION' ,'3'); // When an admin invite a user
define('GROUP_USER_PERMISSION_MODERATOR' ,'4'); // a moderator define('GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER' ,'4'); // When a user whats to join to a group
define('GROUP_USER_PERMISSION_ANONYMOUS' ,'5'); // an anonymous user define('GROUP_USER_PERMISSION_MODERATOR' ,'5'); // a moderator
define('GROUP_USER_PERMISSION_ANONYMOUS' ,'6'); // an anonymous user
class GroupPortalManager class GroupPortalManager
{ {
@ -32,7 +34,7 @@ class GroupPortalManager
* @param int the user_id of the owner * @param int the user_id of the owner
* @return boolean if success * @return boolean if success
*/ */
function add($name, $description, $url, $visibility, $picture='') public static function add($name, $description, $url, $visibility, $picture='')
{ {
$tms = time(); $tms = time();
$table = Database :: get_main_table(TABLE_MAIN_GROUP); $table = Database :: get_main_table(TABLE_MAIN_GROUP);
@ -59,7 +61,7 @@ class GroupPortalManager
* @param int the user_id of the owner * @param int the user_id of the owner
* @return boolean if success * @return boolean if success
*/ */
function update($group_id, $name, $description, $url, $visibility, $picture_uri) public static function update($group_id, $name, $description, $url, $visibility, $picture_uri)
{ {
$group_id = intval($group_id); $group_id = intval($group_id);
$table = Database::get_main_table(TABLE_MAIN_GROUP); $table = Database::get_main_table(TABLE_MAIN_GROUP);
@ -83,7 +85,7 @@ class GroupPortalManager
* @param int id * @param int id
* @return boolean true if success * @return boolean true if success
* */ * */
function delete($id) public static function delete($id)
{ {
$id = intval($id); $id = intval($id);
$table = Database :: get_main_table(TABLE_MAIN_GROUP); $table = Database :: get_main_table(TABLE_MAIN_GROUP);
@ -99,7 +101,7 @@ class GroupPortalManager
/** /**
* *
* */ * */
function url_exist($url) public static function url_exist($url)
{ {
$table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."' "; $sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."' ";
@ -111,7 +113,7 @@ class GroupPortalManager
/** /**
* *
* */ * */
function url_id_exist($url) public static function url_id_exist($url)
{ {
$table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT id FROM $table_access_url WHERE id = '".Database::escape_string($url)."' "; $sql = "SELECT id FROM $table_access_url WHERE id = '".Database::escape_string($url)."' ";
@ -125,7 +127,7 @@ class GroupPortalManager
* @author Julio Montoya * @author Julio Montoya
* @return int count of urls * @return int count of urls
* */ * */
function url_count() public static function url_count()
{ {
$table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT count(id) as count_result FROM $table_access_url"; $sql = "SELECT count(id) as count_result FROM $table_access_url";
@ -140,7 +142,7 @@ class GroupPortalManager
* @author Julio Montoya * @author Julio Montoya
* @return array * @return array
* */ * */
function get_url_data() public static function get_url_data()
{ {
$table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT id, url, description, active FROM $table_access_url"; $sql = "SELECT id, url, description, active FROM $table_access_url";
@ -160,7 +162,7 @@ class GroupPortalManager
* @param int number of items * @param int number of items
* @return array * @return array
* */ * */
function get_all_group_data($visibility = GROUP_PERMISSION_OPEN, $from=0, $number_of_items=10) public static function get_all_group_data($visibility = GROUP_PERMISSION_OPEN, $from=0, $number_of_items=10)
{ {
$table = Database :: get_main_table(TABLE_MAIN_GROUP); $table = Database :: get_main_table(TABLE_MAIN_GROUP);
$visibility = intval($visibility); $visibility = intval($visibility);
@ -179,7 +181,7 @@ class GroupPortalManager
* *
* *
*/ */
function get_group_data($group_id) public static function get_group_data($group_id)
{ {
$table = Database :: get_main_table(TABLE_MAIN_GROUP); $table = Database :: get_main_table(TABLE_MAIN_GROUP);
$group_id = intval($group_id); $group_id = intval($group_id);
@ -199,7 +201,7 @@ class GroupPortalManager
* @param bool show group links or not * @param bool show group links or not
* *
*/ */
function get_group_tags($group_id, $show_tag_links = true) public static function get_group_tags($group_id, $show_tag_links = true)
{ {
$tag = Database :: get_main_table(TABLE_MAIN_TAG); $tag = Database :: get_main_table(TABLE_MAIN_TAG);
$table_group_rel_tag = Database :: get_main_table(TABLE_MAIN_GROUP_REL_TAG); $table_group_rel_tag = Database :: get_main_table(TABLE_MAIN_GROUP_REL_TAG);
@ -237,7 +239,7 @@ class GroupPortalManager
* @author Julio Montoya * @author Julio Montoya
* @return array * @return array
* */ * */
function get_url_data_from_id($url_id) public static function get_url_data_from_id($url_id)
{ {
$table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT id, url, description, active FROM $table_access_url WHERE id = ".Database::escape_string($url_id); $sql = "SELECT id, url, description, active FROM $table_access_url WHERE id = ".Database::escape_string($url_id);
@ -246,12 +248,12 @@ class GroupPortalManager
return $row; return $row;
} }
/** Gets the inner join of users and group table /** Gets the inner join from users and group table
* @author Julio Montoya * @author Julio Montoya
* @return int access url id * @return int access url id
* @return array Database::store_result of the result * @return array Database::store_result of the result
* */ * */
function get_groups_by_user($user_id='', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false) public static function get_groups_by_user($user_id='', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false)
{ {
$where = ''; $where = '';
$table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
@ -288,7 +290,7 @@ class GroupPortalManager
* @return int access url id * @return int access url id
* @return array Database::store_result of the result * @return array Database::store_result of the result
* */ * */
function get_groups_by_popularity($num = 10, $with_image = false) public static function get_groups_by_popularity($num = 10, $with_image = false)
{ {
$where = ''; $where = '';
$table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
@ -325,7 +327,7 @@ class GroupPortalManager
* @return int access url id * @return int access url id
* @return array Database::store_result of the result * @return array Database::store_result of the result
* */ * */
function get_groups_by_age($num = 10, $with_image = false, $relation_type = GROUP_USER_PERMISSION_READER) public static function get_groups_by_age($num = 10, $with_image = false, $relation_type = GROUP_USER_PERMISSION_READER)
{ {
$where = ''; $where = '';
$table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
@ -359,8 +361,10 @@ class GroupPortalManager
return $array; return $array;
} }
/**
function get_users_by_group($group_id='', $with_image = false, $relation_type = 0, $limit = 100, $image_size = 'medium_') * Gets the members of a group
*/
public static function get_users_by_group($group_id='', $with_image = false, $relation_type = array(), $limit = 100, $image_conf = array('size'=>'medium_','height'=>80))
{ {
$where = ''; $where = '';
$table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
@ -368,11 +372,16 @@ class GroupPortalManager
$group_id = intval($group_id); $group_id = intval($group_id);
$limit = intval($limit); $limit = intval($limit);
if ($relation_type == 0) { if (count($relation_type) == 0) {
$where_relation_condition = ''; $where_relation_condition = '';
} else { } else {
$relation_type = intval($relation_type); $new_relation_type = array();
$where_relation_condition = "AND gu.relation_type = $relation_type "; foreach($relation_type as $rel) {
$rel = intval($rel);
$new_relation_type[] ="'$rel'";
}
$relation_type = implode(',', $new_relation_type);
$where_relation_condition = "AND gu.relation_type IN ($relation_type) ";
} }
$sql="SELECT picture_uri, u.user_id, u.firstname, u.lastname, relation_type FROM $tbl_user u $sql="SELECT picture_uri, u.user_id, u.firstname, u.lastname, relation_type FROM $tbl_user u
@ -383,9 +392,8 @@ class GroupPortalManager
$array = array(); $array = array();
while ($row = Database::fetch_array($result, 'ASSOC')) { while ($row = Database::fetch_array($result, 'ASSOC')) {
if ($with_image == true) { if ($with_image == true) {
$picture = UserManager::get_picture_user($row['user_id'], $row['picture_uri'],80,$image_size); $picture = UserManager::get_picture_user($row['user_id'], $row['picture_uri'],$image_conf['height'],$image_conf['size']);
$img = '<img src="'.$picture['file'].'" />'; $row['image'] = '<img src="'.$picture['file'].'" '.$picture['style'].' />';
$row['picture_uri'] = $img;
} }
$array[$row['user_id']] = $row; $array[$row['user_id']] = $row;
} }
@ -399,7 +407,7 @@ class GroupPortalManager
* @return int access url id * @return int access url id
* @return array Database::store_result of the result * @return array Database::store_result of the result
* */ * */
function get_url_rel_course_data($access_url_id='') public static function get_url_rel_course_data($access_url_id='')
{ {
$where =''; $where ='';
$table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@ -425,7 +433,7 @@ class GroupPortalManager
* @return int access url id * @return int access url id
* @return array Database::store_result of the result * @return array Database::store_result of the result
* */ * */
function get_url_rel_session_data($access_url_id='') public static function get_url_rel_session_data($access_url_id='')
{ {
$where =''; $where ='';
$table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
@ -454,7 +462,7 @@ class GroupPortalManager
* @param string lock || unlock * @param string lock || unlock
* @param int url id * @param int url id
* */ * */
function set_url_status($status, $url_id) public static function set_url_status($status, $url_id)
{ {
$url_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $url_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
if ($status=='lock') { if ($status=='lock') {
@ -477,7 +485,7 @@ class GroupPortalManager
* @return int 0 if there are not relationship otherwise return GROUP_USER_PERMISSION_ADMIN or GROUP_USER_PERMISSION_READER constants * @return int 0 if there are not relationship otherwise return GROUP_USER_PERMISSION_ADMIN or GROUP_USER_PERMISSION_READER constants
* */ * */
function get_user_group_role($user_id, $group_id) public static function get_user_group_role($user_id, $group_id)
{ {
$table_group_rel_user= Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP); $table_group_rel_user= Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
$return_value = 0; $return_value = 0;
@ -500,7 +508,7 @@ class GroupPortalManager
* @param int url id * @param int url id
* @return boolean true if success * @return boolean true if success
* */ * */
function relation_url_course_exist($course_id, $url_id) public static function relation_url_course_exist($course_id, $url_id)
{ {
$table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql= "SELECT course_code FROM $table_url_rel_course WHERE access_url_id = ".Database::escape_string($url_id)." AND course_code = '".Database::escape_string($course_id)."'"; $sql= "SELECT course_code FROM $table_url_rel_course WHERE access_url_id = ".Database::escape_string($url_id)." AND course_code = '".Database::escape_string($course_id)."'";
@ -516,7 +524,7 @@ class GroupPortalManager
* @param url_id * @param url_id
* @return boolean true if success * @return boolean true if success
* */ * */
function add_user_to_group($user_id, $group_id, $relation_type = GROUP_USER_PERMISSION_READER) public static function add_user_to_group($user_id, $group_id, $relation_type = GROUP_USER_PERMISSION_READER)
{ {
$table_url_rel_group = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP); $table_url_rel_group = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
if (!empty($user_id) && !empty($group_id)) { if (!empty($user_id) && !empty($group_id)) {
@ -537,7 +545,7 @@ class GroupPortalManager
* @param array of user_ids * @param array of user_ids
* @param array of url_ids * @param array of url_ids
* */ * */
function add_users_to_groups($user_list, $group_list, $relation_type = GROUP_USER_PERMISSION_READER) { public static function add_users_to_groups($user_list, $group_list, $relation_type = GROUP_USER_PERMISSION_READER) {
$table_url_rel_group = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP); $table_url_rel_group = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
$result_array = array(); $result_array = array();
$relation_type = intval($relation_type); $relation_type = intval($relation_type);
@ -550,6 +558,7 @@ class GroupPortalManager
$sql = "INSERT INTO $table_url_rel_group $sql = "INSERT INTO $table_url_rel_group
SET user_id = ".intval($user_id).", group_id = ".intval($group_id).", relation_type = ".intval($relation_type).""; SET user_id = ".intval($user_id).", group_id = ".intval($group_id).", relation_type = ".intval($relation_type)."";
$result = Database::query($sql, __FILE__, __LINE__); $result = Database::query($sql, __FILE__, __LINE__);
if ($result) if ($result)
$result_array[$group_id][$user_id]=1; $result_array[$group_id][$user_id]=1;
@ -564,6 +573,7 @@ class GroupPortalManager
/** /**
* Deletes a group and user relationship * Deletes a group and user relationship
* @author Julio Montoya * @author Julio Montoya
@ -571,7 +581,7 @@ class GroupPortalManager
* @param int url id * @param int url id
* @return boolean true if success * @return boolean true if success
* */ * */
function delete_users($group_id) public static function delete_users($group_id)
{ {
$table_ = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP); $table_ = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
$sql = "DELETE FROM $table_ WHERE group_id = ".intval($group_id); $sql = "DELETE FROM $table_ WHERE group_id = ".intval($group_id);
@ -586,7 +596,7 @@ class GroupPortalManager
* @param int url id * @param int url id
* @return boolean true if success * @return boolean true if success
* */ * */
function delete_url_rel_course($course_code, $url_id) public static function delete_url_rel_course($course_code, $url_id)
{ {
$table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql= "DELETE FROM $table_url_rel_course WHERE course_code = '".Database::escape_string($course_code)."' AND access_url_id=".Database::escape_string($url_id)." "; $sql= "DELETE FROM $table_url_rel_course WHERE course_code = '".Database::escape_string($course_code)."' AND access_url_id=".Database::escape_string($url_id)." ";
@ -601,7 +611,7 @@ class GroupPortalManager
* @param int url id * @param int url id
* @return boolean true if success * @return boolean true if success
* */ * */
function delete_user_rel_group($user_id, $group_id) public static function delete_user_rel_group($user_id, $group_id)
{ {
$table = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP); $table = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
$sql= "DELETE FROM $table WHERE user_id = ".intval($user_id)." AND group_id=".intval($group_id)." "; $sql= "DELETE FROM $table WHERE user_id = ".intval($user_id)." AND group_id=".intval($group_id)." ";
@ -616,7 +626,7 @@ class GroupPortalManager
* @param array user list * @param array user list
* @param int access_url_id * @param int access_url_id
* */ * */
function update_urls_rel_user($user_list,$access_url_id) public static function update_urls_rel_user($user_list,$access_url_id)
{ {
$table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $table_access_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@ -650,7 +660,7 @@ class GroupPortalManager
* @param int group id * @param int group id
* @param int relation type * @param int relation type
* */ * */
function update_user_permission($user_id, $group_id, $relation_type = GROUP_USER_PERMISSION_READER) public static function update_user_role($user_id, $group_id, $relation_type = GROUP_USER_PERMISSION_READER)
{ {
$table_group_rel_user = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP); $table_group_rel_user = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
$group_id = intval($group_id); $group_id = intval($group_id);
@ -662,14 +672,14 @@ class GroupPortalManager
} }
function get_group_admin_list($user_id, $group_id) public static function get_group_admin_list($user_id, $group_id)
{ {
$table_group_rel_user = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP); $table_group_rel_user = Database :: get_main_table(TABLE_MAIN_USER_REL_GROUP);
$group_id = intval($group_id); $group_id = intval($group_id);
$user_id = intval($user_id); $user_id = intval($user_id);
$sql = "UPDATE $table_group_rel_user echo $sql = "SELECT user_id FROM $table_group_rel_user WHERE
SET relation_type = ".intval($relation_type)." WHERE user_id = $user_id AND group_id = $group_id" ; relation_type = ".GROUP_USER_PERMISSION_ADMIN." AND user_id = $user_id AND group_id = $group_id" ;
$result = Database::query($sql, __FILE__, __LINE__); $result = Database::query($sql, __FILE__, __LINE__);
} }
@ -682,7 +692,7 @@ class GroupPortalManager
* @param array user list * @param array user list
* @param int access_url_id * @param int access_url_id
* */ * */
function update_urls_rel_course($course_list,$access_url_id) public static function update_urls_rel_course($course_list,$access_url_id)
{ {
$table_course = Database :: get_main_table(TABLE_MAIN_COURSE); $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@ -712,7 +722,7 @@ class GroupPortalManager
function get_access_url_from_user($user_id) { public static function get_access_url_from_user($user_id) {
$table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $table_url_rel_user = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $table_url = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT url, access_url_id FROM $table_url_rel_user url_rel_user INNER JOIN $table_url u $sql = "SELECT url, access_url_id FROM $table_url_rel_user url_rel_user INNER JOIN $table_url u
@ -726,7 +736,7 @@ class GroupPortalManager
/** /**
* *
* */ * */
function get_url_id($url) public static function get_url_id($url)
{ {
$table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."'"; $sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."'";

@ -140,6 +140,7 @@ class MessageManager
$i = 0; $i = 0;
$message_list = array (); $message_list = array ();
while ($result = Database::fetch_row($sql_result)) { while ($result = Database::fetch_row($sql_result)) {
if ($request===true) { if ($request===true) {
$message[0] = '<input type="checkbox" value='.$result[0].' name="id[]">'; $message[0] = '<input type="checkbox" value='.$result[0].' name="id[]">';
} else { } else {
@ -147,12 +148,9 @@ class MessageManager
} }
if ($request===true) { if ($request===true) {
if($result[4]==0) if($result[4]==0) {
{
$message[1] = Display::return_icon('mail_open.png',get_lang('AlreadyReadMessage'));//Message already read $message[1] = Display::return_icon('mail_open.png',get_lang('AlreadyReadMessage'));//Message already read
} } else {
else
{
$message[1] = Display::return_icon('mail.png',get_lang('UnReadMessage'));//Message without reading $message[1] = Display::return_icon('mail.png',get_lang('UnReadMessage'));//Message without reading
} }
@ -161,8 +159,13 @@ class MessageManager
$message[5] = '<a onclick="reply_to_messages(\'show\','.$result[0].',\'\')" href="javascript:void(0)">'.Display::return_icon('message_reply.png',get_lang('ReplyToMessage')).'</a>'. $message[5] = '<a onclick="reply_to_messages(\'show\','.$result[0].',\'\')" href="javascript:void(0)">'.Display::return_icon('message_reply.png',get_lang('ReplyToMessage')).'</a>'.
'&nbsp;&nbsp;<a onclick="delete_one_message('.$result[0].')" href="javascript:void(0)" >'.Display::return_icon('message_delete.png',get_lang('DeleteMessage')).'</a>'; '&nbsp;&nbsp;<a onclick="delete_one_message('.$result[0].')" href="javascript:void(0)" >'.Display::return_icon('message_delete.png',get_lang('DeleteMessage')).'</a>';
} else { } else {
$message[2] = '<a href="view_message.php?id='.$result[0].'">'.GetFullUserName(($result[1])).'</a>';; if($result[4]==1) {
$message[3] = '<a href="view_message.php?id='.$result[0].'">'.$result[2].'</a>'; $class = 'class = "unread"';
} else {
$class = 'class = "read"';
}
$message[2] = '<a '.$class.' href="view_message.php?id='.$result[0].'">'.GetFullUserName(($result[1])).'</a>';;
$message[3] = '<a '.$class.' href="view_message.php?id='.$result[0].'">'.$result[2].'</a>';
$message[5] = '<a href="new_message.php?re_id='.$result[0].'">'.Display::return_icon('message_reply.png',get_lang('ReplyToMessage')).'</a>'. $message[5] = '<a href="new_message.php?re_id='.$result[0].'">'.Display::return_icon('message_reply.png',get_lang('ReplyToMessage')).'</a>'.
'&nbsp;&nbsp;<a delete_one_message('.$result[0].') href="inbox.php?action=deleteone&id='.$result[0].'">'.Display::return_icon('message_delete.png',get_lang('DeleteMessage')).'</a>'; '&nbsp;&nbsp;<a delete_one_message('.$result[0].') href="inbox.php?action=deleteone&id='.$result[0].'">'.Display::return_icon('message_delete.png',get_lang('DeleteMessage')).'</a>';
} }
@ -518,7 +521,7 @@ class MessageManager
} }
$message[4] = $result[3]; //date stays the same $message[4] = $result[3]; //date stays the same
foreach($message as $key => $value) { foreach($message as $key => $value) {
$message[$key] = api_xml_http_response_encode($value); $message[$key] = $value;
} }
$message_list[] = $message; $message_list[] = $message;
$i++; $i++;
@ -541,7 +544,7 @@ class MessageManager
/** /**
* display message box in the inbox * display message box in the inbox
* @return void * @return string html with the message content
*/ */
public static function show_message_box() { public static function show_message_box() {
global $charset; global $charset;
@ -551,19 +554,21 @@ class MessageManager
$message_id = ''; $message_id = '';
if (isset($_GET['id_send']) && is_numeric($_GET['id_send'])) { if (isset($_GET['id_send']) && is_numeric($_GET['id_send'])) {
// when I get here ? by Julio Montoya
$query = "SELECT * FROM $table_message WHERE user_sender_id=".api_get_user_id()." AND id=".intval(Database::escape_string($_GET['id_send']))." AND msg_status=4;"; $query = "SELECT * FROM $table_message WHERE user_sender_id=".api_get_user_id()." AND id=".intval(Database::escape_string($_GET['id_send']))." AND msg_status=4;";
$result = Database::query($query,__FILE__,__LINE__); $result = Database::query($query,__FILE__,__LINE__);
$path='outbox.php'; $path='outbox.php';
$message_id = intval($_GET['id_send']); $message_id = intval($_GET['id_send']);
} else { } else {
if (is_numeric($_GET['id'])) { if (is_numeric($_GET['id'])) {
$query = "UPDATE $table_message SET msg_status = '0' WHERE user_receiver_id=".api_get_user_id()." AND id='".intval(Database::escape_string($_GET['id']))."';"; $message_id = intval($_GET['id']);
$query = "UPDATE $table_message SET msg_status = '".MESSAGE_STATUS_NEW."' WHERE user_receiver_id=".api_get_user_id()." AND id='".$message_id."';";
$result = Database::query($query,__FILE__,__LINE__); $result = Database::query($query,__FILE__,__LINE__);
$query = "SELECT * FROM $table_message WHERE msg_status<>4 AND user_receiver_id=".api_get_user_id()." AND id='".intval(Database::escape_string($_GET['id']))."';";
$query = "SELECT * FROM $table_message WHERE msg_status<>4 AND user_receiver_id=".api_get_user_id()." AND id='".$message_id."';";
$result = Database::query($query,__FILE__,__LINE__); $result = Database::query($query,__FILE__,__LINE__);
} }
$path='inbox.php'; $path='inbox.php';
$message_id = intval($_GET['id']);
} }
$row = Database::fetch_array($result); $row = Database::fetch_array($result);
@ -577,17 +582,8 @@ class MessageManager
for ($i=0;$i<count($user_con);$i++) for ($i=0;$i<count($user_con);$i++)
if ($row[1]==$user_con[$i]) if ($row[1]==$user_con[$i])
$band=1; $band=1;
if ($band==1 && !isset($_GET['id_send'])) {
if (is_numeric($_GET['id'])) { $message_content = '
$reply = '<a onclick="reply_to_messages(\'show\','.Security::remove_XSS($_GET['id']).',\'\')" href="javascript:void(0)">'.Display::return_icon('message_reply.png',api_xml_http_response_encode(get_lang('ReplyToMessage'))).api_xml_http_response_encode(get_lang('ReplyToMessage')).'</a>';
}
}
echo '<div class=actions>';
echo '<a onclick="close_div_show(\'div_content_messages\')" href="javascript:void(0)">'.Display::return_icon('folder_up.gif',api_xml_http_response_encode(get_lang('BackToInbox'))).api_xml_http_response_encode(get_lang('BackToInbox')).'</a>';
echo $reply;
echo '<a onclick="delete_one_message('.$row[0].')" href="javascript:void(0)" >'.Display::return_icon('message_delete.png',api_xml_http_response_encode(get_lang('DeleteMessage'))).''.api_xml_http_response_encode(get_lang('DeleteMessage')).'</a>';
echo '</div><br />';
echo '
<table class="message_view_table" > <table class="message_view_table" >
<TR> <TR>
<TD width=10>&nbsp; </TD> <TD width=10>&nbsp; </TD>
@ -595,13 +591,25 @@ class MessageManager
<TABLE> <TABLE>
<TR> <TR>
<TD width="100%"> <TD width="100%">
<TR> <h1>'.str_replace("\\","",api_xml_http_response_encode($row[5])).'</h1></TR> <TR> <h1>'.str_replace("\\","",$row[5]).'</h1></TR>
</TD> </TD>
<TR>';
if (api_get_setting('allow_social_tool') == 'true') {
$user_image = '';
/* @todo add user image
$user_image = UserManager::get_user_picture_path_by_id($row[1],'web', true,false);
$user_image = UserManager::get_picture_user($row[1], $user_image['file'],'40');
$user_image = '<img src="'.$user_image['file'].'" style="'.$user_image['style'].'" >';
*/
$message_content .='<TD>'.get_lang('From').' '.$user_image.'<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$row[1].'">'.GetFullUserName($row[1]).'</a> '.api_strtolower(get_lang('To')).'&nbsp;<b>'.get_lang('Me').'</b> </TD>';
} else {
$message_content .='<TD>'.get_lang('From').'&nbsp;'.GetFullUserName($row[1]).'</b> '.api_strtolower(get_lang('To')).' <b>'.get_lang('Me').'</b> </TD>';
}
$message_content .='</TR>
<TR> <TR>
<TD>'.api_xml_http_response_encode(get_lang('From').'&nbsp;<b>'.GetFullUserName($row[1]).'</b> '.api_strtolower(get_lang('To')).'&nbsp; <b>'.GetFullUserName($row[2])).'</b> </TD> <TD >'.get_lang('Date').'&nbsp; '.$row[4].'</TD>
</TR>
<TR>
<TD >'.api_xml_http_response_encode(get_lang('Date').'&nbsp; '.$row[4]).'</TD>
</TR> </TR>
</TR> </TR>
</TABLE> </TABLE>
@ -609,7 +617,7 @@ class MessageManager
<TABLE height=209 width="100%" bgColor=#ffffff> <TABLE height=209 width="100%" bgColor=#ffffff>
<TBODY> <TBODY>
<TR> <TR>
<TD vAlign=top>'.str_replace("\\","",api_xml_http_response_encode($row[6])).'</TD> <TD vAlign=top>'.str_replace("\\","",$row[6]).'</TD>
</TR> </TR>
</TBODY> </TBODY>
</TABLE> </TABLE>
@ -618,6 +626,7 @@ class MessageManager
<TD width=10>&nbsp;</TD> <TD width=10>&nbsp;</TD>
</TR> </TR>
</TABLE>'; </TABLE>';
return $message_content;
} }
@ -876,6 +885,7 @@ function inbox_display() {
$table->set_header(3,$title,false); $table->set_header(3,$title,false);
$table->set_header(4,api_xml_http_response_encode(get_lang('Date')),false,array('style' => 'width:150px;')); $table->set_header(4,api_xml_http_response_encode(get_lang('Date')),false,array('style' => 'width:150px;'));
$table->set_header(5,$action,false,array ('style' => 'width:100px;')); $table->set_header(5,$action,false,array ('style' => 'width:100px;'));
echo '<div id="div_content_table_data">'; echo '<div id="div_content_table_data">';
if ($request===true) { if ($request===true) {
echo '<form name="form_send" id="form_send" action="" method="post">'; echo '<form name="form_send" id="form_send" action="" method="post">';

@ -1,5 +1,5 @@
<?php //$id: $ <?php //$id: $
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/** /**
============================================================================== ==============================================================================
@ -165,14 +165,16 @@ class SocialManager extends UserManager {
} }
} }
/** /**
* get contacts id list * Gets friends id list
* @author isaac flores paz <florespaz@bidsoftperu.com>
* @param int user id * @param int user id
* @param int group id * @param int group id
* @param string name to search * @param string name to search
* @param bool true will load firstname, lastname, and image name
* @return array * @return array
* @author Julio Montoya <gugli100@gmail.com> Cleaning code, function renamed, $load_extra_info option added
* @author isaac flores paz <florespaz@bidsoftperu.com>
*/ */
public static function get_list_id_friends_by_user_id ($user_id,$id_group=null,$search_name=null) { public static function get_friends($user_id, $id_group=null, $search_name=null, $load_extra_info = true) {
$list_ids_friends=array(); $list_ids_friends=array();
$tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_FRIEND); $tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_FRIEND);
$tbl_my_user = Database :: get_main_table(TABLE_MAIN_USER); $tbl_my_user = Database :: get_main_table(TABLE_MAIN_USER);
@ -185,8 +187,14 @@ class SocialManager extends UserManager {
} }
$res=Database::query($sql,__FILE__,__LINE__); $res=Database::query($sql,__FILE__,__LINE__);
while ($row=Database::fetch_array($res,'ASSOC')) { while ($row=Database::fetch_array($res,'ASSOC')) {
if ($load_extra_info == true) {
$path = UserManager::get_user_picture_path_by_id($row['friend_user_id'],'web',false,true);
$my_user_info=api_get_user_info($row['friend_user_id']);
$list_ids_friends[]=array('friend_user_id'=>$row['friend_user_id'],'firstName'=>$my_user_info['firstName'] , 'lastName'=>$my_user_info['lastName'], 'username'=>$my_user_info['username'], 'image'=>$path['file']);
} else {
$list_ids_friends[]=$row; $list_ids_friends[]=$row;
} }
}
return $list_ids_friends; return $list_ids_friends;
} }
@ -204,7 +212,7 @@ class SocialManager extends UserManager {
$list_path_friend=array(); $list_path_friend=array();
$array_path_user=array(); $array_path_user=array();
$combine_friend = array(); $combine_friend = array();
$list_ids = self::get_list_id_friends_by_user_id ($user_id,$id_group,$search_name); $list_ids = self::get_friends($user_id,$id_group,$search_name);
if (is_array($list_ids)) { if (is_array($list_ids)) {
foreach ($list_ids as $values_ids) { foreach ($list_ids as $values_ids) {
$list_path_image_friend[] = UserManager::get_user_picture_path_by_id($values_ids['friend_user_id'],'web',false,true); $list_path_image_friend[] = UserManager::get_user_picture_path_by_id($values_ids['friend_user_id'],'web',false,true);
@ -234,7 +242,7 @@ class SocialManager extends UserManager {
/** /**
* Sends an invitation to contacts * Sends an invitation to contacts
* @author isaac flores paz <florespaz@bidsoftperu.com> * @author isaac flores paz <florespaz@bidsoftperu.com>
* @author Julio Montya <gugli100@gmail.com> Cleaning code * @author Julio Montoya <gugli100@gmail.com> Cleaning code
* @param int user id * @param int user id
* @param int user friend id * @param int user friend id
* @param string title of the message * @param string title of the message
@ -424,10 +432,12 @@ class SocialManager extends UserManager {
if (count($feeds)==0) { return ''; } if (count($feeds)==0) { return ''; }
foreach ($feeds as $url) { foreach ($feeds as $url) {
if (empty($url)) { continue; } if (empty($url)) { continue; }
$rss = fetch_rss($url); $rss = fetch_rss($url);
$res .= '<h2>'.$rss->channel['title'].'</h2>'; $res .= '<h2>'.$rss->channel['title'].'</h2>';
$res .= '<div class="social-rss-channel-items">'; $res .= '<div class="social-rss-channel-items">';
$i = 1; $i = 1;
if (is_array($rss->items)) {
foreach ($rss->items as $item) { foreach ($rss->items as $item) {
if ($limit>=0 and $i>$limit) {break;} if ($limit>=0 and $i>$limit) {break;}
$res .= '<h3><a href="'.$item['link'].'">'.$item['title'].'</a></h3>'; $res .= '<h3><a href="'.$item['link'].'">'.$item['title'].'</a></h3>';
@ -435,6 +445,7 @@ class SocialManager extends UserManager {
$res .= '<div class="social-rss-item-content">'.$item['description'].'</div><br />'; $res .= '<div class="social-rss-item-content">'.$item['description'].'</div><br />';
$i++; $i++;
} }
}
$res .= '</div>'; $res .= '</div>';
} }
return $res; return $res;

@ -2191,6 +2191,7 @@ class UserManager
* @return array with the file and the style of an image i.e $array['file'] $array['style'] * @return array with the file and the style of an image i.e $array['file'] $array['style']
*/ */
public static function get_picture_user($user_id, $picture_file, $height, $size_picture = 'medium_', $style = '') { public static function get_picture_user($user_id, $picture_file, $height, $size_picture = 'medium_', $style = '') {
$patch_profile = 'upload/users/'; $patch_profile = 'upload/users/';
$picture = array(); $picture = array();
$picture['style'] = $style; $picture['style'] = $style;

@ -2,7 +2,7 @@
/* For licensing terms, see /chamilo_license.txt */ /* For licensing terms, see /chamilo_license.txt */
// name of the language file that needs to be included // name of the language file that needs to be included
$language_file = array('registration','messages','userInfo','admin','index'); $language_file = array('registration','messages','userInfo');
$cidReset=true; $cidReset=true;
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'message.lib.php'; require_once api_get_path(LIBRARY_PATH).'message.lib.php';
@ -111,7 +111,6 @@ if (isset($_GET['form_reply']) || isset($_GET['form_delete'])) {
$link_ref="new_message.php"; $link_ref="new_message.php";
$table_message = Database::get_main_table(TABLE_MESSAGE); $table_message = Database::get_main_table(TABLE_MESSAGE);

@ -9,16 +9,21 @@ if (api_get_setting('allow_message_tool')!='true'){
api_not_allowed(); api_not_allowed();
} }
/* This page should be deleted */
if(api_get_user_id()!=0) { if(api_get_user_id()!=0) {
echo '<script language="javascript" type="text/javascript" src="'.api_get_path(WEB_CODE_PATH).'messages/cookies.js"> </script> '; //echo '<script language="javascript" type="text/javascript" src="'.api_get_path(WEB_CODE_PATH).'messages/cookies.js"> </script> ';
echo '<script language="javascript" type="text/javascript">set_url("'.api_get_path(WEB_CODE_PATH).'messages/notify.php") ; notificar()</script> '; //echo '<script language="javascript" type="text/javascript">set_url("'.api_get_path(WEB_CODE_PATH).'messages/notify.php") ; notificar()</script> ';
$number_of_new_messages = MessageManager::get_new_messages(); $number_of_new_messages = MessageManager::get_new_messages();
if(is_null($number_of_new_messages)) { if(is_null($number_of_new_messages)) {
$number_of_new_messages = 0; $number_of_new_messages = 0;
} }
echo "<a href=inbox.php>".get_lang('Inbox')."(<span id=\"nuevos\" style=\"none\">".$number_of_new_messages."</span>)</a>"; /*echo "<a href=inbox.php>".get_lang('Inbox')."(<span id=\"nuevos\" style=\"none\">".$number_of_new_messages."</span>)</a>";
echo " - "; echo " - ";
echo "<a href=new_message.php>".get_lang('ComposeMessage')."</a>"; echo "<a href=new_message.php>".get_lang('ComposeMessage')."</a>";*/
$number_of_new_messages = -1;
if($number_of_new_messages > 0) if($number_of_new_messages > 0)
{ {
?> ?>
@ -36,7 +41,7 @@ if(api_get_user_id()!=0) {
<?php <?php
} }
} else { } else {
echo '<script language="javascript" type="text/javascript" src="'.api_get_path(WEB_CODE_PATH).'messages/cookies.js"> </script>'; //echo '<script language="javascript" type="text/javascript" src="'.api_get_path(WEB_CODE_PATH).'messages/cookies.js"> </script>';
echo '<script language="javascript" type="text/javascript">Set_Cookie( "nuevos", 0, 0, "/","","")</script> '; //echo '<script language="javascript" type="text/javascript">Set_Cookie( "nuevos", 0, 0, "/","","")</script> ';
} }
?> ?>

@ -1,3 +0,0 @@
<?php
/* see main/inc/lib/message.lib.php*/
?>

@ -1,24 +0,0 @@
#box.aviso
{
position:absolute;
width:200px;
height:60px;
z-index:3;
visibility:hidden;
top:85px;
left:10px;
margin: 0px;
padding: 0px;
}
#table.content
{
border: 1px solid #4171B5;
height:60px;
background-color:#DBEAF5;
filter:alpha(opacity=90);
opacity: 0.90;
}
#ref.content
{
text-align:center;
}

@ -229,8 +229,9 @@ if (isset($_GET['rs'])) {
'url' => '#', 'url' => '#',
'name' => get_lang('ComposeMessage') 'name' => get_lang('ComposeMessage')
); );
$this_section = SECTION_MYPROFILE;
Display::display_header('');
Display::display_header('');
$group_id = intval($_REQUEST['group_id']); $group_id = intval($_REQUEST['group_id']);
echo '<div class=actions>'; echo '<div class=actions>';

@ -45,19 +45,25 @@ if ( isset($_REQUEST['user_friend']) ) {
if (api_get_setting('allow_message_tool')=='true') { if (api_get_setting('allow_message_tool')=='true') {
if ($panel == 1) { if ($panel == 1) {
//normal message //normal message
$user_info=api_get_user_info($userfriend_id); $user_info=api_get_user_info($userfriend_id); ?>
echo api_xml_http_response_encode(get_lang('To')); ?> :&nbsp;&nbsp;&nbsp;&nbsp;<?php echo api_xml_http_response_encode(api_get_person_name($user_info['firstName'], $user_info['lastName'])); ?> <div id="display_response_id" style="height:200px;">
<?php echo api_xml_http_response_encode(get_lang('To')); ?> :&nbsp;&nbsp;&nbsp;&nbsp;<?php echo api_xml_http_response_encode(api_get_person_name($user_info['firstName'], $user_info['lastName'])); ?>
<br /> <br />
<br /><?php echo api_xml_http_response_encode(get_lang('Subject')); ?> :<br /><input id="txt_subject_id" type="text" style="width:300px;"><br/> <br /><?php echo api_xml_http_response_encode(get_lang('Subject')); ?> :<br /><input id="txt_subject_id" type="text" style="width:300px;"><br/>
<br /><?php echo api_xml_http_response_encode(get_lang('Message')); ?> :<br /><textarea id="txt_area_invite" rows="4" cols="41"></textarea> <br /><?php echo api_xml_http_response_encode(get_lang('Message')); ?> :<br /><textarea id="txt_area_invite" rows="4" cols="40"></textarea>
<br /><br /> <br />
<button class="save" type="button" value="<?php echo api_xml_http_response_encode(get_lang('SendMessage')); ?>" onclick="action_database_panel('5','<?php echo $userfriend_id;?>')"><?php echo api_xml_http_response_encode(get_lang('SendMessage')) ?></button> <button class="save" type="button" value="<?php echo api_xml_http_response_encode(get_lang('SendMessage')); ?>" onclick="action_database_panel('5','<?php echo $userfriend_id;?>')"><?php echo api_xml_http_response_encode(get_lang('SendMessage')) ?></button>
</div>
<?php <?php
} else { } else {
// friend invitation message // friend invitation message
echo api_xml_http_response_encode(get_lang('AddPersonalMessage')); ?> :<br /><br /> ?>
<textarea id="txt_area_invite" rows="5" cols="41"></textarea><br /><br /> <div id="display_response_id" style="height:200px;">
<button class="save" type="button" value="<?php echo api_xml_http_response_encode(get_lang('SocialAddToFriends')); ?>" onclick="action_database_panel('4','<?php echo $userfriend_id;?>')" ><?php echo api_xml_http_response_encode(get_lang('SocialAddToFriends')) ?></button> <?= api_xml_http_response_encode(get_lang('AddPersonalMessage')); ?> :<br /><br />
<textarea id="txt_area_invite" rows="5" cols="40"></textarea><br /><br />
<button class="save" type="button" value="<?php echo api_xml_http_response_encode(get_lang('SocialAddToFriends')); ?>" onclick="action_database_panel('4','<?php echo $userfriend_id;?>')" >
<?php echo api_xml_http_response_encode(get_lang('SocialAddToFriends')) ?></button>
</div>
<?php <?php
} }
} }
@ -67,9 +73,4 @@ if ( isset($_REQUEST['user_friend']) ) {
</td> </td>
</tr> </tr>
</div> </div>
<tr>
<td>
<div id="display_response_id" style="position:relative"></div>
</td>
</tr>
</table> </table>

@ -10,61 +10,36 @@ if (api_get_setting('allow_message_tool')!='true'){
api_not_allowed(); api_not_allowed();
} }
require_once api_get_path(LIBRARY_PATH).'message.lib.php'; require_once api_get_path(LIBRARY_PATH).'message.lib.php';
$interbreadcrumb[]= array ('url' => 'inbox.php','name' => get_lang('Message'));
$interbreadcrumb[]= array ('url' => '#','name' => get_lang('View'));
if (isset($_GET['id_send']) || isset($_GET['id'])) {
if (isset($_GET['rs'])) {
$interbreadcrumb[]= array (
'url' => '#',
'name' => get_lang('Messages')
);
$interbreadcrumb[]= array (
'url' => '../social/'.$_SESSION['social_dest'].'?#remote-tab-2',
'name' => get_lang('SocialNetwork')
);
$interbreadcrumb[]= array (
'url' => 'inbox.php',
'name' => get_lang('Inbox')
);
$interbreadcrumb[]= array (
'url' => 'outbox.php',
'name' => get_lang('Outbox')
);
} else {
$interbreadcrumb[]= array (
'url' => '#',
'name' => get_lang('Messages')
);
$interbreadcrumb[]= array (
'url' => 'inbox.php',
'name' => get_lang('Inbox')
);
$interbreadcrumb[]= array (
'url' => 'outbox.php',
'name' => get_lang('Outbox')
);
}
}
/* /*
============================================================================== ==============================================================================
HEADER HEADER
============================================================================== ==============================================================================
*/ */
$request=api_is_xml_http_request(); $this_section = SECTION_MYPROFILE;
if ($request===false) { Display::display_header('');
Display::display_header('');
}
//api_display_tool_title(api_xml_http_response_encode(get_lang('ReadMessage'))); echo '<div class=actions>';
if (isset($_GET['id_send'])) { echo '<a href="inbox.php">'.Display::return_icon('folder_up.gif',get_lang('BackToInbox')).get_lang('BackToInbox').'</a>';
MessageManager::show_message_box_sent(); echo '<a href="new_message.php?re_id"'.intval($_GET['id']).'">'.Display::return_icon('message_reply.png',get_lang('ReplyToMessage')).get_lang('ReplyToMessage').'</a>';
echo '<a href="inbox.php?action=deleteone&id="'.intval($_GET['id']).'" >'.Display::return_icon('message_delete.png',get_lang('DeleteMessage')).''.get_lang('DeleteMessage').'</a>';
echo '</div><br />';
$message = MessageManager::show_message_box();
if (!empty($message)) {
echo $message;
} else { } else {
MessageManager::show_message_box(); api_not_allowed();
} }
/* /*
============================================================================== ==============================================================================
FOOTER FOOTER
============================================================================== ==============================================================================
*/ */
if ($request===false) { Display::display_footer();
Display::display_footer();
}
?> ?>

@ -1,5 +1,9 @@
<?php <?php
/* For licensing terms, see /chamilo_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
$language_file = array('registration','messages','userInfo','admin'); $language_file = array('registration','messages','userInfo','admin');
require '../inc/global.inc.php'; require '../inc/global.inc.php';

@ -1,5 +1,9 @@
<?php <?php
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
$language_file = array('registration','messages','userInfo','admin','forum','blog'); $language_file = array('registration','messages','userInfo','admin','forum','blog');
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';

@ -1,7 +1,11 @@
<?php <?php
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
$language_file = array('admin'); $language_file = array('userInfo');
require '../inc/global.inc.php'; require '../inc/global.inc.php';
require_once api_get_path(CONFIGURATION_PATH).'profile.conf.php'; require_once api_get_path(CONFIGURATION_PATH).'profile.conf.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
@ -10,6 +14,8 @@ require_once api_get_path(LIBRARY_PATH).'image.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'social.lib.php'; require_once api_get_path(LIBRARY_PATH).'social.lib.php';
api_block_anonymous_users();
$this_section = SECTION_SOCIAL; $this_section = SECTION_SOCIAL;
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery

@ -1,5 +1,11 @@
<?php <?php
$language_file= 'admin'; /* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
$language_file= 'userInfo';
$cidReset=true; $cidReset=true;
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'/formvalidator/FormValidator.class.php'; require_once api_get_path(LIBRARY_PATH).'/formvalidator/FormValidator.class.php';

@ -1,5 +1,10 @@
<?php <?php
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
$language_file = array('registration','messages','userInfo','admin'); $language_file = array('registration','messages','userInfo','admin');
require '../inc/global.inc.php'; require '../inc/global.inc.php';

@ -1,12 +1,13 @@
<?php // $Id: user_edit.php 22233 2009-07-20 09:54:05Z ivantcholakov $ <?php
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/** /**
============================================================================== * @package dokeos.social
* @package dokeos.admin * @author Julio Montoya <gugli100@gmail.com>
============================================================================== */
*/
// Language files that should be included // Language files that should be included
$language_file = array('admin'); $language_file = array('userInfo');
$cidReset = true; $cidReset = true;
include '../inc/global.inc.php'; include '../inc/global.inc.php';
$this_section = SECTION_SOCIAL; $this_section = SECTION_SOCIAL;

@ -1,16 +1,21 @@
<?php //$id: $ <?php //$id: $
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
// name of the language file that needs to be included // name of the language file that needs to be included
$language_file=array('registration'); $language_file=array('userInfo');
// resetting the course id // resetting the course id
$cidReset=true; $cidReset=true;
// including some necessary dokeos files // including some necessary dokeos files
require('../inc/global.inc.php'); require('../inc/global.inc.php');
require_once ('../inc/lib/xajax/xajax.inc.php'); require_once ('../inc/lib/xajax/xajax.inc.php');
api_block_anonymous_users();
$xajax = new xajax(); $xajax = new xajax();
//$xajax->debugOn(); //$xajax->debugOn();
$xajax -> registerFunction ('search_users'); $xajax -> registerFunction ('search_users');
@ -19,8 +24,9 @@ $xajax -> registerFunction ('search_users');
$this_section = SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;
// setting breadcrumbs // setting breadcrumbs
$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin')); $this_section = SECTION_SOCIAL;
$interbreadcrumb[]=array('url' => 'group_list.php','name' => get_lang('GroupList'));
$interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
// Database Table Definitions // Database Table Definitions
$tbl_group = Database::get_main_table(TABLE_MAIN_GROUP); $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP);
@ -29,7 +35,7 @@ $tbl_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
// setting the name of the tool // setting the name of the tool
$tool_name = get_lang('SubscribeUsersToGroup'); $tool_name = get_lang('SubscribeUsersToGroup');
$group_id = intval($_GET['id']); $group_id = intval($_REQUEST['id']);
$add_type = 'multiple'; $add_type = 'multiple';
if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){ if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){
@ -37,12 +43,26 @@ if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){
} }
//checking for extra field with filter on //checking for extra field with filter on
require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php'); require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once (api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php'); require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
require_once api_get_path(LIBRARY_PATH).'social.lib.php'; require_once api_get_path(LIBRARY_PATH).'social.lib.php';
function search_users($needle,$type) //todo @this validation could be in a function in group_portal_manager
{ if (empty($group_id)) {
api_not_allowed();
} else {
$group_info = GroupPortalManager::get_group_data($group_id);
if (empty($group_info)) {
api_not_allowed();
}
//only admin or moderator can do that
$user_role = GroupPortalManager::get_user_group_role(api_get_user_id(), $group_id);
if (!in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
api_not_allowed();
}
}
function search_users($needle,$type) {
global $tbl_user,$tbl_group_rel_user,$group_id; global $tbl_user,$tbl_group_rel_user,$group_id;
$xajax_response = new XajaxResponse(); $xajax_response = new XajaxResponse();
$return = ''; $return = '';
@ -185,43 +205,44 @@ $form_sent=0;
$errorMsg=$firstLetterUser=$firstLetterSession=''; $errorMsg=$firstLetterUser=$firstLetterSession='';
$UserList=$SessionList=array(); $UserList=$SessionList=array();
$users=$sessions=array(); $users=$sessions=array();
$noPHP_SELF=true;
$group_info = GroupPortalManager::get_group_data($group_id);
api_block_anonymous_users();
Display :: display_header($tool_name, 'Groups'); Display :: display_header($tool_name, 'Groups');
SocialManager::show_social_menu(); SocialManager::show_social_menu();
echo '<div class="actions-title">'; echo '<div class="actions-title">';
echo get_lang('Invitations'); echo get_lang('Invitations');
echo '</div>'; echo '</div>';
//api_display_tool_title($tool_name.' ('.$session_info['name'].')');
if($_POST['form_sent']) { if($_POST['form_sent']) {
$form_sent = $_POST['form_sent']; $form_sent = $_POST['form_sent'];
$firstLetterUser = $_POST['firstLetterUser']; $firstLetterUser = $_POST['firstLetterUser'];
$firstLetterSession = $_POST['firstLetterSession']; $firstLetterSession = $_POST['firstLetterSession'];
$UserList = $_POST['sessionUsersList']; $user_list = $_POST['sessionUsersList'];
$ClassList = $_POST['sessionClassesList'];
$group_id = intval($_POST['id']); $group_id = intval($_POST['id']);
/*if(!is_array($UserList)) { if(!is_array($user_list)) {
$UserList=array(); $user_list=array();
} }
if ($form_sent == 1) { if ($form_sent == 1) {
GroupPortalManager::delete_users($group_id); //invite this users
$result = GroupPortalManager::add_users_to_groups($UserList, array($group_id)); $result = GroupPortalManager::add_users_to_groups($user_list, array($group_id), GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER);
Display :: display_confirmation_message(get_lang('UsersEdited')); $title = 'YouAreInvitedToGroup'.$group_id;
$content = 'YouAreInvitedToGroupContent'.$group_id;
//send invitation message
foreach($user_list as $user_id ){
MessageManager::send_message($user_id, $title, $content);
} }
*/
}
} }
$nosessionUsersList = $sessionUsersList = array(); $nosessionUsersList = $sessionUsersList = array();
/*$sql = 'SELECT COUNT(1) FROM '.$tbl_user;
$rs = Database::query($sql, __FILE__, __LINE__);
$count_courses = Database::result($rs, 0, 0);*/
$ajax_search = $add_type == 'unique' ? true : false; $ajax_search = $add_type == 'unique' ? true : false;
global $_configuration; global $_configuration;
@ -254,152 +275,44 @@ if ($ajax_search) {
$sessionUsersList[$user['user_id']] = $user ; $sessionUsersList[$user['user_id']] = $user ;
} }
} else { } else {
/*
//Filter by Extra Fields
$use_extra_fields = false;
if (is_array($extra_field_list)) {
if (is_array($new_field_list) && count($new_field_list)>0 ) {
$result_list=array();
foreach ($new_field_list as $new_field) {
$varname = 'field_'.$new_field['variable'];
if (Usermanager::is_extra_field_available($new_field['variable'])) {
if (isset($_POST[$varname]) && $_POST[$varname]!='0') {
$use_extra_fields = true;
$extra_field_result[]= Usermanager::get_extra_user_data_by_value($new_field['variable'], $_POST[$varname]);
}
}
}
}
}
*/
$use_extra_fields =false;
if ($use_extra_fields) { $friends = SocialManager::get_friends(api_get_user_id());
$final_result = array();
if (count($extra_field_result)>1) {
for($i=0;$i<count($extra_field_result)-1;$i++) {
if (is_array($extra_field_result[$i+1])) {
$final_result = array_intersect($extra_field_result[$i],$extra_field_result[$i+1]);
}
}
} else {
$final_result = $extra_field_result[0];
}
$where_filter =''; $suggest_friends = false;
if ($_configuration['multiple_access_urls']==true) {
if (is_array($final_result) && count($final_result)>0) {
$where_filter = " AND u.user_id IN ('".implode("','",$final_result)."') ";
} else {
//no results
$where_filter = " AND u.user_id = -1";
}
} else {
if (is_array($final_result) && count($final_result)>0) {
$where_filter = " WHERE u.user_id IN ('".implode("','",$final_result)."') ";
} else {
//no results
$where_filter = " WHERE u.user_id = -1";
}
}
}
if ($use_extra_fields) { if (!$friends) {
$sql="SELECT user_id, lastname, firstname, username, group_id $suggest_friends = true;
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.id_user = u.user_id AND id_session = '$id_session'
$where_filter
$order_clause";
} else { } else {
$sql="SELECT u.user_id, lastname, firstname, username, group_id
FROM $tbl_user u
LEFT JOIN $tbl_group_rel_user gu
ON (gu.user_id = u.user_id) AND gu.group_id = $group_id
$order_clause";
}
if ($_configuration['multiple_access_urls']==true) {
$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1){
$sql="SELECT u.user_id, lastname, firstname, username, id_session
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.id_user = u.user_id AND id_session = '$id_session'
INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id)
WHERE access_url_id = $access_url_id $where_filter
$order_clause";
}
}
$friends = SocialManager::get_list_id_friends_by_user_id(api_get_user_id());
foreach($friends as $friend) { foreach($friends as $friend) {
$user_info=api_get_user_info($friend['friend_user_id']); $group_friend_list = GroupPortalManager::get_groups_by_user($friend['friend_user_id'], 0);
$group_friend_list = GroupPortalManager::get_groups_by_user($friend['friend_user_id']);
$friend_group_id = ''; $friend_group_id = '';
if (isset($group_friend_list[$group_id]) && $group_friend_list[$group_id]['id'] == $group_id) { if (isset($group_friend_list[$group_id]) && $group_friend_list[$group_id]['id'] == $group_id) {
$friend_group_id = $group_id; $friend_group_id = $group_id;
} }
$Users[]=array('user_id' => $friend['friend_user_id'], 'firstname' =>$user_info['firstName'], 'lasttname' => $user_info['lastName'], 'username' =>$user_info['username'],'group_id'=>$friend_group_id ); //var_dump ($group_friend_list[$group_id]['relation_type']);
if ($group_friend_list[$group_id]['relation_type'] == '' ) {
$Users[$friend['friend_user_id']]=array('user_id' => $friend['friend_user_id'], 'firstname' =>$friend['firstName'], 'lasttname' => $friend['lastName'], 'username' =>$friend['username'],'group_id'=>$friend_group_id );
}
}
} }
// echo $sql;
//$result = Database::query($sql,__FILE__,__LINE__);
//$Users = Database::store_result($result,'ASSOC');
foreach ($Users as $user) { foreach ($Users as $user) {
if($user['group_id'] != $group_id) if($user['group_id'] != $group_id)
$nosessionUsersList[$user['user_id']] = $user ; $nosessionUsersList[$user['user_id']] = $user ;
} }
$user_anonymous=api_get_anonymous_id(); //deleting anonymous users
$user_anonymous = api_get_anonymous_id();
foreach($nosessionUsersList as $key_user_list =>$value_user_list) { foreach($nosessionUsersList as $key_user_list =>$value_user_list) {
if ($nosessionUsersList[$key_user_list]['user_id']==$user_anonymous) { if ($nosessionUsersList[$key_user_list]['user_id']==$user_anonymous) {
unset($nosessionUsersList[$key_user_list]); unset($nosessionUsersList[$key_user_list]);
} }
} }
//filling the correct users in list
$sql="SELECT u.user_id, lastname, firstname, username, group_id
FROM $tbl_user u
LEFT JOIN $tbl_group_rel_user
ON $tbl_group_rel_user.user_id = u.user_id AND group_id = '$group_id'
$order_clause";
if ($_configuration['multiple_access_urls']==true) {
$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1){
$sql="SELECT u.user_id, lastname, firstname, username, id_session
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user
ON $tbl_session_rel_user.id_user = u.user_id AND id_session = '$id_session'
INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id)
WHERE access_url_id = $access_url_id
$order_clause";
}
}
$result=Database::query($sql,__FILE__,__LINE__);
$Users=Database::store_result($result);
foreach($Users as $key_user_list =>$value_user_list) {
if ($Users[$key_user_list]['user_id']==$user_anonymous) {
unset($Users[$key_user_list]);
}
}
foreach ($Users as $user) {
if($user['group_id'] == $group_id) {
$sessionUsersList[$user['user_id']] = $user;
if (array_key_exists($user['user_id'],$nosessionUsersList))
unset($nosessionUsersList[$user['user_id']]);
}
}
} }
if ($add_type == 'multiple') { if ($add_type == 'multiple') {
$link_add_type_unique = '<a href="'.api_get_self().'?id='.$group_id.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>'; $link_add_type_unique = '<a href="'.api_get_self().'?id='.$group_id.'&add='.Security::remove_XSS($_GET['add']).'&add_type=unique">'.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').'</a>';
$link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'); $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple');
@ -459,10 +372,10 @@ if(!empty($errorMsg)) {
<table border="0" cellpadding="5" cellspacing="0" width="100%"> <table border="0" cellpadding="5" cellspacing="0" width="100%">
<!-- Users --> <!-- Users -->
<tr> <tr>
<td align="center"><b><?php echo get_lang('UserListInPlatform') ?> :</b> <td align="center"><b><?php echo get_lang('Friends') ?> :</b>
</td> </td>
<td></td> <td></td>
<td align="center"><b><?php echo get_lang('UserListInGroup') ?> :</b></td> <td align="center"><b><?php echo get_lang('SendInvitationTo') ?> :</b></td>
</tr> </tr>
<?php if ($add_type=='no') { ?> <?php if ($add_type=='no') { ?>
@ -519,8 +432,6 @@ if(!empty($errorMsg)) {
} else { } else {
?> ?>
<button class="arrowr" type="button" onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))" onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))"></button> <button class="arrowr" type="button" onclick="moveItem(document.getElementById('origin_users'), document.getElementById('destination_users'))" 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'))" onclick="moveItem(document.getElementById('destination_users'), document.getElementById('origin_users'))"></button>
<?php <?php
} }
?> ?>
@ -546,7 +457,7 @@ unset($sessionUsersList);
<td colspan="3" align="center"> <td colspan="3" align="center">
<br /> <br />
<?php <?php
echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('SubscribeUsersToGroup').'</button>'; echo '<button class="save" type="button" value="" onclick="valide()" >'.get_lang('InviteUsersToGroup').'</button>';
?> ?>
</td> </td>
</tr> </tr>
@ -645,6 +556,13 @@ function makepost(select){
</script> </script>
<?php <?php
//current group members
$members = GroupPortalManager::get_users_by_group($group_id,true,array(GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER));
echo get_lang('UsersAlreadyInvited');
Display::display_sortable_grid('search_users', array(), $members, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, false, true));
/* /*
============================================================================== ==============================================================================
FOOTER FOOTER

@ -1,18 +1,40 @@
<?php <?php
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
$language_file = array('admin'); $language_file = array('userInfo');
require '../inc/global.inc.php'; require '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php'; require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'social.lib.php'; require_once api_get_path(LIBRARY_PATH).'social.lib.php';
$this_section = SECTION_SOCIAL; $this_section = SECTION_SOCIAL;
$interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social')); $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
api_block_anonymous_users(); api_block_anonymous_users();
$group_id = intval($_GET['id']);
//todo @this validation could be in a function in group_portal_manager
if (empty($group_id)) {
api_not_allowed();
} else {
$group_info = GroupPortalManager::get_group_data($group_id);
if (empty($group_info)) {
api_not_allowed();
}
//only admin or moderator can do that
$user_role = GroupPortalManager::get_user_group_role(api_get_user_id(), $group_id);
if (!in_array($user_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) {
api_not_allowed();
}
}
Display :: display_header($tool_name, 'Groups'); Display :: display_header($tool_name, 'Groups');
SocialManager::show_social_menu(); SocialManager::show_social_menu();
echo '<div class="actions-title">'; echo '<div class="actions-title">';
@ -20,8 +42,7 @@ echo get_lang('GroupMembers');
echo '</div>'; echo '</div>';
// Group information // Group information
$group_id = intval($_GET['id']); $admins = GroupPortalManager::get_users_by_group($group_id, true,array(GROUP_USER_PERMISSION_ADMIN));
$admins = GroupPortalManager::get_users_by_group($group_id, true,GROUP_USER_PERMISSION_ADMIN);
$show_message = ''; $show_message = '';
if (isset($_GET['action']) && $_GET['action']=='add') { if (isset($_GET['action']) && $_GET['action']=='add') {
@ -29,7 +50,7 @@ if (isset($_GET['action']) && $_GET['action']=='add') {
$user_join = intval($_GET['u']); $user_join = intval($_GET['u']);
//if i'm the admin //if i'm the admin
if (isset($admins[api_get_user_id()]) && $admins[api_get_user_id()]['relation_type'] == GROUP_USER_PERMISSION_ADMIN) { if (isset($admins[api_get_user_id()]) && $admins[api_get_user_id()]['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
GroupPortalManager::update_user_permission($user_join, $group_id); GroupPortalManager::update_user_role($user_join, $group_id);
$show_message = get_lang('UserAdded'); $show_message = get_lang('UserAdded');
} }
} }
@ -44,12 +65,22 @@ if (isset($_GET['action']) && $_GET['action']=='delete') {
} }
} }
$users = GroupPortalManager::get_users_by_group($group_id, true); if (isset($_GET['action']) && $_GET['action']=='set_moderator') {
// we add a user only if is a open group
$user_moderator= intval($_GET['u']);
//if i'm the admin
if (isset($admins[api_get_user_id()]) && $admins[api_get_user_id()]['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
GroupPortalManager::update_user_role($user_moderator, $group_id, GROUP_USER_PERMISSION_MODERATOR);
$show_message = get_lang('UserChangeToModerator');
}
}
if (! empty($show_message)){ if (! empty($show_message)){
Display :: display_normal_message($show_message); Display :: display_normal_message($show_message);
} }
$users = GroupPortalManager::get_users_by_group($group_id, true, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_READER, GROUP_USER_PERMISSION_MODERATOR));
$new_member_list = array(); $new_member_list = array();
foreach($users as $user) { foreach($users as $user) {
@ -58,12 +89,15 @@ foreach($users as $user) {
$user['link'] = Display::return_icon('admin_star.png', get_lang('Admin')); $user['link'] = Display::return_icon('admin_star.png', get_lang('Admin'));
break; break;
case GROUP_USER_PERMISSION_READER: case GROUP_USER_PERMISSION_READER:
$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><br />'. $user['link'] = '<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=delete">'.Display::return_icon('del_user_big.gif', get_lang('DeleteFromGroup')).'</a><br />'.
'<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=set_admin">'.Display::return_icon('delete.png', get_lang('LikeModerator')).'</a>'; '<a href="group_members.php?id='.$group_id.'&u='.$user['user_id'].'&action=set_moderator">'.Display::return_icon('admins.gif', get_lang('AddModerator')).'</a>';
break; break;
case GROUP_USER_PERMISSION_PENDING_INVITATION: 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>'; $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; break;
case GROUP_USER_PERMISSION_MODERATOR:
$user['link'] = Display::return_icon('moderator_star.png', get_lang('Moderator'));
break;
} }
$new_member_list[] = $user; $new_member_list[] = $user;
} }

@ -1,13 +1,19 @@
<?php <?php
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
$language_file = array('admin'); $language_file = array('userInfo');
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php'; require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
require_once api_get_path(LIBRARY_PATH).'social.lib.php'; require_once api_get_path(LIBRARY_PATH).'social.lib.php';
require_once api_get_path(LIBRARY_PATH).'message.lib.php'; require_once api_get_path(LIBRARY_PATH).'message.lib.php';
api_block_anonymous_users();
$this_section = SECTION_SOCIAL; $this_section = SECTION_SOCIAL;
$htmlHeadXtra[] = '<script type="text/javascript" src="/main/inc/lib/javascript/jquery.js"></script>'; $htmlHeadXtra[] = '<script type="text/javascript" src="/main/inc/lib/javascript/jquery.js"></script>';
@ -80,7 +86,6 @@ $group_info = GroupPortalManager::get_group_data($group_id);
if ($group_id != 0 ) { if ($group_id != 0 ) {
//Loading group information //Loading group information
if (isset($_GET['status']) && $_GET['status']=='sent') { if (isset($_GET['status']) && $_GET['status']=='sent') {
Display::display_confirmation_message(get_lang('MessageHasBeenSent'), false); Display::display_confirmation_message(get_lang('MessageHasBeenSent'), false);
@ -111,6 +116,7 @@ if ($group_id != 0 ) {
$picture = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],160,'medium_'); $picture = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],160,'medium_');
$tags = GroupPortalManager::get_group_tags($group_id, true); $tags = GroupPortalManager::get_group_tags($group_id, true);
$users = GroupPortalManager::get_users_by_group($group_id, true); $users = GroupPortalManager::get_users_by_group($group_id, true);
//my relation with the group is set here //my relation with the group is set here
if (is_array($users[api_get_user_id()]) && count($users[api_get_user_id()]) > 0) { if (is_array($users[api_get_user_id()]) && count($users[api_get_user_id()]) > 0) {
@ -130,7 +136,10 @@ if ($group_id != 0 ) {
echo '<style> echo '<style>
#group_members { width:233px; height:300px; overflow-x:none; overflow-y: auto;} #group_members { width:233px; height:300px; overflow-x:none; overflow-y: auto;}
.group_member_item { width:98px; height:86px; float:left; margin:5px 5px 15px 5px; } .group_member_item { width:98px; height:86px; float:left; margin:5px 5px 15px 5px; }
.group_member_picture { height:65px; }; .group_member_picture { display:block;
height:92px;
margin:0;
overflow:hidden; };
</style>'; </style>';
echo '<div id="layout-left" style="float: left; width: 280px; height: 100%;">'; echo '<div id="layout-left" style="float: left; width: 280px; height: 100%;">';
@ -178,7 +187,13 @@ if ($group_id != 0 ) {
if ($user['relation_type'] == GROUP_USER_PERMISSION_ADMIN) { if ($user['relation_type'] == GROUP_USER_PERMISSION_ADMIN) {
$user['lastname'].= Display::return_icon('admin_star.png', get_lang('Admin')); $user['lastname'].= Display::return_icon('admin_star.png', get_lang('Admin'));
} }
echo '<div class="group_member_item"><a href="profile.php?u='.$user['user_id'].'"><div class="group_member_picture">'.$user['picture_uri'].'</div>'.$user['firstname'].$user['lastname'].'</a></div>'; if ($user['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) {
$user['lastname'].= Display::return_icon('moderator_star.png', get_lang('Moderator'));
}
echo '<div class="group_member_item"><a href="profile.php?u='.$user['user_id'].'">';
echo '<div class="group_member_picture">'.$user['image'].'</div>';
echo api_get_person_name($user['firstname'], $user['lastname']).'</a></div>';
} }
} }
echo '</div>'; echo '</div>';
@ -200,6 +215,9 @@ if ($group_id != 0 ) {
case GROUP_USER_PERMISSION_PENDING_INVITATION: case GROUP_USER_PERMISSION_PENDING_INVITATION:
echo get_lang('PendingApproval'); echo get_lang('PendingApproval');
break; break;
case GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER:
echo get_lang('PendingApproval');
break;
case GROUP_USER_PERMISSION_MODERATOR: case GROUP_USER_PERMISSION_MODERATOR:
echo '<a href="group_members.php?id='.$group_id.'">'.get_lang('MemberList').'</a>'; echo '<a href="group_members.php?id='.$group_id.'">'.get_lang('MemberList').'</a>';
echo '<a href="group_invitation.php?id='.$group_id.'">'.get_lang('InviteFriends').'</a>'; echo '<a href="group_invitation.php?id='.$group_id.'">'.get_lang('InviteFriends').'</a>';

@ -1,10 +1,9 @@
<?php //$id: $ <?php //$id: $
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/** /**
* This is the home of a social network user, here we should show the latest info/status of our friends * @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com> * @author Julio Montoya <gugli100@gmail.com>
* @package dokeos.social */
*/
$language_file = array('registration','messages','userInfo','admin','forum','blog'); $language_file = array('registration','messages','userInfo','admin','forum','blog');
$cidReset = true; $cidReset = true;

@ -1,5 +1,9 @@
<?php <?php
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true; $cidReset = true;
$language_file = array('registration','messages','userInfo','admin'); $language_file = array('registration','messages','userInfo','admin');

@ -1,12 +1,16 @@
<?php <?php
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/**
$language_file = array('messages','userInfo','admin'); * @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
$language_file = array('messages','userInfo');
require '../inc/global.inc.php'; require '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'image.lib.php'; require_once api_get_path(LIBRARY_PATH).'image.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'social.lib.php'; require_once api_get_path(LIBRARY_PATH).'social.lib.php';
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php'; require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
$this_section = SECTION_SOCIAL; $this_section = SECTION_SOCIAL;
$interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social')); $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
@ -61,9 +65,33 @@ SocialManager::show_social_menu();
echo '<div class="actions-title">'; echo '<div class="actions-title">';
echo get_lang('Invitations'); echo get_lang('Invitations');
echo '</div>'; echo '</div>';
// easy links
if (is_array($_GET) && count($_GET)>0) {
foreach($_GET as $key => $value) {
switch ($key) {
case 'accept':
$user_role = GroupPortalManager::get_user_group_role(api_get_user_id(), $value);
if ($user_role == GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER) {
GroupPortalManager::update_user_role(api_get_user_id(), $value, GROUP_USER_PERMISSION_READER);
$show_message = get_lang('UserIsSubscribeToThisGroup');
} else {
$show_message = get_lang('UserIsSubscribeToThisGroup');
}
break 2;
case 'deny':
// delete invitation
GroupPortalManager::delete_user_rel_group(api_get_user_id(), $value);
$show_message = get_lang('GroupInvitationWasDeny');
break 2;
}
}
}
if (! empty($show_message)){
Display :: display_normal_message($show_message);
}
$request = api_is_xml_http_request();
$language_variable = get_lang('PendingInvitations'); $language_variable = get_lang('PendingInvitations');
$language_comment = get_lang('SocialInvitesComment'); $language_comment = get_lang('SocialInvitesComment');
//api_display_tool_title($language_variable); //api_display_tool_title($language_variable);
@ -75,8 +103,7 @@ $user_id = api_get_user_id();
$list_get_invitation = SocialManager::get_list_invitation_of_friends_by_user_id($user_id); $list_get_invitation = SocialManager::get_list_invitation_of_friends_by_user_id($user_id);
$list_get_invitation_sent = SocialManager::get_list_invitation_sent_by_user_id($user_id); $list_get_invitation_sent = SocialManager::get_list_invitation_sent_by_user_id($user_id);
$pending_invitations = GroupPortalManager::get_groups_by_user($user_id, GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER,true);
$pending_invitations = GroupPortalManager::get_groups_by_user($user_id, GROUP_USER_PERMISSION_PENDING_INVITATION,true);
$number_loop=count($list_get_invitation); $number_loop=count($list_get_invitation);
@ -89,9 +116,7 @@ echo '<style>
width:110px; width:110px;
} }
</style>'; </style>';
if ($number_loop==0) { if ($number_loop != 0) {
Display::display_normal_message(get_lang('NoPendingInvitations'));
} else {
echo '<h2>'.get_lang('InvitationReceived').'</h2>'; echo '<h2>'.get_lang('InvitationReceived').'</h2>';
foreach ($list_get_invitation as $invitation) { foreach ($list_get_invitation as $invitation) {
@ -176,8 +201,18 @@ if (count($list_get_invitation_sent) > 0 ){
} }
if (count($pending_invitations) > 0) { if (count($pending_invitations) > 0) {
echo '<h2>'.get_lang('GroupsWaitingApproval').'</h2>'; echo '<h2>'.get_lang('GroupsWaitingApproval').'</h2>';
Display::display_sortable_grid('search_users', array(), $pending_invitations, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false)); $new_invitation = array();
foreach ($pending_invitations as $invitation) {
$invitation['picture_uri'] = '<a href="groups.php?id='.$invitation['id'].'">'.$invitation['picture_uri'].'</a>';
$invitation['name'] = '<a href="groups.php?id='.$invitation['id'].'">'.$invitation['name'].'</a>';
$invitation['join'] = '<a href="invitations.php?accept='.$invitation['id'].'">'.get_lang('AcceptInvitation').'</a>';
$invitation['deny'] = '<a href="invitations.php?deny='.$invitation['id'].'">'.get_lang('DenyInvitation').'</a>';
$new_invitation[]=$invitation;
}
Display::display_sortable_grid('search_users', array(), $new_invitation, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false,false,true,true));
} }
Display::display_footer(); Display::display_footer();

@ -272,58 +272,50 @@ echo '<div id="social-profile-wrapper">';
if ($show_full_profile) { if ($show_full_profile) {
$list_path_friends= $list_path_normal_friends = $list_path_parents = array(); $list_path_friends= $list_path_normal_friends = $list_path_parents = array();
$list_path_good_friends = SocialManager::get_list_path_web_by_user_id($user_id, SOCIALGOODFRIEND); //SOCIALGOODFRIEND , SOCIALFRIEND, SOCIALPARENT
$list_path_normal_friends = SocialManager::get_list_path_web_by_user_id($user_id, SOCIALFRIEND);
$list_path_parents = SocialManager::get_list_path_web_by_user_id($user_id, SOCIALPARENT);
$list_path_friends = array_merge_recursive($list_path_good_friends, $list_path_normal_friends, $list_path_parents); $friends = SocialManager::get_friends($user_id, SOCIALFRIEND);
$friend_html=''; $friend_html = '';
$number_of_images=3; $number_of_images = 3;
$number_friends=0; $number_friends = 0;
$list_friends_id=array(); $list_friends_id = array();
$list_friends_dir=array(); $number_friends = count($friends);
$list_friends_file=array(); $number_of_images = $number_friends;
if ($number_friends != 0) {
if (count($list_path_friends)!=0) {
$friends_count = count($list_path_friends['id_friend']);
for ($z=0;$z< $friends_count ;$z++) {
$list_friends_id[] = $list_path_friends['id_friend'][$z]['friend_user_id'];
$list_friends_dir[] = $list_path_friends['path_friend'][$z]['dir'];
$list_friends_file[]= $list_path_friends['path_friend'][$z]['file'];
}
$number_friends= count($list_friends_dir);
$number_loop = ($number_friends/$number_of_images); $number_loop = ($number_friends/$number_of_images);
$loop_friends = ceil($number_loop); $loop_friends = ceil($number_loop);
$j=0; $j=0;
$friend_html .= '<div class="sectiontitle">'.get_lang('SocialFriend').'</div>'; $friend_html .= '<div class="sectiontitle">'.get_lang('SocialFriend').'</div>';
$friend_html.= '<div id="friend-container" class="social-friend-container">'; $friend_html .= '<div id="friend-container" class="social-friend-container">';
$friend_html.= '<div id="friend-header">'; $friend_html.= '<div id="friend-header">';
//$friend_html.= $friends_count.' '.get_lang('Friends'); //$friend_html.= $friends_count.' '.get_lang('Friends');
if ($friends_count == 1) if ($number_friends == 1)
$friend_html.= '<div style="float:left;">'.$friends_count.' '.get_lang('Friend').'</div>'; $friend_html.= '<div style="float:left;">'.$number_friends.' '.get_lang('Friend').'</div>';
else else
$friend_html.= '<div style="float:left;">'.$friends_count.' '.get_lang('Friends').'</div>'; $friend_html.= '<div style="float:left;">'.$number_friends.' '.get_lang('Friends').'</div>';
if (api_get_user_id() == $user_id) if (api_get_user_id() == $user_id) {
$friend_html.= '<div style="float:right;"><a href="friends.php">'.get_lang('SeeAll').'</a></div>'; $friend_html.= '<div style="float:right;"><a href="friends.php">'.get_lang('SeeAll').'</a></div>';
}
$friend_html.= '</div>'; // close div friend-header $friend_html.= '</div>'; // close div friend-header
for ($k=0;$k<$loop_friends;$k++) { for ($k=0;$k<$loop_friends;$k++) {
if ($j==$number_of_images) { if ($j==$number_of_images) {
$number_of_images=$number_of_images*2; $number_of_images=$number_of_images*2;
} }
while ($j<$number_of_images) { while ($j<$number_of_images) {
if ($list_friends_file[$j]<>"") { if (isset($friends[$j])) {
$my_user_info=api_get_user_info($list_friends_id[$j]); $friend = $friends[$j];
$name_user=api_get_person_name($my_user_info['firstName'], $my_user_info['lastName']); $name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
$friend_html.='<div id=div_'.$list_friends_id[$j].' class="image_friend_network" ><span><center>'; $friend_html.='<div id=div_'.$friend['friend_user_id'].' class="image_friend_network" ><span><center>';
// the height = 92 must be the sqme in the image_friend_network span style in default.css // the height = 92 must be the sqme in the image_friend_network span style in default.css
$friends_profile = SocialManager::get_picture_user($list_friends_id[$j], $list_friends_file[$j], 92, 'medium_', 'width="85" height="90" '); $friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92, 'medium_', 'width="85" height="90" ');
$friend_html.='<a href="profile.php?u='.$list_friends_id[$j].'&amp;'.$link_shared.'">';
$friend_html.='<img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' id="imgfriend_'.$list_friends_id[$j].'" title="'.$name_user.'" />'; $friend_html.='<a href="profile.php?u='.$friend['friend_user_id'].'&amp;'.$link_shared.'">';
$friend_html.='<img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'" />';
$friend_html.= '</center></span>'; $friend_html.= '</center></span>';
$friend_html.= '<center class="friend">'.api_get_person_name($my_user_info['firstName'], $my_user_info['lastName']).'</a></center>'; $friend_html.= '<center class="friend">'.$name_user.'</a></center>';
$friend_html.= '</div>'; $friend_html.= '</div>';
} }
$j++; $j++;
@ -339,6 +331,7 @@ echo '<div id="social-profile-wrapper">';
} }
$friend_html.= '</div>'; $friend_html.= '</div>';
echo $friend_html; echo $friend_html;
//Pending invitations //Pending invitations
if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u']==api_get_user_id())) { if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u']==api_get_user_id())) {
$pending_invitations = SocialManager::get_list_invitation_of_friends_by_user_id(api_get_user_id()); $pending_invitations = SocialManager::get_list_invitation_of_friends_by_user_id(api_get_user_id());
@ -466,11 +459,10 @@ echo '<div id="social-profile-container">';
echo '</div>'; echo '</div>';
echo '</div>'; echo '</div>';
echo '<br/>'; echo '<br/>';
echo '<div class="actions" style="margin-right:5px;">'; echo '<div class="actions" style="margin-right:5px;">';
echo '&nbsp;<a href="/main/messages/send_message_to_userfriend.inc.php?height=365&width=610&user_friend='.$user_id.'&view=profile&view_panel=1" class="thickbox" title="'.get_lang('SendMessage').'">'.Display::return_icon('message_new.png').'&nbsp;&nbsp;'.get_lang('SendMessage').'</a><br />'; echo '&nbsp;<a href="/main/messages/send_message_to_userfriend.inc.php?height=300&width=610&user_friend='.$user_id.'&view=profile&view_panel=1" class="thickbox" title="'.get_lang('SendMessage').'">';
echo Display::return_icon('message_new.png').'&nbsp;&nbsp;'.get_lang('SendMessage').'</a><br />';
//check if I already sent an invitation message //check if I already sent an invitation message
$invitation_sent_list = SocialManager::get_list_invitation_sent_by_user_id(api_get_user_id()); $invitation_sent_list = SocialManager::get_list_invitation_sent_by_user_id(api_get_user_id());
@ -479,7 +471,7 @@ echo '<div id="social-profile-container">';
echo '<a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.get_lang('YouAlreadySentAnInvitation').'</a>'; echo '<a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.get_lang('YouAlreadySentAnInvitation').'</a>';
} else { } else {
if (!$show_full_profile) { if (!$show_full_profile) {
echo '&nbsp;<a href="/main/messages/send_message_to_userfriend.inc.php?view_panel=2&height=300&width=610&user_friend='.$user_id.'" class="thickbox" title="'.get_lang('SendInvitation').'">'.Display :: return_icon('add_multiple_users.gif', get_lang('SocialInvitationToFriends')).'&nbsp;'.get_lang('SendInvitation').'</a>'; echo '&nbsp;<a href="/main/messages/send_message_to_userfriend.inc.php?view_panel=2&height=240&width=610&user_friend='.$user_id.'" class="thickbox" title="'.get_lang('SendInvitation').'">'.Display :: return_icon('add_multiple_users.gif', get_lang('SocialInvitationToFriends')).'&nbsp;'.get_lang('SendInvitation').'</a>';
} }
} }
@ -693,7 +685,7 @@ echo '<div id="social-profile-container">';
echo '</ul><br />'; echo '</ul><br />';
$user_feeds = SocialManager::get_user_feeds($user_id); $user_feeds = SocialManager::get_user_feeds($user_id);
if (!empty($user_feeds )) { if (is_array($user_feeds )) {
echo '<div class="sectiontitle">'.get_lang('RSSFeeds').'</div>'; echo '<div class="sectiontitle">'.get_lang('RSSFeeds').'</div>';
echo '<div class="social-content-training">'; echo '<div class="social-content-training">';
echo $user_feeds; echo $user_feeds;

@ -1,5 +1,9 @@
<?php //$id: $ <?php //$id: $
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
$language_file=array('registration','messages','userInfo','admin'); $language_file=array('registration','messages','userInfo','admin');
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';

@ -1,8 +1,10 @@
<?php //$id: $ <?php //$id: $
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/** /**
* Provides a short controller for friends registration * @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/ */
// names of the language files that needs to be included // names of the language files that needs to be included
$language_file = array('registration','messages','userInfo','admin'); $language_file = array('registration','messages','userInfo','admin');
require '../inc/global.inc.php'; require '../inc/global.inc.php';

@ -1,8 +1,12 @@
<?php <?php
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
// name of the language file that needs to be included // name of the language file that needs to be included
$language_file = array('registration','admin'); $language_file = array('registration','admin','userInfo');
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'social.lib.php'; require_once api_get_path(LIBRARY_PATH).'social.lib.php';

@ -1,5 +1,9 @@
<?php <?php
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
$language_file = array('registration','messages','userInfo','admin'); $language_file = array('registration','messages','userInfo','admin');
require '../inc/global.inc.php'; require '../inc/global.inc.php';

@ -1,5 +1,10 @@
<?php <?php
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
$language_file = array('registration','messages','userInfo','admin'); $language_file = array('registration','messages','userInfo','admin');
$cidReset = true; $cidReset = true;
require '../inc/global.inc.php'; require '../inc/global.inc.php';

@ -1,5 +1,9 @@
<?php <?php
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /chamilo_license.txt */
/**
* @package dokeos.social
* @author Julio Montoya <gugli100@gmail.com>
*/
$cidReset = true; $cidReset = true;
require '../inc/global.inc.php'; require '../inc/global.inc.php';
@ -10,28 +14,22 @@ require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
require_once api_get_path(LIBRARY_PATH).'image.lib.php'; require_once api_get_path(LIBRARY_PATH).'image.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once '../inc/lib/social.lib.php'; require_once '../inc/lib/social.lib.php';
$list_path_friends=array();
$user_id=api_get_user_id(); $list_path_friends = array();
$name_search=Security::remove_XSS($_POST['search_name_q']); $user_id = api_get_user_id();
$name_search= Security::remove_XSS($_POST['search_name_q']);
$number_friends = 0;
if (isset($name_search) && $name_search!='undefined') { if (isset($name_search) && $name_search!='undefined') {
$list_path_friends=SocialManager::get_list_path_web_by_user_id($user_id,null,$name_search); $friends = SocialManager::get_friends($user_id,null,$name_search);
} else { } else {
$list_path_friends=SocialManager::get_list_path_web_by_user_id($user_id); $friends = SocialManager::get_friends($user_id);
} }
$friend_html=''; $friend_html = '';
$number_of_images=8; $number_of_images = 8;
$number_friends=0;
$list_friends_id=array();
$list_friends_dir=array();
$list_friends_file=array();
if (count($list_path_friends)!=0) { $number_friends = count($friends);
for ($z=0;$z<count($list_path_friends['id_friend']);$z++) { if ($number_friends != 0) {
$list_friends_id[] = $list_path_friends['id_friend'][$z]['friend_user_id'];
$list_friends_dir[] = $list_path_friends['path_friend'][$z]['dir'];
$list_friends_file[]= $list_path_friends['path_friend'][$z]['file'];
}
$number_friends= count($list_friends_dir);
$number_loop = ($number_friends/$number_of_images); $number_loop = ($number_friends/$number_of_images);
$loop_friends = ceil($number_loop); $loop_friends = ceil($number_loop);
$j=0; $j=0;
@ -42,18 +40,13 @@ if (count($list_path_friends)!=0) {
$number_of_images=$number_of_images*2; $number_of_images=$number_of_images*2;
} }
while ($j<$number_of_images) { while ($j<$number_of_images) {
if ($list_friends_file[$j]<>"") { if (isset($friends[$j])) {
$user_info=api_get_user_info($list_friends_id[$j]); $friend = $friends[$j];
$user_name=api_xml_http_response_encode(api_get_person_name($user_info['firstName'], $user_info['lastName'])); $user_name = api_xml_http_response_encode($friend['firstName'], $friend['lastName']);
$friends_profile = SocialManager::get_picture_user($list_friends_id[$j], $list_friends_file[$j], 92); $friends_profile = SocialManager::get_picture_user($friend['friend_user_id'], $friend['image'], 92);
$friend_html.='<div onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$list_friends_id[$j].'>'; $friend_html.='<div onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$list_friends_id[$j].'>';
$friend_html.='<span><a href="profile.php?u='.$list_friends_id[$j].'"><center><img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' id="imgfriend_'.$list_friends_id[$j].'" title="'.$user_name.'" /></center></a></span>'; $friend_html.='<span><a href="profile.php?u='.$friend['friend_user_id'].'"><center><img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' id="imgfriend_'.$friend['friend_user_id'].'" title="'.$user_name.'" /></center></a></span>';
$friend_html.='<img onclick="delete_friend (this)" id=img_'.$list_friends_id[$j].' src="../img/blank.gif" alt="" title="" class="image-delete" /> <center class="friend">'.$user_name.'</center></div>'; $friend_html.='<img onclick="delete_friend (this)" id=img_'.$friend['friend_user_id'].' src="../img/blank.gif" alt="" title="" class="image-delete" /> <center class="friend">'.$user_name.'</center></div>';
/*
* $friend_html.='&nbsp;<div onMouseover="show_icon_delete(this)" onMouseout="hide_icon_delete(this)" class="image-social-content" id=div_'.$list_friends_id[$j].' style="float:left" >
* <img src="'.$list_friends_dir[$j]."/".$list_friends_file[$j].'" width="90" height="110" style="margin-left:3px ;margin-rigth:3px;margin-top:10px;margin-bottom:3px;" id="imgfriend_'.$list_friends_id[$j].'" title="'.$user_name.'" onclick="qualify_friend(this)"/>
* <img onclick="delete_friend (this)" id=img_'.$list_friends_id[$j].' src="../img/blank.gif" alt="" title="" class="image-delete" /></div>&nbsp;';
*/
} }
$j++; $j++;
} }

@ -7,8 +7,6 @@ Mock::generate('Display');
Mock::generate('UserManager'); Mock::generate('UserManager');
Mock::generate('MessageManager'); Mock::generate('MessageManager');
class TestSocial extends UnitTestCase{ class TestSocial extends UnitTestCase{
/* /*
public $social; public $social;
@ -18,7 +16,7 @@ class TestSocial extends UnitTestCase{
} }
public function setUp(){ public function setUp(){
$this->social = new UserFriend(); $this->social = new SocialManager();
} }
public function tearDown(){ public function tearDown(){
@ -30,7 +28,7 @@ class TestSocial extends UnitTestCase{
$friend_id=4; $friend_id=4;
$my_user_id=1; $my_user_id=1;
$relation_type=2; $relation_type=2;
$res= UserFriend::register_friend ($friend_id,$my_user_id,$relation_type); $res= SocialManager::register_friend ($friend_id,$my_user_id,$relation_type);
$instans->expectCallCount(Database); $instans->expectCallCount(Database);
$this->assertTrue(is_object($instans)); $this->assertTrue(is_object($instans));
$this->assertTrue(is_null($res)); $this->assertTrue(is_null($res));
@ -43,7 +41,7 @@ class TestSocial extends UnitTestCase{
$instans= new MockDatabase(); $instans= new MockDatabase();
$instans1= new MockDatabase(); $instans1= new MockDatabase();
$friend_id=4; $friend_id=4;
$res = UserFriend::removed_friend ($friend_id); $res = SocialManager::removed_friend ($friend_id);
$instans->expectCallCount(Database,8,'' ); $instans->expectCallCount(Database,8,'' );
$instans1->expectMaximumCallCount(Database,10,''); $instans1->expectMaximumCallCount(Database,10,'');
$this->assertTrue(is_object($instans)); $this->assertTrue(is_object($instans));
@ -57,7 +55,7 @@ class TestSocial extends UnitTestCase{
public function testShowListTypeFriends(){ public function testShowListTypeFriends(){
$instans= new MockDatabase(); $instans= new MockDatabase();
$instans1= new MockDatabase(); $instans1= new MockDatabase();
$res =UserFriend::show_list_type_friends(); $res =SocialManager::show_list_type_friends();
$instans->expectOnce(Database); $instans->expectOnce(Database);
$instans1->expectMaximumCallCount(Database,10,''); $instans1->expectMaximumCallCount(Database,10,'');
$this->assertTrue(is_object($instans) || is_object($instans1)); $this->assertTrue(is_object($instans) || is_object($instans1));
@ -70,7 +68,7 @@ class TestSocial extends UnitTestCase{
public function testGetRelationTypeByName (){ public function testGetRelationTypeByName (){
$relation_type_name=1; $relation_type_name=1;
$res = UserFriend::get_relation_type_by_name ($relation_type_name); $res = SocialManager::get_relation_type_by_name ($relation_type_name);
if(!is_null($res)): if(!is_null($res)):
$this->assertTrue(is_numeric($res)); $this->assertTrue(is_numeric($res));
$this->assertTrue($res); $this->assertTrue($res);
@ -84,7 +82,7 @@ class TestSocial extends UnitTestCase{
$instans2= new MockDatabase(); $instans2= new MockDatabase();
$user_id=1; $user_id=1;
$user_friend=3; $user_friend=3;
$res =UserFriend::get_relation_between_contacts ($user_id,$user_friend); $res =SocialManager::get_relation_between_contacts ($user_id,$user_friend);
$instans->expectOnce(Database); $instans->expectOnce(Database);
$instans1->expectMinimumCallCount(Database); $instans1->expectMinimumCallCount(Database);
$instans2->expectMaximumCallCount(Database); $instans2->expectMaximumCallCount(Database);
@ -106,7 +104,7 @@ class TestSocial extends UnitTestCase{
$user_id = 1; $user_id = 1;
$id_group=3; $id_group=3;
$search_name='group'; $search_name='group';
$res = UserFriend::get_list_id_friends_by_user_id ($user_id,$id_group,$search_name); $res = SocialManager::get_friends_id ($user_id,$id_group,$search_name);
$instans->expectOnce(Database); $instans->expectOnce(Database);
$this->assertTrue(is_array($res)); $this->assertTrue(is_array($res));
$this->assertTrue(is_object($instans)); $this->assertTrue(is_object($instans));
@ -119,7 +117,7 @@ class TestSocial extends UnitTestCase{
$user_id=1; $user_id=1;
$id_group=null; $id_group=null;
$search_name=null; $search_name=null;
$res = UserFriend::get_list_path_web_by_user_id ($user_id,$id_group,$search_name); $res = SocialManager::get_list_path_web_by_user_id ($user_id,$id_group,$search_name);
$instans->expectOnce(UserManager::get_user_picture_path_by_id($values_ids['friend_user_id'],'web',false,true)); $instans->expectOnce(UserManager::get_user_picture_path_by_id($values_ids['friend_user_id'],'web',false,true));
if(!($res===true)): if(!($res===true)):
$this->assertTrue(is_object($instans)); $this->assertTrue(is_object($instans));
@ -132,7 +130,7 @@ class TestSocial extends UnitTestCase{
public function testGetListWebPathUserInvitationByUserId(){ public function testGetListWebPathUserInvitationByUserId(){
$instans = new MockUserManager(); $instans = new MockUserManager();
$user_id=1; $user_id=1;
$res = UserFriend::get_list_web_path_user_invitation_by_user_id($user_id); $res = SocialManager::get_list_web_path_user_invitation_by_user_id($user_id);
$instans->expectOnce(UserManager::get_user_picture_path_by_id($values_ids['user_sender_id'],'web',false,true)); $instans->expectOnce(UserManager::get_user_picture_path_by_id($values_ids['user_sender_id'],'web',false,true));
if(is_array($res)) if(is_array($res))
$this->assertTrue(is_array($res)); $this->assertTrue(is_array($res));
@ -149,7 +147,7 @@ class TestSocial extends UnitTestCase{
$friend_id=3; $friend_id=3;
$message_title='hello'; $message_title='hello';
$message_content='hola'; $message_content='hola';
$res = UserFriend ::send_invitation_friend ($user_id,$friend_id,$message_title,$message_content); $res = SocialManager ::send_invitation_friend ($user_id,$friend_id,$message_title,$message_content);
$instans->expectMaximumCallCount(Database); $instans->expectMaximumCallCount(Database);
if(!is_null($res)): if(!is_null($res)):
$this->assertTrue(is_bool($res)); $this->assertTrue(is_bool($res));
@ -163,7 +161,7 @@ class TestSocial extends UnitTestCase{
public function testGetMessageNumberInvitationByUserId(){ public function testGetMessageNumberInvitationByUserId(){
$instans = new MockDatabase(); $instans = new MockDatabase();
$user_receiver_id=3; $user_receiver_id=3;
$res = UserFriend::get_message_number_invitation_by_user_id ($user_receiver_id); $res = SocialManager::get_message_number_invitation_by_user_id ($user_receiver_id);
$instans->expectMaximumCallCount(Database); $instans->expectMaximumCallCount(Database);
if(is_string($res)): if(is_string($res)):
$this->assertTrue(is_numeric($res)); $this->assertTrue(is_numeric($res));
@ -177,7 +175,7 @@ class TestSocial extends UnitTestCase{
public function testGetListInvitationOfFriendsByUserId(){ public function testGetListInvitationOfFriendsByUserId(){
$instans = new MockDatabase(); $instans = new MockDatabase();
$user_id=1; $user_id=1;
$res = UserFriend::get_list_invitation_of_friends_by_user_id ($user_id); $res = SocialManager::get_list_invitation_of_friends_by_user_id ($user_id);
$instans->expectCallCount(Database,3,''); $instans->expectCallCount(Database,3,'');
$this->assertTrue(is_array($res)); $this->assertTrue(is_array($res));
$this->assertTrue(is_object($instans)); $this->assertTrue(is_object($instans));
@ -190,7 +188,7 @@ class TestSocial extends UnitTestCase{
$instans1= new MockDatabase(); $instans1= new MockDatabase();
$user_send_id=1; $user_send_id=1;
$user_receiver_id=3; $user_receiver_id=3;
$res = UserFriend::invitation_accepted ($user_send_id,$user_receiver_id); $res = SocialManager::invitation_accepted ($user_send_id,$user_receiver_id);
$instans->expectOnce(Database::get_main_table(TABLE_MAIN_MESSAGE)); $instans->expectOnce(Database::get_main_table(TABLE_MAIN_MESSAGE));
$instans1->expectOnce(Database::query($sql,__FILE__,__LINE__)); $instans1->expectOnce(Database::query($sql,__FILE__,__LINE__));
$this->assertTrue(is_null($res)); $this->assertTrue(is_null($res));
@ -205,7 +203,7 @@ class TestSocial extends UnitTestCase{
$instans = new MockDatabase(); $instans = new MockDatabase();
$user_send_id=1; $user_send_id=1;
$user_receiver_id=3; $user_receiver_id=3;
$res = UserFriend::invitation_denied($user_send_id,$user_receiver_id); $res = SocialManager::invitation_denied($user_send_id,$user_receiver_id);
$instans->expectOnce(Database::query($sql,__FILE__,__LINE__)); $instans->expectOnce(Database::query($sql,__FILE__,__LINE__));
$this->assertTrue(is_object($instans)); $this->assertTrue(is_object($instans));
$this->assertTrue(is_null($res)); $this->assertTrue(is_null($res));
@ -219,7 +217,7 @@ class TestSocial extends UnitTestCase{
$instans = new MockDatabase(); $instans = new MockDatabase();
$id_friend_qualify=2; $id_friend_qualify=2;
$type_qualify=1; $type_qualify=1;
$res = UserFriend::qualify_friend($id_friend_qualify,$type_qualify); $res = SocialManager::qualify_friend($id_friend_qualify,$type_qualify);
$instans->expectOnce(Database::query($sql,__FILE__,__LINE__)); $instans->expectOnce(Database::query($sql,__FILE__,__LINE__));
$this->assertTrue(is_null($res)); $this->assertTrue(is_null($res));
$this->assertTrue(is_object($instans)); $this->assertTrue(is_object($instans));

@ -1233,10 +1233,17 @@ if ($show_menu) {
require_once api_get_path(LIBRARY_PATH).'message.lib.php'; require_once api_get_path(LIBRARY_PATH).'message.lib.php';
require_once api_get_path(LIBRARY_PATH).'social.lib.php'; require_once api_get_path(LIBRARY_PATH).'social.lib.php';
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
// New messages
$number_of_new_messages = MessageManager::get_new_messages(); $number_of_new_messages = MessageManager::get_new_messages();
// New contact invitations
$number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id()); $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
// New group invitations sent by a moderator
$group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER,false);
$group_pending_invitations = count($group_pending_invitations);
$cant_msg = ''; $cant_msg = '';
if ($number_of_new_messages > 0) if ($number_of_new_messages > 0)
$cant_msg = ' ('.$number_of_new_messages.')'; $cant_msg = ' ('.$number_of_new_messages.')';
@ -1250,6 +1257,9 @@ if ($show_menu) {
if ($number_of_new_messages_of_friend > 0) { if ($number_of_new_messages_of_friend > 0) {
echo '<a href="'.api_get_path(WEB_PATH).'main/social/invitations.php" class="message-body">'.get_lang('PendingInvitations').' ('.$number_of_new_messages_of_friend.') </a><br />'; echo '<a href="'.api_get_path(WEB_PATH).'main/social/invitations.php" class="message-body">'.get_lang('PendingInvitations').' ('.$number_of_new_messages_of_friend.') </a><br />';
} }
if ( $group_pending_invitations > 0) {
echo '<a href="'.api_get_path(WEB_PATH).'main/social/invitations.php" class="message-body">'.get_lang('GroupPendingInvitations').' ('.$group_pending_invitations.') </a><br />';
}
echo '</p>'; echo '</p>';
//echo '<img src="'.api_get_path(WEB_IMG_PATH).'delete.gif" alt="'.get_lang('Close').'" title="'.get_lang('Close').'" class="message-delete" />'; //echo '<img src="'.api_get_path(WEB_IMG_PATH).'delete.gif" alt="'.get_lang('Close').'" title="'.get_lang('Close').'" class="message-delete" />';
@ -1304,19 +1314,10 @@ if (isset($_plugins['mycourses_menu']) && is_array($_plugins['mycourses_menu']))
} }
if (api_get_setting('allow_reservation') == 'true' && api_is_allowed_to_create_course() ){ if (api_get_setting('allow_reservation') == 'true' && api_is_allowed_to_create_course() ){
//include_once('main/reservation/rsys.php');
echo '<div class="menusection">'; echo '<div class="menusection">';
echo '<span class="menusectioncaption">'.get_lang('Booking').'</span>'; echo '<span class="menusectioncaption">'.get_lang('Booking').'</span>';
echo '<ul class="menulist">'; echo '<ul class="menulist">';
echo '<a href="main/reservation/reservation.php">'.get_lang('ManageReservations').'</a><br />'; echo '<a href="main/reservation/reservation.php">'.get_lang('ManageReservations').'</a><br />';
//echo '<a href="main/reservation/reservation.php">'.get_lang('ManageReservations').'</a><br />';
/*require_once('main/reservation/rsys.php');
if(api_is_platform_admin() || Rsys :: check_user_status() == 1) { // Only for admins & teachers...
echo '<a href="main/reservation/m_item.php">'.get_lang('ManageItems').'</a><br />';
echo '<a href="main/reservation/m_reservation.php">'.get_lang('ManageReservationPeriods').'</a><br />';
}
*/
echo '</ul>'; echo '</ul>';
echo '</div>'; echo '</div>';
} }

@ -159,26 +159,7 @@ function display_user_list($user_list, $_plugins) {
if (api_get_setting('show_email_addresses') == 'true') { if (api_get_setting('show_email_addresses') == 'true') {
$table_header[] = array(get_lang('Email'), true); $table_header[] = array(get_lang('Email'), true);
} }
//$user_anonymous = api_get_anonymous_id(); Display::display_sortable_table($table_header, $table_data, array(), array('per_page' => 30), $extra_params,array(),'grid');
/*
if (api_get_setting('allow_social_tool') == 'true' && api_get_user_id() <> $user_anonymous && api_get_user_id() <> 0) {
$table_header[] = array(get_lang('Friends'), false, 'width="200"');
}
//this feature is deprecated
if (api_get_setting('allow_message_tool') == 'true' && isset($_SESSION['_user'])) {
$table_header[] = array(get_lang('SendMessage'), true);
}*/
//$sorting_options['column'] = (isset($_GET['column']) ? (int)$_GET['column'] : 2);
//if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
//send_invitation_friend_user();
//echo '<div align="right"><input type="button" name="id_btn_send_invitation" id="id_btn_send_invitation" value="'.get_lang('SendInviteMessage').'"/></div>';
//echo '<form action="whoisonline.php" name="form_register_friend" id="form_register_friend" method="post">';
//}
Display::display_sortable_table($table_header, $table_data, $sorting_options, array('per_page' => 30), $extra_params,array(),'grid');
//if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true' ) {
// echo '</form>';
// }
} }
} }
/** /**

Loading…
Cancel
Save