Ejemplo n.º 1
0
 /**
  * @param string $sTab
  * @param ap_Screen $oScreen
  */
 protected function initTableList($sTab, ap_Screen &$oScreen)
 {
     if (AP_TAB_DOMAINS === $sTab) {
         $iTenantId = $this->oAdminPanel->RType() ? $this->oAdminPanel->TenantId() : 0;
         $sSearchDesc = $oScreen->GetSearchDesc();
         $iAllCount = $this->oDomainsApi->getDomainCount($sSearchDesc, $iTenantId);
         $oScreen->EnableSearch($iAllCount > 1 || $sSearchDesc);
         $bAddDefaultDomain = false;
         if (0 === $iTenantId && $this->oAdminPanel->HasAccessDomain(0)) {
             $iAllCount += ceil($iAllCount / ($oScreen->GetLinesPerPage() - 1));
             $bAddDefaultDomain = true;
             $oScreen->AddListItem(0, array('Name' => CApi::I18N('ADMIN_PANEL/DOMAINS_DEFAULT')), true);
         }
         $oScreen->SetAllListCount($iAllCount);
         $aDomainsList = $this->oDomainsApi->getDomainsList($oScreen->GetPage(), $bAddDefaultDomain ? $oScreen->GetLinesPerPage() - 1 : $oScreen->GetLinesPerPage(), $oScreen->GetOrderBy(), $oScreen->GetOrderType(), $sSearchDesc, $iTenantId);
         if (is_array($aDomainsList) && 0 < count($aDomainsList)) {
             foreach ($aDomainsList as $iDomainId => $aDomainArray) {
                 if ($this->oAdminPanel->HasAccessDomain($iDomainId)) {
                     $sName = isset($aDomainArray[1]) ? $aDomainArray[1] : '';
                     if (strpos($sName, '*') !== false) {
                         $oTenant = null;
                         if ($iTenantId === 0) {
                             $oDomain = $this->oDomainsApi->getDomainByName($aDomainArray[1]);
                             if ($oDomain) {
                                 if ($oDomain->IsDefaultTenantDomain && $this->oAdminPanel->RType()) {
                                     $oTenant = $this->oTenantsApi->getTenantById($oDomain->IdTenant);
                                     if ($oTenant) {
                                         $sName = CApi::I18N('ADMIN_PANEL/DOMAINS_DEFAULT_TENANT') . ' (' . $oTenant->Login . ')';
                                     }
                                 } else {
                                     continue;
                                 }
                             }
                         } else {
                             $oDomain = $this->oDomainsApi->getDomainByName($aDomainArray[1]);
                             if ($oDomain) {
                                 if ($oDomain->IsDefaultTenantDomain) {
                                     $sName = CApi::I18N('ADMIN_PANEL/DOMAINS_DEFAULT_TENANT');
                                 }
                             }
                         }
                     } else {
                         if ($this->oAdminPanel->RType()) {
                             $oDomain = $this->oDomainsApi->getDomainByName($aDomainArray[1]);
                             if ($oDomain) {
                                 $oTenant = $this->oTenantsApi->getTenantById($oDomain->IdTenant);
                                 if ($oTenant) {
                                     if ($iTenantId === 0) {
                                         $sName = $sName . ' (' . $oTenant->Login . ')';
                                     }
                                 } else {
                                     $sName = $sName . ' (' . CApi::I18N('ADMIN_PANEL/NOT_IN_TENANT') . ')';
                                 }
                             }
                         }
                     }
                     $oScreen->AddListItem($iDomainId, array('Type' => $aDomainArray[0] ? '<img src="static/images/mailsuite-domain-icon-big.png">' : '<img src="static/images/wm-domain-icon-big.png">', 'Name' => $sName));
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * @param string $sTab
  * @param ap_Screen $oScreen
  */
 protected function initTableList($sTab, ap_Screen &$oScreen)
 {
     if (AP_TAB_DOMAINS === $sTab) {
         $iTenantId = $this->oAdminPanel->RType() ? $this->oAdminPanel->TenantId() : 0;
         $sSearchDesc = $oScreen->GetSearchDesc();
         $iAllCount = $this->oDomainsApi->GetDomainCount($sSearchDesc, $iTenantId);
         $oScreen->EnableSearch($iAllCount > 1 || $sSearchDesc);
         $bAddDefaultDomain = false;
         if (0 === $iTenantId && $this->oAdminPanel->HasAccessDomain(0)) {
             $iAllCount += ceil($iAllCount / ($oScreen->GetLinesPerPage() - 1));
             $bAddDefaultDomain = true;
             $oScreen->AddListItem(0, array('Name' => CApi::I18N('ADMIN_PANEL/DOMAINS_DEFAULT')), true);
         }
         $oScreen->SetAllListCount($iAllCount);
         $aDomainsList = $this->oDomainsApi->GetDomainsList($oScreen->GetPage(), $bAddDefaultDomain ? $oScreen->GetLinesPerPage() - 1 : $oScreen->GetLinesPerPage(), $oScreen->GetOrderBy(), $oScreen->GetOrderType(), $sSearchDesc, $iTenantId);
         if (is_array($aDomainsList) && 0 < count($aDomainsList)) {
             foreach ($aDomainsList as $iDomainId => $aDomainArray) {
                 if ($this->oAdminPanel->HasAccessDomain($iDomainId)) {
                     $oScreen->AddListItem($iDomainId, array('Type' => $aDomainArray[0] ? '<img src="static/images/mailsuite-domain-icon-big.png">' : '<img src="static/images/wm-domain-icon-big.png">', 'Name' => $aDomainArray[1]));
                 }
             }
         }
     }
 }