Browse Source

Ticket #4034 - When Application page type is active Informer area disappears.

AntonLV 4 years ago
parent
commit
85d797f430

+ 3 - 1
inc/classes/BxDolInformer.php

@@ -29,7 +29,7 @@ define('BX_INFORMER_ERROR', 3);
  */
 class BxDolInformer extends BxDolFactory implements iBxDolSingleton
 {
-	protected $_bEnabled = true;
+    protected $_bEnabled = true;
     protected $_aMessages = array();
 
     /**
@@ -41,6 +41,8 @@ class BxDolInformer extends BxDolFactory implements iBxDolSingleton
             trigger_error ('Multiple instances are not allowed for the BxDolInformer class.', E_USER_ERROR);
 
         parent::__construct();
+
+        $this->_addPermanentMessages();
     }
 
     /**

+ 10 - 10
template/scripts/BxBaseInformer.php

@@ -39,24 +39,22 @@ class BxBaseInformer extends BxDolInformer
     public function display ()
     {
     	if(!$this->_bEnabled)
-    		return '';
-
-        $this->_addPermanentMessages();
+            return '';
 
         if (!$this->_aMessages)
             return '';
 
-		$aTmplVarsMessages = array();
+        $aTmplVarsMessages = [];
         foreach ($this->_aMessages as $sId => $a) {
-        	$a['class'] = $this->_aMapType2Class[$a['type']];
+            $a['class'] = $this->_aMapType2Class[$a['type']];
 
-        	$aTmplVarsMessages[] = $a;
+            $aTmplVarsMessages[] = $a;
         }
 
         $this->_addJsCss();
-        return $this->_oTemplate->parseHtmlByName('informer.html', array(
-            'bx_repeat:messages' => $aTmplVarsMessages,
-        ));
+        return $this->_oTemplate->parseHtmlByName('informer.html', [
+            'bx_repeat:messages' => $aTmplVarsMessages
+        ]);
     }
 
     /**
@@ -66,7 +64,9 @@ class BxBaseInformer extends BxDolInformer
     {
         if ($this->_bJsCssAdded)
             return;
-        $this->_oTemplate->addCss(array('informer.css'));
+
+        $this->_oTemplate->addCss(['informer.css']);
+
         $this->_bJsCssAdded = true;
     }
 }

+ 8 - 9
template/scripts/BxBasePageAccount.php

@@ -12,6 +12,7 @@
  */
 class BxBasePageAccount extends BxTemplPage
 {
+    protected $_oInformer;
     protected $_aMapStatus2LangKey = array (
         BX_PROFILE_STATUS_PENDING => '_sys_txt_account_pending',
         BX_PROFILE_STATUS_SUSPENDED => '_sys_txt_account_suspended',
@@ -21,6 +22,10 @@ class BxBasePageAccount extends BxTemplPage
     {
         parent::__construct($aObject, $oTemplate);
 
+        $this->_oInformer = BxDolInformer::getInstance($this->_oTemplate);
+        if($this->_aObject['uri'] == 'account-profile-switcher')
+            $this->_oInformer->remove('sys-account-profile-system');
+
         $oProfile = BxDolProfile::getInstance();
         $aProfileInfo = $oProfile ? $oProfile->getInfo() : false;
 
@@ -44,11 +49,8 @@ class BxBasePageAccount extends BxTemplPage
         // display message if profile isn't active
         if ($oProfile) {
             $sStatus = $oProfile->getStatus();
-            if (isset($this->_aMapStatus2LangKey[$sStatus])) {
-                $oInformer = BxDolInformer::getInstance($this->_oTemplate);
-                if ($oInformer)
-                    $oInformer->add('sys-account-status-not-active', _t($this->_aMapStatus2LangKey[$sStatus]), BX_INFORMER_ALERT);
-            }
+            if(isset($this->_aMapStatus2LangKey[$sStatus]))
+                $this->_oInformer->add('sys-account-status-not-active', _t($this->_aMapStatus2LangKey[$sStatus]), BX_INFORMER_ALERT);
         }
 
         // switch profile context
@@ -94,10 +96,7 @@ class BxBasePageAccount extends BxTemplPage
                 else
                     $sInformerMsg = $mixedRes;
 
-                $oInformer = BxDolInformer::getInstance($this->_oTemplate);
-                if($oInformer)
-                    $oInformer->add('sys-account-profile-context-change-result', $sInformerMsg ? $sInformerMsg : _t('_error occured'), true === $mixedRes ? BX_INFORMER_INFO : BX_INFORMER_ERROR);
-
+                $this->_oInformer->add('sys-account-profile-context-change-result', $sInformerMsg ? $sInformerMsg : _t('_error occured'), true === $mixedRes ? BX_INFORMER_INFO : BX_INFORMER_ERROR);
             }
         }
     }

+ 0 - 1
template/scripts/BxBaseServiceProfiles.php

@@ -447,7 +447,6 @@ class BxBaseServiceProfiles extends BxDol
     public function serviceAccountProfileSwitcher ($iAccountId = false, $iActiveProfileId = null, $sUrlProfileAction = '', $bShowAll = 0, $sButtonTitle = '', $sProfileTemplate = '')
     {
     	$oTemplate = BxDolTemplate::getInstance();
-    	BxDolInformer::getInstance($oTemplate)->setEnabled(false);
 
         $oProfilesQuery = BxDolProfileQuery::getInstance();