This commit is contained in:
wangyidong
2021-03-31 16:49:34 +08:00
parent 27317517dc
commit 5dd5f12b1f
4 changed files with 62 additions and 30 deletions
+1 -1
View File
@@ -244,7 +244,7 @@ class router extends baseRouter
if($this->dbh and !empty($this->config->db->name) and !defined('IN_UPGRADE'))
{
/* Get story concept in project and product. */
$URSRList = $this->dbh->query('SELECT `key`, `value` FROM' . TABLE_LANG . "WHERE module = 'custom' and section = 'URSRList' and lang = \"{$this->clientLang}\"")->fetchAll();
$URSRList = $this->dbh->query('SELECT `key`, `value` FROM' . TABLE_LANG . "WHERE module = 'custom' and section = 'URSRList' and `key` = \"{$config->URSR}\"")->fetchAll();
/* Get UR pairs and SR pairs. */
$URPairs = array();
+24 -4
View File
@@ -484,7 +484,7 @@ class customModel extends model
* Get UR and SR pairs.
*
* @access public
* @return void
* @return array
*/
public function getURSRPairs()
{
@@ -494,6 +494,11 @@ class customModel extends model
->andWhere('module')->eq('custom')
->andWhere('section')->eq('URSRList')
->fetchAll();
if(empty($langData))
{
$URSR = $this->loadModel('setting')->getURSR();
$langData = $this->dao->select('`key`, `value`, `system`')->from(TABLE_LANG)->where('`key`')->eq($URSR)->andWhere('module')->eq('custom')->andWhere('section')->eq('URSRList')->fetchAll();
}
$URSRPairs = array();
foreach($langData as $id => $content)
@@ -509,11 +514,16 @@ class customModel extends model
* Get UR pairs.
*
* @access public
* @return void
* @return array
*/
public function getURPairs()
{
$URSRList = $this->dao->select('`key`,`value`')->from(TABLE_LANG)->where('module')->eq('custom')->andWhere('section')->eq('URSRList')->andWhere('lang')->eq($this->app->clientLang)->fetchPairs();
if(empty($URSRList))
{
$URSR = $this->loadModel('setting')->getURSR();
$URSRList = $this->dao->select('`key`,`value`')->from(TABLE_LANG)->where('module')->eq('custom')->andWhere('section')->eq('URSRList')->andWhere('`key`')->eq($URSR)->fetchPairs();
}
$URPairs = array();
foreach($URSRList as $key => $value)
@@ -529,11 +539,16 @@ class customModel extends model
* Get SR pairs.
*
* @access public
* @return void
* @return array
*/
public function getSRPairs()
{
$URSRList = $this->dao->select('`key`,`value`')->from(TABLE_LANG)->where('module')->eq('custom')->andWhere('section')->eq('URSRList')->andWhere('lang')->eq($this->app->clientLang)->fetchPairs();
if(empty($URSRList))
{
$URSR = $this->loadModel('setting')->getURSR();
$URSRList = $this->dao->select('`key`,`value`')->from(TABLE_LANG)->where('module')->eq('custom')->andWhere('section')->eq('URSRList')->andWhere('`key`')->eq($URSR)->fetchPairs();
}
$SRPairs = array();
foreach($URSRList as $key => $value)
@@ -549,7 +564,7 @@ class customModel extends model
* Get UR and SR list.
*
* @access public
* @return void
* @return array
*/
public function getURSRList()
{
@@ -561,6 +576,11 @@ class customModel extends model
->andWhere('module')->eq('custom')
->andWhere('section')->eq('URSRList')
->fetchAll();
if(empty($langData))
{
$URSR = $this->loadModel('setting')->getURSR();
$langData = $this->dao->select('`key`, `value`, `system`')->from(TABLE_LANG)->where('`key`')->eq($URSR)->andWhere('module')->eq('custom')->andWhere('section')->eq('URSRList')->fetchAll();
}
$URSRList = array();
foreach($langData as $id => $content)
+1 -1
View File
@@ -872,7 +872,7 @@ class my extends control
$this->view->position[] = $this->lang->my->preference;
$this->view->URSRList = $this->loadModel('custom')->getURSRPairs();
$this->view->URSR = isset($this->config->URSR) ? $this->config->URSR : $this->setting->getItem('owner=system&module=custom&key=URSR');
$this->view->URSR = $this->setting->getURSR();
$this->view->programLink = isset($this->config->programLink) ? $this->config->programLink : 'program-browse';
$this->view->productLink = isset($this->config->productLink) ? $this->config->productLink : 'product-all';
$this->view->projectLink = isset($this->config->projectLink) ? $this->config->projectLink : 'project-browse';
+36 -24
View File
@@ -14,10 +14,10 @@
class settingModel extends model
{
//-------------------------------- methods for get, set and delete setting items. ----------------------------//
/**
* Get value of an item.
*
*
* @param string $paramString see parseItemParam();
* @access public
* @return misc
@@ -29,7 +29,7 @@ class settingModel extends model
/**
* Get some items.
*
*
* @param string $paramString see parseItemParam();
* @access public
* @return array
@@ -40,10 +40,10 @@ class settingModel extends model
}
/**
* Set value of an item.
*
* @param string $path system.common.global.sn or system.common.sn
* @param string $value
* Set value of an item.
*
* @param string $path system.common.global.sn or system.common.sn
* @param string $value
* @access public
* @return void
*/
@@ -78,12 +78,12 @@ class settingModel extends model
/**
* Batch set items, the example:
*
*
* $path = 'system.mail';
* $items->turnon = true;
* $items->smtp->host = 'localhost';
*
* @param string $path like system.mail
* @param string $path like system.mail
* @param array|object $items the items array or object, can be mixed by one level or two levels.
* @access public
* @return bool
@@ -112,7 +112,7 @@ class settingModel extends model
/**
* Delete items.
*
*
* @param string $paramString see parseItemParam();
* @access public
* @return void
@@ -124,7 +124,7 @@ class settingModel extends model
/**
* Parse the param string for select or delete items.
*
*
* @param string $paramString owner=xxx&key=sn and so on.
* @access public
* @return array
@@ -132,7 +132,7 @@ class settingModel extends model
public function parseItemParam($paramString)
{
/* Parse the param string into array. */
parse_str($paramString, $params);
parse_str($paramString, $params);
/* Init fields not set in the param string. */
$fields = 'owner,module,section,key';
@@ -144,7 +144,7 @@ class settingModel extends model
/**
* Create a DAO object to select or delete one or more records.
*
*
* @param array $params the params parsed by parseItemParam() method.
* @param string $method select|delete.
* @access public
@@ -162,7 +162,7 @@ class settingModel extends model
/**
* Get config of system and one user.
*
* @param string $account
* @param string $account
* @access public
* @return array
*/
@@ -189,10 +189,10 @@ class settingModel extends model
}
//-------------------------------- methods for version and sn. ----------------------------//
/**
* Get the version of current zentaopms.
*
*
* Since the version field not saved in db. So if empty, return 0.3 beta.
*
* @access public
@@ -206,9 +206,21 @@ class settingModel extends model
}
/**
* Update version
*
* @param string $version
* Get URSR.
*
* @access public
* @return int
*/
public function getURSR()
{
if(isset($this->config->URSR)) return $this->config->URSR;
return $this->getItem('owner=system&module=custom&key=URSR');
}
/**
* Update version
*
* @param string $version
* @access public
* @return void
*/
@@ -219,7 +231,7 @@ class settingModel extends model
/**
* Set the sn of current zentaopms.
*
*
* @access public
* @return void
*/
@@ -231,8 +243,8 @@ class settingModel extends model
/**
* Compute a SN. Use the server ip, and server software string as seed, and an rand number, two micro time
*
* Note: this sn just to unique this zentaopms. No any private info.
*
* Note: this sn just to unique this zentaopms. No any private info.
*
* @access public
* @return string
@@ -246,8 +258,8 @@ class settingModel extends model
/**
* Judge a sn needed update or not.
*
* @param string $sn
*
* @param string $sn
* @access public
* @return bool
*/