'Event Cats', 'URL' => get_admin_plugin_menu_link(dirname(__FILE__). '/admin/evntcats_admin.php') ) ); return $menu; } } // End class $obj = new event_cats(); // Admin help management add_event_handler('get_popup_help_content', 'ec_popup_help_content', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); function ec_popup_help_content($popup_help_content, $page) { return ( $help_content = ($page == 'event_cats' and is_admin()) ? load_language('help.html', EVNTCATS_PATH, array('return' => true)) : false ) ? $popup_help_content.$help_content : $popup_help_content; } // Mettre en place l'autoid, qu'on voie si ça marche ! //---------------------------------- /** * * auto_log_user() * the function uses the value of the argument "autolog" of the posted URL, as a code * to know which username has to be logged in. * * @param no parameter * @return no return value */ add_event_handler('init', 'auto_log_user'); function auto_log_user() { global $ec_conf, $ec_lists; $ec_ap = NULL; $ec_cat = NULL; $ec_img = NULL; if (isset($_GET['autolog']) and ($ec_conf['activated'] == 1)) { if (!is_a_guest()) logout_user(); build_ec_lists(); foreach ($ec_lists['ec_table'] as $ec_entry) { if ($code_exists = ($ec_entry['code'] == $_GET['autolog'])) break; } if ($code_exists) { if (isset($_GET['ap'])) $ec_ap = $_GET['ap']; if (strpos($ec_entry['action'], 'ec_ok') !== false) { log_user($ec_entry['user_id'], false); if (isset($_GET['cat'])) $ec_cat = $_GET['cat']; if (isset($_GET['img'])) $ec_img = $_GET['img']; if ( $ec_entry['forced'] == 'true' and $ec_entry['action'] != 'ec_forced_pb' ) { if (empty($ec_entry['arg1']) and !empty($ec_entry['arg2'])) { $ec_ap = $ec_entry['arg2']; } elseif (!empty($ec_entry['arg1'])) { $ec_cat = $ec_entry['arg1']; if (!empty($ec_entry['arg2'])) $ec_img = $ec_entry['arg2']; } } if (isset($ec_ap)) { if (array_key_exists($ec_ap,$ec_lists['add_pages'])) { redirect( PHPWG_ROOT_PATH.'index.php?/additional_page/'.$ec_ap); } } elseif (isset($ec_cat)) { if (array_key_exists($ec_cat, $ec_lists['categories'])) { if (isset($ec_img)) { if (mysql_fetch_row(pwg_query(' SELECT * FROM `'.IMAGE_CATEGORY_TABLE.'` WHERE `category_id` = '.$ec_cat.' AND `image_id` = '.$ec_img ))) { redirect(PHPWG_ROOT_PATH.'picture.php?/'.$ec_img.'/category/'.$ec_cat); } } redirect(PHPWG_ROOT_PATH.'index.php?/category/'.$ec_cat); } } else { redirect(make_index_url()); } } else { if ($ec_entry['action'] == 'ec_nok') { if (isset($ec_ap)) { if (array_key_exists($ec_ap,$ec_lists['add_pages'])) { redirect( PHPWG_ROOT_PATH.'index.php?/additional_page/'.$ec_ap); } } access_denied(); } else { redirect(make_index_url()); } } } else { if ( $ec_conf['unknown_code'] == 2 and array_key_exists( $ec_conf['unknown_code_ap_id'], $ec_lists['add_pages'] ) ) { redirect( PHPWG_ROOT_PATH. 'index.php?/additional_page/'.$ec_conf['unknown_code_ap_id'] ); } elseif ($ec_conf['unknown_code'] == 1 or $ec_conf['unknown_code'] == 2) { access_denied(); } else { redirect(make_index_url()); } } } } /** * * assign_perm_for_new_user() * copies/paste groups+access+properties associations of previously connected * username, to newly created username. * * @param no parameter * @return no return value */ add_event_handler('register_user', 'assign_perm_for_new_user'); function assign_perm_for_new_user($new_user) { /* global $user; if (!is_a_guest() and !is_admin()) { // User access $query = 'SELECT cat_id FROM '.USER_ACCESS_TABLE.' WHERE user_id = '.$user['id'].';'; $result = pwg_query($query); $insert = array(); while ($row = mysql_fetch_assoc($result)) { $insert[] = '('.$new_user['id'].','.$row['cat_id'].')'; } if (!empty($insert)) { pwg_query('INSERT INTO '.USER_ACCESS_TABLE.' VALUES '.implode(',', $insert).';'); } // User groups $query = 'SELECT group_id FROM '.USER_GROUP_TABLE.' WHERE user_id = '.$user['id'].';'; $result = pwg_query($query); $insert = array(); while ($row = mysql_fetch_assoc($result)) { $insert[] = '('.$new_user['id'].','.$row['group_id'].')'; } if (!empty($insert)) { pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES '.implode(',', $insert).';'); } // User infos $query = 'SELECT level FROM '.USER_INFOS_TABLE.' WHERE user_id = '.$user['id'].';'; $result = pwg_query($query); $insert = array(); while ($row = mysql_fetch_assoc($result)) { $insert[] = '('.$new_user['id'].','.$row['level'].')'; } if (!empty($insert)) { $query = 'UPDATE '.USER_INFOS_TABLE.' SET level = '.$user['level'].' WHERE user_id = '.$new_user['id'].';'; pwg_query($query); } } */ } /** * * duplicate_account_url() * adds a link "Duplicate" in Identification block menu. * * @param no parameter * @return no return value */ add_event_handler('blockmanager_apply', 'duplicate_account_url'); function duplicate_account_url() { /* global $conf, $lang, $template; if ($conf['allow_user_registration'] and !is_admin() and !is_a_guest()) and !is_admin() and !is_a_guest()) { $template->assign( 'U_REGISTER', get_root_url().'register.php'); $lang['Create a new account'] = l10n('Duplicate account'); $lang['Register'] = l10n('Duplicate'); } */ } // copying/pasting the following lines from same file in plugin LLGBO2, // because it looks like it's useful :-/ ..... /* add_event_handler('render_element_content', array(&$obj,'MyPictureOptions'), EVENT_HANDLER_PRIORITY_NEUTRAL-1, 2 ); */ add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'plugin_admin_menu') ); set_plugin_data($plugin['id'], $obj); ?>