Пример #1
0
 public static function invokePermissions($pUser, $pObject, $pMethod)
 {
     return true;
     $pUser = new User();
     $registry = KISS_Framework_Registry::instance();
     $permissions = $registry->getEntry('user_defined');
     $permissions_default = $registry->getEntry('default');
     $permission_array = array($permissions->xpath('/application/permission/user[@role="' . $pUser->getRole() . '"]/class[@name="' . get_class($pObject) . '"]/method[@name="' . $pMethod . '"]'), $permissions->xpath('/application/permission/user[@role="' . $pUser->getRole() . '"]/class[@name="' . get_class($pObject) . '"]'), $permissions->xpath('/application/permission/user[@role="' . $pUser->getRole() . '"]'), $permissions->xpath('/application/permission/user[@role="default"]'));
     //$permissions_default->xpath('/application/permission/user[@role="default"]')
     foreach ($permission_array as $permission) {
         if ($permission && count($permission) == 1) {
             return (string) $permission[0]['access'] == "true";
         }
     }
     return false;
 }
Пример #2
0
 /**
  * 返回一个数据库对象
  *
  * @param int $pDBConfig
  * @return KISS_KDO_SqlCommand
  */
 static function &getInstance($pDBConfig = 0, $forceConnect = FALSE)
 {
     if (empty(KISS_KDO_SqlCommand::$theInstances[$pDBConfig])) {
         $registry =& KISS_Framework_Registry::instance();
         $db_configs = $registry->getEntry('database_connections');
         $dbconfig = $db_configs[$pDBConfig];
         $class_name = 'KISS_KDO_' . $dbconfig['DatabaseType'] . 'Command';
         if (!class_exists($class_name)) {
             die('不支持该数据库类型:' . $class_name . '!<br>支持类型:MySql MsSql');
         }
         self::$theInstances[$pDBConfig] = new $class_name();
         self::$theInstances[$pDBConfig]->resetDB($db_configs[$pDBConfig]);
         if ($forceConnect) {
             self::$theInstances[$pDBConfig]->connectDB();
         }
     }
     return self::$theInstances[$pDBConfig];
 }
Пример #3
0
 private function generate()
 {
     $this->config_path = $this->mRoot . $this->mPath['config'];
     $registry =& KISS_Framework_Registry::instance();
     $db_configs = $registry->getEntry('database_connections');
     for ($i = 0; $i < count($db_configs); $i++) {
         $SqlCommand =& KISS_KDO_SqlCommand::getInstance($i);
         $tables = $SqlCommand->ExecuteArrayQuery('SHOW TABLE STATUS FROM ' . $db_configs[$i]['DatabaseName'], 0, 0, 'num');
         foreach ($tables as $row) {
             if (is_array($_POST['tables']) && count($_POST['tables']) > 0 && in_array($row[0], $_POST['tables'])) {
                 print "DB_{$i}: <input type='checkbox'><a href='Admin_" . KISS_Util_Util::magicName($row[0]) . ".php' target='_blank'>{$row[0]}</a> <a href='?action=config&table={$row[0]}&config={$i}'>初始化</a><br>\n";
                 $this->mSmarty->assign('class_name', KISS_Util_Util::magicName($row[0]));
                 $this->mSmarty->assign('table_name', $row[0]);
                 $this->mSmarty->assign('db_offset', $i);
                 $this->mSmarty->assign('date', date("Y/m/d"));
                 if (!file_exists(KISS_Framework_Config::getSystemPath('class') . "/" . KISS_Util_Util::magicName($row[0]) . "2.php")) {
                     $ConfigFile = $this->config_path . "/{$i}_{$row[0]}.serialize";
                     $table_config = array();
                     $keys = array();
                     if (file_exists($ConfigFile)) {
                         $table_config = unserialize(file_get_contents($ConfigFile));
                     }
                     $SqlCommand =& KISS_KDO_SqlCommand::getInstance();
                     $results = $SqlCommand->ExecuteAssocArrayQuery("show full fields from `{$row['0']}`");
                     foreach ($results as &$field) {
                         $field['PHPType'] = $this->getPhpType($field['Type']);
                         $field['PHPMember'] = implode("", array_map('ucfirst', explode('_', $field['Field'])));
                     }
                     $this->mSmarty->assign('keys', $results);
                     if (empty($row[1])) {
                         $this->generate_file(KISS_Framework_Config::getSystemPath('class') . "/DB/" . KISS_Util_Util::magicName($row[0]) . ".php", $this->mSmarty->fetch("base/tpl.class.view.mapping.htm"));
                     } else {
                         $this->generate_file(KISS_Framework_Config::getSystemPath('class') . "/DB/" . KISS_Util_Util::magicName($row[0]) . ".php", $this->mSmarty->fetch("base/tpl.class.mapping.htm"));
                     }
                 }
                 $this->generate_file($this->mRoot . $this->mPath['class'] . "/" . KISS_Util_Util::magicName($row[0]) . ".php", $this->mSmarty->fetch("base/tpl.class.manager.htm"));
             }
         }
     }
 }
Пример #4
0
 /**
  * Get Root Path(WEB-INF's Path)
  *
  * @return string
  */
 function getRootPath()
 {
     $registry =& KISS_Framework_Registry::instance();
     return $registry->getEntry('root_path');
 }