=') ) { array_push($menu, array( 'NAME' => $name, 'URL' => get_root_url().'admin.php?page=plugin-'.basename(LCAS_PATH) ) ); } else // Compliance with Piwigo 2.1 { array_push($menu, array( 'NAME' => $name, 'URL' => get_admin_plugin_menu_link(LCAS_PATH.'/admin/LCAS_admin.php') ) ); } return $menu; } // Check users identification // Define prefilter to add tooltips on register page add_event_handler('init', 'LCAS_InitPage'); function LCAS_InitPage() { global $template, $conf, $lang; $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']); // Set $conf['insensitive_case_logon'] to false, as LCAS takes completely // in charge everything concerning the case and the accents in the login if ($conf_LCAS[0] != '0') $conf['insensitive_case_logon'] = false; /* User identification */ if (script_basename() == 'identification') { if (isset($_POST['username']) and isset($conf_LCAS[0])) { $new_username = LCAS_SearchCaseUsername($_POST['username'], $conf_LCAS[0]); $_POST['username'] = ($new_username == '') ? $_POST['username'] : $new_username; } } // Add tooltips on register and identification page $sb = script_basename(); $fn = ''; if ($sb == 'register' or $sb == 'identification') $fn = ($sb == 'register') ? 'LCAS_add_tooltips_prefilter_register' : 'LCAS_add_tooltips_prefilter_identification'; if ($fn != '') { $template->assign(array( 'LCAS_username_tooltip' => $lang['LCAS_tooltip_username_register'][intval($conf_LCAS[0])], 'LCAS_password_tooltip' => $lang['LCAS_tooltip_password_register'], )); $template->set_prefilter($sb, $fn); } } function LCAS_add_tooltips_prefilter_register($content, &$smarty) { $search = 'for="login"'; $replacement = 'for="login" title="{$LCAS_username_tooltip}"'; $content = str_replace($search, $replacement, $content); $search = 'name="login"'; $replacement = 'name="login" title="{$LCAS_username_tooltip}"'; $content = str_replace($search, $replacement, $content); $search = 'for="password"'; $replacement = 'for="password" title="{$LCAS_password_tooltip}"'; $content = str_replace($search, $replacement, $content); $search = 'name="password"'; $replacement = 'name="password" title="{$LCAS_password_tooltip}"'; $content = str_replace($search, $replacement, $content); $search = 'for="password_conf"'; $replacement = 'for="password_conf" title="{$LCAS_password_tooltip}"'; $content = str_replace($search, $replacement, $content); $search = 'name="password_conf"'; $replacement = 'name="password_conf" title="{$LCAS_password_tooltip}"'; $content = str_replace($search, $replacement, $content); return $content; } function LCAS_add_tooltips_prefilter_identification($content, &$smarty) { $search = 'for="username"'; $replacement = 'for="username" title="{$LCAS_username_tooltip}"'; $content = str_replace($search, $replacement, $content); $search = 'name="username"'; $replacement = 'name="username" title="{$LCAS_username_tooltip}"'; $content = str_replace($search, $replacement, $content); $search = 'for="password"'; $replacement = 'for="password" title="{$LCAS_password_tooltip}"'; $content = str_replace($search, $replacement, $content); $search = 'name="password"'; $replacement = 'name="password" title="{$LCAS_password_tooltip}"'; $content = str_replace($search, $replacement, $content); return $content; } // Check users registration // Returns error add_event_handler('register_user_check', 'LCAS_RegistrationCheck'); function LCAS_RegistrationCheck($errors) { global $conf, $lang; $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']); load_language('plugin.lang', LCAS_PATH); if (isset($conf_LCAS[0])) $NewPostLogin = LCAS_SearchCaseUsername($_POST['login'], $conf_LCAS[0]); if (isset($NewPostLogin) and get_userid($NewPostLogin)) $errors[] = $lang['LCAS_error'][intval($conf_LCAS[0])]; return $errors; } /** * * LCAS_add_tooltips() * add tooltips on username and password fields * * @param no parameter * @return no return value */ add_event_handler('blockmanager_apply', 'LCAS_add_tooltips_index'); function LCAS_add_tooltips_index() { global $template, $conf, $lang; $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']); $template->assign(array( 'LCAS_username_tooltip' => $lang['LCAS_tooltip_username_index'][intval($conf_LCAS[0])], 'LCAS_password_tooltip' => $lang['LCAS_tooltip_password_index'], )); $template->set_prefilter('menubar', 'LCAS_add_tooltips_prefilter_index'); } function LCAS_add_tooltips_prefilter_index($content, &$smarty) { $search = 'for="username"'; $replacement = 'for="username" title="{$LCAS_username_tooltip}"'; $content = str_replace($search, $replacement, $content); $search = 'name="username"'; $replacement = 'name="username" title="{$LCAS_username_tooltip}"'; $content = str_replace($search, $replacement, $content); $search = 'for="password"'; $replacement = 'for="password" title="{$LCAS_password_tooltip}"'; $content = str_replace($search, $replacement, $content); $search = 'name="password"'; $replacement = 'name="password" title="{$LCAS_password_tooltip}"'; $content = str_replace($search, $replacement, $content); return $content; } // LCAS_admin_user_filter // // Allow to use LCAS for searching usernames, in admin user_list page // add_event_handler('loc_end_admin', 'LCAS_admin_user_filter'); function LCAS_admin_user_filter() { if ( strpos($_SERVER['REQUEST_URI'], 'user_list') !== false and isset($_GET['username']) and !empty($_GET['username']) ) include(LCAS_PATH.'include/admin_search.inc.php'); } // LCAS_add_tooltips_user_list // // Also set prefilter to add tooltip // add_event_handler('loc_begin_admin', 'LCAS_add_tooltips_user_list'); function LCAS_add_tooltips_user_list() { global $template, $conf, $lang; $conf_LCAS= unserialize($conf['LoginCaseAccentsSensitivity']); if (strpos($_SERVER['REQUEST_URI'], 'user_list') !== false) { $template->assign( 'LCAS_username_tooltip_admin', $lang['LCAS_tooltip_username_admin'][intval($conf_LCAS[0])] ); $template->set_prefilter('user_list','LCAS_add_tooltips_prefilter_admin'); } } function LCAS_add_tooltips_prefilter_admin($content, &$smarty) { $search = 'name="username"'; $replacement = 'name="username" title="{$LCAS_username_tooltip_admin}"'; $content = str_replace($search, $replacement, $content); return $content; } ?>