Fixed a couple of bugs in a few programs and added a few comments/annotations
Esse commit está contido em:
@@ -31,7 +31,6 @@ class ProjectFactory extends Project{
|
||||
{
|
||||
$props= $this->getProperties($entity1);
|
||||
|
||||
|
||||
if(sizeof($props) != sizeof($entity2->properties)
|
||||
||
|
||||
array_keys($props) != array_keys($entity2->properties))
|
||||
|
||||
@@ -25,6 +25,7 @@ class MindCommand extends Symfony\Component\Console\Command\Command
|
||||
private $optionalOptions = Array();
|
||||
private $commandFlags = Array();
|
||||
public $answers = Array();
|
||||
public $commandAction = null;
|
||||
public $commandAvailableOptions = Array();
|
||||
|
||||
/**
|
||||
@@ -518,10 +519,6 @@ class MindCommand extends Symfony\Component\Console\Command\Command
|
||||
|
||||
$this->runPlugins('before');
|
||||
|
||||
/*echo "\n\n";
|
||||
print_r($this->commandAvailableOptions);
|
||||
echo "\n\n";*/
|
||||
|
||||
foreach($this->commandAvailableOptions as $k=>$avOpts)
|
||||
{
|
||||
if($avOpts && !in_array(strtolower($this->$k),
|
||||
|
||||
@@ -162,7 +162,9 @@
|
||||
}
|
||||
$program->$realArgs[$k]= $arg;
|
||||
}
|
||||
$program->action();
|
||||
return true;
|
||||
|
||||
if(is_string($program->commandAction))
|
||||
return $program->{$program->commandAction}();
|
||||
$program->runAction();
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,38 @@ class User{
|
||||
|
||||
/**
|
||||
* Returns an array of all registered users.
|
||||
* @param boolean detailed If you want only the login, or the complete data from user
|
||||
* @return Array
|
||||
*/
|
||||
public static function usersList()
|
||||
public static function usersList($detailed=false)
|
||||
{
|
||||
return \MindUser::listUsers();
|
||||
return \MindUser::listUsers($detailed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns wether the user exists or not
|
||||
* @param string $userLogin The user login
|
||||
* @return boolean
|
||||
*/
|
||||
public static function userExists($userLogin)
|
||||
{
|
||||
$usersList= \MindUser::listUsers(true);
|
||||
foreach($usersList as $user)
|
||||
{
|
||||
if($user['login'] == $userLogin)
|
||||
return $user;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the information about the specified user
|
||||
* @param string login
|
||||
* @return Array
|
||||
*/
|
||||
public static function loadUserInfo($login)
|
||||
{
|
||||
return self::userExists($login);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @license licenses/mind3rd.license
|
||||
*/
|
||||
use Symfony\Component\Console\Input\InputArgument,
|
||||
Symfony\Component\Console\Input\InputOption,
|
||||
Symfony\Component\Console;
|
||||
|
||||
/**
|
||||
* This class represents a model for programs
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
*/
|
||||
class Add extends MindCommand implements program
|
||||
{
|
||||
/*
|
||||
* The properties you will use as argument MUST be declared, and public
|
||||
*/
|
||||
public $user= '';
|
||||
public $to= '';
|
||||
public $project= '';
|
||||
|
||||
public function executableFunction()
|
||||
{
|
||||
if(!\API\User::userExists($this->user))
|
||||
return false; // TODO: put it into L10N
|
||||
if(!\API\Project::projectExists($this->project))
|
||||
return false; // TODO: put it into L10N
|
||||
|
||||
$user= \API\User::loadUserInfo($this->user);
|
||||
print_r(\API\Project::data());
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
/**
|
||||
* You can use the following structure to set the program behavior
|
||||
*/
|
||||
$this->setCommandName('add')
|
||||
->setDescription("Add a user to an specified project")
|
||||
->setRestrict(true)
|
||||
->setHelp("Use this command to add a user to a project.\nYou MUST be the project's owner")
|
||||
->setAction('executableFunction');
|
||||
|
||||
/**
|
||||
* The next commands shows you how to set the signature of you program, such as
|
||||
* parameters, options or flags.
|
||||
* Your class will receive a property for each parameter, which can be accessed
|
||||
* by its argument name(in this example, 'firstArgument'.
|
||||
*/
|
||||
$this->addRequiredArgument('user',
|
||||
'The user to be added');
|
||||
$this->addRequiredArgument('to',
|
||||
'string "to"');
|
||||
$this->addRequiredArgument('project',
|
||||
'The project in which the user will be added as developer');
|
||||
|
||||
|
||||
$this->init();
|
||||
}
|
||||
}
|
||||
Referência em uma Nova Issue
Bloquear um usuário