Subversion Repositories ALCASAR

Rev

Rev 2016 | Rev 2047 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2016 Rev 2044
Line 77... Line 77...
77
	//	if value is null or equals the default value then don't add it
77
	//	if value is null or equals the default value then don't add it
78
			else if (isset($default_vals["$key"]) && ($val == '' || check_defaults($val,$op_val,$default_vals["$key"])))
78
			else if (isset($default_vals["$key"]) && ($val == '' || check_defaults($val,$op_val,$default_vals["$key"])))
79
				continue;
79
				continue;
80
	//	if value differs from the sql value then update
80
	//	if value differs from the sql value then update
81
			else{
81
			else{
82
				#if attribute not set, we create it. 
-
 
83
                                if(!isset($old_val) && $sql_attr=='Filter-Id')
-
 
84
                                {
-
 
85
                                        $res = da_sql_query($link,$config,"UPDATE $table SET value = '$val' WHERE $query_key = '$login' AND attribute = '$sql_attr' AND value = '';");
-
 
86
                                        if (!$res || !da_sql_affected_rows($link,$res,$config))
-
 
87
                                                echo "<b>Change failed for attribute $key: " . da_sql_error($link,$config) . "</b><br>\n";
-
 
88
                                }
-
 
89
			
-
 
90
				if (isset($item_vals["$key"][$j]) && (isset($old_val) && $old_val !='') || $sql_attr=='Filter-Id'){
82
				if (isset($item_vals["$key"][$j]) && (isset($old_val) && $old_val !='') || $sql_attr=='Filter-Id'){
91
					$old_val = $item_vals["$key"][$j];
83
					$old_val = $item_vals["$key"][$j];
92
					$old_val = da_sql_escape_string($link, $old_val);
84
					$old_val = da_sql_escape_string($link, $old_val);
93
					#we keep the fourth bit of Filter-Id to warn user about administrator who read imputability logs.
85
					#we keep the fourth bit of Filter-Id to warn user about administrator who read imputability logs.
94
                                        $val[3]=$old_val[3];
86
                                        $val[3]=$old_val[3];
95
					$res = da_sql_query($link,$config,
87
					$res = da_sql_query($link,$config,
96
					"UPDATE $table SET value = '$val' WHERE $query_key = '$login' AND
88
					"UPDATE $table SET value = '$val' WHERE $query_key = '$login' AND
97
					attribute = '$sql_attr' AND value = '$old_val';");
89
					attribute = '$sql_attr' AND value = '$old_val';");
-
 
90
					
-
 
91
					#if filter-id does not exit, we create it (ALCASAR 2.9.2 DDB)
-
 
92
					if (!$res || !da_sql_affected_rows($link,$res,$config))
-
 
93
						$res = da_sql_query($link,$config,"INSERT INTO $table ($query_key,attribute,value $text2) VALUES ('$login','$sql_attr','00000000', ':=');");
98
	
94
					
99
					if (!$res || !da_sql_affected_rows($link,$res,$config))
95
					if (!$res || !da_sql_affected_rows($link,$res,$config))
100
						echo "<b>Change failed for attribute $key: " . da_sql_error($link,$config) . "</b><br>\n";
96
						echo "<b>Change failed for attribute $key: " . da_sql_error($link,$config) . "</b><br>\n";
101
				}
97
				}
102
				else{
98
				else{
103
					if($val != ''){
99
					if($val != ''){
104
						$res = da_sql_query($link,$config,
100
					$old_val = $item_vals["$key"][$j];
-
 
101
                                        $old_val = da_sql_escape_string($link, $old_val);
-
 
102
 
105
						"INSERT INTO $table ($query_key,attribute,value $text2)
103
                                        $res = da_sql_query($link,$config,
-
 
104
                                        "UPDATE $table SET value = '$val' WHERE $query_key = '$login' AND
106
						VALUES ('$login','$sql_attr','$val' $op_val2);");
105
                                        attribute = '$sql_attr' AND value = '$old_val';");
-
 
106
                                        
-
 
107
                                        #if attribute does not exist, we create it.     
-
 
108
                                        if (!$res || !da_sql_affected_rows($link,$res,$config))
-
 
109
                                        {
-
 
110
                                                $res = da_sql_query($link,$config,"INSERT INTO $table ($query_key,attribute,value $text2) VALUES ('$login','$sql_attr','$val' $op_val2);");
-
 
111
                                        }
-
 
112
 
107
					if (!$res || !da_sql_affected_rows($link,$res,$config))
113
					if (!$res || !da_sql_affected_rows($link,$res,$config))
108
						echo "<b>Change failed for attribute $key: " . da_sql_error($link,$config) . "</b><br>\n";
114
						echo "<b>Change failed for attribute $key: " . da_sql_error($link,$config) . "</b><br>\n";
109
					}
115
					}
-
 
116
					else
-
 
117
                                        {
-
 
118
                                                #if value is empty, we delete this attribute
-
 
119
                                                $old_val = $item_vals["$key"][$j];
-
 
120
                                                $old_val = da_sql_escape_string($link, $old_val);
-
 
121
                                                if(isset($old_val) && $old_val != '')
-
 
122
                                                {
-
 
123
                                                        $res = da_sql_query($link,$config,"DELETE FROM $table WHERE $query_key = '$login' AND attribute = '$sql_attr' AND value = '$old_val';");
-
 
124
                                                }
-
 
125
                                        }
110
				}
126
				}
111
			}
127
			}
112
		}
128
		}
113
	}
129
	}
114
}
130
}