Пример #1
0
 /**
  * Static admin function allowing addition of a learnpath to a course.
  * @param	string	Course code
  * @param	string	Learnpath name
  * @param	string	Learnpath description string, if provided
  * @param	string	Type of learnpath (default = 'guess', others = 'dokeos', 'aicc',...)
  * @param	string	Type of files origin (default = 'zip', others = 'dir','web_dir',...)
  * @param	string	Zip file containing the learnpath or directory containing the learnpath
  * @param	string	Keyword tags to add to the document
  * @return	integer	The new learnpath ID on success, 0 on failure
  */
 function add_lp($course, $name, $description = '', $learnpath = 'guess', $origin = 'zip', $zipname = '', $keyword = '')
 {
     global $charset;
     //if($this->debug>0){error_log('New LP - In learnpath::add_lp()',0);}
     //TODO
     $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
     //check course code exists
     //check lp_name doesn't exist, otherwise append something
     $i = 0;
     $name = learnpath::escape_string($name);
     //session_id
     $session_id = api_get_session_id();
     $check_name = "SELECT * FROM {$tbl_lp} WHERE name = '{$name}'";
     //if($this->debug>2){error_log('New LP - Checking the name for new LP: '.$check_name,0);}
     $res_name = Database::query($check_name, __FILE__, __LINE__);
     while (Database::num_rows($res_name)) {
         //there is already one such name, update the current one a bit
         $i++;
         $name = $name . ' - ' . $i;
         $check_name = "SELECT * FROM {$tbl_lp} WHERE name = '{$name}'";
         //if($this->debug>2){error_log('New LP - Checking the name for new LP: '.$check_name,0);}
         $res_name = Database::query($check_name, __FILE__, __LINE__);
     }
     //new name does not exist yet; keep it
     //escape description
     $description = learnpath::escape_string(api_htmlentities($description, ENT_QUOTES, $charset));
     //Kevin: added htmlentities()
     $type = 1;
     switch ($learnpath) {
         case 'guess':
             break;
         case 'dokeos':
             $type = 1;
             break;
         case 'aicc':
             break;
     }
     switch ($origin) {
         case 'zip':
             //check zipname string. If empty, we are currently creating a new Dokeos learnpath
             break;
         case 'manual':
         default:
             $get_max = "SELECT MAX(display_order) FROM {$tbl_lp}";
             $res_max = Database::query($get_max, __FILE__, __LINE__);
             if (Database::num_rows($res_max) < 1) {
                 $dsp = 1;
             } else {
                 $row = Database::fetch_array($res_max);
                 $dsp = $row[0] + 1;
             }
             $sql_insert = "INSERT INTO {$tbl_lp} " . "(lp_type,name,description,path,default_view_mod," . "default_encoding,display_order,content_maker," . "content_local,js_lib,session_id) " . "VALUES ({$type},'{$name}','{$description}','','embedded'," . "'UTF-8','{$dsp}','Dokeos'," . "'local','','" . Database::escape_string($session_id) . "')";
             //if($this->debug>2){error_log('New LP - Inserting new lp '.$sql_insert,0);}
             $res_insert = Database::query($sql_insert, __FILE__, __LINE__);
             $id = Database::insert_id();
             if (api_get_setting('search_enabled') == 'true' && extension_loaded('xapian')) {
                 //save search engine keyword
                 $searchkey = new SearchEngineManager();
                 $searchkey->idobj = $id;
                 $searchkey->course_code = api_get_course_id();
                 $searchkey->tool_id = TOOL_LEARNPATH;
                 $searchkey->value = $keyword;
                 $searchkey->save();
                 $lp = new learnpath(api_get_course_id(), $id, api_get_user_id());
                 $lp->search_engine_save();
             }
             if ($id > 0) {
                 //insert into item_property
                 api_item_property_update(api_get_course_info(), TOOL_LEARNPATH, $id, 'LearnpathAdded', api_get_user_id());
                 return $id;
             }
             break;
     }
 }
Пример #2
0
 		    $len = $auth_end - $auth_init + 4;
             }
 
 			$author_fixed=substr($author,$auth_init, $len);*/
 $author_fixed = $author;
 $_SESSION['oLP']->set_author(api_convert_encoding($author_fixed, api_get_system_encoding(), $_SESSION['oLP']->encoding));
 //	$_SESSION['oLP']->set_author($author_fixed);
 $_SESSION['oLP']->set_encoding($_REQUEST['lp_encoding']);
 $_SESSION['oLP']->set_maker($_REQUEST['lp_maker']);
 $_SESSION['oLP']->set_proximity($_REQUEST['lp_proximity']);
 $_SESSION['oLP']->set_interface($_REQUEST['lp_interface']);
 $_SESSION['oLP']->set_theme($_REQUEST['lp_theme']);
 $_SESSION['oLP']->update_scorm_debug($_REQUEST['enable_debug']);
 if (api_get_setting('search_enabled') === 'true' && extension_loaded('xapian')) {
     //save search engine keyword
     $searchkey = new SearchEngineManager();
     $searchkey->idobj = $_SESSION['oLP']->get_id();
     $searchkey->course_code = api_get_course_id();
     $searchkey->tool_id = TOOL_LEARNPATH;
     $searchkey->value = $_REQUEST['search_terms'];
     $searchkey->updateKeyWord();
     $_SESSION['oLP']->search_engine_edit();
 }
 if ($_REQUEST['remove_picture']) {
     $_SESSION['oLP']->delete_lp_image();
 }
 if ($_FILES['lp_preview_image']['size'] > 0) {
     $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']);
 }
 if ($_FILES['lp_update_source']['size'] > 0) {
     // a new source has been sent (scorm or aicc)