source: subversion/branches/devel-vnext/plugins/macbay_filter/form.php @ 647

Last change on this file since 647 was 647, checked in by till, 6 years ago

# bugfixes in macbay_filter

  • started on macbay_pop3
  • Property svn:executable set to *
File size: 4.4 KB
Line 
1<?php
2/**
3 * @author Till Klampaeckel <till@php.net>
4 * @link   http://www.stalker.com/CommuniGatePro/QueueRules.html
5 */
6
7/**
8 * Include this plugin's bootstrap for all necessary goodness.
9 * @ignore
10 */
11require_once dirname(__FILE__) . '/bootstrap.php';
12
13/**
14 * handle $_plugin_action calls
15 * @ignore
16 */
17if ($_SERVER['REQUEST_METHOD'] == 'POST') {
18    require dirname(__FILE__) . '/bin/plugin_action.php';
19}
20require dirname(__FILE__) . '/bin/get.php';
21
22//echo '<pre>'; var_dump($mb_rules); echo '</pre>'; exit;
23
24$registry = rc_registry::getInstance();
25$OUTPUT   = $registry->get('OUTPUT', 'core');
26?>
27<?php echo $OUTPUT->parse('header_small', false); ?>
28<!-- #content needed to make CSS work - we override inline -->
29<div id="content" style="width:780px !important;">
30    <form id="currentRules" method="post" action="<?php echo $RC_URI; ?>?_task=plugin&_action=macbay_filter/form.php" style="margin:0 0 0 0 !important;width:760px;">
31        <fieldset>
32                <h2>Filter</h2>
33                <?php
34                if (count($mb_rules) > 0):
35                foreach($mb_rules AS $mb_rule):
36                   $_mb_filter_name = $mb_rule[1];
37                   $_mb_filter_prio = $mb_rule[0];
38                   include dirname(__FILE__) . '/filter.php';
39
40                   /**
41                    * garbage collection
42                    */
43                   unset($_mb_filter_name);
44                       unset($_mb_filter_prio);
45                       unset($mb_rule);
46                   endforeach;
47                else:
48                echo 'Sie haben noch keine Regeln angelegt.';
49                endif;
50                ?>
51        </fieldset>
52        <input type="hidden" name="_plugin_action" value="save" />
53    </form>
54    <?php if (count($mb_rules) > 0): ?>
55    <div id="saveBtn">
56                <div class="btn btn-active-big">
57                        <p><span id="saveButton">&Auml;nderungen speichern</span></p>
58                </div>
59        </div>
60        <br clear="left" />
61        <?php endif; ?>
62        <br clear="left" />
63        <span onclick="slideInOrOut($(this));" class="ajaxfakelink" style="padding-bottom:15px;">Neuen Regelsatz anlegen.</span>
64        <div id="newFormWrapper" style="padding-top:20px;">
65        <form action="<?php echo $RC_URI; ?>?_task=plugin&_action=macbay_filter/form.php" id="newRule" method="post" style="margin:none;width:760px;">
66            <?php require dirname(__FILE__) . '/filter_neu.php'; ?>
67            <input type="hidden" name="_plugin_action" value="add" />
68        </form>
69    </div>
70</div>
71<script type="text/javascript">
72/* <![CDATA[ */
73$(document).ready(function(){
74   $('#saveButton').bind('click', function(){ $('#currentRules').submit(); });
75   $('#newFormWrapper').hide();
76   $('#saveNewButton').bind('click', function(){ $('#newRule').submit(); });
77});
78
79/**
80 * @global mb_modes
81 */
82var mb_modes = new Array();
83<?php
84foreach($mb_data['modes'] AS $cat=>$modes):
85    $c = 0;
86    echo "mb_modes['$cat'] = new Array;\n";
87    foreach ($modes AS $r=>$hr):
88        echo "mb_modes['$cat'][$c] = new Object;\n";
89        echo "mb_modes['$cat'][$c].r = '$r';\n";
90        echo "mb_modes['$cat'][$c].hr = '$hr';\n";
91        $c++;
92    endforeach;
93endforeach;
94?>
95
96function slideInOrOut(obj)
97{
98    var text = $(obj).text();
99    if (text == 'Neuen Regelsatz anlegen.') {
100        $('#newFormWrapper').slideDown('slow');
101        $(obj).text('Nein, doch nicht.');
102        return;
103    }
104    $('#newFormWrapper').slideUp('slow');
105    $(obj).text('Neuen Regelsatz anlegen.');
106    return;
107}
108
109/**
110 * local functions, because we need the URI in them.
111 */
112function addRow(filterId, ruleType)
113{
114    var wrapper = new String(ruleType + '_' + filterId + '_add');
115    $.post(
116        '<?php echo $RC_URI; ?>?_task=plugin&_action=macbay_filter/ajax/new_' + ruleType + '.php',
117        {id: wrapper},
118        function(data) {
119            $(document.getElementById(wrapper)).append(data);
120            return;
121        }
122    );
123}
124function deleteFilter(filterName, formId)
125{
126    var status = confirm('Wollen Sie den Regelsatz "' + filterName + '" wirklich entfernen?');
127    if (status != true) {
128        return;
129    }
130    $.post(
131        '<?php echo $registry->get('RC_URI', 'core'); ?>?_task=plugin&_action=macbay_filter/delete.php',
132        {filterName: filterName },
133        function(data) {
134            if (data == 'ok') {
135                $('#' + formId).slideUp('slow').ready(function(){
136                    $('#' + formId).remove();
137                });
138                return;
139            }
140            alert('Der Regelsatz konnte nicht entfernt werden.');
141            return;
142        }
143    )
144}
145/* ]]> */
146</script>
147</body>
148</html>
Note: See TracBrowser for help on using the repository browser.