function instagram_feeds_create_blocks in Instagram Feeds 7
Creates blocks from Instagram Feeds.
Parameters
string $delta: node nid for creating (if not exist) block for this settings. If not set all blocks will be created.
1 call to instagram_feeds_create_blocks()
- instagram_feeds_queue in ./
instagram_feeds.module - Deletes old (not needed) Feeds URLs or create new needed Feeds URL (by cron).
File
- ./
instagram_feeds.module, line 1129
Code
function instagram_feeds_create_blocks($delta = NULL) {
$existing_deltas = variable_get('instagram_feeds_block_ids', array());
$must_have_deltas = db_select('node', 'n')
->fields('n', array(
'nid',
))
->condition('n.status', 1)
->condition('n.type', INSTAGRAM_FEEDS_SETTINGS_NODE_TYPE)
->orderBy('n.nid')
->execute()
->fetchCol();
$deltas_to_delete = array_diff($existing_deltas, $must_have_deltas);
if (count($deltas_to_delete)) {
db_delete('block')
->condition('module', 'instagram_feeds')
->condition('delta', $deltas_to_delete, 'IN')
->execute();
db_delete('block_role')
->condition('module', 'instagram_feeds')
->condition('delta', $deltas_to_delete, 'IN')
->execute();
cache_clear_all();
$existing_deltas = array_diff($existing_deltas, $deltas_to_delete);
}
if (is_null($delta)) {
$new_deltas = array_diff($must_have_deltas, $existing_deltas);
if (count($new_deltas) || count($deltas_to_delete)) {
variable_set('instagram_feeds_block_ids', $must_have_deltas);
cache_clear_all();
}
}
elseif (!in_array($delta, $existing_deltas)) {
$existing_deltas[] = $delta;
sort($existing_deltas);
variable_set('instagram_feeds_block_ids', $existing_deltas);
cache_clear_all();
}
elseif (count($deltas_to_delete)) {
variable_set('instagram_feeds_block_ids', $existing_deltas);
cache_clear_all();
}
}