本文整理汇总了PHP中WT\Auth::user方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::user方法的具体用法?PHP Auth::user怎么用?PHP Auth::user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT\Auth
的用法示例。
在下文中一共展示了Auth::user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMyPageMenu
public static function getMyPageMenu()
{
global $PEDIGREE_FULL_DETAILS, $PEDIGREE_LAYOUT;
$showFull = $PEDIGREE_FULL_DETAILS ? 1 : 0;
$showLayout = $PEDIGREE_LAYOUT ? 1 : 0;
if (!Auth::id()) {
return null;
}
//-- main menu
$menu = new WT_Menu(WT_I18N::translate('My page'), 'index.php?ctype=user&ged=' . WT_GEDURL, 'menu-mymenu');
//-- mypage submenu
$submenu = new WT_Menu(WT_I18N::translate('My page'), 'index.php?ctype=user&ged=' . WT_GEDURL, 'menu-mypage');
$menu->addSubmenu($submenu);
//-- editaccount submenu
if (Auth::user()->getSetting('editaccount')) {
$submenu = new WT_Menu(WT_I18N::translate('My account'), 'edituser.php', 'menu-myaccount');
$menu->addSubmenu($submenu);
}
if (WT_USER_GEDCOM_ID) {
//-- my_pedigree submenu
$submenu = new WT_Menu(WT_I18N::translate('My pedigree'), 'pedigree.php?ged=' . WT_GEDURL . '&rootid=' . WT_USER_GEDCOM_ID . "&show_full={$showFull}&talloffset={$showLayout}", 'menu-mypedigree');
$menu->addSubmenu($submenu);
//-- my_indi submenu
$submenu = new WT_Menu(WT_I18N::translate('My individual record'), 'individual.php?pid=' . WT_USER_GEDCOM_ID . '&ged=' . WT_GEDURL, 'menu-myrecord');
$menu->addSubmenu($submenu);
}
if (WT_USER_GEDCOM_ADMIN) {
//-- admin submenu
$submenu = new WT_Menu(WT_I18N::translate('Administration'), 'admin.php', 'menu-admin');
$menu->addSubmenu($submenu);
}
return $menu;
}
示例2: exists_pending_change
function exists_pending_change(User $user = null, WT_Tree $tree = null)
{
global $WT_TREE;
if ($user === null) {
$user = Auth::user();
}
if ($tree === null) {
$tree = $WT_TREE;
}
if ($user === null || $tree === null) {
return false;
}
return $tree->canAcceptChanges($user) && WT_DB::prepare("SELECT 1" . " FROM `##change`" . " WHERE status='pending' AND gedcom_id=?")->execute(array($tree->tree_id))->fetchOne();
}
示例3: getBlock
public function getBlock($block_id, $template = true, $cfg = null)
{
$id = $this->getName() . $block_id;
$class = $this->getName() . '_block';
$title = '<span dir="auto">' . WT_I18N::translate('Welcome %s', Auth::user()->getRealName()) . '</span>';
$content = '<table><tr>';
if (Auth::user()->getSetting('editaccount')) {
$content .= '<td><a href="edituser.php"><i class="icon-mypage"></i><br>' . WT_I18N::translate('My account') . '</a></td>';
}
if (WT_USER_GEDCOM_ID) {
$content .= '<td><a href="pedigree.php?rootid=' . WT_USER_GEDCOM_ID . '&ged=' . WT_GEDURL . '"><i class="icon-pedigree"></i><br>' . WT_I18N::translate('My pedigree') . '</a></td>';
$content .= '<td><a href="individual.php?pid=' . WT_USER_GEDCOM_ID . '&ged=' . WT_GEDURL . '"><i class="icon-indis"></i><br>' . WT_I18N::translate('My individual record') . '</a></td>';
}
$content .= '</tr></table>';
if ($template) {
require WT_THEME_DIR . 'templates/block_main_temp.php';
} else {
return $content;
}
}
示例4: header
}
// If there is no current tree and we need one, then redirect somewhere
if (WT_SCRIPT_NAME != 'admin_trees_manage.php' && WT_SCRIPT_NAME != 'admin_pgv_to_wt.php' && WT_SCRIPT_NAME != 'login.php' && WT_SCRIPT_NAME != 'logout.php' && WT_SCRIPT_NAME != 'import.php' && WT_SCRIPT_NAME != 'help_text.php' && WT_SCRIPT_NAME != 'message.php') {
if (!$WT_TREE || !WT_IMPORTED) {
if (Auth::isAdmin()) {
header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'admin_trees_manage.php');
} else {
header('Location: ' . WT_LOGIN_URL . '?url=' . rawurlencode(WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')), true, 301);
}
exit;
}
}
if (Auth::id()) {
// Update the login time every 5 minutes
if (WT_TIMESTAMP - $WT_SESSION->activity_time > 300) {
Auth::user()->setSetting('sessiontime', WT_TIMESTAMP);
$WT_SESSION->activity_time = WT_TIMESTAMP;
}
}
// Set the theme
if (substr(WT_SCRIPT_NAME, 0, 5) == 'admin' || WT_SCRIPT_NAME == 'module.php' && substr(WT_Filter::get('mod_action'), 0, 5) == 'admin') {
// Administration scripts begin with “admin” and use a special administration theme
define('WT_THEME_DIR', WT_THEMES_DIR . '_administration/');
} else {
if (WT_Site::preference('ALLOW_USER_THEMES')) {
// Requested change of theme?
$THEME_DIR = WT_Filter::get('theme');
if (!in_array($THEME_DIR, get_theme_names())) {
$THEME_DIR = '';
}
// Last theme used?
示例5:
}
switch (WT_Filter::get('show_marnm', 'no|yes')) {
case 'no':
$show_marnm = false;
if (Auth::id()) {
Auth::user()->setSetting(WT_SCRIPT_NAME . '_show_marnm', $show_marnm);
}
break;
case 'yes':
$show_marnm = true;
if (Auth::id()) {
Auth::user()->setSetting(WT_SCRIPT_NAME . '_show_marnm', $show_marnm);
}
break;
default:
$show_marnm = Auth::id() && Auth::user()->getSetting(WT_SCRIPT_NAME . '_show_marnm');
}
// Make sure selections are consistent.
// i.e. can’t specify show_all and surname at the same time.
if ($show_all == 'yes') {
if ($show_all_firstnames == 'yes') {
$alpha = '';
$surname = '';
$legend = WT_I18N::translate('All');
$url = WT_SCRIPT_NAME . '?show_all=yes&ged=' . WT_GEDURL;
$show = 'indi';
} else {
if ($falpha) {
$alpha = '';
$surname = '';
$legend = WT_I18N::translate('All') . ', ' . WT_Filter::escapeHtml($falpha) . '…';
示例6: failed
Log::addAuthenticationLog('Login failed (incorrect password): ' . $username);
throw new Exception(WT_I18N::translate('The username or password is incorrect.'));
}
if (!$user->getSetting('verified')) {
Log::addAuthenticationLog('Login failed (not verified by user): ' . $username);
throw new Exception(WT_I18N::translate('This account has not been verified. Please check your email for a verification message.'));
}
if (!$user->getSetting('verified_by_admin')) {
Log::addAuthenticationLog('Login failed (not approved by admin): ' . $username);
throw new Exception(WT_I18N::translate('This account has not been approved. Please wait for an administrator to approve it.'));
}
Auth::login($user);
Log::addAuthenticationLog('Login: ' . Auth::user()->getUserName() . '/' . Auth::user()->getRealName());
$WT_SESSION->timediff = $timediff;
$WT_SESSION->locale = Auth::user()->getSetting('language');
$WT_SESSION->theme_dir = Auth::user()->getSetting('theme');
// If we’ve clicked login from the login page, we don’t want to go back there.
if (strpos($url, WT_SCRIPT_NAME) === 0) {
$url = '';
}
// We're logging in as an administrator
if (Auth::isAdmin()) {
// Check for updates
$latest_version_txt = fetch_latest_version();
if (preg_match('/^[0-9.]+\\|[0-9.]+\\|/', $latest_version_txt)) {
list($latest_version, $earliest_version, $download_url) = explode('|', $latest_version_txt);
if (version_compare(WT_VERSION, $latest_version) < 0) {
// An upgrade is available. Let the admin know, by redirecting to the upgrade wizard
$url = 'admin_site_upgrade.php';
}
} else {
示例7: array
<?php
$menu_items = array(WT_MenuBar::getGedcomMenu(), WT_MenuBar::getMyPageMenu(), WT_MenuBar::getChartsMenu(), WT_MenuBar::getListsMenu(), WT_MenuBar::getCalendarMenu(), WT_MenuBar::getReportsMenu(), WT_MenuBar::getSearchMenu());
foreach (WT_MenuBar::getModuleMenus() as $menu) {
$menu_items[] = $menu;
}
// Print the menu bar
echo '<div id="topMenu">', '<ul id="main-menu">';
foreach ($menu_items as $menu) {
if ($menu) {
echo getMenuAsCustomList($menu);
}
}
echo '</ul>';
echo '<div id="menu-right">', '<ul class="makeMenu">';
if (WT_USER_ID) {
echo '<li><a href="edituser.php" class="link">', WT_Filter::escapeHtml(Auth::user()->getRealName()), '</a></li><li>', logout_link(), '</li>';
if (WT_USER_CAN_ACCEPT && exists_pending_change()) {
echo ' <li><a href="#" onclick="window.open(\'edit_changes.php\',\'_blank\', chan_window_specs); return false;" style="color:red;">', WT_I18N::translate('Pending changes'), '</a></li>';
}
} else {
echo '<li>', login_link(), '</li>';
}
$menu = WT_MenuBar::getFavoritesMenu();
if ($menu) {
echo $menu->getMenuAsList();
}
$menu = WT_MenuBar::getLanguageMenu();
if ($menu) {
echo $menu->getMenuAsList();
}
$menu = WT_MenuBar::getThemeMenu();
示例8: getActionButtons
function getActionButtons($xref)
{
if (Auth::user()->getSetting('auto_accept')) {
return array(batch_update::createSubmitButton(WT_I18N::translate('Update'), $xref, 'update'), batch_update::createSubmitButton(WT_I18N::translate('Update all'), $xref, 'update_all'));
} else {
return array(batch_update::createSubmitButton(WT_I18N::translate('Update'), $xref, 'update'));
}
}
示例9: pasteid
break;
case "note":
$controller->setPageTitle(WT_I18N::translate('Find a shared note'));
break;
case "source":
$controller->setPageTitle(WT_I18N::translate('Find a source'));
break;
case "specialchar":
$controller->setPageTitle(WT_I18N::translate('Find a special character'));
$language_filter = WT_Filter::get('language_filter');
if (Auth::id()) {
// Users will probably always want the same language, so remember their setting
if (!$language_filter) {
$language_filter = Auth::user()->getSetting('default_language_filter');
} else {
Auth::user()->setSetting('default_language_filter', $language_filter);
}
}
require WT_ROOT . 'includes/specialchars.php';
$action = "filter";
break;
case "facts":
$controller->setPageTitle(WT_I18N::translate('Find a fact or event'))->addInlineJavascript('initPickFact();');
break;
}
$controller->pageHeader();
echo '<script>';
?>
function pasteid(id, name, thumb) {
if (thumb) {
window.opener.<?php
示例10:
?>
<div id="header">
<div class="header_img">
<img src="<?php
echo WT_CSS_URL;
?>
images/webtrees.png" width="242" height="50" alt="<?php
echo WT_WEBTREES;
?>
">
</div>
<ul id="extra-menu" class="makeMenu">
<li>
<?php
if (WT_USER_ID) {
echo '<a href="edituser.php">', WT_I18N::translate('Logged in as '), ' ', WT_Filter::escapeHtml(Auth::user()->getRealName()), '</a></li> <li>', logout_link();
} else {
echo login_link();
}
?>
</li>
<?php
echo WT_MenuBar::getFavoritesMenu();
?>
<?php
echo WT_MenuBar::getThemeMenu();
?>
<?php
echo WT_MenuBar::getLanguageMenu();
?>
</ul>
示例11: checkbox
<div class="label">', WT_I18N::translate('Password'), help_link('password'), '</div>
<div class="value"><input type="password" name="form_pass1"> ', WT_I18N::translate('Leave password blank if you want to keep the current password.'), '</div>
<div class="label">', WT_I18N::translate('Confirm password'), help_link('password_confirm'), '</div>
<div class="value"><input type="password" name="form_pass2"></div>
<div class="label">', WT_I18N::translate('Language'), '</div>
<div class="value">', edit_field_language('form_language', Auth::user()->getSetting('language')), '</div>
<div class="label">', WT_I18N::translate('Email address'), help_link('email'), '</div>
<div class="value"><input type="email" name="form_email" value="', WT_Filter::escapeHtml(Auth::user()->getEmail()), '" size="50"></div>
<div class="label">', WT_I18N::translate('Theme'), help_link('THEME'), '</div>
<div class="value">
<select name="form_theme">
<option value="">', WT_Filter::escapeHtml(WT_I18N::translate('<default theme>')), '</option>';
foreach (get_theme_names() as $themename => $themedir) {
echo '<option value="', $themedir, '"';
if ($themedir == Auth::user()->getSetting('theme')) {
echo ' selected="selected"';
}
echo '>', $themename, '</option>';
}
echo '</select>
</div>
<div class="label">', WT_I18N::translate('Preferred contact method'), help_link('edituser_contact_meth'), '</div>
<div class="value">', edit_field_contact('form_contact_method', Auth::user()->getSetting('contactmethod')), '</div>
<div class="label">', WT_I18N::translate('Visible to other users when online'), help_link('useradmin_visibleonline'), '</div>
<div class="value">', checkbox('form_visible_online', Auth::user()->getSetting('visibleonline')), '</div>
</div>';
// close edituser-table
echo '<div id="edituser_submit"><input type="submit" value="', WT_I18N::translate('save'), '"></div>';
echo '</form>
</div>';
// close edituser-page
示例12: login
private function login($user_id)
{
global $WT_SESSION;
$user = User::find($user_id);
$user_name = $user->getUserName();
// Below copied from authenticateUser in authentication.php
$is_admin = $user->getPreference('canadmin');
$verified = $user->getPreference('verified');
$approved = $user->getPreference('verified_by_admin');
if ($verified && $approved || $is_admin) {
Auth::login($user);
Log::addAuthenticationLog('Login: ' . Auth::user()->getUserName() . '/' . Auth::user()->getRealName());
$WT_SESSION->locale = Auth::user()->getPreference('language');
$WT_SESSION->theme_dir = Auth::user()->getPreference('theme');
$WT_SESSION->activity_time = WT_TIMESTAMP;
$user->setPreference('sessiontime', WT_TIMESTAMP);
Zend_Session::writeClose();
return $user_id;
} elseif (!$is_admin && !$verified) {
Log::addAuthenticationLog('Login failed ->' . $user_name . '<- not verified');
return -1;
} elseif (!$is_admin && !$approved) {
Log::addAuthenticationLog('Login failed ->' . $user_name . '<- not approved');
return -2;
}
throw new Exception('Login failure: Unexpected condition');
}
示例13: deleteRecord
public function deleteRecord()
{
// Create a pending change
WT_DB::prepare("INSERT INTO `##change` (gedcom_id, xref, old_gedcom, new_gedcom, user_id) VALUES (?, ?, ?, '', ?)")->execute(array($this->gedcom_id, $this->xref, $this->getGedcom(), Auth::id()));
// Accept this pending change
if (Auth::user()->getSetting('auto_accept')) {
accept_all_changes($this->xref, $this->gedcom_id);
}
// Clear the cache
self::$gedcom_record_cache = null;
self::$pending_record_cache = null;
Log::addEditLog('Delete: ' . static::RECORD_TYPE . ' ' . $this->xref);
}
示例14: header
$recordsTotal = WT_DB::prepare($SELECT2 . $WHERE)->execute($args)->fetchOne();
header('Content-type: application/json');
echo json_encode(array('draw' => WT_Filter::getInteger('draw'), 'recordsTotal' => $recordsTotal, 'recordsFiltered' => $recordsFiltered, 'data' => $data));
exit;
}
$controller->pageHeader()->addExternalJavascript(WT_JQUERY_DATATABLES_URL)->addInlineJavascript('
jQuery("#log_list").dataTable( {
"dom": \'<"H"pf<"dt-clear">irl>t<"F"pl>\',
"processing": true,
"serverSide": true,
"ajax": "' . WT_SERVER_NAME . WT_SCRIPT_PATH . WT_SCRIPT_NAME . '?action=load_json&from=' . $from . '&to=' . $to . '&type=' . $type . '&oldged=' . rawurlencode($oldged) . '&newged=' . rawurlencode($newged) . '&xref=' . rawurlencode($xref) . '&user=' . rawurlencode($user) . '&gedc=' . rawurlencode($gedc) . '",
' . WT_I18N::datatablesI18N(array(10, 20, 50, 100, 500, 1000, -1)) . ',
jQueryUI: true,
autoWidth: false,
sorting: [[ 0, "desc" ]],
pageLength: ' . Auth::user()->getSetting('admin_site_change_page_size', 10) . ',
pagingType: "full_numbers",
columns: [
/* Timestamp */ { },
/* Status */ { },
/* Record */ { },
/* Old data */ { class: "raw_gedcom", sortable: false },
/* New data */ { class: "raw_gedcom", sortable: false },
/* User */ { },
/* Family tree */ { }
]
});
');
$url = WT_SCRIPT_NAME . '?from=' . rawurlencode($from) . '&to=' . rawurlencode($to) . '&type=' . rawurlencode($type) . '&oldged=' . rawurlencode($oldged) . '&newged=' . rawurlencode($newged) . '&xref=' . rawurlencode($xref) . '&user=' . rawurlencode($user) . '&gedc=' . rawurlencode($gedc);
$users_array = array();
foreach (User::all() as $tmp_user) {
示例15: init
/**
* Initialise the translation adapter with a locale setting.
*
* @param string|null $locale If no locale specified, choose one automatically
*
* @return string $string
*/
public static function init($locale = null)
{
global $WT_SESSION;
// The translation libraries only work with a cache.
$cache_options = array('automatic_serialization' => true, 'cache_id_prefix' => md5(WT_SERVER_NAME . WT_SCRIPT_PATH));
if (ini_get('apc.enabled')) {
self::$cache = Zend_Cache::factory('Core', 'Apc', $cache_options, array());
} elseif (WT_File::mkdir(WT_DATA_DIR . 'cache')) {
self::$cache = Zend_Cache::factory('Core', 'File', $cache_options, array('cache_dir' => WT_DATA_DIR . 'cache'));
} else {
self::$cache = Zend_Cache::factory('Core', 'Zend_Cache_Backend_BlackHole', $cache_options, array(), false, true);
}
Zend_Locale::setCache(self::$cache);
Zend_Translate::setCache(self::$cache);
$installed_languages = self::installed_languages();
if (is_null($locale) || !array_key_exists($locale, $installed_languages)) {
// Automatic locale selection.
$locale = WT_Filter::get('lang');
if ($locale && array_key_exists($locale, $installed_languages)) {
// Requested in the URL?
if (Auth::id()) {
Auth::user()->setSetting('language', $locale);
}
} elseif (array_key_exists($WT_SESSION->locale, $installed_languages)) {
// Rembered from a previous visit?
$locale = $WT_SESSION->locale;
} else {
// Browser preference takes priority over gedcom default
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$prefs = explode(',', str_replace(' ', '', $_SERVER['HTTP_ACCEPT_LANGUAGE']));
} else {
$prefs = array();
}
if (WT_GED_ID) {
// Add the tree’s default language as a low-priority
$locale = get_gedcom_setting(WT_GED_ID, 'LANGUAGE');
$prefs[] = $locale . ';q=0.2';
}
$prefs2 = array();
foreach ($prefs as $pref) {
list($l, $q) = explode(';q=', $pref . ';q=1.0');
$l = preg_replace_callback('/_[a-z][a-z]$/', function ($x) {
return strtoupper($x[0]);
}, str_replace('-', '_', $l));
// en-gb => en_GB
if (array_key_exists($l, $prefs2)) {
$prefs2[$l] = max((double) $q, $prefs2[$l]);
} else {
$prefs2[$l] = (double) $q;
}
}
// Ensure there is a fallback.
if (!array_key_exists('en_US', $prefs2)) {
$prefs2['en_US'] = 0.01;
}
arsort($prefs2);
foreach (array_keys($prefs2) as $pref) {
if (array_key_exists($pref, $installed_languages)) {
$locale = $pref;
break;
}
}
}
}
// Load the translation file
self::$translation_adapter = new Zend_Translate('gettext', WT_ROOT . 'language/' . $locale . '.mo', $locale);
// Deprecated - some custom modules use this to add translations
Zend_Registry::set('Zend_Translate', self::$translation_adapter);
// Load any local user translations
if (is_dir(WT_DATA_DIR . 'language')) {
if (file_exists(WT_DATA_DIR . 'language/' . $locale . '.mo')) {
self::addTranslation(new Zend_Translate('gettext', WT_DATA_DIR . 'language/' . $locale . '.mo', $locale));
}
if (file_exists(WT_DATA_DIR . 'language/' . $locale . '.php')) {
self::addTranslation(new Zend_Translate('array', WT_DATA_DIR . 'language/' . $locale . '.php', $locale));
}
if (file_exists(WT_DATA_DIR . 'language/' . $locale . '.csv')) {
self::addTranslation(new Zend_Translate('csv', WT_DATA_DIR . 'language/' . $locale . '.csv', $locale));
}
}
// Extract language settings from the translation file
global $DATE_FORMAT;
// I18N: This is the format string for full dates. See http://php.net/date for codes
$DATE_FORMAT = self::noop('%j %F %Y');
global $TIME_FORMAT;
// I18N: This is the format string for the time-of-day. See http://php.net/date for codes
$TIME_FORMAT = self::noop('%H:%i:%s');
// Alphabetic sorting sequence (upper-case letters), used by webtrees to sort strings
list(, self::$alphabet_upper) = explode('=', self::noop('ALPHABET_upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ'));
// Alphabetic sorting sequence (lower-case letters), used by webtrees to sort strings
list(, self::$alphabet_lower) = explode('=', self::noop('ALPHABET_lower=abcdefghijklmnopqrstuvwxyz'));
global $WEEK_START;
// I18N: This is the first day of the week on calendars. 0=Sunday, 1=Monday...
//.........这里部分代码省略.........