Commit a2b8ec195faf29b76983d6df41327e8923c4c509

Authored by Benjamin Renard
1 parent 1c1417db

Fix userDefaults.json creation

Showing 1 changed file with 7 additions and 7 deletions   Show diff stats
php/classes/AmdaAction.php
... ... @@ -1762,17 +1762,17 @@ class AmdaAction
1762 1762 $childrenToReturn = array();
1763 1763 $children = [];
1764 1764 if (!file_exists(DATAPATH.'defaultValues.json'))
1765   - return array('success' => false , 'defaultValues' => array(), 'message'=>'efaultvalues file not found.');
  1765 + return array('success' => false , 'defaultValues' => array(), 'message'=>'Defaultvalues file not found.');
1766 1766 $json_o = json_decode(file_get_contents(DATAPATH.'defaultValues.json'), true);
1767 1767 if (empty($json_o))
1768 1768 return array('success' => false , 'defaultValues' => array(), 'message'=>'Error : defaultValues file empty.');
1769 1769  
1770   - if (!file_exists(USERDIR.'userDefaults.json'))
1771   - return array('success' => true , 'defaultValues' => $json_o, 'message'=>'No modification on defaultvalues.');
1772   -
1773   - $json_user = json_decode(file_get_contents(USERDIR.'userDefaults.json'), true);
1774   - if (empty($json_user))
1775   - return array('success' => true , 'defaultValues' => $json_o, 'message'=>'No modification on defaultvalues.');
  1770 + $json_user = array();
  1771 + if (file_exists(USERDIR.'userDefaults.json'))
  1772 + $json_user = json_decode(file_get_contents(USERDIR.'userDefaults.json'), true);
  1773 + if (empty($json_user)) {
  1774 + $json_user = array();
  1775 + }
1776 1776  
1777 1777 foreach($json_user as $key => $value){
1778 1778 $keys = explode(".", $key);
... ...