From 382324d309a6b80a9d22270e016fb05cfa8d51b5 Mon Sep 17 00:00:00 2001 From: Thomas Mudrunka Date: Fri, 23 Sep 2011 17:17:12 +0200 Subject: [PATCH] Priprava na budouci spravu pristupovych prav pomoci rozdeleni uzivatelu do skupin --- index.php | 8 ++++++-- install.sql | 27 ++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/index.php b/index.php index 9e4a67d..c23213f 100755 --- a/index.php +++ b/index.php @@ -433,6 +433,10 @@ class Sklad_DB extends PDO { return preg_replace('(^.|.$)', '', $this->quote($str)); //TODO HACK } + function quote_identifier($str) { + return '`'.$this->escape($str).'`'; //TODO HACK + } + function build_query_select($class, $id=false, $limit=false, $offset=0, $where=false, $search=false, $history=false, $order=false, $suffix_id='_id') { //Configuration $join = array( @@ -450,9 +454,9 @@ class Sklad_DB extends PDO { $class = $this->escape($class); //SELECT - $sql="SELECT * FROM $class\n"; + $sql="SELECT * FROM `$class`\n"; //JOIN - if(isset($join[$class])) foreach($join[$class] as $j) $sql .= "LEFT JOIN $j USING($j$suffix_id)\n"; + if(isset($join[$class])) foreach($join[$class] as $j) $sql .= "LEFT JOIN `$j` USING($j$suffix_id)\n"; //WHERE/REGEXP if($search) { $search = $this->quote($search); diff --git a/install.sql b/install.sql index 75a4636..9a6eb03 100644 --- a/install.sql +++ b/install.sql @@ -40,6 +40,31 @@ INSERT INTO `category` VALUES (1,'picovinky'),(2,'Tezka technika, Traktory, etc. /*!40000 ALTER TABLE `category` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `group` +-- + +DROP TABLE IF EXISTS `group`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `group` ( + `group_id` int(11) NOT NULL auto_increment, + `group_key` char(23) collate utf8_czech_ci NOT NULL, + `group_value` char(23) collate utf8_czech_ci NOT NULL, + PRIMARY KEY (`group_id`,`group_key`) +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `group` +-- + +LOCK TABLES `group` WRITE; +/*!40000 ALTER TABLE `group` DISABLE KEYS */; +INSERT INTO `group` VALUES (0,'default','rw'),(0,'name','admin'),(2,'name','employee'); +/*!40000 ALTER TABLE `group` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `item` -- @@ -258,4 +283,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2011-08-26 0:30:05 +-- Dump completed on 2011-09-23 15:16:52 -- 2.30.2