GUI pro locky
authorThomas Mudrunka <tomas@mudrunka.cz>
Sat, 28 Jul 2012 23:28:32 +0000 (01:28 +0200)
committerThomas Mudrunka <tomas@mudrunka.cz>
Sat, 28 Jul 2012 23:28:32 +0000 (01:28 +0200)
assistants/lock.inc.php [new file with mode: 0644]
index.php

diff --git a/assistants/lock.inc.php b/assistants/lock.inc.php
new file mode 100644 (file)
index 0000000..c042ee9
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+switch($SUBPATH[0]) {
+       default: case 1:
+               $result = $this->db->safe_query_fetch("SELECT * FROM `lock`;");
+               if(empty($result)) {
+                       echo 'Not locked...';
+                       $user=$this->db->auth->get_user_id();
+                       $username=$this->db->auth->get_username_by_id($user);
+                       echo $this->html->form("$URL/2", 'POST', array(
+                               array('reason',$username,'textarea',false,'autofocus','reason:'),
+                               array('lock','lock','submit')
+                       ));
+               } else {
+                       echo $this->html->render_item_table($result);
+                       echo $this->html->form("$URL/2", 'POST', array(
+                               array('unlock','unlock','submit')
+                       ));
+               }
+
+               break;
+       case 2:
+               if(isset($_POST['lock'])) {
+                       $lock = $this->db->quote($_POST['reason']);
+                       $this->db->safe_query("INSERT INTO `lock` (lock_name) VALUES ($lock);");
+                       $this->post_redirect_get("$URL_INTERNAL/1", T('Lock set'));
+               }
+               if(isset($_POST['unlock'])) {
+                       $this->db->safe_query("TRUNCATE TABLE `lock`;");
+                       $this->post_redirect_get("$URL_INTERNAL/1", T('Lock unset'));
+               }
+               $this->post_redirect_get("$URL_INTERNAL/1","Lock: No value passed!", true);
+               break;
+}
index 7467bbf02b195386b2fb46b7b1908d8667495e57..439ffae800a1644b381708540cea21b030c4d148 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -743,7 +743,7 @@ class Sklad_DB extends PDO {
 
        function get_columns($class,$disable_cols=array()) { //TODO: Not sure if compatible with non-MySQL DBs
                $class = $this->escape($class);
-               $sql = "SHOW COLUMNS FROM $class;";
+               $sql = "SHOW COLUMNS FROM `$class`;";
                $columns = $this->safe_query_fetch($sql);
                /*foreach($columns as $colk => $col) foreach($col as $key => $val) {
                        if(in_array($col['Field'],$disable_cols)) $columns[$colk]['Extra']='auto_increment';
This page took 0.166297 seconds and 4 git commands to generate.