Beispiel #1
0
function giveActionAccess($where, $role_id)
{
    $db = BizSystem::dbConnection();
    try {
        if (empty($where)) {
            $sql = "SELECT * FROM acl_action";
        } else {
            $sql = "SELECT * FROM acl_action WHERE {$where}";
        }
        BizSystem::log(LOG_DEBUG, "DATAOBJ", $sql);
        $rs = $db->fetchAll($sql);
        $sql = "";
        foreach ($rs as $r) {
            $sql = "DELETE FROM acl_role_action WHERE role_id={$role_id} AND action_id={$r['0']}; ";
            BizSystem::log(LOG_DEBUG, "DATAOBJ", $sql);
            $db->query($sql);
            $sql = "INSERT INTO acl_role_action (role_id, action_id, access_level) VALUES ({$role_id},{$r['0']},1)";
            BizSystem::log(LOG_DEBUG, "DATAOBJ", $sql);
            $db->query($sql);
        }
    } catch (Exception $e) {
        echo "ERROR: " . $e->getMessage() . "" . PHP_EOL;
        return false;
    }
}
 function open($savePath, $sessionName)
 {
     // echo "session open".nl;
     // connect to session db
     $this->sessionDb = BizSystem::dbConnection(SESSION_DBNAME);
     $sessionID = session_id();
     if ($sessionID !== "") {
         $this->initSessionData = $this->read($sessionID);
     }
     return true;
 }
 /**
  * Get database connection
  *
  * @return Zend_Db_Adapter_Abstract
  **/
 public function getDBConnection()
 {
     return BizSystem::dbConnection($this->m_Database);
 }
Beispiel #4
0
 /**
  * Execute SQL
  *
  * @param array $argList
  * @return void
  */
 protected function executeSQL($argList)
 {
     $dbName = $argList["DBName"];
     if (!$dbName) {
         $dbName = "Default";
     }
     $sql = $argList["SQL"];
     $db = BizSystem::dbConnection($dbName);
     try {
         $resultSet = $db->query($sql);
     } catch (Exception $e) {
         $errorMessage = "Error in run SQL: " . $sql . ". " . $e->getMessage();
     }
 }
Beispiel #5
0
 public function DBConnection()
 {
     return BizSystem::dbConnection($this->dbName);
 }
 /**
  * Get database connection
  *
  * @return Zend_Db_Adapter_Abstract
  **/
 public function getDBConnection($type = 'default')
 {
     switch (strtolower($type)) {
         case "default":
         case "read":
             if ($this->m_DatabaseforRead) {
                 $dbName = $this->m_DatabaseforRead;
             } else {
                 $dbName = $this->m_Database;
             }
             break;
         case "write":
             if ($this->m_DatabaseforWrite) {
                 $dbName = $this->m_DatabaseforWrite;
             } else {
                 $dbName = $this->m_Database;
             }
             break;
     }
     return BizSystem::dbConnection($dbName);
 }
Beispiel #7
0
echo "This script is to create cubi installation database." . PHP_EOL;
echo "Please create a CubiInstall database in cubi/Config.xml." . PHP_EOL;
echo "Is CubiInstall created? (y/n) ";
// Read the input
$answer = trim(fgets(STDIN));
echo "Your answer is {$answer}" . PHP_EOL;
if ($answer != 'y') {
    exit;
}
include_once dirname(dirname(__FILE__)) . "/app_init.php";
if (!defined("CLI")) {
    exit;
}
include_once MODULE_PATH . "/system/lib/ModuleLoader.php";
$cubiInstallDb = "CubiInstall";
$db = BizSystem::dbConnection($cubiInstallDb);
if (!$db) {
    echo "Please create a CubiInstall database in cubi/Config.xml." . PHP_EOL;
}
$modules = array('system', 'menu');
foreach (glob(MODULE_PATH . DIRECTORY_SEPARATOR . "*") as $dir) {
    $modName = str_replace(MODULE_PATH . DIRECTORY_SEPARATOR, "", $dir);
    if ($modName != "system" && $modName != "menu") {
        array_push($modules, $modName);
    }
}
// find all modules
foreach ($modules as $mod) {
    echo PHP_EOL . "---------------------------------------------------" . PHP_EOL;
    echo "> Start loading '{$mod}' module ..." . PHP_EOL;
    $loader = new ModuleLoader($mod, $cubiInstallDb);
Beispiel #8
0
 /**
  * Load table index and uniqueness information
  * @return void
  */
 protected function getTableIndex()
 {
     $db = BizSystem::dbConnection($this->db_name);
     $db_driver = $this->db_config['Driver'];
     switch (strtoupper($db_driver)) {
         case 'PDO_MYSQL':
             $sql = "SHOW INDEX FROM {$this->table_name};";
             $result = $db->query($sql);
             $tblIndexes = $result->fetchAll();
             break;
         default:
             break;
     }
     $tableIndex = array();
     if ($tblIndexes) {
         foreach ($tblIndexes as $colIndex) {
             $non_unique = $colIndex[1];
             $key_name = $colIndex[2];
             $col_name = $colIndex[4];
             if ($key_name != "PRIMARY" && $tblCols[$col_name]['DATA_TYPE'] != 'int') {
                 //$tableIndex[$key_name]=array();
                 $indexInfo = array("NON_UNIQUE" => $non_unique, "KEY_NAME" => $key_name, "COL_NAME" => $col_name);
                 if (!is_array($tableIndex[$key_name])) {
                     $tableIndex[$key_name] = array();
                 }
                 array_push($tableIndex[$key_name], $indexInfo);
             }
         }
     }
     $this->tableIndex = $tableIndex;
     $uniqueness = "";
     foreach ($tableIndex as $key_name => $key_index) {
         $key_uniqueness = "";
         foreach ($key_index as $indexInfo) {
             if ($indexInfo['NON_UNIQUE'] == "0") {
                 if ($key_uniqueness != "") {
                     $key_uniqueness .= ",";
                 }
                 $key_uniqueness .= $indexInfo['COL_NAME'];
             }
         }
         if ($key_uniqueness != "") {
             $uniqueness .= $key_uniqueness . ";";
         }
     }
     $this->uniqueness = $uniqueness;
 }
Beispiel #9
0
 /**
  * Get Database profile
  *
  * @todo not finish
  * @param <type> $userId
  * @param <type> $password
  */
 protected function getDBProfile($userId, $password)
 {
     // CASE 1: simple one table query
     // SELECT role, group, pstn, divn, org FROm user_table AS t1
     // WHERE t1.userid='$userid'
     // CASE 2: intersection table user_pstn (user_role, user_divn, user_org ...), need to query multiple times
     // SELECT t1.pstnid, t2.name FROM user_pstn_table AS t1
     // JOIN pstn_table AS t2 ON t1.pstnid=t2.id
     // WHERE t1.userid='$userid'
     // CASE 3: all hierarchy info contained in one big party table, do query once, then filter on type column
     // SELECT t1.partyid, t2.name, t2.type FROM user_party_table AS t1
     // JOIN party_table AS t2 ON t1.partyid=t2.id
     // WHERE t1.userid='$userid'
     $db = BizSystem::dbConnection();
     $resultSet = $db->execute($sql);
     $sqlArr = $resultSet->fetchRow();
     // process the result
 }