Ejemplo n.º 1
0
<?php

$options = array(elgg_echo('form:yes') => 'yes', elgg_echo('form:no') => 'no');
if (form_get_user_content_status()) {
    $form_user_content_area = 'yes';
} else {
    $form_user_content_area = 'no';
}
$body = '';
$body .= elgg_echo('form:user_content_status_title');
$body .= '<br />';
$body .= elgg_view('input/radio', array('internalname' => 'params[user_content_area]', 'value' => $form_user_content_area, 'options' => $options));
echo $body;
function form_pagesetup()
{
    global $CONFIG;
    // Set up menu and content setting for logged in users
    if (isloggedin()) {
        form_set_menu_items();
        if (form_get_user_content_status()) {
            add_menu(elgg_echo('item:object:form_data'), $CONFIG->wwwroot . "pg/form/" . $_SESSION['user']->username);
            // add a view content option to user settings
            extend_elgg_settings_page('form/settings/usersettings', 'usersettings/user');
        }
    }
    $context = get_context();
    $form_id = get_input('form_id', get_input('id', 0));
    if (!$form_id && ($sid = get_input('sid', 0))) {
        $form_id = get_entity($sid)->form_id;
    }
    if ($form_id) {
        $form = get_entity($form_id);
        set_page_owner($form->getOwner());
    }
    $username = page_owner_entity()->username;
    if (get_context() == 'admin') {
        $admin_url = $CONFIG->wwwroot . 'mod/form/manage_all_forms.php';
        if ($username) {
            $admin_url .= '?username='******'form:manage_forms_title'), $admin_url);
    }
    if ($context == 'form:admin' && isadminloggedin()) {
        // add_submenu_item(elgg_echo('form:add_new_profile_form_link'),$CONFIG->wwwroot.'mod/form/manage_form.php?username='******'&profile=1', '4formactions');
        // add_submenu_item(elgg_echo('form:add_new_group_profile_form_link'),$CONFIG->wwwroot.'mod/form/manage_form.php?username='******'&profile=2', '4formactions');
        add_submenu_item(elgg_echo('form:manage_group_profile_categories_title'), $CONFIG->wwwroot . 'mod/form/manage_group_profile_categories.php?username='******'4formactions');
    }
    if (in_array($context, array('form', 'form:content', 'form:admin')) && isadminloggedin()) {
        // currently only admins get to manage forms
        if ($form_id) {
            add_submenu_item(elgg_echo('form:edit_page_link'), $CONFIG->wwwroot . 'mod/form/manage_form.php?id=' . $form_id, '1formactions');
            if ($context == 'form:admin') {
                add_submenu_item(elgg_echo('form:preview_link_text'), $CONFIG->wwwroot . 'mod/form/form.php?id=' . $form_id . '&preview=true', '1formactions');
                add_submenu_item(elgg_echo('form:public_link_text'), $CONFIG->wwwroot . 'mod/form/form.php?id=' . $form_id, '1formactions');
                add_submenu_item(elgg_echo('form:list_search_definitions_link'), $CONFIG->wwwroot . 'mod/form/list_search_definitions.php?form_id=' . $form_id, '1formactions');
                add_submenu_item(elgg_echo('form:add_new_search_definition_link_text'), $CONFIG->wwwroot . 'mod/form/manage_search_definition.php?form_id=' . $form_id, '1formactions');
                add_submenu_item(elgg_echo('form:manage_translations_link'), $CONFIG->wwwroot . 'mod/form/manage_form_translation.php?id=' . $form_id, '1formactions');
            }
        }
        add_submenu_item(elgg_echo('form:manage_forms_title'), $CONFIG->wwwroot . 'mod/form/manage_all_forms.php?username='******'3formactions');
        if ($context == 'form:admin') {
            add_submenu_item(elgg_echo('form:add_new_link'), $CONFIG->wwwroot . 'mod/form/manage_form.php?username='******'4formactions');
            add_submenu_item(elgg_echo('form:list_all_fields_link'), $CONFIG->wwwroot . 'mod/form/list_fields.php?type=all&username='******'3formactions');
            add_submenu_item(elgg_echo('form:list_orphan_fields_link'), $CONFIG->wwwroot . 'mod/form/list_fields.php?type=orphan&username='******'3formactions');
        }
    }
    if (in_array($context, array('form', 'form:content', 'form:admin')) && form_get_user_content_status()) {
        add_submenu_item(elgg_echo('form:view_all_forms'), $CONFIG->wwwroot . 'pg/form/' . $username, '2formactions');
    }
    if ($context == 'form:content' && $form_id) {
        if (isloggedin()) {
            set_page_owner($_SESSION['user']->getGUID());
        }
        if (!$form->profile) {
            if ($sid = get_input('sid', 0)) {
                $sid_bit = '&sid=' . $sid;
            } else {
                $sid_bit = '';
            }
            if (isloggedin()) {
                add_submenu_item(elgg_echo('form:add_content'), $CONFIG->wwwroot . 'mod/form/form.php?id=' . $form_id, '0formactions');
                //add_submenu_item(elgg_echo('form:view_mine'),$CONFIG->wwwroot.'mod/form/my_forms.php?id='.$form_id.'&form_view=mine'.$sid_bit,'4formactions');
                //add_submenu_item(elgg_echo('form:view_friends'),$CONFIG->wwwroot.'mod/form/my_forms.php?id='.$form_id.'&form_view=friends'.$sid_bit,'4formactions');
            }
            add_submenu_item(elgg_echo('form:view_all'), $CONFIG->wwwroot . 'mod/form/my_forms.php?id=' . $form_id . '&form_view=all' . $sid_bit, '0formactions');
            $sd_list = get_entities_from_metadata('form_id', $form_id, 'object', 'form:search_definition');
            if ($sd_list) {
                foreach ($sd_list as $sd) {
                    $sd_id = $sd->getGUID();
                    add_submenu_item(form_search_definition_t($form, $sd, 'title'), $CONFIG->wwwroot . 'mod/form/search.php?sid=' . $sd_id, '0formactions');
                }
            }
        }
    }
}