tbrehm
2005-11-26 b4e90c97c397a0436a2033f6e171cc4ea92fe276
interface/lib/classes/tform.inc.php
@@ -101,7 +101,7 @@
   * der Variablen mit Regex
   * @var errorMessage
   */
   var $errorMessage;
   var $errorMessage = '';
   
   var $dateformat = "d.m.Y";
    var $formDef;
@@ -216,6 +216,7 @@
         $querystring = str_replace("{GROUPS}",$_SESSION["s"]["user"]["groups"],$querystring);
         $table_idx = $this->formDef['db_table_idx'];
         $querystring = str_replace("{RECORDID}",$record[$table_idx],$querystring);
         $querystring = str_replace("{AUTHSQL}",$this->getAuthSQL('r'),$querystring);
         
         // Getting the records
         $tmp_records = $app->db->queryAllRecords($querystring);
@@ -435,7 +436,7 @@
            break;
            
            default:
               $new_record[$key] = htmlspecialchars($field['value']);
               $new_record[$key] = htmlspecialchars($field['default']);
            }
         }
      
@@ -456,7 +457,7 @@
   function encode($record,$tab) {
      
      if(!is_array($this->formDef['tabs'][$tab])) $app->error("Tab ist leer oder existiert nicht (TAB: $tab).");
      $this->errorMessage = '';
      //$this->errorMessage = '';
      
      if(is_array($record)) {
         foreach($this->formDef['tabs'][$tab]['fields'] as $key => $field) {
@@ -556,14 +557,12 @@
                  $this->errorMessage .= $this->wordbook[$errmsg]."<br>\r\n";
               }
            break;
            /*
            case 'ISEMAIL':
               if(!preg_match("", $field_value)) {
               if(!preg_match("/^\w+[\w.-]*\w+@\w+[\w.-]*\w+\.[a-z]{2,4}$/i", $field_value)) {
                  $errmsg = $validator['errmsg'];
                  $this->errorMessage .= $this->wordbook[$errmsg]."<br>\r\n";
               }
            break;
            */
            case 'ISINT':
               $tmpval = intval($field_value);
               if($tmpval === 0 and !empty($field_value)) {
@@ -602,6 +601,9 @@
      
      global $app;
      
      // If there are no data records on the tab, return empty sql string
      if(count($this->formDef['tabs'][$tab]['fields']) == 0) return '';
      // checking permissions
      if($this->formDef['auth'] == 'yes') {
         if($action == "INSERT") {
@@ -631,14 +633,22 @@
               if($action == "INSERT") {
                  if($field['formtype'] == 'PASSWORD') {
                     $sql_insert_key .= "`$key`, ";
                     $sql_insert_val .= "md5('".$record[$key]."'), ";
                     if($field['encryption'] == 'CRYPT') {
                        $sql_insert_val .= "'".crypt($record[$key])."', ";
                     } else {
                        $sql_insert_val .= "md5('".$record[$key]."'), ";
                     }
                  } else {
                     $sql_insert_key .= "`$key`, ";
                     $sql_insert_val .= "'".$record[$key]."', ";
                  }
               } else {
                  if($field['formtype'] == 'PASSWORD') {
                     $sql_update .= "`$key` = md5('".$record[$key]."'), ";
                     if($field['encryption'] == 'CRYPT') {
                        $sql_update .= "`$key` = '".crypt($record[$key])."', ";
                     } else {
                        $sql_update .= "`$key` = md5('".$record[$key]."'), ";
                     }
                  } else {
                     $sql_update .= "`$key` = '".$record[$key]."', ";
                  }
@@ -646,6 +656,7 @@
            }
         }
        }
      
      // Füge Backticks nur bei unvollständigen Tabellennamen ein
      if(stristr($this->formDef['db_table'],'.')) {
@@ -835,9 +846,12 @@
      } else {
         $result = false;
         if($this->formDef["auth_preset"]["userid"] == $_SESSION["s"]["user"]["userid"] && stristr($perm,$this->formDef["auth_preset"]["perm_user"])) $result = true;
         if($this->formDef["auth_preset"]["userid"] == $_SESSION["s"]["user"]["groupid"] && stristr($perm,$this->formDef["auth_preset"]["perm_group"])) $result = true;
         if($this->formDef["auth_preset"]["groupid"] == $_SESSION["s"]["user"]["groupid"] && stristr($perm,$this->formDef["auth_preset"]["perm_group"])) $result = true;
         if(@stristr($perm,$this->formDef["auth_preset"]["perm_other"])) $result = true;
         
         // if preset == 0, everyone can insert a record of this type
         if($this->formDef["auth_preset"]["userid"] == 0 AND $this->formDef["auth_preset"]["groupid"] == 0) $result = true;
         return $result;
         
      }