Exemple #1
0
function blog_admin_controller()
{
    $Blog = new Blog();
    getBlogUserPermissions();
    global $blogUserPermissions, $SITEURL;
    if (!isset($_GET['update'])) {
        $update = blog_version_check();
        if ($update[0] == 'current') {
            $ucolor = '#308000';
        } elseif ($update[0] == 'update') {
            $ucolor = '#FFA500';
        } elseif ($update[0] == 'beta') {
            $ucolor = '#2B5CB3';
        } else {
            $ucolor = '#D94136';
        }
    } else {
        $ucolor = '#777777';
    }
    if (isset($_GET['edit_post']) && $blogUserPermissions['blogeditpost'] == true) {
        editPost($_GET['edit_post']);
    } elseif (isset($_GET['create_post']) && $blogUserPermissions['blogcreatepost'] == true) {
        editPost();
    } elseif (isset($_GET['categories']) && $blogUserPermissions['blogcategories'] == true) {
        if (isset($_GET['edit_category'])) {
            $add_category = $Blog->saveCategory($_POST['new_category']);
            if ($add_category == true) {
                echo '<div class="updated">' . i18n_r(BLOGFILE . '/CATEGORY_ADDED') . '</div>';
            } else {
                echo '<div class="error">' . i18n_r(BLOGFILE . '/CATEGORY_ERROR') . '</div>';
            }
        }
        if (isset($_GET['delete_category'])) {
            $Blog->deleteCategory($_GET['delete_category']);
        }
        #edit_categories
        $category_file = getXML(BLOGCATEGORYFILE);
        require_once 'html/category-management.php';
    } elseif (isset($_GET['auto_importer']) && $blogUserPermissions['blogrssimporter'] == true) {
        if (isset($_POST['post-rss'])) {
            $post_data = array();
            $post_data['name'] = $_POST['post-rss'];
            $post_data['category'] = $_POST['post-category'];
            $add_feed = $Blog->saveRSS($post_data);
            if ($add_feed == true) {
                echo '<div class="updated">' . i18n_r(BLOGFILE . '/FEED_ADDED') . '</div>';
            } else {
                echo '<div class="error">' . i18n_r(BLOGFILE . '/FEED_ERROR') . '</div>';
            }
        } elseif (isset($_GET['delete_rss'])) {
            $delete_feed = $Blog->deleteRSS($_GET['delete_rss']);
            if ($delete_feed == true) {
                echo '<div class="updated">' . i18n_r(BLOGFILE . '/FEED_DELETED') . '</div>';
            } else {
                echo '<div class="error">' . i18n_r(BLOGFILE . '/FEED_DELETE_ERROR') . '</div>';
            }
        }
        #edit_rss
        $rss_file = getXML(BLOGRSSFILE);
        require_once 'html/feed-management.php';
    } elseif (isset($_GET['settings']) && $blogUserPermissions['blogsettings'] == true) {
        show_settings_admin();
    } elseif (isset($_GET['update']) && $blogUserPermissions['blogsettings'] == true) {
        show_update_admin();
    } elseif (isset($_GET['help']) && $blogUserPermissions['bloghelp'] == true) {
        require_once 'html/help-admin.php';
    } elseif (isset($_GET['custom_fields']) && $blogUserPermissions['blogcustomfields'] == true) {
        $CustomFields = new customFields();
        if (isset($_POST['save_custom_fields'])) {
            $saveCustomFields = $CustomFields->saveCustomFields();
            if ($saveCustomFields) {
                echo '<div class="updated">' . i18n_r(BLOGFILE . '/EDIT_OK') . '</div>';
            }
        }
        show_custom_fields();
    } else {
        if (isset($_GET['save_post'])) {
            savePost();
        } elseif (isset($_GET['delete_post']) && $blogUserPermissions['blogdeletepost'] == true) {
            $post_id = urldecode($_GET['delete_post']);
            $delete_post = $Blog->deletePost($post_id);
            if ($delete_post == true) {
                echo '<div class="updated">' . i18n_r(BLOGFILE . '/POST_DELETED') . '</div>';
            } else {
                echo '<div class="error">' . i18n(BLOGFILE . '/FEED_DELETE_ERROR') . '</div>';
            }
        }
        #show_posts_admin
        $all_posts = $Blog->listPosts(true, true);
        // Get a list of all the posts in the blog
        require_once 'html/posts-admin.php';
        // Bring in the HTML to show this section
    }
}
Exemple #2
0
/** 
* Handles conditionals for admin functions
* 
* @return void
*/
function blog_admin_controller()
{
    $Blog = new Blog();
    getBlogUserPermissions();
    global $blogUserPermissions;
    showAdminNav();
    if (isset($_GET['edit_post']) && $blogUserPermissions['blogeditpost'] == true) {
        editPost($_GET['edit_post']);
    } elseif (isset($_GET['create_post']) && $blogUserPermissions['blogcreatepost'] == true) {
        editPost();
    } elseif (isset($_GET['categories']) && $blogUserPermissions['blogcategories'] == true) {
        if (isset($_GET['edit_category'])) {
            $add_category = $Blog->saveCategory($_POST['new_category']);
            if ($add_category == true) {
                echo '<div class="updated">';
                i18n(BLOGFILE . '/CATEGORY_ADDED');
                echo '</div>';
            } else {
                echo '<div class="error">';
                i18n(BLOGFILE . '/CATEGORY_ERROR');
                echo '</div>';
            }
        }
        if (isset($_GET['delete_category'])) {
            $Blog->deleteCategory($_GET['delete_category']);
        }
        edit_categories();
    } elseif (isset($_GET['auto_importer']) && $blogUserPermissions['blogrssimporter'] == true) {
        if (isset($_POST['post-rss'])) {
            $post_data = array();
            $post_data['name'] = $_POST['post-rss'];
            $post_data['category'] = $_POST['post-category'];
            $add_feed = $Blog->saveRSS($post_data);
            if ($add_feed == true) {
                echo '<div class="updated">';
                i18n(BLOGFILE . '/FEED_ADDED');
                echo '</div>';
            } else {
                echo '<div class="error">';
                i18n(BLOGFILE . '/FEED_ERROR');
                echo '</div>';
            }
        } elseif (isset($_GET['delete_rss'])) {
            $delete_feed = $Blog->deleteRSS($_GET['delete_rss']);
            if ($delete_feed == true) {
                echo '<div class="updated">';
                i18n(BLOGFILE . '/FEED_DELETED');
                echo '</div>';
            } else {
                echo '<div class="error">';
                i18n(BLOGFILE . '/FEED_DELETE_ERROR');
                echo '</div>';
            }
        }
        edit_rss();
    } elseif (isset($_GET['settings']) && $blogUserPermissions['blogsettings'] == true) {
        show_settings_admin();
    } elseif (isset($_GET['help']) && $blogUserPermissions['bloghelp'] == true) {
        show_help_admin();
    } elseif (isset($_GET['custom_fields']) && $blogUserPermissions['blogcustomfields'] == true) {
        $CustomFields = new customFields();
        if (isset($_POST['save_custom_fields'])) {
            $saveCustomFields = $CustomFields->saveCustomFields();
            if ($saveCustomFields) {
                echo '<div class="updated">' . i18n_r(BLOGFILE . '/EDIT_OK') . '</div>';
            }
        }
        show_custom_fields();
    } else {
        if (isset($_GET['save_post'])) {
            savePost();
        } elseif (isset($_GET['delete_post']) && $blogUserPermissions['blogdeletepost'] == true) {
            $post_id = urldecode($_GET['delete_post']);
            $delete_post = $Blog->deletePost($post_id);
            if ($delete_post == true) {
                echo '<div class="updated">';
                i18n(BLOGFILE . '/POST_DELETED');
                echo '</div>';
            } else {
                echo '<div class="error">';
                i18n(BLOGFILE . '/FEED_DELETE_ERROR');
                echo '</div>';
            }
        }
        show_posts_admin();
    }
}