Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It should be possible to remove the note ‘Install sample data’ even without installed sample data #9770

Open
rich20 opened this issue Nov 21, 2024 · 6 comments
Milestone

Comments

@rich20
Copy link
Member

rich20 commented Nov 21, 2024

Describe the bug
#9724
Confirmed

With this fix #9724 it is now possible to run Kunena without sample data, as both smileys and ranking images are entered into the database during a new installation.
The problem, however, is that the ‘Install SampleData’ alert in the dashboard only disappears if the value sampleData = 1 is entered in the database table #__kunena_version. Therefore, you are still forced to either install the sample data or manipulate this value in the database.
An additional option should therefore be provided, e.g.

Install sample data?
Yes (recommended for beginners)
No

Additional context
Both options, Yes as well No, should make this hint disappear.

@rich20 rich20 added this to the 6.3 milestone Nov 21, 2024
Copy link

This issue is stale because it has been open 30 days with no activity.

@Pinkeltje
Copy link
Contributor

Is it an option to remove the entire block from dashboard and change documentation? Install Kunena Sample Data from Joomla dashboard as it is present there as well?
2024-12-26 Screenshot 729

@xillibit
Copy link
Member

The block like you show it on Joomla! dashboard is installed by the Kunena quick icon module. There are two places on Kunena dashboard and Joomla! dashboard where the install sample data is displayed

@Pinkeltje
Copy link
Contributor

Pinkeltje commented Dec 26, 2024

I know. But my suggestion was to remove it from Kunena dashboard so it only appears in Joomla dashboard. That would in my opinion solve the problem to remove the entire block from cpanel <?php if (!KunenaForum::versionSampleData()) : that would solve the problem

‘Install sample data’ even without installed sample data

without changing the code for this block.
So when users do a fresh Kunena install, they should install sample date from Joomla dashboard. Just a thought.

@Pinkeltje
Copy link
Contributor

Pinkeltje commented Dec 27, 2024

Change code between
<div id="j-main-container" class="col-md-12" role="main">
and
<?php if (!$this->KunenaMenusExists) : ?>
Use same layout and use buttons

  <?php
function setSampleDataFlag($value = 1)
{
    $db = JFactory::getDbo();
    $query = $db->getQuery(true);
    
    $query->update($db->quoteName('#__kunena_version'))
          ->set($db->quoteName('sampleData') . ' = ' . $db->quote($value));
    
    $db->setQuery($query);
    
    try {
        return $db->execute();
    } catch (Exception $e) {
        return false;
    }
}

if (!isset($_POST['sample_data_choice']) && !KunenaForum::versionSampleData()) : ?>
    <div class="row clearfix">
        <div class="col-xl-3 col-md-3">
            <div class="card proj-t-card bg-warning">
                <div class="card-body">
                    <div class="row align-items-center mb-30">
                        <div class="col-auto">
                            <i class="fas fa-database text-white f-30"></i>
                        </div>
                        <div class="col pl-0">
                            <h6 class="mb-0 text-white"><?php echo Text::_('COM_KUNENA_CPANEL_LABEL_INSTALL'); ?></h6>
                            <h6 class="mb-0 text-white"><?php echo Text::_('COM_KUNENA_CPANEL_LABEL_SAMPLE_DATA'); ?></h6>
                        </div>
                    </div>
                    <div>
                        <form method="post" id="sampleDataForm">
                            <ul id="sample-data-wrapper" class="list-group list-group-flush sample-data">
                                <li class="list-group-item sampledata-kunena">
                                    <div class="d-flex flex-column">
                                        <div class="sample-data__title mb-3">
                                            <?php echo Text::_('COM_KUNENA_SAMPLE_DATA_QUESTION'); ?>
                                        </div>
                                        <div class="btn-group justify-content-center">
                                            <button type="submit" name="sample_data_choice" value="yes" class="btn btn-secondary btn-sm mx-1">
                                                <?php echo Text::_('JYES'); ?>
                                            </button>
                                            <button type="submit" name="sample_data_choice" value="no" class="btn btn-secondary btn-sm mx-1">
                                                <?php echo Text::_('JNO'); ?>
                                            </button>
                                        </div>
                                    </div>
                                </li>
                            </ul>
                        </form>
                    </div>
                    <h6 class="pt-badge bg-cyan"><i class="fas fa-exclamation text-white f-18"></i></h6>
                </div>
            </div>
        </div>
    </div>
<?php else :
    if (isset($_POST['sample_data_choice']) && $_POST['sample_data_choice'] === 'no') {
        setSampleDataFlag(1);
        echo '<div class="alert alert-success">' . Text::_('COM_KUNENA_SAMPLEDATA_SKIPPED') . '</div>';
    } elseif (isset($_POST['sample_data_choice']) && $_POST['sample_data_choice'] === 'yes') {
        if (!KunenaForum::versionSampleData()) : ?>
            <div class="row clearfix">
                <div class="col-xl-3 col-md-3">
                    <div class="card proj-t-card bg-warning">
                        <div class="card-body">
                            <div class="row align-items-center mb-30">
                                <div class="col-auto">
                                    <i class="fas fa-database text-white f-30"></i>
                                </div>
                                <div class="col pl-0">
                                    <h6 class="mb-0 text-white"><?php echo Text::_('COM_KUNENA_CPANEL_LABEL_INSTALL'); ?></h6>
                                    <h6 class="mb-0 text-white"><?php echo Text::_('COM_KUNENA_CPANEL_LABEL_SAMPLE_DATA'); ?></h6>
                                </div>
                            </div>
                            <div>
                                <ul id="sample-data-wrapper" class="list-group list-group-flush sample-data">
                                    <li class="list-group-item sampledata-kunena">
                                        <div class="d-flex justify-content-between align-items-center">
                                            <div class="sample-data__title me-2">
                                                <span class="sample-data__icon icon-comments me-1" aria-hidden="true"></span>
                                                <?php echo Text::_('COM_KUNENA_CPANEL_LABEL_KUNENA_FORUM_SAMPLE_DATA'); ?>
                                            </div>
                                            <button type="button" 
                                                    class="btn btn-secondary btn-sm apply-sample-data" 
                                                    data-type="kunena" 
                                                    data-steps="1">
                                                <span class="icon-upload" aria-hidden="true"></span> 
                                                <?php echo Text::_('COM_KUNENA_CPANEL_BUTTON_INSTALL'); ?>
                                            </button>
                                        </div>
                                        <p class="sample-data__desc small mt-1">
                                            <?php echo Text::_('COM_KUNENA_CPANEL_LABEL_INSTALL_SAMPLE_DATA') ?>
                                        </p>
                                    </li>
                                    <li class="list-group-item sampledata-progress-kunena d-none">
                                        <div class="progress mb-3">
                                            <div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar"></div>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

          
        <?php endif;
    }
endif; ?>

Language strings for COM_KUNENA_SAMPLEDATA_SKIPPED and COM_KUNENA_SAMPLE_DATA_QUESTION should be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants