function _sheetnode_google_import_callback in Sheetnode 7.2
Same name and namespace in other branches
- 6 modules/sheetnode_google/sheetnode_google.import.inc \_sheetnode_google_import_callback()
- 7 modules/sheetnode_google/sheetnode_google.import.inc \_sheetnode_google_import_callback()
1 string reference to '_sheetnode_google_import_callback'
- _sheetnode_google_import_form_submit in modules/
sheetnode_google/ sheetnode_google.import.inc - Internal google import form submit.
File
- modules/
sheetnode_google/ sheetnode_google.import.inc, line 100 - Extension to sheetnode for importing from Google sheets.
Code
function _sheetnode_google_import_callback($node, $params, &$context) {
$spreadsheet = $context['sandbox']['spreadsheet'];
if ($context['sandbox']['total'] > 1 && module_exists('book')) {
// Create book if none present.
if (empty($context['sandbox']['book'])) {
global $user;
$book = new StdClass();
$book->type = 'book';
node_object_prepare($book);
$book->title = $spreadsheet->title->text;
if (empty($book->title)) {
$book->title = t('Untitled Workbook');
}
$book->name = $user->name;
$book->language = LANGUAGE_NONE;
$book->book['bid'] = 'new';
$book->book['plid'] = $book->book['mlid'] = NULL;
// Let other modules alter the book or do other work.
drupal_alter('sheetnode_import', $book, $params, $context);
$book = node_submit($book);
node_save($book);
if ($book->nid) {
$context['results'][] = $book->nid;
$context['sandbox']['book'] = $book;
}
}
// Mark the book as parent to the sheetnode.
$book = $context['sandbox']['book'];
$node->book['bid'] = $book->nid;
$node->book['plid'] = $book->book['mlid'];
$node->book['module'] = 'book';
$node->book['weight'] = $context['sandbox']['current'] - 1;
}
}