]> git.mjollnir.org Git - moodle.git/commitdiff
Now, the entry->concept and alias->alias fields are trimmed
authorstronk7 <stronk7>
Fri, 14 May 2004 18:37:30 +0000 (18:37 +0000)
committerstronk7 <stronk7>
Fri, 14 May 2004 18:37:30 +0000 (18:37 +0000)
in edit, import, export, backup and restore.
To solve bug 985
(http://moodle.org/bugs/bug.php?op=show&bugid=985)

mod/glossary/backuplib.php
mod/glossary/edit.php
mod/glossary/import.php
mod/glossary/lib.php
mod/glossary/restorelib.php

index cdbf5d32f133fbd727fc86708335b4c0170c6bef..085d7de11faba344dc004f1ad7e9dc28af3d8067 100644 (file)
 
                     fwrite ($bf,full_tag("ID",6,false,$glo_ent->id));
                     fwrite ($bf,full_tag("USERID",6,false,$glo_ent->userid));
-                    fwrite ($bf,full_tag("CONCEPT",6,false,$glo_ent->concept));
+                    fwrite ($bf,full_tag("CONCEPT",6,false,trim($glo_ent->concept)));
                     fwrite ($bf,full_tag("DEFINITION",6,false,$glo_ent->definition));
                     fwrite ($bf,full_tag("FORMAT",6,false,$glo_ent->format));
                     fwrite ($bf,full_tag("ATTACHMENT",6,false,$glo_ent->attachment));
             foreach ($aliases as $alias) {
                 $status =fwrite ($bf,start_tag("ALIAS",7,true));
 
-                fwrite ($bf,full_tag("ALIAS_TEXT",8,false,$alias->alias));
+                fwrite ($bf,full_tag("ALIAS_TEXT",8,false,trim($alias->alias)));
 
                 $status =fwrite ($bf,end_tag("ALIAS",7,true));        
             }
index fd75a7a2042443d263619a4149cacfcb68d54f59..a11facd1f52a6ce245644519a84d77c965a6d428 100644 (file)
@@ -46,7 +46,7 @@ if ( $confirm ) {
     $newentry->course = $glossary->course;
     $newentry->glossaryid = $glossary->id;
 
-    $newentry->concept = $form->concept;
+    $newentry->concept = trim($form->concept);
     $newentry->definition = $form->text;
     $newentry->format = $form->format;
     $newentry->usedynalink = $form->usedynalink;
@@ -169,6 +169,7 @@ echo "Creating!!!!!";
     if ( isset($form->aliases) ) {
         if ( $aliases = explode("\n",$form->aliases) ) {
             foreach ($aliases as $alias) {
+                $alias = trim($alias);
                 if ($alias) {
                     unset($newalias);
                     $newalias->entryid = $e;
index 717e7e9e961ae99d3ec808cb8dd16e2e8d83857f..1b04887169573882c6d397fc0f5aa276e92bb2dc 100644 (file)
             $xmlentry = $xmlentries[$i];
 
             unset($newentry);
-            $newentry->concept          = addslashes(utf8_decode($xmlentry['#']['CONCEPT'][0]['#']));
+            $newentry->concept          = addslashes(trim(utf8_decode($xmlentry['#']['CONCEPT'][0]['#'])));
             $newentry->definition       = addslashes(utf8_decode($xmlentry['#']['DEFINITION'][0]['#']));
 
             $permissiongranted = 1;
                         unset($newalias);
         
                         $newalias->entryid = $newentry->id;
-                        $newalias->alias = addslashes(utf8_decode($xmlalias['#']['NAME'][0]['#']));
+                        $newalias->alias = addslashes(trim(utf8_decode($xmlalias['#']['NAME'][0]['#'])));
                         $newalias->id = insert_record("glossary_alias",$newalias);
                     }
 
index 80b71d7f5bd7fb642e7aba1563caecba0c1b59ea..8293337daef2bf617e3451472bc3c12377d912bd 100644 (file)
@@ -1576,7 +1576,7 @@ global $CFG;
                 }
                 if ( $entry->approved and $permissiongranted ) {
                     $status = fwrite($h,glossary_start_tag("ENTRY",3,true));
-                    fwrite($h,glossary_full_tag("CONCEPT",4,false,$entry->concept));
+                    fwrite($h,glossary_full_tag("CONCEPT",4,false,trim($entry->concept)));
                     fwrite($h,glossary_full_tag("DEFINITION",4,false,$entry->definition));
                     fwrite($h,glossary_full_tag("FORMAT",4,false,$entry->format));
                     fwrite($h,glossary_full_tag("USEDYNALINK",4,false,$entry->usedynalink));
@@ -1588,7 +1588,7 @@ global $CFG;
                         $status = fwrite ($h,glossary_start_tag("ALIASES",4,true));
                         foreach ($aliases as $alias) {
                             $status = fwrite ($h,glossary_start_tag("ALIAS",5,true));
-                                fwrite($h,glossary_full_tag("NAME",6,false,$alias->alias));
+                                fwrite($h,glossary_full_tag("NAME",6,false,trim($alias->alias)));
                             $status = fwrite($h,glossary_end_tag("ALIAS",5,true));
                         }
                         $status = fwrite($h,glossary_end_tag("ALIASES",4,true));
@@ -1656,7 +1656,7 @@ require_once "../../lib/xmlize.php";
     $line = '';
     if ($h) {
         while ( !feof($h) ) {
-                  $char = fread($h,1024);
+           $char = fread($h,1024);
            $line .= $char;
         }
         fclose($h);
index 5cf818920af7a02df394a2ffc68f5d4aea82838d..92164286d1b3e9dd896579347ad0281614313bb9 100644 (file)
             //Now, build the GLOSSARY_ENTRIES record structure
             $entry->glossaryid = $new_glossary_id;
             $entry->userid = backup_todb($ent_info['#']['USERID']['0']['#']);
-            $entry->concept = backup_todb($ent_info['#']['CONCEPT']['0']['#']);
+            $entry->concept = backup_todb(trim($ent_info['#']['CONCEPT']['0']['#']));
             $entry->definition = backup_todb($ent_info['#']['DEFINITION']['0']['#']);
             $entry->format = backup_todb($ent_info['#']['FORMAT']['0']['#']);
             $entry->attachment = backup_todb($ent_info['#']['ATTACHMENT']['0']['#']);
 
             //Now, build the GLOSSARY_ALIAS record structure
             $alias->entryid = $new_entry_id;
-            $alias->alias = backup_todb($alias_info['#']['ALIAS_TEXT']['0']['#']);
+            $alias->alias = backup_todb(trim($alias_info['#']['ALIAS_TEXT']['0']['#']));
 
             //The structure is equal to the db, so insert the glossary_comments
             $newid = insert_record ("glossary_alias",$alias);