本文整理汇总了PHP中WT_Site::getPreference方法的典型用法代码示例。如果您正苦于以下问题:PHP WT_Site::getPreference方法的具体用法?PHP WT_Site::getPreference怎么用?PHP WT_Site::getPreference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_Site
的用法示例。
在下文中一共展示了WT_Site::getPreference方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch_latest_version
function fetch_latest_version()
{
$last_update_timestamp = WT_Site::getPreference('LATEST_WT_VERSION_TIMESTAMP');
if ($last_update_timestamp < WT_TIMESTAMP - 24 * 60 * 60) {
$row = WT_DB::prepare("SHOW VARIABLES LIKE 'version'")->fetchOneRow();
$params = '?w=' . WT_VERSION . '&p=' . PHP_VERSION . '&m=' . $row->value . '&o=' . (DIRECTORY_SEPARATOR == '/' ? 'u' : 'w');
$latest_version_txt = WT_File::fetchUrl('http://svn.webtrees.net/build/latest-version.txt' . $params);
if ($latest_version_txt) {
WT_Site::setPreference('LATEST_WT_VERSION', $latest_version_txt);
WT_Site::setPreference('LATEST_WT_VERSION_TIMESTAMP', WT_TIMESTAMP);
return $latest_version_txt;
} else {
// Cannot connect to server - use cached version (if we have one)
return WT_Site::getPreference('LATEST_WT_VERSION');
}
} else {
return WT_Site::getPreference('LATEST_WT_VERSION');
}
}
示例2: transport
public static function transport()
{
switch (WT_Site::getPreference('SMTP_ACTIVE')) {
case 'internal':
return new Zend_Mail_Transport_Sendmail();
case 'external':
$config = array('name' => WT_Site::getPreference('SMTP_HELO'), 'port' => WT_Site::getPreference('SMTP_PORT'));
if (WT_Site::getPreference('SMTP_AUTH')) {
$config['auth'] = 'login';
$config['username'] = WT_Site::getPreference('SMTP_AUTH_USER');
$config['password'] = WT_Site::getPreference('SMTP_AUTH_PASS');
}
if (WT_Site::getPreference('SMTP_SSL') !== 'none') {
$config['ssl'] = WT_Site::getPreference('SMTP_SSL');
}
return new Zend_Mail_Transport_Smtp(WT_Site::getPreference('SMTP_HOST'), $config);
default:
// For testing
return new Zend_Mail_Transport_File();
}
}
示例3: getBlock
public function getBlock($block_id, $template = true, $cfg = null)
{
global $controller;
$indi_xref = $controller->getSignificantIndividual()->getXref();
$id = $this->getName() . $block_id;
$class = $this->getName() . '_block';
$title = '<span dir="auto">' . WT_TREE_TITLE . '</span>';
$content = '<table><tr>';
$content .= '<td><a href="pedigree.php?rootid=' . $indi_xref . '&ged=' . WT_GEDURL . '"><i class="icon-pedigree"></i><br>' . WT_I18N::translate('Default chart') . '</a></td>';
$content .= '<td><a href="individual.php?pid=' . $indi_xref . '&ged=' . WT_GEDURL . '"><i class="icon-indis"></i><br>' . WT_I18N::translate('Default individual') . '</a></td>';
if (WT_Site::getPreference('USE_REGISTRATION_MODULE') && WT_USER_ID == false) {
$content .= '<td><a href="' . WT_LOGIN_URL . '?action=register"><i class="icon-user_add"></i><br>' . WT_I18N::translate('Request new user account') . '</a></td>';
}
$content .= "</tr>";
$content .= "</table>";
if ($template) {
require WT_THEME_DIR . 'templates/block_main_temp.php';
} else {
return $content;
}
}
示例4: color_theme_dropdown
function color_theme_dropdown()
{
global $COLOR_THEME_LIST, $WT_SESSION, $subColor;
$menu = new WT_Menu(WT_I18N::translate('Palette'), '#', 'menu-color');
uasort($COLOR_THEME_LIST, array('WT_I18N', 'strcasecmp'));
foreach ($COLOR_THEME_LIST as $colorChoice => $colorName) {
$submenu = new WT_Menu($colorName, get_query_url(array('themecolor' => $colorChoice), '&'), 'menu-color-' . $colorChoice);
if (isset($WT_SESSION->subColor)) {
if ($WT_SESSION->subColor == $colorChoice) {
$submenu->addClass('', '', 'theme-active');
}
} elseif (WT_Site::getPreference('DEFAULT_COLOR_PALETTE') == $colorChoice) {
/* here when visitor changes palette from default */
$submenu->addClass('', '', 'theme-active');
} elseif ($subColor == 'ash') {
/* here when site has different theme as default and user switches to colors */
if ($subColor == $colorChoice) {
$submenu->addClass('', '', 'theme-active');
}
}
$menu->addSubMenu($submenu);
}
return $menu->getMenuAsList();
}
示例5: historical_facts
private static function historical_facts(WT_Individual $person)
{
global $SHOW_RELATIVES_EVENTS;
$facts = array();
if ($SHOW_RELATIVES_EVENTS) {
// Only include events between birth and death
$birt_date = $person->getEstimatedBirthDate();
$deat_date = $person->getEstimatedDeathDate();
if (file_exists(WT_Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php')) {
require WT_Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php';
foreach ($histo as $hist) {
// Earlier versions of the WIKI encouraged people to use HTML entities,
// rather than UTF8 encoding.
$hist = html_entity_decode($hist, ENT_QUOTES, 'UTF-8');
$fact = new WT_Fact($hist, $person, 'histo');
$sdate = $fact->getDate();
if ($sdate->isOK() && WT_Date::Compare($birt_date, $sdate) <= 0 && WT_Date::Compare($sdate, $deat_date) <= 0) {
$facts[] = $fact;
}
}
}
}
return $facts;
}
示例6: updateSchema
/**
* Run a series of scripts to bring the database schema up to date.
*
* @param $schema_dir
* @param $schema_name
* @param $target_version
*
* @return void
* @throws Exception
*/
public static function updateSchema($schema_dir, $schema_name, $target_version)
{
try {
$current_version = (int) WT_Site::getPreference($schema_name);
} catch (PDOException $e) {
// During initial installation, this table won’t exist.
// It will only be a problem if we can’t subsequently create it.
$current_version = 0;
}
// During installation, the current version is set to a special value of
// -1 (v1.2.5 to v1.2.7) or -2 (v1.3.0 onwards). This indicates that the tables have
// been created, and we are already at the latest version.
switch ($current_version) {
case -1:
// Due to a bug in webtrees 1.2.5 - 1.2.7, the setup value of "-1"
// wasn't being updated.
$current_version = 12;
WT_Site::setPreference($schema_name, $current_version);
break;
case -2:
// Because of the above bug, we now set the version to -2 during setup.
$current_version = $target_version;
WT_Site::setPreference($schema_name, $current_version);
break;
}
// Update the schema, one version at a time.
while ($current_version < $target_version) {
$next_version = $current_version + 1;
require $schema_dir . 'db_schema_' . $current_version . '_' . $next_version . '.php';
// The updatescript should update the version or throw an exception
$current_version = (int) WT_Site::getPreference($schema_name);
if ($current_version != $next_version) {
throw new Exception("Internal error while updating {$schema_name} to {$next_version}");
}
}
}
示例7: delete
public static function delete($tree_id)
{
// If this is the default tree, then unset
if (WT_Site::getPreference('DEFAULT_GEDCOM') == self::getNameFromId($tree_id)) {
WT_Site::setPreference('DEFAULT_GEDCOM', '');
}
// Don't delete the logs.
WT_DB::prepare("UPDATE `##log` SET gedcom_id=NULL WHERE gedcom_id =?")->execute(array($tree_id));
WT_DB::prepare("DELETE `##block_setting` FROM `##block_setting` JOIN `##block` USING (block_id) WHERE gedcom_id=?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##block` WHERE gedcom_id =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##dates` WHERE d_file =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##families` WHERE f_file =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##user_gedcom_setting` WHERE gedcom_id =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##gedcom_setting` WHERE gedcom_id =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##individuals` WHERE i_file =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##link` WHERE l_file =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##media` WHERE m_file =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##module_privacy` WHERE gedcom_id =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##name` WHERE n_file =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##next_id` WHERE gedcom_id =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##other` WHERE o_file =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##placelinks` WHERE pl_file =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##places` WHERE p_file =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##sources` WHERE s_file =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##hit_counter` WHERE gedcom_id =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##change` WHERE gedcom_id =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##default_resn` WHERE gedcom_id =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##gedcom_chunk` WHERE gedcom_id =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##log` WHERE gedcom_id =?")->execute(array($tree_id));
WT_DB::prepare("DELETE FROM `##gedcom` WHERE gedcom_id =?")->execute(array($tree_id));
// After updating the database, we need to fetch a new (sorted) copy
self::$trees = null;
}
示例8: edit_field_yes_no_inline
</dt>
<dd><?php
echo edit_field_yes_no_inline('site_setting-USE_REGISTRATION_MODULE', WT_Site::getPreference('USE_REGISTRATION_MODULE'), $controller);
?>
</dd>
<dt><?php
echo WT_I18N::translate('Require an administrator to approve new user registrations'), help_link('REQUIRE_ADMIN_AUTH_REGISTRATION');
?>
</dt>
<dd><?php
echo edit_field_yes_no_inline('site_setting-REQUIRE_ADMIN_AUTH_REGISTRATION', WT_Site::getPreference('REQUIRE_ADMIN_AUTH_REGISTRATION'), $controller);
?>
</dd>
<dt><?php
echo WT_I18N::translate('Show acceptable use agreement on “Request new user account” page'), help_link('SHOW_REGISTER_CAUTION');
?>
</dt>
<dd><?php
echo edit_field_yes_no_inline('site_setting-SHOW_REGISTER_CAUTION', WT_Site::getPreference('SHOW_REGISTER_CAUTION'), $controller);
?>
</dd>
</dl>
</td>
</tr>
</table>
</div>
</div>
</div>
示例9: header
}
} else {
header('HTTP/1.0 406 Not Acceptable');
}
break;
case 'reject-changes':
// Reject all the pending changes for a record
$record = WT_GedcomRecord::getInstance(WT_Filter::post('xref', WT_REGEX_XREF));
if ($record && WT_USER_CAN_ACCEPT && $record->canShow() && $record->canEdit()) {
WT_FlashMessages::addMessage(WT_I18N::translate('The changes to “%s” have been rejected.', $record->getFullName()));
reject_all_changes($record->getXref(), $record->getGedcomId());
} else {
header('HTTP/1.0 406 Not Acceptable');
}
break;
case 'theme':
// Change the current theme
$theme_dir = WT_Filter::post('theme');
if (WT_Site::getPreference('ALLOW_USER_THEMES') && in_array($theme_dir, get_theme_names())) {
$WT_SESSION->theme_dir = $theme_dir;
if (Auth::id()) {
// Remember our selection
Auth::user()->setSetting('theme', $theme_dir);
}
} else {
// Request for a non-existant theme.
header('HTTP/1.0 406 Not Acceptable');
}
break;
}
Zend_Session::writeClose();
示例10: get_gedcom_setting
$THEME_DIR = $WT_SESSION->theme_dir;
}
} else {
$THEME_DIR = '';
}
if (!$THEME_DIR) {
// User cannot choose (or has not chosen) a theme.
// 1) gedcom setting
// 2) site setting
// 3) webtrees
// 4) first one found
if (WT_GED_ID) {
$THEME_DIR = get_gedcom_setting(WT_GED_ID, 'THEME_DIR');
}
if (!in_array($THEME_DIR, get_theme_names())) {
$THEME_DIR = WT_Site::getPreference('THEME_DIR');
}
if (!in_array($THEME_DIR, get_theme_names())) {
$THEME_DIR = 'webtrees';
}
if (!in_array($THEME_DIR, get_theme_names())) {
list($THEME_DIR) = get_theme_names();
}
}
define('WT_THEME_DIR', WT_THEMES_DIR . $THEME_DIR . '/');
// Remember this setting
if (WT_THEME_DIR != WT_THEMES_DIR . '_administration/') {
$WT_SESSION->theme_dir = $THEME_DIR;
}
}
// If we have specified a CDN, use it for static theme resources
示例11: login_or_register
/**
* If the Facebook username or email is associated with an account, login to it. Otherwise, register a new account.
*
* @param object $facebookUser Facebook user
* @param string $url (optional) URL to redirect to afterwards.
*/
private function login_or_register(&$facebookUser, $url = '')
{
$REQUIRE_ADMIN_AUTH_REGISTRATION = WT_Site::getPreference('REQUIRE_ADMIN_AUTH_REGISTRATION');
if ($this->getSetting('require_verified', 1) && empty($facebookUser->verified)) {
$this->error_page(WT_I18N::translate('Only verified Facebook accounts are authorized. Please verify your account on Facebook and then try again'));
}
if (empty($facebookUser->username)) {
$facebookUser->username = $facebookUser->id;
}
$user_id = $this->get_user_id_from_facebook_username($facebookUser->username);
if (!$user_id) {
if (!isset($facebookUser->email)) {
$this->error_page(WT_I18N::translate('You must grant access to your email address via Facebook in order to use this website. Please uninstall the application on Facebook and try again.'));
}
$user = User::findByIdentifier($facebookUser->email);
if ($user) {
$user_id = $user->getUserId();
}
}
if ($user_id) {
// This is an existing user so log them in if they are approved
$login_result = $this->login($user_id);
$message = '';
switch ($login_result) {
case -1:
// not validated
$message = WT_I18N::translate('This account has not been verified. Please check your email for a verification message.');
break;
case -2:
// not approved
$message = WT_I18N::translate('This account has not been approved. Please wait for an administrator to approve it.');
break;
default:
$user = User::find($user_id);
$user->setPreference(self::user_setting_facebook_username, $this->cleanseFacebookUsername($facebookUser->username));
// redirect to the homepage/$url
header('Location: ' . WT_SCRIPT_PATH . $url);
return;
}
$this->error_page($message);
} else {
// This is a new Facebook user who may or may not already have a manual account
if (!WT_Site::getPreference('USE_REGISTRATION_MODULE')) {
$this->error_page('<p>' . WT_I18N::translate('The administrator has disabled registrations.') . '</p>');
}
// check if the username is already in use
$username = $this->cleanseFacebookUsername($facebookUser->username);
$wt_username = substr($username, 0, 32);
// Truncate the username to 32 characters to match the DB.
if (User::findByIdentifier($wt_username)) {
// fallback to email as username since we checked above that a user with the email didn't exist.
$wt_username = $facebookUser->email;
$wt_username = substr($wt_username, 0, 32);
// Truncate the username to 32 characters to match the DB.
}
// Generate a random password since the user shouldn't need it and can always reset it.
$password = md5(uniqid(rand(), TRUE));
$hashcode = md5(uniqid(rand(), true));
$preApproved = unserialize($this->getSetting('preapproved'));
// From login.php:
Log::addAuthenticationLog('User registration requested for: ' . $wt_username);
if ($user = User::create($wt_username, $facebookUser->name, $facebookUser->email, $password)) {
$verifiedByAdmin = !$REQUIRE_ADMIN_AUTH_REGISTRATION || isset($preApproved[$username]);
$user->setPreference(self::user_setting_facebook_username, $this->cleanseFacebookUsername($facebookUser->username))->setPreference('language', WT_LOCALE)->setPreference('verified', '1')->setPreference('verified_by_admin', $verifiedByAdmin ? '1' : '0')->setPreference('reg_timestamp', date('U'))->setPreference('reg_hashcode', $hashcode)->setPreference('contactmethod', 'messaging2')->setPreference('visibleonline', '1')->setPreference('editaccount', '1')->setPreference('auto_accept', '0')->setPreference('canadmin', '0')->setPreference('sessiontime', $verifiedByAdmin ? WT_TIMESTAMP : '0')->setPreference('comment', @$facebookUser->birthday . "\n " . "https://www.facebook.com/" . $this->cleanseFacebookUsername($facebookUser->username));
// Apply pre-approval settings
if (isset($preApproved[$username])) {
$userSettings = $preApproved[$username];
foreach ($userSettings as $gedcom => $userGedcomSettings) {
foreach (array('gedcomid', 'rootid', 'canedit') as $userPref) {
if (empty($userGedcomSettings[$userPref])) {
continue;
}
// Use a direct DB query instead of $tree->setUserPreference since we
// can't get a reference to the WT_Tree since it checks permissions but
// we are trying to give the permissions.
WT_DB::prepare("REPLACE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, LEFT(?, 255))")->execute(array($user->getUserId(), $gedcom, $userPref, $userGedcomSettings[$userPref]));
}
}
// Remove the pre-approval record
unset($preApproved[$username]);
$this->setSetting('preapproved', serialize($preApproved));
}
// We need jQuery below
global $controller;
$controller = new WT_Controller_Page();
$controller->setPageTitle($this->getTitle())->pageHeader();
echo '<form id="verify-form" name="verify-form" method="post" action="', WT_LOGIN_URL, '" class="ui-autocomplete-loading" style="width:16px;height:16px;padding:0">';
echo $this->hidden_input("action", "verify_hash");
echo $this->hidden_input("user_name", $wt_username);
echo $this->hidden_input("user_password", $password);
echo $this->hidden_input("user_hashcode", $hashcode);
echo WT_Filter::getCsrf();
echo '</form>';
if ($verifiedByAdmin) {
//.........这里部分代码省略.........
示例12: __construct
function __construct()
{
parent::__construct();
// $action comes from GET (menus) or POST (form submission)
$this->action = WT_Filter::post('action', 'advanced|general|soundex|replace');
if (!$this->action) {
$this->action = WT_Filter::get('action', 'advanced|general|soundex|replace', 'general');
}
$topsearch = WT_Filter::postBool('topsearch');
if ($topsearch) {
$this->isPostBack = true;
$this->srfams = 'yes';
$this->srindi = 'yes';
$this->srsour = 'yes';
$this->srnote = 'yes';
}
// Get the query
$this->query = WT_Filter::post('query', '.{2,}');
$this->myquery = WT_Filter::escapeHtml($this->query);
$this->replace = WT_Filter::post('replace');
$this->replaceNames = WT_Filter::postBool('replaceNames');
$this->replacePlaces = WT_Filter::postBool('replacePlaces');
$this->replacePlacesWord = WT_Filter::postBool('replacePlacesWord');
$this->replaceAll = WT_Filter::postBool('replaceAll');
// TODO: fetch each variable independently, using appropriate validation
// Aquire all the variables values from the $_REQUEST
$varNames = array("isPostBack", "srfams", "srindi", "srsour", "srnote", "view", "soundex", "subaction", "nameprt", "showasso", "resultsPageNum", "resultsPerPage", "totalResults", "totalGeneralResults", "indiResultsPrinted", "famResultsPrinted", "srcResultsPrinted", "myindilist", "mysourcelist", "mynotelist", "myfamlist");
$this->setRequestValues($varNames);
if (!$this->isPostBack) {
// Enable the default gedcom for search
$str = str_replace(array(".", "-", " "), array("_", "_", "_"), WT_GEDCOM);
$_REQUEST["{$str}"] = $str;
}
// Retrieve the gedcoms to search in
if (count(WT_Tree::getAll()) > 1 && WT_Site::getPreference('ALLOW_CHANGE_GEDCOM')) {
foreach (WT_Tree::getAll() as $tree) {
$str = str_replace(array(".", "-", " "), array("_", "_", "_"), $tree->tree_name);
if (isset($_REQUEST["{$str}"]) || $topsearch) {
$this->sgeds[$tree->tree_id] = $tree->tree_name;
$_REQUEST["{$str}"] = 'yes';
}
}
} else {
$this->sgeds[WT_GED_ID] = WT_GEDCOM;
}
// vars use for soundex search
$this->firstname = WT_Filter::post('firstname');
$this->lastname = WT_Filter::post('lastname');
$this->place = WT_Filter::post('place');
$this->year = WT_Filter::post('year');
// Set the search result titles for soundex searches
if ($this->firstname || $this->lastname || $this->place) {
$this->myquery = WT_Filter::escapeHtml(implode(' ', array($this->firstname, $this->lastname, $this->place)));
}
if (!empty($_REQUEST["name"])) {
$this->name = $_REQUEST["name"];
$this->myname = $this->name;
} else {
$this->name = "";
$this->myname = "";
}
if (!empty($_REQUEST["birthdate"])) {
$this->birthdate = $_REQUEST["birthdate"];
$this->mybirthdate = $this->birthdate;
} else {
$this->birthdate = "";
$this->mybirthdate = "";
}
if (!empty($_REQUEST["birthplace"])) {
$this->birthplace = $_REQUEST["birthplace"];
$this->mybirthplace = $this->birthplace;
} else {
$this->birthplace = "";
$this->mybirthplace = "";
}
if (!empty($_REQUEST["deathdate"])) {
$this->deathdate = $_REQUEST["deathdate"];
$this->mydeathdate = $this->deathdate;
} else {
$this->deathdate = "";
$this->mydeathdate = "";
}
if (!empty($_REQUEST["deathplace"])) {
$this->deathplace = $_REQUEST["deathplace"];
$this->mydeathplace = $this->deathplace;
} else {
$this->deathplace = "";
$this->mydeathplace = "";
}
if (!empty($_REQUEST["gender"])) {
$this->gender = $_REQUEST["gender"];
$this->mygender = $this->gender;
} else {
$this->gender = "";
$this->mygender = "";
}
$this->inputFieldNames[] = "action";
$this->inputFieldNames[] = "isPostBack";
$this->inputFieldNames[] = "resultsPerPage";
$this->inputFieldNames[] = "query";
//.........这里部分代码省略.........
示例13: getThemeMenu
public static function getThemeMenu()
{
global $SEARCH_SPIDER;
if (WT_GED_ID && !$SEARCH_SPIDER && WT_Site::getPreference('ALLOW_USER_THEMES') && get_gedcom_setting(WT_GED_ID, 'ALLOW_THEME_DROPDOWN')) {
$menu = new WT_Menu(WT_I18N::translate('Theme'), '#', 'menu-theme');
foreach (get_theme_names() as $themename => $themedir) {
$submenu = new WT_Menu($themename, get_query_url(array('theme' => $themedir), '&'), 'menu-theme-' . $themedir);
if (WT_THEME_DIR == 'themes/' . $themedir . '/') {
$submenu->addClass('', '', 'theme-active');
}
$menu->addSubMenu($submenu);
}
return $menu;
} else {
return null;
}
}
示例14: help_link
<td>', WT_I18N::translate('Allow this user to edit his account information'), help_link('useradmin_editaccount'), '</td>
<td><input type="checkbox" name="editaccount" value="1" checked="checked"></td>
<tr>
<td>', WT_I18N::translate('Preferred contact method'), '</td>
<td>';
echo edit_field_contact('new_contact_method', $new_contact_method);
echo '</td>
<td>', WT_I18N::translate('Visible to other users when online'), help_link('useradmin_visibleonline'), '</td>
<td><input type="checkbox" name="visibleonline" value="1" checked="checked"></td>
</tr>
<tr>
</tr>
<tr>
<td>', WT_I18N::translate('Language'), '</td>
<td>', edit_field_language('user_language', $user_language), '</td>';
if (WT_Site::getPreference('ALLOW_USER_THEMES')) {
echo '<td>', WT_I18N::translate('Theme'), help_link('THEME'), '</td>
<td>
<select name="new_user_theme">
<option value="" selected="selected">', WT_Filter::escapeHtml(WT_I18N::translate('<default theme>')), '</option>';
foreach (get_theme_names() as $themename => $themedir) {
echo '<option value="', $themedir, '">', $themename, '</option>';
}
echo '</select>
</td>';
}
echo '</tr>';
if (Auth::isAdmin()) {
echo '<tr>
<td>', WT_I18N::translate('Admin comments on user'), '</td>
<td colspan="3"><textarea style="width:95%;" rows="5" name="new_comment" value="', WT_Filter::escapeHtml($new_comment), '"></textarea></td>
示例15: addMessage
function addMessage($message)
{
global $WT_TREE, $WT_REQUEST;
$success = true;
$sender = User::findByIdentifier($message['from']);
$recipient = User::findByIdentifier($message['to']);
// Sender may not be a webtrees user
if ($sender) {
$sender_email = $sender->getEmail();
$sender_real_name = $sender->getRealName();
} else {
$sender_email = $message['from'];
$sender_real_name = $message['from_name'];
}
// Send a copy of the copy message back to the sender.
if ($message['method'] != 'messaging') {
// Switch to the sender’s language.
if ($sender) {
WT_I18N::init($sender->getSetting('language'));
}
$copy_email = $message['body'];
if (!empty($message['url'])) {
$copy_email .= WT_Mail::EOL . WT_Mail::EOL . '--------------------------------------' . WT_Mail::EOL . WT_I18N::translate('This message was sent while viewing the following URL: ') . $message['url'] . WT_Mail::EOL;
}
$copy_email .= WT_Mail::auditFooter();
if ($sender) {
// Message from a logged-in user
$copy_email = WT_I18N::translate('You sent the following message to a webtrees user:') . ' ' . $recipient->getRealName() . WT_Mail::EOL . WT_Mail::EOL . $copy_email;
} else {
// Message from a visitor
$copy_email = WT_I18N::translate('You sent the following message to a webtrees administrator:') . WT_Mail::EOL . WT_Mail::EOL . WT_Mail::EOL . $copy_email;
}
$success = $success && WT_Mail::send($WT_TREE, $sender_email, $sender_real_name, WT_Site::getPreference('SMTP_FROM_NAME'), $WT_TREE->preference('title'), WT_I18N::translate('webtrees message') . ' - ' . $message['subject'], $copy_email);
}
// Switch to the recipient’s language.
WT_I18N::init($recipient->getSetting('language'));
if (isset($message['from_name'])) {
$message['body'] = WT_I18N::translate('Your name:') . ' ' . $message['from_name'] . WT_Mail::EOL . WT_I18N::translate('Email address:') . ' ' . $message['from_email'] . WT_Mail::EOL . WT_Mail::EOL . $message['body'];
}
// Add another footer - unless we are an admin
if (!Auth::isAdmin()) {
if (!empty($message['url'])) {
$message['body'] .= WT_Mail::EOL . WT_Mail::EOL . '--------------------------------------' . WT_Mail::EOL . WT_I18N::translate('This message was sent while viewing the following URL: ') . $message['url'] . WT_Mail::EOL;
}
$message['body'] .= WT_Mail::auditFooter();
}
if (empty($message['created'])) {
$message['created'] = gmdate("D, d M Y H:i:s T");
}
if ($message['method'] != 'messaging3' && $message['method'] != 'mailto' && $message['method'] != 'none') {
WT_DB::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)")->execute(array($message['from'], $WT_REQUEST->getClientIp(), $recipient->getUserId(), $message['subject'], str_replace('<br>', '', $message['body'])));
}
if ($message['method'] != 'messaging') {
if ($sender) {
$original_email = WT_I18N::translate('The following message has been sent to your webtrees user account from ');
$original_email .= $sender->getRealName();
} else {
$original_email = WT_I18N::translate('The following message has been sent to your webtrees user account from ');
if (!empty($message['from_name'])) {
$original_email .= $message['from_name'];
} else {
$original_email .= $message['from'];
}
}
$original_email .= WT_Mail::EOL . WT_Mail::EOL . $message['body'];
$success = $success && WT_Mail::send($WT_TREE, $recipient->getEmail(), $recipient->getRealName(), $sender_email, $sender_real_name, WT_I18N::translate('webtrees message') . ' - ' . $message['subject'], $original_email);
}
WT_I18N::init(WT_LOCALE);
// restore language settings if needed
return $success;
}