source: extensions/adult_content/charte_user.php @ 9568

Last change on this file since 9568 was 9565, checked in by flop25, 13 years ago

the users 16 and 18 can't access to charte_user.php
cleaner way to code

File size: 2.8 KB
Line 
1<?php
2define('PHPWG_ROOT_PATH','../../');
3include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
4$adult_content = get_plugin_data('adult_content');
5if ( is_a_guest() or $user['username'] == '16' or $user['username'] == '18')
6{
7        redirect(make_index_url());
8}
9elseif ( isset($_POST['groupe']) and ( $_POST['groupe'] == '+18' or $_POST['groupe'] == '16-17' or $_POST['groupe'] == 'nothing') )
10{
11////////////anciennement lié à quoi/////       
12                        $adult_content->fill_idgroups_user();
13                        $adult_content->fill_idgroups_ad_c();
14   ////////////placer dans group////////////
15      $query = '
16SELECT id FROM '.GROUPS_TABLE.'
17  WHERE name IN (\''. $_POST['groupe'].'\')
18;';
19      $data_group = mysql_fetch_array(pwg_query($query));
20         
21      if (!$adult_content->is_in_ad_c_group())
22          {
23      pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.$user['id'].'\', \''.$data_group['id'].'\' )' );
24          }
25      else
26          {
27      pwg_query('UPDATE '.USER_GROUP_TABLE.' SET group_id=\''.$data_group['id'].'\' WHERE user_id IN (\''.$user['id'].'\') AND group_id IN (\''.$adult_content->is_in_ad_c_group().'\')' );
28          }
29          $query = '
30DELETE FROM '.USER_CACHE_TABLE.'
31  WHERE user_id = '.$user['id'];
32      pwg_query($query);
33                        log_user( $user['id'], false);
34      redirect(make_index_url());
35}
36elseif (!isset( $_POST['groupe'] ))
37{
38   $title = 'Adult content';
39   $page['body_id'] = 'adult_content_page';
40   include(PHPWG_ROOT_PATH.'include/page_header.php');
41   load_language('plugin.lang', $adult_content->plugin_path);
42
43   $template->assign(
44     array(
45       'PLUGIN_NAME' => $adult_content->plugin_name
46       ));
47////////////lié à quoi/////     
48                        $adult_content->fill_idgroups_user();
49                        $adult_content->fill_idgroups_ad_c();   
50
51        if (!$adult_content->is_in_ad_c_group())
52        {
53                 $template->assign(
54                         array(
55                                 'EXPLIC' => $lang['ac_not_def'],
56                                 'MAIN'  => $lang['ac_text_charte'],
57                                        )
58                         );
59        }
60        elseif ($adult_content->is_in_ad_c_group() )
61        {
62                $link=$adult_content->is_in_ad_c_group();
63                if ($link == $adult_content->idgroups_ad_c[0])
64                {
65                         $statut = $lang['ac_statut'].$lang['ac_user_text_18'];
66                }
67                if ($link ==  $adult_content->idgroups_ad_c[1])
68                {
69                         $statut = $lang['ac_statut'].$lang['ac_user_text_16'];
70                }
71                if ($link ==  $adult_content->idgroups_ad_c[2])
72                {
73                         $statut = $lang['ac_user_no'];
74                }
75         
76     $main = '<p>'.$statut.'</p>'
77                .'<p><a href="javascript:void(0)" OnClick="history.back()" >'.$lang['ac_retour_c'].'</a></p>';
78       $template->assign(
79         array(
80           'EXPLIC' => $lang['ac_def'],
81           'MAIN'  => $main,
82            )
83         );
84   }
85
86   $template->set_filename('charte', $adult_content->plugin_path.'include/charte_user.tpl');
87
88   $template->parse('charte');
89   include(PHPWG_ROOT_PATH.'include/page_tail.php');
90
91}//fin if !isset( $_POST['groupe'] )
92else
93{
94redirect(make_index_url());
95}
96?>
Note: See TracBrowser for help on using the repository browser.