* reset setCompany.

This commit is contained in:
xia0ta0
2013-09-03 14:25:20 +08:00
parent 831a383726
commit da1735f3c8
2 changed files with 26 additions and 0 deletions

View File

@@ -22,6 +22,7 @@ class common extends control
parent::__construct();
$this->common->startSession();
$this->common->sendHeader();
$this->common->setCompany();
$this->common->setUser();
$this->common->loadConfigFromDB();
$this->common->loadCustomFromDB();

View File

@@ -36,6 +36,31 @@ class commonModel extends model
header("Cache-control: private");
}
/**
* Set the commpany.
*
* First, search company by the http host. If not found, search by the default domain. Last, use the first as the default.
* After get the company, save it to session.
* @access public
* @return void
*/
public function setCompany()
{
$httpHost = $this->server->http_host;
if($this->session->company)
{
$this->app->company = $this->session->company;
}
else
{
$company = $this->loadModel('company')->getFirst();
if(!$company) $this->app->triggerError(sprintf($this->lang->error->companyNotFound, $httpHost), __FILE__, __LINE__, $exit = true);
$this->session->set('company', $company);
$this->app->company = $company;
}
}
/**
* Set the user info.
*