diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index e5dbc4de55..529632132d 100644 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -69,8 +69,9 @@ ************************************************************************** */ -include(api_get_path(INCLUDE_PATH).'/lib/mail.lib.inc.php'); -include(api_get_path(INCLUDE_PATH).'/conf/mail.conf.php'); +require_once(api_get_path(INCLUDE_PATH).'/lib/mail.lib.inc.php'); +require_once(api_get_path(INCLUDE_PATH).'/conf/mail.conf.php'); +require_once(api_get_path(INCLUDE_PATH).'/lib/usermanager.lib.php'); /** * This function handles all the forum and forumcategories actions. This is a wrapper for the @@ -1943,7 +1944,7 @@ function display_user_link($user_id, $name) { if ($user_id<>0) { - return "".$name.""; + return ''.$name.''; } else { @@ -1951,6 +1952,40 @@ function display_user_link($user_id, $name) } } +/** +* This function displays the user image from the profile, with a link to the user's details. +* @param int User's database ID +* @param str User's name +* @return string An HTML with the anchor and the image of the user +* @author Julio Montoya +*/ + +function display_user_image($user_id,$name) +{ + $link=''; + $attrb=array(); + + if ($user_id<>0) + { + $image_path = UserManager::get_user_picture_path_by_id($user_id,'web'); + $image_repository = $image_path['dir']; + $existing_image = $image_path['file']; + if (is_array($image_path) && $existing_image!='') { + return $link.''.$name.''; + } + else + return $link.''.$name.''; + + + } + else + { + return $link.''.$name.''; + } + +} + + /** * The thread view counter gets increased every time someone looks at the thread * diff --git a/main/forum/viewthread_flat.inc.php b/main/forum/viewthread_flat.inc.php index 90e71b4e45..0244ffc4b4 100644 --- a/main/forum/viewthread_flat.inc.php +++ b/main/forum/viewthread_flat.inc.php @@ -86,6 +86,11 @@ foreach ($rows as $row) } if($origin!='learnpath') { + + if (api_get_course_setting('allow_user_image_forum')) { + echo '
'.display_user_image($row['user_id'],$name).'
'; + } + echo display_user_link($row['user_id'], $name).'
'; } else diff --git a/main/forum/viewthread_nested.inc.php b/main/forum/viewthread_nested.inc.php index d93e7f800a..63ec9ef608 100644 --- a/main/forum/viewthread_nested.inc.php +++ b/main/forum/viewthread_nested.inc.php @@ -89,6 +89,7 @@ foreach ($rows as $post) { $name=$post['firstname'].' '.$post['lastname']; } + if (api_get_course_setting('allow_user_image_forum')) {echo '
'.display_user_image($post['user_id']).'
'; } echo display_user_link($post['user_id'], $name).'
'; echo $post['post_date'].'

'; // The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum diff --git a/main/forum/viewthread_threaded.inc.php b/main/forum/viewthread_threaded.inc.php index 3eaa2973e9..22ba01cf32 100644 --- a/main/forum/viewthread_threaded.inc.php +++ b/main/forum/viewthread_threaded.inc.php @@ -100,6 +100,7 @@ else { $name=$rows[$display_post_id]['firstname'].' '.$rows[$display_post_id]['lastname']; } +if (api_get_course_setting('allow_user_image_forum')) {echo '
'.display_user_image($rows[$display_post_id]['user_id']).'
'; } echo display_user_link($rows[$display_post_id]['user_id'], $name).'
'; echo $rows[$display_post_id]['post_date'].'

'; // The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum diff --git a/main/inc/lib/add_course.lib.inc.php b/main/inc/lib/add_course.lib.inc.php index b445db71e7..70e40cef77 100644 --- a/main/inc/lib/add_course.lib.inc.php +++ b/main/inc/lib/add_course.lib.inc.php @@ -766,7 +766,7 @@ function update_Db_course($courseDbName) doc_state tinyint unsigned NOT NULL default 1, calendar_state tinyint unsigned NOT NULL default 1, work_state tinyint unsigned NOT NULL default 1, - announcements_state tinyint unsigned NOT NULL default 1, + announcements_state tinyint unsigned databaseNOT NULL default 1, max_student smallint unsigned NOT NULL default 8, self_reg_allowed tinyint unsigned NOT NULL default 0, self_unreg_allowed tinyint unsigned NOT NULL default 0, @@ -1701,6 +1701,7 @@ function fill_Db_course($courseDbName, $courseRepository, $language,$default_doc api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('allow_user_edit_agenda',0,'agenda')"); api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('allow_user_edit_announcement',0,'announcement')"); api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('email_alert_manager_on_new_quiz',0,'quiz')"); + api_sql_query("INSERT INTO `".$TABLESETTING . "`(variable,value,category) VALUES ('allow_user_image_forum',1,'forum')"); /* ----------------------------------------------------------- Course homepage tools for platform admin only diff --git a/main/install/migrate-db-1.8.4-1.8.5-pre.sql b/main/install/migrate-db-1.8.4-1.8.5-pre.sql index 0ea95009cf..641a2a6046 100644 --- a/main/install/migrate-db-1.8.4-1.8.5-pre.sql +++ b/main/install/migrate-db-1.8.4-1.8.5-pre.sql @@ -30,6 +30,7 @@ INSERT INTO settings_current (variable, subkey, type, category, selected_value, INSERT INTO settings_options (variable, value, display_text) VALUES ('openid_authentication', 'true', 'Yes'); INSERT INTO settings_options (variable, value, display_text) VALUES ('openid_authentication', 'false', 'No'); INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext) VALUES ('profile','openid','checkbox','User','false','ProfileChangesTitle','ProfileChangesComment',NULL,'OpenIDURL'); + CREATE TABLE templates (id int NOT NULL auto_increment, title varchar(100) NOT NULL, description varchar(250) NOT NULL, course_code varchar(40) NOT NULL, user_id int NOT NULL, ref_doc int NOT NULL, PRIMARY KEY (id)); ALTER TABLE user ADD openid varchar(255) DEFAULT NULL; ALTER TABLE user ADD INDEX (openid(50)); @@ -77,4 +78,5 @@ ALTER TABLE dropbox_post ADD session_id SMALLINT UNSIGNED NOT NULL ; ALTER TABLE dropbox_post ADD INDEX ( session_id ) ; ALTER TABLE dropbox_file ADD session_id SMALLINT UNSIGNED NOT NULL ; ALTER TABLE dropbox_file ADD INDEX ( session_id ) ; -ALTER TABLE item_property ADD INDEX (tool,ref); \ No newline at end of file +ALTER TABLE item_property ADD INDEX (tool,ref); +INSERT INTO course_setting(variable,value,category) VALUES ('allow_user_image_forum',1,'forum'); \ No newline at end of file