diff --git a/main/css/blue_lagoon/default.css b/main/css/blue_lagoon/default.css index 3c9d910511..e583cbc3aa 100755 --- a/main/css/blue_lagoon/default.css +++ b/main/css/blue_lagoon/default.css @@ -2664,4 +2664,12 @@ input[type="text"]:focus, input[type="password"]:focus, textarea:focus { #maincontent .courseslist li { margin-bottom:8px; +} + +a.read { + font-weight:normal; +} + +a.unread { + } \ No newline at end of file diff --git a/main/img/moderator_star.png b/main/img/moderator_star.png new file mode 100644 index 0000000000..2ed4502c58 Binary files /dev/null and b/main/img/moderator_star.png differ diff --git a/main/inc/lib/group_portal_manager.lib.php b/main/inc/lib/group_portal_manager.lib.php index f8012d135a..0d6c21bd7e 100755 --- a/main/inc/lib/group_portal_manager.lib.php +++ b/main/inc/lib/group_portal_manager.lib.php @@ -15,9 +15,11 @@ define('GROUP_PERMISSION_CLOSED', '2'); // Group user permissions define('GROUP_USER_PERMISSION_ADMIN' ,'1'); // the admin of a group 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_MODERATOR' ,'4'); // a moderator -define('GROUP_USER_PERMISSION_ANONYMOUS' ,'5'); // an anonymous user +define('GROUP_USER_PERMISSION_PENDING_INVITATION' ,'3'); // When an admin invite a user +define('GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER' ,'4'); // When a user whats to join to a group +define('GROUP_USER_PERMISSION_MODERATOR' ,'5'); // a moderator + +define('GROUP_USER_PERMISSION_ANONYMOUS' ,'6'); // an anonymous user class GroupPortalManager { @@ -32,7 +34,7 @@ class GroupPortalManager * @param int the user_id of the owner * @return boolean if success */ - function add($name, $description, $url, $visibility, $picture='') + public static function add($name, $description, $url, $visibility, $picture='') { $tms = time(); $table = Database :: get_main_table(TABLE_MAIN_GROUP); @@ -59,7 +61,7 @@ class GroupPortalManager * @param int the user_id of the owner * @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); $table = Database::get_main_table(TABLE_MAIN_GROUP); @@ -83,7 +85,7 @@ class GroupPortalManager * @param int id * @return boolean true if success * */ - function delete($id) + public static function delete($id) { $id = intval($id); $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); $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); $sql = "SELECT id FROM $table_access_url WHERE id = '".Database::escape_string($url)."' "; @@ -125,7 +127,7 @@ class GroupPortalManager * @author Julio Montoya * @return int count of urls * */ - function url_count() + public static function url_count() { $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $sql = "SELECT count(id) as count_result FROM $table_access_url"; @@ -140,7 +142,7 @@ class GroupPortalManager * @author Julio Montoya * @return array * */ - function get_url_data() + public static function get_url_data() { $table_access_url= Database :: get_main_table(TABLE_MAIN_ACCESS_URL); $sql = "SELECT id, url, description, active FROM $table_access_url"; @@ -160,7 +162,7 @@ class GroupPortalManager * @param int number of items * @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); $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); $group_id = intval($group_id); @@ -199,7 +201,7 @@ class GroupPortalManager * @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); $table_group_rel_tag = Database :: get_main_table(TABLE_MAIN_GROUP_REL_TAG); @@ -237,7 +239,7 @@ class GroupPortalManager * @author Julio Montoya * @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); $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; } - /** Gets the inner join of users and group table + /** Gets the inner join from users and group table * @author Julio Montoya * @return int access url id * @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 = ''; $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 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 = ''; $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 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 = ''; $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); @@ -359,8 +361,10 @@ class GroupPortalManager 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 = ''; $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); @@ -368,11 +372,16 @@ class GroupPortalManager $group_id = intval($group_id); $limit = intval($limit); - if ($relation_type == 0) { + if (count($relation_type) == 0) { $where_relation_condition = ''; } else { - $relation_type = intval($relation_type); - $where_relation_condition = "AND gu.relation_type = $relation_type "; + $new_relation_type = array(); + 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 @@ -382,12 +391,11 @@ class GroupPortalManager $result=Database::query($sql,__FILE__,__LINE__); $array = array(); while ($row = Database::fetch_array($result, 'ASSOC')) { - if ($with_image == true) { - $picture = UserManager::get_picture_user($row['user_id'], $row['picture_uri'],80,$image_size); - $img = ''; - $row['picture_uri'] = $img; - } - $array[$row['user_id']] = $row; + if ($with_image == true) { + $picture = UserManager::get_picture_user($row['user_id'], $row['picture_uri'],$image_conf['height'],$image_conf['size']); + $row['image'] = ''; + } + $array[$row['user_id']] = $row; } return $array; } @@ -399,7 +407,7 @@ class GroupPortalManager * @return int access url id * @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 =''; $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 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 =''; $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 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); 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 * */ - 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); $return_value = 0; @@ -500,7 +508,7 @@ class GroupPortalManager * @param int url id * @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); $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 * @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); if (!empty($user_id) && !empty($group_id)) { @@ -537,7 +545,7 @@ class GroupPortalManager * @param array of user_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); $result_array = array(); $relation_type = intval($relation_type); @@ -549,6 +557,7 @@ class GroupPortalManager if ($role == 0) { $sql = "INSERT INTO $table_url_rel_group SET user_id = ".intval($user_id).", group_id = ".intval($group_id).", relation_type = ".intval($relation_type).""; + $result = Database::query($sql, __FILE__, __LINE__); if ($result) @@ -564,6 +573,7 @@ class GroupPortalManager + /** * Deletes a group and user relationship * @author Julio Montoya @@ -571,7 +581,7 @@ class GroupPortalManager * @param int url id * @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); $sql = "DELETE FROM $table_ WHERE group_id = ".intval($group_id); @@ -586,7 +596,7 @@ class GroupPortalManager * @param int url id * @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); $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 * @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); $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 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_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 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); $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); $group_id = intval($group_id); $user_id = intval($user_id); - $sql = "UPDATE $table_group_rel_user - SET relation_type = ".intval($relation_type)." WHERE user_id = $user_id AND group_id = $group_id" ; + echo $sql = "SELECT user_id FROM $table_group_rel_user WHERE + relation_type = ".GROUP_USER_PERMISSION_ADMIN." AND user_id = $user_id AND group_id = $group_id" ; $result = Database::query($sql, __FILE__, __LINE__); } @@ -682,7 +692,7 @@ class GroupPortalManager * @param array user list * @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_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 = 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 @@ -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); $sql = "SELECT id FROM $table_access_url WHERE url = '".Database::escape_string($url)."'"; diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php index 56be5a8567..2a761b1a25 100755 --- a/main/inc/lib/message.lib.php +++ b/main/inc/lib/message.lib.php @@ -139,6 +139,7 @@ class MessageManager $i = 0; $message_list = array (); while ($result = Database::fetch_row($sql_result)) { + var_dump($result); if ($request===true) { $message[0] = ''; } else { @@ -146,12 +147,9 @@ class MessageManager } 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 - } - else - { + } else { $message[1] = Display::return_icon('mail.png',get_lang('UnReadMessage'));//Message without reading } @@ -160,8 +158,13 @@ class MessageManager $message[5] = ''.Display::return_icon('message_reply.png',get_lang('ReplyToMessage')).''. '  '.Display::return_icon('message_delete.png',get_lang('DeleteMessage')).''; } else { - $message[2] = ''.GetFullUserName(($result[1])).'';; - $message[3] = ''.$result[2].''; + if($result[4]==1) { + $class = 'class = "unread"'; + } else { + $class = 'class = "read"'; + } + $message[2] = ''.GetFullUserName(($result[1])).'';; + $message[3] = ''.$result[2].''; $message[5] = ''.Display::return_icon('message_reply.png',get_lang('ReplyToMessage')).''. '  '.Display::return_icon('message_delete.png',get_lang('DeleteMessage')).''; } @@ -466,7 +469,7 @@ class MessageManager } $message[4] = $result[3]; //date stays the same foreach($message as $key => $value) { - $message[$key] = api_xml_http_response_encode($value); + $message[$key] = $value; } $message_list[] = $message; $i++; @@ -489,29 +492,31 @@ class MessageManager /** * display message box in the inbox - * @return void + * @return string html with the message content */ public static function show_message_box() { global $charset; - $table_message = Database::get_main_table(TABLE_MESSAGE); + $table_message = Database::get_main_table(TABLE_MESSAGE); $tbl_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT); - $message_id = ''; + $message_id = ''; 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;"; $result = Database::query($query,__FILE__,__LINE__); $path='outbox.php'; $message_id = intval($_GET['id_send']); - } else { - 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']))."';"; + } else { + if (is_numeric($_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__); - $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']))."';"; - $result = Database::query($query,__FILE__,__LINE__); - } - $path='inbox.php'; - $message_id = intval($_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__); + } + $path='inbox.php'; } $row = Database::fetch_array($result); @@ -540,17 +545,8 @@ class MessageManager for ($i=0;$i'.Display::return_icon('message_reply.png',api_xml_http_response_encode(get_lang('ReplyToMessage'))).api_xml_http_response_encode(get_lang('ReplyToMessage')).''; - } - } - echo '
'; - echo ''.Display::return_icon('folder_up.gif',api_xml_http_response_encode(get_lang('BackToInbox'))).api_xml_http_response_encode(get_lang('BackToInbox')).''; - echo $reply; - echo ''.Display::return_icon('message_delete.png',api_xml_http_response_encode(get_lang('DeleteMessage'))).''.api_xml_http_response_encode(get_lang('DeleteMessage')).''; - echo '

'; - echo ' + + $message_content = ' @@ -558,13 +554,25 @@ class MessageManager
 

'.str_replace("\\","",api_xml_http_response_encode($row[5])).'

+

'.str_replace("\\","",$row[5]).'

+ '; + 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 = ''; + */ + $message_content .=''; + + } else { + $message_content .=''; + } + + $message_content .=' - - - - +
-
'.get_lang('From').' '.$user_image.''.GetFullUserName($row[1]).' '.api_strtolower(get_lang('To')).' '.get_lang('Me').' '.get_lang('From').' '.GetFullUserName($row[1]).' '.api_strtolower(get_lang('To')).' '.get_lang('Me').'
'.api_xml_http_response_encode(get_lang('From').' '.GetFullUserName($row[1]).' '.api_strtolower(get_lang('To')).'  '.GetFullUserName($row[2])).'
'.api_xml_http_response_encode(get_lang('Date').'  '.$row[4]).''.get_lang('Date').'  '.$row[4].'
@@ -572,7 +580,7 @@ class MessageManager - +
'.str_replace("\\","",api_xml_http_response_encode($row[6])).''.str_replace("\\","",$row[6]).'
@@ -581,6 +589,7 @@ class MessageManager   '; + return $message_content; } @@ -818,6 +827,7 @@ function inbox_display() { $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(5,$action,false,array ('style' => 'width:100px;')); + echo '
'; if ($request===true) { echo '
'; diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index 329fb7799e..e0bf48313a 100755 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -1,5 +1,5 @@ + * Gets friends id list * @param int user id * @param int group id * @param string name to search + * @param bool true will load firstname, lastname, and image name * @return array + * @author Julio Montoya Cleaning code, function renamed, $load_extra_info option added + * @author isaac flores paz */ - 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(); $tbl_my_friend = Database :: get_main_table(TABLE_MAIN_USER_FRIEND); $tbl_my_user = Database :: get_main_table(TABLE_MAIN_USER); @@ -182,10 +184,16 @@ class SocialManager extends UserManager { } if (isset($search_name) && is_string($search_name)===true) { $sql.=' AND friend_user_id IN (SELECT user_id FROM '.$tbl_my_user.' WHERE '.(api_is_western_name_order() ? 'concat(firstName, lastName)' : 'concat(lastName, firstName)').' like concat("%","'.Database::escape_string($search_name).'","%"));'; - } + } $res=Database::query($sql,__FILE__,__LINE__); while ($row=Database::fetch_array($res,'ASSOC')) { - $list_ids_friends[]=$row; + 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; + } } return $list_ids_friends; } @@ -204,7 +212,7 @@ class SocialManager extends UserManager { $list_path_friend=array(); $array_path_user=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)) { 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); @@ -234,7 +242,7 @@ class SocialManager extends UserManager { /** * Sends an invitation to contacts * @author isaac flores paz - * @author Julio Montya Cleaning code + * @author Julio Montoya Cleaning code * @param int user id * @param int user friend id * @param string title of the message @@ -424,17 +432,20 @@ class SocialManager extends UserManager { if (count($feeds)==0) { return ''; } foreach ($feeds as $url) { if (empty($url)) { continue; } + $rss = fetch_rss($url); $res .= '

'.$rss->channel['title'].'

'; $res .= ''; } return $res; diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index a007df03f4..708b832dbd 100644 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -2191,6 +2191,7 @@ class UserManager * @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 = '') { + $patch_profile = 'upload/users/'; $picture = array(); $picture['style'] = $style; diff --git a/main/messages/inbox.php b/main/messages/inbox.php index 0672be40e9..c879325a23 100755 --- a/main/messages/inbox.php +++ b/main/messages/inbox.php @@ -2,7 +2,7 @@ /* For licensing terms, see /chamilo_license.txt */ // 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; require_once '../inc/global.inc.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"; - $table_message = Database::get_main_table(TABLE_MESSAGE); diff --git a/main/messages/index.php b/main/messages/index.php index c9dc7151b6..4b5b9fd60a 100755 --- a/main/messages/index.php +++ b/main/messages/index.php @@ -9,16 +9,21 @@ if (api_get_setting('allow_message_tool')!='true'){ api_not_allowed(); } + +/* This page should be deleted */ + if(api_get_user_id()!=0) { - echo ' '; - echo ' '; + //echo ' '; + //echo ' '; $number_of_new_messages = MessageManager::get_new_messages(); + if(is_null($number_of_new_messages)) { $number_of_new_messages = 0; } - echo "".get_lang('Inbox')."(".$number_of_new_messages.")"; + /*echo "".get_lang('Inbox')."(".$number_of_new_messages.")"; echo " - "; - echo "".get_lang('ComposeMessage').""; + echo "".get_lang('ComposeMessage')."";*/ + $number_of_new_messages = -1; if($number_of_new_messages > 0) { ?> @@ -36,7 +41,7 @@ if(api_get_user_id()!=0) { '; - echo ' '; + //echo ''; + //echo ' '; } ?> \ No newline at end of file diff --git a/main/messages/messages.css b/main/messages/messages.css deleted file mode 100755 index d462376440..0000000000 --- a/main/messages/messages.css +++ /dev/null @@ -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; -} \ No newline at end of file diff --git a/main/messages/new_message.php b/main/messages/new_message.php index 9019bab5c7..984d3af642 100755 --- a/main/messages/new_message.php +++ b/main/messages/new_message.php @@ -229,8 +229,9 @@ if (isset($_GET['rs'])) { 'url' => '#', 'name' => get_lang('ComposeMessage') ); +$this_section = SECTION_MYPROFILE; +Display::display_header(''); - Display::display_header(''); $group_id = intval($_REQUEST['group_id']); echo '
'; diff --git a/main/messages/send_message_to_userfriend.inc.php b/main/messages/send_message_to_userfriend.inc.php index 496008ac80..87b1684511 100755 --- a/main/messages/send_message_to_userfriend.inc.php +++ b/main/messages/send_message_to_userfriend.inc.php @@ -45,19 +45,25 @@ if ( isset($_REQUEST['user_friend']) ) { if (api_get_setting('allow_message_tool')=='true') { if ($panel == 1) { //normal message - $user_info=api_get_user_info($userfriend_id); - echo api_xml_http_response_encode(get_lang('To')); ?> :     -
-
:

-
:
-

- + $user_info=api_get_user_info($userfriend_id); ?> +
+ :     +
+
:

+
:
+
+ +
:

-

- + ?> +
+ :

+

+ +
- - -
- - - + \ No newline at end of file diff --git a/main/messages/view_message.php b/main/messages/view_message.php index d2c29be18c..b237af4d23 100755 --- a/main/messages/view_message.php +++ b/main/messages/view_message.php @@ -10,61 +10,36 @@ if (api_get_setting('allow_message_tool')!='true'){ api_not_allowed(); } 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 ============================================================================== */ -$request=api_is_xml_http_request(); -if ($request===false) { - Display::display_header(''); -} -//api_display_tool_title(api_xml_http_response_encode(get_lang('ReadMessage'))); -if (isset($_GET['id_send'])) { - MessageManager::show_message_box_sent(); +$this_section = SECTION_MYPROFILE; +Display::display_header(''); + + +echo '
'; + + +$message = MessageManager::show_message_box(); +if (!empty($message)) { + echo $message; } else { - MessageManager::show_message_box(); + api_not_allowed(); } + /* ============================================================================== FOOTER ============================================================================== */ -if ($request===false) { - Display::display_footer(); -} +Display::display_footer(); ?> \ No newline at end of file diff --git a/main/social/contacts.inc.php b/main/social/contacts.inc.php index 9c325fbb73..838d7398fb 100755 --- a/main/social/contacts.inc.php +++ b/main/social/contacts.inc.php @@ -1,6 +1,10 @@ + */ + $language_file = array('registration','messages','userInfo','admin'); require '../inc/global.inc.php'; require_once api_get_path(CONFIGURATION_PATH).'profile.conf.php'; diff --git a/main/social/data_personal.inc.php b/main/social/data_personal.inc.php index 4038e1ffd9..04331e6a9c 100755 --- a/main/social/data_personal.inc.php +++ b/main/social/data_personal.inc.php @@ -1,6 +1,10 @@ + */ + $language_file = array('registration','messages','userInfo','admin','forum','blog'); require_once '../inc/global.inc.php'; require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; diff --git a/main/social/friends.php b/main/social/friends.php index bde515abfa..5bcea63da2 100755 --- a/main/social/friends.php +++ b/main/social/friends.php @@ -1,7 +1,11 @@ + */ -$language_file = array('admin'); +$language_file = array('userInfo'); require '../inc/global.inc.php'; require_once api_get_path(CONFIGURATION_PATH).'profile.conf.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).'social.lib.php'; +api_block_anonymous_users(); + $this_section = SECTION_SOCIAL; $htmlHeadXtra[] = ''; //jQuery diff --git a/main/social/group_add.php b/main/social/group_add.php index 2fba90c983..1d7c546f6f 100755 --- a/main/social/group_add.php +++ b/main/social/group_add.php @@ -1,5 +1,11 @@ + */ + +$language_file= 'userInfo'; $cidReset=true; require_once '../inc/global.inc.php'; require_once api_get_path(LIBRARY_PATH).'/formvalidator/FormValidator.class.php'; diff --git a/main/social/group_contact.inc.php b/main/social/group_contact.inc.php index 40d23e5603..b16602b9b7 100755 --- a/main/social/group_contact.inc.php +++ b/main/social/group_contact.inc.php @@ -1,5 +1,10 @@ + */ + $language_file = array('registration','messages','userInfo','admin'); require '../inc/global.inc.php'; diff --git a/main/social/group_edit.php b/main/social/group_edit.php index 6767d08bef..1b21a0909b 100755 --- a/main/social/group_edit.php +++ b/main/social/group_edit.php @@ -1,12 +1,13 @@ - + */ + + // Language files that should be included -$language_file = array('admin'); +$language_file = array('userInfo'); $cidReset = true; include '../inc/global.inc.php'; $this_section = SECTION_SOCIAL; diff --git a/main/social/group_invitation.php b/main/social/group_invitation.php index 672ae47a3a..36a7b9316c 100755 --- a/main/social/group_invitation.php +++ b/main/social/group_invitation.php @@ -1,16 +1,21 @@ + */ + // name of the language file that needs to be included -$language_file=array('registration'); +$language_file=array('userInfo'); // resetting the course id $cidReset=true; // including some necessary dokeos files require('../inc/global.inc.php'); - require_once ('../inc/lib/xajax/xajax.inc.php'); +api_block_anonymous_users(); + $xajax = new xajax(); //$xajax->debugOn(); $xajax -> registerFunction ('search_users'); @@ -19,8 +24,9 @@ $xajax -> registerFunction ('search_users'); $this_section = SECTION_PLATFORM_ADMIN; // setting breadcrumbs -$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin')); -$interbreadcrumb[]=array('url' => 'group_list.php','name' => get_lang('GroupList')); +$this_section = SECTION_SOCIAL; + +$interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social')); // Database Table Definitions $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 $tool_name = get_lang('SubscribeUsersToGroup'); -$group_id = intval($_GET['id']); +$group_id = intval($_REQUEST['id']); $add_type = 'multiple'; 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 -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).'usermanager.lib.php'; +require_once api_get_path(LIBRARY_PATH).'group_portal_manager.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; $xajax_response = new XajaxResponse(); $return = ''; @@ -185,43 +205,44 @@ $form_sent=0; $errorMsg=$firstLetterUser=$firstLetterSession=''; $UserList=$SessionList=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'); SocialManager::show_social_menu(); echo '
'; echo get_lang('Invitations'); echo '
'; -//api_display_tool_title($tool_name.' ('.$session_info['name'].')'); + + if($_POST['form_sent']) { $form_sent = $_POST['form_sent']; $firstLetterUser = $_POST['firstLetterUser']; $firstLetterSession = $_POST['firstLetterSession']; - $UserList = $_POST['sessionUsersList']; - $ClassList = $_POST['sessionClassesList']; + $user_list = $_POST['sessionUsersList']; + $group_id = intval($_POST['id']); - - /*if(!is_array($UserList)) { - $UserList=array(); + + if(!is_array($user_list)) { + $user_list=array(); } - if ($form_sent == 1) { - GroupPortalManager::delete_users($group_id); - $result = GroupPortalManager::add_users_to_groups($UserList, array($group_id)); - Display :: display_confirmation_message(get_lang('UsersEdited')); + if ($form_sent == 1) { + //invite this users + $result = GroupPortalManager::add_users_to_groups($user_list, array($group_id), GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER); + $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(); -/*$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; global $_configuration; @@ -254,152 +275,44 @@ if ($ajax_search) { $sessionUsersList[$user['user_id']] = $user ; } } 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) { - $final_result = array(); - if (count($extra_field_result)>1) { - for($i=0;$i0) { - $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) { - $sql="SELECT user_id, lastname, firstname, username, group_id - 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 { + $friends = SocialManager::get_friends(api_get_user_id()); - $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"; - } - } + $suggest_friends = false; - $friends = SocialManager::get_list_id_friends_by_user_id(api_get_user_id()); - 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']); - $friend_group_id = ''; - if (isset($group_friend_list[$group_id]) && $group_friend_list[$group_id]['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 ); + if (!$friends) { + $suggest_friends = true; + } else { + foreach($friends as $friend) { + $group_friend_list = GroupPortalManager::get_groups_by_user($friend['friend_user_id'], 0); + $friend_group_id = ''; + if (isset($group_friend_list[$group_id]) && $group_friend_list[$group_id]['id'] == $group_id) { + $friend_group_id = $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) { if($user['group_id'] != $group_id) $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) { if ($nosessionUsersList[$key_user_list]['user_id']==$user_anonymous) { 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') { $link_add_type_unique = ''.Display::return_icon('single.gif').get_lang('SessionAddTypeUnique').''; $link_add_type_multiple = Display::return_icon('multiple.gif').get_lang('SessionAddTypeMultiple'); @@ -459,10 +372,10 @@ if(!empty($errorMsg)) { - - + @@ -519,8 +432,6 @@ if(!empty($errorMsg)) { } else { ?> -

- @@ -546,7 +457,7 @@ unset($sessionUsersList); @@ -645,6 +556,13 @@ function makepost(select){ true, 'per_page' => 100), $query_vars, false, array(true, false, true)); + + /* ============================================================================== FOOTER diff --git a/main/social/group_members.php b/main/social/group_members.php index 4bb9750300..7db63e05d0 100755 --- a/main/social/group_members.php +++ b/main/social/group_members.php @@ -1,18 +1,40 @@ + */ + +$language_file = array('userInfo'); require '../inc/global.inc.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).'social.lib.php'; + $this_section = SECTION_SOCIAL; $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social')); 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'); SocialManager::show_social_menu(); echo '
'; @@ -20,8 +42,7 @@ echo get_lang('GroupMembers'); echo '
'; // Group information -$group_id = intval($_GET['id']); -$admins = GroupPortalManager::get_users_by_group($group_id, true,GROUP_USER_PERMISSION_ADMIN); +$admins = GroupPortalManager::get_users_by_group($group_id, true,array(GROUP_USER_PERMISSION_ADMIN)); $show_message = ''; if (isset($_GET['action']) && $_GET['action']=='add') { @@ -29,7 +50,7 @@ if (isset($_GET['action']) && $_GET['action']=='add') { $user_join = 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_permission($user_join, $group_id); + GroupPortalManager::update_user_role($user_join, $group_id); $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)){ 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(); foreach($users as $user) { @@ -58,11 +89,14 @@ foreach($users as $user) { $user['link'] = Display::return_icon('admin_star.png', get_lang('Admin')); break; case GROUP_USER_PERMISSION_READER: - $user['link'] = ''.Display::return_icon('delete.png', get_lang('DeleteFromGroup')).'
'. - ''.Display::return_icon('delete.png', get_lang('LikeModerator')).''; + $user['link'] = ''.Display::return_icon('del_user_big.gif', get_lang('DeleteFromGroup')).'
'. + ''.Display::return_icon('admins.gif', get_lang('AddModerator')).''; break; case GROUP_USER_PERMISSION_PENDING_INVITATION: $user['link'] = ''.Display::return_icon('pending_invitation.png', get_lang('PendingInvitation')).''; + break; + case GROUP_USER_PERMISSION_MODERATOR: + $user['link'] = Display::return_icon('moderator_star.png', get_lang('Moderator')); break; } $new_member_list[] = $user; diff --git a/main/social/groups.php b/main/social/groups.php index 9a455d96b7..a6919b4bd5 100755 --- a/main/social/groups.php +++ b/main/social/groups.php @@ -1,13 +1,19 @@ + */ + +$language_file = array('userInfo'); require_once '../inc/global.inc.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).'social.lib.php'; require_once api_get_path(LIBRARY_PATH).'message.lib.php'; +api_block_anonymous_users(); + $this_section = SECTION_SOCIAL; $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social')); @@ -24,8 +30,7 @@ $group_id = intval($_GET['id']); $group_info = GroupPortalManager::get_group_data($group_id); -if ($group_id != 0 ) { - +if ($group_id != 0 ) { //Loading group information if (isset($_GET['status']) && $_GET['status']=='sent') { Display::display_confirmation_message(get_lang('MessageHasBeenSent'), false); @@ -56,6 +61,7 @@ if ($group_id != 0 ) { $picture = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],160,'medium_'); $tags = GroupPortalManager::get_group_tags($group_id, true); $users = GroupPortalManager::get_users_by_group($group_id, true); + //my relation with the group is set here if (is_array($users[api_get_user_id()]) && count($users[api_get_user_id()]) > 0) { @@ -70,12 +76,15 @@ if ($group_id != 0 ) { $my_group_role = GROUP_USER_PERMISSION_ANONYMOUS; } - + //@todo this must be move to default.css for dev use only echo ''; echo '
'; @@ -122,7 +131,13 @@ if ($group_id != 0 ) { if ($user['relation_type'] == GROUP_USER_PERMISSION_ADMIN) { $user['lastname'].= Display::return_icon('admin_star.png', get_lang('Admin')); } - echo ''; + if ($user['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) { + $user['lastname'].= Display::return_icon('moderator_star.png', get_lang('Moderator')); + } + + echo ''; } } echo '
'; @@ -144,6 +159,9 @@ if ($group_id != 0 ) { case GROUP_USER_PERMISSION_PENDING_INVITATION: echo get_lang('PendingApproval'); break; + case GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER: + echo get_lang('PendingApproval'); + break; case GROUP_USER_PERMISSION_MODERATOR: echo ''.get_lang('MemberList').''; echo ''.get_lang('InviteFriends').''; diff --git a/main/social/home.php b/main/social/home.php index 35a08bbbfe..bf4bef916a 100755 --- a/main/social/home.php +++ b/main/social/home.php @@ -1,11 +1,10 @@ -* @package dokeos.social -*/ - + * @package dokeos.social + * @author Julio Montoya + */ + $language_file = array('registration','messages','userInfo','admin','forum','blog'); $cidReset = true; require '../inc/global.inc.php'; diff --git a/main/social/index.php b/main/social/index.php index ad2c91a1e7..72beaaf298 100755 --- a/main/social/index.php +++ b/main/social/index.php @@ -1,6 +1,10 @@ + */ + $cidReset = true; $language_file = array('registration','messages','userInfo','admin'); require '../inc/global.inc.php'; diff --git a/main/social/invitations.php b/main/social/invitations.php index 98ea9a0ff4..c51a90f76f 100755 --- a/main/social/invitations.php +++ b/main/social/invitations.php @@ -1,12 +1,16 @@ + */ +$language_file = array('messages','userInfo'); require '../inc/global.inc.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).'social.lib.php'; require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php'; + $this_section = SECTION_SOCIAL; $interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social')); @@ -61,9 +65,33 @@ SocialManager::show_social_menu(); echo '
'; echo get_lang('Invitations'); echo '
'; - +// 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_comment = get_lang('SocialInvitesComment'); //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_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,true); +$pending_invitations = GroupPortalManager::get_groups_by_user($user_id, GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER,true); $number_loop=count($list_get_invitation); @@ -89,9 +116,7 @@ echo ''; -if ($number_loop==0) { - Display::display_normal_message(get_lang('NoPendingInvitations')); -} else { +if ($number_loop != 0) { echo '

'.get_lang('InvitationReceived').'

'; foreach ($list_get_invitation as $invitation) { @@ -176,8 +201,18 @@ if (count($list_get_invitation_sent) > 0 ){ } if (count($pending_invitations) > 0) { + echo '

'.get_lang('GroupsWaitingApproval').'

'; - 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'] = ''.$invitation['picture_uri'].''; + $invitation['name'] = ''.$invitation['name'].''; + $invitation['join'] = ''.get_lang('AcceptInvitation').''; + $invitation['deny'] = ''.get_lang('DenyInvitation').''; + $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(); diff --git a/main/social/profile.php b/main/social/profile.php index b9708dbec7..538d9f6da4 100755 --- a/main/social/profile.php +++ b/main/social/profile.php @@ -272,58 +272,50 @@ echo '
'; if ($show_full_profile) { $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); - $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); - - $friend_html=''; - $number_of_images=3; - $number_friends=0; - $list_friends_id=array(); - $list_friends_dir=array(); - $list_friends_file=array(); - - 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); - $loop_friends = ceil($number_loop); + //SOCIALGOODFRIEND , SOCIALFRIEND, SOCIALPARENT + + $friends = SocialManager::get_friends($user_id, SOCIALFRIEND); + + $friend_html = ''; + $number_of_images = 3; + $number_friends = 0; + $list_friends_id = array(); + $number_friends = count($friends); + $number_of_images = $number_friends; + if ($number_friends != 0) { + $number_loop = ($number_friends/$number_of_images); + $loop_friends = ceil($number_loop); $j=0; - $friend_html .= '
'.get_lang('SocialFriend').'
'; - $friend_html.= '
: + : : :

'.get_lang('SubscribeUsersToGroup').''; + echo ''; ?>