Added multiple line support to console component(symfony console);
Added 'set project.source' command;
Esse commit está contido em:
@@ -23,7 +23,8 @@ class MindProject extends VersionManager{
|
||||
'database_name',
|
||||
'database_port',
|
||||
'database_user',
|
||||
'database_pwd');
|
||||
'database_pwd',
|
||||
'source');
|
||||
|
||||
/**
|
||||
* Uses the QueryFactory to return the sql to create all the database.
|
||||
@@ -81,14 +82,18 @@ class MindProject extends VersionManager{
|
||||
* This method actually changes AND PERSISTS the change to the
|
||||
* database.
|
||||
*
|
||||
* To change the source of a project, the user MUST be with the project opened.
|
||||
* Neither Admin users have access to change a source of a project, without
|
||||
* loging into it(opening the project).
|
||||
*
|
||||
* @param String $attr
|
||||
* @param Mixed $value
|
||||
* @param String $proj
|
||||
* @param String $proj The project or the source file to be chenged
|
||||
* @return boolean
|
||||
*/
|
||||
public static function set($attr, $value, $proj=false)
|
||||
{
|
||||
if(\in_array($attr, self::$adminValidAttrs) || $proj){
|
||||
if(\in_array($attr, self::$adminValidAttrs) || ($proj && $attr != 'source')){
|
||||
if(!\MindUser::isAdmin()){
|
||||
\Mind::write('mustBeAdmin');
|
||||
return false;
|
||||
@@ -142,6 +147,7 @@ class MindProject extends VersionManager{
|
||||
\MindSpeaker::write('permissionDenied', true, $proj);
|
||||
return false;
|
||||
}
|
||||
|
||||
$attr= trim($attr);
|
||||
if(!\in_array($attr, self::$availableAttrs)){
|
||||
\MindSpeaker::write('invalidCreateParams');
|
||||
@@ -149,14 +155,26 @@ class MindProject extends VersionManager{
|
||||
return false;
|
||||
}
|
||||
|
||||
$iniContent= preg_replace("/".$attr."(( |\t)+)?=.+(\n|$)/", $attr."=".$value."\n", $iniContent);
|
||||
try{
|
||||
file_put_contents($iniSource, $iniContent);
|
||||
\MindProject::reload();
|
||||
return true;
|
||||
}catch(Excepption $e){
|
||||
\MindSpeaker::write('permissionDenied', true, $proj);
|
||||
if($attr == 'source'){
|
||||
$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))
|
||||
return true;
|
||||
Mind::write('permissionDenied');
|
||||
return false;
|
||||
}else{
|
||||
$iniContent= preg_replace("/".$attr."(( |\t)+)?=.+(\n|$)/", $attr."=".str_replace('"', '', $value)."\n", $iniContent);
|
||||
try{
|
||||
file_put_contents($iniSource, $iniContent);
|
||||
\MindProject::reload();
|
||||
return true;
|
||||
}catch(Excepption $e){
|
||||
\MindSpeaker::write('permissionDenied', true, $proj);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,10 +68,18 @@ class Shell
|
||||
$command = readline($this->application->getName().' > ');
|
||||
|
||||
/** changed by felipeNMoura **/
|
||||
// showing nothing when the user just hits ENTER
|
||||
if($command == "\n" || $command == ""){
|
||||
$this->output->write("");
|
||||
continue;
|
||||
}
|
||||
// enabling multiple lines when quoted
|
||||
preg_filter('/\"/', '"', $command, -1, $count);
|
||||
while($count%2>0){ // unended quoted string
|
||||
$command.= "\\n".readline(' > ');
|
||||
preg_filter('/\"/', '"', $command, -1, $count);
|
||||
//continue;
|
||||
}
|
||||
/** end of changes made by felipnmoura **/
|
||||
|
||||
|
||||
|
||||
@@ -77,7 +77,23 @@
|
||||
set user :username: as :status:
|
||||
or
|
||||
set user :username: as :type:
|
||||
Where status may be 'A' or 'I', and type may be 'A' or 'N'")
|
||||
|
||||
Where status may be 'A' or 'I', and type may be 'A' or 'N'
|
||||
|
||||
Examples:
|
||||
1) An administrator changing the name of another project
|
||||
auth admin
|
||||
set project.name \"New Name\" projectToBeChanged
|
||||
|
||||
2) A user changing the idiom of one of his projects
|
||||
auth felipe
|
||||
use projectToBeChanged
|
||||
set project.idiom pt
|
||||
3) A user changing the source of a project(changing the main.mnd source file)
|
||||
auth felipe
|
||||
use projectToBeChanged
|
||||
set project.source \"New content is written here, for the source of the project\" main
|
||||
")
|
||||
->setAction('executableFunction');
|
||||
|
||||
$this->addRequiredArgument('property',
|
||||
|
||||
@@ -122,7 +122,8 @@ EOT
|
||||
case 'source':
|
||||
$p= \Mind::$currentProject;
|
||||
if($p){
|
||||
var_dump(\MindProject::loadSource());
|
||||
$s= $this->extra? $this->extra: 'main';
|
||||
echo \MindProject::loadSource($s)."\n";
|
||||
}else{
|
||||
\MindSpeaker::write("currentProjectRequired");
|
||||
}
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário