object($page) || $page->isError()) {
            $sp = SinglePage::add('/dashboard/system/registration/notification');
            $sp->update(array('cName' => 'Notification Settings'));
        }

    }

    protected function addBlockTypes()
    {
        $bt = BlockType::getByHandle('express_form');
        if (!is_object($bt)) {
            BlockType::installBlockType('express_form');
        }

        $bt = BlockType::getByHandle('dashboard_site_activity');
        if (is_object($bt)) {
            $bt->delete();
        }

        $bt = BlockType::getByHandle('desktop_site_activity');
        if (!is_object($bt)) {
            BlockType::installBlockType('desktop_site_activity');
        }

        $bt = BlockType::getByHandle('dashboard_app_status');
        if (is_object($bt)) {
            $bt->delete();
        }

        $bt = BlockType::getByHandle('desktop_app_status');
        if (!is_object($bt)) {
            BlockType::installBlockType('desktop_app_status');
        }

        $bt = BlockType::getByHandle('dashboard_featured_theme');
        if (is_object($bt)) {
            $bt->delete();
        }

        $bt = BlockType::getByHandle('desktop_featured_theme');
        if (!is_object($bt)) {
            BlockType::installBlockType('desktop_featured_theme');
        }

        $bt = BlockType::getByHandle('dashboard_featured_addon');
        if (is_object($bt)) {
            $bt->delete();
        }

        $bt = BlockType::getByHandle('desktop_featured_addon');
        if (!is_object($bt)) {
            BlockType::installBlockType('desktop_featured_addon');
        }

        $bt = BlockType::getByHandle('dashboard_newsflow_latest');
        if (is_object($bt)) {
            $bt->delete();
        }

        $bt = BlockType::getByHandle('desktop_newsflow_latest');
        if (!is_object($bt)) {
            BlockType::installBlockType('desktop_newsflow_latest');
        }

        $bt = BlockType::getByHandle('desktop_latest_form');
        if (!is_object($bt)) {
            BlockType::installBlockType('desktop_latest_form');
        }
        $bt = BlockType::getByHandle('desktop_waiting_for_me');
        if (!is_object($bt)) {
            BlockType::installBlockType('desktop_waiting_for_me');
        }

        $bt = BlockType::getByHandle('express_entry_list');
        if (!is_object($bt)) {
            BlockType::installBlockType('express_entry_list');
        }

        $bt = BlockType::getByHandle('express_entry_detail');
        if (!is_object($bt)) {
            BlockType::installBlockType('express_entry_detail');
        }

        $bt = BlockType::getByHandle('desktop_waiting_for_me');
        if (!is_object($bt)) {
            BlockType::installBlockType('desktop_waiting_for_me');
        }

        $bt = BlockType::getByHandle('page_title');
        if (is_object($bt)) {
            $bt->refresh();
        }

        $bt = BlockType::getByHandle('page_list');
        if (is_object($bt)) {
            $bt->refresh();
        }
    }

    protected function addTreeNodeTypes()
    {
        $this->connection->Execute('update TreeNodeTypes set treeNodeTypeHandle =? where treeNodeTypeHandle =?', array(
            'category', 'topic_category',
        ));
        $this->connection->Execute('update PermissionKeys set pkHandle =? where pkHandle =?', array(
            'view_category_tree_node', 'view_topic_category_tree_node',
        ));
        $this->connection->Execute('update PermissionKeyCategories set pkCategoryHandle =? where pkCategoryHandle =?', array(
            'category_tree_node', 'topic_category_tree_node',
        ));
        $results = NodeType::getByHandle('express_entry_results');
        if (!is_object($results)) {
            NodeType::add('express_entry_results');
        }
        $category = NodeType::getByHandle('express_entry_category');
        if (!is_object($category)) {
            NodeType::add('express_entry_category');
        }
        $results = TreeType::getByHandle('express_entry_results');
        if (!is_object($results)) {
            TreeType::add('express_entry_results');
            $tree = ExpressEntryResults::add();
            $node = $tree->getRootTreeNodeObject();
            // Add forms node beneath it.
            \Concrete\Core\Tree\Node\Type\Category::add(ExpressFormBlockController::FORM_RESULTS_CATEGORY_NAME, $node);
        }
    }

    protected function installDesktops()
    {
        $template = Template::getByHandle('desktop');
        if (!is_object($template)) {
            Template::add('desktop', t('Desktop'), FILENAME_PAGE_TEMPLATE_DEFAULT_ICON, null, true);
        }
        $type = \Concrete\Core\Page\Type\Type::getByHandle('core_desktop');
        if (!is_object($type)) {
            \Concrete\Core\Page\Type\Type::add(array(
                'handle' => 'core_desktop',
                'name' => 'Desktop',
                'internal' => true
            ));
        }

        $category = Category::getByHandle('collection')->getController();
        $attribute = CollectionKey::getByHandle('is_desktop');
        if (!is_object($attribute)) {
            $type = new BooleanType();
            $key = new PageKey();
            $key->setAttributeKeyHandle('is_desktop');
            $key->setAttributeKeyName('Is Desktop');
            $key->setIsAttributeKeyInternal(true);
            $category->add($type, $key);
        }
        $attribute = CollectionKey::getByHandle('desktop_priority');
        if (!is_object($attribute)) {
            $type = new NumberType();
            $key = new PageKey();
            $key->setAttributeKeyHandle('desktop_priority');
            $key->setAttributeKeyName('Desktop Priority');
            $key->setIsAttributeKeyInternal(true);
            $category->add($type, $key);
        }

        $desktop = Page::getByPath('/dashboard/welcome');
        if (is_object($desktop) &&!$desktop->isError()) {
            $desktop->moveToTrash();
        }

        $desktop = Page::getByPath('/desktop');
        if (is_object($desktop) &&!$desktop->isError()) {
            $desktop->moveToTrash();
        }

        $page = \Page::getByPath("/account/messages");
        if (is_object($page) &&!$page->isError()) {
            $page->moveToTrash();
        }

        // Private Messages tweak
        SinglePage::add('/account/messages');

        $ci = new ContentImporter();
        $ci->importContentFile(DIR_BASE_CORE. '/config/install/base/desktops.xml');

        $desktop = Page::getByPath('/dashboard/welcome');
        $desktop->movePageDisplayOrderToTop();

        \Config::save('concrete.misc.login_redirect', 'DESKTOP');
    }

    protected function updateWorkflows()
    {
        $page = \Page::getByPath("/dashboard/workflow");
        if (is_object($page) &&!$page->isError()) {
            $page->moveToTrash();
        }
        $page = \Page::getByPath("/dashboard/system/permissions/workflows");
        if (!is_object($page) || $page->isError()) {
            SinglePage::add('/dashboard/system/permissions/workflows');
        }
    }

    protected function installSite()
    {
        /**
         * @var $service Service
         */
        $service = \Core::make('site');
        $site = $service->getDefault();
        $em