Habari\AdminPostsHandler::get_publish PHP Метод

get_publish() публичный Метод

Handles GET requests of the publish page.
public get_publish ( $template = 'publish' )
    public function get_publish($template = 'publish')
    {
        $extract = $this->handler_vars->filter_keys('id', 'content_type_name');
        foreach ($extract as $key => $value) {
            ${$key} = $value;
        }
        $content_type = Post::type($content_type_name);
        // 0 is what's assigned to new posts
        if (isset($id) && $id != 0) {
            $post = Post::get(array('id' => $id, 'status' => Post::status('any')));
            Plugins::act('admin_publish_post', $post);
            if (!$post) {
                Session::error(_t("You don't have permission to edit that post"));
                $this->get_blank();
            }
            if (!ACL::access_check($post->get_access(), 'edit')) {
                Session::error(_t("You don't have permission to edit that post"));
                $this->get_blank();
            }
            $this->theme->post = $post;
        } else {
            $post = new Post();
            Plugins::act('admin_publish_post', $post);
            $this->theme->post = $post;
            $post->content_type = Post::type(isset($content_type) ? $content_type : 'entry');
            // check the user can create new posts of the set type.
            $user = User::identify();
            $type = 'post_' . Post::type_name($post->content_type);
            if (ACL::user_cannot($user, $type) || !ACL::user_can($user, 'post_any', 'create') && !ACL::user_can($user, $type, 'create')) {
                Session::error(_t('Access to create posts of type %s is denied', array(Post::type_name($post->content_type))));
                $this->get_blank();
            }
        }
        $this->theme->admin_page = _t('Publish %s', array(Plugins::filter('post_type_display', Post::type_name($post->content_type), 'singular')));
        $this->theme->admin_title = _t('Publish %s', array(Plugins::filter('post_type_display', Post::type_name($post->content_type), 'singular')));
        $statuses = Post::list_post_statuses(false);
        $this->theme->statuses = $statuses;
        $form = $post->get_form('admin');
        $this->theme->form = $form;
        $this->theme->wsse = Utils::WSSE();
        $this->display($template);
    }