, 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 * @version $Id: work.php 10418 2006-12-07 15:48:25Z pcool $ * * @todo refactor more code into functions, use quickforms, coding standards, ... */ /** ============================================================================== * STUDENT PUBLICATIONS MODULE * * Note: for a more advanced module, see the dropbox tool. * This one is easier with less options. * This tool is better used for publishing things, * sending in assignments is better in the dropbox. * * GOALS * ***** * Allow student to quickly send documents immediately * visible on the course website. * * The script does 5 things: * * 1. Upload documents * 2. Give them a name * 3. Modify data about documents * 4. Delete link to documents and simultaneously remove them * 5. Show documents list to students and visitors * * On the long run, the idea is to allow sending realvideo . Which means only * establish a correspondence between RealServer Content Path and the user's * documents path. * * All documents are sent to the address /$_configuration['root_sys']/$currentCourseID/document/ * where $currentCourseID is the web directory for the course and $_configuration['root_sys'] * usually /var/www/html * * Modified by Patrick Cool, february 2004: * Allow course managers to specify wether newly uploaded documents should * be visible or unvisible by default * This is ideal for reviewing the uploaded documents before the document * is available for everyone. * * note: maybe the form to change the behaviour should go into the course * properties page? * note 2: maybe a new field should be created in the course table for * this behaviour. * * We now use the show_score field since this is not used. * ============================================================================== */ /* ============================================================================== INIT SECTION ============================================================================== */ // name of the language file that needs to be included $language_file = "work"; // Section (for the tabs) $this_section=SECTION_COURSES; // @todo why is this needed? //session if(isset($_GET['id_session'])) { $_SESSION['id_session'] = $_GET['id_session']; } /* ----------------------------------------------------------- Including necessary files ----------------------------------------------------------- */ include('../inc/global.inc.php'); include_once(api_get_path(LIBRARY_PATH) . "course.lib.php"); include_once(api_get_path(LIBRARY_PATH) . "debug.lib.inc.php"); include_once(api_get_path(LIBRARY_PATH) . "events.lib.inc.php"); include_once('work.lib.php'); /* ----------------------------------------------------------- Table definitions ----------------------------------------------------------- */ $tool_name = get_lang(TOOL_STUDENTPUBLICATION); $main_course_table = Database::get_main_table(TABLE_MAIN_COURSE); $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); $iprop_table = Database::get_course_table(TABLE_ITEM_PROPERTY); /* ----------------------------------------------------------- Constants and variables ----------------------------------------------------------- */ $user_id = api_get_user_id(); $course_code = $_course['sysCode']; $is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course($user_id, $course_code, $_SESSION['id_session']); $currentCourseRepositorySys = api_get_path(SYS_COURSE_PATH) . $_course["path"]."/"; $currentCourseRepositoryWeb = api_get_path(WEB_COURSE_PATH) . $_course["path"]."/"; $currentUserFirstName = $_user['firstName']; $currentUserLastName = $_user['lastName']; $authors = $_POST['authors']; $delete = $_REQUEST['delete']; $description = $_REQUEST['description']; $display_tool_options = $_REQUEST['display_tool_options']; $display_upload_form = $_REQUEST['display_upload_form']; $edit = $_REQUEST['edit']; $make_invisible = $_REQUEST['make_invisible']; $make_visible = $_REQUEST['make_visible']; $origin = $_REQUEST['origin']; $submitGroupWorkUrl = $_REQUEST['submitGroupWorkUrl']; $submitWork = $_REQUEST['submitWork']; $title = $_REQUEST['title']; $uploadvisibledisabled = $_REQUEST['uploadvisibledisabled']; $id = (int) $_REQUEST['id']; /* ----------------------------------------------------------- Configuration settings ----------------------------------------------------------- */ $link_target_parameter = ""; //or e.g. "target=\"_blank\""; $always_show_tool_options = false; $always_show_upload_form = false; if ($always_show_tool_options) { $display_tool_options = true; } if ($always_show_upload_form) { $display_upload_form = true; } api_protect_course_script(); /* ----------------------------------------------------------- More init stuff ----------------------------------------------------------- */ if(isset($_POST['cancelForm']) && !empty($_POST['cancelForm'])) { header('Location: '.$_SERVER['PHP_SELF']."?origin=$origin"); exit(); } if ($submitWork || $submitGroupWorkUrl) { // these libraries are only used for upload purpose // so we only include them when necessary include_once(api_get_path(INCLUDE_PATH)."lib/fileUpload.lib.php"); include_once(api_get_path(INCLUDE_PATH)."lib/fileDisplay.lib.php"); // need format_url function } // If the POST's size exceeds 8M (default value in php.ini) the $_POST array is emptied // If that case happens, we set $submitWork to 1 to allow displaying of the error message // The redirection with header() is needed to avoid apache to show an error page on the next request if($_SERVER['REQUEST_METHOD'] == 'POST' && !sizeof($_POST)) { if(strstr($_SERVER['REQUEST_URI'],'?')) { header('Location: '.$_SERVER['REQUEST_URI'].'&submitWork=1'); exit(); } else { header('Location: '.$_SERVER['REQUEST_URI'].'?submitWork=1'); exit(); } } //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 (!empty($_GET['toolgroup'])){ $toolgroup=$_GET['toolgroup']; api_session_register('toolgroup'); } } /* ----------------------------------------------------------- Header ----------------------------------------------------------- */ if ($origin != 'learnpath') { Display::display_header($tool_name,"Work"); } else { //we are in the learnpath tool ?> 0){ $emailto = ''; while($row_email = Database::fetch_array($res_resp)){ if(!empty($row_email['myemail'])){ $emailto .= $row_email['myemail'].','; } } $emailfromaddr = get_setting('emailAdministrator'); $emailfromname = get_setting('siteName'); $emailsubject = "[".get_setting('siteName')."] "; // The body can be as long as you wish, and any combination of text and variables //$emailbody=get_lang('SendMailBody').' '.api_get_path(WEB_CODE_PATH)."work/work.php?".api_get_cidreq()." ($title)\n\n".get_setting('administratorName')." ".get_setting('administratorSurname')."\n". get_lang('Manager'). " ".get_setting('siteName')."\nT. ".get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".get_setting('emailAdministrator'); $emailbody=get_lang('SendMailBody').' '.api_get_path(WEB_CODE_PATH)."work/work.php?".api_get_cidreq()." ($title)\n\n".get_setting('administratorName')." ".get_setting('administratorSurname')."\n". get_lang('Manager'). " ".get_setting('siteName')."\n" .get_lang('Email') ." : ".get_setting('emailAdministrator'); // Here we are forming one large header line // Every header must be followed by a \n except the last $emailheaders = "From: ".get_setting('administratorSurname')." ".get_setting('administratorName')." <".get_setting('emailAdministrator').">\n"; $emailheaders .= "Reply-To: ".get_setting('emailAdministrator'); // Because I predefined all of my variables, this api_send_mail() function looks nice and clean hmm? @api_send_mail( $emailto, $emailsubject, $emailbody, $emailheaders); } $message = get_lang('DocAdd'); if ($uploadvisibledisabled && !$is_allowed_to_edit) { $message .= "
".get_lang('_doc_unvisible')."
"; } //stats if(!$Id) { $Id = $insertId; } event_upload($Id); $submit_success_message = $message . "
\n"; Display::display_normal_message($submit_success_message); } //{ /*======================================= Display links to upload form and tool options =======================================*/ display_action_links($always_show_tool_options, $always_show_upload_form); /*======================================= Display form to upload document =======================================*/ if($is_course_member) { if ($display_upload_form || $edit) { if($edit){ //Get the author ID for that document from the item_property table $is_author = false; $author_sql = "SELECT * FROM $iprop_table WHERE tool = 'work' AND insert_user_id='$user_id' AND ref=".mysql_real_escape_string($edit); $author_qry = api_sql_query($author_sql,__FILE__,__LINE__); if(Database::num_rows($author_qry)==1) { $is_author = true; } } echo "
\n", "\n"; if(!empty($error_message)) Display::display_error_message($error_message); if ($submitGroupWorkUrl) // For user comming from group space to publish his work { $realUrl = str_replace ($_configuration['root_sys'], $_configuration['root_web'], str_replace("\\", "/", realpath($submitGroupWorkUrl) ) ) ; echo "\n", "\n", "\n", "\n"; } elseif ($edit && ($is_allowed_to_edit or $is_author)) { $workUrl = $currentCourseRepositoryWeb.$workUrl; echo "\n", "\n", "\n", "\n"; } else // else standard upload option { echo "\n", "\n", "\n", "\n"; } if(empty($authors)) { $authors=$_user['lastName']." ".$_user['firstName']; } echo "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "", "\n", "\n", "
", "", get_lang("Document")," : ", "", "",$realUrl,"", "
", "\n", get_lang('Document')," : ", "", "",$workUrl,"", "
", get_lang("DownloadFile"),"  ", "", "", "
", get_lang("TitleWork"),"  ", "", "", "
", get_lang("Authors")."  ", "", "\n", "
", get_lang("Description"),"  ", "", "", "", "", "
", ""; if($submitWork || $edit) { echo "  "; } echo "
\n", "
\n", "

 

"; } } else { //the user is not registered in this course echo "

" . get_lang("MustBeRegisteredUser") . "

"; } /* ============================================================================== Display of tool options ============================================================================== */ if ($display_tool_options) { display_tool_options($uploadvisibledisabled, $origin); } /* ============================================================================== Display list of student publications ============================================================================== */ /*if ( ! $id )*/ display_student_publications_list($currentCourseRepositoryWeb, $link_target_parameter, $dateFormatLong, $origin); //} /* ============================================================================== Footer ============================================================================== */ if ($origin != 'learnpath') { //we are not in the learning path tool Display::display_footer(); } ?>