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; }
/** * Store a new message (of the appropriate type) in the message log. * * @param string $message * @param string $log_type * @param WT_Tree|null $tree */ private static function addLog($message, $log_type, WT_Tree $tree = null) { global $WT_REQUEST, $WT_TREE; if (!$tree) { $tree = $WT_TREE; } WT_DB::prepare("INSERT INTO `##log` (log_type, log_message, ip_address, user_id, gedcom_id) VALUES (?, ?, ?, ?, ?)")->execute(array($log_type, $message, $WT_REQUEST->getClientIp(), Auth::id(), $tree ? $tree->tree_id : null)); }
case "place": $controller->setPageTitle(WT_I18N::translate('Find a place')); break; case "repo": $controller->setPageTitle(WT_I18N::translate('Find a repository')); 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();
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA use WT\Auth; define('WT_SCRIPT_NAME', 'index_edit.php'); require './includes/session.php'; $controller = new WT_Controller_Ajax(); // Only one of $user_id and $gedcom_id should be set $user_id = WT_Filter::get('user_id', WT_REGEX_INTEGER, WT_Filter::post('user_id', WT_REGEX_INTEGER)); if ($user_id) { $gedcom_id = null; } else { $gedcom_id = WT_Filter::get('gedcom_id', WT_REGEX_INTEGER, WT_Filter::post('gedcom_id', WT_REGEX_INTEGER)); } // Only an admin can edit the "default" page // Only managers can edit the "home page" // Only a user or an admin can edit a user’s "my page" if ($gedcom_id < 0 && !Auth::isAdmin() || $gedcom_id > 0 && !Auth::isManager(WT_Tree::get($gedcom_id)) || $user_id && Auth::id() != $user_id && !Auth::isAdmin()) { $controller->pageHeader(); $controller->addInlineJavascript('window.location.reload();'); exit; } $action = WT_Filter::get('action'); if (isset($_REQUEST['main'])) { $main = $_REQUEST['main']; } else { $main = array(); } if (isset($_REQUEST['right'])) { $right = $_REQUEST['right']; } else { $right = array(); }
} 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) . '…';
/** * The authenticated user, from the current session. * * @return User|null */ public static function user() { return User::find(Auth::id()); }
// but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA use WT\Auth; use WT\Log; use WT\User; define('WT_SCRIPT_NAME', 'edituser.php'); require './includes/session.php'; require_once WT_ROOT . 'includes/functions/functions_print_lists.php'; require WT_ROOT . 'includes/functions/functions_edit.php'; // prevent users with editing account disabled from being able to edit their account if (!Auth::id() || !Auth::user()->getSetting('editaccount')) { header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH); exit; } // Valid values for form variables $ALL_THEMES_DIRS = array(); foreach (get_theme_names() as $themename => $themedir) { $ALL_THEME_DIRS[] = $themedir; } // Extract form variables $form_action = WT_Filter::post('form_action'); $form_username = WT_Filter::post('form_username'); $form_realname = WT_Filter::post('form_realname'); $form_pass1 = WT_Filter::post('form_pass1', WT_REGEX_PASSWORD); $form_pass2 = WT_Filter::post('form_pass2', WT_REGEX_PASSWORD); $form_email = WT_Filter::postEmail('form_email');
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); }
/** * 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... list(, $WEEK_START) = explode('=', self::noop('WEEK_START=0')); global $TEXT_DIRECTION; $TEXT_DIRECTION = self::scriptDirection(self::languageScript($locale)); self::$locale = $locale; self::$dir = $TEXT_DIRECTION; // I18N: This punctuation is used to separate lists of items. self::$list_separator = self::translate(', '); // I18N: This is the name of the MySQL collation that applies to your language. A list is available at http://dev.mysql.com/doc/refman/5.0/en/charset-unicode-sets.html self::$collation = self::translate('utf8_unicode_ci'); // Non-latin numbers may require non-latin digits try { self::$numbering_system = Zend_Locale_Data::getContent($locale, 'defaultnumberingsystem'); } catch (Zend_Locale_Exception $ex) { // The latest CLDR database omits some languges such as Tatar (tt) self::$numbering_system = 'latin'; } return $locale; }
private static function _getHitCount($page_name, $params) { if (is_array($params) && isset($params[0]) && $params[0] != '') { $page_parameter = $params[0]; } else { $page_parameter = ''; } if ($page_name === null) { // index.php?ctype=gedcom $page_name = 'index.php'; $page_parameter = 'gedcom:' . get_id_from_gedcom($page_parameter ? $page_parameter : WT_GEDCOM); } elseif ($page_name == 'index.php') { // index.php?ctype=user $user = User::findByIdentifier($page_parameter); $page_parameter = 'user:'******'<span class="hit-counter">' . WT_I18N::number($count) . '</span>'; }
// This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA use WT\Auth; define('WT_SCRIPT_NAME', 'block_edit.php'); require './includes/session.php'; $block_id = WT_Filter::getInteger('block_id'); $block = WT_DB::prepare("SELECT SQL_CACHE * FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOneRow(); // Check access. (1) the block must exist, (2) gedcom blocks require // managers, (3) user blocks require the user or an admin if (!$block || $block->gedcom_id && !Auth::isManager(WT_Tree::get($block->gedcom_id)) || $block->user_id && $block->user_id != Auth::id() && !Auth::isAdmin()) { exit; } $class_name = $block->module_name . '_WT_Module'; $block = new $class_name(); $controller = new WT_Controller_Ajax(); $controller->pageHeader(); if (array_key_exists('ckeditor', WT_Module::getActiveModules())) { ckeditor_WT_Module::enableEditor($controller); } ?> <form name="block" method="post" action="block_edit.php?block_id=<?php echo $block_id; ?> " onsubmit="return modalDialogSubmitAjax(this);" > <input type="hidden" name="save" value="1">