[9530] | 1 | <?php |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | class Adultcontent |
---|
| 5 | { |
---|
| 6 | var $plugin_name, $plugin_path; |
---|
[9564] | 7 | var $idgroups_user = array(); |
---|
| 8 | var $idgroups_ad_c = array();// 0=+18 1=16 2=nothing |
---|
[9530] | 9 | function Adultcontent($plugin_name, $plugin_path) |
---|
| 10 | { |
---|
| 11 | // Args |
---|
| 12 | $this->plugin_name = $plugin_name; |
---|
| 13 | $this->plugin_path = $plugin_path; |
---|
| 14 | } |
---|
[9564] | 15 | function fill_idgroups_user() |
---|
[9530] | 16 | { |
---|
[9564] | 17 | global $user; |
---|
| 18 | |
---|
| 19 | $query = 'SELECT group_id FROM ' . USER_GROUP_TABLE . ' WHERE user_id = ' . $user['id'] . ';'; |
---|
| 20 | $result = pwg_query($query); |
---|
[21047] | 21 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[9564] | 22 | { |
---|
| 23 | array_push($this->idgroups_user, $row['group_id']); |
---|
| 24 | } |
---|
| 25 | } |
---|
| 26 | function fill_idgroups_ad_c() |
---|
| 27 | { |
---|
| 28 | global $user; |
---|
| 29 | |
---|
| 30 | $query = 'SELECT id FROM ' . GROUPS_TABLE . ' WHERE name IN (\'+18\', \'16-17\', \'nothing\') ORDER BY id'; |
---|
| 31 | $result = pwg_query($query); |
---|
[21047] | 32 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[9564] | 33 | { |
---|
| 34 | array_push($this->idgroups_ad_c, $row['id']); |
---|
| 35 | } |
---|
| 36 | } |
---|
| 37 | function is_in_ad_c_group() |
---|
| 38 | { |
---|
| 39 | foreach( $this->idgroups_ad_c as $id ) |
---|
| 40 | { |
---|
| 41 | if ( in_array($id, $this->idgroups_user)) |
---|
| 42 | { |
---|
| 43 | return $id; |
---|
| 44 | exit; |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | return false; |
---|
| 48 | } |
---|
| 49 | function get_link_icon($main_link, $action) |
---|
| 50 | { |
---|
[9530] | 51 | $link_url = add_url_params($main_link, array('ad' => $action)); |
---|
| 52 | return $link_url; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | function loading_lang() |
---|
| 56 | { |
---|
| 57 | global $lang; |
---|
[9564] | 58 | load_language('plugin.lang', $this->plugin_path); |
---|
[9530] | 59 | } |
---|
| 60 | function var_template() |
---|
| 61 | { |
---|
| 62 | global $user; |
---|
| 63 | if ($user['template'] == 'flop_pure_design') |
---|
| 64 | { |
---|
| 65 | $r = 'var_fpd.inc.php'; |
---|
| 66 | } |
---|
| 67 | else |
---|
| 68 | { |
---|
| 69 | $r = 'var.inc.php'; |
---|
| 70 | } |
---|
| 71 | return $r; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | function register_ac_menubar_blocks($menu_ref_arr) { |
---|
| 75 | $menu = & $menu_ref_arr[0]; |
---|
| 76 | if ($menu->get_id() != 'menubar') |
---|
[9626] | 77 | { |
---|
[9530] | 78 | return; |
---|
[9626] | 79 | } |
---|
[9530] | 80 | $menu->register_block(new RegisteredBlock('mbAdultContent', 'Adult Content', 'AC')); |
---|
| 81 | } |
---|
| 82 | function ac_lien_menu($menu) |
---|
| 83 | { |
---|
[9626] | 84 | array_push( |
---|
| 85 | $menu, |
---|
| 86 | array('NAME' => 'Adult Content', |
---|
| 87 | 'URL' => get_admin_plugin_menu_link(get_root_url().'plugins/'.$this->plugin_name.'/admin/admin.php') |
---|
| 88 | ) |
---|
| 89 | ); |
---|
[9530] | 90 | return $menu; |
---|
| 91 | } |
---|
| 92 | function get_template($file) |
---|
| 93 | { |
---|
| 94 | global $user, $template; |
---|
[9564] | 95 | $r_theme_file=array(); |
---|
| 96 | $dir = $this->plugin_path.'template/'; |
---|
| 97 | $r_theme_file=($template->smarty->template_dir); |
---|
[9530] | 98 | foreach( $r_theme_file as $style) |
---|
| 99 | { |
---|
| 100 | $theme_file = explode("/", $style); |
---|
| 101 | $pos = count($theme_file) - 2 ; |
---|
| 102 | $theme_file = $dir.$theme_file[$pos].'/'.$file; |
---|
| 103 | if (file_exists($theme_file)) |
---|
| 104 | { |
---|
| 105 | return $theme_file; |
---|
| 106 | } |
---|
| 107 | else |
---|
| 108 | { |
---|
| 109 | $theme_file=NULL; |
---|
[10855] | 110 | } |
---|
[9530] | 111 | |
---|
| 112 | |
---|
[10855] | 113 | } |
---|
| 114 | if (empty($theme_file)) |
---|
| 115 | { |
---|
| 116 | return $dir.'default/'.$file; |
---|
| 117 | } |
---|
[9530] | 118 | } |
---|
| 119 | |
---|
| 120 | function placer_identification($menu_ref_arr) |
---|
| 121 | { |
---|
| 122 | ///////////////////////[début du plug]//////////////////// |
---|
| 123 | $this->loading_lang(); |
---|
| 124 | global $user, $conf, $page, $template; |
---|
| 125 | $menu = & $menu_ref_arr[0]; |
---|
[21047] | 126 | $conf_plugin = unserialize($conf['ad_c_plugin']); |
---|
[9530] | 127 | $template->assign( |
---|
| 128 | array( |
---|
| 129 | 'AC_NAME' => AC_NAME |
---|
| 130 | )); |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | //include($this->var_template()); |
---|
[21047] | 134 | if (is_a_guest() and $conf_plugin['menublock_for_guest']=='true') |
---|
[9530] | 135 | { |
---|
| 136 | |
---|
| 137 | ///////////////////////[gestion fermer/ouvert]//////////////////// |
---|
| 138 | if ( !isset( $_GET['ad'] ) ) |
---|
| 139 | { |
---|
| 140 | if ( !isset( $_COOKIE['pwg_adult_content'] ) or $_COOKIE['pwg_adult_content'] == 'open' ) |
---|
| 141 | { |
---|
| 142 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'closed') )); |
---|
| 143 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
| 144 | $block->set_title(l10n('ac_title_menu')); |
---|
| 145 | $block->template = $this->get_template('opened.tpl'); |
---|
| 146 | } |
---|
| 147 | } |
---|
| 148 | elseif ( $_COOKIE['pwg_adult_content'] == 'closed' ) |
---|
| 149 | { |
---|
| 150 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'open') )); |
---|
| 151 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
| 152 | $block->set_title(l10n('ac_title_fermer')); |
---|
| 153 | $block->template = $this->get_template('closed.tpl'); |
---|
| 154 | } |
---|
| 155 | |
---|
| 156 | } |
---|
| 157 | } |
---|
| 158 | elseif ( $_GET['ad'] == 'closed' ) |
---|
| 159 | { |
---|
| 160 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'open') )); |
---|
| 161 | setcookie( 'pwg_adult_content', 'closed', time()+60*60*24*30, cookie_path() ); |
---|
| 162 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
| 163 | $block->set_title(l10n('ac_title_fermer')); |
---|
| 164 | $block->template = $this->get_template('closed.tpl'); |
---|
| 165 | } |
---|
| 166 | } |
---|
| 167 | elseif ( $_GET['ad'] == 'open' ) |
---|
| 168 | { |
---|
| 169 | $template->assign(array( 'LINK' => $this->get_link_icon(duplicate_index_url(), 'closed') )); |
---|
| 170 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
| 171 | $block->set_title(l10n('ac_title_menu')); |
---|
| 172 | $block->template = $this->get_template('opened.tpl'); |
---|
| 173 | } |
---|
| 174 | |
---|
| 175 | setcookie( 'pwg_adult_content', 'open', time()+60*60*24*30, cookie_path() ); |
---|
| 176 | } |
---|
| 177 | ///////////////////////[FIN fermer/ouvert]//////////////////// |
---|
| 178 | }//fin if guest |
---|
[21047] | 179 | elseif (is_a_guest() and $conf_plugin['menublock_for_guest']!='true') |
---|
[9530] | 180 | { |
---|
| 181 | $menu->hide_block('mbAdultContent'); |
---|
| 182 | } |
---|
| 183 | elseif ($user['username'] == '18') |
---|
| 184 | { |
---|
| 185 | $menu->hide_block('mbIdentification'); |
---|
| 186 | $template->assign( |
---|
| 187 | array( |
---|
| 188 | 'AC_MSG' => l10n('ac_user_text_18') |
---|
| 189 | )); |
---|
| 190 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
| 191 | $block->set_title(l10n('ac_title_menu')); |
---|
| 192 | $block->template = $this->get_template('msg.tpl'); |
---|
| 193 | } |
---|
| 194 | |
---|
| 195 | $_SESSION['age']="18"; |
---|
| 196 | setcookie( 'age', '18', time()+60*60*24*30, cookie_path() ); |
---|
| 197 | |
---|
| 198 | }//fin if 18 ans |
---|
| 199 | elseif ($user['username'] == '16') |
---|
| 200 | { |
---|
| 201 | $menu->hide_block('mbIdentification'); |
---|
| 202 | $template->assign( |
---|
| 203 | array( |
---|
| 204 | 'AC_MSG' => l10n('ac_user_text_16') |
---|
| 205 | )); |
---|
| 206 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
| 207 | $block->set_title(l10n('ac_title_menu')); |
---|
| 208 | $block->template = $this->get_template('msg.tpl'); |
---|
| 209 | } |
---|
| 210 | |
---|
| 211 | }//fin if 16-17 ans |
---|
[12082] | 212 | elseif (!is_admin() and $user['status']!="generic") |
---|
[9530] | 213 | { |
---|
| 214 | ////////////lié à quoi///// |
---|
[9564] | 215 | $this->fill_idgroups_user(); |
---|
| 216 | $this->fill_idgroups_ad_c(); |
---|
[9530] | 217 | |
---|
[9649] | 218 | if ( !$this->is_in_ad_c_group() )// lié à rien |
---|
[9564] | 219 | { |
---|
| 220 | $template->assign( |
---|
| 221 | array( |
---|
| 222 | 'AC_MSG' => l10n('ac_charte_user_not') |
---|
| 223 | )); |
---|
| 224 | $menu = & $menu_ref_arr[0]; |
---|
| 225 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
[9649] | 226 | //$block->set_title(l10n('ac_title_choose')); |
---|
[9564] | 227 | $block->template = $this->get_template('choose.tpl'); |
---|
| 228 | } |
---|
[9649] | 229 | $query = 'SELECT id FROM ' . GROUPS_TABLE . ' WHERE name IN (\'+18\', \'16-17\', \'nothing\') ORDER BY id'; |
---|
| 230 | $result = pwg_query($query); |
---|
| 231 | if ( isset($conf['UserAdvManager']) ) |
---|
| 232 | { |
---|
| 233 | $conf_UAM_2 = unserialize($conf['UserAdvManager']); |
---|
[21522] | 234 | if ( in_array($conf_UAM_2['NO_CONFIRM_GROUP'], $this->idgroups_user))/// $conf_UAM_2[2] est le groupe des user en attente de modération |
---|
[9649] | 235 | { |
---|
| 236 | $menu->hide_block('mbAdultContent'); |
---|
| 237 | } |
---|
| 238 | } |
---|
| 239 | |
---|
[9564] | 240 | } |
---|
| 241 | else |
---|
| 242 | { |
---|
| 243 | $link=$this->is_in_ad_c_group(); |
---|
| 244 | if ($link == $this->idgroups_ad_c[0]) |
---|
| 245 | { |
---|
| 246 | $statut = l10n('ac_user_text_18'); |
---|
| 247 | } |
---|
| 248 | if ($link == $this->idgroups_ad_c[1]) |
---|
| 249 | { |
---|
| 250 | $statut = l10n('ac_user_text_16'); |
---|
| 251 | } |
---|
| 252 | if ($link == $this->idgroups_ad_c[2]) |
---|
| 253 | { |
---|
| 254 | $statut = l10n('ac_user_no_s'); |
---|
| 255 | } |
---|
| 256 | $template->assign( |
---|
| 257 | array( |
---|
| 258 | 'AC_MSG' => $statut.". ".l10n('ac_charte_user_def') |
---|
| 259 | )); |
---|
| 260 | $menu = & $menu_ref_arr[0]; |
---|
| 261 | if (($block = $menu->get_block( 'mbAdultContent' )) != null) { |
---|
| 262 | $block->set_title(l10n('ac_title_menu_statut')); |
---|
| 263 | $block->template = $this->get_template('choose.tpl'); |
---|
| 264 | } |
---|
[9530] | 265 | |
---|
| 266 | } |
---|
| 267 | } |
---|
| 268 | |
---|
| 269 | }//fin placer_identification |
---|
| 270 | function on_register() |
---|
| 271 | { |
---|
[9649] | 272 | if ( !function_exists('UAM_admin_menu')) |
---|
| 273 | { |
---|
| 274 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
| 275 | $user_id = get_userid($_POST['login']); |
---|
| 276 | log_user( $user_id, false); |
---|
[9564] | 277 | redirect(PHPWG_ROOT_PATH.'plugins/adult_content/charte_user.php'); |
---|
[9649] | 278 | } |
---|
[21047] | 279 | } |
---|
| 280 | function ac_stuffs_module($modules) |
---|
| 281 | { |
---|
| 282 | load_language('plugin.lang', $this->plugin_path); |
---|
| 283 | array_push($modules, array( |
---|
| 284 | 'path' => PHPWG_PLUGINS_PATH . AC_NAME . '/stuffs_module/', |
---|
| 285 | 'name' => l10n('ac_text'), |
---|
[21057] | 286 | 'description' => l10n('Disclaimer for the guest, with the ability to choose its age'), |
---|
[21047] | 287 | ) |
---|
| 288 | ); |
---|
| 289 | return $modules; |
---|
| 290 | } |
---|
| 291 | |
---|
[9530] | 292 | }//fin class |
---|
[3331] | 293 | ?> |
---|