diff --git a/mind3rd/API/classes/Mind.php b/mind3rd/API/classes/Mind.php index 08bc13b..a994d45 100755 --- a/mind3rd/API/classes/Mind.php +++ b/mind3rd/API/classes/Mind.php @@ -33,6 +33,7 @@ public static $content = ""; public static $originalContent = ""; public static $curLang = 'en'; + public static $availableSetAttrs= Array(); public static function &getInstance() { @@ -214,6 +215,39 @@ Mind::$autoloadPaths[]= $p; } + public static function set($property, $value){ + if(!\MindUser::isAdmin()){ + \Mind::write('mustBeAdmin'); + return false; + } + $iniSource= _MINDSRC_.MIND_CONF; + if(!file_exists($iniSource)){ + echo "[Main] Failed retrieving the configuration file!!!\nTry to reinstall mind!\n"; + return false; + } + try{ + $iniContent= file_get_contents($iniSource); + }catch(Exception $e){ + \MindSpeaker::write('permissionDenied', true, $proj); + return false; + } + $attr= trim($property); + if(!\in_array($attr, self::$availableSetAttrs)){ + \MindSpeaker::write('invalidCreateParams'); + echo "Available list: ".implode(', ', self::$availableSetAttrs)."\n"; + return false; + } + $iniContent= preg_replace("/".$attr."(( |\t)+)?=.+(\n|$)/", $attr."=\"". addslashes($value)."\"\n", $iniContent); + try{ + file_put_contents($iniSource, $iniContent); + }catch(Excepption $e){ + \MindSpeaker::write('permissionDenied', true, $proj); + return false; + } + \Mind::write('done'); + return true; + } + /** * The Constructor */ @@ -222,12 +256,14 @@ { return $GLOBALS['_MIND']; }*/ + $path= _MINDSRC_; Mind::$projectsDir= $path.PROJECTS_DIR; Mind::$modelsDir= $path.MODELS_DIR; $this->about= parse_ini_file($path.ABOUT_INI); $this->defaults= parse_ini_file($path.DEFAULTS_INI); $this->conf= parse_ini_file($path.MIND_CONF); + self::$availableSetAttrs= array_keys($this->conf); require_once($path.L10N_DIR.$this->defaults['default_human_language'].'.php'); Mind::$curLang= $this->defaults['default_human_languageName']; Mind::$l10n= new $this->defaults['default_human_language'](); @@ -239,5 +275,7 @@ Mind::$gosh= new theos\Gosh(); Mind::$darwin= new scientia\Darwin(); + + } } \ No newline at end of file diff --git a/mind3rd/API/classes/MindProject.php b/mind3rd/API/classes/MindProject.php index 6962969..5c76b6c 100755 --- a/mind3rd/API/classes/MindProject.php +++ b/mind3rd/API/classes/MindProject.php @@ -24,6 +24,7 @@ class MindProject extends VersionManager{ 'database_port', 'database_user', 'database_pwd', + 'sourceadd', 'sourceAdd', 'source'); /** @@ -148,25 +149,31 @@ class MindProject extends VersionManager{ return false; } - $attr= trim($attr); + $attr= strtolower(trim($attr)); if(!\in_array($attr, self::$availableAttrs)){ \MindSpeaker::write('invalidCreateParams'); echo "Available list: ".implode(', ', self::$availableAttrs)."\n"; return false; } - if($attr == 'source'){ + if($attr == 'source' || $attr == 'sourceadd'){ $srcs= Mind::$currentProject['sources']; $source= func_get_arg(2); if(!$source) $source= 'main'; //echo "\n\n".$srcs.'/'.addslashes($source).'.mnd'."\n\n"; - if(file_put_contents($srcs.'/'.addslashes($source).'.mnd', $value)) + if( + file_put_contents( + $srcs.'/'.addslashes($source).'.mnd', + (($attr == 'sourceadd')? "\n": '').$value, + ($attr == 'sourceadd')? FILE_APPEND: false + ) + ) return true; Mind::write('permissionDenied'); return false; }else{ - $iniContent= preg_replace("/".$attr."(( |\t)+)?=.+(\n|$)/", $attr."=".str_replace('"', '', $value)."\n", $iniContent); + $iniContent= preg_replace("/".$attr."(( |\t)+)?=.+(\n|$)/", $attr."=\"".addslashes($value)."\"\n", $iniContent); try{ file_put_contents($iniSource, $iniContent); \MindProject::reload(); diff --git a/mind3rd/API/external/Symfony/Component/Console/Application.php b/mind3rd/API/external/Symfony/Component/Console/Application.php index 51c0bd8..f6a5aaf 100755 --- a/mind3rd/API/external/Symfony/Component/Console/Application.php +++ b/mind3rd/API/external/Symfony/Component/Console/Application.php @@ -89,7 +89,7 @@ class Application //new InputOption('--quiet', '-q', InputOption::PARAMETER_NONE, 'Do not output any message.'), //new InputOption('--verbose', '-v', InputOption::PARAMETER_NONE, 'Increase verbosity of messages.'), //new InputOption('--version', '-V', InputOption::PARAMETER_NONE, 'Display this program version.'), - new InputOption('--color', '-c', InputOption::PARAMETER_NONE, 'Force ANSI color output.'), + //new InputOption('--color', '-c', InputOption::PARAMETER_NONE, 'Force ANSI color output.'), //new InputOption('--no-interaction', '-n', InputOption::PARAMETER_NONE, 'Do not ask any interactive question.'), )); } diff --git a/mind3rd/API/languages/pt/quantifiers.xml b/mind3rd/API/languages/pt/quantifiers.xml index afa6080..26f373b 100755 --- a/mind3rd/API/languages/pt/quantifiers.xml +++ b/mind3rd/API/languages/pt/quantifiers.xml @@ -9,6 +9,6 @@ nada,nenhum,zero,0,nenhuma um,uma,1,algum,alguma,único,única,unico,unica - uns,alguns,umas,algumas,muito,muita,muitos,vários,muitas,várias,diversos,diversas,n,m,x + uns,alguns,umas,algumas,muito,muita,muitos,vários,varios,muitas,várias,diversos,diversas,n,m,x ou,até,/ \ No newline at end of file diff --git a/mind3rd/API/programs/Set.php b/mind3rd/API/programs/Set.php index a50e2c2..209d920 100755 --- a/mind3rd/API/programs/Set.php +++ b/mind3rd/API/programs/Set.php @@ -39,6 +39,8 @@ */ public function executableFunction() { + GLOBAL $_MIND; + $property= explode('.', $this->property); if(sizeof($property) <= 1){ \MindSpeaker::write('wrongParam', true, "property", $this->property); @@ -46,23 +48,33 @@ } $entity= $property[0]; $property= $property[1]; - if($entity == 'user'){ - if($property == 'pwd' && !$this->extra){ - $this->prompt('pwd', "What will be the password?", true); - if($this->value) - $this->extra= $this->value; - $this->value= $this->answers['pwd']; - } - if($this->extra){ - if(\MindUser::set($property, $this->value, $this->extra)) + switch($entity){ + case 'user': + if($property == 'pwd' && !$this->extra){ + $this->prompt('pwd', "What will be the password?", true); + if($this->value) + $this->extra= $this->value; + $this->value= $this->answers['pwd']; + } + if($this->extra){ + if(\MindUser::set($property, $this->value, $this->extra)) + \MindSpeaker::write('done'); + }else{ + if(\MindUser::set($property, $this->value)) + \MindSpeaker::write('done'); + } + break; + case 'project': + if(\MindProject::set($property, $this->value, $this->extra)) \MindSpeaker::write('done'); - }else{ - if(\MindUser::set($property, $this->value)) - \MindSpeaker::write('done'); - } - }else{ - if(\MindProject::set($property, $this->value, $this->extra)) - \MindSpeaker::write('done'); + break; + case 'conf': + \Mind::set($property, $this->value); + break; + default: + \Mind.write('invalidOption', true, $entity); + return false; + break; } } diff --git a/mind3rd/API/programs/Show.php b/mind3rd/API/programs/Show.php index 4e2664c..78a9a57 100755 --- a/mind3rd/API/programs/Show.php +++ b/mind3rd/API/programs/Show.php @@ -84,7 +84,6 @@ EOT case 'conf': case 'props': case 'properties': - //var_dump($_MIND); $p= \Mind::$currentProject; if($p){ //$p['users']= Array(); diff --git a/mind3rd/env/mind.ini b/mind3rd/env/mind.ini index 4ff3bdb..0828670 100755 --- a/mind3rd/env/mind.ini +++ b/mind3rd/env/mind.ini @@ -8,7 +8,7 @@ ; ; ; specify where theWebMind will find the phpunit classes -phpunit-src= "/usr/bin/phpunit" +phpunit-src=/usr/bin/phpunit ; what is the minimun size of a field, that may identify it as a big ; field or not big_fields_size= 255