Ejemplo n.º 1
0
/**
 * Call back function for ticket link
 * 
 * @param mixed $matches
 * @return
 */
function replace_ticket_link_callback($matches)
{
    if (count($matches) < 2) {
        return null;
    }
    // if
    if (!logged_user()->isMemberOfOwnerCompany()) {
        $object = ProjectTickets::findOne(array('conditions' => array('`id` = ? AND `project_id` = ? AND `is_private` = 0 ', $matches[1], active_project()->getId())));
    } else {
        $object = ProjectTickets::findOne(array('conditions' => array('`id` = ? AND `project_id` = ?', $matches[1], active_project()->getId())));
    }
    // if
    if (!$object instanceof ProjectTicket) {
        return '<del>' . lang('invalid reference') . '</del>';
    } else {
        return '<a href="' . $object->getViewUrl() . '">' . $object->getTitle() . '</a>';
    }
    // if
}