Ejemplo n.º 1
0
 /**
  * Redirect to startup page after logging in if request contains any params (except security key)
  *
  * @param Mage_Admin_Model_User $user
  * @param Zend_Controller_Request_Http $request
  * @param string|null $alternativeUrl
  * @return null|string
  */
 public function getRedirectUrl(Mage_Admin_Model_User $user, Zend_Controller_Request_Http $request = null, $alternativeUrl = null)
 {
     if (empty($request)) {
         return;
     }
     $countRequiredParams = $this->_urlModel->useSecretKey() && $request->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME) ? 1 : 0;
     $countGetParams = count($request->getUserParams()) + count($request->getQuery());
     return $countGetParams > $countRequiredParams ? $this->_urlModel->getUrl($user->getStartupPageUrl()) : $alternativeUrl;
 }
Ejemplo n.º 2
0
 /**
  * Recursive Build Menu array
  *
  * @param Varien_Simplexml_Element $parent
  * @param string $path
  * @param int $level
  * @return array
  */
 protected function _buildMenuArray(Varien_Simplexml_Element $parent = null, $path = '', $level = 0)
 {
     if (is_null($parent)) {
         $parent = Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode('menu');
     }
     $parentArr = array();
     $sortOrder = 0;
     foreach ($parent->children() as $childName => $child) {
         if (1 == $child->disabled) {
             continue;
         }
         $aclResource = 'admin/' . ($child->resource ? (string) $child->resource : $path . $childName);
         if (!$this->_checkAcl($aclResource) || !$this->_isEnabledModuleOutput($child)) {
             continue;
         }
         if ($child->depends && !$this->_checkDepends($child->depends)) {
             continue;
         }
         $menuArr = array();
         $menuArr['label'] = $this->_getHelperValue($child);
         $menuArr['sort_order'] = $child->sort_order ? (int) $child->sort_order : $sortOrder;
         if ($child->action) {
             $menuArr['url'] = $this->_url->getUrl((string) $child->action, array('_cache_secret_key' => true));
         } else {
             $menuArr['url'] = '#';
             $menuArr['click'] = 'return false';
         }
         $menuArr['active'] = $this->getActive() == $path . $childName || strpos($this->getActive(), $path . $childName . '/') === 0;
         $menuArr['level'] = $level;
         if ($child->children) {
             $menuArr['children'] = $this->_buildMenuArray($child->children, $path . $childName . '/', $level + 1);
         }
         $parentArr[$childName] = $menuArr;
         $sortOrder++;
     }
     uasort($parentArr, array($this, '_sortMenu'));
     while (list($key, $value) = each($parentArr)) {
         $last = $key;
     }
     if (isset($last)) {
         $parentArr[$last]['last'] = true;
     }
     return $parentArr;
 }
Ejemplo n.º 3
0
 public function getUrl($routePath = null, $routeParams = null)
 {
     // Get the original URLs from the registry
     $original_urls = Mage::registry('original_urls');
     // If this value is empty, it is not yet initialized
     if (empty($original_urls)) {
         return parent::getUrl($routePath, $routeParams);
     }
     // Fetch the result from this method
     $rt = parent::getUrl($routePath, $routeParams);
     // Replace the current URL with the original URL
     $store = Mage::app()->getStore();
     if ($store->getConfig('web/secure/use_in_adminhtml') == 1 && isset($original_urls['web/secure/base_url'])) {
         $rt = str_replace($store->getConfig('web/secure/base_url'), $original_urls['web/secure/base_url'], $rt);
     } elseif (isset($original_urls['web/unsecure/base_url'])) {
         $rt = str_replace($store->getConfig('web/unsecure/base_url'), $original_urls['web/unsecure/base_url'], $rt);
     }
     return $rt;
 }
 /**
  * Get the startup page URL for the current user set in the session.
  * @return string
  */
 protected function _getStartpageUri()
 {
     /** @var string */
     $startpageUri = $this->getUser()->getStartupPageUrl();
     return $this->url->getUrl($startpageUri);
 }