コード例 #1
0
function ShowPreferencesPermissionsSettings()
{
    global $context, $txt, $smcFunc, $sourcedir;
    $context['view-perms'] = 0;
    $group_selected = '';
    //load permissions
    LoadUPModulesPermissions();
    //View Perms?
    if (!empty($_POST['view-perms'])) {
        checkSession('post');
        $context['view-perms'] = 1;
        $group_selected = (int) $_POST['group'];
        $context['group-selected'] = $group_selected;
        //permits granted
        $result = $smcFunc['db_query']('', "\n\t\t\tSELECT permission, value\n\t\t\tFROM {db_prefix}up_groups_perms\n\t\t\tWHERE ID_GROUP = {int:id_group}", array('id_group' => $group_selected));
        while ($row = $smcFunc['db_fetch_assoc']($result)) {
            $context['permissions'][$row['permission']]['value'] = !empty($row['value']) ? 1 : 0;
        }
        $smcFunc['db_free_result']($result);
    }
    if (!empty($_POST['save'])) {
        checkSession('post');
        $id_group = (int) $_POST['group_selected'];
        $smcFunc['db_query']('', "\n\t\t\tDELETE FROM {db_prefix}up_groups_perms\n\t\t\tWHERE ID_GROUP = {int:id_group}", array('id_group' => $id_group));
        foreach ($context['permissions'] as $permissions => $value) {
            $smcFunc['db_query']('', "\n\t\t\t\tINSERT IGNORE INTO {db_prefix}up_groups_perms(ID_GROUP, permission, value)\n\t\t\t\tVALUES({int:id_group}, {string:perm_name}, " . (!empty($_POST[$permissions]) ? '{int:active}' : '{int:disabled}') . ")", array('id_group' => $id_group, 'perm_name' => $permissions, 'active' => 1, 'disabled' => 0));
        }
        redirectexit('action=adminportal;area=preferences;sa=permissions-settings;' . $context['session_var'] . '=' . $context['session_id']);
    }
    //Load the MemberGroups
    LoadMemberGroups($group_selected);
    $context['sub_template'] = 'preferences_permissions_settings';
    $context['page_title'] = $txt['ultport_admin_permissions_settings_title'] . ' - ' . $txt['ultport_preferences_title'];
}
コード例 #2
0
function Edit()
{
    global $context, $scripturl, $txt, $settings, $user_info, $ultimateportalSettings, $smcFunc;
    if (empty($_POST['save'])) {
        checkSession('get');
    }
    if (empty($ultimateportalSettings['ipage_enable'])) {
        fatal_lang_error('ultport_error_no_active', false);
    }
    if (!$user_info['is_admin'] && !$user_info['up-modules-permissions']['ipage_moderate']) {
        fatal_lang_error('ultport_error_no_perms_groups', false);
    }
    $id = !empty($_REQUEST['id']) && is_numeric($_REQUEST['id']) ? (int) $_REQUEST['id'] : '';
    if (empty($id)) {
        fatal_lang_error('ultport_error_id_not_found', false);
    }
    if (!empty($_POST['save'])) {
        checkSession('post');
        if (empty($_POST['title'])) {
            fatal_lang_error('ultport_error_no_add_ipage_title', false);
        }
        $title = (string) $smcFunc['htmlspecialchars']($_POST['title']);
        $column_left = !empty($_POST['column_left']) ? (int) $_POST['column_left'] : 0;
        $column_right = !empty($_POST['column_right']) ? (int) $_POST['column_right'] : 0;
        $content = $_POST['type_ipage'] == 'html' ? $_POST['elm1'] : (string) $smcFunc['htmlspecialchars']($_POST['ipage_content']);
        $content = $smcFunc['htmltrim']($content, ENT_QUOTES);
        $id_member_updated = (int) $user_info['id'];
        $username_updated = (string) $user_info['username'];
        $date_updated = time();
        $type_ipage = $_POST['type_ipage'];
        $permissionsArray = array();
        if (!empty($_POST['perms'])) {
            foreach ($_POST['perms'] as $rgroup) {
                $permissionsArray[] = (int) $rgroup;
            }
        }
        $finalPermissions = implode(",", $permissionsArray);
        $active = !empty($_POST['active']) ? (string) $_POST['active'] : 'off';
        $sticky = !empty($_POST['sticky']) ? (int) $_POST['sticky'] : 0;
        //Now insert the NEWS in the smf_up_news
        $smcFunc['db_query']('', "\n\t\t\tUPDATE {db_prefix}ultimate_portal_ipage\n\t\t\tSET \ttitle = {string:title}, \n\t\t\t\t\tsticky = {int:sticky}, \n\t\t\t\t\tactive = {string:active}, \n\t\t\t\t\ttype_ipage = {string:type_ipage}, \n\t\t\t\t\tcontent = {string:content}, \n\t\t\t\t\tperms = {string:perms}, \n\t\t\t\t\tcolumn_left = {int:column_left}, \n\t\t\t\t\tcolumn_right = {int:column_right}, \n\t\t\t\t\tdate_updated = {int:date_updated}, \n\t\t\t\t\tid_member_updated = {int:id_member_updated}, \n\t\t\t\t\tusername_updated = {string:username_updated}\n\t\t\tWHERE id = {int:id}", array('title' => $title, 'sticky' => $sticky, 'active' => $active, 'type_ipage' => $type_ipage, 'content' => $content, 'perms' => $finalPermissions, 'column_left' => $column_left, 'column_right' => $column_right, 'date_updated' => $date_updated, 'id_member_updated' => $id_member_updated, 'username_updated' => $username_updated, 'id' => $id));
        //redirect
        if ($active == 'on') {
            redirectexit('action=internal-page;sa=view;id=' . $id);
        } else {
            redirectexit('action=internal-page;sa=view-inactive;id=' . $id);
        }
    }
    if (!empty($id)) {
        //Load Specific Information
        LoadInternalPage('', $condition = "WHERE id = {$id}");
        //Load Member Groups
        LoadMemberGroups();
        //Load the Editor HTML or BBC?
        if ($context['type_ipage'] == 'html') {
            context_html_headers();
            $type_ipage_linktree = $txt['up_ipage_add_html'];
        }
        if ($context['type_ipage'] == 'bbc') {
            $editorOptions = array('id' => 'ipage_content', 'value' => $context['content'], 'form' => 'ipageform');
            $context['smileyBox_container'] = 'smileyBox_' . $editorOptions['id'];
            $context['bbcBox_container'] = 'bbcBox_' . $editorOptions['id'];
            up_create_control_richedit($editorOptions);
            $context['post_box_name'] = $editorOptions['id'];
            $type_ipage_linktree = $txt['up_ipage_add_bbc'];
        }
        //IP Link-tree
        $context['news-linktree'] = '&nbsp;<img alt="" border="0" src="' . $settings['default_images_url'] . '/ultimate-portal/open_linktree.gif" />&nbsp;<a href="' . $scripturl . '?action=internal-page">' . $txt['up_module_ipage_title'] . '</a> <br /><img alt="" border="0" src="' . $settings['default_images_url'] . '/ultimate-portal/linktree_side.gif" />&nbsp;' . $txt['ultport_button_edit'] . '( <em><a href="' . $scripturl . '?action=internal-page;sa=' . ($context['active'] == 'off' && $user_info['is_admin'] ? 'view-inactive' : 'view') . ';id=' . $context['id'] . '">' . $context['title'] . '</a></em> )';
        //Forum linktree
        $context['linktree'][1] = array('url' => $scripturl . '?action=internal-page', 'name' => $txt['up_module_ipage_title']);
    }
    $context['sub_template'] = 'edit';
    $context['page_title'] = $txt['ultport_button_edit'] . '(' . $context['title'] . ')';
}
コード例 #3
0
function ShowBlockPerms()
{
    global $context, $txt, $smcFunc;
    $id = !empty($_REQUEST['id']) ? (int) $smcFunc['db_escape_string']($_REQUEST['id']) : '';
    if (!isset($_POST['save'])) {
        checkSession('get');
    }
    if (isset($_POST['save'])) {
        checkSession('post');
        //go the update perms in Sources/Subs-UltimatePortal.php
        up_update_block_perms($id);
    }
    $myquery = $smcFunc['db_query']('', "\n\t\tSELECT id, title, perms\n\t\tFROM {db_prefix}ultimate_portal_blocks\n\t\tWHERE id={int:id}\n\t\tLIMIT 1", array('id' => $id));
    while ($row = $smcFunc['db_fetch_assoc']($myquery)) {
        $context['id'] = $row['id'];
        $context['title'] = $row['title'];
        $context['perms'] = $row['perms'];
    }
    $smcFunc['db_free_result']($myquery);
    // We need the membergroups / Para poder usar un vector (array) que contenga el ID y nombre del grupo
    LoadMemberGroups();
    // Call the sub template.
    $context['sub_template'] = 'perms_block';
    $context['page_title'] = $context['title'] . ' - ' . $txt['ultport_admin_edit_bk_php'];
}