/**
  * Return event date by in store timezone, with specified format
  *
  * @param string $type (start, end)
  * @param Enterprise_CatalogEvent_Model_Event $event
  * @param string $format
  * @return string
  */
 protected function _getEventDate($type, $event, $format)
 {
     $date = new Zend_Date($this->_getLocale()->getLocale());
     // changing timezone to UTC
     $date->setTimezone(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);
     $dateString = $event->getData('date_' . $type);
     $date->set($dateString, Varien_Date::DATETIME_INTERNAL_FORMAT);
     if ($timezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE)) {
         // changing timezone to default store timezone
         $date->setTimezone($timezone);
     }
     return $date->toString($format);
 }
Esempio n. 2
0
 /**
  * Validate catalog event save
  *
  * @param Enterprise_CatalogEvent_Model_Event $model
  */
 public function catalogEventSaveBefore($model)
 {
     $category = Mage::getModel('catalog/category')->load($model->getCategoryId());
     if (!$category->getId()) {
         $this->_throwSave();
     }
     // save event only for exclusive categories
     $rootFound = false;
     foreach ($this->_role->getAllowedRootCategories() as $rootPath) {
         if ($category->getPath() === $rootPath || 0 === strpos($category->getPath(), "{$rootPath}/")) {
             $rootFound = true;
             break;
         }
     }
     if (!$rootFound) {
         $this->_throwSave();
     }
     // in non-exclusive mode allow to change the image only
     if ($model->getId()) {
         if (!$this->_role->hasExclusiveCategoryAccess($category->getPath())) {
             foreach (array_keys($model->getData()) as $key) {
                 if ($model->dataHasChangedFor($key) && $key !== 'image') {
                     $model->setData($key, $model->getOrigData($key));
                 }
             }
         }
     }
 }