Activated strict SQL mode, minor SQL injection fix, fixed _vl() debug helper.
[fa-stable.git] / includes / ui / class.crud_view.inc
index 8572fdbe867d6f3c527cc3fcb330b0e2e4763d48..963ed75b311a50b1396fe7f531193dc0935235dd 100644 (file)
@@ -43,7 +43,7 @@ class user_view {
        var $dec;
        var $name;
 
-       function user_view($name)
+       function __construct($name)
        {
                $this->name = $name;
        }
@@ -72,6 +72,8 @@ class user_view {
                                    return user_numeric($value);
                        case 'percent':
                                        return user_numeric($value)/100;
+                       case 'check':
+                                       return isset($value) ? 1 : 0;
                        case 'text':
                        case 'date':
                        default:
@@ -92,6 +94,8 @@ class user_view {
                                return number_format2($value);
                        case 'percent':
                                return percent_format($value*100);
+                       case 'check':
+                               return !empty($value);
                        case 'stock':
                                $this->dec = get_qty_dec($value); // retrieve dec for use in following qty fields
                        case 'text':
@@ -161,7 +165,8 @@ class user_view {
                                $value = isset($this->data->$fld) ?     $this->data->$fld : @$fmt['dflt'];
                        else
                                $value = isset($this->data[$fld]) ?     $this->data[$fld] : @$fmt['dflt'];
-                       if(isset($value))
+
+                       if (isset($value))
                                $output[$post] = $this->_format_output($value, @$fmt['fmt']);
                }
        }
@@ -198,9 +203,13 @@ class user_view {
                        $post = isset($fmt['post']) ? $fmt['post'] : $name; // input name (default to field name)
                        $fld = isset($fmt['fld']) ? $fmt['fld'] : $name;        // input value (default to field name)
 
+
 //                     if ($all || array_key_exists($post, $input))
 //                     {
-                               $value = $this->_format_input(@$input[$post], @$fmt['fmt']);
+                               if (@$fmt['fmt'] == 'check')
+                                       $value = @$input[$post] ? 1 : 0;
+                               else
+                                       $value = $this->_format_input(@$input[$post], @$fmt['fmt']);
 
 //                             if (is_array($data))
                                if ($all || isset($value))
@@ -269,9 +278,9 @@ class simple_crud_view extends user_view {
        var $display_both = false; //when set to true both list and editor are displayed all the time (eventually set in sub classes)
        //
        //
-       function simple_crud_view($name, $data_set = null, $options=array())
+       function __construct($name, $data_set = null, $options=array())
        {
-               $this->user_view($name);
+               parent::__construct($name);
 
                $this->options = array_merge($this->options, $options);
 
@@ -596,10 +605,10 @@ class simple_crud_view extends user_view {
 
 class selector_crud_view extends simple_crud_view {
 
-       function selector_crud_view($name, $data_set = null, $options=array())
+       function __construct($name, $data_set = null, $options=array())
        {
                $this->display_both = true;
-               $this->simple_crud_view($name, $data_set, $options);
+               parent::__construct($name, $data_set, $options);
        }
 
        function _check_mode()
@@ -650,10 +659,10 @@ class table_crud_view extends simple_crud_view {
 
        var $title;
 
-       function table_crud_view($name, &$data_set = null, $options=array())
+       function __construct($name, &$data_set = null, $options=array())
        {
                $this->display_both = true;
-               $this->simple_crud_view($name, $data_set, $options);
+               parent::__construct($name, $data_set, $options);
        }
        /**
        *