Login or Register

RSS IconRecent posts in this topic

avatar
jwtdigital on Jan 10. 2008. 10:17 am
Can anyone suggest a way to list comments on tickets starting with the most recent?

Thanks
avatar
Ilija Studen on Jan 10. 2008. 10:45 am
Put this function in Ticket class (Ticket.class.php in activecollab/application/modules/tickets/models/tickets):

/**
 * Return comment submitted for this project object
 *
 * @param integer $min_visiblity
 * @return array
 */
function getComments($min_visiblity = VISIBILITY_NORMAL) {
  return ProjectObjects::find(array(
    'conditions' => array("type = 'Comment' AND parent_id = ? AND state >= ? AND visibility >= ?", $this->getId(), STATE_VISIBLE, $min_visiblity),
     'order' => 'created_on DESC',
  ));
}

activeCollab team member
avatar
jwtdigital on Jan 10. 2008. 10:57 am
Hi Ilija,
I added the code but there was no change?

My file now looks like this....

<?php


/**
 * Return comment submitted for this project object
 *
 * @param integer $min_visiblity
 * @return array
 */
function getComments($min_visiblity = VISIBILITY_NORMAL) {
  return ProjectObjects::find(array(
    'conditions' => array("type = 'Comment' AND parent_id = ? AND state >= ? AND visibility >= ?", $this->getId(), STATE_VISIBLE, $min_visiblity),
     'order' => 'created_on DESC',
  ));
}

  /**
  * Ticket record class
  *
  * @package activeCollab.modules.tickets
  * @subpackage models
  */
  class Ticket extends ProjectObject {
    
    /**
     * Manage permission name
     * 
     * @var string
     */
    var $manage_permission_name = 'tickets_manage';
    
    /**
     * Define fields used by this project object
     *
     * @var array
     */
    var $fields = array
avatar
Ilija Studen on Jan 10. 2008. 11:05 am
Add it inside of the class, not above it. See how functions are defined after series of variables defined with var...
activeCollab team member
avatar
jwtdigital on Jan 10. 2008. 11:15 am
That works now thanks! Comments are now in reverse order but the actual comment numbers #1, #2, #3 etc has number one at the top, even though it was actually the *last* comment.

Only a minor thing but would be helpful if you could suggest a quick fix.

Many thanks
avatar
Ilija Studen on Jan 10. 2008. 11:19 am
Sorry, to fix that would require much more changes.

This hack is nice because it's simple and can't do any damage - it just applies to tickets and that's it. If you go any further you'd need much more tweaking and testing.
activeCollab team member
avatar
jwtdigital on Jan 10. 2008. 11:40 am
No worries... thanks for your help! :)

RSS IconRecent posts in this topic