/**
 * Handle on inline tabs event
 *
 * @param NamedList $tabs
 * @param ApplicationObject $object
 * @param User $logged_user
 * @param string $interface
 * @return null
 */
function ac_gitolite_handle_on_inline_tabs(&$tabs, &$object, &$logged_user, $interface)
{
    if ($object instanceof User) {
        if ($object->getId() == $logged_user->getId() || $logged_user->isAdministrator() || $logged_user->isPeopleManager()) {
            $tabs->add('view_keys', array('title' => lang('Public Keys'), 'url' => Router::assemble('get_public_keys', array('company_id' => $object->getCompanyId(), 'user_id' => $object->getId()))));
        }
    }
    // if User
}
function frosso_estimated_cost_handle_on_after_object_save(ApplicationObject &$object)
{
    if ($object instanceof Milestone && !$object instanceof RemediaMilestone) {
        if (isset($_POST['milestone']['custom_field_1']) && $_POST['milestone']['custom_field_1'] != '') {
            $remedia_mil = new RemediaMilestone($object->getId());
            $remedia_mil->customFields()->setValue('custom_field_1', $_POST['milestone']['custom_field_1']);
            $remedia_mil->setNew(false);
            $remedia_mil->save();
        }
    }
}
 /**
  * Find last attachment for a given object
  *
  * @param ApplicationObject $object
  * @return Attachment
  */
 function findLastByObject($object)
 {
     return Attachments::find(array('conditions' => array('parent_id = ? AND parent_type = ?', $object->getId(), get_class($object)), 'order' => 'created_on DESC', 'limit' => 1, 'one' => true));
 }