source: extensions/Piwecard/admin/admin_manage.php @ 20010

Last change on this file since 20010 was 20010, checked in by julien1311, 11 years ago

[piwecard] lots of improvements

  • Property svn:eol-style set to native
File size: 3.5 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4global $template, $page;
5 
6$piwecard = get_plugin_data($plugin_id);
7
8$template->set_filenames(array(
9        'plugin_admin_content'  => ECARD_ROOT.'/admin/template/admin_manage.tpl',
10        'double_select'                 => 'double_select.tpl'
11));
12
13// Switch on right side (=>)   
14if (isset($_POST['falsify']) and isset($_POST['cat_true']) and count($_POST['cat_true']) > 0) {
15        foreach ($_POST['cat_true'] as $cat)
16                unset($piwecard->my_config['selected_cats'][array_search($cat, $piwecard->my_config['selected_cats'])]);
17        $piwecard->save_config();
18}
19
20// Switch on left side (<=)
21if (isset($_POST['trueify']) and isset($_POST['cat_false']) and count($_POST['cat_false']) > 0) {
22        $query = 'SELECT id, name, uppercats, global_rank FROM '.CATEGORIES_TABLE.' WHERE id IN ("'.implode('","', $_POST['cat_false']).'");';
23        $result = pwg_query($query);
24
25        if (!empty($result)) {
26                while ($cat = pwg_db_fetch_assoc($result))
27                        array_push($piwecard->my_config['selected_cats'], $cat['id']);                 
28        }
29        usort($piwecard->my_config['selected_cats'], 'global_rank_compare');
30
31        $piwecard->save_config();
32}
33
34if (isset($_POST['submit'])) { 
35        $piwecard->my_config['authorizations'] = $_POST['ecard_authorizations'];
36        if (isset($_POST['ecard_selected_cats_recursive']) AND $_POST['ecard_selected_cats_recursive'] == '1')
37                $piwecard->my_config['recursive'] = true;
38        else
39                $piwecard->my_config['recursive'] = false;
40        $piwecard->save_config();
41        array_push($page['infos'], l10n('ecard_admin_saveOK'));
42}
43
44//Populate double_select
45$query = 'SELECT id, name, uppercats, global_rank FROM '.CATEGORIES_TABLE.' WHERE id not IN ("'.implode('","', $piwecard->my_config['selected_cats']).'");';
46$result = pwg_query($query);
47$categories = array();
48if (!empty($result)) {
49        while ($row = pwg_db_fetch_assoc($result))
50                array_push($categories, $row);
51}
52usort($categories, 'global_rank_compare');
53
54$tpl = array();
55if (!empty($result)) {
56        foreach ($categories as $cat) {
57        $tpl[$cat['id']] = get_cat_display_name_cache($cat['uppercats'], null, false);
58        }
59}
60$template->assign('category_option_false', $tpl);
61$template->assign('category_option_false_selected', array());
62
63$query = 'SELECT id, name, uppercats, global_rank FROM '.CATEGORIES_TABLE.' WHERE id IN ("'.implode('","', $piwecard->my_config['selected_cats']).'");';
64$result = pwg_query($query);
65$categories = array();
66if (!empty($result)) {
67        while ($row = pwg_db_fetch_assoc($result))
68                array_push($categories, $row);
69}
70usort($categories, 'global_rank_compare');
71
72$tpl2 = array();
73if (!empty($result)) {
74        foreach ($categories as $cat) {
75        $tpl2[$cat['id']] = get_cat_display_name_cache($cat['uppercats'], null, false);
76        }
77}
78$template->assign('category_option_true', $tpl2);
79$template->assign('category_option_true_selected', array());
80
81$template->assign('ecard', array(
82                                                                'all_cats_checked' => (($piwecard->my_config['authorizations'] == 'all_cats') ? 'checked="checked"' : ''),
83                                                                'selected_cats_checked' => (($piwecard->my_config['authorizations'] == 'selected_cats') ? 'checked="checked"' : ''),
84                                                                'selected_cats_recursive_checked' => (($piwecard->my_config['recursive']) ? 'checked="checked"' : ''),
85                                                                'user_cats_checked' => (($piwecard->my_config['authorizations'] == 'user_cats') ? 'checked="checked"' : ''),
86                                                        )
87);
88
89$template->assign(array(
90                                                'F_ACTION' => '',
91                                                'L_CAT_OPTIONS_TRUE' => l10n('selected_cats'),
92                                                'L_CAT_OPTIONS_FALSE' => l10n('non_selected_cats'),
93                                        )
94);
95
96$template->assign_var_from_handle('DOUBLE_SELECT', 'double_select');
97$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
98?>
Note: See TracBrowser for help on using the repository browser.