in edit, import, export, backup and restore.
To solve bug 985
(http://moodle.org/bugs/bug.php?op=show&bugid=985)
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));
}
$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;
if ( isset($form->aliases) ) {
if ( $aliases = explode("\n",$form->aliases) ) {
foreach ($aliases as $alias) {
+ $alias = trim($alias);
if ($alias) {
unset($newalias);
$newalias->entryid = $e;
$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);
}
}
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));
$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));
$line = '';
if ($h) {
while ( !feof($h) ) {
- $char = fread($h,1024);
+ $char = fread($h,1024);
$line .= $char;
}
fclose($h);
//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);