public function submit_all() { if ($this->validateAction()) { if ($this->permissions->canDeleteBlock() && $this->page->isMasterCollection()) { $name = sprintf('delete_block_%s', $this->block->getBlockID()); $queue = \Queue::get($name); if ($_POST['process']) { $obj = new \stdClass(); $messages = $queue->receive(20); foreach ($messages as $key => $p) { $block = unserialize($p->body); $page = \Page::getByID($block['cID'], $block['cvID']); $b = \Block::getByID($block['bID'], $page, $block['arHandle']); if (is_object($b) && !$b->isError()) { $b->deleteBlock(); } $queue->deleteMessage($p); } $obj->totalItems = $queue->count(); if ($queue->count() == 0) { $queue->deleteQueue($name); } $obj->bID = $this->block->getBlockID(); $obj->aID = $this->area->getAreaID(); $obj->message = t('All child blocks deleted successfully.'); echo json_encode($obj); $this->app->shutdown(); } else { $queue = $this->block->queueForDefaultsUpdate($_POST, $queue); } $totalItems = $queue->count(); \View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d block", "%d blocks", $totalItems))); $this->app->shutdown(); } } }
<?php defined('C5_EXECUTE') or die("Access Denied."); use Concrete\Core\Multilingual\Page\Section\Section; $dh = Loader::helper('concrete/dashboard/sitemap'); if (!$dh->canRead()) { die(t("Access Denied.")); } // we have to do this otherwise permissions pointers aren't correct // (cInheritPermissionsFromCID on parent nodes) Core::make('cache/request')->disable(); $q = Queue::get('copy_page'); $includeParent = true; if ($_REQUEST['copyChildrenOnly']) { $includeParent = false; } $db = Loader::db(); if ($_POST['process']) { $obj = new stdClass(); $js = Loader::helper('json'); $messages = $q->receive(Config::get('concrete.limits.copy_pages')); foreach ($messages as $key => $p) { // delete the page here $page = unserialize($p->body); $oc = Page::getByID($page['cID']); // this is the page we're going to copy. // now we check to see if the parent ID of the current record has already been duplicated somewhere. $newCID = $db->GetOne('select cID from QueuePageDuplicationRelations where originalCID = ? and queue_name = ?', array($page['cParentID'], 'copy_page')); if ($newCID > 0) { $dc = Page::getByID($newCID); } else {
<?php defined('C5_EXECUTE') or die("Access Denied."); $u = new User(); $form = Loader::helper('form'); $dh = Core::make('helper/date'); /* @var $dh \Concrete\Core\Localization\Service\Date */ $sh = Loader::helper('concrete/dashboard/sitemap'); if (!$sh->canRead()) { die(t('Access Denied')); } $u = new User(); if ($_POST['task'] == 'delete_pages') { $q = Queue::get('delete_page_request'); if ($_POST['process']) { $obj = new stdClass(); $js = Loader::helper('json'); $messages = $q->receive(Config::get('concrete.limits.delete_pages')); foreach ($messages as $key => $p) { // delete the page here $page = unserialize($p->body); $c = Page::getByID($page['cID']); if ($c->getCollectionID() > 1) { $pkr = new \Concrete\Core\Workflow\Request\DeletePageRequest(); $pkr->setRequestedPage($c); $pkr->setRequesterUserID($u->getUserID()); $u->unloadCollectionEdit($c); $pkr->trigger(); } $q->deleteMessage($p); }
public function queueForDuplication($destination, $includeParent = true) { $pages = array(); $pages = $this->populateRecursivePages($pages, array('cID' => $this->getCollectionID()), $this->getCollectionParentID(), 0, $includeParent); // now, since this is deletion, we want to order the pages by level, which // should get us no funny business if the queue dies. usort($pages, array('Page', 'queueForDuplicationSort')); $q = Queue::get('copy_page'); foreach ($pages as $page) { $page['destination'] = $destination->getCollectionID(); $q->send(serialize($page)); } }
//实例化Memcache $mc = new Memcache(); $mc->connect('127.0.0.1', 11211); //实例化消息队列 $queue = new Queue($mc); $name = "Memcache"; //写入消息队列 $queue->put($name, "Memcache消息队列测试--" . rand(0, 100)); //出消息队列 $temp = $queue->get($name); var_dump($temp); $temp = $queue->status($name); var_dump($temp); echo "<hr/>"; /*******Tokyotrant*******/ echo "Tokyotrant队列测试:<br />"; //实例化Tokyotran $tt = new Memcache(); $tt->connect('127.0.0.1', 1978); //实例化消息队列 $queue = new Queue($tt); $name = "Tokyotrant"; //写入消息队列 $queue->put($name, "Tokyotrant消息队列测试--" . rand(0, 100)); //出消息队列 $temp = $queue->get($name); var_dump($temp); $temp = $queue->status($name); var_dump($temp); echo "<hr/>"; /*******Redis*******/
<?php defined('C5_EXECUTE') or die("Access Denied."); $dh = Loader::helper('concrete/dashboard/sitemap'); if (!$dh->canRead()) { die(t("Access Denied.")); } $q = Queue::get('delete_page'); $isEmptyTrash = false; if ($_POST['process']) { $obj = new stdClass(); $js = Loader::helper('json'); $messages = $q->receive(Config::get('concrete.limits.sitemap_pages')); foreach ($messages as $key => $p) { // delete the page here $page = unserialize($p->body); $c = Page::getByID($page['cID']); $c->delete(); $q->deleteMessage($p); } $obj->totalItems = $q->count(); if ($q->count() == 0) { $q->deleteQueue('delete_page'); } print $js->encode($obj); exit; } else { if ($q->count() == 0) { $c = Page::getByID($_REQUEST['cID']); if ($c->getCollectionPath() == Config::get('concrete.paths.trash')) { $isEmptyTrash = true;
public function getQueueObject() { return Queue::get('job_' . $this->getJobHandle(), array('timeout' => 1)); }
public function flush() { $this->assertLoggedIn(); $this->set('area', 'queues'); try { //how do we find them? $queue = new Queue($this->args('id')); //did we really get someone? if (!$queue->isHydrated()) { throw new Exception("Could not find that queue."); } if ($queue->get('user_id') != User::$me->id) { throw new Exception("You do not own this queue."); } $this->set('queue', $queue); $this->setTitle('Empty Queue - ' . $queue->getName()); if ($this->args('submit')) { Activity::log("emptied the queue <strong>" . $queue->getName() . "</strong>."); $queue->flush(); $this->forwardToUrl($queue->getUrl()); } } catch (Exception $e) { $this->setTitle('Empty Queue - Error'); $this->set('megaerror', $e->getMessage()); } }
public function submit() { if ($this->validateAction() && $this->canAccess()) { $a = \Area::get($this->page, $_GET['arHandle']); $c = $this->page; if (is_object($a)) { $b = \Block::getByID($_GET['bID'], $c, $a); $p = new \Permissions($b); if ($p->canAdminBlock() && $c->isMasterCollection()) { $name = sprintf('update_defaults_%s', $b->getBlockID()); $queue = \Queue::get($name); if ($_POST['process']) { $obj = new \stdClass(); $messages = $queue->receive(20); foreach ($messages as $key => $p) { $record = unserialize($p->body); $page = \Page::getByID($record['cID'], $record['cvID']); if ($record['action'] == 'add_alias') { $this->block->alias($page); } else { if ($record['action'] == 'update_forked_alias') { $forked = \Block::getByID($record['bID'], $page, $record['arHandle']); if (is_object($forked) && !$forked->isError()) { // take the current block that is in defaults, and replace the block on the page // with that block. $existingDisplayOrder = $forked->getBlockDisplayOrder(); $bt = $b->getBlockTypeObject(); // Now we delete the existing forked block. $forked->deleteBlock(); if ($bt->isCopiedWhenPropagated()) { $b = $this->block->duplicate($page, true); } else { $this->block->alias($page); $b = \Block::getByID($this->block->getBlockID(), $page, $record['arHandle']); } $b->setAbsoluteBlockDisplayOrder($existingDisplayOrder); $page->rescanDisplayOrder($record['arHandle']); } } } $queue->deleteMessage($p); } $obj->totalItems = $queue->count(); if ($queue->count() == 0) { $queue->deleteQueue($name); } $obj->bID = $b->getBlockID(); $obj->aID = $a->getAreaID(); $obj->message = t('All child blocks updated successfully.'); echo json_encode($obj); $this->app->shutdown(); } else { $queue = $this->block->queueForDefaultsAliasing($_POST['addBlock'], $queue); } $totalItems = $queue->count(); \View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d pages", "%d pages", $totalItems))); } } } $this->app->shutdown(); }