function getSuggestedEntries() { if (!defined('_ADODB_LAYER')) { $rs = new KT_Recordset($GLOBALS[$this->config['recordset']]); } else { $rs =& $GLOBALS[$this->config['recordset']]; } $index = 0; $arr = array(); while (!$rs->EOF && $index < $this->options['numberOfSuggestions']) { $arr[] = $rs->Fields($this->config['suggestField']); $index++; $rs->MoveNext(); } return array('choices' => $arr); }
function WDG_JsRecordset($RecordsetName) { $rs = $GLOBALS[$RecordsetName]; if (is_resource($rs)) { $recordset = new KT_Recordset($rs); } else { $recordset =& $rs; } $nl = "\r\n"; $this->outputString .= <<<EOD <script> top.jsRawData_{$RecordsetName} = [ EOD; $fieldCount = $recordset->FieldCount(); $fieldNames = array(); for ($i = 0; $i < $fieldCount; $i++) { $meta = $recordset->FetchField($i); if ($meta) { $fieldNames[] = $meta->name; $this->outputString .= ($i == 0 ? '[' : ', ') . '"' . $meta->name . '"'; } } $this->outputString .= <<<EOD ], //data EOD; while (!$recordset->EOF) { $arr = array(); foreach ($fieldNames as $field) { $arr[] = $recordset->Fields($field); } $this->outputString .= WDG_phparray2jsarray($arr) . ', '; $recordset->MoveNext(); } $this->outputString .= <<<EOD [] ]; top.{$RecordsetName} = new JSRecordset('{$RecordsetName}'); </script> EOD; //restore old rs position $recordset->MoveFirst(); }
/** * Creates a fake recordset array from the current $columns * This function is called ONLY on error * @return array associative array with the current values. * @access protected */ function getFakeRsArr() { tNG_log::log('tNG' . $this->transactionType, "getFakeRsArr"); $localRs = $this->getLocalRecordset(); if (is_resource($localRs)) { $localRs = new KT_Recordset($localRs); } $fakeArr = array(); $tmpArr = $this->columns; if (!isset($tmpArr[$this->primaryKey]) && trim($this->primaryKey) != '') { $tmpArr[$this->primaryKey] = $this->primaryKeyColumn; } // Transaction was executed and failed, create the recordset from the submitted values foreach ($tmpArr as $colName => $colDetails) { if ($colDetails['method'] == "CURRVAL") { $value = KT_escapeForSql($localRs->Fields($colName), "STRING_TYPE", true); } else { $value = KT_escapeForSql($colDetails['value'], "STRING_TYPE", true); } $fakeArr[$colName] = $value; } $savedPK = $this->getSavedValue($this->primaryKey); if (!is_null($savedPK)) { $fakeArr[$this->pkName] = KT_escapeForSql($savedPK, "STRING_TYPE", true); } else { $fakeArr[$this->pkName] = ""; } return $fakeArr; }
/** * Setter. Sets the attachmetns * Only for PRO version * @param string rename rule * @access public */ function setAttachmentRenameRule($renameRule) { if ($this->type == 'recordset' && $this->error == '') { if (!isset($GLOBALS[$this->rsName])) { $this->error = new tNG_error('EMAIL_ERROR_RECORDSET', array(), array($this->rsName)); return; } $recordset =& $GLOBALS[$this->rsName]; if (is_resource($recordset)) { $rs = new KT_Recordset($recordset); } else { $rs =& $recordset; } $rs->MoveFirst(); while (!$rs->EOF) { $GLOBALS["row_" . $this->rsName] = $rs->fields; $renameRule2 = KT_DynamicData($renameRule, null, null, false, array()); // security if (substr(KT_realpath($this->folder . $renameRule2, false), 0, strlen($this->folder)) != $this->folder) { $this->error = new tNG_error("EMAIL_ERROR_FOLDER", array(), array(KT_realpath($this->folder . $renameRule2, false), $this->folder)); break; } else { if (is_file($this->folder . $renameRule2)) { $this->attachments[] = $this->folder . $renameRule2; } } $rs->MoveNext(); } $rs->MoveFirst(); } else { if ($this->type == 'custom' && $this->error == '') { $renameRule = KT_DynamicData($renameRule, $this->getTng(), $this->escapeMethod, $this->getUseSavedData(), array()); // security if (substr(KT_realpath($this->folder . $renameRule, false), 0, strlen($this->folder)) != $this->folder) { $this->error = new tNG_error("EMAIL_ERROR_FOLDER", array(), array(KT_realpath($this->folder . $renameRule, false), $this->folder)); } else { if (is_file($this->folder . $renameRule)) { $this->attachments[] = $this->folder . $renameRule; } } } } $this->type = ''; $this->folder = ''; $this->rsName = ''; }