123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
- class Configuration extends Entity{
- protected $id,$key,$value,$confTab;
- protected $fields =
- array(
- 'id'=>'key',
- 'key'=>'longstring',
- 'value'=>'longstring'
- );
-
- public function getAll(){
-
- if(!isset($_SESSION['configuration'])){
-
- $configurationManager = new Configuration();
- $configs = $configurationManager->populate();
- $confTab = array();
- foreach($configs as $config){
- $this->confTab[$config->getKey()] = Functions::decrypt($config->getValue());
- }
- $_SESSION['configuration'] = serialize($this->confTab);
-
- }else{
- $this->confTab = unserialize($_SESSION['configuration']);
- }
-
- }
-
- public function get($key){
- return (isset($this->confTab[$key])?$this->confTab[$key]:'');
- }
-
- public function put($key,$value){
- $secured_value = Functions::crypt($value);
- $configurationManager = new Configuration();
- if (isset($this->confTab[$key])){
- $configurationManager->change(array('value'=>$secured_value),array('key'=>$key));
- } else {
- $configurationManager->add($key,$secured_value);
- }
- $this->confTab[$key] = $value;
- unset($_SESSION['configuration']);
- }
-
- public function add($key,$value){
- $config = new Configuration();
- $config->setKey($key);
- $config->setValue($value);
- $config->save();
- $this->confTab[$key] = $value;
- unset($_SESSION['configuration']);
- }
-
-
- function getId(){
- return $this->id;
- }
- function getKey(){
- return $this->key;
- }
- function setKey($key){
- $this->key = $key;
- }
- function getValue(){
- return $this->value;
- }
- function setValue($value){
- $this->value = $value;
- }
- }
- ?>
|