MDL-35034 Repository: Google Docs does not fail when download is restricted

Conflicts:

	lib/googleapi.php
	repository/googledocs/lib.php
This commit is contained in:
Frederic Massart
2012-09-03 14:09:36 +08:00
parent 8f3c8e78a9
commit 1e12baddde
2 changed files with 14 additions and 10 deletions
+11 -9
View File
@@ -316,19 +316,21 @@ class google_docs {
$source = 'https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key='.$docid.'&exportFormat=xls';
break;
case 'pdf':
case 'file':
$title = (string)$gdoc->title;
$source = (string)$gdoc->content[0]->attributes()->src;
// Some files don't have a content probably because the download has been restricted.
if (isset($gdoc->content)) {
$source = (string)$gdoc->content[0]->attributes()->src;
}
break;
}
if(!empty($source)){
$files[] = array( 'title' => $title,
'url' => "{$gdoc->link[0]->attributes()->href}",
'source' => $source,
'date' => usertime(strtotime($gdoc->updated)),
'thumbnail' => (string) $OUTPUT->pix_url(file_extension_icon($title, 32))
);
}
$files[] = array( 'title' => $title,
'url' => "{$gdoc->link[0]->attributes()->href}",
'source' => $source,
'date' => usertime(strtotime($gdoc->updated)),
'thumbnail' => (string) $OUTPUT->pix_url(file_extension_icon($title, 32))
);
}
return $files;