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