Changeset 187 for trunk/globals/classes/form.php
- Timestamp:
- 12/10/2008 04:45:22 PM (3 years ago)
- File:
-
- 1 edited
-
trunk/globals/classes/form.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/globals/classes/form.php
r6 r187 73 73 $this->data[$i]['Pickup_url'] = makelink(array("page" => "pickup", "subpage" => $subpage, "object" => $this->info['FORM_NAME'].".elements['".str_replace(".", "__", $data_field).($multi==FALSE?'':"[]")."']")); 74 74 if ($multi == FALSE) { 75 $this->data[$i]['Type_Pickup'] = $values[0];75 $this->data[$i]['Type_Pickup'] = (isset($values[0])?$values[0]:''); 76 76 } else { 77 77 $this->data[$i]['Type_Pickup'] = $values; … … 91 91 for($i=0;$i<count($this->data);$i++) { 92 92 $key = explode("__", $this->data[$i]['fullField']); 93 if ( $key[1] != '') {93 if (isset($key[1])) { 94 94 if ($ckey == $key[0]) { 95 $this->data[$i]['value'] = $db_data[0][$key[1]];95 $this->data[$i]['value'] = (isset($db_data[0][$key[1]])?$db_data[0][$key[1]]:""); 96 96 } 97 97 } … … 125 125 for ($i=0;$i<count($this->data);$i++) { 126 126 if (isset($this->data[$i])) { 127 $this->data[$i]['value'] = (isset($_POST[$this->data[$i]['fullField']]) ? $_POST[$this->data[$i]['fullField']] : $sc[$this->data[$i]['fullField']]); 127 if (isset($sc[$this->data[$i]['fullField']])) { 128 $sc_dati_ff = $sc[$this->data[$i]['fullField']]; 129 } 130 else { 131 $sc_dati_ff = ''; 132 } 133 $this->data[$i]['value'] = (isset($_POST[$this->data[$i]['fullField']]) ? $_POST[$this->data[$i]['fullField']] : $sc_dati_ff); 128 134 if (isset($this->data[$i]['Compare'])) { 129 $this->data[$i]['Compare_value'] = (isset($_POST[$this->data[$i]['fullField'].'_compare']) ? $_POST[$this->data[$i]['fullField'].'_compare'] : $sc[$this->data[$i]['fullField'].'_compare']); 135 if (isset($sc[$this->data[$i]['fullField'].'_compare'])) { 136 $sc_dati_ff_cmp = $sc[$this->data[$i]['fullField'].'_compare']; 137 } 138 else { 139 $sc_dati_ff_cmp = ''; 140 } 141 $this->data[$i]['Compare_value'] = (isset($_POST[$this->data[$i]['fullField'].'_compare']) ? $_POST[$this->data[$i]['fullField'].'_compare'] : $sc_dati_ff_cmp); 130 142 } 131 143 $this->data[$i]['Null'] = 'YES'; … … 136 148 // get the where string for SQL. $extra[_fieldname_]: '=' | 'starts_with' | 'ends_with' | 'contains' | 'exclude' 137 149 function db_data_where($extra="") { 150 $where = ""; 138 151 for ($i=0;$i<count($this->data);$i++) { 139 152 if (isset($this->data[$i])) { … … 143 156 } 144 157 $value = $this->data[$i]['value']; 145 switch ( $extra[$item]) {158 switch (isset($extra[$item])?$extra[$item]:'') { 146 159 case '': 147 160 case '=': … … 183 196 global $db; 184 197 if (!is_array($pdata)) $pdata = array(); 198 $ret = TRUE; 199 $args = func_get_args(); 200 for ($carg=1;$carg<func_num_args() || $carg==1;$carg=$carg+3) { 201 $ckey = isset($args[$carg])?$args[$carg]:''; 202 unset($data); 203 $cpost = $this->correct_datetime_data($_POST); 204 for($i=0;$i<count($this->data);$i++) { 205 $key = explode("__", $this->data[$i]['fullField']); 206 if (isset($key[1])) { 207 if ($ckey == '') $ckey = $key[0]; 208 if ($ckey == $key[0]) { 209 if (isset($cpost[$this->data[$i]['fullField']])) { 210 if (!is_array($cpost[$this->data[$i]['fullField']])) { 211 $data[$key[1]] = $cpost[$this->data[$i]['fullField']]; 212 } 213 } 214 } 215 } 216 } 217 reset($pdata); 218 while (list($key, $value) = each($pdata)) { 219 $key = explode(".", $key); 220 if ($ckey == $key[0] || !isset($key[1])) { 221 $data[(isset($key[1])?$key[1]:$key[0])] = $value; 222 } 223 } 224 $field = isset($args[$carg+1])?$args[$carg+1]:''; 225 $value = isset($args[$carg+2])?$args[$carg+2]:''; 226 if ($field == '' || $value == '' || $value == 'add') { 227 $ret = $ret && $db->add($ckey, $data); 228 } else { 229 $ret = $ret && $db->set($ckey, $data, "$field = '$value'"); 230 } 231 } 232 return $ret; 233 } 234 235 // pdata: extra data, args: [[table], [key] [value] ...] 236 function db_set_multi($pdata=array()) { 237 global $db; 185 238 $ret = TRUE; 186 239 $args = func_get_args(); … … 191 244 for($i=0;$i<count($this->data);$i++) { 192 245 $key = explode("__", $this->data[$i]['fullField']); 193 if ( $key[1] != '') {246 if (isset($key[1])) { 194 247 if ($ckey == '') $ckey = $key[0]; 195 248 if ($ckey == $key[0]) { 196 if (!is_array($cpost[$this->data[$i]['fullField']])) { 197 $data[$key[1]] = $cpost[$this->data[$i]['fullField']]; 198 } 249 $data[$key[1]] = (isset($cpost[$this->data[$i]['fullField']]))?$cpost[$this->data[$i]['fullField']]:NULL; 199 250 } 200 251 } … … 203 254 while (list($key, $value) = each($pdata)) { 204 255 $key = explode(".", $key); 205 if ($ckey == $key[0] || $key[1] == '') { 206 $data[($key[1]==''?$key[0]:$key[1])] = $value; 207 } 208 } 209 $field = $args[$carg+1]; 210 $value = $args[$carg+2]; 211 if ($field == '' || $value == '' || $value == 'add') { 212 $ret = $ret && $db->add($ckey, $data); 213 } else { 214 $ret = $ret && $db->set($ckey, $data, "$field = '$value'"); 215 } 216 } 217 return $ret; 218 } 219 220 // pdata: extra data, args: [[table], [key] [value] ...] 221 function db_set_multi($pdata=array()) { 222 global $db; 223 $ret = TRUE; 224 $args = func_get_args(); 225 for ($carg=1;$carg<func_num_args() || $carg==1;$carg=$carg+3) { 226 $ckey = $args[$carg]; 227 unset($data); 228 $cpost = $this->correct_datetime_data($_POST); 229 for($i=0;$i<count($this->data);$i++) { 230 $key = explode("__", $this->data[$i]['fullField']); 231 if ($key[1] != '') { 232 if ($ckey == '') $ckey = $key[0]; 233 if ($ckey == $key[0]) { 234 $data[$key[1]] = $cpost[$this->data[$i]['fullField']]; 235 } 236 } 237 } 238 reset($pdata); 239 while (list($key, $value) = each($pdata)) { 240 $key = explode(".", $key); 241 if ($ckey == $key[0] || $key[1] == '') { 242 $data[($key[1]==''?$key[0]:$key[1])] = $value; 256 if ($ckey == $key[0] || !isset($key[1])) { 257 $data[(!isset($key[1])?$key[0]:$key[1])] = $value; 243 258 } 244 259 } … … 253 268 } 254 269 $ret = $ret && $db->del($ckey, $args[$carg+1]." = '".$args[$carg+2]."'"); 255 for ($i=0;$i<count($data_f);$i++) { 256 $data_f[$i][$args[$carg+1]] = $args[$carg+2]; 257 $ret = $ret && $db->add($ckey, $data_f[$i]); 270 if (isset($data_f)) { 271 for ($i=0;$i<count($data_f);$i++) { 272 $data_f[$i][$args[$carg+1]] = $args[$carg+2]; 273 $ret = $ret && $db->add($ckey, $data_f[$i]); 274 } 258 275 } 259 276 }
Note: See TracChangeset
for help on using the changeset viewer.
