phpMyFAQ /phpmyfaq/admin/record.questions.php

Language PHP Lines 146
MD5 Hash 9ec6194199539d7a6a47dd82c9c97701
Repository https://github.com/cyrke/phpMyFAQ.git View Raw File
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
/**
 * Delete open questions
 *
 * PHP Version 5.3
 *
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
 * obtain one at http://mozilla.org/MPL/2.0/.
 *
 * @category  phpMyFAQ
 * @package   Administration
 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
 * @copyright 2003-2012 phpMyFAQ Team
 * @license   http://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
 * @link      http://www.phpmyfaq.de
 * @since     2003-02-24
 */

if (!defined('IS_VALID_PHPMYFAQ')) {
    header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']));
    exit();
}

printf("<header><h2>%s</h2></header>", $PMF_LANG['msgOpenQuestions']);

if ($permission['delquestion']) {

    $category = new PMF_Category($faqConfig, false);
    $category->setUser($currentAdminUser);
    $category->setGroups($currentAdminGroups);
    $date       = new PMF_Date($faqConfig);
    $questionId = PMF_Filter::filterInput(INPUT_GET, 'id', FILTER_VALIDATE_INT);
    
    $toggle = PMF_Filter::filterInput(INPUT_GET, 'is_visible', FILTER_SANITIZE_STRING);
    if ($toggle == 'toggle') {
        $is_visible = $faq->getVisibilityOfQuestion($questionId);
        if (!is_null($is_visible)) {
            $faq->setVisibilityOfQuestion($questionId, ($is_visible == 'N' ? 'Y' : 'N'));
        }
    }

    print '<div id="returnMessage"></div>';

    $openquestions = $faq->getAllOpenQuestions();

    if (count($openquestions) > 0) {
?>
    <form id="questionSelection" name="questionSelection" method="post">
    <table class="table table-striped">
    <thead>
        <tr>
            <th></th>
            <th><?php print $PMF_LANG['ad_entry_author']; ?></th>
            <th><?php print $PMF_LANG['ad_entry_theme']; ?></th>
            <th colspan="2"><?php print $PMF_LANG['ad_entry_visibility']; ?>?</th>
        </tr>
    </thead>
    <tbody>
<?php
        foreach ($openquestions as $question) {
?>
        <tr>
            <td>
                <input id="questions[]"
                       name="questions[]"
                       value="<?php print $question['id']; ?>" type="checkbox" />
            </td>
            <td>
                <?php print $date->format(PMF_Date::createIsoDate($question['created'])); ?>
                <br />
                <a href="mailto:<?php print $question['email']; ?>">
                    <?php print $question['username']; ?>
                </a>
            </td>
            <td>
                <strong><?php print $category->categoryName[$question['category_id']]['name'] ?></strong>
                <br />
                <?php print $question['question'] ?>
            </td>
            <td>
                <a href="?action=question&amp;id=<?php print $question['id']; ?>&amp;is_visible=toggle"
                   class="btn btn-info">
                    <?php print ('Y' == $question['is_visible']) ? $PMF_LANG['ad_gen_no'] : $PMF_LANG['ad_gen_yes']; ?>
                </a>
            </td>
            <td>
                <?php if ($faqConfig->get('records.enableCloseQuestion') && $question['answer_id']) { ?>
                <a href="?action=editentry&amp;id=<?php print $question['answer_id']; ?>&amp;lang=<?php print $LANGCODE; ?>"
                   class="btn btn-success">
                    <?php print $PMF_LANG['msg2answerFAQ']; ?>
                </a>
                <?php } else { ?>
                <a href="?action=takequestion&amp;id=<?php print $question['id']; ?>" class="btn btn-success">
                    <?php print $PMF_LANG['ad_ques_take']; ?>
                </a>
                <?php } ?>

            </td>
        </tr>
<?php
        }
?>
    </tbody>
    </table>
    </form>

    <p>
        <button class="btn btn-danger" id="submitDeleteQuestions" type="submit">
            <?php print $PMF_LANG["ad_entry_delete"]; ?>
        </button>
    </p>

    <script type="text/javascript">
        /* <![CDATA[ */
        $('#submitDeleteQuestions').click(function() { deleteQuestions(); return false; });

        function deleteQuestions()
        {
            var questions = $('#questionSelection').serialize();

            $('#returnMessage').empty();
            $.ajax({
                type: 'POST',
                url:  'index.php?action=ajax&ajax=records&ajaxaction=delete_question',
                data: questions,
                success: function(msg) {
                    $('#saving_data_indicator').html('<img src="images/indicator.gif" /> deleting ...');
                    $('tr td input:checked').parent().parent().fadeOut('slow');
                    $('#saving_data_indicator').fadeOut('slow');
                    $('#returnMessage').
                            html('<p class="alert alert-success">' + msg + '</p>');
                }
            });
            return false;
        }

        /* ]]> */
    </script>
<?php
    } else {
        print $PMF_LANG['msgNoQuestionsAvailable'];
    }
} else {
    print $PMF_LANG['err_NotAuth'];
}
Back to Top