Changeset 21047


Ignore:
Timestamp:
Feb 26, 2013, 8:50:03 PM (7 years ago)
Author:
flop25
Message:

-compatibility 2.5 (only)
-changing config variables (assoc array)
-adding a pwg stuffs block

ToDo: enable the option for the block

Location:
extensions/adult_content
Files:
5 added
7 edited

Legend:

Unmodified
Added
Removed
  • extensions/adult_content/admin/admin.php

    r12646 r21047  
    77global $prefixeTable;
    88load_language('plugin.lang', $ad_c->plugin_path);
    9 $conf_ad_c = explode("," , $conf['ad_c_plugin']);
     9$conf_ad_c = unserialize($conf['ad_c_plugin']);
    1010
    1111
     
    1414if (isset($_POST['option_ad_c']))
    1515{
    16         $newconf_plugin = (isset($_POST['menublock_for_guest'])) ? 'true' : 'false';
    17         $newconf_plugin .= (isset($_POST['block_on_index'])) ? ',true' : ',false';
    18         $newconf_plugin .= (isset($_POST['manage_what'])) ? ','.$_POST['manage_what'] : ',both';
    19         //$newconf_plugin = implode ("," , $newconf_plugin);
     16  $newconf_plugin=array();
     17        $newconf_plugin['menublock_for_guest'] = (isset($_POST['menublock_for_guest'])) ? true : false;
     18        $newconf_plugin['block_on_index'] = (isset($_POST['block_on_index'])) ? true : false;
     19        $newconf_plugin['manage_what'] = (isset($_POST['manage_what'])) ? $_POST['manage_what'] : 'both';
    2020        $query = '
    2121                UPDATE '.CONFIG_TABLE.'
    22                 SET value="'.$newconf_plugin.'"
     22                SET value="'.pwg_db_real_escape_string(serialize($newconf_plugin)).'"
    2323                WHERE param="ad_c_plugin"
    2424                LIMIT 1';
     
    2626                               
    2727        array_push($page['infos'], l10n('ad_c_msg_admin_1'));
     28  load_conf_from_db();
     29  $conf_ad_c = unserialize($conf['ad_c_plugin']);
    2830}
    2931
    30 load_conf_from_db();
    31 $conf_ad_c = explode("," , $conf['ad_c_plugin']);
    3232
    3333$check='checked="checked"';
    34 if ($conf_ad_c[0]=='true') { $menublock=$check; } else { $menublock=NULL; }
    35 if ($conf_ad_c[1]=='true') { $index=$check; } else { $index=NULL; }
     34if ($conf_ad_c['menublock_for_guest']=='true') { $menublock=$check; } else { $menublock=NULL; }
     35if ($conf_ad_c['block_on_index']=='true') { $index=$check; } else { $index=NULL; }
    3636$disabled='disabled="disabled"';
    3737        $template->assign(
    3838                array(
    39                   'AD_C_manage_what' => $conf_ad_c[2],
     39                  'AD_C_manage_what' => $conf_ad_c['manage_what'],
    4040                  'AD_C_menublock_for_guest' => $menublock,
    4141                  'AD_C_block_on_index' => $index,
  • extensions/adult_content/charte.php

    r12646 r21047  
    22define('PHPWG_ROOT_PATH','../../');
    33include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
    4 $conf_ad_c = explode("," , $conf['ad_c_plugin']);
    5 if ( !is_a_guest() or $conf_ad_c[0]!='true')
     4$conf_ad_c = unserialize($conf['ad_c_plugin']);
     5if ( !is_a_guest() or $conf_ad_c['menublock_for_guest']!='true')
    66{
    77        redirect(make_index_url());
     
    2323  array(
    2424    'PLUGIN_NAME' => $adult_content->plugin_name,
    25     'AD_C_manage_what' => $conf_ad_c[2],
     25    'AD_C_manage_what' => $conf_ad_c['manage_what'],
    2626    ));
    2727$template->set_filename('controller', $adult_content->plugin_path.'include/charte.tpl');
  • extensions/adult_content/charte_user.php

    r12646 r21047  
    22define('PHPWG_ROOT_PATH','../../');
    33include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
    4 $conf_ad_c = explode("," , $conf['ad_c_plugin']);
     4$conf_ad_c = unserialize($conf['ad_c_plugin']);
    55$adult_content = get_plugin_data('adult_content');
    66if ( is_a_guest() or $user['username'] == '16' or $user['username'] == '18')
     
    1818  WHERE name IN (\''. $_POST['groupe'].'\')
    1919;';
    20       $data_group = mysql_fetch_array(pwg_query($query));
     20      $data_group = pwg_db_fetch_array(pwg_query($query));
    2121         
    2222      if (!$adult_content->is_in_ad_c_group())
     
    8686    $template->assign(
    8787    array(
    88       'AD_C_manage_what' => $conf_ad_c[2],
     88      'AD_C_manage_what' => $conf_ad_c['manage_what'],
    8989    )
    9090    );
  • extensions/adult_content/class.inc.php

    r12082 r21047  
    1919    $query = 'SELECT group_id FROM ' . USER_GROUP_TABLE . ' WHERE user_id = ' . $user['id'] . ';';
    2020    $result = pwg_query($query);
    21     while ($row = mysql_fetch_assoc($result))
     21    while ($row = pwg_db_fetch_assoc($result))
    2222    {
    2323      array_push($this->idgroups_user, $row['group_id']);
     
    3030    $query = 'SELECT id FROM ' . GROUPS_TABLE . ' WHERE name IN (\'+18\', \'16-17\', \'nothing\') ORDER BY id';
    3131    $result = pwg_query($query);
    32     while ($row = mysql_fetch_assoc($result))
     32    while ($row = pwg_db_fetch_assoc($result))
    3333    {
    3434      array_push($this->idgroups_ad_c, $row['id']);
     
    131131  WHERE name IN (\'+18\')
    132132;';
    133      $data_18 = mysql_fetch_array(pwg_query($query));
     133     $data_18 = pwg_db_fetch_array(pwg_query($query));
    134134         $query = '
    135135SELECT id FROM '.GROUPS_TABLE.'
    136136  WHERE name IN (\'16-17\')
    137137;';
    138      $data_16 = mysql_fetch_array(pwg_query($query));
     138     $data_16 = pwg_db_fetch_array(pwg_query($query));
    139139         $query = '
    140140SELECT id FROM '.GROUPS_TABLE.'
    141141  WHERE name IN (\'nothing\')
    142142;';
    143      $data_no = mysql_fetch_array(pwg_query($query));
     143     $data_no = pwg_db_fetch_array(pwg_query($query));
    144144         $n_query = '
    145145SELECT COUNT(*) AS result FROM '.USER_GROUP_TABLE.'
    146146  WHERE group_id IN (\''.$data_18['id'].'\',\''.$data_16['id'].'\',\''.$data_no['id'].'\') AND user_id IN (\''.$user['id'].'\')
    147147;';
    148       $data_user = mysql_fetch_array(pwg_query($n_query));
     148      $data_user = pwg_db_fetch_array(pwg_query($n_query));
    149149          $is_grouped = $data_user['result'];   
    150150         
     
    164164    global $user, $conf, $page, $template;
    165165    $menu = & $menu_ref_arr[0];
    166                 $conf_plugin = explode("," , $conf['ad_c_plugin']);
     166                $conf_plugin = unserialize($conf['ad_c_plugin']);
    167167                $template->assign(
    168168                        array(
     
    172172
    173173    //include($this->var_template());
    174     if (is_a_guest() and $conf_plugin[0]=='true')
     174    if (is_a_guest() and $conf_plugin['menublock_for_guest']=='true')
    175175        {
    176176       
     
    217217///////////////////////[FIN fermer/ouvert]////////////////////
    218218    }//fin if guest
    219     elseif (is_a_guest() and $conf_plugin[0]!='true')
     219    elseif (is_a_guest() and $conf_plugin['menublock_for_guest']!='true')
    220220    { 
    221221                  $menu->hide_block('mbAdultContent');
     
    317317      redirect(PHPWG_ROOT_PATH.'plugins/adult_content/charte_user.php');
    318318                }
    319   }
     319  }
     320  function ac_stuffs_module($modules)
     321  {
     322    load_language('plugin.lang', $this->plugin_path);
     323    array_push($modules, array(
     324      'path' => PHPWG_PLUGINS_PATH . AC_NAME . '/stuffs_module/',
     325      'name' => l10n('ac_text'),
     326      'description' => l10n('ac_stuffs_description'),
     327      )
     328    );
     329    return $modules;
     330  }
     331
    320332}//fin class
    321333?>
  • extensions/adult_content/language/fr_FR/plugin.lang.php

    r18151 r21047  
    8383';
    8484$lang['ad_c_linktolang']="Lien vers le fichier langue d'Adult Content (Nécessite localFiles Editor)";
     85
     86$lang['ac_stuffs_description']="Charte pour le visiteur et choix de son âge"
    8587?>
  • extensions/adult_content/main.inc.php

    r10855 r21047  
    3535add_event_handler('loc_begin_index', array(&$adult_content, 'set_block_on_index'));
    3636*/
     37add_event_handler('get_stuffs_modules', array(&$adult_content, 'ac_stuffs_module'));
     38
    3739
    3840add_event_handler('loc_end_picture', 'comment_manage');
  • extensions/adult_content/maintain.inc.php

    r12622 r21047  
    33function plugin_install()
    44{
    5     global $conf;
     5  global $conf;
    66
    77////////////créer groupe////////////
    8     $query = '
     8  $query = '
    99INSERT INTO '.GROUPS_TABLE.'
    1010  (name)
     
    1212  (\'+18\')
    1313;';
    14     pwg_query($query);
    15     $query = '
     14  pwg_query($query);
     15  $query = '
    1616INSERT INTO '.GROUPS_TABLE.'
    1717  (name)
     
    1919  (\'16-17\')
    2020;';
    21     pwg_query($query);
    22     $query = '
     21  pwg_query($query);
     22  $query = '
    2323INSERT INTO '.GROUPS_TABLE.'
    2424  (name)
     
    2626  (\'nothing\')
    2727;';
    28     pwg_query($query);
     28  pwg_query($query);
    2929////////////créer user////////////
    3030        include_once(PHPWG_ROOT_PATH.'include/functions_user.inc.php');
     
    3434////////////placer dans group 16////////////
    3535    $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'16-17\') ;');
    36     $data_group = mysql_fetch_array($result);
     36    $data_group = pwg_db_fetch_array($result);
    3737          pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('16').'\', \''.$data_group['id'].'\' )' );
    3838
    3939////////////placer dans group 18////////////
    4040  $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'+18\') ;');
    41   $data_group = mysql_fetch_array($result);
     41  $data_group = pwg_db_fetch_array($result);
    4242          pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('18').'\', \''.$data_group['id'].'\' )' );
    4343
     44////////////placer dans group nothing////////////
     45  $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'nothing\') ;');
     46  $data_group = pwg_db_fetch_array($result);
     47          pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.$conf['guest_id'].'\', \''.$data_group['id'].'\' )' );
     48
    4449/////////////Config plugin
     50    $config_start=array('menublock_for_guest'=>true,'block_on_index'=>false,'manage_what'=>'both');
    4551    $q = '
    4652INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
    4753        VALUES
    48         ("ad_c_plugin" , "true,false,both" , "Plugin adult_content : menublock_for_guest, block_on_index, manage_what");';
     54        ("ad_c_plugin" , "'.pwg_db_real_escape_string(serialize($config_start)).'" , "Plugin adult_content : menublock_for_guest, block_on_index, manage_what");';
    4955    pwg_query($q);
    5056
     
    5561function plugin_activate()
    5662{
    57         ///user exist ?///
     63  global $conf;
     64///user exist ?///
    5865        $query = '
    5966        SELECT COUNT(*) AS result FROM '.USERS_TABLE.'
    6067        WHERE username IN (\'18\')
    6168        ;';
    62         $data_user = mysql_fetch_array(pwg_query($query));
     69        $data_user = pwg_db_fetch_array(pwg_query($query));
    6370        $exist = $data_user['result'];
    6471        if ( $exist == 0 )
     
    7178        WHERE username IN (\'16\')
    7279        ;';
    73         $data_user = mysql_fetch_array(pwg_query($query));
     80        $data_user = pwg_db_fetch_array(pwg_query($query));
    7481        $exist = $data_user['result'];
    7582        if ( $exist == 0 )
     
    7784                register_user('16', 'adult_content', '');
    7885        }
    79         ///group exist ?///
    80         $query = '
    81         SELECT COUNT(*) AS result FROM '.GROUPS_TABLE.'
    82         WHERE name IN (\'+18\')
    83         ;';
    84         $data_user = mysql_fetch_array(pwg_query($query));
    85         $exist = $data_user['result'];
    86         if ( $exist == 0 )
    87         {
    88                 $query = 'INSERT INTO '.GROUPS_TABLE.'
    89                                                         (name)
    90                                                         VALUES
    91                                                         (\'+18\')
    92                                                         ;';
    93                 pwg_query($query);
    94         ////////////placer dans group 18////////////
    95                 $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'+18\') ;');
    96                 $data_group = mysql_fetch_array($result);
    97                 pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('18').'\', \''.$data_group['id'].'\' )' );
    98         }
    99        
    100         $query = '
    101         SELECT COUNT(*) AS result FROM '.GROUPS_TABLE.'
    102         WHERE name IN (\'16-17\')
    103         ;';
    104         $data_user = mysql_fetch_array(pwg_query($query));
    105         $exist = $data_user['result'];
    106         if ( $exist == 0 )
    107         {
    108                 $query = '
    109                 INSERT INTO '.GROUPS_TABLE.'
    110                 (name)
    111                 VALUES
    112                 (\'16-17\')
    113                 ;';
    114                 pwg_query($query);
     86///groups///
     87  $query = 'INSERT IGNORE INTO '.GROUPS_TABLE.' (name) VALUES (\'+18\'),(\'16-17\'),(\'nothing\') ;';
     88        pwg_query($query);
     89////////////placer dans group 18////////////
     90  $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'+18\') ;');
     91  $data_group = pwg_db_fetch_array($result);
     92  pwg_query('INSERT IGNORE INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('18').'\', \''.$data_group['id'].'\' )' );
    11593////////////placer dans group 16////////////
    116                 $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'16-17\') ;');
    117                 $data_group = mysql_fetch_array($result);
    118                 pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('16').'\', \''.$data_group['id'].'\' )' );
    119        
    120         }
    121                 //grp nothing
    122         $query = '
    123         SELECT COUNT(*) AS result FROM '.GROUPS_TABLE.'
    124         WHERE name IN (\'nothing\')
    125         ;';
    126         $data_user = mysql_fetch_array(pwg_query($query));
    127         $exist = $data_user['result'];
    128         if ( $exist == 0 )
    129         {
    130                 $query = '
    131                 INSERT INTO '.GROUPS_TABLE.'
    132                 (name)
    133                 VALUES
    134                 (\'nothing\')
    135                 ;';
    136                 pwg_query($query);
    137         }
    138        
    139         ///assoc user/group exist ?///
    140        
    141         $n_query = '
    142         SELECT id FROM '.GROUPS_TABLE.'
    143         WHERE name IN (\'16-17\')
    144         ;';
    145         $data_group = mysql_fetch_array(pwg_query($n_query));
    146         $query = '
    147         SELECT COUNT(*) AS result FROM '.USER_GROUP_TABLE.'
    148         WHERE group_id IN (\''.$data_group['id'].'\') AND user_id IN (\''.get_userid('16').'\')
    149         ;';
    150         $data_user_group = mysql_fetch_array(pwg_query($query));
    151         $exist = $data_user_group['result'];
    152         if ( $exist == 0 )
    153         {
    154                 pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('16').'\', \''.$data_group['id'].'\' )' );
    155         }
    156         $n_query = '
    157         SELECT id FROM '.GROUPS_TABLE.'
    158         WHERE name IN (\'+18\')
    159         ;';
    160         $data_group = mysql_fetch_array(pwg_query($n_query));
    161         $query = '
    162         SELECT COUNT(*) AS result FROM '.USER_GROUP_TABLE.'
    163         WHERE group_id IN (\''.$data_group['id'].'\') AND user_id IN (\''.get_userid('18').'\')
    164         ;';
    165         $data_user_group = mysql_fetch_array(pwg_query($query));
    166         $exist = $data_user_group['result'];
    167         if ( $exist == 0 )
    168         {
    169                 pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('18').'\', \''.$data_group['id'].'\' )' );
    170         }
     94  $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'16-17\') ;');
     95  $data_group = pwg_db_fetch_array($result);
     96  pwg_query('INSERT IGNORE INTO '.USER_GROUP_TABLE.' VALUES(\''.get_userid('16').'\', \''.$data_group['id'].'\' )' );
     97////////////placer dans group nothing////////////
     98  $result = pwg_query('SELECT id FROM '.GROUPS_TABLE.' WHERE name IN (\'nothing\') ;');
     99  $data_group = pwg_db_fetch_array($result);
     100  pwg_query('INSERT IGNORE INTO '.USER_GROUP_TABLE.' VALUES(\''.$conf['guest_id'].'\', \''.$data_group['id'].'\' )' );
    171101       
    172102        ////////////mis en generic////////////
     
    190120        WHERE param IN (\'ad_c_plugin\')
    191121        ;';
    192         $data_table = mysql_fetch_array(pwg_query($query));
     122        $data_table = pwg_db_fetch_array(pwg_query($query));
    193123        $exist = $data_table['result'];
    194124        if ( $exist == 0 )
    195125        {
    196         $q = '
    197         INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
    198         VALUES
    199     ("ad_c_plugin" , "true,false,both" , "Plugin adult_content : menublock_for_guest, block_on_index, manage_what");';
    200         pwg_query($q);
     126          $config_start=array('menublock_for_guest'=>true,'block_on_index'=>false,'manage_what'=>'both');
     127    $q = '
     128    INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
     129    VALUES
     130      ("ad_c_plugin" , "'.pwg_db_real_escape_string(serialize($config_start)).'" , "Plugin adult_content : menublock_for_guest, block_on_index, manage_what");';
     131    pwg_query($q);
    201132        }
    202133        else {
    203134                $query = '
    204         SELECT value FROM '.CONFIG_TABLE.'
    205         WHERE param IN (\'ad_c_plugin\')
    206         ;';
    207         $data_conf = mysql_fetch_array(pwg_query($query));
    208         $conf=explode(',', $data_conf['value']);
    209         $nbr=count($conf);
    210        
    211          if ($nbr!=3)
    212          {
    213                 pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param IN (\'ad_c_plugin\')');
    214                 $q = '
    215                 INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
    216                 VALUES
    217     ("ad_c_plugin" , "true,false,both" , "Plugin adult_content : menublock_for_guest, block_on_index, manage_what");';
    218                 pwg_query($q);
    219                 }
     135    SELECT value FROM '.CONFIG_TABLE.'
     136    WHERE param IN (\'ad_c_plugin\')
     137    ;';
     138    $data_conf = pwg_db_fetch_array(pwg_query($query));
     139    $cf=@unserialize($data_conf);
     140    $nbr=count($cf);
     141       
     142          if ($nbr!=3)
     143          {
     144      $config_start=array('menublock_for_guest'=>true,'block_on_index'=>false,'manage_what'=>'both');
     145      $q = '
     146      UPDATE ' . CONFIG_TABLE . ' SET
     147      param="ad_c_plugin", value="'.pwg_db_real_escape_string(serialize($config_start)).'", comment="Plugin adult_content : menublock_for_guest, block_on_index, manage_what"
     148      WHERE param IN (\'ad_c_plugin\');';
     149      pwg_query($q);
     150    }
    220151        }
    221152       
     
    237168  WHERE name IN (\'16-17\')
    238169;';
    239     $data_group = mysql_fetch_array(pwg_query($query));
     170    $data_group = pwg_db_fetch_array(pwg_query($query));
    240171          pwg_query('DELETE FROM '.USER_GROUP_TABLE.' WHERE group_id IN (\''.$data_group['id'].'\')' );
    241172         
     
    245176  WHERE name IN (\'+18\')
    246177;';
    247     $data_group = mysql_fetch_array(pwg_query($query));
     178    $data_group = pwg_db_fetch_array(pwg_query($query));
    248179          pwg_query('DELETE FROM '.USER_GROUP_TABLE.' WHERE group_id IN (\''.$data_group['id'].'\')' );
    249180
     
    253184  WHERE name IN (\'nothing\')
    254185;';
    255     $data_group = mysql_fetch_array(pwg_query($query));
     186    $data_group = pwg_db_fetch_array(pwg_query($query));
    256187          pwg_query('DELETE FROM '.USER_GROUP_TABLE.' WHERE group_id IN (\''.$data_group['id'].'\')' );
    257188 
Note: See TracChangeset for help on using the changeset viewer.