'Event Cats',
'URL' => get_admin_plugin_menu_link(dirname(__FILE__).
'/admin/evntcats_admin.php')
)
);
return $menu;
}
} // End class
$obj = new event_cats();
// Adds the translation of "duplicate" link
load_language('duplic.lang', EVNTCATS_PATH);
// 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 = (is_admin() and $page == 'help') ?
load_language($page.'.html', EVNTCATS_PATH, array('return' => true)) : false
) ? $popup_help_content.$help_content : $popup_help_content;
}
//----------------------------------
/**
*
* 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_lists;
$ec_ap = NULL;
$ec_cat = NULL;
$ec_img = NULL;
if (isset($_GET['autolog']) and (read_ec_conf('activated') == 1)) {
if (!is_a_guest()) {
$url = '';
foreach ($_GET as $item => $value) {
if ($url != '') $url.='&';
$url.= $item.'='.$value;
}
logout_user();
redirect(get_absolute_root_url().'index.php?'.$url);
}
build_ec_lists();
foreach ($ec_lists['ec_table'] as $ec_entry) {
if ($code_exists = ($ec_entry['code'] == $_GET['autolog'])) break;
}
if ($code_exists) {
if (is_in($ec_entry['action'], 'ec_ok')) {
log_user($ec_entry['user_id'], false);
if (isset($_GET['ap'])) $ec_ap = $_GET['ap'];
if (isset($_GET['cat'])) $ec_cat = $_GET['cat'];
if (isset($_GET['img'])) $ec_img = $_GET['img'];
if ($ec_entry['forced'] == 'true') {
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 (ec_image_exists($ec_cat, $ec_img)) {
redirect(PHPWG_ROOT_PATH.'picture.php?/'.$ec_img.'/category/'.$ec_cat);
}
}
redirect(PHPWG_ROOT_PATH.'index.php?/category/'.$ec_cat);
}
}
redirect(make_index_url());
}
else {
if (
$ec_entry['action'] == 'ec_nok' or
$ec_entry['action'] == 'ec_nok_ap_pb'
) {
if ($ec_entry['action'] == 'ec_nok_ap_pb') access_denied();
$ec_ap = $ec_entry['arg2'];
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 (
read_ec_conf('unknown_code') == '2' and
array_key_exists(
read_ec_conf('unknown_code_ap_id'), $ec_lists['add_pages']
)
) {
redirect(
PHPWG_ROOT_PATH.
'index.php?/additional_page/'.read_ec_conf('unknown_code_ap_id')
);
}
elseif (read_ec_conf('unknown_code') == '1' or
read_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()) if (
read_ec_conf('dup_allow') == '1' or (
read_ec_conf('dup_allow') == '2' and
dup_allowed($user['id'])
)
) {
// User access
$result = pwg_query("
SELECT `cat_id`
FROM `".USER_ACCESS_TABLE."`
WHERE `user_id` = ".$user['id'].";
");
$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
$result = pwg_query("
SELECT `group_id`
FROM `".USER_GROUP_TABLE."`
WHERE `user_id` = ".$user['id'].";
");
$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
$result = pwg_query("
SELECT `level`
FROM `".USER_INFOS_TABLE."`
WHERE `user_id` = ".$user['id'].";
");
$insert = array();
while ($row = mysql_fetch_assoc($result))
$insert[] = "(".$new_user['id'].",".$row['level'].")";
if (!empty($insert)) pwg_query("
UPDATE `".USER_INFOS_TABLE."`
SET `level` = ".$user['level']."
WHERE `user_id` = ".$new_user['id'].";
");
}
}
/**
*
* duplicate_account_url()
* adds a link for duplicating the currently identified user in
* Identification block menu, in case the identifed user is granted to
* duplication. Displays also the connection link for generic users, if
* required in the configuration.
*
* ec_duplicate_prefilter
* is used to modify the "quick connect" block in identification menu block,
* so that visitors identifying themselves this way, are redirected to the
* page they're currently displaying, instead of home page. This
* functionnality has been added at version 2.1.0 in Piwigo core
* (see bug:1484 Redirection after quickconnect), thus it is useless to
* implement it from here for Piwigo versions higher or equal to 2.1.0.
*
* @param no parameter
* @return no return value
*/
add_event_handler('blockmanager_apply', 'duplicate_account_url');
function ec_duplicate_prefilter($content, &$smarty) {
$search = "";
$addon = '';
$replacement = "".$addon;
return str_replace($search, $replacement, $content);
}
function duplicate_account_url() {
global $lang, $template, $user;
if (version_compare(PHPWG_VERSION, '2.1.0', '<')) {
// Makes the "quick connect" fieldset able to redirect to current page
// after user identification, just as does the "connection" link.
$template->assign(array('U_REDIRECT' => $_SERVER['REQUEST_URI']));
$template->set_prefilter('menubar', 'ec_duplicate_prefilter');
}
// Adds duplication link, if needed
if (!is_admin() and !is_a_guest()) if (
read_ec_conf('dup_allow') == '1' or (
read_ec_conf('dup_allow') == '2' and
dup_allowed($user['id'])
)
) {
$template->assign('U_REGISTER', get_root_url().'register.php');
if (
read_ec_conf('duplic_display') == '1' or (
read_ec_conf('duplic_display') == '2' and
!is_generic()
)
) {
$lang['Register'] = $lang['Duplicate'];
$lang['Create a new account'] =
$lang['Create a new account with same properties'];
}
}
// Adds connection link, if needed
if (read_ec_conf('display_connection') == '1' and is_generic()) {
// Adds connection link
$template->assign(
'U_LOGIN',
get_root_url().'identification.php?redirect='.$_SERVER['REQUEST_URI']
);
}
}
add_event_handler(
'get_admin_plugin_menu_links',
array(&$obj, 'plugin_admin_menu')
);
set_plugin_data($plugin['id'], $obj);
?>