id) ? $this->id : array($this->id); $uid = $qry[1]; if($_POST && $qry[0] == "savepreset") { $exclude_array = explode(',',$exclude_fields); $existing = $sql->db_Count("preset", "(*)", " WHERE preset_name='".$saveID."' ") ? TRUE : FALSE; foreach($_POST as $key => $value) { if (in_array($key,$exclude_array) || ($tp->toDB($key) != $key)) { unset($_POST[$key]); // Remove any fields excluded from preset, and those with potentially dubious key names } $_POST[$key] = $tp->toDB($value); } if ($existing) { // Delete any existing entries for this preset (else checkbox settings not updated) $sql -> db_Delete("preset", "preset_name ='".$saveID."' "); } foreach($_POST as $key => $value) { $sql -> db_Insert("preset", "0, '".$saveID."', '$key', '$value' "); } if(!$output) { $ns->tablerender(LAN_SAVED, LAN_PRESET_SAVED); return; } require_once (e_HANDLER."message_handler.php"); $emessage = &eMessage::getInstance(); $emessage->add(LAN_PRESET_SAVED, E_MESSAGE_SUCCESS); } if($_POST['delete_preset'] && e_QUERY == "clr_preset") { $del = $_POST['del_id']; $check = $sql->db_Delete("preset", "preset_name ='".$unique_id[$del]."' "); if($output) { $ns->tablerender(LAN_SAVED, $check ? LAN_PRESET_DELETED : LAN_DELETED_FAILED); return; } require_once (e_HANDLER."message_handler.php"); $emessage = &eMessage::getInstance(); if($check) $emessage->add(LAN_PRESET_DELETED, E_MESSAGE_SUCCESS); else $emessage->add(LAN_DELETED_FAILED, E_MESSAGE_ERROR); } } /** * Read preset * * @param string $unique_id * @return array values */ function read_preset($unique_id) { global $sql, $tp; $val = array(); if(!$_POST) { if($sql->db_Select("preset", "*", "preset_name ='$unique_id' ")) { while($row = $sql->db_Fetch()) { $val[$row['preset_field']] = $tp->toForm($row['preset_value']); $_POST[$row['preset_field']] = $tp->toForm($row['preset_value']); } } } return $val; } // --------------------------------------------------- } ?>