Added some new commands to the API namespace to make it easier for developers
Esse commit está contido em:
@@ -105,7 +105,7 @@ class mysql implements DBMS{
|
||||
(
|
||||
<properties>
|
||||
<primarykeys>
|
||||
);
|
||||
)ENGINE=InnoDB;
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of theWebMind Project
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a facade class for the API.
|
||||
*
|
||||
* This class offers the access to many generic methods which may use different
|
||||
* classes in a quite easier way.
|
||||
*
|
||||
* @author felipe nascimento de moura <felipenmoura@gmail.com>
|
||||
*/
|
||||
class Facade {
|
||||
|
||||
}
|
||||
@@ -12,5 +12,17 @@ namespace Lobe;
|
||||
* @author felipe
|
||||
*/
|
||||
abstract class Neuron {
|
||||
|
||||
|
||||
public static function listLobes()
|
||||
{
|
||||
$list= Array();
|
||||
$d = dir(\theos\ProjectFileManager::getLobesDir());
|
||||
while (false !== ($entry = $d->read()))
|
||||
{
|
||||
if($entry!= 'Neuron.php' && $entry[0] != '.')
|
||||
$list[]= $entry;
|
||||
}
|
||||
$d->close();
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
namespace Lobe\testFacade;
|
||||
/**
|
||||
* Description of DBGen
|
||||
*
|
||||
* @author Felipe Nascimento de Moura <felipenmoura@gmail.com>
|
||||
*/
|
||||
class testFacade extends \Lobe\Neuron implements \neuron{
|
||||
// TODO: REMOVE THIS FILE AFTER THE REQUIRED TESTS
|
||||
public function __construct(Array $data)
|
||||
{
|
||||
echo "Here, a list of available commands from the \API package:\n";
|
||||
echo "\API\\\n";
|
||||
echo " GET::\n";
|
||||
echo " \API\Get::plugins(true); // passing true, it echoes directly\n";
|
||||
echo " \API\Get::projectData();\n";
|
||||
echo " \API\Get::currentProject();\n";
|
||||
echo " \API\Get::tables();\n";
|
||||
echo " \API\Get::DDL();\n";
|
||||
echo " \API\Get::DecoratedDDL();\n";
|
||||
echo " \API\Get::lobes();\n";
|
||||
echo " \API\Get::source();\n";
|
||||
echo " \API\Get::idioms();\n";
|
||||
|
||||
echo " Project::\n";
|
||||
echo " \API\Project::data();\n";
|
||||
echo " \API\Project::current();\n";
|
||||
echo " \API\Project::getDDLCommand();\n";
|
||||
echo " \API\Project::getDDLCommand(false);\n";
|
||||
echo " \API\Project::openProject('demo_en');\n";
|
||||
echo " \API\Project::projectExists('demo_en');\n";
|
||||
echo " \API\Project::source();\n";
|
||||
|
||||
echo " User::\n";
|
||||
echo " \API\User::projectsList();\n";
|
||||
}
|
||||
}
|
||||
@@ -187,6 +187,11 @@ class ProjectFactory extends Project{
|
||||
$this->db->execute("COMMIT");
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
\Mind::$project= null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The DAO\ProjectFactory constructor
|
||||
* It calls the DAO\Project's constructor
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
public $defaults= null;
|
||||
public $conf= null;
|
||||
|
||||
public static $project= null;
|
||||
public static $autoloadPaths= Array();
|
||||
public static $currentProject= null;
|
||||
public static $ref= Array();
|
||||
@@ -21,21 +22,51 @@
|
||||
public static $l10n= null;
|
||||
public static $triggers= Array();
|
||||
public static $modelsDir= "";
|
||||
public static $lexer;
|
||||
public static $canonic;
|
||||
public static $syntaxer;
|
||||
public static $tokenizer;
|
||||
/**
|
||||
*
|
||||
* @var theos\Gosh $gosh the "creator" class
|
||||
*/
|
||||
public static $gosh;
|
||||
public static $darwin;
|
||||
public static $langPath= "";
|
||||
public static $content= "";
|
||||
public static $originalContent= "";
|
||||
public static $curLang= 'en';
|
||||
|
||||
/**
|
||||
* @var Lexer An instance of the Lexer class
|
||||
*/
|
||||
public static $lexer;
|
||||
/**
|
||||
* @var Canonic An instance of the Canonic class
|
||||
*/
|
||||
public static $canonic;
|
||||
/**
|
||||
* @var Syntaxer An instance of the Syntaxer class
|
||||
*/
|
||||
public static $syntaxer;
|
||||
/**
|
||||
* @var Tokenizer The tokenizer class
|
||||
*/
|
||||
public static $tokenizer;
|
||||
/**
|
||||
* @var theos\Gosh $gosh the "creator" class
|
||||
*/
|
||||
public static $gosh;
|
||||
/**
|
||||
* @var \scientia\Darwin An instance of the Darwin class
|
||||
*/
|
||||
public static $darwin;
|
||||
|
||||
/**
|
||||
* Gets the list of the currently instaled idioms.
|
||||
* @return Array
|
||||
*/
|
||||
public static function getIdiomsList()
|
||||
{
|
||||
$ar= Array();
|
||||
$d= dir(_MINDSRC_.L10N_DIR);
|
||||
while(false !== $entry= $d->read())
|
||||
{
|
||||
if(substr($entry, 0, 1) != '.')
|
||||
$ar[]= str_replace('.php', '', $entry);
|
||||
}
|
||||
return $ar;
|
||||
}
|
||||
/**
|
||||
* Verifies wheter the software is installed or not
|
||||
* @return boolean
|
||||
|
||||
@@ -10,9 +10,20 @@
|
||||
* @author felipe
|
||||
*/
|
||||
class MindDB {
|
||||
private $db= null;
|
||||
|
||||
public static $db= null;
|
||||
public static $inTransaction= false;
|
||||
public $lastInsertedId= 0;
|
||||
|
||||
public function __get($what)
|
||||
{
|
||||
if($what=='db')
|
||||
return self::$db;
|
||||
if(isset($this->$what))
|
||||
return $this->$what;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method query
|
||||
* @param String $qr
|
||||
@@ -20,7 +31,7 @@ class MindDB {
|
||||
*/
|
||||
public function query($qr)
|
||||
{
|
||||
$ret= $this->db->query($qr);
|
||||
$ret= self::$db->query($qr);
|
||||
$ar_ret= Array();
|
||||
while($tuple= $ret->fetchArray(SQLITE3_ASSOC))
|
||||
{
|
||||
@@ -36,20 +47,29 @@ class MindDB {
|
||||
*/
|
||||
public function execute($command)
|
||||
{
|
||||
$ret= $this->db->exec($command);
|
||||
$this->lastInsertedId= $this->db->lastInsertRowId();
|
||||
if(strtoupper($command) == 'BEGIN')
|
||||
{
|
||||
if(self::$inTransaction)
|
||||
return true;
|
||||
self::$inTransaction= true;
|
||||
}elseif(strtoupper($command) == 'COMMIT' || strtoupper($command) == 'ROLLBACK')
|
||||
{
|
||||
self::$inTransaction= false;
|
||||
}
|
||||
$ret= self::$db->exec($command);
|
||||
$this->lastInsertedId= self::$db->lastInsertRowId();
|
||||
return $this->lastInsertedId;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if(!$db = new SQLite3(_MINDSRC_.SQLITE))
|
||||
{
|
||||
Mind::message('Database', '[Fail]');
|
||||
return false;
|
||||
}
|
||||
$this->db= $db;
|
||||
if(!self::$db)
|
||||
if(!self::$db = new SQLite3(_MINDSRC_.SQLITE))
|
||||
{
|
||||
Mind::message('Database', '[Fail]');
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
public $description;
|
||||
public $links= Array();
|
||||
|
||||
public function listPlugins($echoes)
|
||||
public static function listPlugins($echoes=true)
|
||||
{
|
||||
if($echoes)
|
||||
{
|
||||
@@ -24,7 +24,7 @@
|
||||
$header.= "|".str_pad("Trigger", $col2, " ", STR_PAD_BOTH);
|
||||
$header.= "|".str_pad("Event", $col34, " ", STR_PAD_BOTH);
|
||||
$header.= "|".str_pad("Active", $col34, " ", STR_PAD_BOTH)."|\n";
|
||||
$line= "+".str_pad("", 78, '-')."+";
|
||||
$line= "+".str_pad("", 78, '-')."+\n";
|
||||
$echoes= $line;
|
||||
$echoes.=$header;
|
||||
$echoes.=$line;
|
||||
|
||||
@@ -84,6 +84,49 @@ class MindProject extends VersionManager{
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the project already exists,
|
||||
* false, otherwise
|
||||
*
|
||||
* @global Mind $_MIND
|
||||
* @param String $project
|
||||
* @return boolean
|
||||
*/
|
||||
public static function projectExists($projectName)
|
||||
{
|
||||
GLOBAL $_MIND;
|
||||
$projectfile= Mind::$projectsDir.$projectName;
|
||||
$noAccess= true;
|
||||
|
||||
$db= new MindDB();
|
||||
$hasProject= "SELECT pk_project
|
||||
from project
|
||||
where project.name = '".$projectName."'
|
||||
";
|
||||
$data= $db->query($hasProject);
|
||||
if(sizeof($data)>0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function projectsList($user=false)
|
||||
{
|
||||
GLOBAL $_MIND;
|
||||
|
||||
$user= $user? $user: $_SESSION['pk_user'];
|
||||
|
||||
$db= new MindDB();
|
||||
$hasProject= "SELECT pk_project,
|
||||
project.name as name
|
||||
from project_user,
|
||||
project
|
||||
where fk_user= ".$user."
|
||||
and fk_project = pk_project
|
||||
";
|
||||
$data= $db->query($hasProject);
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function loadIdiom($idiom)
|
||||
{
|
||||
@@ -102,6 +145,13 @@ class MindProject extends VersionManager{
|
||||
public static function openProject($p)
|
||||
{
|
||||
GLOBAL $_REQ;
|
||||
if(Mind::$project)
|
||||
{
|
||||
if($_SESSION['currentProject'] != $p['pk_project'])
|
||||
Mind::$project->close();
|
||||
else
|
||||
return Mind::$project;
|
||||
}
|
||||
$_SESSION['currentProject']= $p['pk_project'];
|
||||
$_SESSION['currentProjectName']= $p['name'];
|
||||
$_SESSION['currentProjectDir']= Mind::$projectsDir.$p['name'];
|
||||
@@ -122,7 +172,8 @@ class MindProject extends VersionManager{
|
||||
$pF= new DAO\ProjectFactory(Mind::$currentProject);
|
||||
Mind::$currentProject['version']= $pF->data['version'];
|
||||
Mind::$currentProject['pk_version']= $pF->data['pk_version'];
|
||||
|
||||
Mind::$project= $pF;
|
||||
|
||||
Mind::write('projectOpened', true, $p['name']);
|
||||
return true;
|
||||
}
|
||||
@@ -139,23 +190,23 @@ class MindProject extends VersionManager{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function import($src)
|
||||
public static function import($src, $sourceFile='main')
|
||||
{
|
||||
self::$sourceContent[$src]= $src;
|
||||
self::$sourceContent[$sourceFile]= $src;
|
||||
$extraFiles[]= preg_match_all(IMPORT_SOURCE, $src, $matches);
|
||||
$matches= $matches[0];
|
||||
foreach($matches as &$import)
|
||||
{
|
||||
$import= substr($import, 8);
|
||||
$extraContent= self::loadSource($import);
|
||||
self::import($extraContent);
|
||||
self::import($extraContent, $import);
|
||||
}
|
||||
}
|
||||
|
||||
public static function loadSources()
|
||||
{
|
||||
$main= self::loadSource();
|
||||
self::import($main);
|
||||
self::import($main, 'main');
|
||||
}
|
||||
|
||||
public static function setUp()
|
||||
@@ -204,6 +255,7 @@ class MindProject extends VersionManager{
|
||||
{
|
||||
MindProject::commit();
|
||||
}
|
||||
|
||||
if(sizeof(Analyst::$entities) > 0)
|
||||
$init= true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of MindUser
|
||||
*
|
||||
* @author felipe
|
||||
*/
|
||||
class MindUser
|
||||
{
|
||||
public static function listUsers($detailed=false)
|
||||
{
|
||||
$db= new \MindDB();
|
||||
if($detailed)
|
||||
$projs= $db->query('SELECT * from user');
|
||||
else
|
||||
$projs= $db->query('SELECT login from user');
|
||||
return $projs;
|
||||
}
|
||||
}
|
||||
@@ -7,15 +7,6 @@
|
||||
class VersionManager {
|
||||
public static function commit()
|
||||
{
|
||||
/*
|
||||
* OK atualizar a versaopegando(pegando a chave da nova versão)
|
||||
* selecionar todas as tabelas e propriedades q nao estejam marcadas como drop
|
||||
* ver diferenças entre cada tabela
|
||||
* ver tabelas q ficaram sobrando na lista recem analisada(novas)
|
||||
* ver tabelas q ficaram sobrando na lista antiga(para dropar)
|
||||
* insere novas
|
||||
* marca antigas como dropped
|
||||
*/
|
||||
$project= new DAO\ProjectFactory(Mind::$currentProject);
|
||||
$project->commit();
|
||||
Mind::$currentProject['pk_version']= $project->versionId;
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
namespace API;
|
||||
/**
|
||||
* Description of Get
|
||||
*
|
||||
* @author felipe
|
||||
*/
|
||||
class Get{
|
||||
|
||||
public static function plugins($echoes=false)
|
||||
{
|
||||
return \MindPlugin::listPlugins($echoes);
|
||||
}
|
||||
public static function lobes()
|
||||
{
|
||||
return \Lobe\Neuron::listLobes();
|
||||
}
|
||||
public static function projectData()
|
||||
{
|
||||
$dt= \Mind::$currentProject;
|
||||
if(isset($dt['data']))
|
||||
$dt['data']= '';
|
||||
return $dt;
|
||||
}
|
||||
public static function tables()
|
||||
{
|
||||
return \Analyst::getUniverse();
|
||||
}
|
||||
public static function DDL()
|
||||
{
|
||||
$dbDriver= \Mind::$currentProject['database_drive'];
|
||||
\DQB\QueryFactory::setUp($dbDriver);
|
||||
return \DQB\QueryFactory::getCompleteQuery(false, true, 'array');
|
||||
}
|
||||
public static function DecoratedDDL()
|
||||
{
|
||||
$dbDriver= \Mind::$currentProject['database_drive'];
|
||||
\DQB\QueryFactory::setUp($dbDriver);
|
||||
return \DQB\QueryFactory::getCompleteQuery(true, false, 'array');
|
||||
}
|
||||
|
||||
public static function currentProject()
|
||||
{
|
||||
return \Mind::$project? \Mind::$project:
|
||||
false;
|
||||
}
|
||||
public static function source()
|
||||
{
|
||||
return \API\Project::source();
|
||||
}
|
||||
public static function idioms()
|
||||
{
|
||||
return \Mind::getIdiomsList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
namespace API;
|
||||
/**
|
||||
* Description of Get
|
||||
*
|
||||
* @author felipe
|
||||
*/
|
||||
class Project{
|
||||
|
||||
public static function openProject($projectName)
|
||||
{
|
||||
if(!$projectData= \Mind::hasProject($projectName))
|
||||
return false;
|
||||
\Mind::openProject($projectData);
|
||||
return self::current();
|
||||
}
|
||||
|
||||
public static function projectList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function current()
|
||||
{
|
||||
return \Mind::$project? \Mind::$project:
|
||||
false;
|
||||
}
|
||||
|
||||
public static function data()
|
||||
{
|
||||
$dt= \Mind::$currentProject;
|
||||
return $dt;
|
||||
}
|
||||
public static function getDDLCommand($decorated=true)
|
||||
{
|
||||
if($decorated)
|
||||
return \API\Get::DecoratedDDL();
|
||||
return \API\Get::DDL();
|
||||
}
|
||||
public static function projectExists($projectName)
|
||||
{
|
||||
return \MindProject::projectExists($projectName);
|
||||
}
|
||||
public static function analyze()
|
||||
{
|
||||
return MindProject::analyze(false);
|
||||
}
|
||||
public static function source()
|
||||
{
|
||||
if(sizeof(\MindProject::$sourceContent) == 0)
|
||||
\MindProject::loadSources();
|
||||
return \MindProject::$sourceContent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
namespace API;
|
||||
/**
|
||||
* Description of User
|
||||
*
|
||||
* @author felipe
|
||||
*/
|
||||
class User{
|
||||
public static function usersList()
|
||||
{
|
||||
return \MindUser::listUsers();
|
||||
}
|
||||
public static function projectsList()
|
||||
{
|
||||
return \MindProject::projectsList();
|
||||
}
|
||||
/*
|
||||
public static function ()
|
||||
{
|
||||
}
|
||||
public static function ()
|
||||
{
|
||||
}*/
|
||||
}
|
||||
@@ -167,6 +167,9 @@ EOT
|
||||
"\nWill this user be an administrator?",
|
||||
Array('Y'=>'Yes',
|
||||
'N'=>'No'));
|
||||
$this->prompt('email', "What is the user's e-mail?");
|
||||
|
||||
$email= $this->answers['email'];
|
||||
|
||||
$qr_newUser= "INSERT into user
|
||||
(
|
||||
@@ -174,7 +177,8 @@ EOT
|
||||
login,
|
||||
pwd,
|
||||
status,
|
||||
type
|
||||
type,
|
||||
email
|
||||
)
|
||||
values
|
||||
(
|
||||
@@ -185,7 +189,8 @@ EOT
|
||||
'".(strtoupper(
|
||||
substr($this->answers['type'],
|
||||
0,
|
||||
1))=='Y'? 'A': 'N')."'
|
||||
1))=='Y'? 'A': 'N')."',
|
||||
'".$email."'
|
||||
)";
|
||||
$db->execute($qr_newUser);
|
||||
Mind::write('userCreated', true, $this->argName);
|
||||
|
||||
@@ -23,9 +23,13 @@
|
||||
$dir= \theos\ProjectFileManager::getLobesDir();
|
||||
$d = dir($dir);
|
||||
$options= Array();
|
||||
$avOpts= Array();
|
||||
while (false !== ($entry = $d->read())) {
|
||||
if(is_dir($dir.$entry) && substr($entry, 0, 1) != '.')
|
||||
{
|
||||
$options[]= " >".$entry."\n";
|
||||
$avOpts[]= $entry;
|
||||
}
|
||||
}
|
||||
$d->close();
|
||||
|
||||
@@ -42,7 +46,7 @@ EOT;
|
||||
->setAction('action')
|
||||
->setHelp($help);
|
||||
|
||||
$this->addRequiredArgument('lobe', 'Lobe to be used');
|
||||
$this->addRequiredArgument('lobe', 'Lobe to be used', $avOpts);
|
||||
$this->addOptionalArgument('param', 'A param for that command');
|
||||
$this->addOptionalArgument('detail', 'A detail for that command');
|
||||
$this->addOptionalArgument('optional', 'An optional argument');
|
||||
|
||||
@@ -26,7 +26,9 @@ EOT
|
||||
'entities',
|
||||
'relations',
|
||||
'version',
|
||||
'plugins'));
|
||||
'idioms',
|
||||
'plugins',
|
||||
'lobes'));
|
||||
$this->addOptionalArgument('extra', 'Any extra information to be used');
|
||||
$this->addFlag('detailed', '-d', 'Show detailed data');
|
||||
|
||||
@@ -65,7 +67,6 @@ EOT
|
||||
{
|
||||
echo JSON_encode($userList);
|
||||
}else{
|
||||
//foreach($projectList as $proj)
|
||||
$this->printMatrix($userList);
|
||||
}
|
||||
break;
|
||||
@@ -137,6 +138,13 @@ EOT
|
||||
break;
|
||||
case 'plugins':
|
||||
MindPlugin::listPlugins($_REQ['env']!='http');
|
||||
break;
|
||||
case 'idioms':
|
||||
Mind::getIdiomsList();
|
||||
break;
|
||||
case 'lobes':
|
||||
echo implode("\n", \Lobe\Neuron::listLobes());
|
||||
echo "\n";
|
||||
break;
|
||||
default:
|
||||
Mind::write('invalidOption', true, $this->what);
|
||||
@@ -156,13 +164,7 @@ EOT
|
||||
}
|
||||
private function loadUsersList()
|
||||
{
|
||||
|
||||
$db= new MindDB();
|
||||
if($this->detailed)
|
||||
$projs= $db->query('SELECT * from user');
|
||||
else
|
||||
$projs= $db->query('SELECT login from user');
|
||||
return $projs;
|
||||
return MindUser::listUsers($this->detailed);
|
||||
}
|
||||
private function printList($list)
|
||||
{
|
||||
|
||||
@@ -31,18 +31,29 @@
|
||||
GLOBAL $_MIND;
|
||||
$what= preg_replace("/[ '\"\.\/]/", '', $what);
|
||||
$what= str_replace('\\', '/', $what);
|
||||
$what= str_replace('.', '', $what);
|
||||
|
||||
if(file_exists(_MINDSRC_.'/mind3rd/API/programs/'.$what.'.php'))
|
||||
{
|
||||
include(_MINDSRC_.'/mind3rd/API/programs/'.$what.'.php');
|
||||
return true;
|
||||
}
|
||||
if(strpos($what, '\\')>=0)
|
||||
|
||||
// checking if the class is not a facad from the API
|
||||
if(strpos($what, 'API/')!==false)
|
||||
{
|
||||
$what= explode('\\', $what);
|
||||
$what= array_pop($what);
|
||||
$what= explode('/', $what);
|
||||
$classFile= array_pop($what);
|
||||
$what= str_replace('/', '\\', $what);
|
||||
$file= _MINDSRC_.'/mind3rd/API/facade/'.$classFile.".php";
|
||||
if(file_exists($file))
|
||||
{
|
||||
include($file);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// checking if the class is inside any of the autoload paths
|
||||
$dirs= Mind::$autoloadPaths;
|
||||
|
||||
for($i=0; $i<sizeof($dirs); $i++)
|
||||
@@ -62,9 +73,7 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
// cortex has a special treatment
|
||||
|
||||
|
||||
// ok, if it's reached here...it didn't go well!
|
||||
echo " [ERROR] Class not found: ".$what."\n";
|
||||
return false;
|
||||
}
|
||||
@@ -12,6 +12,7 @@ CREATE TABLE project
|
||||
info text ,
|
||||
creator int4 ,
|
||||
dt_creation timestamp,
|
||||
status char(1) default 'A',
|
||||
PRIMARY KEY(pk_project)
|
||||
);
|
||||
|
||||
@@ -23,8 +24,9 @@ CREATE TABLE user
|
||||
name varchar(255) ,
|
||||
login varchar(40) not null ,
|
||||
pwd varchar(40) not null ,
|
||||
status char(1) ,
|
||||
type char(1) ,
|
||||
status char(1),
|
||||
email varchar(1024) not null,
|
||||
type char(1),
|
||||
PRIMARY KEY(pk_user)
|
||||
);
|
||||
|
||||
@@ -33,8 +35,9 @@ CREATE TABLE user
|
||||
CREATE TABLE project_user
|
||||
(
|
||||
pk_project_user integer unique not null,
|
||||
fk_project integer ,
|
||||
fk_user integer ,
|
||||
fk_project integer,
|
||||
fk_user integer,
|
||||
status char(1) default 'A',
|
||||
PRIMARY KEY(pk_project_user),
|
||||
FOREIGN KEY(fk_user) REFERENCES user(pk_user),
|
||||
FOREIGN KEY(fk_project) REFERENCES project(pk_project)
|
||||
|
||||
externo
+19
-5
@@ -156,6 +156,16 @@ abstract class Setup {
|
||||
echo " ".str_replace('\\', '/', getcwd()).
|
||||
"/".$sqliteBaseFile."\n";
|
||||
}else{
|
||||
$email= 'mail@domain.com';
|
||||
$pwd= 'admin';
|
||||
if(isset($_POST))
|
||||
{
|
||||
if(isset($_POST['adminEmail']))
|
||||
$email= $_POST['adminEmail'];
|
||||
if(isset($_POST['adminPWD']))
|
||||
$email= $_POST['adminPWD'];
|
||||
}
|
||||
|
||||
if(class_exists($sqlite) && $db = new SQLite3($sqliteBaseFile))
|
||||
{
|
||||
$DDL= file_get_contents($sqliteDDLFile);
|
||||
@@ -170,18 +180,22 @@ abstract class Setup {
|
||||
login,
|
||||
pwd,
|
||||
status,
|
||||
type
|
||||
type,
|
||||
email
|
||||
)VALUES(
|
||||
'Administrator',
|
||||
'admin',
|
||||
'".sha1('admin')."',
|
||||
'".sha1($pwd)."',
|
||||
'A',
|
||||
'A'
|
||||
'A',
|
||||
'".$email."'
|
||||
);");
|
||||
echo " setting database permissions...\n";
|
||||
|
||||
if($_MIND['sys']== 'unix')
|
||||
echo shell_exec('sudo chmod 777 '.getcwd().'/mind3rd/SQLite/mind');
|
||||
if($_MIND['sys']== 'unix')
|
||||
echo shell_exec('sudo chmod 777 '.getcwd().'/mind3rd/SQLite/mind');
|
||||
chmod($sqliteBaseFile, 0777);
|
||||
|
||||
}else{
|
||||
echo " <[ERROR] SQLite Database could not be created. ".
|
||||
" Is your server working properly with SQLite?>\n";
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário