Skip to content

Instantly share code, notes, and snippets.

@hissy
Created October 27, 2013 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hissy/7176912 to your computer and use it in GitHub Desktop.
Save hissy/7176912 to your computer and use it in GitHub Desktop.
[concrete5/job] Remove all blocks in Sidebar area from all pages
<?php
defined('C5_EXECUTE') or die("Access Denied.");
class RemoveSidebarContents extends QueueableJob {
public $jSupportsQueue = true;
public function getJobName() {
return t("Remove Sidebar Contents");
}
public function getJobDescription() {
return t("Remove all blocks in Sidebar area from all pages");
}
public function start(Zend_Queue $q) {
$db = Loader::db();
$rsPages = $db->query('SELECT cID FROM Pages WHERE (cID > 1) ORDER BY cID');
while($rowPage = $rsPages->FetchRow()) {
$q->send($rowPage['cID']);
}
$rsPages->Close();
unset($rsPages);
}
public function finish(Zend_Queue $q) {
return t('Process completed.');
}
public function processQueueItem(Zend_Queue_Message $msg) {
$c = Page::getByID($msg->body, 'RECENT');
if (is_object($c) && $c->isMasterCollection() == false) {
$blocks = $c->getBlocks('Sidebar');
foreach ($blocks as $block) {
$block->deleteBlock();
}
$c->rescanDisplayOrder('Sidebar');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment