/**
* getHistory - returns a result set of audit trail for this support request.
*
- * @return database result set.
+ * @return resource result set.
*/
function getHistory() {
- return db_query_params ('SELECT * FROM artifact_history_user_vw WHERE artifact_id=$1 ORDER BY entrydate DESC',
+ return db_query_params ('SELECT * FROM artifact_history_user_vw WHERE artifact_id=$1 ORDER BY entrydate DESC, id ASC',
array ($this->getID())) ;
}
/**
- * getMessages - get the list of messages attached to this artifact.
+ * getMessages - get the list of messages attached to this artifact.
*
- * @return database result set.
+ * @param string $order
+ * @return resource result set.
*/
- function getMessages($order='up') {
- if ($order == 'up') {
- function getMessages($asc=false) {
- return db_query_params ('SELECT * FROM artifact_message_user_vw WHERE artifact_id=$1 ORDER BY adddate ' . ($asc ? 'ASC' : 'DESC') . ', id ASC',
- array ($this->getID())) ;
++ function getMessages($if_i_get_the_person_reinventing_the_wheel='up') {
++ /*
++ * This is necessary because someone committed a change
++ * to this method in FusionForge trunk that accepts 'up'
++ * as default (luckily, it’s the same!) and 'down' as
++ * alternative probability, whereas FusionForge 5.2 has
++ * false as default and true for ascending order, so we
++ * need to check this out and use === to be sure ☹
++ */
++ if ($if_i_get_the_person_reinventing_the_wheel === 'up') {
+ $order = 'DESC';
- }
- else {
++ } elseif ($if_i_get_the_person_reinventing_the_wheel === true) {
++ $order = 'ASC';
++ } elseif ($if_i_get_the_person_reinventing_the_wheel === false) {
++ $order = 'DESC';
++ } else {
+ $order = 'ASC';
+ }
- return db_query_params ('SELECT * FROM artifact_message_user_vw WHERE artifact_id=$1 ORDER BY adddate '.$order,
- array ($this->getID())) ;
++ return db_query_params('SELECT * FROM artifact_message_user_vw WHERE artifact_id=$1 ORDER BY adddate ' . $order . ', id ASC',
++ array($this->getID()));
+ }
+
+ /**
+ * getMessage - get a message attached to this artifact.
+ *
+ * @param int $msg_id id of the message.
+ * @access public
+ * @return database result set.
+ */
+ function getMessage($msg_id) {
+ if (!$msg_id) {
+ return false;
+ }
+ return db_query_params ('SELECT * FROM artifact_message_user_vw WHERE id=$1',
+ array($msg_id));
}
/**