'.get_lang('Messages').'
diff --git a/main/inc/banner.inc.php b/main/inc/banner.inc.php
index 4ceb0f6332..1d3a5c6c73 100644
--- a/main/inc/banner.inc.php
+++ b/main/inc/banner.inc.php
@@ -233,6 +233,16 @@ if ($_user['user_id'] && !api_is_anonymous()) {
$menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];
}
}
+
+
+ // Social Networking
+ //if (api_get_setting('show_tabs', 'social') == 'true') {
+ if (1) {
+ $navigation['social'] = $possible_tabs['social'];
+ } else{
+ $menu_navigation['social'] = $possible_tabs['social'];
+ }
+
if(api_is_platform_admin(true)) {
@@ -520,6 +530,13 @@ function get_tabs() {
$navigation['session_my_progress']['url'] = api_get_path(WEB_CODE_PATH).'auth/my_progress.php';
$navigation['session_my_progress']['title'] = get_lang('MyProgress');
}
+
+ // Social
+ if (api_get_setting('allow_social_tool')=='true') {
+ $navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/profile.php';
+ $navigation['social']['title'] = get_lang('SocialNetwork');
+ }
+
// Platform administration
if (api_is_platform_admin(true)) {
diff --git a/main/inc/header.inc.php b/main/inc/header.inc.php
index a6764d1933..9d53f87b19 100644
--- a/main/inc/header.inc.php
+++ b/main/inc/header.inc.php
@@ -219,4 +219,4 @@ include(api_get_path(LIBRARY_PATH).'/javascript/email_links.lib.js.php');
set_additional_parameters($query_vars);
}
- foreach ($header as $index => $header_item)
- {
- $table->set_header($index, $header_item[0], $header_item[1], $header_item[2], $header_item[3]);
- }
- $table->set_form_actions($form_actions);
- if ($style=='table')
- $table->display();
- else
- $table->display_grid();
+ if ($style=='table') {
+ if (is_array($header) && count($header)>0 ) {
+ foreach ($header as $index => $header_item) {
+ $table->set_header($index, $header_item[0], $header_item[1], $header_item[2], $header_item[3]);
+ }
+ }
+ $table->set_form_actions($form_actions);
+ $table->display();
+ } else {
+ $table->display_grid();
+ }
+ }
+ /**
+ * Shows a nice grid
+ * @param string grid name (important to create css)
+ * @param array header content
+ * @param array array with the information to show
+ * @param array $paging_options Keys are:
+ * 'per_page_default' = items per page when switching from
+ * full- list to per-page-view
+ * 'per_page' = number of items to show per page
+ * 'page_nr' = The page to display
+ * 'hide_navigation' = true to hide the navigation
+ * @param array $query_vars Additional variables to add in the query-string
+ * @param array $form actions Additional variables to add in the query-string
+ * @param mixed An array with bool values to know which columns show. i.e: $vibility_options= array(true, false) we will only show the first column
+ * Can be also only a bool value. TRUE: show all columns, FALSE: show nothing
+ */
+
+ public static function display_sortable_grid ($name, $header, $content, $paging_options = array (), $query_vars = null, $form_actions=array(), $vibility_options = true) {
+ global $origin;
+ $column = 0;
+ $default_items_per_page = isset ($paging_options['per_page']) ? $paging_options['per_page'] : 20;
+ $table = new SortableTableFromArray($content, $column, $default_items_per_page, $name);
+ if (is_array($query_vars)) {
+ $table->set_additional_parameters($query_vars);
+ }
+ $table->display_simple_grid($vibility_options, $paging_options['hide_navigation']);
}
+
/**
diff --git a/main/inc/lib/group_portal_manager.lib.php b/main/inc/lib/group_portal_manager.lib.php
new file mode 100755
index 0000000000..54250239fa
--- /dev/null
+++ b/main/inc/lib/group_portal_manager.lib.php
@@ -0,0 +1,1054 @@
+,
+ *
+ * @param string The URL of the site
+ * @param string The description of the site
+ * @param int is active or not
+ * @param int the user_id of the owner
+ * @return boolean if success
+ */
+ function add($name, $description, $url, $visibility, $picture='')
+ {
+ $tms = time();
+ $table = Database :: get_main_table(TABLE_MAIN_GROUP);
+ $sql = "INSERT INTO $table
+ SET name = '".Database::escape_string($name)."',
+ description = '".Database::escape_string($description)."',
+ picture_uri = '".Database::escape_string($picture)."',
+ url = '".Database::escape_string($url)."',
+ visibility = '".Database::escape_string($visibility)."',
+ created_on = FROM_UNIXTIME(".$tms."),
+ updated_on = FROM_UNIXTIME(".$tms.")";
+ $result = Database::query($sql, __FILE__, __LINE__);
+ $return = Database::insert_id();
+ return $return;
+ }
+
+ /**
+ * Updates a group
+ * @author Julio Montoya
,
+ *
+ * @param int The id
+ * @param string The description of the site
+ * @param int is active or not
+ * @param int the user_id of the owner
+ * @return boolean if success
+ */
+ function update($group_id, $name, $description, $url, $visibility, $picture_uri)
+ {
+ $group_id = intval($group_id);
+ $table = Database::get_main_table(TABLE_MAIN_GROUP);
+ $tms = time();
+ $sql = "UPDATE $table
+ SET name = '".Database::escape_string($name)."',
+ description = '".Database::escape_string($description)."',
+ picture_uri = '".Database::escape_string($picture_uri)."',
+ url = '".Database::escape_string($url)."',
+ visibility = '".Database::escape_string($visibility)."',
+ updated_on = FROM_UNIXTIME(".$tms.")
+ WHERE id = '$group_id'";
+ $result = Database::query($sql, __FILE__, __LINE__);
+ return $result;
+ }
+
+
+ /**
+ * Deletes a group
+ * @author Julio Montoya
+ * @param int id
+ * @return boolean true if success
+ * */
+ function delete($id)
+ {
+ $id = intval($id);
+ $table = Database :: get_main_table(TABLE_MAIN_GROUP);
+ $sql= "DELETE FROM $table WHERE id = ".Database::escape_string($id);
+ $result = Database::query($sql, __FILE__, __LINE__);
+ return $result;
+ }
+
+ /**
+ *
+ * */
+ 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)."' ";
+ $res = Database::query($sql,__FILE__,__LINE__);
+ $num = Database::num_rows($res);
+ return $num;
+ }
+
+ /**
+ *
+ * */
+ 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)."' ";
+ $res = Database::query($sql,__FILE__,__LINE__);
+ $num = Database::num_rows($res);
+ return $num;
+ }
+
+ /**
+ * This function get the quantity of URLs
+ * @author Julio Montoya
+ * @return int count of urls
+ * */
+ 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";
+ $res = Database::query($sql, __FILE__, __LINE__);
+ $url = Database::fetch_array($res,'ASSOC');
+ $result = $url['count_result'];
+ return $result;
+ }
+
+ /**
+ * Gets the id, url, description, and active status of ALL URLs
+ * @author Julio Montoya
+ * @return array
+ * */
+ 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";
+ $res = Database::query($sql, __FILE__, __LINE__);
+ $urls = array ();
+ while ($url = Database::fetch_array($res)) {
+ $urls[] = $url;
+ }
+ return $urls;
+ }
+
+ /**
+ * Gets data of all groups
+ * @author Julio Montoya
+ * @return array
+ * */
+ 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);
+ $user_condition = '';
+ $sql = "SELECT name, description, picture_uri FROM $table WHERE visibility = $visibility ";
+ $res = Database::query($sql, __FILE__, __LINE__);
+ $data = array ();
+ while ($item = Database::fetch_array($res)) {
+ $data[] = $item;
+ }
+ return $data;
+ }
+
+ function get_group_data($group_id)
+ {
+ $table = Database :: get_main_table(TABLE_MAIN_GROUP);
+ $group_id = intval($group_id);
+ $user_condition = '';
+ $sql = "SELECT name, description, picture_uri, visibility FROM $table WHERE id = $group_id ";
+ $res = Database::query($sql, __FILE__, __LINE__);
+ $item = array();
+ if (Database::num_rows($res)>0) {
+ $item = Database::fetch_array($res,'ASSOC');
+ }
+ return $item;
+ }
+
+ 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);
+ $group_id = intval($group_id);
+ $user_condition = '';
+
+ $sql = "SELECT tag FROM $tag t INNER JOIN $table_group_rel_tag gt ON (gt.tag_id= t.id) WHERE gt.group_id = $group_id ";
+ $res = Database::query($sql, __FILE__, __LINE__);
+ $tags = array();
+ if (Database::num_rows($res)>0) {
+ while ($row = Database::fetch_array($res,'ASSOC')) {
+ $tags[] = $row;
+ }
+ }
+
+ if ($show_tag_links == true) {
+ if (is_array($tags) && count($tags)>0) {
+ foreach ($tags as $tag) {
+ $tag_tmp[] = ''.$tag['tag'].' ';
+ }
+ if (is_array($tags) && count($tags)>0) {
+ $tags= implode(', ',$tag_tmp);
+ }
+ } else {
+ $tags = '';
+ }
+ }
+ return $tags;
+ }
+
+
+
+ /**
+ * Gets the id, url, description, and active status of ALL URLs
+ * @author Julio Montoya
+ * @return array
+ * */
+ 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);
+ $res = Database::query($sql, __FILE__, __LINE__);
+ $row = Database::fetch_array($res);
+ return $row;
+ }
+
+ /** Gets the inner join of 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)
+ {
+ $where = '';
+ $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
+ $tbl_group = Database::get_main_table(TABLE_MAIN_GROUP);
+ $user_id = intval($user_id);
+
+ if ($relation_type == 0) {
+ $where_relation_condition = '';
+ } else {
+ $relation_type = intval($relation_type);
+ $where_relation_condition = "AND gu.relation_type = $relation_type ";
+ }
+
+ $sql = "SELECT g.picture_uri, g.name, g.description, g.id
+ FROM $tbl_group g
+ INNER JOIN $table_group_rel_user gu
+ ON gu.group_id = g.id WHERE gu.user_id = $user_id $where_relation_condition ";
+
+ $result=Database::query($sql,__FILE__,__LINE__);
+ $array = array();
+ while ($row = Database::fetch_array($result, 'ASSOC')) {
+ if ($with_image == true) {
+ $picture = self::get_picture_group($row['id'], $row['picture_uri'],80);
+ $img = ' ';
+ $row['picture_uri'] = $img;
+ }
+ $array[$row['id']] = $row;
+ }
+ return $array;
+ }
+
+ function get_users_by_group($group_id='', $with_image = false)
+ {
+ $where = '';
+ $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
+ $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
+ $group_id = intval($group_id);
+
+ if ($relation_type == 0) {
+ $where_relation_condition = '';
+ } else {
+ $relation_type = intval($relation_type);
+ $where_relation_condition = "AND gu.relation_type = $relation_type ";
+ }
+
+ $sql="SELECT u.user_id, u.firstname, u.lastname, picture_uri, relation_type FROM $tbl_user u
+ INNER JOIN $table_group_rel_user gu
+ ON (gu.user_id = u.user_id) WHERE gu.group_id= $group_id $where_relation_condition ORDER BY relation_type, firstname";
+
+ $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);
+ $img = ' ';
+ $row['picture_uri'] = $img;
+ }
+ $array[$row['user_id']] = $row;
+ }
+ return $array;
+ }
+
+
+
+ /** Gets the inner join of access_url and the course table
+ * @author Julio Montoya
+ * @return int access url id
+ * @return array Database::store_result of the result
+ * */
+ function get_url_rel_course_data($access_url_id='')
+ {
+ $where ='';
+ $table_url_rel_course = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
+ $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
+
+ if (!empty($access_url_id))
+ $where ="WHERE $table_url_rel_course.access_url_id = ".Database::escape_string($access_url_id);
+
+ $sql="SELECT course_code, title, access_url_id
+ FROM $tbl_course u
+ INNER JOIN $table_url_rel_course
+ ON $table_url_rel_course.course_code = code
+ $where
+ ORDER BY title, code";
+
+ $result=Database::query($sql,__FILE__,__LINE__);
+ $courses=Database::store_result($result);
+ return $courses;
+ }
+
+ /** Gets the inner join of access_url and the session table
+ * @author Julio Montoya
+ * @return int access url id
+ * @return array Database::store_result of the result
+ * */
+ function get_url_rel_session_data($access_url_id='')
+ {
+ $where ='';
+ $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
+ $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
+
+ if (!empty($access_url_id))
+ $where ="WHERE $table_url_rel_session.access_url_id = ".Database::escape_string($access_url_id);
+
+ $sql="SELECT id, name, access_url_id
+ FROM $tbl_session u
+ INNER JOIN $table_url_rel_session
+ ON $table_url_rel_session.session_id = id
+ $where
+ ORDER BY name, id";
+
+ $result=Database::query($sql,__FILE__,__LINE__);
+ $sessions=Database::store_result($result);
+ return $sessions;
+ }
+
+
+
+ /**
+ * Sets the status of an URL 1 or 0
+ * @author Julio Montoya
+ * @param string lock || unlock
+ * @param int url id
+ * */
+ function set_url_status($status, $url_id)
+ {
+ $url_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
+ if ($status=='lock') {
+ $status_db='0';
+ }
+ if ($status=='unlock') {
+ $status_db='1';
+ }
+ if(($status_db=='1' OR $status_db=='0') AND is_numeric($url_id)) {
+ $sql="UPDATE $url_table SET active='".Database::escape_string($status_db)."' WHERE id='".Database::escape_string($url_id)."'";
+ $result = Database::query($sql, __FILE__, __LINE__);
+ }
+ }
+
+ /**
+ * Gets the relationship between a group and a User
+ * @author Julio Montoya
+ * @param int user id
+ * @param int group_id
+ * @return boolean true if success
+ * */
+ 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;
+ if (!empty($user_id) && !empty($group_id)) {
+ $sql = "SELECT relation_type FROM $table_group_rel_user WHERE id = ".intval($group_id)." AND user_id = ".intval($user_id)." ";
+ $result = Database::query($sql, __FILE__, __LINE__);
+ if (Database::num_rows($result)>0) {
+ $row = Database::fetch_row($result);
+ $return_value = $row['relation_type'];
+ }
+ }
+ return $return_value;
+ }
+
+ /**
+ * Checks the relationship between an URL and a Course (return the num_rows)
+ * @author Julio Montoya
+ * @param int user id
+ * @param int url id
+ * @return boolean true if success
+ * */
+ 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)."'";
+ $result = Database::query($sql, __FILE__, __LINE__);
+ $num = Database::num_rows($result);
+ return $num;
+ }
+
+
+ /**
+ * Checks the relationship between an URL and a Session (return the num_rows)
+ * @author Julio Montoya
+ * @param int user id
+ * @param int url id
+ * @return boolean true if success
+ * */
+ function relation_url_session_exist($session_id, $url_id)
+ {
+ $table_url_rel_session= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
+ $sql= "SELECT session_id FROM $table_url_rel_session WHERE access_url_id = ".Database::escape_string($url_id)." AND session_id = ".Database::escape_string($session_id);
+ $result = Database::query($sql, __FILE__, __LINE__);
+ $num = Database::num_rows($result);
+ return $num;
+ }
+
+
+ /**
+ * Add a group of users into a group of URLs
+ * @author Julio Montoya
+ * @param array of user_ids
+ * @param array of url_ids
+ * */
+ function add_users_to_urls($user_list, $url_list)
+ {
+ $table_url_rel_user= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
+ $result_array=array();
+
+ if (is_array($user_list) && is_array($url_list)){
+ foreach ($url_list as $url_id) {
+ foreach ($user_list as $user_id) {
+ $count = UrlManager::relation_url_user_exist($user_id,$url_id);
+ if ($count==0) {
+ $sql = "INSERT INTO $table_url_rel_user
+ SET user_id = ".Database::escape_string($user_id).", access_url_id = ".Database::escape_string($url_id);
+ $result = Database::query($sql, __FILE__, __LINE__);
+ if($result)
+ $result_array[$url_id][$user_id]=1;
+ else
+ $result_array[$url_id][$user_id]=0;
+ }
+ }
+ }
+ }
+ return $result_array;
+ }
+
+
+ /**
+ * Add a group of courses into a group of URLs
+ * @author Julio Montoya
+ * @param array of course ids
+ * @param array of url_ids
+ * */
+ function add_courses_to_urls($course_list,$url_list)
+ {
+ $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
+ $result_array=array();
+
+ if (is_array($course_list) && is_array($url_list)){
+ foreach ($url_list as $url_id) {
+ foreach ($course_list as $course_code) {
+ $count = UrlManager::relation_url_course_exist($course_code,$url_id);
+ if ($count==0) {
+ $sql = "INSERT INTO $table_url_rel_course
+ SET course_code = '".Database::escape_string($course_code)."', access_url_id = ".Database::escape_string($url_id);
+ $result = Database::query($sql, __FILE__, __LINE__);
+ if($result)
+ $result_array[$url_id][$course_code]=1;
+ else
+ $result_array[$url_id][$course_code]=0;
+ }
+ }
+ }
+ }
+ return $result_array;
+ }
+
+
+ /**
+ * Add a group of sessions into a group of URLs
+ * @author Julio Montoya
+ * @param array of session ids
+ * @param array of url_ids
+ * */
+ function add_sessions_to_urls($session_list,$url_list)
+ {
+ $table_url_rel_session= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
+ $result_array=array();
+
+ if (is_array($session_list) && is_array($url_list)){
+ foreach ($url_list as $url_id) {
+ foreach ($session_list as $session_id) {
+ $count = UrlManager::relation_url_session_exist($session_id,$url_id);
+ if ($count==0) {
+ $sql = "INSERT INTO $table_url_rel_session
+ SET session_id = ".Database::escape_string($session_id).", access_url_id = ".Database::escape_string($url_id);
+ $result = Database::query($sql, __FILE__, __LINE__);
+ if($result)
+ $result_array[$url_id][$session_id]=1;
+ else
+ $result_array[$url_id][$session_id]=0;
+ }
+ }
+ }
+ }
+ return $result_array;
+ }
+
+
+
+ /**
+ * Add a user into a url
+ * @author Julio Montoya
+ * @param user_id
+ * @param url_id
+ * @return boolean true if success
+ * */
+ 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)) {
+ $role = self::get_user_group_role($user_id,$group_id);
+ 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__);
+ }
+ }
+ return $result;
+ }
+
+ function add_course_to_url($course_code, $url_id=1)
+ {
+ $table_url_rel_course= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
+ if (empty($url_id)) $url_id=1;
+ $count = UrlManager::relation_url_course_exist($course_code,$url_id);
+ if (empty($count)) {
+ $sql = "INSERT INTO $table_url_rel_course
+ SET course_code = '".Database::escape_string($course_code)."', access_url_id = ".Database::escape_string($url_id);
+ $result = Database::query($sql, __FILE__, __LINE__);
+ }
+ return $result;
+ }
+
+
+ function add_session_to_url($session_id, $url_id=1)
+ {
+ $table_url_rel_session= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
+ if (empty($url_id)) $url_id=1;
+ $count = UrlManager::relation_url_session_exist($session_id,$url_id);
+ if (empty($count)) {
+ $sql = "INSERT INTO $table_url_rel_session
+ SET session_id = ".Database::escape_string($session_id).", access_url_id = ".Database::escape_string($url_id);
+ $result = Database::query($sql, __FILE__, __LINE__);
+ }
+ return $result;
+ }
+
+
+ /**
+ * Deletes an url and user relationship
+ * @author Julio Montoya
+ * @param int user id
+ * @param int url id
+ * @return boolean true if success
+ * */
+ function delete_url_rel_user($user_id, $url_id)
+ {
+ $table_url_rel_user= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
+ $sql= "DELETE FROM $table_url_rel_user WHERE user_id = ".Database::escape_string($user_id)." AND access_url_id=".Database::escape_string($url_id)." ";
+ $result = Database::query($sql, __FILE__, __LINE__);
+ return $result;
+ }
+
+ /**
+ * Deletes an url and course relationship
+ * @author Julio Montoya
+ * @param char course code
+ * @param int url id
+ * @return boolean true if success
+ * */
+ 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)." ";
+ $result = Database::query($sql, __FILE__, __LINE__);
+ return $result;
+ }
+
+ /**
+ * Deletes an url and session relationship
+ * @author Julio Montoya
+ * @param char course code
+ * @param int url id
+ * @return boolean true if success
+ * */
+ function delete_url_rel_session($session_id, $url_id)
+ {
+ $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
+ $sql= "DELETE FROM $table_url_rel_session WHERE session_id = ".Database::escape_string($session_id)." AND access_url_id=".Database::escape_string($url_id)." ";
+ $result = Database::query($sql, __FILE__, __LINE__);
+ return $result;
+ }
+
+
+ /**
+ * Updates the access_url_rel_user table with a given user list
+ * @author Julio Montoya
+ * @param array user list
+ * @param int access_url_id
+ * */
+ 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);
+
+ $sql = "SELECT user_id FROM $table_url_rel_user WHERE access_url_id=".Database::escape_string($access_url_id);
+ $result = Database::query($sql,__FILE__,__LINE__ );
+ $existingUsers = array();
+
+ while($row = Database::fetch_array($result)){
+ $existingUsers[] = $row['user_id'];
+ }
+
+ //adding users
+ foreach($user_list as $enreg_user) {
+ if(!in_array($enreg_user, $existingUsers)) {
+ UrlManager::add_user_to_url($enreg_user,$access_url_id);
+ }
+ }
+ //deleting old users
+ foreach($existingUsers as $existing_user) {
+ if(!in_array($existing_user, $user_list)) {
+ UrlManager::delete_url_rel_user($existing_user,$access_url_id);
+ }
+ }
+ }
+
+
+ /**
+ * Updates the access_url_rel_course table with a given user list
+ * @author Julio Montoya
+ * @param array user list
+ * @param int access_url_id
+ * */
+ 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);
+
+ $sql = "SELECT course_code FROM $table_url_rel_course WHERE access_url_id=".Database::escape_string($access_url_id);
+ $result = Database::query($sql,__FILE__,__LINE__ );
+ $existing_courses = array();
+
+ while($row = Database::fetch_array($result)){
+ $existing_courses[] = $row['course_code'];
+ }
+
+ //adding courses
+ foreach($course_list as $course) {
+ if(!in_array($course, $existing_courses)) {
+ UrlManager::add_course_to_url($course,$access_url_id);
+ }
+ }
+
+ //deleting old courses
+ foreach($existing_courses as $existing_course) {
+ if(!in_array($existing_course, $course_list)) {
+ UrlManager::delete_url_rel_course($existing_course,$access_url_id);
+ }
+ }
+ }
+
+ /**
+ * Updates the access_url_rel_session table with a given user list
+ * @author Julio Montoya
+ * @param array user list
+ * @param int access_url_id
+ * */
+ function update_urls_rel_session($session_list,$access_url_id)
+ {
+ $table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
+ $table_url_rel_session = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
+
+ $sql = "SELECT session_id FROM $table_url_rel_session WHERE access_url_id=".Database::escape_string($access_url_id);
+ $result = Database::query($sql,__FILE__,__LINE__ );
+ $existing_sessions = array();
+
+ while($row = Database::fetch_array($result)){
+ $existing_sessions[] = $row['session_id'];
+ }
+
+ //adding users
+ foreach($session_list as $session) {
+ if(!in_array($session, $existing_sessions)) {
+ UrlManager::add_session_to_url($session,$access_url_id);
+ }
+ }
+
+ //deleting old users
+ foreach($existing_sessions as $existing_session) {
+ if(!in_array($existing_session, $session_list)) {
+ UrlManager::delete_url_rel_session($existing_session,$access_url_id);
+ }
+ }
+ }
+
+
+ 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
+ ON (url_rel_user.access_url_id = u.id)
+ WHERE user_id = ".Database::escape_string($user_id);
+ $result = Database::query($sql, __FILE__, __LINE__);
+ $url_list = Database::store_result($result);
+ return $url_list;
+ }
+
+ /**
+ *
+ * */
+ 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)."'";
+ $result = Database::query($sql);
+ $access_url_id = Database::result($result, 0, 0);
+ return $access_url_id;
+ }
+
+
+ public static function get_all_group_tags($tag, $from=0, $number_of_items=10) {
+ // database table definition
+
+ $group_table = Database::get_main_table(TABLE_MAIN_GROUP);
+ $table_tag = Database::get_main_table(TABLE_MAIN_TAG);
+ $table_group_tag_values = Database::get_main_table(TABLE_MAIN_GROUP_REL_TAG);
+
+ //default field_id == 1
+
+ $field_id = 5;
+
+ $tag = Database::escape_string($tag);
+ $from = intval($from);
+ $number_of_items = intval($number_of_items);
+
+ // all the information of the field
+ $sql = "SELECT g.id, g.name, g.description, g.picture_uri FROM $table_tag t INNER JOIN $table_group_tag_values tv ON (tv.tag_id=t.id)
+ INNER JOIN $group_table g ON(tv.group_id =g.id)
+ WHERE tag LIKE '$tag%' AND field_id= $field_id ORDER BY tag";
+
+ $sql .= " LIMIT $from,$number_of_items";
+
+ $result = Database::query($sql, __FILE__, __LINE__);
+ $return = array();
+ if (Database::num_rows($result)> 0) {
+ while ($row = Database::fetch_array($result,'ASSOC')) {
+ $return[$row['id']] = $row;
+ }
+ }
+
+ $keyword = $tag;
+ $sql = "SELECT g.id, g.name, g.description, g.url, g.picture_uri FROM $group_table g";
+
+ //@todo implement groups + multiple urls
+
+ /*
+ global $_configuration;
+ if ($_configuration['multiple_access_urls']==true && api_get_current_access_url_id()!=-1) {
+ $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
+ $sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
+ }*/
+
+ //@todo implement visibility
+
+ if (isset ($keyword)) {
+ $keyword = Database::escape_string($keyword);
+ $sql .= " WHERE (g.name LIKE '%".$keyword."%' OR g.description LIKE '%".$keyword."%' OR g.url LIKE '%".$keyword."%' )";
+ }
+
+ $direction = 'ASC';
+ if (!in_array($direction, array('ASC','DESC'))) {
+ $direction = 'ASC';
+ }
+
+ $column = intval($column);
+ $from = intval($from);
+ $number_of_items = intval($number_of_items);
+
+ //$sql .= " ORDER BY col$column $direction ";
+ $sql .= " LIMIT $from,$number_of_items";
+
+ $res = Database::query($sql, __FILE__, __LINE__);
+ if (Database::num_rows($res)> 0) {
+ while ($row = Database::fetch_array($res,'ASSOC')) {
+ if (!in_array($row['id'], $return)) {
+ $return[$row['id']] = $row;
+ }
+ }
+ }
+ return $return;
+ }
+
+
+ /**
+ * Creates new user pfotos in various sizes of a user, or deletes user pfotos.
+ * Note: This method relies on configuration setting from dokeos/main/inc/conf/profile.conf.php
+ * @param int $user_id The user internal identitfication number.
+ * @param string $file The common file name for the newly created pfotos. It will be checked and modified for compatibility with the file system.
+ * If full name is provided, path component is ignored.
+ * If an empty name is provided, then old user photos are deleted only, @see UserManager::delete_user_picture() as the prefered way for deletion.
+ * @param string $source_file The full system name of the image from which user photos will be created.
+ * @return string/bool Returns the resulting common file name of created images which usually should be stored in database.
+ * When deletion is recuested returns empty string. In case of internal error or negative validation returns FALSE.
+ */
+ public static function update_group_picture($group_id, $file = null, $source_file = null) {
+
+ // Validation 1.
+ if (empty($group_id)) {
+ return false;
+ }
+ $delete = empty($file);
+ if (empty($source_file)) {
+ $source_file = $file;
+ }
+
+ // Configuration options about user photos.
+ require_once api_get_path(CONFIGURATION_PATH).'profile.conf.php';
+
+ // User-reserved directory where photos have to be placed.
+ $path_info = self::get_group_picture_path_by_id($group_id, 'system', true);
+ $path = $path_info['dir'];
+ // If this directory does not exist - we create it.
+ if (!file_exists($path)) {
+ $perm = api_get_setting('permissions_for_new_directories');
+ $perm = octdec(!empty($perm) ? $perm : '0770');
+ @mkdir($path, $perm, true);
+ }
+
+ // The old photos (if any).
+ $old_file = $path_info['file'];
+
+ // Let us delete them.
+ if (!empty($old_file)) {
+ if (KEEP_THE_OLD_IMAGE_AFTER_CHANGE) {
+ $prefix = 'saved_'.date('Y_m_d_H_i_s').'_'.uniqid('').'_';
+ @rename($path.'small_'.$old_file, $path.$prefix.'small_'.$old_file);
+ @rename($path.'medium_'.$old_file, $path.$prefix.'medium_'.$old_file);
+ @rename($path.'big_'.$old_file, $path.$prefix.'big_'.$old_file);
+ @rename($path.$old_file, $path.$prefix.$old_file);
+ } else {
+ @unlink($path.'small_'.$old_file);
+ @unlink($path.'medium_'.$old_file);
+ @unlink($path.'big_'.$old_file);
+ @unlink($path.$old_file);
+ }
+ }
+
+ // Exit if only deletion has been requested. Return an empty picture name.
+ if ($delete) {
+ return '';
+ }
+
+ // Validation 2.
+ $allowed_types = array('jpg', 'jpeg', 'png', 'gif');
+ $file = str_replace('\\', '/', $file);
+ $filename = (($pos = strrpos($file, '/')) !== false) ? substr($file, $pos + 1) : $file;
+ $extension = strtolower(substr(strrchr($filename, '.'), 1));
+ if (!in_array($extension, $allowed_types)) {
+ return false;
+ }
+
+ // This is the common name for the new photos.
+ if (KEEP_THE_NAME_WHEN_CHANGE_IMAGE && !empty($old_file)) {
+ $old_extension = strtolower(substr(strrchr($old_file, '.'), 1));
+ $filename = in_array($old_extension, $allowed_types) ? substr($old_file, 0, -strlen($old_extension)) : $old_file;
+ $filename = (substr($filename, -1) == '.') ? $filename.$extension : $filename.'.'.$extension;
+ } else {
+ $filename = replace_dangerous_char($filename);
+ if (PREFIX_IMAGE_FILENAME_WITH_UID) {
+ $filename = uniqid('').'_'.$filename;
+ }
+ // We always prefix user photos with user ids, so on setting
+ // api_get_setting('split_users_upload_directory') === 'true'
+ // the correspondent directories to be found successfully.
+ $filename = $group_id.'_'.$filename;
+ }
+
+ // Storing the new photos in 4 versions with various sizes.
+
+ $picture_info = @getimagesize($source_file);
+ $type = $picture_info[2];
+ $small = self::resize_picture($source_file, 22);
+ $medium = self::resize_picture($source_file, 85);
+ $normal = self::resize_picture($source_file, 200);
+ $big = new image($source_file); // This is the original picture.
+
+ $ok = false;
+ $detected = array(1 => 'GIF', 2 => 'JPG', 3 => 'PNG');
+ if (in_array($type, array_keys($detected))) {
+ $ok = $small->send_image($detected[$type], $path.'small_'.$filename)
+ && $medium->send_image($detected[$type], $path.'medium_'.$filename)
+ && $normal->send_image($detected[$type], $path.$filename)
+ && $big->send_image($detected[$type], $path.'big_'.$filename);
+ }
+ return $ok ? $filename : false;
+ }
+
+ /**
+ * Get user picture URL or path from user ID (returns an array).
+ * The return format is a complete path, enabling recovery of the directory
+ * with dirname() or the file with basename(). This also works for the
+ * functions dealing with the user's productions, as they are located in
+ * the same directory.
+ * @param integer User ID
+ * @param string Type of path to return (can be 'none', 'system', 'rel', 'web')
+ * @param bool Whether we want to have the directory name returned 'as if' there was a file or not (in the case we want to know which directory to create - otherwise no file means no split subdir)
+ * @param bool If we want that the function returns the /main/img/unknown.jpg image set it at true
+ * @return array Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty er's
+ */
+ public static function get_group_picture_path_by_id($id, $type = 'none', $preview = false, $anonymous = false) {
+
+ switch ($type) {
+ case 'system': // Base: absolute system path.
+ $base = api_get_path(SYS_CODE_PATH);
+ break;
+ case 'rel': // Base: semi-absolute web path (no server base).
+ $base = api_get_path(REL_CODE_PATH);
+ break;
+ case 'web': // Base: absolute web path.
+ $base = api_get_path(WEB_CODE_PATH);
+ break;
+ case 'none':
+ default: // Base: empty, the result path below will be relative.
+ $base = '';
+ }
+
+ if (empty($id) || empty($type)) {
+ return $anonymous ? array('dir' => $base.'img/', 'file' => 'unknown.jpg') : array('dir' => '', 'file' => '');
+ }
+
+ $id = intval($id);
+
+ $group_table = Database :: get_main_table(TABLE_MAIN_GROUP);
+ $sql = "SELECT picture_uri FROM $group_table WHERE id=".$id;
+ $res = Database::query($sql, __FILE__, __LINE__);
+
+ if (!Database::num_rows($res)) {
+ return $anonymous ? array('dir' => $base.'img/', 'file' => 'unknown.jpg') : array('dir' => '', 'file' => '');
+ }
+
+ $user = Database::fetch_array($res);
+ $picture_filename = trim($user['picture_uri']);
+
+ if (api_get_setting('split_users_upload_directory') === 'true') {
+ if (!empty($picture_filename)) {
+ $dir = $base.'upload/users/groups/'.substr($picture_filename, 0, 1).'/'.$id.'/';
+ } elseif ($preview) {
+ $dir = $base.'upload/users/groups/'.substr((string)$id, 0, 1).'/'.$id.'/';
+ } else {
+ $dir = $base.'upload/users/groups/'.$id.'/';
+ }
+ } else {
+ $dir = $base.'upload/users/groups/'.$id.'/';
+ }
+ if (empty($picture_filename) && $anonymous) {
+ return array('dir' => $base.'img/', 'file' => 'unknown.jpg');
+ }
+ return array('dir' => $dir, 'file' => $picture_filename);
+ }
+
+ /**
+ * Resize a picture
+ *
+ * @param string file picture
+ * @param int size in pixels
+ * @return obj image object
+ */
+ public static function resize_picture($file, $max_size_for_picture) {
+ if (!class_exists('image')) {
+ require_once api_get_path(LIBRARY_PATH).'image.lib.php';
+ }
+ $temp = new image($file);
+ $picture_infos = api_getimagesize($file);
+ if ($picture_infos[0] > $max_size_for_picture) {
+ $thumbwidth = $max_size_for_picture;
+ if (empty($thumbwidth) or $thumbwidth == 0) {
+ $thumbwidth = $max_size_for_picture;
+ }
+ $new_height = round(($thumbwidth / $picture_infos[0]) * $picture_infos[1]);
+ if ($new_height > $max_size_for_picture)
+ $new_height = $thumbwidth;
+ $temp->resize($thumbwidth, $new_height, 0);
+ }
+ return $temp;
+ }
+ /**
+ * Gets the current user image
+ * @param string user id
+ * @param string picture user name
+ * @param string height
+ * @param string picture size it can be small_, medium_ or big_
+ * @param string style css
+ * @return array with the file and the style of an image i.e $array['file'] $array['style']
+ */
+ public static function get_picture_group($id, $picture_file, $height, $size_picture = 'medium_', $style = '') {
+ $patch_profile = 'upload/users/groups/';
+ $picture = array();
+ $picture['style'] = $style;
+ if ($picture_file == 'unknown.jpg') {
+ $picture['file'] = api_get_path(WEB_CODE_PATH).'img/'.$picture_file;
+ return $picture;
+ }
+ $image_array_sys = self::get_group_picture_path_by_id($id, 'system', false, true);
+ $image_array = self::get_group_picture_path_by_id($id, 'web', false, true);
+ $file = $image_array_sys['dir'].$size_picture.$picture_file;
+ if (file_exists($file)) {
+ $picture['file'] = $image_array['dir'].$size_picture.$picture_file;
+ $picture['style'] = '';
+ if ($height > 0) {
+ $dimension = api_getimagesize($picture['file']);
+ $margin = (($height - $dimension[1]) / 2);
+ //@ todo the padding-top should not be here
+ $picture['style'] = ' style="padding-top:'.$margin.'px; width:'.$dimension[0].'px; height:'.$dimension[1].';" ';
+ }
+ } else {
+ //$file = api_get_path(SYS_CODE_PATH).$patch_profile.$user_id.'/'.$picture_file;
+ $file = $image_array_sys['dir'].$picture_file;
+ if (file_exists($file) && !is_dir($file)) {
+ $picture['file'] = $image_array['dir'].$picture_file;
+ } else {
+ $picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_group.png';
+ }
+ }
+ return $picture;
+ }
+
+ public static function delete_group_picture($user_id) {
+ return self::update_group_picture($user_id);
+ }
+}
+?>
\ No newline at end of file
diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php
index 71521069c0..02b3589d80 100644
--- a/main/inc/lib/main_api.lib.php
+++ b/main/inc/lib/main_api.lib.php
@@ -143,6 +143,7 @@ define('SECTION_COURSE_ADMIN', 'course_admin');
define('SECTION_PLATFORM_ADMIN', 'platform_admin');
define('SECTION_MYGRADEBOOK', 'mygradebook');
define('SECTION_TRACKING','session_my_space');
+define('SECTION_SOCIAL', 'social');
// CONSTANT name for local authentication source
define('PLATFORM_AUTH_SOURCE', 'platform');
@@ -2285,8 +2286,6 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us
$time = date("Y-m-d H:i:s", $time);
if (!empty($session_id)) {
$session_id = intval($session_id);
- } else {
- $session_id = api_get_session_id();
}
// Definition of tables
diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php
index 9d6f5addbb..fb945a1d0d 100644
--- a/main/inc/lib/message.lib.php
+++ b/main/inc/lib/message.lib.php
@@ -25,70 +25,63 @@
require_once api_get_path(LIBRARY_PATH).'online.inc.php';
require_once api_get_path(SYS_CODE_PATH).'messages/message.class.php';
function inbox_display() {
- global $charset;
- echo ' ';
- //api_display_tool_title(api_xml_http_response_encode(get_lang('Inbox')));
- echo '
';
- echo '
';
- $charset = api_get_setting('platform_charset');
- $table_message = Database::get_main_table(TABLE_MESSAGE);
- $request=api_is_xml_http_request();
- if ($_SESSION['social_exist']===true) {
- $redirect="#remote-tab-2";
- if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true') {
- $success= get_lang('SelectedMessagesDeleted');
- } else {
- $success= get_lang('SelectedMessagesDeleted');
- }
+ global $charset;
+// $charset = api_get_setting('platform_charset');
+ $table_message = Database::get_main_table(TABLE_MESSAGE);
+ $request=api_is_xml_http_request();
+ if ($_SESSION['social_exist']===true) {
+ $redirect="#remote-tab-2";
+ if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true') {
+ $success= get_lang('SelectedMessagesDeleted');
} else {
$success= get_lang('SelectedMessagesDeleted');
}
- if (isset ($_REQUEST['action'])) {
- switch ($_REQUEST['action']) {
- case 'delete' :
- $number_of_selected_messages = count($_POST['id']);
- foreach ($_POST['id'] as $index => $message_id) {
- MessageManager::delete_message_by_user_receiver(api_get_user_id(), $message_id);
- }
- Display::display_normal_message(api_xml_http_response_encode($success),false);
- break;
- case 'deleteone' :
- MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_GET['id']);
- Display::display_confirmation_message(api_xml_http_response_encode($success),false);
- echo ' ';
- break;
- }
+ } else {
+ $success= get_lang('SelectedMessagesDeleted');
+ }
+ if (isset ($_REQUEST['action'])) {
+ switch ($_REQUEST['action']) {
+ case 'delete' :
+ $number_of_selected_messages = count($_POST['id']);
+ foreach ($_POST['id'] as $index => $message_id) {
+ MessageManager::delete_message_by_user_receiver(api_get_user_id(), $message_id);
+ }
+ Display::display_normal_message(api_xml_http_response_encode($success),false);
+ break;
+ case 'deleteone' :
+ MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_GET['id']);
+ Display::display_confirmation_message(api_xml_http_response_encode($success),false);
+ echo ' ';
+ break;
}
- // display sortable table with messages of the current user
- $table = new SortableTable('messages', 'get_number_of_messages_mask', 'get_message_data_mask', 3, get_number_of_messages_mask(),'DESC');
- $table->set_header(0, '', false,array ('style' => 'width:20px;'));
- $title=api_xml_http_response_encode(get_lang('Title'));
- $action=api_xml_http_response_encode(get_lang('Actions'));
- $table->set_header(1,api_xml_http_response_encode(get_lang('Status')),false,array('style' => 'width:30px;'));
- $table->set_header(2,api_xml_http_response_encode(get_lang('From')),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(5,$action,false,array ('style' => 'width:100px;'));
- echo '';
- if ($request===true) {
- echo '
';
- if (get_number_of_messages_mask() > 0) {
- echo '
'.api_xml_http_response_encode(get_lang('SelectAll')).' ';
- echo '
'.api_xml_http_response_encode(get_lang('UnSelectAll')).' ';
- echo '
'.api_xml_http_response_encode(get_lang('DeleteSelectedMessages')).' ';
+ }
+ // display sortable table with messages of the current user
+ $table = new SortableTable('messages', 'get_number_of_messages_mask', 'get_message_data_mask', 3, get_number_of_messages_mask(),'DESC');
+ $table->set_header(0, '', false,array ('style' => 'width:20px;'));
+ $title=api_xml_http_response_encode(get_lang('Title'));
+ $action=api_xml_http_response_encode(get_lang('Actions'));
+ $table->set_header(1,api_xml_http_response_encode(get_lang('Status')),false,array('style' => 'width:30px;'));
+ $table->set_header(2,api_xml_http_response_encode(get_lang('From')),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(5,$action,false,array ('style' => 'width:100px;'));
+ echo '
';
+ if ($request===true) {
+ echo '
';
+ if (get_number_of_messages_mask() > 0) {
+ echo '
'.api_xml_http_response_encode(get_lang('SelectAll')).' ';
+ echo '
'.api_xml_http_response_encode(get_lang('UnSelectAll')).' ';
+ echo '
'.api_xml_http_response_encode(get_lang('DeleteSelectedMessages')).' ';
- }
- } else {
- $table->set_form_actions(array ('delete' => get_lang('DeleteSelectedMessages')));
- $table->display();
}
- echo '
';
+ } else {
+ $table->set_form_actions(array ('delete' => get_lang('DeleteSelectedMessages')));
+ $table->display();
+ }
+ echo '
';
}
function get_number_of_messages_mask() {
return MessageManager::get_number_of_messages();
diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php
index c6032c5986..6f8a32e0d6 100755
--- a/main/inc/lib/social.lib.php
+++ b/main/inc/lib/social.lib.php
@@ -7,8 +7,9 @@ define(SOCIALFRIEND,3);
define(SOCIALGOODFRIEND,4);
define(SOCIALENEMY,5);
define(SOCIALDELETED,6);
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
-class UserFriend extends UserManager {
+class SocialManager extends UserManager {
private function __construct() {
@@ -332,4 +333,248 @@ class UserFriend extends UserManager {
}
}
}
+
+ /**
+ * Get user's feeds
+ * @param int User ID
+ * @param int Limit of posts per feed
+ * @return string HTML section with all feeds included
+ * @author Yannick Warnier
+ * @since Dokeos 1.8.6.1
+ */
+ function get_user_feeds($user,$limit=5) {
+ if (!function_exists('fetch_rss')) { return '';}
+ $fields = UserManager::get_extra_fields();
+ $feed_fields = array();
+ $feeds = array();
+ $res = ''.get_lang('RSSFeeds').'
';
+ $res .= '';
+ $feed = UserManager::get_extra_user_data_by_field($user,'rssfeeds');
+ if(empty($feed)) { return ''; }
+ $feeds = split(';',$feed['rssfeeds']);
+ if (count($feeds)==0) { return ''; }
+ foreach ($feeds as $url) {
+ if (empty($url)) { continue; }
+ $rss = fetch_rss($url);
+ $res .= '
'.$rss->channel['title'].' ';
+ $res .= '';
+ }
+ $res .= '';
+ $res .= '
';
+ return $res;
+ }
+
+ /**
+ * Helper functions definition
+ */
+ function get_logged_user_course_html($my_course, $count) {
+ global $nosession;
+ if (api_get_setting('use_session_mode')=='true' && !$nosession) {
+ global $now, $date_start, $date_end;
+ }
+ //initialise
+ $result = '';
+ // Table definitions
+ $main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
+ $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
+ $course_database = $my_course['db'];
+ $course_tool_table = Database :: get_course_table(TABLE_TOOL_LIST, $course_database);
+ $tool_edit_table = Database :: get_course_table(TABLE_ITEM_PROPERTY, $course_database);
+ $course_group_user_table = Database :: get_course_table(TOOL_USER, $course_database);
+
+ $user_id = api_get_user_id();
+ $course_system_code = $my_course['k'];
+ $course_visual_code = $my_course['c'];
+ $course_title = $my_course['i'];
+ $course_directory = $my_course['d'];
+ $course_teacher = $my_course['t'];
+ $course_teacher_email = isset($my_course['email'])?$my_course['email']:'';
+ $course_info = Database :: get_course_info($course_system_code);
+ //error_log(print_r($course_info,true));
+ $course_access_settings = CourseManager :: get_access_settings($course_system_code);
+
+ $course_visibility = $course_access_settings['visibility'];
+
+ $user_in_course_status = CourseManager :: get_user_in_course_status(api_get_user_id(), $course_system_code);
+ //function logic - act on the data
+ $is_virtual_course = CourseManager :: is_virtual_course_from_system_code($my_course['k']);
+ if ($is_virtual_course) {
+ // If the current user is also subscribed in the real course to which this
+ // virtual course is linked, we don't need to display the virtual course entry in
+ // the course list - it is combined with the real course entry.
+ $target_course_code = CourseManager :: get_target_of_linked_course($course_system_code);
+ $is_subscribed_in_target_course = CourseManager :: is_user_subscribed_in_course(api_get_user_id(), $target_course_code);
+ if ($is_subscribed_in_target_course) {
+ return; //do not display this course entry
+ }
+ }
+ $has_virtual_courses = CourseManager :: has_virtual_courses_from_code($course_system_code, api_get_user_id());
+ if ($has_virtual_courses) {
+ $return_result = CourseManager :: determine_course_title_from_course_info(api_get_user_id(), $course_info);
+ $course_display_title = $return_result['title'];
+ $course_display_code = $return_result['code'];
+ } else {
+ $course_display_title = $course_title;
+ $course_display_code = $course_visual_code;
+ }
+ $s_course_status=$my_course['s'];
+ $s_htlm_status_icon="";
+
+ if ($s_course_status==1) {
+ $s_htlm_status_icon=Display::return_icon('teachers.gif', get_lang('Teacher'));
+ }
+ if ($s_course_status==2) {
+ $s_htlm_status_icon=Display::return_icon('coachs.gif', get_lang('GeneralCoach'));
+ }
+ if ($s_course_status==5) {
+ $s_htlm_status_icon=Display::return_icon('students.gif', get_lang('Student'));
+ }
+
+ //display course entry
+ $result .= '';
+
+ if (api_get_setting('use_session_mode')=='true' && !$nosession) {
+ $session = '';
+ $active = false;
+ if (!empty($my_course['session_name'])) {
+
+ // Request for the name of the general coach
+ $sql = 'SELECT lastname, firstname
+ FROM '.$tbl_session.' ts LEFT JOIN '.$main_user_table .' tu
+ ON ts.id_coach = tu.user_id
+ WHERE ts.id='.(int) $my_course['id_session']. ' LIMIT 1';
+ $rs = Database::query($sql, __FILE__, __LINE__);
+ $sessioncoach = Database::store_result($rs);
+ $sessioncoach = $sessioncoach[0];
+
+ $session = array();
+ $session['title'] = $my_course['session_name'];
+ if ( $my_course['date_start']=='0000-00-00' ) {
+ $session['dates'] = get_lang('WithoutTimeLimits');
+ if ( api_get_setting('show_session_coach') === 'true' ) {
+ $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
+ }
+ $active = true;
+ } else {
+ $session ['dates'] = ' - '.get_lang('From').' '.$my_course['date_start'].' '.get_lang('To').' '.$my_course['date_end'];
+ if ( api_get_setting('show_session_coach') === 'true' ) {
+ $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
+ }
+ $active = ($date_start <= $now && $date_end >= $now)?true:false;
+ }
+ }
+ $output = array ($my_course['user_course_cat'], $result, $my_course['id_session'], $session, 'active'=>$active);
+ } else {
+ $output = array ($my_course['user_course_cat'], $result);
+ }
+ //$my_course['creation_date'];
+ return $output;
+ }
+
+ public static function show_social_menu() {
+ echo '';
+ }
}
\ No newline at end of file
diff --git a/main/inc/lib/sortabletable.class.php b/main/inc/lib/sortabletable.class.php
index 46575e8032..e5e4c61a1a 100644
--- a/main/inc/lib/sortabletable.class.php
+++ b/main/inc/lib/sortabletable.class.php
@@ -378,10 +378,7 @@ class SortableTable extends HTML_Table {
$html .= '';
+ }
+ //deprecated
+ public function get_public_users($keyword, $from = 0, $number_of_items= 20, $column=2, $direction='ASC') {
+
+ $admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
+ $sql = "SELECT
+ u.user_id AS col0,
+ u.official_code AS col1,
+ ".(api_is_western_name_order()
+ ? "u.firstname AS col2,
+ u.lastname AS col3,"
+ : "u.lastname AS col2,
+ u.firstname AS col3,")."
+ u.username AS col4,
+ u.email AS col5,
+ u.status AS col6,
+ u.active AS col7,
+ u.user_id AS col8 ".
+ ", u.expiration_date AS exp ".
+ " FROM $user_table u ";
+
+ // adding the filter to see the user's only of the current access_url
+ global $_configuration;
+ if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls']==true && api_get_current_access_url_id()!=-1) {
+ $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
+ $sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
+ }
+
+ if (isset ($keyword)) {
+ $keyword = Database::escape_string($keyword);
+ //OR u.official_code LIKE '%".$keyword."%'
+ $sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%' OR u.username LIKE '%".$keyword."%' OR u.email LIKE '%".$keyword."%' )";
+ }
+ $keyword_active = true;
+ //only active users
+ if ($keyword_active) {
+ $sql .= " AND u.active='1'";
+ }
+
+ // adding the filter to see the user's only of the current access_url
+ if ($_configuration['multiple_access_urls']==true && api_get_current_access_url_id()!=-1) {
+ $sql.= " AND url_rel_user.access_url_id=".api_get_current_access_url_id();
+ }
+
+ if (!in_array($direction, array('ASC','DESC'))) {
+ $direction = 'ASC';
+ }
+
+ $column = intval($column);
+ $from = intval($from);
+ $number_of_items = intval($number_of_items);
+
+ $sql .= " ORDER BY col$column $direction ";
+ $sql .= " LIMIT $from,$number_of_items";
+ $res = Database::query($sql, __FILE__, __LINE__);
+
+ $users = array ();
+ $t = time();
+ while ($user = Database::fetch_row($res)) {
+ if ($user[7] == 1 && $user[9] != '0000-00-00 00:00:00') {
+ // check expiration date
+ $expiration_time = convert_mysql_date($user[9]);
+ // if expiration date is passed, store a special value for active field
+ if ($expiration_time < $t) {
+ $user[7] = '-1';
+ }
+ }
+ // forget about the expiration date field
+ $users[] = array($user[0],$user[1],$user[2],$user[3],$user[4],$user[5],$user[6],$user[7],$user[8]);
+ }
+ return $users;
+ }
+ function show_menu(){
+ echo '';
+ }
}
diff --git a/main/install/dokeos_main.sql b/main/install/dokeos_main.sql
index 3e108d850c..4383aa861d 100644
--- a/main/install/dokeos_main.sql
+++ b/main/install/dokeos_main.sql
@@ -2271,7 +2271,7 @@ CREATE TABLE session_category (
--
-CREATE TABLE user_tag (
+CREATE TABLE tag (
id int NOT NULL auto_increment,
tag varchar(255) NOT NULL,
field_id int NOT NULL,
@@ -2287,3 +2287,34 @@ CREATE TABLE user_rel_tag (
PRIMARY KEY (id)
);
+--
+-- Table structure for user platform groups
+--
+
+CREATE TABLE `group` (
+ id int NOT NULL AUTO_INCREMENT,
+ name varchar(255) NOT NULL,
+ description varchar(255) NOT NULL,
+ picture_uri varchar(255) NOT NULL,
+ url varchar(255) NOT NULL,
+ visibility int NOT NULL,
+ updated_on varchar(255) NOT NULL,
+ created_on varchar(255) NOT NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE group_rel_tag (
+ id int NOT NULL AUTO_INCREMENT,
+ tag_id int NOT NULL,
+ group_id int NOT NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE group_rel_user (
+ id int NOT NULL AUTO_INCREMENT,
+ group_id int NOT NULL,
+ user_id int NOT NULL,
+ relation_type int NOT NULL,
+ PRIMARY KEY (id)
+);
+
diff --git a/main/install/migrate-db-1.8.6.1-1.8.6.2-pre.sql b/main/install/migrate-db-1.8.6.1-1.8.6.2-pre.sql
index c8edcf7ea4..89aa7df8f8 100755
--- a/main/install/migrate-db-1.8.6.1-1.8.6.2-pre.sql
+++ b/main/install/migrate-db-1.8.6.1-1.8.6.2-pre.sql
@@ -1,77 +1,74 @@
--- This script updates the databases structure before migrating the data from
--- version 1.8.6.1 to version 1.8.6.2
--- it is intended as a standalone script, however, because of the multiple
--- databases related difficulties, it should be parsed by a PHP script in
--- order to connect to and update the right databases.
--- There is one line per query, allowing the PHP function file() to read
--- all lines separately into an array. The xxMAINxx-type markers are there
--- to tell the PHP script which database we're talking about.
--- By always using the keyword "TABLE" in the queries, we should be able
--- to retrieve and modify the table name from the PHP script if needed, which
--- will allow us to deal with the unique-database-type installations
---
--- This first part is for the main database
--- xxMAINxx
-ALTER TABLE gradebook_evaluation ADD COLUMN type varchar(40) NOT NULL;
-ALTER TABLE session ADD COLUMN visibility int NOT NULL default 1;
-ALTER TABLE session ADD COLUMN session_category_id INT NOT NULL;
-
-ALTER TABLE session_rel_course_rel_user ADD COLUMN visibility int NOT NULL default 1;
-ALTER TABLE session_rel_course_rel_user ADD COLUMN status int NOT NULL default 0;
-CREATE TABLE session_category (id int(11) NOT NULL auto_increment, name varchar(100) default NULL, date_start date default NULL, date_end date default NULL, PRIMARY KEY (id));
-
-
-INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_coach_to_edit_course_session', NULL, 'radio', 'Course', 'false', 'AllowCoachsToEditInsideTrainingSessions', 'AllowCoachsToEditInsideTrainingSessionsComment', NULL, NULL, 0);
-INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('show_courses_descriptions_in_catalog', NULL, 'radio', 'Course', 'true', 'ShowCoursesDescriptionsInCatalogTitle', 'ShowCoursesDescriptionsInCatalogComment', NULL, NULL, 1, 1);
-INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('show_glossary_in_extra_tools', NULL, 'radio', 'Course', 'false', 'ShowGlossaryInExtraToolsTitle', 'ShowGlossaryInExtraToolsComment', NULL, NULL,1,0);
-
-INSERT INTO settings_options (variable, value, display_text) VALUES ('show_courses_descriptions_in_catalog', 'true', 'Yes');
-INSERT INTO settings_options (variable, value, display_text) VALUES ('show_courses_descriptions_in_catalog', 'false', 'No');
-
-INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_coach_to_edit_course_session', 'true', 'Yes');
-INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_coach_to_edit_course_session', 'false', 'No');
-
-INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'true', 'Yes');
-INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'false', 'No');
-
-CREATE TABLE user_tag (id int NOT NULL auto_increment, tag varchar(255) NOT NULL, field_id int NOT NULL, count int NOT NULL, PRIMARY KEY (id));
+-- This script updates the databases structure before migrating the data from
+-- version 1.8.6.1 to version 1.8.6.2
+-- it is intended as a standalone script, however, because of the multiple
+-- databases related difficulties, it should be parsed by a PHP script in
+-- order to connect to and update the right databases.
+-- There is one line per query, allowing the PHP function file() to read
+-- all lines separately into an array. The xxMAINxx-type markers are there
+-- to tell the PHP script which database we're talking about.
+-- By always using the keyword "TABLE" in the queries, we should be able
+-- to retrieve and modify the table name from the PHP script if needed, which
+-- will allow us to deal with the unique-database-type installations
+--
+-- This first part is for the main database
+-- xxMAINxx
+ALTER TABLE gradebook_evaluation ADD COLUMN type varchar(40) NOT NULL;
+ALTER TABLE session ADD COLUMN visibility int NOT NULL default 1;
+ALTER TABLE session ADD COLUMN session_category_id INT NOT NULL;
+
+ALTER TABLE session_rel_course_rel_user ADD COLUMN visibility int NOT NULL default 1;
+ALTER TABLE session_rel_course_rel_user ADD COLUMN status int NOT NULL default 0;
+CREATE TABLE session_category (id int(11) NOT NULL auto_increment, name varchar(100) default NULL, date_start date default NULL, date_end date default NULL, PRIMARY KEY (id));
+
+
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_coach_to_edit_course_session', NULL, 'radio', 'Course', 'false', 'AllowCoachsToEditInsideTrainingSessions', 'AllowCoachsToEditInsideTrainingSessionsComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('show_courses_descriptions_in_catalog', NULL, 'radio', 'Course', 'true', 'ShowCoursesDescriptionsInCatalogTitle', 'ShowCoursesDescriptionsInCatalogComment', NULL, NULL, 1, 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('show_glossary_in_extra_tools', NULL, 'radio', 'Course', 'false', 'ShowGlossaryInExtraToolsTitle', 'ShowGlossaryInExtraToolsComment', NULL, NULL,1,0);
+
+INSERT INTO settings_options (variable, value, display_text) VALUES ('show_courses_descriptions_in_catalog', 'true', 'Yes');
+INSERT INTO settings_options (variable, value, display_text) VALUES ('show_courses_descriptions_in_catalog', 'false', 'No');
+
+INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_coach_to_edit_course_session', 'true', 'Yes');
+INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_coach_to_edit_course_session', 'false', 'No');
+
+INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'true', 'Yes');
+INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'false', 'No');
+
+CREATE TABLE tag (id int NOT NULL auto_increment, tag varchar(255) NOT NULL, field_id int NOT NULL, count int NOT NULL, PRIMARY KEY (id));
CREATE TABLE user_rel_tag (id int NOT NULL auto_increment,user_id int NOT NULL,tag_id int NOT NULL, PRIMARY KEY (id));
-CREATE TABLE announcement_attachment ( id int NOT NULL auto_increment, path varchar(255) NOT NULL, comment text, size int NOT NULL default 0, announcement_id int NOT NULL, filename varchar(255) NOT NULL, PRIMARY KEY (id) );
-
-INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('send_email_to_admin_when_create_course',NULL,'radio','Platform','false','SendEmailToAdminTitle','SendEmailToAdminComment',NULL,NULL, 1);
-INSERT INTO settings_options (variable, value, display_text) VALUES ('send_email_to_admin_when_create_course','true','Yes');
-INSERT INTO settings_options (variable, value, display_text) VALUES ('send_email_to_admin_when_create_course','false','No');
-
-INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('go_to_course_after_login', NULL, 'radio', 'Course', 'false', 'GoToCourseAfterLoginTitle', 'GoToCourseAfterLoginComment', NULL, NULL, 0);
-INSERT INTO settings_options (variable, value, display_text) VALUES ('go_to_course_after_login', 'true', 'Yes');
-INSERT INTO settings_options (variable, value, display_text) VALUES ('go_to_course_after_login', 'false', 'No');
-
--- xxSTATSxx
-ALTER TABLE track_e_exercices ADD COLUMN expired_time_control datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
-ALTER TABLE track_e_online ADD INDEX (course);
-
--- xxUSERxx
-
--- xxCOURSExx
-
-ALTER TABLE quiz ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
-ALTER TABLE blog ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
-ALTER TABLE course_description ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
-ALTER TABLE glossary ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
-ALTER TABLE link ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
-ALTER TABLE wiki ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
-ALTER TABLE tool ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
-ALTER TABLE link_category ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
-ALTER TABLE item_property ADD id_session INT NOT NULL DEFAULT 0;
-ALTER TABLE item_property DROP INDEX idx_item_property_toolref, ADD INDEX idx_item_property_toolref (tool, ref, id_session);
+CREATE TABLE announcement_attachment ( id int NOT NULL auto_increment, path varchar(255) NOT NULL, comment text, size int NOT NULL default 0, announcement_id int NOT NULL, filename varchar(255) NOT NULL, PRIMARY KEY (id) );
+
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('send_email_to_admin_when_create_course',NULL,'radio','Platform','false','SendEmailToAdminTitle','SendEmailToAdminComment',NULL,NULL, 1);
+INSERT INTO settings_options (variable, value, display_text) VALUES ('send_email_to_admin_when_create_course','true','Yes');
+INSERT INTO settings_options (variable, value, display_text) VALUES ('send_email_to_admin_when_create_course','false','No');
+
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('go_to_course_after_login', NULL, 'radio', 'Course', 'false', 'GoToCourseAfterLoginTitle', 'GoToCourseAfterLoginComment', NULL, NULL, 0);
+INSERT INTO settings_options (variable, value, display_text) VALUES ('go_to_course_after_login', 'true', 'Yes');
+INSERT INTO settings_options (variable, value, display_text) VALUES ('go_to_course_after_login', 'false', 'No');
+
+
+-- xxSTATSxx
+ALTER TABLE track_e_exercices ADD COLUMN expired_time_control datetime NOT NULL DEFAULT '0000-00-00 00:00:00';
+ALTER TABLE track_e_online ADD INDEX (course);
+
+-- xxUSERxx
+
+-- xxCOURSExx
+
+ALTER TABLE quiz ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
+ALTER TABLE blog ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
+ALTER TABLE course_description ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
+ALTER TABLE glossary ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
+ALTER TABLE link ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
+ALTER TABLE wiki ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
+ALTER TABLE tool ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
+ALTER TABLE link_category ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
+ALTER TABLE item_property ADD id_session INT NOT NULL DEFAULT 0;
+ALTER TABLE item_property DROP INDEX idx_item_property_toolref, ADD INDEX idx_item_property_toolref (tool, ref, id_session);
ALTER TABLE quiz ADD COLUMN expired_time int NOT NULL DEFAULT '0' AFTER feedback_type;
ALTER TABLE group_info ADD COLUMN chat_state TINYINT DEFAULT 1, ADD INDEX (chat_state);
-ALTER TABLE group_category ADD COLUMN chat_state TINYINT DEFAULT 1, ADD INDEX (chat_state);
-ALTER TABLE student_publication ADD COLUMN weight float(6,2) UNSIGNED NOT NULL DEFAULT 0;
-ALTER TABLE course_description ADD COLUMN description_type TINYINT NOT NULL DEFAULT 0;
-ALTER TABLE dropbox_category ADD COLUMN session_id smallint NOT NULL DEFAULT 0, ADD INDEX (session_id);
-ALTER TABLE chat_connected ADD COLUMN session_id smallint NOT NULL DEFAULT 0;
-ALTER TABLE chat_connected ADD COLUMN to_group_id INT NOT NULL DEFAULT 0;
-ALTER TABLE chat_connected DROP PRIMARY KEY;
-ALTER TABLE chat_connected ADD INDEX char_connected_index(user_id,session_id,to_group_id);
+ALTER TABLE group_category ADD COLUMN chat_state TINYINT DEFAULT 1, ADD INDEX (chat_state);
+ALTER TABLE student_publication ADD COLUMN weight float(6,2) UNSIGNED NOT NULL DEFAULT 0;
+ALTER TABLE course_description ADD COLUMN description_type TINYINT NOT NULL DEFAULT 0;
+ALTER TABLE dropbox_category ADD COLUMN session_id smallint NOT NULL DEFAULT 0, ADD INDEX (session_id);
\ No newline at end of file
diff --git a/main/messages/inbox.php b/main/messages/inbox.php
index d5f13277ea..be3ea1e736 100755
--- a/main/messages/inbox.php
+++ b/main/messages/inbox.php
@@ -136,35 +136,45 @@ if (isset($_GET['form_reply']) || isset($_GET['form_delete'])) {
}
}
-if ($request===false) {
- $interbreadcrumb[]= array (
- 'url' => '#',
- 'name' => get_lang('Messages')
- );
- $interbreadcrumb[]= array (
- 'url' => 'outbox.php',
- 'name' => get_lang('Outbox')
- );
- $interbreadcrumb[]= array (
- 'url' => 'inbox.php',
- 'name' => get_lang('Inbox')
- );
- Display::display_header('');
- $link_ref="new_message.php";
-} else {
- $link_ref="../messages/new_message.php?rs=1";
-}
+
+$link_ref="new_message.php";
+
$table_message = Database::get_main_table(TABLE_MESSAGE);
-/*echo ' ';
+
+
//api_display_tool_title(api_xml_http_response_encode(get_lang('Inbox')));
-echo '
';
-echo '
';*/
-if (!isset($_GET['del_msg'])) {
+if ($_GET['f']=='social') {
+ $this_section = SECTION_SOCIAL;
+ $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Profile'));
+ $interbreadcrumb[]= array ('url' => 'outbox.php','name' => get_lang('Inbox'));
+} else {
+ $this_section = SECTION_MYPROFILE;
+ $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Profile'));
+ $interbreadcrumb[]= array ('url' => 'outbox.php','name' => get_lang('Inbox'));
+}
+
+Display::display_header('');
+
+if ($_GET['f']=='social') {
+ require_once api_get_path(LIBRARY_PATH).'social.lib.php';
+ SocialManager::show_social_menu();
+ echo '';
+ echo get_lang('Messages');
+ echo '
';
+} else {
+ //comes from normal profile
+ echo '';
+}
+
+
+if (!isset($_GET['del_msg'])) {
inbox_display();
} else {
- $num_msg = $_POST['total'];
+ $num_msg = intval($_POST['total']);
for ($i=0;$i<$num_msg;$i++) {
if($_POST[$i]) {
//the user_id was necesarry to delete a message??
diff --git a/main/messages/index.php b/main/messages/index.php
index 55b4055197..aeefea2d56 100755
--- a/main/messages/index.php
+++ b/main/messages/index.php
@@ -1,27 +1,5 @@
- Copyright (c) Facultad de Matematicas, UADY (México)
- Copyright (c) Evie, Free University of Brussels (Belgium)
-
- For a full list of contributors, see "credits.txt".
- The full license can be read in "license.txt".
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- See the GNU General Public License for more details.
-
- Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
- Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /dokeos_license.txt */
$language_file= 'messages';
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'message.lib.php';
@@ -34,7 +12,7 @@ if (api_get_setting('allow_message_tool')!='true'){
if(api_get_user_id()!=0) {
echo ' ';
echo ' ';
- $number_of_new_messages = get_new_messages();
+ $number_of_new_messages = MessageManager::get_new_messages();
if(is_null($number_of_new_messages)) {
$number_of_new_messages = 0;
}
diff --git a/main/messages/message.class.php b/main/messages/message.class.php
index 11b06a9761..0dd7b8b5b9 100755
--- a/main/messages/message.class.php
+++ b/main/messages/message.class.php
@@ -1,26 +1,5 @@
-
- For a full list of contributors, see "credits.txt".
- The full license can be read in "license.txt".
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- See the GNU General Public License for more details.
-
- Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
- Mail: info@dokeos.com
-
-==============================================================================
-*/
+/* For licensing terms, see /dokeos_license.txt */
require_once api_get_path(LIBRARY_PATH).'/main_api.lib.php';
require_once api_get_path(LIBRARY_PATH).'/online.inc.php';
diff --git a/main/messages/new_message.php b/main/messages/new_message.php
index bf9120e4c4..64313f2a15 100755
--- a/main/messages/new_message.php
+++ b/main/messages/new_message.php
@@ -213,14 +213,14 @@ if (isset($_GET['rs'])) {
'name' => get_lang('ComposeMessage')
);
-if ($request===false) {
Display::display_header('');
-}
-//api_display_tool_title($nameTools);
+
echo '';
+ echo ''.Display::return_icon('inbox.png',api_xml_http_response_encode(get_lang('Inbox'))).api_xml_http_response_encode(get_lang('Inbox')).' ';
+ echo ''.Display::return_icon('message_new.png',api_xml_http_response_encode(get_lang('ComposeMessage'))).api_xml_http_response_encode(get_lang('ComposeMessage')).' ';
+ echo ''.Display::return_icon('outbox.png',api_xml_http_response_encode(get_lang('Outbox'))).api_xml_http_response_encode(get_lang('Outbox')).' ';
+echo ' ';
if (!isset($_POST['compose'])) {
if(isset($_GET['re_id'])) {
$message_id = $_GET['re_id'];
diff --git a/main/messages/notify.php b/main/messages/notify.php
index 45b57f6188..adcc7d9bb2 100755
--- a/main/messages/notify.php
+++ b/main/messages/notify.php
@@ -1,29 +1,7 @@
- Copyright (c) Facultad de Matematicas, UADY (México)
- Copyright (c) Evie, Free University of Brussels (Belgium)
-
- For a full list of contributors, see "credits.txt".
- The full license can be read in "license.txt".
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- See the GNU General Public License for more details.
-
- Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
- Mail: info@dokeos.com
-==============================================================================
-*/
+/* For licensing terms, see /dokeos_license.txt */
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'message.lib.php';
header("Cache-Control: no-cache, must-revalidate");
- echo get_new_messages();
+ echo MessageManager::get_new_messages();
?>
\ No newline at end of file
diff --git a/main/messages/outbox.php b/main/messages/outbox.php
index 98e8a5a911..ca4f84d43b 100755
--- a/main/messages/outbox.php
+++ b/main/messages/outbox.php
@@ -93,6 +93,13 @@ if ($request===false) {
);
Display::display_header('');
}
+
+echo ' ';
-//api_display_tool_title(api_xml_http_response_encode(get_lang('Outbox')));
-echo '
';
+
$user_sender_id=api_get_user_id();
if ($_REQUEST['action']=='delete') {
$delete_list_id=array();
diff --git a/main/messages/send_message.php b/main/messages/send_message.php
index d0fbd36bba..669a88edbd 100755
--- a/main/messages/send_message.php
+++ b/main/messages/send_message.php
@@ -71,8 +71,8 @@ if ($panel_id==4) {
if ($subject_message=='clear') {
$subject_message=null;
}
- UserFriend::send_invitation_friend_user($user_id,$subject_message,$content_message);
+ SocialManager::send_invitation_friend_user($user_id,$subject_message,$content_message);
} elseif ($panel_id==5) {
- UserFriend::send_invitation_friend_user($user_id,$subject_message,$content_message);
+ SocialManager::send_invitation_friend_user($user_id,$subject_message,$content_message);
}
?>
diff --git a/main/social/data_personal.inc.php b/main/social/data_personal.inc.php
index 5485f1efa5..4038e1ffd9 100755
--- a/main/social/data_personal.inc.php
+++ b/main/social/data_personal.inc.php
@@ -129,7 +129,7 @@ $language_variable=api_xml_http_response_encode(get_lang('PersonalData'));
$number_of_outbox_message=MessageManager::get_number_of_messages_sent();
$cant_out_box=' ('.$number_of_outbox_message.')';
$cant_msg = ' ('.$number_of_new_messages.')';
- $number_of_new_messages_of_friend=UserFriend::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());
//echo '
'.get_lang('Messages').'
diff --git a/main/social/friends.php b/main/social/friends.php
new file mode 100644
index 0000000000..bd91a8dd94
--- /dev/null
+++ b/main/social/friends.php
@@ -0,0 +1,150 @@
+'; //jQuery
+$htmlHeadXtra[] = '';
+$htmlHeadXtra[] = '';
+$htmlHeadXtra[] = '';
+$htmlHeadXtra[] = '';
+$htmlHeadXtra[] = '';
+
+$interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
+
+Display :: display_header($tool_name, 'Groups');
+SocialManager::show_social_menu();
+
+echo '
';
+echo get_lang('MyFriends');
+echo '
';
+
+
+//$list_path_friends=array();
+$request=api_is_xml_http_request();
+$language_variable=api_xml_http_response_encode(get_lang('Contacts'));
+//api_display_tool_title($language_variable);
+
+$user_id=api_get_user_id();
+$image_path = UserManager::get_user_picture_path_by_id ($user_id,'web',false,true);
+?>
+
+
+
+
+
+
+
+
+
+
+
+';
+require_once 'show_search_image.inc.php';
+echo '';
+?>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/social/group_add.php b/main/social/group_add.php
new file mode 100644
index 0000000000..91441bb3c4
--- /dev/null
+++ b/main/social/group_add.php
@@ -0,0 +1,78 @@
+addElement('text', 'name', get_lang('Name'));
+$form->applyFilter('name', 'html_filter');
+$form->applyFilter('name', 'trim');
+$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
+
+// Description
+$form->addElement('text', 'description', get_lang('Description'));
+$form->applyFilter('description', 'html_filter');
+$form->applyFilter('description', 'trim');
+
+
+// url
+$form->addElement('text', 'url', get_lang('URL'));
+$form->applyFilter('url', 'html_filter');
+$form->applyFilter('url', 'trim');
+
+// Picture
+$form->addElement('file', 'picture', get_lang('AddPicture'));
+
+$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
+
+$form->addRule('picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
+
+
+/*
+ $form->add_textfield('id_text_name', api_xml_http_response_encode(get_lang('SendMessageTo')),true,array('size' => 40,'id'=>'id_text_name','onkeyup'=>'send_request_and_search()','autocomplete'=>'off','style'=>'padding:0px'));
+ $form->addRule('id_text_name', api_xml_http_response_encode(get_lang('ThisFieldIsRequired')), 'required');
+ $form->addElement('html','
');
+ $form->addElement('hidden','user_list',0,array('id'=>'user_list'));
+
+$form->add_textfield('title', api_xml_http_response_encode(get_lang('Title')));
+$form->add_html_editor('content', '', false, false, array('ToolbarSet' => 'Messages', 'Width' => '95%', 'Height' => '250'));
+if (isset($_GET['re_id'])) {
+ $form->addElement('hidden','re_id',Security::remove_XSS($_GET['re_id']));
+ $form->addElement('hidden','save_form','save_form');
+}
+
+*/
+
+$form->addElement('style_submit_button','add_group', api_xml_http_response_encode(get_lang('AddGroup')),'class="save"');
+
+$form->setRequiredNote(api_xml_http_response_encode('
* '.get_lang('ThisFieldIsRequired').' '));
+$form->setDefaults($default);
+if ($form->validate()) {
+ $values = $form->exportValues();
+ var_dump($values);
+ $receiver_user_id = $values['user_list'];
+ $title = $values['title'];
+ $content = $values['content'];
+ //all is well, send the message
+ //MessageManager::send_message($receiver_user_id, $title, $content);
+ //MessageManager::display_success_message($receiver_user_id);
+} else {
+ $form->display();
+}
+
+
+
+
+?>
\ No newline at end of file
diff --git a/main/social/group_contact.inc.php b/main/social/group_contact.inc.php
index 1a29aca776..40d23e5603 100755
--- a/main/social/group_contact.inc.php
+++ b/main/social/group_contact.inc.php
@@ -17,10 +17,12 @@ $request=api_is_xml_http_request();
$language_variable=api_xml_http_response_encode(get_lang('ContactsGroups'));
//api_display_tool_title($language_variable);
$user_id=api_get_user_id();
-$list_groups=UserFriend::show_list_type_friends();
+$list_groups=SocialManager::show_list_type_friends();
+
+
for ($p=0;$p
@@ -65,7 +67,7 @@ for ($p=0;$p' .
'' .
' '.
diff --git a/main/social/group_invitation.php b/main/social/group_invitation.php
new file mode 100644
index 0000000000..3b59c641c0
--- /dev/null
+++ b/main/social/group_invitation.php
@@ -0,0 +1,17 @@
+
\ No newline at end of file
diff --git a/main/social/groups.php b/main/social/groups.php
new file mode 100644
index 0000000000..7f123fb520
--- /dev/null
+++ b/main/social/groups.php
@@ -0,0 +1,120 @@
+'home.php','name' => get_lang('Social'));
+Display :: display_header($tool_name, 'Groups');
+
+//show the action menu
+SocialManager::show_social_menu();
+echo '';
+echo get_lang('Groups');
+echo '
';
+
+$group_id = intval($_GET['id']);
+
+if ($group_id != 0 ) {
+ $group_info = GroupPortalManager::get_group_data($group_id);
+ $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);
+
+
+ //var_dump($users);
+
+
+ //Group's title
+ echo ''.$group_info['name'].' ';
+
+ //image
+ echo '';
+ echo $img = '
';
+ echo '
';
+
+ //description
+ echo '';
+ echo $group_info['description'];
+ echo '
';
+
+ //Privacy
+ echo '';
+ echo get_lang('Privacy').' : ';
+ if ($group_info['visibility']== GROUP_PERMISSION_OPEN) {
+ echo get_lang('ThisIsAnOpenGroup');
+ } elseif ($group_info['visibility']== GROUP_PERMISSION_CLOSED) {
+ echo get_lang('ThisIsACloseGroup');
+ }
+ echo '
';
+
+ //group tags
+ if (!empty($tags)) {
+ echo '';
+ echo get_lang('Tags').' : '.$tags;
+ echo '
';
+ }
+
+ echo '';
+ echo get_lang('Members').' : ';
+ foreach($users as $user) {
+ echo $user['picture_uri'].$user['firstname'].$user['lastname'].' ';
+ }
+ echo '
';
+
+
+ echo '';
+ if (in_array(api_get_user_id(), $users)) {
+ //im a member
+ if (isset($users[api_get_user_id()]) && $users[api_get_user_id()]['relation_info']!='') {
+ $my_group_role = $users[api_get_get_user_id()]['relation_info'];
+ // just a reader
+ if ($my_group_role == GROUP_USER_PERMISSION_READER) {
+ echo 'Im just a reader';
+ echo 'Invite others';
+ echo 'Leave group';
+ //the main admin
+ } elseif ($my_group_role == GROUP_USER_PERMISSION_ADMIN) {
+ echo 'Imm the admin';
+ echo 'Edit group';
+ echo 'Invite others';
+ }
+ } else {
+ //im not a member
+ echo 'I should register';
+ }
+ } else {
+ //im not a member
+ echo 'I should register';
+ }
+ echo '
';
+
+} else {
+ echo ''.get_lang('Newest').' ';
+ echo ''.get_lang('Popular').' ';
+ echo ''.get_lang('MyGroups').' ';
+
+ $results = GroupPortalManager::get_groups_by_user(api_get_user_id(), 0, true);
+ $groups = array();
+ foreach ($results as $result) {
+ $id = $result['id'];
+ $url_open = ' ';
+ $url_close = ' ';
+
+ $groups[]= array($url_open.$result['picture_uri'].$url_close, $url_open.$result['name'].$url_close);
+ }
+
+ Display::display_sortable_grid('search_users', array(), $groups, array('hide_navigation'=>true, 'per_page' => 100), $query_vars, false, array(true, true, true,false));
+
+}
+
+
+
+
+Display :: display_footer();
+?>
\ No newline at end of file
diff --git a/main/social/home.php b/main/social/home.php
new file mode 100644
index 0000000000..f046a7d69f
--- /dev/null
+++ b/main/social/home.php
@@ -0,0 +1,611 @@
+
+* @package dokeos.social
+*/
+
+$language_file = array('registration','messages','userInfo','admin','forum','blog');
+$cidReset = true;
+require '../inc/global.inc.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).'array.lib.php';
+$user_id = api_get_user_id();
+$show_full_profile = true;
+//social tab
+$this_section = SECTION_SOCIAL;
+
+//I'm your friend? I can see your profile?
+if (isset($_GET['u'])) {
+ $user_id = (int) Database::escape_string($_GET['u']);
+ // It's me!
+ if (api_get_user_id() != $user_id) {
+ $user_info = UserManager::get_user_info_by_id($user_id);
+ $show_full_profile = false;
+ if ($user_info==false) {
+ // user does no exist !!
+ api_not_allowed();
+ } else {
+ //checking the relationship between me and my friend
+ $my_status= SocialManager::get_relation_between_contacts(api_get_user_id(), $user_id);
+ if (in_array($my_status, array(SOCIALPARENT, SOCIALFRIEND, SOCIALGOODFRIEND))) {
+ $show_full_profile = true;
+ }
+ //checking the relationship between my friend and me
+ $my_friend_status = SocialManager::get_relation_between_contacts($user_id, api_get_user_id());
+ if (in_array($my_friend_status, array(SOCIALPARENT, SOCIALFRIEND, SOCIALGOODFRIEND))) {
+ $show_full_profile = true;
+ } else {
+ // im probably not a good friend
+ $show_full_profile = false;
+ }
+ }
+ } else {
+ $user_info = UserManager::get_user_info_by_id($user_id);
+ }
+} else {
+ $user_info = UserManager::get_user_info_by_id($user_id);
+}
+
+$libpath = api_get_path(LIBRARY_PATH);
+require_once api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php';
+require_once api_get_path(SYS_CODE_PATH).'announcements/announcements.inc.php';
+require_once $libpath.'course.lib.php';
+require_once $libpath.'formvalidator/FormValidator.class.php';
+require_once $libpath.'magpierss/rss_fetch.inc';
+
+api_block_anonymous_users();
+
+$htmlHeadXtra[] = ''; //jQuery
+$htmlHeadXtra[] = ''; //jQuery corner
+$htmlHeadXtra[] = '';
+$htmlHeadXtra[] = ' ';
+$htmlHeadXtra[] = '
+';
+$htmlHeadXtra[] = '';
+if (isset($_GET['shared'])) {
+ $my_link='../social/index.php';
+ $link_shared='shared='.Security::remove_XSS($_GET['shared']);
+} else {
+ $my_link='../auth/profile.php';
+ $link_shared='';
+}
+$interbreadcrumb[]= array ('url' =>$my_link,'name' => get_lang('ModifyProfile') );
+$interbreadcrumb[]= array (
+ 'url' => '../social/profile.php?'.$link_shared.'#remote-tab-1',
+ 'name' => get_lang('ViewMySharedProfile')
+);
+
+if (isset($_GET['u']) && is_numeric($_GET['u'])) {
+ $info_user=api_get_user_info($_GET['u']);
+ $interbreadcrumb[]= array (
+ 'url' => 'javascript: void(0);',
+ 'name' => api_get_person_name($info_user['firstName'], $info_user['lastName'])
+ );
+}
+if (isset($_GET['u'])) {
+ $param_user='u='.Security::remove_XSS($_GET['u']);
+}else {
+ $info_user=api_get_user_info(api_get_user_id());
+ $param_user='';
+}
+$_SESSION['social_user_id'] = $user_id;
+
+
+/**
+ * Display
+ */
+Display :: display_header(null);
+
+// @todo here we must show the user information as read only
+//User picture size is calculated from SYSTEM path
+
+$img_array= UserManager::get_user_picture_path_by_id($user_id,'web',true,true);
+
+//print_r($user_info);
+// Added by Ivan Tcholakov, 03-APR-2009.
+if (USE_JQUERY_CORNERS_SCRIPT) {
+echo $s="";
+}
+
+
+//echo '';
+
+//Setting some course info
+$my_user_id=isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id();
+$personal_course_list = UserManager::get_personal_session_course_list($my_user_id);
+$course_list_code = array();
+$i=1;
+//print_r($personal_course_list);
+
+
+
+if (is_array($personal_course_list)) {
+ foreach ($personal_course_list as $my_course) {
+ if ($i<=10) {
+ $list[] = SocialManager::get_logged_user_course_html($my_course,$i);
+ //$course_list_code[] = array('code'=>$my_course['c'],'dbName'=>$my_course['db'], 'title'=>$my_course['i']); cause double
+ $course_list_code[] = array('code'=>$my_course['c'],'dbName'=>$my_course['db']);
+
+ } else {
+ break;
+ }
+ $i++;
+ }
+ //to avoid repeted courses
+ $course_list_code = array_unique_dimensional($course_list_code);
+}
+
+
+echo '';
+
+
+echo '';
+if ($user_id == api_get_user_id())
+ echo get_lang('ViewMySharedProfile');
+else
+ echo get_lang('ViewSharedProfile').' - '.api_get_person_name($user_info['firstname'], $user_info['lastname']);
+
+echo '
';
+
+echo '';
+// RIGHT COLUMN
+ echo '
';
+ //---- FRIENDS
+
+ 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);
+ $j=0;
+ $friend_html .= '
'.get_lang('SocialFriend').'
';
+ $friend_html.= '
';
+ $friend_html.= ''; // close div friend-header
+
+ for ($k=0;$k<$loop_friends;$k++) {
+ if ($j==$number_of_images) {
+ $number_of_images=$number_of_images*2;
+ }
+ while ($j<$number_of_images) {
+ if ($list_friends_file[$j]<>"") {
+ $my_user_info=api_get_user_info($list_friends_id[$j]);
+ $name_user=api_get_person_name($my_user_info['firstName'], $my_user_info['lastName']);
+ $friend_html.='
';
+ // 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" ');
+ $friend_html.='';
+ $friend_html.=' ';
+ $friend_html.= ' ';
+ $friend_html.= '
'.api_get_person_name($my_user_info['firstName'], $my_user_info['lastName']).' ';
+ $friend_html.= '
';
+ }
+ $j++;
+ }
+ }
+ } else {
+ // No friends!! :(
+ $friend_html .= '
'.get_lang('Friends').'
';
+ $friend_html.= '
';
+ $friend_html.= ''; // close div friend-header
+ }
+ $friend_html.= '
';
+ echo $friend_html;
+ //Pending invitations
+ 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());
+ $list_get_path_web=SocialManager::get_list_web_path_user_invitation_by_user_id(api_get_user_id());
+ $count_pending_invitations = count($pending_invitations);
+ //echo '
';
+ //javascript:register_friend(this)
+ //var_dump($pending_invitations);
+ echo '
';
+ echo '
';
+ if ($count_pending_invitations > 0) {
+ echo '
';
+ echo api_convert_encoding(get_lang('PendingInvitations'),$charset,'UTF-8');
+ echo '
';
+ for ($i=0;$i<$count_pending_invitations;$i++) {
+ //var_dump($invitations);
+ echo '
';
+ echo '
';
+ echo '
';
+ echo '
';
+ echo '
';
+ echo ' '.api_convert_encoding(substr($pending_invitations[$i]['content'],0,50),$charset,'UTF-8');
+ echo '
';
+ echo '
'.get_lang('SocialAddToFriends').' ';
+ echo '
';
+ echo '
';
+ echo '
';
+ echo '
';
+ }
+ }
+ echo '
';
+ }
+
+ //--Productions
+ $production_list = UserManager::build_production_list($user_id);
+ if (!empty($production_list )) {
+ echo '
';
+ echo '
';
+ echo get_lang('MyProductions');
+ echo '
';
+ echo '
';
+ echo $production_list;
+ echo '
';
+ }
+
+ // Images uploaded by course
+ $file_list = '';
+ if (is_array($course_list_code) && count($course_list_code)>0) {
+ foreach ($course_list_code as $course) {
+ $file_list.= UserManager::get_user_upload_files_by_course($user_id,$course['code']);
+ }
+ }
+
+ if (!empty($file_list)) {
+ echo '
';
+ echo '
';
+ echo get_lang('ImagesUploaded');
+ echo '
';
+ echo '
';
+ echo $file_list;
+ echo '
';
+ }
+
+ //loading this information
+
+ //-- Competences
+ if (!empty($user_info['competences']) || !empty($user_info['diplomas']) || !empty($user_info['openarea']) || !empty($user_info['teach']) ) {
+ echo '
';
+ echo '
';
+ echo get_lang('MoreInformation');
+ echo '
';
+ }
+ echo '
';
+ $cut_size = 220;
+ if (!empty($user_info['competences'])) {
+ echo '
';
+ echo '
';
+ echo '
'.get_lang('MyCompetences').'
';
+ echo cut($user_info['competences'],$cut_size);
+ echo '
';
+ echo '
';
+ }
+
+ if (!empty($user_info['diplomas'])) {
+ echo '
';
+ echo '
'.get_lang('MyDiplomas').'
';
+ echo cut($user_info['diplomas'],$cut_size);
+ echo '
';
+ echo '
';
+ }
+ if (!empty($user_info['openarea'])) {
+ echo '
';
+ echo '
'.get_lang('MyPersonalOpenArea').'
';
+ echo cut($user_info['openarea'],$cut_size);
+ echo '
';
+ echo '
';
+ }
+ if (!empty($user_info['teach'])) {
+ echo '
';
+ echo '
'.get_lang('MyTeach').'
';
+ echo cut($user_info['teach'],$cut_size);
+ echo '
';
+ echo '
';
+ }
+ echo '
';
+ } else {
+ echo '
';
+ }
+
+ echo '
'; // end of content section
+
+
+echo '
';
+ // LEFT COLUMN
+ echo '
';
+
+ //--- User image
+ echo '
';
+ echo '
';
+ echo '
';
+ echo '
';
+ echo '
';
+ echo '
';
+
+ // Send message or Add to friend links
+ /*if (!$show_full_profile) {
+ echo '
'.Display::return_icon('message_new.png').' '.get_lang('SendMessage').' ';
+ }*/
+
+ // Extra information
+
+ if ($show_full_profile) {
+ //-- Extra Data
+ $t_uf = Database :: get_main_table(TABLE_MAIN_USER_FIELD);
+ $t_ufo = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
+ $extra_user_data = UserManager::get_extra_user_data($user_id);
+ $extra_information = '';
+ if (is_array($extra_user_data) && count($extra_user_data)>0 ) {
+ $extra_information = '
';
+ $extra_information .= get_lang('ExtraInformation');
+ $extra_information .= '
';
+ $extra_information .='
';
+ $extra_information_value = '';
+ foreach($extra_user_data as $key=>$data) {
+ // get display text, visibility and type from user_field table
+ $field_variable = str_replace('extra_','',$key);
+ $sql = "SELECT field_display_text,field_visible,field_type,id FROM $t_uf WHERE field_variable ='$field_variable'";
+ $res_field = Database::query($sql,__FILE__,__LINE__);
+ $row_field = Database::fetch_row($res_field);
+ $field_display_text = $row_field[0];
+ $field_visible = $row_field[1];
+ $field_type = $row_field[2];
+ $field_id = $row_field[3];
+ if ($field_visible == 1) {
+ if (is_array($data)) {
+ $extra_information_value .= '
'.ucfirst($field_display_text).': '.implode(',',$data).'
';
+ } else {
+ if ($field_type == USER_FIELD_TYPE_DOUBLE_SELECT) {
+ $id_options = explode(';',$data);
+ $value_options = array();
+ // get option display text from user_field_options table
+ foreach ($id_options as $id_option) {
+ $sql = "SELECT option_display_text FROM $t_ufo WHERE id = '$id_option'";
+ $res_options = Database::query($sql,__FILE__,__LINE__);
+ $row_options = Database::fetch_row($res_options);
+ $value_options[] = $row_options[0];
+ }
+ $extra_information_value .= '
'.ucfirst($field_display_text).': '.implode(' ',$value_options).'
';
+ } elseif($field_type == USER_FIELD_TYPE_TAG ) {
+ $user_tags = UserManager::get_user_tags($user_id, $field_id);
+ $tag_tmp = array();
+ foreach ($user_tags as $tags) {
+ //$tag_tmp[] = $tags['tag'];
+ $tag_tmp[] = '
'.$tags['tag'].' ';
+ }
+ if (is_array($user_tags) && count($user_tags)>0) {
+ $extra_information_value .= '
'.ucfirst($field_display_text).': '.implode(', ',$tag_tmp).'
';
+ }
+ } else {
+ $extra_information_value .= '
'.ucfirst($field_display_text).': '.$data.'
';
+ }
+ }
+ }
+ }
+ // if there are information to show
+ if (!empty($extra_information_value)) {
+ $extra_information .= $extra_information_value;
+ }
+ $extra_information .= '
';
+ $extra_information .= '
';
+ }
+ // if there are information to show
+ if (!empty($extra_information_value))
+ echo $extra_information;
+
+
+ // ---- My Agenda Items
+ $my_agenda_items = show_simple_personal_agenda($user_id);
+ if (!empty($my_agenda_items)) {
+ echo '
';
+ echo get_lang('MyAgenda');
+ echo '
';
+ $tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA);
+ echo '
';
+ echo '
';
+ echo $my_agenda_items;
+ echo '
';
+
+ echo '
';
+ echo '
';
+ }
+
+ //-----Announcements
+ $announcement_content = '';
+ $my_announcement_by_user_id=isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id();
+
+ foreach ($course_list_code as $course) {
+ $content = get_all_annoucement_by_user_course($course['dbName'],$my_announcement_by_user_id);
+ $course_info=api_get_course_info($course['code']);
+ if (!empty($content)) {
+ $announcement_content.= '
';
+ $announcement_content.= '
'.$course_info['name'].'
';
+ $announcement_content.= $content;
+ $announcement_content.= '
';
+ $announcement_content.= '
';
+ }
+
+ }
+
+ if(!empty($announcement_content)) {
+ echo '
';
+ echo get_lang('Announcements');
+ echo '
';
+ echo '
';
+ echo $announcement_content.' ';
+ echo '
';
+ }
+ }
+ echo '
';
+
+
+ // CENTER COLUMN
+
+
+ echo '
';
+
+ //--- Basic Information
+
+ echo 'ssss';
+ echo '
';
+ echo '
';
+echo '
'; //from the main
+echo '
';
+Display :: display_footer();
\ No newline at end of file
diff --git a/main/social/index.php b/main/social/index.php
index a25c49d5e0..ad2c91a1e7 100755
--- a/main/social/index.php
+++ b/main/social/index.php
@@ -5,6 +5,8 @@ $cidReset = true;
$language_file = array('registration','messages','userInfo','admin');
require '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
+require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
+
$this_section = SECTION_MYPROFILE;
$_SESSION['this_section']=$this_section;
api_block_anonymous_users();
@@ -15,391 +17,7 @@ $htmlHeadXtra[] = '';
//$htmlHeadXtra[] = '';
-$htmlHeadXtra[] = '';
if (api_get_setting('allow_message_tool')=='true') {
$htmlHeadXtra[] ='";
-//
}
-//
-
-//echo '
';
//Setting some course info
$my_user_id=isset($_GET['u']) ? Security::remove_XSS($_GET['u']) : api_get_user_id();
@@ -470,12 +240,10 @@ $course_list_code = array();
$i=1;
//print_r($personal_course_list);
-
-
if (is_array($personal_course_list)) {
foreach ($personal_course_list as $my_course) {
if ($i<=10) {
- $list[] = get_logged_user_course_html($my_course,$i);
+ $list[] = SocialManager::get_logged_user_course_html($my_course,$i);
//$course_list_code[] = array('code'=>$my_course['c'],'dbName'=>$my_course['db'], 'title'=>$my_course['i']); cause double
$course_list_code[] = array('code'=>$my_course['c'],'dbName'=>$my_course['db']);
@@ -488,14 +256,18 @@ if (is_array($personal_course_list)) {
$course_list_code = array_unique_dimensional($course_list_code);
}
+//show the action menu
+SocialManager::show_social_menu();
+
echo '
';
if ($user_id == api_get_user_id())
echo get_lang('ViewMySharedProfile');
else
echo get_lang('ViewSharedProfile').' - '.api_get_person_name($user_info['firstname'], $user_info['lastname']);
-
echo '
';
+
+
echo '
';
// RIGHT COLUMN
echo '
';
@@ -504,9 +276,9 @@ echo '
';
if ($show_full_profile) {
$list_path_friends= $list_path_normal_friends = $list_path_parents = array();
- $list_path_good_friends = UserFriend::get_list_path_web_by_user_id($user_id, SOCIALGOODFRIEND);
- $list_path_normal_friends = UserFriend::get_list_path_web_by_user_id($user_id, SOCIALFRIEND);
- $list_path_parents = UserFriend::get_list_path_web_by_user_id($user_id, SOCIALPARENT);
+ $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);
@@ -538,7 +310,7 @@ echo '
';
else
$friend_html.= '
'.$friends_count.' '.get_lang('Friends').'
';
if (api_get_user_id() == $user_id)
- $friend_html.= '
';
+ $friend_html.= '
';
$friend_html.= '
'; // close div friend-header
for ($k=0;$k<$loop_friends;$k++) {
@@ -551,7 +323,7 @@ echo '
';
$name_user=api_get_person_name($my_user_info['firstName'], $my_user_info['lastName']);
$friend_html.='
';
// the height = 92 must be the sqme in the image_friend_network span style in default.css
- $friends_profile = UserFriend::get_picture_user($list_friends_id[$j], $list_friends_file[$j], 92, 'medium_', 'width="85" height="90" ');
+ $friends_profile = SocialManager::get_picture_user($list_friends_id[$j], $list_friends_file[$j], 92, 'medium_', 'width="85" height="90" ');
$friend_html.='';
$friend_html.=' ';
$friend_html.= ' ';
@@ -573,8 +345,8 @@ echo '
';
echo $friend_html;
//Pending invitations
if (!isset($_GET['u']) || (isset($_GET['u']) && $_GET['u']==api_get_user_id())) {
- $pending_invitations = UserFriend::get_list_invitation_of_friends_by_user_id(api_get_user_id());
- $list_get_path_web=UserFriend::get_list_web_path_user_invitation_by_user_id(api_get_user_id());
+ $pending_invitations = SocialManager::get_list_invitation_of_friends_by_user_id(api_get_user_id());
+ $list_get_path_web=SocialManager::get_list_web_path_user_invitation_by_user_id(api_get_user_id());
$count_pending_invitations = count($pending_invitations);
//echo '
';
//javascript:register_friend(this)
@@ -694,10 +466,10 @@ echo '
';
echo '
';
echo '
';
echo '
';
- echo '
';
- echo '
';
+
+
if (api_get_user_id() == $user_id) {
- // if i'm me
+ /* // if i'm me
echo '
';
echo Display::return_icon('email.gif');
echo '
'.get_lang('MyInbox').' ';
@@ -705,12 +477,13 @@ echo '
';*/
} else {
+ echo '
';
+ echo '
';
+ echo '
';
+ }
echo '
';
// Send message or Add to friend links
@@ -761,8 +534,9 @@ echo '
';
$user_tags = UserManager::get_user_tags($user_id, $field_id);
$tag_tmp = array();
foreach ($user_tags as $tags) {
- $tag_tmp[] = $tags['tag'];
- }
+ //$tag_tmp[] = $tags['tag'];
+ $tag_tmp[] = '
'.$tags['tag'].' ';
+ }
if (is_array($user_tags) && count($user_tags)>0) {
$extra_information_value .= '
'.ucfirst($field_display_text).': '.implode(', ',$tag_tmp).'
';
}
@@ -927,7 +701,7 @@ echo '
';
*/
}
echo ' ';
- echo get_user_feeds($user_id);
+ echo SocialManager::get_user_feeds($user_id);
echo '
';
}
echo '
';
diff --git a/main/social/qualify_contact.inc.php b/main/social/qualify_contact.inc.php
index 78fdd734e0..318feb902e 100755
--- a/main/social/qualify_contact.inc.php
+++ b/main/social/qualify_contact.inc.php
@@ -9,13 +9,13 @@ $user_friend=(int)$_POST['user_friend'];
$list_of_options=array();
$img_user=array();
$img_info_user=array();
-$list_of_options=UserFriend::show_list_type_friends();
+$list_of_options=SocialManager::show_list_type_friends();
$path_user=str_replace(array('\\','../','\\0'),array('','',''),$_GET['path_user']);
$img_user =explode('"',$path_user);
$number_list=count($list_of_options);
$user_friend = $user_id = (int)str_replace(array('\\','"'),array('',''),$_GET['id_user']);
$user_info=api_get_user_info($user_friend);
-$user_friend_relation=UserFriend::get_relation_between_contacts(api_get_user_id(),$user_friend);
+$user_friend_relation=SocialManager::get_relation_between_contacts(api_get_user_id(),$user_friend);
?>
diff --git a/main/social/register_friend.php b/main/social/register_friend.php
index 3e7dbbaca7..94accdf016 100755
--- a/main/social/register_friend.php
+++ b/main/social/register_friend.php
@@ -23,9 +23,9 @@ if (isset($_POST['is_my_friend'])) {
}
if (isset($_POST['friend_id'])) {
- UserFriend::register_friend ((int)$the_current_user_id,(int)$my_current_friend,(int)$relation_type);
- UserFriend::register_friend ((int)$my_current_friend,(int)$the_current_user_id,(int)$relation_type);
- UserFriend::invitation_accepted ((int)$my_current_friend,(int)$the_current_user_id);
+ SocialManager::register_friend ((int)$the_current_user_id,(int)$my_current_friend,(int)$relation_type);
+ SocialManager::register_friend ((int)$my_current_friend,(int)$the_current_user_id,(int)$relation_type);
+ SocialManager::invitation_accepted ((int)$my_current_friend,(int)$the_current_user_id);
if (isset($_POST['is_my_friend'])) {
echo api_xml_http_response_encode(get_lang('AddedContactToList'));
} else {
@@ -34,14 +34,14 @@ if (isset($_POST['friend_id'])) {
}
if (isset($_POST['denied_friend_id'])) {
- UserFriend::invitation_denied((int)$my_denied_current_friend,(int)$the_current_user_id);
+ SocialManager::invitation_denied((int)$my_denied_current_friend,(int)$the_current_user_id);
Display::display_confirmation_message(api_xml_http_response_encode(get_lang('InvitationDenied')));
}
if (isset($_POST['delete_friend_id'])) {
- UserFriend::removed_friend((int)$my_delete_friend);
+ SocialManager::removed_friend((int)$my_delete_friend);
}
if(isset($_POST['user_id_friend_q']) && isset($_POST['type_friend_q'])) {
- UserFriend::qualify_friend((int)$friend_id_qualify,(int)$type_friend_qualify);
+ SocialManager::qualify_friend((int)$friend_id_qualify,(int)$type_friend_qualify);
echo api_xml_http_response_encode(get_lang('AttachContactsToGroupSuccesfuly'));
}
?>
\ No newline at end of file
diff --git a/main/social/search.php b/main/social/search.php
index ade015737f..32446d417c 100644
--- a/main/social/search.php
+++ b/main/social/search.php
@@ -2,284 +2,66 @@
/* For licensing terms, see /dokeos_license.txt */
// name of the language file that needs to be included
-$language_file = array ('registration','admin');
-
+$language_file = array('registration','admin');
require_once '../inc/global.inc.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';
-require_once (api_get_path(LIBRARY_PATH).'sortabletable.class.php');
-require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
-require_once (api_get_path(LIBRARY_PATH).'security.lib.php');
-require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
+$this_section = SECTION_SOCIAL;
+$tool_name = get_lang('Search');
+$interbreadcrumb[]= array ('url' =>'home.php','name' => get_lang('Social'));
-$tool_name = get_lang('SearchAUser');
Display :: display_header($tool_name);
-
-
-// Build search-form
-$form = new FormValidator('search_user', 'get', '', '', null, false);
-$renderer = & $form->defaultRenderer();
-$renderer->setElementTemplate('{element} ');
-$form->add_textfield('keyword', '', false);
-$form->addElement('style_submit_button', 'submit', get_lang('SearchButton'), 'class="search"');
-$form->addElement('static', 'additionalactions', null, $actions);
-$form->display();
-
-
-if (isset ($_GET['keyword'])) {
- if (isset ($_GET['keyword'])) {
- $parameters = array ('keyword' => Security::remove_XSS($_GET['keyword']));
- }
- // Create a sortable table with user-data
- $parameters['sec_token'] = Security::get_token();
+//show the action menu
+SocialManager::show_social_menu();
+echo '';
+echo get_lang('Search');
+echo '
';
+
+$query = $_GET['q'];
+echo UserManager::get_search_form($query);
- $table = new SortableTable('users', 'get_number_of_users', 'get_user_data', (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2);
- $table->set_additional_parameters($parameters);
- $table->set_header(0, '', false);
- $table->set_header(1, get_lang('OfficialCode'));
- if (api_is_western_name_order()) {
- $table->set_header(2, get_lang('FirstName'));
- $table->set_header(3, get_lang('LastName'));
- } else {
- $table->set_header(2, get_lang('LastName'));
- $table->set_header(3, get_lang('FirstName'));
- }
- $table->set_header(4, get_lang('LoginName'));
- $table->set_header(5, get_lang('Email'));
-
- //tag
- $table_tag = new SortableTable('tags', 'get_number_of_user_tags', 'get_user_tag_data');
- $table_tag->set_additional_parameters($parameters);
- $table_tag->set_header(0, '', false);
- $table->set_header(1, get_lang('OfficialCode'));
- if (api_is_western_name_order()) {
- $table_tag->set_header(2, get_lang('FirstName'));
- $table_tag->set_header(3, get_lang('LastName'));
- } else {
- $table_tag->set_header(2, get_lang('LastName'));
- $table_tag->set_header(3, get_lang('FirstName'));
- }
- /*
- //groups
- $table_tag = new SortableTable('groups', 'get_number_of_user_tags', 'get_user_tag_data');
- $table_tag->set_additional_parameters($parameters);
- $table_tag->set_header(0, '', false);
- $table->set_header(1, get_lang('OfficialCode'));
- if (api_is_western_name_order()) {
- $table_tag->set_header(2, get_lang('FirstName'));
- $table_tag->set_header(3, get_lang('LastName'));
- } else {
- $table_tag->set_header(2, get_lang('LastName'));
- $table_tag->set_header(3, get_lang('FirstName'));
- }
-*/
- echo get_lang('Users');
- $table->display_grid();
-
- echo get_lang('Tags');
- $table_tag->display_grid();
- /*
- echo get_lang('Groups');
- $table_group->display_grid();
- */
-}
-
-/**
- * Get the users to display on the current page (fill the sortable-table)
- * @param int offset of first user to recover
- * @param int Number of users to get
- * @param int Column to sort on
- * @param string Order (ASC,DESC)
- * @see SortableTable#get_table_data($from)
- */
-function get_user_tag_data($from, $number_of_items, $column, $direction)
-{
- if (isset ($_GET['keyword'])) {
- $keyword = Database::escape_string($_GET['keyword']);
- }
- $user_tags = UserManager::get_all_user_tags($keyword,'5',$from, $number_of_items);
- return $user_tags;
-}
-
-
-
-/**
- * Get the total number of users on the platform
- * @see SortableTable#get_total_number_of_items()
- */
-function get_number_of_user_tags()
-{
- $tag_table = Database :: get_main_table(TABLE_MAIN_USER_TAG);
- $sql = "SELECT COUNT(tag) AS total_number_of_items FROM $tag_table u";
- if (isset ($_GET['keyword'])) {
- $keyword = Database::escape_string($_GET['keyword']);
- $sql .= " WHERE (tag LIKE '%".$keyword."%' )";
- }
- $res = Database::query($sql, __FILE__, __LINE__);
- $obj = Database::fetch_object($res);
- return $obj->total_number_of_items;
-}
-
-
-/**
- * Get the users to display on the current page (fill the sortable-table)
- * @param int offset of first user to recover
- * @param int Number of users to get
- * @param int Column to sort on
- * @param string Order (ASC,DESC)
- * @see SortableTable#get_table_data($from)
- */
-function get_user_data($from, $number_of_items, $column, $direction)
-{
- $user_table = Database :: get_main_table(TABLE_MAIN_USER);
- $sql = "SELECT
- u.user_id AS col0,
- u.official_code AS col1,
- ".(api_is_western_name_order()
- ? "u.firstname AS col2,
- u.lastname AS col3,"
- : "u.lastname AS col2,
- u.firstname AS col3,")."
- u.username AS col4,
- u.email AS col5
- FROM $user_table u ";
-
- // adding the filter to see the user's only of the current access_url
- global $_configuration;
- if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls']==true && api_get_current_access_url_id()!=-1) {
- $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
- $sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
- }
-
- if (isset ($_GET['keyword'])) {
- $keyword = Database::escape_string($_GET['keyword']);
- $sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%' OR u.username LIKE '%".$keyword."%' OR u.official_code LIKE '%".$keyword."%' OR u.email LIKE '%".$keyword."%' )";
- } elseif (isset ($_GET['keyword_firstname'])) {
- $admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
- $keyword_firstname = Database::escape_string($_GET['keyword_firstname']);
- $keyword_lastname = Database::escape_string($_GET['keyword_lastname']);
- $keyword_email = Database::escape_string($_GET['keyword_email']);
- $keyword_officialcode = Database::escape_string($_GET['keyword_officialcode']);
- $keyword_username = Database::escape_string($_GET['keyword_username']);
- $keyword_status = Database::escape_string($_GET['keyword_status']);
- $query_admin_table = '';
- $keyword_admin = '';
-
- if ($keyword_status == SESSIONADMIN) {
- $keyword_status = '%';
- $query_admin_table = " , $admin_table a ";
- $keyword_admin = ' AND a.user_id = u.user_id ';
+//I'm searching something
+if ($query != '') {
+ if (isset($query) && $query!='') {
+ //get users from tags
+ $users = UserManager::get_all_user_tags($query, 0, 0, 5);
+
+ $results = array();
+ if (is_array($users)) {
+ echo ''.get_lang('Users').' ';
+
+ foreach($users as $user) {
+ $picture = UserManager::get_picture_user($user['user_id'], $user['picture_uri'],80);
+ $url_open = '';
+ $url_close =' ';
+ $img = $url_open.' '.$url_close;
+ $user['firstname'] = $url_open.$user['firstname'].$url_close;
+
+ $results[] = array($img, $user['firstname'],$user['lastname'],$user['tag']);
+ }
}
- $keyword_active = isset($_GET['keyword_active']);
- $keyword_inactive = isset($_GET['keyword_inactive']);
- $sql .= $query_admin_table." WHERE (u.firstname LIKE '%".$keyword_firstname."%' " .
- "AND u.lastname LIKE '%".$keyword_lastname."%' " .
- "AND u.username LIKE '%".$keyword_username."%' " .
- "AND u.email LIKE '%".$keyword_email."%' " .
- "AND u.official_code LIKE '%".$keyword_officialcode."%' " .
- "AND u.status LIKE '".$keyword_status."'" .
- $keyword_admin;
-
- if ($keyword_active && !$keyword_inactive) {
- $sql .= " AND u.active='1'";
- } elseif($keyword_inactive && !$keyword_active) {
- $sql .= " AND u.active='0'";
- }
- $sql .= " ) ";
- }
-
- // adding the filter to see the user's only of the current access_url
- if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls']==true && api_get_current_access_url_id()!=-1) {
- $sql.= " AND url_rel_user.access_url_id=".api_get_current_access_url_id();
- }
-
- if (!in_array($direction, array('ASC','DESC'))) {
- $direction = 'ASC';
- }
- $column = intval($column);
- $from = intval($from);
- $number_of_items = intval($number_of_items);
-
- $sql .= " ORDER BY col$column $direction ";
- $sql .= " LIMIT $from,$number_of_items";
- $res = Database::query($sql, __FILE__, __LINE__);
-
- $users = array ();
- $t = time();
- while ($user = Database::fetch_row($res)) {
- if ($user[7] == 1 && $user[9] != '0000-00-00 00:00:00') {
- // check expiration date
- $expiration_time = convert_mysql_date($user[9]);
- // if expiration date is passed, store a special value for active field
- if ($expiration_time < $t) {
- $user[7] = '-1';
- }
- }
- // forget about the expiration date field
- $users[] = array($user[0],$user[1],$user[2],$user[3],$user[4],$user[5]);
- }
- return $users;
+ Display::display_sortable_grid('search_users', array(), $results, array('hide_navigation'=>true, 'per_page' => 5), $query_vars, false ,true);
+
+ //get users from tags
+ $groups = GroupPortalManager::get_all_group_tags($query);
+ $results = array();
+ if (is_array($groups) && count($groups)>0) {
+ echo ''.get_lang('Groups').' ';
+ foreach($groups as $group) {
+ $picture = GroupPortalManager::get_picture_group($group['id'], $group['picture_uri'],80);
+ $img = ' ';
+ $tags = GroupPortalManager::get_group_tags($group['id']);
+ $group['name'] = ''.$group['name'].' ';
+ $img = ''.$img.' ';
+ $results[] = array($img, $group['name'],$group['description'],$tags);
+ }
+ }
+ Display::display_sortable_grid('search_users', array(), $results, array('hide_navigation'=>true, 'per_page' => 5), $query_vars, false, array(true,true,true,true,true));
+ }
+} else {
+ //we should show something
}
-
-
-
-/**
- * Get the total number of users on the platform
- * @see SortableTable#get_total_number_of_items()
- */
-function get_number_of_users()
-{
- $user_table = Database :: get_main_table(TABLE_MAIN_USER);
- $sql = "SELECT COUNT(u.user_id) AS total_number_of_items FROM $user_table u";
-
- // adding the filter to see the user's only of the current access_url
- global $_configuration;
- if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls']==true && api_get_current_access_url_id()!=-1) {
- $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
- $sql.= " INNER JOIN $access_url_rel_user_table url_rel_user ON (u.user_id=url_rel_user.user_id)";
- }
-
- if ( isset ($_GET['keyword'])) {
- $keyword = Database::escape_string($_GET['keyword']);
- $sql .= " WHERE (u.firstname LIKE '%".$keyword."%' OR u.lastname LIKE '%".$keyword."%' OR u.username LIKE '%".$keyword."%' OR u.email LIKE '%".$keyword."%' OR u.official_code LIKE '%".$keyword."%') ";
- } elseif (isset ($_GET['keyword_firstname'])) {
- $admin_table = Database :: get_main_table(TABLE_MAIN_ADMIN);
- $keyword_firstname = Database::escape_string($_GET['keyword_firstname']);
- $keyword_lastname = Database::escape_string($_GET['keyword_lastname']);
- $keyword_email = Database::escape_string($_GET['keyword_email']);
- $keyword_officialcode = Database::escape_string($_GET['keyword_officialcode']);
- $keyword_username = Database::escape_string($_GET['keyword_username']);
- $keyword_status = Database::escape_string($_GET['keyword_status']);
- $query_admin_table = '';
- $keyword_admin = '';
- if ($keyword_status == SESSIONADMIN) {
- $keyword_status = '%';
- $query_admin_table = " , $admin_table a ";
- $keyword_admin = ' AND a.user_id = u.user_id ';
- }
- $keyword_active = isset($_GET['keyword_active']);
- $keyword_inactive = isset($_GET['keyword_inactive']);
- $sql .= $query_admin_table .
- " WHERE (u.firstname LIKE '%".$keyword_firstname."%' " .
- "AND u.lastname LIKE '%".$keyword_lastname."%' " .
- "AND u.username LIKE '%".$keyword_username."%' " .
- "AND u.email LIKE '%".$keyword_email."%' " .
- "AND u.official_code LIKE '%".$keyword_officialcode."%' " .
- "AND u.status LIKE '".$keyword_status."'" .
- $keyword_admin;
- if($keyword_active && !$keyword_inactive) {
- $sql .= " AND u.active='1'";
- } elseif($keyword_inactive && !$keyword_active) {
- $sql .= " AND u.active='0'";
- }
- $sql .= " ) ";
- }
-
- // adding the filter to see the user's only of the current access_url
- if ((api_is_platform_admin() || api_is_session_admin()) && $_configuration['multiple_access_urls']==true && api_get_current_access_url_id()!=-1) {
- $sql.= " AND url_rel_user.access_url_id=".api_get_current_access_url_id();
- }
-
- $res = Database::query($sql, __FILE__, __LINE__);
- $obj = Database::fetch_object($res);
- return $obj->total_number_of_items;
-}
\ No newline at end of file
+Display :: display_footer();
+?>
\ No newline at end of file
diff --git a/main/social/select_friend_response.php b/main/social/select_friend_response.php
index 88167f9938..110e061eff 100755
--- a/main/social/select_friend_response.php
+++ b/main/social/select_friend_response.php
@@ -19,8 +19,8 @@ $language_comment=api_xml_http_response_encode(get_lang('SocialInvitesComment'))
$list_get_invitation=array();
$list_get_path_web=array();
$user_id=api_get_user_id();
-$list_get_invitation=UserFriend::get_list_invitation_of_friends_by_user_id($user_id);
-$list_get_path_web=UserFriend::get_list_web_path_user_invitation_by_user_id($user_id);
+$list_get_invitation=SocialManager::get_list_invitation_of_friends_by_user_id($user_id);
+$list_get_path_web=SocialManager::get_list_web_path_user_invitation_by_user_id($user_id);
$number_loop=count($list_get_invitation);
if ($number_loop==0) {
Display::display_normal_message(api_xml_http_response_encode(get_lang('YouDontHaveInvites')));
@@ -47,7 +47,7 @@ cellpadding="0" cellspacing="0" bgcolor="#9DACBF">
-
+
/>
diff --git a/main/social/show_search_image.inc.php b/main/social/show_search_image.inc.php
index cd72bf72ce..02a46e47b6 100755
--- a/main/social/show_search_image.inc.php
+++ b/main/social/show_search_image.inc.php
@@ -34,9 +34,9 @@ $list_path_friends=array();
$user_id=api_get_user_id();
$name_search=Security::remove_XSS($_POST['search_name_q']);
if (isset($name_search) && $name_search!='undefined') {
- $list_path_friends=UserFriend::get_list_path_web_by_user_id($user_id,null,$name_search);
+ $list_path_friends=SocialManager::get_list_path_web_by_user_id($user_id,null,$name_search);
} else {
- $list_path_friends=UserFriend::get_list_path_web_by_user_id($user_id);
+ $list_path_friends=SocialManager::get_list_path_web_by_user_id($user_id);
}
$friend_html='';
$number_of_images=8;
@@ -64,7 +64,7 @@ if (count($list_path_friends)!=0) {
if ($list_friends_file[$j]<>"") {
$user_info=api_get_user_info($list_friends_id[$j]);
$user_name=api_xml_http_response_encode(api_get_person_name($user_info['firstName'], $user_info['lastName']));
- $friends_profile = UserFriend::get_picture_user($list_friends_id[$j], $list_friends_file[$j], 92);
+ $friends_profile = SocialManager::get_picture_user($list_friends_id[$j], $list_friends_file[$j], 92);
$friend_html.='
'.$user_name.' ';
diff --git a/whoisonline.php b/whoisonline.php
index af6f6152f1..42ea359693 100644
--- a/whoisonline.php
+++ b/whoisonline.php
@@ -19,7 +19,8 @@ require_once './main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'social.lib.php';
-
+//social tab
+$this_section = SECTION_SOCIAL;
// table definitions
$track_user_table = Database::get_main_table(TABLE_MAIN_USER);
@@ -130,10 +131,14 @@ function display_user_list($user_list, $_plugins) {
$uid = $user[0];
$user_info = api_get_user_info($uid);
$table_row = array();
- $url = '?id='.$uid.$course_url;
+ if (api_get_setting('allow_social_tool')=='true') {
+ $url = '/main/social/profile.php?u='.$uid.$course_url;
+ } else {
+ $url = '?id='.$uid.$course_url;
+ }
$image_array = UserManager::get_user_picture_path_by_id($uid, 'system', false, true);
- $friends_profile = UserFriend::get_picture_user($uid, $image_array['file'], 92, 'medium_', ' width="90" height="90" ');
+ $friends_profile = SocialManager::get_picture_user($uid, $image_array['file'], 92, 'medium_', ' width="90" height="90" ');
// reduce image
$name = api_get_person_name($user_info['firstName'], $user_info['lastName']);
$table_row[] = ' ';
@@ -247,7 +252,7 @@ function display_individual_user($user_id) {
$user_anonymous = api_get_anonymous_id();
if ($safe_user_id != api_get_user_id() && !api_is_anonymous($safe_user_id)) {
- $user_relation = UserFriend::get_relation_between_contacts(api_get_user_id(), $safe_user_id);
+ $user_relation = SocialManager::get_relation_between_contacts(api_get_user_id(), $safe_user_id);
if ($user_relation == 0 || $user_relation == 6) {
echo ''.Display :: return_icon('add_multiple_users.gif', get_lang('SocialInvitationToFriends')).' '.get_lang('SendInvitation').'
'.Display :: return_icon('mail_send.png', get_lang('SendAMessage')).' '.get_lang('SendAMessage').' ';
@@ -366,6 +371,7 @@ if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) ||
if ($user_list) {
if (!isset($_GET['id'])) {
+ echo UserManager::get_search_form($_GET['q']);
display_user_list($user_list, $_plugins);
} else {
//individual user information - also displays header info
'.get_lang('TryAndFindSomeFriends').'
'; + //javascript:register_friend(this) + //var_dump($pending_invitations); + echo '
'; + echo '
'; + for ($i=0;$i<$count_pending_invitations;$i++) { + //var_dump($invitations); + echo '
'; + echo ''.get_lang('SocialAddToFriends').''; + echo '
'; + echo '
'; + echo '
'; + echo '
'; + echo '
'; + } + + if (!empty($user_info['diplomas'])) { + echo '
'; + } + if (!empty($user_info['openarea'])) { + echo '
'; + } + if (!empty($user_info['teach'])) { + echo '
'; + } + echo '
'; + } + + echo '
'; + echo '
'; + echo '
'; + }*/ + + // Extra information + + if ($show_full_profile) { + //-- Extra Data + $t_uf = Database :: get_main_table(TABLE_MAIN_USER_FIELD); + $t_ufo = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS); + $extra_user_data = UserManager::get_extra_user_data($user_id); + $extra_information = ''; + if (is_array($extra_user_data) && count($extra_user_data)>0 ) { + $extra_information = '
'; + $extra_information .='
'; + } else { + if ($field_type == USER_FIELD_TYPE_DOUBLE_SELECT) { + $id_options = explode(';',$data); + $value_options = array(); + // get option display text from user_field_options table + foreach ($id_options as $id_option) { + $sql = "SELECT option_display_text FROM $t_ufo WHERE id = '$id_option'"; + $res_options = Database::query($sql,__FILE__,__LINE__); + $row_options = Database::fetch_row($res_options); + $value_options[] = $row_options[0]; + } + $extra_information_value .= ''.ucfirst($field_display_text).': '.implode(' ',$value_options).'
'; + } elseif($field_type == USER_FIELD_TYPE_TAG ) { + $user_tags = UserManager::get_user_tags($user_id, $field_id); + $tag_tmp = array(); + foreach ($user_tags as $tags) { + //$tag_tmp[] = $tags['tag']; + $tag_tmp[] = ''.$tags['tag'].''; + } + if (is_array($user_tags) && count($user_tags)>0) { + $extra_information_value .= ''.ucfirst($field_display_text).': '.implode(', ',$tag_tmp).'
'; + } + } else { + $extra_information_value .= ''.ucfirst($field_display_text).': '.$data.'
'; + } + } + } + } + // if there are information to show + if (!empty($extra_information_value)) { + $extra_information .= $extra_information_value; + } + $extra_information .= '
'; + } + // if there are information to show + if (!empty($extra_information_value)) + echo $extra_information; + + + // ---- My Agenda Items + $my_agenda_items = show_simple_personal_agenda($user_id); + if (!empty($my_agenda_items)) { + echo '
'; + echo '
'; + } + + } + + if(!empty($announcement_content)) { + echo '
'; + echo '
'; + echo '
'; //javascript:register_friend(this) @@ -694,10 +466,10 @@ echo '
'; echo '
'; - echo '
'; + echo '
'; - //echo ' '.get_lang('SendMessage').''; - } - echo '
'; // Send message or Add to friend links @@ -761,8 +534,9 @@ echo '
'; } @@ -927,7 +701,7 @@ echo '
'; - echo get_user_feeds($user_id); + echo SocialManager::get_user_feeds($user_id); echo '
'.get_lang('Users').'
'; + + foreach($users as $user) { + $picture = UserManager::get_picture_user($user['user_id'], $user['picture_uri'],80); + $url_open = ''; + $url_close =''; + $img = $url_open.''.get_lang('Groups').'
'; + foreach($groups as $group) { + $picture = GroupPortalManager::get_picture_group($group['id'], $group['picture_uri'],80); + $img = ''.Display :: return_icon('mail_send.png', get_lang('SendAMessage')).' '.get_lang('SendAMessage').''; @@ -366,6 +371,7 @@ if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) || if ($user_list) { if (!isset($_GET['id'])) { + echo UserManager::get_search_form($_GET['q']); display_user_list($user_list, $_plugins); } else { //individual user information - also displays header info