[svn r16414] audio upload learnpath step

skala
Patrick Cool 17 years ago
parent 76b031a0ff
commit 8b53ab7ba8
  1. 3
      main/inc/lib/add_course.lib.inc.php
  2. 3
      main/install/migrate-db-1.8.5-1.8.6-pre.sql
  3. 31
      main/newscorm/learnpath.class.php

@ -1113,7 +1113,8 @@ function update_Db_course($courseDbName)
"launch_data text not null default ''," . //data from imsmanifest <item>
"max_time_allowed char(13) NULL default ''," . //data from imsmanifest <adlcp:maxtimeallowed>
"terms TEXT NULL," . // contains the indexing tags (search engine)
"search_did INT NULL)"; // contains the internal search-engine id of this element
"search_did INT NULL,".// contains the internal search-engine id of this element
"audio VARCHAR(250))"; // contains the audio file that goes with the learning path step
if(!api_sql_query($sql, __FILE__, __LINE__))
{
error_log($sql,0);

@ -68,4 +68,5 @@ ALTER TABLE group_info ADD INDEX ( session_id ) ;
ALTER TABLE survey ADD session_id SMALLINT UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE survey ADD INDEX ( session_id ) ;
CREATE TABLE wiki_discuss (id int NOT NULL auto_increment, publication_id int NOT NULL default 0, userc_id int NOT NULL default 0, comment text NOT NULL, p_score varchar(255) default NULL, timestamp timestamp(14) NOT NULL, PRIMARY KEY (id) );
CREATE TABLE wiki_mailcue (id int NOT NULL, user_id int NOT NULL, type text NOT NULL, group_id int DEFAULT NULL, KEY (id) );
CREATE TABLE wiki_mailcue (id int NOT NULL, user_id int NOT NULL, type text NOT NULL, group_id int DEFAULT NULL, KEY (id) );
ALTER TABLE lp_item ADD audio VARCHAR(250);

@ -543,6 +543,30 @@ class learnpath {
}
// upload audio
if (!empty($_FILES['mp3']['tmp_name']))
{
// create the audio folder if it does not exist yet
global $_course;
$filepath = api_get_path('SYS_COURSE_PATH').$_course['path'].'/document/';
if(!is_dir($filepath.'audio'))
{
$perm = api_get_setting('permissions_for_new_directories');
$perm = octdec(!empty($perm)?$perm:'0770');
mkdir($filepath.'audio2',$perm);
$audio_id=add_document($_course,'/audio','folder',0,'audio');
api_item_property_update($_course, TOOL_DOCUMENT, $audio_id, 'FolderCreated', api_get_user_id());
}
// upload the file in the documents tool
include_once(api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php');
handle_uploaded_document($_course, $_FILES['mp3'],api_get_path('SYS_COURSE_PATH').$_course['path'].'/document','/audio',api_get_user_id(),'','','','','',false);
// store the mp3 file in the lp_item table
$sql_insert_audio = "UPDATE $tbl_lp_item SET audio = '".Database::escape_string($_FILES['mp3']['name'])."' WHERE id = '".Database::escape_string($new_item_id)."'";
api_sql_query($sql_insert_audio, __FILE__, __LINE__);
}
return $new_item_id;
}
@ -4379,7 +4403,6 @@ class learnpath {
// for flv player : to prevent edition problem with firefox, we have to use a strange tip (don't blame me please)
$content = str_replace('</body>','<style type="text/css">body{}</style></body>',$content);
if(!file_exists($filepath . $filename))
{
if($fp = @fopen($filepath . $filename, 'w'))
@ -6181,7 +6204,7 @@ class learnpath {
*/
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
$form = new FormValidator('form','POST',api_get_self()."?".$_SERVER["QUERY_STRING"]);
$form = new FormValidator('form','POST',api_get_self()."?".$_SERVER["QUERY_STRING"],'','enctype="multipart/form-data"');
$defaults["title"]=mb_convert_encoding($item_title,$charset,$this->encoding);
$defaults["description"]=mb_convert_encoding($item_description,$charset,$this->encoding);
@ -6275,6 +6298,10 @@ class learnpath {
$select_prerequisites=$form->addElement('select', 'prerequisites', get_lang('Prerequisites').'&nbsp;:', '', 'id="prerequisites" style="background:#F8F8F8; border:1px solid #999999; font-family:Arial, Verdana, Helvetica, sans-serif; font-size:12px; width:300px;"');
$select_prerequisites->addOption(get_lang("NoPrerequisites"),0,'style="padding-left:3px;"');
// form element for uploading an mp3 file
$form->addElement('file','mp3',get_lang('File'),'id="mp3" size="45"');
$form->addRule('file', 'The extension of the Song file should be *.mp3', 'filename', '/^.*\.mp3$/');
if ( api_get_setting('search_enabled') === 'true' )
{
//add terms field

Loading…
Cancel
Save