Marius Cramer
2015-05-07 9c79079e9cd5c53b61209bed6754ac6c06bbbda2
interface/lib/classes/tform.inc.php
@@ -131,7 +131,7 @@
      $this->module = $module;
      $wb = array();
      include_once ISPC_ROOT_PATH.'/lib/lang/'.$_SESSION['s']['language'].'.lng';
      include ISPC_ROOT_PATH.'/lib/lang/'.$_SESSION['s']['language'].'.lng';
      if(is_array($wb)) $wb_global = $wb;
@@ -252,7 +252,9 @@
         unset($tmp_recordid);
         $querystring = str_replace("{AUTHSQL}", $this->getAuthSQL('r'), $querystring);
         $querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', "self::table_auth_sql", $querystring);
         //$querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', "self::table_auth_sql", $querystring);
         //*Used the ld form to be compatible with php < 5.3
         $querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', create_function('$matches','global $app; $tmp = $app->tform->getAuthSQL("r", $matches[1]); return $tmp;'), $querystring);
         // Getting the records
         $tmp_records = $app->db->queryAllRecords($querystring);
@@ -293,10 +295,12 @@
      return $values;
   }
   /*
   function table_auth_sql($matches){
      return $this->getAuthSQL('r', $matches[1]);
   }
   */
   //* If the parameter 'valuelimit' is set
   function applyValueLimit($limit, $values) {
@@ -845,6 +849,15 @@
               }
            }
            break;
         case 'ISASCII':
            if(preg_match("/[^\x20-\x7F]/", $field_value)) {
               $errmsg = $validator['errmsg'];
               if(isset($this->wordbook[$errmsg])) {
                  $this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
               } else {
                  $this->errorMessage .= $errmsg."<br />\r\n";
               }
            }
         case 'ISEMAIL':
            if(function_exists('filter_var')) {
               if(filter_var($field_value, FILTER_VALIDATE_EMAIL) === false) {
@@ -1048,6 +1061,8 @@
   function getSQL($record, $tab, $action = 'INSERT', $primary_id = 0, $sql_ext_where = '') {
      global $app;
      $primary_id = $app->functions->intval($primary_id);
      // If there are no data records on the tab, return empty sql string
      if(count($this->formDef['tabs'][$tab]['fields']) == 0) return '';
@@ -1272,6 +1287,7 @@
   function getDataRecord($primary_id) {
      global $app;
      $escape = '`';
      $primary_id = $app->functions->intval($primary_id);
      $sql = "SELECT * FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id." AND ".$this->getAuthSQL('r', $this->formDef['db_table']);
      return $app->db->queryOneRecord($sql);
   }
@@ -1285,7 +1301,12 @@
   }
   function getAuthSQL($perm, $table = '') {
      if($_SESSION["s"]["user"]["typ"] == 'admin') {
      global $app;
      $perm = $app->db->quote($perm);
      $table = $app->db->quote($table);
      if($_SESSION["s"]["user"]["typ"] == 'admin' || $_SESSION['s']['user']['mailuser_id'] > 0) {
         return '1';
      } else {
         if ($table != ''){
@@ -1309,6 +1330,7 @@
   function checkPerm($record_id, $perm) {
      global $app;
      $record_id = $app->functions->intval($record_id);
      if($record_id > 0) {
         // Add backticks for incomplete table names.
         if(stristr($this->formDef['db_table'], '.')) {
@@ -1403,7 +1425,7 @@
      if($limit_name == '') $app->error('Limit name missing in function checkClientLimit.');
      // Get the limits of the client that is currently logged in
      $client_group_id = $_SESSION["s"]["user"]["default_group"];
      $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
      $client = $app->db->queryOneRecord("SELECT $limit_name as number, parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
      // Check if the user may add another item
@@ -1425,7 +1447,7 @@
      if($limit_name == '') $app->error('Limit name missing in function checkClientLimit.');
      // Get the limits of the client that is currently logged in
      $client_group_id = $_SESSION["s"]["user"]["default_group"];
      $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
      $client = $app->db->queryOneRecord("SELECT parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
      //* If the client belongs to a reseller, we will check against the reseller Limit too
@@ -1491,7 +1513,7 @@
    */
   function _getDateTimeHTML($form_element, $default_value, $display_seconds=false)
   {
      $_datetime = strtotime($default_value);
      $_datetime = ($default_value && $default_value != '0000-00-00 00:00:00' ? strtotime($default_value) : false);
      $_showdate = ($_datetime === false) ? false : true;
      $dselect = array('day', 'month', 'year', 'hour', 'minute');