diff --git a/main/work/work.lib.php b/main/work/work.lib.php index 9450af95d3..861bf9a357 100644 --- a/main/work/work.lib.php +++ b/main/work/work.lib.php @@ -57,7 +57,7 @@ function display_action_links($cur_dir_path, $always_show_tool_options, $always_ if (! $always_show_tool_options && api_is_allowed_to_edit()) { // Create dir - $display_output .= ''.get_lang('CreateDir').' '.get_lang('CreateDir').'   '; + $display_output .= ''.get_lang('CreateDir').' '.get_lang('CreateDir').'   '; // Options $display_output .= "".Display::return_icon('acces_tool.gif', get_lang("EditToolOptions")).' ' . get_lang("EditToolOptions") . "  "; } @@ -293,11 +293,11 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou $group_query = " WHERE post_group_id = '".$_SESSION['toolgroup']."' "; // set to select only messages posted by the user's group $subdirs_query = "AND url NOT LIKE BINARY '$sub_course_dir%/%' AND url LIKE BINARY '$sub_course_dir%'"; } else { - $group_query = ''; - $subdirs_query = "WHERE url NOT LIKE '$sub_course_dir%/%' AND url LIKE '$sub_course_dir%'"; + $group_query = " WHERE post_group_id = '0' "; + $subdirs_query = "AND url NOT LIKE '$sub_course_dir%/%' AND url LIKE '$sub_course_dir%'"; } - $sql_get_publications_list = "SELECT * FROM $work_table $group_query $subdirs_query ".$add_in_where_query." AND session_id IN (0,".intval($id_session).") ORDER BY id"; + $sql_get_publications_list = "SELECT * FROM $work_table $group_query $subdirs_query ".$add_in_where_query." AND session_id IN (0,".intval($id_session).") ORDER BY id"; $sql_get_publications_num = "SELECT count(url) " . "FROM ".$work_table." " . "WHERE url LIKE BINARY '$sub_course_dir%' " . @@ -378,8 +378,13 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou } $session_condition = intval($id_session)!=0 ?"AND work.session_id IN (0,".intval($id_session).")" : ""; - $sql_select_directory= "SELECT prop.lastedit_date, id, author, has_properties, view_properties, description, qualification,id FROM ".$iprop_table." prop INNER JOIN ".$work_table." work ON (prop.ref=work.id) WHERE " . - "work.url LIKE BINARY '".$mydir_temp."' AND work.filetype = 'folder' AND prop.tool='work' $session_condition"; + $sql_select_directory= "SELECT prop.lastedit_date, id, author, has_properties, view_properties, description, qualification,id FROM ".$iprop_table." prop INNER JOIN ".$work_table." work ON (prop.ref=work.id) WHERE "; + if (!empty($_SESSION['toolgroup'])) { + $sql_select_directory.=" work.post_group_id = '".$_SESSION['toolgroup']."' "; // set to select only messages posted by the user's group + } else { + $sql_select_directory.=" work.post_group_id = '0' "; + } + $sql_select_directory.=" AND work.url LIKE BINARY '".$mydir_temp."' AND work.filetype = 'folder' AND prop.tool='work' $session_condition"; $result=api_sql_query($sql_select_directory,__FILE__,__LINE__); $row=Database::fetch_array($result); @@ -1044,9 +1049,9 @@ function insert_all_directory_in_course_table($base_work_dir) active = '0', accepted = '1', filetype = 'folder', - post_group_id = '0', + post_group_id = '".$_GET['toolgroup']."', sent_date = '0000-00-00 00:00:00' "; - //api_sql_query($sql_insert_all, __FILE__, __LINE__); + api_sql_query($sql_insert_all, __FILE__, __LINE__); } } diff --git a/main/work/work.php b/main/work/work.php index 155a54a4ee..bb4d6e9f95 100644 --- a/main/work/work.php +++ b/main/work/work.php @@ -27,7 +27,7 @@ * @author Patrick Cool , Ghent University - ability for course admins to specify wether uploaded documents are visible or invisible by default. * @author Roan Embrechts, code refactoring and virtual course support * @author Frederic Vauthier, directories management -* @version $Id: work.php 17491 2008-12-31 17:45:51Z cfasanando $ +* @version $Id: work.php 17575 2009-01-07 21:51:12Z cvargas1 $ * * @todo refactor more code into functions, use quickforms, coding standards, ... */ @@ -239,12 +239,12 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST' && !sizeof($_POST)) { } } //toolgroup comes from group. the but of tis variable is to limit post to the group of the student -if (!api_is_course_admin()) { +//if (!api_is_course_admin()) { if (!empty ($_GET['toolgroup'])) { $toolgroup = Database::escape_string($_GET['toolgroup']); api_session_register('toolgroup'); } -} +//} //-------------------------------------------------------------------// @@ -465,7 +465,7 @@ if (api_is_allowed_to_edit(false,true)) { active = '0', accepted = '1', filetype = 'folder', - post_group_id = '0', + post_group_id = '".$toolgroup."', sent_date = NOW(), qualification = '".(($_POST['qualification_value']!='') ? Database::escape_string($_POST['qualification_value']) : '') ."', parent_id = '', @@ -781,9 +781,15 @@ if ($ctok==$_POST['sec_token']) { //check the token inserted into the form } } elseif ($newWorkUrl) { + if (isset ($_SESSION['toolgroup'])) { + $post_group_id = $_SESSION['toolgroup']; + } else { + $post_group_id = '0'; + } + /* * SPECIAL CASE ! For a work coming from another area (i.e. groups) - */ + */ $url = str_replace('../../' . $_course['path'] . '/', '', $newWorkUrl); if (!$title) { @@ -797,11 +803,12 @@ if ($ctok==$_POST['sec_token']) { //check the token inserted into the form } $sql = "INSERT INTO " . $work_table . " - SET url = '" . $url . "', - title = '" . $title . "', - description = '" . $description . "', - author = '" . $authors . "', - sent_date = NOW(), + SET url = '" . $url . "', + title = '" . $title . "', + description = '" . $description . "', + author = '" . $authors . "', + post_group_id = '".$post_group_id."', + sent_date = NOW(), session_id = ".intval($id_session); api_sql_query($sql, __FILE__, __LINE__); @@ -815,9 +822,9 @@ if ($ctok==$_POST['sec_token']) { //check the token inserted into the form for ($i = 0; $i < count($list_id); $i++) { api_item_property_update($_course, 'work', $list_id[$i], 'FolderUpdated', $user_id); } - + } - + /* * SPECIAL CASE ! For a work edited */ @@ -870,7 +877,6 @@ if ($ctok==$_POST['sec_token']) { //check the token inserted into the form } } } - if (!empty($_POST['submitWork']) && !empty($succeed) && !$id) { //last value is to check this is not "just" an edit //YW Tis part serve to send a e-mail to the tutors when a new file is sent