Ejemplo n.º 1
0
/**
 * Render the options available for the given object
 *
 * @param ProjectDataObject $object
 * @return string
 */
function render_object_options(ProjectDataObject $object, $additional_options = null)
{
    $options = array();
    if ($object->canEdit(logged_user())) {
        $options[] = '<a href="' . $object->getEditUrl() . '">' . lang('edit') . '</a>';
    }
    // if
    if ($object->canView(logged_user())) {
        $options[] = '<a href="' . $object->getViewUrl() . '">' . lang('view') . '</a>';
    }
    // if
    if ($object->canDelete(logged_user())) {
        $options[] = '<a href="' . $object->getDeleteUrl() . '">' . lang('delete') . '</a>';
    }
    // if
    if (is_array($additional_options)) {
        $options = array_merge($options, $additional_options);
    }
    if (count($options)) {
        tpl_assign('options', $options);
        return tpl_fetch(get_template_path('object_options', 'application'));
    }
    return '';
}