00001 <?php
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/DataAccess.php';
00026
00027
00028
00029
00040
00041 class FF_DataAccess_CustomField_mysql extends FF_DataAccess {
00042
00043
00048 var $dataTable;
00049
00050
00051
00052
00059 function FF_DataAccess_CustomField_mysql()
00060 {
00061 FF_DataAccess::FF_DataAccess();
00062 $this->table = $this->o_registry->getConfigParam('data/custom_fields', 'mayday_custom_fields', 'mayday');
00063 $this->dataTable = $this->o_registry->getConfigParam('data/custom_fields_data', 'mayday_custom_fields_data', 'mayday');
00064 }
00065
00066
00067
00068
00077 function remove($in_id)
00078 {
00079 $o_result =& parent::remove($in_id);
00080 if ($o_result->isSuccess()) {
00081 $tmp = $this->table;
00082 $this->table = $this->dataTable;
00083 $o_result =& parent::remove($in_id, 'field_id');
00084 $this->table = $tmp;
00085 }
00086
00087 return $o_result;
00088 }
00089
00090
00091
00092
00103 function getFieldsByCategory($in_catId, $in_ticketId = null)
00104 {
00105 if (!is_null($in_ticketId)) {
00106 $s_query = "SELECT id, category_id, description, type, data
00107 FROM $this->table AS t1
00108 LEFT JOIN $this->dataTable AS t2 ON t1.id = t2.field_id AND ticket_id = ?
00109 WHERE category_id = ? ORDER BY id";
00110
00111 return $this->o_data->getAll($s_query, array($in_ticketId, $in_catId));
00112 }
00113 else {
00114 $s_query = "SELECT * FROM $this->table WHERE category_id = ? ORDER BY id";
00115
00116 return $this->o_data->getAll($s_query, array($in_catId));
00117 }
00118
00119 }
00120
00121
00122
00123
00135 function saveData($in_fieldId, $in_ticketId, $in_data, &$in_result)
00136 {
00137 $result = $this->o_data->autoExecute($this->dataTable, array('data' => $in_data, 'field_id' => $in_fieldId, 'ticket_id' => $in_ticketId));
00138 if (DB::isError($result)) {
00139 $in_result->addMessage($result->getMessage());
00140 }
00141 }
00142
00143
00144
00145
00154 function removeDataForTicket($in_ticketId)
00155 {
00156 $s_stmt = $this->o_data->prepare("DELETE FROM $this->dataTable WHERE ticket_id = ?");
00157 $this->o_data->execute($s_stmt, $in_ticketId);
00158 }
00159
00160
00161
00162
00169 function getCategoriesWithField()
00170 {
00171 $s_query = "SELECT DISTINCT(category_id) FROM $this->table";
00172 return $this->o_data->getCol($s_query, 0);
00173 }
00174
00175
00176
00177
00184 function getNextId()
00185 {
00186
00187 $this->o_data->setOption('seqname_format', '%s');
00188 return $this->o_data->nextId($this->o_registry->getConfigParam('data/sequence_table'));
00189 }
00190
00191
00192 }
00193 ?>