Beispiel #1
0
 /**
  * Postdispatch action handler
  *
  */
 public function logAction()
 {
     if (!$this->_initAction) {
         return;
     }
     $username = null;
     $userId = null;
     if (Mage::getSingleton('admin/session')->isLoggedIn()) {
         $userId = Mage::getSingleton('admin/session')->getUser()->getId();
         $username = Mage::getSingleton('admin/session')->getUser()->getUsername();
     }
     $errors = Mage::getModel('adminhtml/session')->getMessages()->getErrors();
     $loggingEvent = Mage::getModel('enterprise_logging/event')->setData(array('ip' => Mage::helper('core/http')->getRemoteAddr(), 'x_forwarded_ip' => Mage::app()->getRequest()->getServer('HTTP_X_FORWARDED_FOR'), 'user' => $username, 'user_id' => $userId, 'is_success' => empty($errors), 'fullaction' => $this->_initAction, 'error_message' => implode("\n", array_map(create_function('$a', 'return $a->toString();'), $errors))));
     if ($this->_actionName == 'denied') {
         $_conf = $this->_config->getNode($this->_initAction);
         if (!$_conf || !$this->_config->isActive($this->_initAction)) {
             return;
         }
         $loggingEvent->setAction($_conf->action);
         $loggingEvent->setEventCode($_conf->getParent()->getParent()->getName());
         $loggingEvent->setInfo(Mage::helper('enterprise_logging')->__('Access denied'));
         $loggingEvent->setIsSuccess(0);
         $loggingEvent->save();
         return;
     }
     if ($this->_skipNextAction) {
         return;
     }
     $loggingEvent->setAction($this->_eventConfig->action);
     $loggingEvent->setEventCode($this->_eventConfig->getParent()->getParent()->getName());
     try {
         $callback = isset($this->_eventConfig->post_dispatch) ? (string) $this->_eventConfig->post_dispatch : false;
         $defaulfCallback = 'postDispatchGeneric';
         $classMap = $this->_getCallbackFunction($callback, $this->_controllerActionsHandler, $defaulfCallback);
         $handler = $classMap['handler'];
         $callback = $classMap['callback'];
         if (!$handler) {
             return;
         }
         if ($handler->{$callback}($this->_eventConfig, $loggingEvent, $this)) {
             /**
              * Prepare additional info
              */
             if ($this->getCollectedAdditionalData()) {
                 $loggingEvent->setAdditionalInfo($this->getCollectedAdditionalData());
             }
             $loggingEvent->save();
             if ($eventId = $loggingEvent->getId()) {
                 foreach ($this->_eventChanges as $changes) {
                     if ($changes && ($changes->getOriginalData() || $changes->getResultData())) {
                         $changes->setEventId($eventId);
                         $changes->save();
                     }
                 }
             }
         }
     } catch (Exception $e) {
         Mage::logException($e);
     }
 }
Beispiel #2
0
 public function updateMenu(Varien_Simplexml_Element $node)
 {
     $entityTypesCollection = $this->_getEntityTypesCollection();
     if ($entityTypesCollection->getSize()) {
         $children = $node->addChild('children');
         $index = 0;
         foreach ($entityTypesCollection as $entityType) {
             $index += 10;
             $menuItem = $children->addChild(sprintf('goodahead_etm_entity_type_%d', $entityType->getId()));
             $menuItem->addChild('title', strlen($entityType->getEntityTypeName()) ? $entityType->getEntityTypeName() : $entityType->getEntityTypeCode());
             $menuItem->addChild('sort_order', $index);
             $menuItem->addChild('action', sprintf((string) $node->base_link, $entityType->getId()));
         }
     } else {
         $nodeName = $node->getName();
         unset($node->getParent()->{$nodeName});
     }
 }
Beispiel #3
0
 /**
  * Enter description here ...
  * @param Varien_Simplexml_Element $config
  * @param array | null $fields
  * @param string | null $module
  */
 protected function _translateConfigRecursively($config, $fields = null, $module = null)
 {
     if ($fields && in_array($config->getName(), $fields)) {
         $name = $config->getName();
         $parent = $config->getParent();
         $value = (string) $config;
         $moduleName = $module ? $module : $this->_getModuleName();
         $parent->{$name} = Mage::app()->getTranslator()->translate(array(new Mage_Core_Model_Translate_Expr($value, $moduleName)));
     }
     $fields = isset($config['translate']) ? explode(',', (string) $config['translate']) : null;
     $module = isset($config['module']) ? (string) $config['module'] : null;
     foreach ($config->children() as $key => $value) {
         $this->_translateConfigRecursively($value, $fields, $module);
     }
 }
Beispiel #4
0
 /**
  * Whether parent node of specified node can be considered a safe container
  *
  * @param Varien_Simplexml_Element $node
  * @return bool
  */
 protected static function _isParentSafe(Varien_Simplexml_Element $node)
 {
     $parentAttributes = $node->getParent()->attributes();
     if (isset($parentAttributes['name'])) {
         if (!in_array($parentAttributes['name'], self::$_containerWhiteList)) {
             return false;
         }
     }
     return true;
 }