185 lines
6.5 KiB
PHP
185 lines
6.5 KiB
PHP
<?php
|
|
/**
|
|
* SOTESHOP/stSklepy24Plugin
|
|
*
|
|
* Ten plik należy do aplikacji stSklepy24Plugin 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 stSklepy24Plugin
|
|
* @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 stSklepy24BackendActions
|
|
*
|
|
* @package stSklepy24Plugin
|
|
* @subpackage actions
|
|
*/
|
|
class stSklepy24BackendActions extends autostSklepy24BackendActions
|
|
{
|
|
/**
|
|
* Przeciążenie aktualizacji config'a
|
|
*/
|
|
protected function updateConfigFromRequest()
|
|
{
|
|
$config = $this->getRequestParameter('config');
|
|
|
|
if (is_dir(sfConfig::get('sf_plugins_dir')."/appAdsTrackerPlugin")) {
|
|
if ($config['ads_tracker']==1) {
|
|
appAdsTracker::checkCompare("sklepy24",1);
|
|
} else {
|
|
appAdsTracker::checkCompare("sklepy24",0);
|
|
}
|
|
}
|
|
|
|
parent::updateConfigFromRequest();
|
|
|
|
$this->dispatcher->notify(new sfEvent($this, 'stCeneoBackendActions.updateConfigFromRequest'), array('config' => $this->config));
|
|
}
|
|
|
|
public function executeProductEnable()
|
|
{
|
|
$ids = $this->getRequestParameter('sklepy24[selected]', array());
|
|
|
|
foreach ($ids as $id) {
|
|
$c = new Criteria();
|
|
$c->add(Sklepy24Peer::PRODUCT_ID, $id);
|
|
$Sklepy24 = Sklepy24Peer::doSelectOne($c);
|
|
|
|
if (null === $Sklepy24) {
|
|
$Sklepy24 = new Sklepy24();
|
|
$Sklepy24->setProductId($id);
|
|
}
|
|
|
|
$Sklepy24->setActive(true);
|
|
$Sklepy24->save();
|
|
}
|
|
|
|
return $this->redirect('stSklepy24Backend/list?page=' . $this->getRequestParameter('page', 1));
|
|
}
|
|
|
|
public function executeProductDisable()
|
|
{
|
|
$ids = $this->getRequestParameter('sklepy24[selected]', array());
|
|
|
|
/**
|
|
* @var Sklepy24 $Sklepy24
|
|
*/
|
|
foreach (Sklepy24Peer::retrieveByPKs(array_values($ids)) as $Sklepy24) {
|
|
$Sklepy24->delete();
|
|
}
|
|
|
|
return $this->redirect('stSklepy24Backend/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(Sklepy24Peer::ACTIVE, '');
|
|
$criterion->addOr($c->getNewCriterion(Sklepy24Peer::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(Sklepy24Peer::ACTIVE, '');
|
|
$criterion->addOr($c->getNewCriterion(Sklepy24Peer::ACTIVE, null, Criteria::ISNULL));
|
|
$c->add($criterion);
|
|
}
|
|
|
|
if ($this->filters['active'] == 1) {
|
|
$c->add(Sklepy24Peer::ACTIVE, $this->filters['active']);
|
|
}
|
|
}
|
|
|
|
|
|
if ($this->filters) {
|
|
$c->add(Sklepy24Peer::PRODUCT_ID, 0, Criteria::NOT_EQUAL);
|
|
}
|
|
|
|
$this->getDispatcher()->notify(new sfEvent($this, 'autoStSklepy24BackendActions.addFiltersCriteria', array('criteria' => $c)));
|
|
}
|
|
|
|
public function executeAddAll()
|
|
{
|
|
Sklepy24Peer::doDeleteAll();
|
|
|
|
$con = Propel::getConnection();
|
|
|
|
$con->executeQuery(sprintf(
|
|
"INSERT INTO %s(%s, %s) (SELECT %s, 1 FROM %s)",
|
|
Sklepy24Peer::TABLE_NAME,
|
|
Sklepy24Peer::PRODUCT_ID,
|
|
Sklepy24Peer::ACTIVE,
|
|
ProductPeer::ID,
|
|
ProductPeer::TABLE_NAME
|
|
));
|
|
|
|
return $this->redirect('stSklepy24Backend/list?page=' . $this->getRequestParameter('page', 1));
|
|
}
|
|
|
|
public function executeDeleteAll()
|
|
{
|
|
Sklepy24Peer::doDeleteAll();
|
|
|
|
return $this->redirect('stSklepy24Backend/list?page=' . $this->getRequestParameter('page', 1));
|
|
}
|
|
|
|
protected function getSklepy24OrCreate($id = 'id')
|
|
{
|
|
$sklepy24 = Sklepy24Peer::retrieveByProduct($this->related_object);
|
|
|
|
if (null === $sklepy24) {
|
|
if ($this->hasRequestParameter('id')) {
|
|
return $this->redirect('@stSklepy24Plugin?action=create&product_id=' . $this->related_object->getId().'&view=default');
|
|
} else {
|
|
$sklepy24 = new Sklepy24();
|
|
$sklepy24->setProduct($this->related_object);
|
|
}
|
|
}
|
|
|
|
return $sklepy24;
|
|
}
|
|
|
|
public function executeGenerateCustom()
|
|
{
|
|
parent::executeGenerateCustom();
|
|
|
|
$i18n = $this->getContext()->getI18n();
|
|
$this->getBreadcrumbsBuilder()->getDefaultBreadcrumbs()->add($i18n->__('Generowanie pliku'));
|
|
}
|
|
} |