From: stronk7 Date: Fri, 14 May 2004 18:37:30 +0000 (+0000) Subject: Now, the entry->concept and alias->alias fields are trimmed X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b965603072f459b2174a7859f4d42b8a5dabb907;p=moodle.git Now, the entry->concept and alias->alias fields are trimmed in edit, import, export, backup and restore. To solve bug 985 (http://moodle.org/bugs/bug.php?op=show&bugid=985) --- diff --git a/mod/glossary/backuplib.php b/mod/glossary/backuplib.php index cdbf5d32f1..085d7de11f 100644 --- a/mod/glossary/backuplib.php +++ b/mod/glossary/backuplib.php @@ -157,7 +157,7 @@ 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)); @@ -257,7 +257,7 @@ 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)); } diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index fd75a7a204..a11facd1f5 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -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; diff --git a/mod/glossary/import.php b/mod/glossary/import.php index 717e7e9e96..1b04887169 100644 --- a/mod/glossary/import.php +++ b/mod/glossary/import.php @@ -152,7 +152,7 @@ $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; @@ -208,7 +208,7 @@ 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); } diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 80b71d7f5b..8293337dae 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -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); diff --git a/mod/glossary/restorelib.php b/mod/glossary/restorelib.php index 5cf818920a..92164286d1 100644 --- a/mod/glossary/restorelib.php +++ b/mod/glossary/restorelib.php @@ -132,7 +132,7 @@ //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']['#']); @@ -311,7 +311,7 @@ //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);