* when either the visisted domain or default domain has not the related company, use the first.

This commit is contained in:
wangchunsheng
2010-01-26 08:15:29 +00:00
parent 2562218fec
commit 9d26d39772
2 changed files with 10 additions and 1 deletions
+4 -1
View File
@@ -289,7 +289,9 @@ EOT;
/**
* 设置当前访问的公司信息。
*
* 首先尝试按照当前访问的域名查找对应的公司信息,如果无法查到,再按照默认的域名进行查找。
* 首先尝试按照当前访问的域名查找对应的公司信息,
* 如果无法查到,再按照默认的域名进行查找。
* 如果还无法查到,则取第一个公司作为默认的公司。
* 获取公司信息之后,将其写入到$_SESSION中。
*
* @access public
@@ -305,6 +307,7 @@ EOT;
{
$company = $this->company->getByDomain();
if(!$company and isset($this->config->default->domain)) $company = $this->company->getByDomain($this->config->default->domain);
if(!$company) $company = $this->company->getFirst();
if(!$company) $this->app->error(sprintf($this->lang->error->companyNotFound, $_SERVER['HTTP_HOST']), __FILE__, __LINE__, $exit = true);
$_SESSION['company'] = $company;
$this->app->company = $company;
+6
View File
@@ -36,6 +36,12 @@ class companyModel extends model
{
return $this->dao->select('*')->from(TABLE_COMPANY)->fetchAll();
}
/* 获得第一个公司。*/
public function getFirst()
{
return $this->dao->select('*')->from(TABLE_COMPANY)->orderBy('id')->limit(1)->fetch();
}
/**
* 通过域名查找公司信息。