http://www.atutor.ca/atutor/mantis/view.php?id=4373
authorCindy Li <cli@ocad.ca>
Tue, 29 Jun 2010 19:29:57 +0000 (19:29 -0000)
committerCindy Li <cli@ocad.ca>
Tue, 29 Jun 2010 19:29:57 +0000 (19:29 -0000)
http://www.atutor.ca/atutor/mantis/view.php?id=4360
http://www.atutor.ca/atutor/mantis/view.php?id=4361

docs/home/ims/ims_import.php
docs/home/imscc/ims_export.php
docs/include/classes/DAO/OAuthServerTokensDAO.class.php
docs/include/constants.inc.php

index a163a55..15042c1 100644 (file)
@@ -141,7 +141,7 @@ function check_available_size($course_id)
                        header('Location: '.$_base_path.'tools/tile/index.php');
                } 
                else if ($oauth_import) {
-                       echo "error=".urlencode('Empty OAuth token');
+                       echo "error=".urlencode('No space for the content.');
                }
                else {
                        header('Location: '.$_SERVER['HTTP_REFERER']);
@@ -257,8 +257,10 @@ function checkResources($import_path){
        //other arrays. 
        //Using sizeof make sure it's not a subset of array2.
        //-1 on data because it always contain the imsmanifest.xml file
-       if (!empty($result) || sizeof($data)-1>sizeof($filearray)){
-               $msg->addError(array('IMPORT_CARTRIDGE_FAILED', _AT('ims_missing_references')));
+       if (!$skip_ims_validation){
+               if (!empty($result) || sizeof($data)-1>sizeof($filearray)){
+                       $msg->addError(array('IMPORT_CARTRIDGE_FAILED', _AT('ims_missing_references')));
+               }
        }
        return true;
 }
@@ -399,7 +401,7 @@ function rehash($items){
        /* builds the $path array which is the path from the root to the current element */
        function startElement($parser, $name, $attrs) {
                global $items, $path, $package_base_path, $all_package_base_path, $package_real_base_path;
-               global $element_path, $import_path;
+               global $element_path, $import_path, $skip_ims_validation;
                global $xml_base_path, $test_message, $content_type;
                global $current_identifier, $msg, $ns, $ns_cp;
                global $course_primary_lang;
@@ -427,7 +429,7 @@ function rehash($items){
                }
                
                //validate namespaces
-               if(isset($attrs['xsi:schemaLocation']) && $name=='manifest'){
+               if(!$skip_ims_validation && isset($attrs['xsi:schemaLocation']) && $name=='manifest'){
                        $schema_location = array();
                        $split_location = preg_split('/[\r\n\s]+/', trim($attrs['xsi:schemaLocation']));
 
@@ -463,7 +465,7 @@ function rehash($items){
                        $xml_base_path = $attrs['xml:base'];
                } else if ($name == 'file') {
                        // check if it misses file references
-                       if(!isset($attrs['href']) || $attrs['href']==''){
+                       if(!$skip_ims_validation && (!isset($attrs['href']) || $attrs['href']=='')){
                                //$msg->addError('MANIFEST_NOT_WELLFORM');
                                $msg->addError(array('IMPORT_CARTRIDGE_FAILED', _AT('ims_missing_references')));
                        }
@@ -596,7 +598,7 @@ function rehash($items){
                        if(!isset($items[$current_identifier]) && $attrs['href']!=''){
                                $items[$current_identifier]['href']      = $attrs['href'];
                        }
-                       if (substr($attrs['href'], 0, 7) == 'http://' || substr($attrs['href'], 0, 8) == 'https://' || file_exists($import_path.$attrs['href'])){
+                       if (substr($attrs['href'], 0, 7) == 'http://' || substr($attrs['href'], 0, 8) == 'https://' || file_exists($import_path.$attrs['href']) || $skip_ims_validation){
                                $items[$current_identifier]['file'][] = $attrs['href'];
                        } else {
                                //$msg->addError('');
@@ -789,6 +791,11 @@ if (!isset($_POST['submit']) && !isset($_POST['cancel']) && !isset($_GET['oauth_
 
 $cid = intval($_POST['cid']);
 
+//If user chooses to ignore validation.
+if(isset($_POST['ignore_validation']) && $_POST['ignore_validation']==1) {
+       $skip_ims_validation = true;
+}
+
 if (isset($_REQUEST['url']) && ($_REQUEST['url'] != 'http://') ) {
        if ($content = @file_get_contents($_REQUEST['url'])) {
                $filename = substr(time(), -6). '.zip';
@@ -1003,10 +1010,6 @@ if (file_exists($import_path . $glossary_path . 'glossary.xml')){
 */
 // Check if all the files exists in the manifest, iff it's a IMS CC package.
 if ($content_type == 'IMS Common Cartridge') {
-       //If user chooses to ignore validation.
-       if(isset($_POST['ignore_validation']) && $_POST['ignore_validation']==1) {
-               $skip_ims_validation = true;
-       }
        checkResources($import_path);
 }
 
index 85df743..36da368 100644 (file)
@@ -167,7 +167,14 @@ class MyHandler {
                        }
                } else if (isset($elements[$name]) && ($attrs[$elements[$name]] != '')) {
                        /* we know exactly which attribute contains the reference to the file. */
-                       $my_files[] = $attrs[$elements[$name]];
+                       //hack, if param[name]=autoplay or autostart, ignore
+                       if (!($name=='param' && ($attrs['name']=='autoplay' || $attrs['name']=='autoStart'))){
+                           //skip glossary.html, tweak to accomodate atutor imscp; also skip repeated entries.
+                           if (strpos($attrs[$elements[$name]], 'glossary.html')===false 
+                                   && !in_array($attrs[$elements[$name]], $my_files)){
+                               $my_files[] = $attrs[$elements[$name]];
+                           }
+                       }
                }
     }
     function closeHandler(& $parser,$name) { }
index 40617f2..1b9ae96 100644 (file)
@@ -183,7 +183,8 @@ class OAuthServerTokensDAO extends DAO {
        function isTokenExpired($token)
        {
                $sql = "SELECT unix_timestamp(now()) now_timestamp, 
-                              unix_timestamp(addtime(ost.assign_date, osc.expire_threshold)) expire_timestamp
+                              osc.expire_threshold,
+                              unix_timestamp(addtime(ost.assign_date, sec_to_time(osc.expire_threshold))) expire_timestamp
                          FROM ".TABLE_PREFIX."oauth_server_consumers osc, ".TABLE_PREFIX."oauth_server_tokens ost
                         WHERE osc.consumer_id=ost.consumer_id
                           AND ost.token='".$token."'
@@ -191,10 +192,11 @@ class OAuthServerTokensDAO extends DAO {
                         ORDER BY ost.assign_date DESC";
                $row = $this->execute($sql);
 
-               if (!is_array($row) || $row['now_timestamp'] > $row['expire_timestamp'])
+               if ((!is_array($row) || $row['now_timestamp'] > $row['expire_timestamp']) && $row['expire_threshold'] != 0) {
                        return true;
-               else
+               } else {
                        return false;
+               }
        }
 }
 ?>
\ No newline at end of file
index 9d269d9..8ff237f 100644 (file)
@@ -20,9 +20,9 @@ if (!defined('TR_INCLUDE_PATH')) { exit; }
 $_config_defaults = array();
 $_config_defaults['site_name']          = '';
 $_config_defaults['contact_email']      = '';
-$_config_defaults['max_file_size']      = 1048576;  // 1MB
-$_config_defaults['max_course_size']    = 10485760; // 10 MB
-$_config_defaults['max_file_size']      = 1048576;  // 1MB
+$_config_defaults['max_file_size']      = 10485760;  // 10MB
+$_config_defaults['max_course_size']    = 104857600; // 100 MB
+$_config_defaults['max_file_size']      = 10485760;  // 10MB
 $_config_defaults['illegal_extentions'] = 'exe|asp|php|php3|bat|cgi|pl|com|vbs|reg|pcd|pif|scr|bas|inf|vb|vbe|wsc|wsf|wsh';
 $_config_defaults['default_language']   = 'en';
 $_config_defaults['use_captcha']               = 0;    //use captcha?