function EditUPNews()
{
    global $context, $txt, $smcFunc;
    if (empty($_POST['save'])) {
        checkSession('get');
    }
    //Save
    if (!empty($_POST['save'])) {
        checkSession('post');
        if (empty($_POST['title'])) {
            fatal_lang_error('ultport_error_no_add_news_title', false);
        }
        $id = !empty($_POST['id']) ? (int) $_POST['id'] : '';
        $title = (string) $smcFunc['db_escape_string']($_POST['title']);
        $id_cat = !empty($_POST['id_cat']) ? (int) $_POST['id_cat'] : '';
        $body = !empty($_POST['elm1']) ? (string) up_convert_savedbadmin($_POST['elm1']) : '';
        $id_member_updated = !empty($_POST['id_member_updated']) ? (int) $_POST['id_member_updated'] : '';
        $username_updated = !empty($_POST['username_updated']) ? (string) $_POST['username_updated'] : '';
        $date_updated = time();
        if (!empty($id_cat) && !empty($body) && !empty($id)) {
            //Now insert the NEWS in the smf_up_news
            $smcFunc['db_query']('', "\n\t\t\t\tUPDATE {db_prefix}up_news\n\t\t\t\tSET id_category = {int:id_cat}, \n\t\t\t\t\ttitle = {string:title}, \n\t\t\t\t\tbody = {string:body}, \n\t\t\t\t\tid_member_updated = {int:id_member_updated},\n\t\t\t\t\tusername_updated ={string:username_updated},\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tdate_updated = {string:date_updated}\n\t\t\t\tWHERE id = {int:id}\n\t\t\t\tLIMIT 1", array('id_cat' => $id_cat, 'id_member_updated' => $id_member_updated, 'title' => $title, 'username_updated' => $username_updated, 'body' => $body, 'date_updated' => $date_updated, 'id' => $id));
        }
        //redirect the News Admin Section
        redirectexit('action=adminportal;area=up-news;sa=admin-news;' . $context['session_var'] . '=' . $context['session_id']);
    }
    //Load the News
    $id = !empty($_REQUEST['id']) ? (int) $smcFunc['db_escape_string']($_REQUEST['id']) : '';
    $myquery = $smcFunc['db_query']('', "\n\t\tSELECT * \n\t\tFROM {db_prefix}up_news \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['id_category'] = $row['id_category'];
        $context['id_member'] = $row['id_member'];
        $context['title'] = stripslashes($row['title']);
        $context['username'] = $row['username'];
        $context['body'] = stripslashes($row['body']);
        $context['date'] = $row['date'];
    }
    //Load the sections
    $context['section-edit'] = '';
    $myquery2 = $smcFunc['db_query']('', "\n\t\tSELECT id, title \n\t\tFROM {db_prefix}up_news_sections \n\t\tORDER BY id ASC");
    while ($row2 = $smcFunc['db_fetch_assoc']($myquery2)) {
        $active = '';
        if ($context['id_category'] == $row2['id']) {
            $active = 'selected="selected"';
        }
        $context['section-edit'] .= '<option ' . $active . ' value="' . $row2['id'] . '">' . $row2['title'] . '</option>';
    }
    context_html_headers();
    $context['sub_template'] = 'edit_news';
    $context['page_title'] = $txt['ultport_admin_news_title'] . ' - ' . $txt['ultport_admin_edit_news_title'] . ' - ' . $txt['ultport_admin_module_title2'];
}
function EditBlockHtml()
{
    global $context, $txt, $smcFunc;
    if (!isset($_POST['save'])) {
        checkSession('get');
    }
    if (isset($_POST['save'])) {
        checkSession('post');
        if (empty($_POST['bk-title'])) {
            fatal_lang_error('ultport_error_no_add_bk_title', false);
        }
        $id = !empty($_POST['id']) ? $_POST['id'] : '';
        $title = up_convert_savedbadmin($_POST['bk-title']);
        $icon = !empty($_POST['icon']) ? (string) $_POST['icon'] : 'bk-html';
        $bk_collapse = !empty($_POST['can_collapse']) ? (string) $_POST['can_collapse'] : '';
        $bk_style = !empty($_POST['bk_style']) ? (string) $_POST['bk_style'] : '';
        $bk_no_title = !empty($_POST['no_title']) ? (string) $_POST['no_title'] : '';
        $textarea = !empty($_POST['elm1']) ? up_convert_savedbadmin($_POST['elm1']) : '';
        if (!empty($id) && !empty($textarea)) {
            //Now UPDATE the Ultimate portal Blocks HTML
            $smcFunc['db_query']('', "\n\t\t\t\t\tUPDATE {db_prefix}ultimate_portal_blocks\n\t\t\t\t\tSET\ttitle = {string:title},\n\t\t\t\t\t\ticon = {string:icon},\n\t\t\t\t\t\tcontent = {string:textarea},\n\t\t\t\t\t\tbk_collapse = {string:bk_collapse},\n\t\t\t\t\t\tbk_style = {string:bk_style},\n\t\t\t\t\t\tbk_no_title = {string:bk_no_title}\n\t\t\t\t\tWHERE id = {int:id}\n\t\t\t\t\tLIMIT 1", array('title' => $title, 'icon' => $icon, 'textarea' => $textarea, 'bk_collapse' => $bk_collapse, 'bk_style' => $bk_style, 'bk_no_title' => $bk_no_title, 'id' => $id));
        }
        //redirect the Blocks Admin
        redirectexit('action=adminportal;area=ultimate_portal_blocks;sa=admin-block;' . $context['session_var'] . '=' . $context['session_id']);
    }
    $id = !empty($_REQUEST['id']) ? (int) $smcFunc['db_escape_string']($_REQUEST['id']) : '';
    $context['id'] = $id;
    if (!empty($id)) {
        $myquery = $smcFunc['db_query']('', "\n\t\t\tSELECT title, icon, content, bk_collapse, bk_style, bk_no_title\n\t\t\tFROM {db_prefix}ultimate_portal_blocks\n\t\t\tWHERE id={int:id}\n\t\t\tLIMIT 1", array('id' => $id));
        while ($row = $smcFunc['db_fetch_assoc']($myquery)) {
            $context['title'] = stripslashes($row['title']);
            $context['icon'] = stripslashes($row['icon']);
            $context['content'] = stripslashes($row['content']);
            $context['bk_collapse'] = stripslashes($row['bk_collapse']);
            $context['bk_style'] = stripslashes($row['bk_style']);
            $context['bk_no_title'] = stripslashes($row['bk_no_title']);
        }
        $smcFunc['db_free_result']($myquery);
    }
    //Load image folder
    load_image_folder("/icons");
    //load the context_html_headers from Sources/Sub-Ultimate-Portal.php
    context_html_headers("elm1");
    // Call the sub template.
    $context['sub_template'] = 'edit_block_html';
    $context['page_title'] = $txt['ultport_admin_edit_bk_html'];
}
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'] . ')';
}
示例#4
0
function EditNew()
{
    global $db_prefix, $context, $scripturl, $txt, $settings;
    global $user_info;
    global $smcFunc;
    if (!isset($_POST['save'])) {
        checkSession('get');
    }
    //Security - Can User Edit the NEW?
    if (empty($user_info['up-modules-permissions']['news_moderate']) && !$user_info['is_admin']) {
        fatal_lang_error('ultport_error_no_perms_groups', false);
    }
    //End Security
    //Save
    if (isset($_POST['save'])) {
        checkSession('post');
        if (empty($_POST['title'])) {
            fatal_lang_error('ultport_error_no_add_news_title', false);
        }
        $id = (int) $_POST['id'];
        $title = $smcFunc['db_escape_string']($_POST['title']);
        $id_cat = (int) $_POST['id_cat'];
        $body = up_convert_savedbadmin($_POST['elm1']);
        $id_member_updated = (int) $_POST['id_member_updated'];
        $username_updated = $_POST['username_updated'];
        $date_updated = time();
        //Now insert the NEWS in the smf_up_news
        $smcFunc['db_query']('', "UPDATE {$db_prefix}up_news\n\t\t\t\tSET id_category = {$id_cat}, \n\t\t\t\t\ttitle = '{$title}', \n\t\t\t\t\tbody = '{$body}', \n\t\t\t\t\tid_member_updated = {$id_member_updated},\n\t\t\t\t\tusername_updated = '{$username_updated}',\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tdate_updated = {$date_updated}\n\t\t\t\tWHERE id = {$id}");
        //redirect the News Admin Section
        redirectexit('action=news;sa=view-new;id=' . $id . '');
    }
    //Load the News
    $id = $smcFunc['db_escape_string']($_REQUEST['id']);
    $myquery = $smcFunc['db_query']('', "SELECT * \n\t\t\t\t\t\tFROM {$db_prefix}up_news \n\t\t\t\t\t\tWHERE id = {$id}");
    while ($row = $smcFunc['db_fetch_assoc']($myquery)) {
        $context['id'] = $row['id'];
        $context['id_category'] = $row['id_category'];
        $context['id_member'] = $row['id_member'];
        $context['title'] = stripslashes($row['title']);
        $context['title-news'] = '<a href="' . $scripturl . '?action=news;sa=view-new;id=' . $row['id'] . '">' . stripslashes($row['title']) . '</a>';
        $context['username'] = $row['username'];
        $context['body'] = stripslashes($row['body']);
        $context['date'] = $row['date'];
    }
    //Load the sections
    $context['section-edit'] = '';
    $myquery2 = $smcFunc['db_query']('', "SELECT id, title \n\t\t\t\t\t\tFROM {$db_prefix}up_news_sections \n\t\t\t\t\t\tORDER BY id ASC");
    //for the linktree
    $section = '';
    while ($row2 = $smcFunc['db_fetch_assoc']($myquery2)) {
        $active = '';
        if ($context['id_category'] == $row2['id']) {
            $active = 'selected="selected"';
            $section = '<a href="' . $scripturl . '?action=news;sa=show-cat;id=' . $row2['id'] . '">' . stripslashes($row2['title']) . '</a>';
        }
        $context['section-edit'] .= '<option ' . $active . ' value="' . $row2['id'] . '">' . $row2['title'] . '</option>';
    }
    //Load the html headers and load the Editor - Source/Subs-UltimatePortal.php
    context_html_headers("elm1");
    //News Link-tree
    $context['news-linktree'] = '&nbsp;<img border="0" src="' . $settings['default_images_url'] . '/ultimate-portal/open_linktree.gif" alt="" />&nbsp;<a href="' . $scripturl . '?action=news">' . $txt['up_module_news_title'] . '</a> &raquo; ' . $section . '<br /><img border="0" src="' . $settings['default_images_url'] . '/ultimate-portal/linktree_side.gif" alt="" />&nbsp;' . $txt['up_module_news_edit'] . '&nbsp;<em>(' . $context['title-news'] . ')</em>';
    //Forum linktree
    $context['linktree'][1] = array('url' => $scripturl . '?action=news', 'name' => $txt['up_module_news_title']);
    // Call the sub template.
    $context['sub_template'] = 'edit_news';
    $context['page_title'] = $txt['up_module_news_edit'] . ' - ' . $context['title'];
}