fixed uncommited bug for SQL generator; added annotations; shrinked sql generator to use the \API\ namespace
Esse commit está contido em:
@@ -57,6 +57,7 @@ class En implements l10n{
|
||||
$this->messages['done'] = Mind::message("API: Done\n", '[Ok]', false);
|
||||
$this->messages['invalidOptionValue'] = Mind::message("API: '%s' is not a valid option for '%s'", '[Fail]', false);
|
||||
$this->messages['runnintPHPUnit'] = "Please wait...running PHPUnit...\n";
|
||||
$this->messages['mustBeAdmin'] = Mind::message("API: You must be the admin to perform this action", '[Fail]', false);
|
||||
$this->messages['phpunitNotFound'] = "You must specify where to find phpUnit classes\n".
|
||||
"You can configure it on mind3rd/env/mind.ini ini file\n".
|
||||
"changing the phpunit-src ini property\n";;
|
||||
|
||||
@@ -65,6 +65,7 @@ class pt implements l10n{
|
||||
$this->messages['done'] = Mind::message("API: Pronto\n", '[Ok]', false);
|
||||
$this->messages['invalidOptionValue'] = Mind::message("API: '%s' não é uma opção válida para '%s'", '[Fail]', false);
|
||||
$this->messages['runnintPHPUnit'] = "Aguarde...executando testes unitários...\n";
|
||||
$this->messages['mustBeAdmin'] = Mind::message("API: Você precisa ser o administrador para executar esta instrução", '[Fail]', false);
|
||||
$this->messages['phpunitNotFound'] = "Especifique onde encontram-se as classes do PHPUnit\n".
|
||||
"Você pode configurar isto em mind3rd/env/mind.ini ini file\n".
|
||||
"alterando a propriedade phpunit-src\n";
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
/**
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* Notice that, these packages are being used only for documentation,
|
||||
* not to organize the classes.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @license licenses/mind3rd.license
|
||||
*/
|
||||
|
||||
namespace Lobe;
|
||||
/**
|
||||
* Description of Neuron
|
||||
* A Neuron.
|
||||
*
|
||||
* @author felipe
|
||||
* @package Lobe
|
||||
*/
|
||||
abstract class Neuron {
|
||||
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
/**
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* Notice that, these packages are being used only for documentation,
|
||||
* not to organize the classes.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @license licenses/mind3rd.license
|
||||
*/
|
||||
namespace Lobe\db;
|
||||
/**
|
||||
* Description of DBGen
|
||||
* Database Generator.
|
||||
* Generates/manages the database according to the current project's configuration.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @package Lobe
|
||||
* @subpackage db
|
||||
*/
|
||||
class db extends \Lobe\Neuron implements \neuron{
|
||||
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
/**
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* Notice that, these packages are being used only for documentation,
|
||||
* not to organize the classes.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @license licenses/mind3rd.license
|
||||
*/
|
||||
namespace Lobe\db\resources;
|
||||
/**
|
||||
* Description of DBDealer
|
||||
* DBDealer.
|
||||
*
|
||||
* @author felipe
|
||||
* @package Lobe
|
||||
* @subpackage db
|
||||
* @subpackage resources
|
||||
*/
|
||||
class DBDealer {
|
||||
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
/**
|
||||
* This file is part of TheWebMind 3rd generation.
|
||||
*
|
||||
* Notice that, these packages are being used only for documentation,
|
||||
* not to organize the classes.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @license licenses/mind3rd.license
|
||||
*/
|
||||
namespace Lobe\sql;
|
||||
/**
|
||||
* Description of sql
|
||||
* SQL file generator.
|
||||
* Generates the .sql file into docs directory of the project.
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
* @package Lobe
|
||||
* @subpackage sql
|
||||
*/
|
||||
class sql extends \Lobe\Neuron implements \neuron{
|
||||
|
||||
public function __construct(Array $data)
|
||||
{
|
||||
$projectData= \Mind::$currentProject;
|
||||
\DQB\QueryFactory::$showHeader= true;
|
||||
\DQB\QueryFactory::setUp(\Mind::$currentProject['database_drive']);
|
||||
\DQB\QueryFactory::buildQuery('*');
|
||||
$qrs= \DQB\QueryFactory::getCompleteQuery(false, true, 'string');
|
||||
|
||||
$file= \theos\ProjectFileManager::createFile('docs/create.sql');
|
||||
return \fwrite($file, $qrs) !== false;
|
||||
$file= 'docs/create.sql';
|
||||
\API\FileManager::createFile($file);
|
||||
\API\FileManager::writeToFile($file, \API\Get::DDL());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -47,5 +47,6 @@ class testFacade extends \Lobe\Neuron implements \neuron{
|
||||
echo " openProject(\$projectName);\n";
|
||||
echo " projectExists(\$projectName);\n";
|
||||
echo " source();\n";
|
||||
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,13 @@ class QueryFactory extends TableSort{
|
||||
|
||||
public static function getCompleteQuery($decorated=true, $raw= false, $format='string')
|
||||
{
|
||||
$closingQueries= Array();
|
||||
if(sizeof(self::$queries) == 0)
|
||||
{
|
||||
self::buildQuery();
|
||||
//echo "No queries to show...have you commited your project?\n";
|
||||
//return false;
|
||||
}
|
||||
$closingQueries= Array();
|
||||
$outpt= ($format=='string')? "": Array();
|
||||
if(self::$showHeader)
|
||||
{
|
||||
|
||||
@@ -12,13 +12,55 @@
|
||||
*/
|
||||
class MindUser
|
||||
{
|
||||
static protected $dbConn = false;
|
||||
static protected $validAttrs = Array('name', 'email', 'pwd');
|
||||
static protected $adminValidAttrs = Array('status', 'type');
|
||||
|
||||
protected static function hash($pwd)
|
||||
{
|
||||
return sha1($pwd);
|
||||
}
|
||||
|
||||
public static function set($attr, $value, $user=false)
|
||||
{
|
||||
if(\in_array($attr, self::$adminValidAttrs) || $user)
|
||||
{
|
||||
if($_SESSION['pk_user'] != 1)
|
||||
{
|
||||
\Mind::write('mustBeAdmin');
|
||||
return false;
|
||||
}
|
||||
}elseif(!\in_array($attr, self::$validAttrs))
|
||||
return false;
|
||||
|
||||
if($attr == 'pwd')
|
||||
$value= self::hash($value);
|
||||
|
||||
$value= (is_string($value))? "'".$value."'": $value;
|
||||
|
||||
$db= self::getDBConn();
|
||||
$user= $user? $user: $_SESSION['pk_user'];
|
||||
$qr= "UPDATE user set ".$attr."= ".$value.
|
||||
"WHERE pk_user=".$user;
|
||||
$db->execute($qr);
|
||||
if($attr == 'pwd')
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
protected static function getDBConn()
|
||||
{
|
||||
if(!self::$dbConn)
|
||||
self::$dbConn= new \MindDB();
|
||||
return self::$dbConn;
|
||||
}
|
||||
|
||||
public static function listUsers($detailed=false)
|
||||
{
|
||||
$db= new \MindDB();
|
||||
$db= self::getDBConn();
|
||||
if($detailed)
|
||||
$projs= $db->query('SELECT * from user');
|
||||
$usrs= $db->query('SELECT * from user');
|
||||
else
|
||||
$projs= $db->query('SELECT login from user');
|
||||
return $projs;
|
||||
$usrs= $db->query('SELECT login from user');
|
||||
return $usrs;
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ class ProjectFileManager {
|
||||
{
|
||||
$file= self::setInnerURI($file);
|
||||
if(file_exists($file))
|
||||
return \file_put_contents ($file, $data);
|
||||
return \file_put_contents($file, $data);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ namespace API;
|
||||
*/
|
||||
class User{
|
||||
|
||||
static protected $validAttrs= Array('name', 'email', 'password');
|
||||
|
||||
/**
|
||||
* Returns an array of all registered users.
|
||||
* @return Array
|
||||
@@ -33,9 +31,9 @@ class User{
|
||||
return \MindProject::projectsList();
|
||||
}
|
||||
|
||||
public static function set($attr, $value)
|
||||
public static function set($attr, $value, $user=false)
|
||||
{
|
||||
print_r(self::$validAttrs);
|
||||
\MindUser::set($attr, $value, $user);
|
||||
}
|
||||
/*
|
||||
public static function ()
|
||||
|
||||
@@ -19,12 +19,17 @@
|
||||
public $whose = '';
|
||||
public $attribute= '';
|
||||
public $value = '';
|
||||
public $extra = '';
|
||||
|
||||
private function setUserData()
|
||||
{
|
||||
if($this->attribute=='pwd')
|
||||
$this->value= $this->prompt('pwd', 'The new password, please', true);
|
||||
\API\User::set($this->attribute, $this->value);
|
||||
if($this->extra && $this->value=='as')
|
||||
{
|
||||
|
||||
}else
|
||||
\API\User::set($this->attribute, $this->value);
|
||||
}
|
||||
|
||||
private function setProjectData()
|
||||
@@ -47,8 +52,13 @@
|
||||
|
||||
$this->setCommandName('set')
|
||||
->setDescription("Sets user's or project's data ")
|
||||
->setRestrict(false)
|
||||
->setHelp("You can set information about the current user or a project's data.")
|
||||
->setRestrict(true)
|
||||
->setHelp("You can set information about the current user or a project's data.
|
||||
if you are the admin, you can use the following line:
|
||||
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'")
|
||||
->setAction('executableFunction');
|
||||
|
||||
$this->addRequiredArgument('whose',
|
||||
@@ -58,6 +68,8 @@
|
||||
'The attribute you will change');
|
||||
$this->addOptionalArgument('value',
|
||||
'The value for that attribute(optional only for pwd');
|
||||
$this->addOptionalArgument('extra',
|
||||
'An extra data about the defined attribute(the status or type for users or projects)');
|
||||
|
||||
$this->init();
|
||||
}
|
||||
|
||||
@@ -75,7 +75,6 @@ EOT
|
||||
$this->query= 'update';
|
||||
break;
|
||||
}
|
||||
|
||||
$qrs= \MindProject::showSQL(($this->table=='*'), $this->table, $this->query);
|
||||
echo $qrs;
|
||||
return $this;
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário