'default' => '',
'min' => 1,
'max' => 1,
- )
+ ),
+ 'init' => array(
+ 'desc' => 'Initialize the database (pg only supported)',
+ 'short' => 'i',
+ 'default' => '',
+ 'min' => 1,
+ 'max' => 1,
+ ),
+
);
+ var $cli_options = false;
+
var $cli = false;
function getAuth() {
function get($args, $opt)
{
+
+ $this->cli_options = $opt;
+
if($args == 'Person'){
if(empty($opt['source']) || empty($opt['prefix'])){
die("Missing Source directory for person json files or prefix for the passwrod! Try -f [JSON file path] -p [prefix] \n");
die("DONE! \n");
}
+
+
if($args == 'Company'){
if(empty($opt['name']) || empty($opt['comptype'])){
die("Missing company name or type! Try --name=[the name of company] -- comptype=[the type of company] \n");
/**
* postgresql import..
*/
- function importpgsql($url)
+ function importpgsql($dburl)
{
// hide stuff for web..
$ar = $this->modulesList();
- foreach($ar as $m) {
+ foreach($ar as $m) {
+
+ // if init has been called
+ // look in pgsql.ini
+ if (!empty($this->cli_options['init'])) {
+ $this->importpgsqldir($dburl, $this->rootDir. "/Pman/$m/pgsql.init");
+ $this->importpgsqldir($dburl, $this->rootDir. "/Pman/$m/pgsql.initdata");
+ }
+
+
$fd = $this->rootDir. "/Pman/$m/DataObjects";
}
- function importpgsqldir($url, $dir)
+ function importpgsqldir($url, $dir, $disable_triggers = false)
{
require_once 'System.php';
$cat = System::which('cat');
' -h ' . $url['host'] .
' -U' . escapeshellarg($url['user']) .
' ' . basename($url['path']);
+
+
echo $psql_cmd . "\n" ;
+ echo "scan : $dir\n";
foreach(glob($dir.'/*.sql') as $bfn) {
}
$fn = false;
- if (basename($dir) != 'pgsql') {
+ if (!preg_match('/pgsql/', basename($dir) )) {
if ( !preg_match('#\.pg\.sql$#', basename($bfn))) {
$fn = $this->convertToPG($bfn);
}
$this->updateDataGroups();
$this->updateDataCompanies();
- $c = DB_DataObject::Factory('I18N');
+ $c = DB_DataObject::Factory('I18n');
$c->buildDB();