added code to duplicate criteria and type for duplicate smartblock

This commit is contained in:
Robb Ebright 2017-08-17 01:21:26 -04:00
parent c6cfd97b1a
commit 6a11253ce3

View file

@ -322,9 +322,27 @@ class LibraryController extends Zend_Controller_Action
$newBl = new Application_Model_Block(); $newBl = new Application_Model_Block();
$newBl->setCreator(Application_Model_User::getCurrentUser()->getId()); $newBl->setCreator(Application_Model_User::getCurrentUser()->getId());
$newBl->setDescription($originalBl->getDescription()); $newBl->setDescription($originalBl->getDescription());
if ($originalBl->isStatic()) {
Logging::info($originalBl->getCriteria()); $newBl->saveType('static');
//$newBl->saveSmartBlockCriteria(); }
else {
$newBl->saveType('dynamic');
}
// the issue here is that the format that getCriteria provides is different from the format the saveCriteria
// expects due to the useage of startForm. So we either need to write new code that simply copies the database
// or figure out a way to instantiate a form inside of here and save it without modifying it.
//$newBlForm = new Application_Form_SmartBlockCriteria;
//$newBlForm->startForm($id);
$criteria = CcBlockcriteriaQuery::create()->orderByDbCriteria()->findByDbBlockId($id);
foreach ($criteria as &$c) {
$row = new CcBlockcriteria();
$row->setDbCriteria($c->getDbCriteria());
$row->setDbModifier($c->getDbModifier());
$row->setDbValue($c->getDbValue());
$row->setDbExtra($c->getDbExtra());
$row->setDbBlockId($newBl->getId());
$row->save();
}
$newBl->setName(sprintf(_("Copy of %s"), $originalBl->getName())); $newBl->setName(sprintf(_("Copy of %s"), $originalBl->getName()));
} }