/**
  * @return mixed
  */
 protected function getPeer()
 {
     if (!$this->peer) {
         require_once 'creole/Creole.php';
         \Creole::registerDriver('*', 'creole.contrib.DebugConnection');
         $this->peer = $this->createPeer();
     }
     return $this->peer;
 }
Esempio n. 2
0
$_SESSION = array_merge($_SESSION, $arraySession);



//Required classes for dbArray work

//require_once ("propel/Propel.php");

//require_once ("creole/Creole.php");

//G::LoadThirdParty ("pake", "pakeColor.class");

Propel::init (PATH_CORE . "config/databases.php");

Creole::registerDriver ('dbarray', 'creole.contrib.DBArrayConnection');



function getLangFiles()

{

    $dir = PATH_LANGUAGECONT;

    $filesArray = array ();

    if (file_exists ($dir)) {

        if ($handle = opendir ($dir)) {
 /**
  * Creates a new Connection as using the driver, url, userid and password specified.
  * The calling method is responsible for closing the connection.
  * @return Connection the newly created connection.
  * @throws BuildException if the UserId/Password/Url is not set or there is no suitable driver or the driver fails to load.
  */
 protected function getConnection()
 {
     if ($this->url === null) {
         throw new BuildException("Url attribute must be set!", $this->location);
     }
     try {
         $this->log("Connecting to " . $this->getUrl(), PROJECT_MSG_VERBOSE);
         $info = new Properties();
         $dsn = Creole::parseDSN($this->url);
         if (!isset($dsn["username"]) && $this->userId === null) {
             throw new BuildException("Username must be in URL or userid attribute must be set.", $this->location);
         }
         if ($this->userId) {
             $dsn["username"] = $this->getUserId();
         }
         if ($this->password) {
             $dsn["password"] = $this->getPassword();
         }
         if ($this->driver) {
             Creole::registerDriver($dsn['phptype'], $this->driver);
         }
         $conn = Creole::getConnection($dsn);
         $conn->setAutoCommit($this->autocommit);
         return $conn;
     } catch (SQLException $e) {
         throw new BuildException($e->getMessage(), $this->location);
     }
 }
Esempio n. 4
0
 /**
  *
  * @param      string $name The database name.
  * @return     Connection A database connection
  * @throws     PropelException - if no conneciton params, or SQLException caught when trying to connect.
  */
 public static function getConnection($name = null)
 {
     if ($name === null) {
         $name = self::getDefaultDB();
     }
     $con = isset(self::$connectionMap[$name]) ? self::$connectionMap[$name] : null;
     if ($con === null || $name === 'dbarray') {
         $dsn = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null;
         if ($dsn === null) {
             if (isset($_SESSION['PROCESS'])) {
                 /** Added By Erik Amaru <erik@colosa.com *******************************
                  * @date: 27-05-08 11:48                                                *
                  * @Description: this was added for the additional database connections *
                  ***********************************************************************/
                 G::LoadClass('dbConnections');
                 $oDbConnections = new dbConnections($_SESSION['PROCESS']);
                 $oDbConnections->loadAdditionalConnections();
                 $dsn = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null;
             } else {
                 throw new PropelException("No connection params set for " . $name);
             }
         }
         include_once 'creole/Creole.php';
         // if specified, use custom driver
         if (isset(self::$configuration['datasources'][$name]['driver'])) {
             Creole::registerDriver($dsn['phptype'], self::$configuration['datasources'][$name]['driver']);
         }
         try {
             $con = Creole::getConnection($dsn);
         } catch (SQLException $e) {
             throw new PropelException($e);
         }
         self::$connectionMap[$name] = $con;
     }
     return $con;
 }
Esempio n. 5
0
 /**
  * Iterates through each datamodel/database, dumps the contents of all tables and creates a DOM XML doc.
  *
  * @return void
  * @throws BuildException
  */
 public function main()
 {
     $this->validate();
     $buf = "Database settings:\n" . " driver: " . ($this->databaseDriver ? $this->databaseDriver : "(default)") . "\n" . " URL: " . $this->databaseUrl . "\n" . ($this->databaseUser ? " user: "******"\n" : "") . ($this->databasePassword ? " password: "******"\n" : "");
     // deprecated
     $this->log($buf, PROJECT_MSG_VERBOSE);
     // 1) First create the Data XML -> database name map.
     $this->createDataDbMap();
     // 2) Now go create the XML files from teh database(s)
     foreach ($this->getDataModels() as $dataModel) {
         // there is really one 1 db per datamodel
         foreach ($dataModel->getDatabases() as $database) {
             // if database name is specified, then we only want to dump that one db.
             if (empty($this->databaseName) || $this->databaseName && $database->getName() == $this->databaseName) {
                 $outFile = $this->getMappedFile($dataModel->getName());
                 $this->log("Dumping data to XML for database: " . $database->getName());
                 $this->log("Writing to XML file: " . $outFile->getName());
                 try {
                     $url = str_replace("@DB@", $database->getName(), $this->databaseUrl);
                     $buf = "Database settings:\n" . " driver: " . ($this->databaseDriver ? $this->databaseDriver : "(default)") . "\n" . " URL: " . $url . "\n" . ($this->databaseUser ? " user: "******"\n" : "") . ($this->databasePassword ? " password: "******"\n" : "");
                     $this->log($buf, PROJECT_MSG_VERBOSE);
                     $dsn = Creole::parseDSN($url);
                     // deprecated, but here for BC
                     if ($this->databaseUser) {
                         $dsn['username'] = $this->databaseUser;
                     }
                     if ($this->databasePassword) {
                         $dsn['password'] = $this->databasePassword;
                     }
                     if ($this->databaseName) {
                         $dsn['database'] = $this->databaseName;
                     }
                     if ($this->databaseDriver) {
                         Creole::registerDriver($dsn['phptype'], $this->databaseDriver);
                     }
                     $this->conn = Creole::getConnection($dsn);
                     $doc = $this->createXMLDoc($database);
                     $doc->save($outFile->getAbsolutePath());
                 } catch (SQLException $se) {
                     $this->log("SQLException while connecting to DB: " . $se->getMessage(), PROJECT_MSG_ERR);
                     throw new BuildException($se);
                 }
             }
             // if databaseName && database->getName == databaseName
         }
         // foreach database
     }
     // foreach datamodel
 }
 /**
  * Take the base url, the target database and insert a set of SQL
  * files into the target database.
  *
  * @param      string $url
  * @param      string $database
  * @param      array $transactions
  */
 private function insertDatabaseSqlFiles($url, $database, $transactions)
 {
     $url = str_replace("@DB@", $database, $url);
     $this->log("Our new url -> " . $url);
     try {
         $buf = "Database settings:\n" . " driver: " . ($this->driver ? $this->driver : "(default)") . "\n" . " URL: " . $url . "\n" . ($this->userId ? " user: "******"\n" : "") . ($this->password ? " password: "******"\n" : "");
         $this->log($buf, PROJECT_MSG_VERBOSE);
         $dsn = Creole::parseDSN($url);
         if ($this->userId) {
             $dsn["username"] = $this->userId;
         }
         if ($this->password) {
             $dsn["password"] = $this->password;
         }
         if ($this->driver) {
             Creole::registerDriver($dsn['phptype'], $this->driver);
         }
         $this->conn = Creole::getConnection($dsn);
         $this->conn->setAutoCommit($this->autocommit);
         $this->statement = $this->conn->createStatement();
         $out = null;
         try {
             if ($this->output !== null) {
                 $this->log("Opening PrintStream to output file " . $this->output->__toString(), PROJECT_MSG_VERBOSE);
                 $out = new FileWriter($this->output);
             }
             // Process all transactions
             for ($i = 0, $size = count($transactions); $i < $size; $i++) {
                 $transactions[$i]->runTransaction($out);
                 if (!$this->autocommit) {
                     $this->log("Commiting transaction", PROJECT_MSG_VERBOSE);
                     $this->conn->commit();
                 }
             }
         } catch (Exception $e) {
             if ($out) {
                 $out->close();
             }
         }
     } catch (IOException $e) {
         if (!$this->autocommit && $this->conn !== null && $this->onError == "abort") {
             try {
                 $this->conn->rollback();
             } catch (SQLException $ex) {
                 // do nothing.
                 System::println("Rollback failed.");
             }
         }
         if ($this->statement) {
             $this->statement->close();
         }
         throw new BuildException($e);
     } catch (SQLException $e) {
         if (!$this->autocommit && $this->conn !== null && $this->onError == "abort") {
             try {
                 $this->conn->rollback();
             } catch (SQLException $ex) {
                 // do nothing.
                 System::println("Rollback failed");
             }
         }
         if ($this->statement) {
             $this->statement->close();
         }
         throw new BuildException($e);
     }
     $this->statement->close();
     $this->log($this->goodSql . " of " . $this->totalSql . " SQL statements executed successfully");
 }
 /**
  * Establishes a Creole database connection
  *
  * @return     object The connection
  */
 protected function getConnection()
 {
     // Attemtp to connect to a database.
     $this->dsn = Creole::parseDSN($this->dbUrl);
     if ($this->dbUser) {
         $this->dsn["username"] = $this->dbUser;
     }
     if ($this->dbPassword) {
         $this->dsn["password"] = $this->dbPassword;
     }
     if ($this->dbDriver) {
         Creole::registerDriver($this->dsn['phptype'], $this->dbDriver);
     }
     $con = Creole::getConnection($this->dsn);
     $this->log("DB connection established");
     return $con;
 }
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
/**
 * @package    symfony
 * @subpackage addon
 * @author     Fabien Potencier <*****@*****.**>
 * @version    SVN: $Id: sfPropelAutoload.php 210 2007-03-01 23:59:16Z jphipps $
 */
require_once 'propel/Propel.php';
if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
    // register debug driver
    require_once 'creole/Creole.php';
    Creole::registerDriver('*', 'symfony.addon.creole.drivers.sfDebugConnection');
    // register our logger
    require_once sfConfig::get('sf_symfony_lib_dir') . '/addon/creole/drivers/sfDebugConnection.php';
    sfDebugConnection::setLogger(sfLogger::getInstance());
}
// propel initialization
Propel::setConfiguration(sfPropelDatabase::getConfiguration());
Propel::initialize();
Esempio n. 9
0
 /**
  * SysLogin
  */
 public function sysLogin()
 {
     require_once "propel/Propel.php";
     require_once "creole/Creole.php";
     G::LoadClass('system');
     G::LoadThirdParty("pake", "pakeColor.class");
     Propel::init(PATH_CORE . "config/databases.php");
     Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
     // getting posibles errors passed by GET method
     $this->getInUrlError();
     $availableWorkspace = $this->getWorkspacesAvailable();
     $availableWorkspaceList = array();
     foreach ($availableWorkspace as $ws) {
         $availableWorkspaceList[] = array($ws, $ws);
     }
     $aField['LOGIN_VERIFY_MSG'] = G::loadTranslation('LOGIN_VERIFY_MSG');
     //Get Server Configuration
     G::LoadClass('serverConfiguration');
     $oServerConf =& serverConf::getSingleton();
     $availableLangArray = $this->getLanguagesList();
     $this->includeExtJSLib('ux/virtualkeyboard');
     $this->setJSVar('sysLang', SYS_LANG);
     $this->includeExtJS('main/sysLogin');
     $this->setVar('logo_company', $this->getCompanyLogo());
     $this->setVar('pmos_version', System::getVersion());
     $footerText = 'Copyright &copy; 2003-' . date('Y') . ' Colosa, Inc. All rights reserved.';
     $adviseText = 'Supplied free of charge with no support, certification, warranty,
         maintenance nor indemnity by Colosa and its Certified Partners. ';
     $this->setVar('footer_text', $footerText);
     $this->setVar('advise_text', $adviseText);
     //binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter()
     if (($flyNotify = $this->getFlyNotify()) !== false) {
         $this->setJSVar('flyNotify', $flyNotify);
     }
     $this->setJSVar('languages', $availableLangArray);
     $this->setJSVar('workspaces', $availableWorkspaceList);
     $this->setJSVar('wsPrivate', $oServerConf->getProperty('LOGIN_NO_WS'));
     $this->setJSVar('defaultLang', 'en');
     $this->setJSVar('defaultWS', '');
     $loginScript = $this->getHeadPublisher()->getExtJsLibraries();
     $loginScript .= $this->getHeadPublisher()->getExtJsScripts();
     $this->setVar('login_script', $loginScript);
     $this->setVar('login_vars', $this->getHeadPublisher()->getExtJsVariablesScript());
     $this->setLayout('pm-modern-login');
     $this->render();
 }
Esempio n. 10
0
 /**
  *
  * @param      string $name The database name.
  * @return     Connection A database connection
  * @throws     PropelException - if no conneciton params, or SQLException caught when trying to connect.
  */
 public static function getConnection($name = null)
 {
     if ($name === null || $name != self::$configuration['datasources']['default']) {
         $name = self::getDefaultDB();
     }
     $con = isset(self::$connectionMap[$name]) ? self::$connectionMap[$name] : null;
     if ($con === null) {
         $dsn = isset(self::$configuration['datasources'][$name]['connection']) ? self::$configuration['datasources'][$name]['connection'] : null;
         if ($dsn === null) {
             throw new PropelException("No connection params set for " . $name);
         }
         include_once 'creole/Creole.php';
         // if specified, use custom driver
         if (isset(self::$configuration['datasources'][$name]['driver'])) {
             Creole::registerDriver($dsn['phptype'], self::$configuration['datasources'][$name]['driver']);
         }
         try {
             $con =& Creole::getConnection($dsn);
         } catch (SQLException $e) {
             throw new PropelException($e);
         }
         self::$connectionMap[$name] = $con;
     }
     return $con;
 }
Esempio n. 11
0
 /**
  * SysLogin
  */
 public function sysLogin()
 {
     require_once "propel/Propel.php";
     require_once "creole/Creole.php";
     G::LoadClass('system');
     G::LoadThirdParty("pake", "pakeColor.class");
     Propel::init(PATH_CORE . "config/databases.php");
     Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
     // getting posibles errors passed by GET method
     $this->getInUrlError();
     $availableWorkspace = $this->getWorkspacesAvailable();
     $availableWorkspaceList = array();
     foreach ($availableWorkspace as $ws) {
         $availableWorkspaceList[] = array($ws, $ws);
     }
     $aField['LOGIN_VERIFY_MSG'] = G::loadTranslation('LOGIN_VERIFY_MSG');
     //Get Server Configuration
     G::LoadClass('serverConfiguration');
     $oServerConf =& serverConf::getSingleton();
     $availableLangArray = $this->getLanguagesList();
     $this->includeExtJSLib('ux/virtualkeyboard');
     $this->setJSVar('sysLang', SYS_LANG);
     $this->includeExtJS('main/sysLogin');
     $this->setVar('logo_company', $this->getCompanyLogo());
     $this->setVar('pmos_version', System::getVersion());
     $footerText = G::LoadTranslation('ID_COPYRIGHT_FROM') . date('Y') . G::LoadTranslation('ID_COPYRIGHT_COL');
     $adviseText = G::LoadTranslation('ID_COLOSA_AND_CERTIFIED_PARTNERS');
     $this->setVar('footer_text', $footerText);
     $this->setVar('advise_text', $adviseText);
     //binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter()
     if (($flyNotify = $this->getFlyNotify()) !== false) {
         $this->setJSVar('flyNotify', $flyNotify);
     }
     $this->setJSVar('languages', $availableLangArray);
     $this->setJSVar('workspaces', $availableWorkspaceList);
     $this->setJSVar('wsPrivate', $oServerConf->getProperty('LOGIN_NO_WS'));
     $this->setJSVar('defaultLang', 'en');
     $this->setJSVar('defaultWS', '');
     $loginScript = $this->getHeadPublisher()->getExtJsLibraries();
     $loginScript .= $this->getHeadPublisher()->getExtJsScripts();
     $this->setVar("login_script", $loginScript);
     $this->setVar("login_vars", $this->getHeadPublisher()->getExtJsVariablesScript());
     $this->setVar("URL_TRANSLATION_JS", G::browserCacheFilesUrl("/js/ext/translation.en.js"));
     $this->setLayout("pm-modern-login");
     $this->render();
 }
Esempio n. 12
0
 public function initPropel($sys = '')
 {
     if (empty($sys)) {
         if (!defined(SYS_SYS)) {
             throw new Exception("Error: Undefined syemtem env. constant 'SYS_SYS'");
         }
         $sys = SYS_SYS;
     }
     // setup propel definitions and logging
     if (defined('DEBUG_SQL_LOG') && DEBUG_SQL_LOG) {
         define('PM_PID', mt_rand(1, 999999));
         // register debug connection decorator driver
         Creole::registerDriver('*', 'creole.contrib.DebugConnection');
         // initialize Propel with converted config file
         Propel::init(PATH_CORE . "config/databases.php");
         // unified log file for all databases
         $logFile = PATH_DATA . 'log' . PATH_SEP . 'propel.log';
         $logger = Log::singleton('file', $logFile, 'wf ' . $sys, null, PEAR_LOG_INFO);
         Propel::setLogger($logger);
         // log file for workflow database
         $con = Propel::getConnection('workflow');
         if ($con instanceof DebugConnection) {
             $con->setLogger($logger);
         }
         // log file for rbac database
         $con = Propel::getConnection('rbac');
         if ($con instanceof DebugConnection) {
             $con->setLogger($logger);
         }
         // log file for report database
         $con = Propel::getConnection('rp');
         if ($con instanceof DebugConnection) {
             $con->setLogger($logger);
         }
     } else {
         Propel::init(PATH_CORE . "config/databases.php");
     }
     Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
 }
Esempio n. 13
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
/**
 * @package    symfony
 * @subpackage propel
 * @author     Fabien Potencier <*****@*****.**>
 * @version    SVN: $Id: sfPropelAutoload.php 9864 2008-06-25 12:24:49Z fabien $
 */
require_once 'propel/Propel.php';
$dispatcher = sfProjectConfiguration::getActive()->getEventDispatcher();
if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
    // register debug driver
    require_once 'creole/Creole.php';
    Creole::registerDriver('*', 'symfony.plugins.sfPropelPlugin.lib.creole.drivers.sfDebugConnection');
    // register our logger
    require_once sfConfig::get('sf_symfony_lib_dir') . '/plugins/sfPropelPlugin/lib/creole/drivers/sfDebugConnection.php';
    sfDebugConnection::setDispatcher($dispatcher);
}
// propel initialization
Propel::setConfiguration(sfPropelDatabase::getConfiguration());
Propel::initialize();
Esempio n. 14
0
 function __construct()
 {
     \Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
 }
Esempio n. 15
0
 /**
  * Test to make sure that a de-registered driver cannot
  * be used.
  */
 public function testUnregisterDriver()
 {
     Creole::deregisterDriver('mysql');
     try {
         $driver = Creole::getConnection('mysql://hostname/dbname');
         $this->fail("Expected SQLException to be thrown by attempt to connect to unregistered driver type.");
     } catch (SQLException $e) {
         $this->expectException("No driver has been registered to handle connection type: mysql", $e);
     }
     // now put it back :)
     Creole::registerDriver('mysql', 'creole.drivers.mysql.MySQLConnection');
 }