Exemple #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) {
                                     $oTenant = $this->oTenantsApi->GetTenantById($oDomain->IdTenant);
                                     if ($oTenant) {
                                         $sName = 'Default domain (' . $oTenant->Login . ')';
                                     }
                                 }
                             }
                         } else {
                             $oDomain = $this->oDomainsApi->GetDomainByName($aDomainArray[1]);
                             if ($oDomain) {
                                 if ($oDomain->IsDefaultTenantDomain) {
                                     $sName = 'Default domain';
                                 }
                             }
                         }
                     }
                     $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));
                 }
             }
         }
     }
 }