first commit
This commit is contained in:
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stRadarPlugin
|
||||
*
|
||||
* Ten plik należy do aplikacji stRadarPlugin opartej na licencji (Professional License SOTE).
|
||||
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
|
||||
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
|
||||
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
|
||||
*
|
||||
* @package stRadarPlugin
|
||||
* @subpackage actions
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/sote (Professional License SOTE)
|
||||
* @version $Id: actions.class.php 10 2009-08-24 09:32:18Z michal $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Klasa stRadarBackendActions
|
||||
*
|
||||
* @package stRadarPlugin
|
||||
* @subpackage actions
|
||||
*/
|
||||
class stRadarBackendActions extends autostRadarBackendActions
|
||||
{
|
||||
/**
|
||||
* Przeciążenie aktualizacji config'a
|
||||
*/
|
||||
protected function updateConfigFromRequest()
|
||||
{
|
||||
$config = $this->getRequestParameter('config');
|
||||
|
||||
if ($config['ads_tracker']==1) {
|
||||
appAdsTracker::checkCompare("radar",1);
|
||||
} else {
|
||||
appAdsTracker::checkCompare("radar",0);
|
||||
}
|
||||
|
||||
parent::updateConfigFromRequest();
|
||||
|
||||
$this->dispatcher->notify(new sfEvent($this, 'stCeneoBackendActions.updateConfigFromRequest'), array('config' => $this->config));
|
||||
}
|
||||
|
||||
public function executeProductEnable()
|
||||
{
|
||||
$ids = $this->getRequestParameter('radar[selected]', array());
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$c = new Criteria();
|
||||
$c->add(RadarPeer::PRODUCT_ID, $id);
|
||||
$Radar = RadarPeer::doSelectOne($c);
|
||||
|
||||
if (null === $Radar) {
|
||||
$Radar = new Radar();
|
||||
$Radar->setProductId($id);
|
||||
}
|
||||
|
||||
$Radar->setActive(true);
|
||||
$Radar->save();
|
||||
}
|
||||
|
||||
return $this->redirect('stRadarBackend/list?page=' . $this->getRequestParameter('page', 1));
|
||||
}
|
||||
|
||||
public function executeProductDisable()
|
||||
{
|
||||
$ids = $this->getRequestParameter('radar[selected]', array());
|
||||
|
||||
/**
|
||||
* @var Radar $Radar
|
||||
*/
|
||||
foreach (RadarPeer::retrieveByPKs(array_values($ids)) as $Radar) {
|
||||
$Radar->delete();
|
||||
}
|
||||
|
||||
return $this->redirect('stRadarBackend/list?page=' . $this->getRequestParameter('page', 1));
|
||||
}
|
||||
|
||||
protected function addFiltersCriteria($c)
|
||||
{
|
||||
if (isset($this->filters['code_is_empty'])) {
|
||||
$criterion = $c->getNewCriterion(ProductPeer::CODE, '');
|
||||
$criterion->addOr($c->getNewCriterion(ProductPeer::CODE, null, Criteria::ISNULL));
|
||||
$c->add($criterion);
|
||||
} else if (isset($this->filters['code']) && $this->filters['code'] !== '') {
|
||||
if (method_exists($this, 'filterCriteriaByProductCode')) {
|
||||
$filter_anyway = !$this->filterCriteriaByProductCode($c, $this->filters['code']);
|
||||
} else {
|
||||
$filter_anyway = true;
|
||||
}
|
||||
|
||||
if ($filter_anyway) {
|
||||
$c->add(ProductPeer::CODE, '%' . $this->filters['code'] . '%', Criteria::LIKE);
|
||||
}
|
||||
}
|
||||
if (isset($this->filters['product_is_empty'])) {
|
||||
$criterion = $c->getNewCriterion(ProductPeer::OPT_NAME, '');
|
||||
$criterion->addOr($c->getNewCriterion(ProductPeer::OPT_NAME, null, Criteria::ISNULL));
|
||||
$c->add($criterion);
|
||||
} else if (isset($this->filters['product']) && $this->filters['product'] !== '') {
|
||||
if (method_exists($this, 'filterCriteriaByProductOptName')) {
|
||||
$filter_anyway = !$this->filterCriteriaByProductOptName($c, $this->filters['product']);
|
||||
} else {
|
||||
$filter_anyway = true;
|
||||
}
|
||||
|
||||
if ($filter_anyway) {
|
||||
$c->add(ProductPeer::OPT_NAME, '%' . $this->filters['product'] . '%', Criteria::LIKE);
|
||||
}
|
||||
}
|
||||
if (isset($this->filters['active_is_empty'])) {
|
||||
$criterion = $c->getNewCriterion(RadarPeer::ACTIVE, '');
|
||||
$criterion->addOr($c->getNewCriterion(RadarPeer::ACTIVE, null, Criteria::ISNULL));
|
||||
$c->add($criterion);
|
||||
} else if (isset($this->filters['active']) && $this->filters['active'] !== '') {
|
||||
if ($this->filters['active'] == null || $this->filters['active'] == 0) {
|
||||
$criterion = $c->getNewCriterion(RadarPeer::ACTIVE, '');
|
||||
$criterion->addOr($c->getNewCriterion(RadarPeer::ACTIVE, null, Criteria::ISNULL));
|
||||
$c->add($criterion);
|
||||
}
|
||||
|
||||
if ($this->filters['active'] == 1) {
|
||||
$c->add(RadarPeer::ACTIVE, $this->filters['active']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($this->filters) {
|
||||
$c->add(RadarPeer::PRODUCT_ID, 0, Criteria::NOT_EQUAL);
|
||||
}
|
||||
|
||||
$this->getDispatcher()->notify(new sfEvent($this, 'autoStRadarBackendActions.addFiltersCriteria', array('criteria' => $c)));
|
||||
}
|
||||
|
||||
public function executeAddAll()
|
||||
{
|
||||
RadarPeer::doDeleteAll();
|
||||
|
||||
$con = Propel::getConnection();
|
||||
|
||||
$con->executeQuery(sprintf(
|
||||
"INSERT INTO %s(%s, %s) (SELECT %s, 1 FROM %s)",
|
||||
RadarPeer::TABLE_NAME,
|
||||
RadarPeer::PRODUCT_ID,
|
||||
RadarPeer::ACTIVE,
|
||||
ProductPeer::ID,
|
||||
ProductPeer::TABLE_NAME
|
||||
));
|
||||
|
||||
return $this->redirect('stRadarBackend/list?page=' . $this->getRequestParameter('page', 1));
|
||||
}
|
||||
|
||||
public function executeDeleteAll()
|
||||
{
|
||||
RadarPeer::doDeleteAll();
|
||||
|
||||
return $this->redirect('stRadarBackend/list?page=' . $this->getRequestParameter('page', 1));
|
||||
}
|
||||
|
||||
protected function getRadarOrCreate($id = 'id')
|
||||
{
|
||||
$radar = RadarPeer::retrieveByProduct($this->related_object);
|
||||
|
||||
if (null === $radar) {
|
||||
if ($this->hasRequestParameter('id')) {
|
||||
return $this->redirect('@stRadarPlugin?action=create&product_id=' . $this->related_object->getId().'&view=default');
|
||||
} else {
|
||||
$radar = new Radar();
|
||||
$radar->setProduct($this->related_object);
|
||||
}
|
||||
}
|
||||
|
||||
return $radar;
|
||||
}
|
||||
|
||||
public function executeGenerateCustom()
|
||||
{
|
||||
parent::executeGenerateCustom();
|
||||
|
||||
$i18n = $this->getContext()->getI18n();
|
||||
$this->getBreadcrumbsBuilder()->getDefaultBreadcrumbs()->add($i18n->__('Generowanie pliku'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user