This repository has been archived by the owner on Sep 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: refs #380 Added setting table. Changed assetstore's default name…
…. Re-added assetstore default selection.
- Loading branch information
Charles Ma
committed
Dec 1, 2011
1 parent
996f381
commit 0629233
Showing
10 changed files
with
293 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
class Upgrade_3_1_4 extends MIDASUpgrade | ||
{ | ||
public function preUpgrade() | ||
{ | ||
} | ||
|
||
public function mysql() | ||
{ | ||
$sql = "CREATE TABLE IF NOT EXISTS `setting` ( | ||
`setting_id` bigint(20) NOT NULL AUTO_INCREMENT, | ||
`name` varchar(255) NOT NULL, | ||
`module` varchar(255) NOT NULL, | ||
`value` text NULL DEFAULT NULL , | ||
PRIMARY KEY (`setting_id`) | ||
) DEFAULT CHARSET=utf8;"; | ||
$this->db->query($sql); | ||
} | ||
|
||
|
||
public function pgsql() | ||
{ | ||
$sql = "CREATE TABLE community ( | ||
setting_id serial PRIMARY KEY, | ||
name character varying(256) NOT NULL, | ||
module character varying(256) NOT NULL, | ||
value text NOT NULL | ||
) ;"; | ||
$this->db->query($sql); | ||
} | ||
|
||
public function postUpgrade() | ||
{ | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
/*========================================================================= | ||
MIDAS Server | ||
Copyright (c) Kitware SAS. 20 rue de la Villette. All rights reserved. | ||
69328 Lyon, FRANCE. | ||
See Copyright.txt for details. | ||
This software is distributed WITHOUT ANY WARRANTY; without even | ||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
PURPOSE. See the above copyright notices for more information. | ||
=========================================================================*/ | ||
require_once BASE_PATH.'/core/models/dao/SettingDao.php'; | ||
|
||
/** Setting Model Base*/ | ||
abstract class SettingModelBase extends AppModel | ||
{ | ||
/** Constructor*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
$this->_name = 'setting'; | ||
$this->_key = 'setting_id'; | ||
|
||
$this->_mainData = array( | ||
'setting_id' => array('type' => MIDAS_DATA), | ||
'name' => array('type' => MIDAS_DATA), | ||
'module' => array('type' => MIDAS_DATA), | ||
'value' => array('type' => MIDAS_DATA) | ||
); | ||
$this->initialize(); // required | ||
} // end __construct() | ||
|
||
/** Abstract functions */ | ||
abstract function getDaoByName($name, $module = 'core'); | ||
|
||
/** get value by name */ | ||
public function getValueByName($name, $module = 'core') | ||
{ | ||
$dao = $this->getDaoByName($name, $module); | ||
if($dao == false) | ||
{ | ||
return null; | ||
} | ||
return $dao->getValue(); | ||
} | ||
|
||
/** Set Configuration value. Set value as null to delete */ | ||
public function setConfig($name, $value, $module = 'core') | ||
{ | ||
if(!is_string($name) || !is_string($value) || !is_string($module)) | ||
{ | ||
throw new Zend_Exception('Error Parameters'); | ||
} | ||
$dao = $this->getDaoByName($name, $module); | ||
if($dao != false && $dao->getValue() == $value) | ||
{ | ||
return; | ||
} | ||
if($dao != false && $value === null) | ||
{ | ||
$this->delete($previousDao); | ||
} | ||
elseif($dao != false) | ||
{ | ||
$dao->setValue($value); | ||
$this->save($dao); | ||
} | ||
else | ||
{ | ||
$dao = new SettingDao (); | ||
$dao->setName($name); | ||
$dao->setModule($module); | ||
$dao->setValue($value); | ||
$this->save($dao); | ||
} | ||
return $dao; | ||
} | ||
|
||
} // end class AssetstoreModelBase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/*========================================================================= | ||
MIDAS Server | ||
Copyright (c) Kitware SAS. 20 rue de la Villette. All rights reserved. | ||
69328 Lyon, FRANCE. | ||
See Copyright.txt for details. | ||
This software is distributed WITHOUT ANY WARRANTY; without even | ||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
PURPOSE. See the above copyright notices for more information. | ||
=========================================================================*/ | ||
|
||
/** | ||
* \class SettingDao | ||
* \brief DAO (table setting) | ||
*/ | ||
class SettingDao extends AppDao | ||
{ | ||
public $_model = 'Setting'; | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/*========================================================================= | ||
MIDAS Server | ||
Copyright (c) Kitware SAS. 20 rue de la Villette. All rights reserved. | ||
69328 Lyon, FRANCE. | ||
See Copyright.txt for details. | ||
This software is distributed WITHOUT ANY WARRANTY; without even | ||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | ||
PURPOSE. See the above copyright notices for more information. | ||
=========================================================================*/ | ||
|
||
require_once BASE_PATH.'/core/models/base/SettingModelBase.php'; | ||
|
||
/** | ||
* SettingModel | ||
* Pdo Model | ||
*/ | ||
class SettingModel extends SettingModelBase | ||
{ | ||
/** get by name*/ | ||
function getDaoByName($name, $module = 'core') | ||
{ | ||
if(!is_string($name) || !is_string($module)) | ||
{ | ||
throw new Zend_Exception('Error Parameters'); | ||
} | ||
$row = $this->database->fetchRow($this->database->select()->where('name = ?', $name)->where('module = ?', $module)); | ||
$dao = $this->initDao(ucfirst($this->_name), $row); | ||
return $dao; | ||
} | ||
}// end class |
Oops, something went wrong.