Example #1
0
 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;
 }
Example #2
0
 /**
  * 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));
 }
Example #3
0
 /**
  * get edit menu
  */
 function getEditMenu()
 {
     $SHOW_GEDCOM_RECORD = get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD');
     if (!$this->record || $this->record->isOld()) {
         return null;
     }
     // edit menu
     $menu = new WT_Menu(WT_I18N::translate('Edit'), '#', 'menu-obje');
     if (WT_USER_CAN_EDIT) {
         $submenu = new WT_Menu(WT_I18N::translate('Edit media object'), '#', 'menu-obje-edit');
         $submenu->addOnclick("window.open('addmedia.php?action=editmedia&pid={$this->record->getXref()}', '_blank', edit_window_specs)");
         $menu->addSubmenu($submenu);
         // main link displayed on page
         if (array_key_exists('GEDFact_assistant', WT_Module::getActiveModules())) {
             $submenu = new WT_Menu(WT_I18N::translate('Manage links'), '#', 'menu-obje-link');
             $submenu->addOnclick("return ilinkitem('" . $this->record->getXref() . "','manage');");
         } else {
             $submenu = new WT_Menu(WT_I18N::translate('Set link'), '#', 'menu-obje-link');
             $ssubmenu = new WT_Menu(WT_I18N::translate('To individual'), '#', 'menu-obje-link-indi');
             $ssubmenu->addOnclick("return ilinkitem('" . $this->record->getXref() . "','person');");
             $submenu->addSubMenu($ssubmenu);
             $ssubmenu = new WT_Menu(WT_I18N::translate('To family'), '#', 'menu-obje-link-fam');
             $ssubmenu->addOnclick("return ilinkitem('" . $this->record->getXref() . "','family');");
             $submenu->addSubMenu($ssubmenu);
             $ssubmenu = new WT_Menu(WT_I18N::translate('To source'), '#', 'menu-obje-link-sour');
             $ssubmenu->addOnclick("return ilinkitem('" . $this->record->getXref() . "','source');");
             $submenu->addSubMenu($ssubmenu);
         }
         $menu->addSubmenu($submenu);
     }
     // delete
     if (WT_USER_CAN_EDIT) {
         $submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-obje-del');
         $submenu->addOnclick("return delete_media('" . WT_I18N::translate('Are you sure you want to delete “%s”?', strip_tags($this->record->getFullName())) . "', '" . $this->record->getXref() . "');");
         $menu->addSubmenu($submenu);
     }
     // edit raw
     if (Auth::isAdmin() || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) {
         $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM'), '#', 'menu-obje-editraw');
         $submenu->addOnclick("return edit_raw('" . $this->record->getXref() . "');");
         $menu->addSubmenu($submenu);
     }
     // add to favorites
     if (array_key_exists('user_favorites', WT_Module::getActiveModules())) {
         $submenu = new WT_Menu(WT_I18N::translate('Add to favorites'), '#', 'menu-obje-addfav');
         $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'" . $this->record->getXref() . "'},function(){location.reload();})");
         $menu->addSubmenu($submenu);
     }
     //-- get the link for the first submenu and set it as the link for the main menu
     if (isset($menu->submenus[0])) {
         $link = $menu->submenus[0]->onclick;
         $menu->addOnclick($link);
     }
     return $menu;
 }
Example #4
0
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();
}
Example #5
0
 public function modAction($mod_action)
 {
     switch ($mod_action) {
         case 'admin_batch_update':
             $controller = new WT_Controller_Page();
             $controller->setPageTitle(WT_I18N::translate('Batch update'))->restrictAccess(Auth::isAdmin())->pageHeader();
             // TODO: these files should be methods in this class
             require WT_ROOT . WT_MODULES_DIR . $this->getName() . '/' . $mod_action . '.php';
             $mod = new batch_update();
             echo $mod->main();
             break;
         default:
             header('HTTP/1.0 404 Not Found');
     }
 }
Example #6
0
 /**
  * get edit menu
  */
 function getEditMenu()
 {
     $SHOW_GEDCOM_RECORD = get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD');
     if (!$this->record || $this->record->isOld()) {
         return null;
     }
     // edit menu
     $menu = new WT_Menu(WT_I18N::translate('Edit'), '#', 'menu-repo');
     if (WT_USER_CAN_EDIT) {
         $fact = $this->record->getFirstFact('NAME');
         $submenu = new WT_Menu(WT_I18N::translate('Edit repository'), '#', 'menu-repo-edit');
         if ($fact) {
             // Edit existing name
             $submenu->addOnclick('return edit_record(\'' . $this->record->getXref() . '\', \'' . $fact->getFactId() . '\');');
         } else {
             // Add new name
             $submenu->addOnclick('return add_fact(\'' . $this->record->getXref() . '\', \'NAME\');');
         }
         $menu->addSubmenu($submenu);
     }
     // delete
     if (WT_USER_CAN_EDIT) {
         $submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-repo-del');
         $submenu->addOnclick("return delete_repository('" . WT_I18N::translate('Are you sure you want to delete “%s”?', strip_tags($this->record->getFullName())) . "', '" . $this->record->getXref() . "');");
         $menu->addSubmenu($submenu);
     }
     // edit raw
     if (Auth::isAdmin() || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) {
         $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM'), '#', 'menu-repo-editraw');
         $submenu->addOnclick("return edit_raw('" . $this->record->getXref() . "');");
         $menu->addSubmenu($submenu);
     }
     // add to favorites
     if (array_key_exists('user_favorites', WT_Module::getActiveModules())) {
         $submenu = new WT_Menu(WT_I18N::translate('Add to favorites'), '#', 'menu-repo-addfav');
         $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&mod_action=menu-add-favorite',{xref:'" . $this->record->getXref() . "'},function(){location.reload();})");
         $menu->addSubmenu($submenu);
     }
     //-- get the link for the first submenu and set it as the link for the main menu
     if (isset($menu->submenus[0])) {
         $link = $menu->submenus[0]->onclick;
         $menu->addOnclick($link);
     }
     return $menu;
 }
Example #7
0
 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 . '&amp;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 . '&amp;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;
     }
 }
Example #8
0
 /**
  * PDF Setup - WT_Report_PDF
  */
 function setup()
 {
     parent::setup();
     // Setup the PDF class with custom size pages because WT supports more page sizes. If WT sends an unknown size name then the default would be A4
     $this->pdf = new PDF($this->orientation, parent::unit, array($this->pagew, $this->pageh), self::unicode, "UTF-8", self::diskcache);
     // Setup the PDF margins
     $this->pdf->setMargins($this->leftmargin, $this->topmargin, $this->rightmargin);
     $this->pdf->SetHeaderMargin($this->headermargin);
     $this->pdf->SetFooterMargin($this->footermargin);
     //Set auto page breaks
     $this->pdf->SetAutoPageBreak(true, $this->bottommargin);
     // Set font subsetting
     $this->pdf->setFontSubsetting(self::subsetting);
     // Setup PDF compression
     $this->pdf->SetCompression(self::compression);
     // Setup RTL support
     $this->pdf->setRTL($this->rtl);
     // Set the document information
     // Only admin should see the version number
     $appversion = WT_WEBTREES;
     if (Auth::isAdmin()) {
         $appversion .= " " . WT_VERSION;
     }
     $this->pdf->SetCreator($appversion . " (" . parent::wt_url . ")");
     // Not implemented yet - WT_Report_Base::setup()
     $this->pdf->SetAuthor($this->rauthor);
     $this->pdf->SetTitle($this->title);
     $this->pdf->SetSubject($this->rsubject);
     $this->pdf->SetKeywords($this->rkeywords);
     $this->pdf->setReport($this);
     if ($this->showGenText) {
         // The default style name for Generated by.... is 'genby'
         $element = new CellPDF(0, 10, 0, "C", "", "genby", 1, ".", ".", 0, 0, "", "", true);
         $element->addText($this->generatedby);
         $element->setUrl(parent::wt_url);
         $this->pdf->addFooter($element);
     }
 }
// (at your option) any later version.
//
// 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', 'admin_module_sidebar.php');
require 'includes/session.php';
require WT_ROOT . 'includes/functions/functions_edit.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('Module administration'))->pageHeader()->addInlineJavascript('
    jQuery("#sidebars_table").sortable({items: ".sortme", forceHelperSize: true, forcePlaceholderSize: true, opacity: 0.7, cursor: "move", axis: "y"});

    //-- update the order numbers after drag-n-drop sorting is complete
    jQuery("#sidebars_table").bind("sortupdate", function(event, ui) {
			jQuery("#"+jQuery(this).attr("id")+" input").each(
				function (index, value) {
					value.value = index+1;
				}
			);
		});
	');
$modules = WT_Module::getActiveSidebars(WT_GED_ID, WT_PRIV_HIDE);
$action = WT_Filter::post('action');
if ($action == 'update_mods' && WT_Filter::checkCsrf()) {
    foreach ($modules as $module_name => $module) {
Example #10
0
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// 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', 'admin_users_bulk.php');
require './includes/session.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('Send broadcast messages'))->pageHeader();
?>
<div id="users_bulk">
	<p>
		<a href="#" onclick="message('all', 'messaging2', ''); return false;">
			<?php 
echo WT_I18N::translate('Send message to all users');
?>
		</a>
	</p>
	<p>
		<a href="#" onclick="message('never_logged', 'messaging2', ''); return false;">
			<?php 
echo WT_I18N::translate('Send message to users who have never logged in');
?>
		</a>
Example #11
0
}
// 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?
Example #12
0
 /**
  * get edit menu
  */
 function getEditMenu()
 {
     $SHOW_GEDCOM_RECORD = get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD');
     if (!$this->record || $this->record->isOld()) {
         return null;
     }
     // edit menu
     $menu = new WT_Menu(WT_I18N::translate('Edit'), '#', 'menu-indi');
     $menu->addLabel($menu->label, 'down');
     // What behaviour shall we give the main menu?  If we leave it blank, the framework
     // will copy the first submenu - which may be edit-raw or delete.
     // As a temporary solution, make it edit the name
     $menu->addOnclick("return false;");
     if (WT_USER_CAN_EDIT) {
         foreach ($this->record->getFacts() as $fact) {
             if ($fact->getTag() == 'NAME' && $fact->canEdit()) {
                 $menu->addOnclick("return edit_name('" . $this->record->getXref() . "', '" . $fact->getFactId() . "');");
             }
             break;
         }
         $submenu = new WT_Menu(WT_I18N::translate('Add a new name'), '#', 'menu-indi-addname');
         $submenu->addOnclick("return add_name('" . $this->record->getXref() . "');");
         $menu->addSubmenu($submenu);
         $has_sex_record = false;
         $submenu = new WT_Menu(WT_I18N::translate('Edit gender'), '#', 'menu-indi-editsex');
         foreach ($this->record->getFacts() as $fact) {
             if ($fact->getTag() == 'SEX' && $fact->canEdit()) {
                 $submenu->addOnclick("return edit_record('" . $this->record->getXref() . "', '" . $fact->getFactId() . "');");
                 $has_sex_record = true;
                 break;
             }
         }
         if (!$has_sex_record) {
             $submenu->addOnclick("return add_new_record('" . $this->record->getXref() . "', 'SEX');");
         }
         $menu->addSubmenu($submenu);
         if (count($this->record->getSpouseFamilies()) > 1) {
             $submenu = new WT_Menu(WT_I18N::translate('Re-order families'), '#', 'menu-indi-orderfam');
             $submenu->addOnclick("return reorder_families('" . $this->record->getXref() . "');");
             $menu->addSubmenu($submenu);
         }
     }
     // delete
     if (WT_USER_CAN_EDIT) {
         $submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-indi-del');
         $submenu->addOnclick("return delete_individual('" . WT_I18N::translate('Are you sure you want to delete “%s”?', WT_Filter::escapeJs(strip_tags($this->record->getFullName()))) . "', '" . $this->record->getXref() . "');");
         $menu->addSubmenu($submenu);
     }
     // edit raw
     if (Auth::isAdmin() || WT_USER_CAN_EDIT && $SHOW_GEDCOM_RECORD) {
         $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM'), '#', 'menu-indi-editraw');
         $submenu->addOnclick("return edit_raw('" . $this->record->getXref() . "');");
         $menu->addSubmenu($submenu);
     }
     // add to favorites
     if (array_key_exists('user_favorites', WT_Module::getActiveModules())) {
         $submenu = new WT_Menu(WT_I18N::translate('Add to favorites'), '#', 'menu-indi-addfav');
         $submenu->addOnclick("jQuery.post('module.php?mod=user_favorites&amp;mod_action=menu-add-favorite',{xref:'" . $this->record->getXref() . "'},function(){location.reload();})");
         $menu->addSubmenu($submenu);
     }
     return $menu;
 }
Example #13
0
//
// 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\User;
define('WT_SCRIPT_NAME', 'admin_pgv_to_wt.php');
require './includes/session.php';
//require WT_ROOT.'includes/functions/functions_edit.php';
// We can only import into an empty system, so deny access if we have already created a gedcom or added users.
if (WT_GED_ID || count(User::all()) > 1) {
    header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH);
    exit;
}
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('PhpGedView to webtrees transfer wizard'));
$error = '';
$warning = '';
$PGV_PATH = WT_Filter::post('PGV_PATH');
if ($PGV_PATH) {
    if (!is_dir($PGV_PATH) || !is_readable($PGV_PATH . '/config.php')) {
        $error = WT_I18N::translate('The specified directory does not contain an installation of PhpGedView');
    } else {
        // Load the configuration settings
        $config_php = file_get_contents($PGV_PATH . '/config.php');
        // The easiest way to do this is to exec() the file - but not lines containing require or PHP tags
        $config_php = preg_replace(array('/^\\s*(include|require).*/m', '/.*<\\?php.*/', '/.*\\?>.*/'), '', $config_php);
        eval($config_php);
        // $INDEX_DIRECTORY can be either absolute or relative to the PhpGedView root.
        if (preg_match('/^(\\/|\\|[A-Z]:)/', $INDEX_DIRECTORY)) {
            $INDEX_DIRECTORY = realpath($INDEX_DIRECTORY);
Example #14
0
    // Request to change color
    $subColor = $_GET['themecolor'];
    if (Auth::id()) {
        Auth::user()->setSetting('themecolor', $subColor);
        if (Auth::isAdmin()) {
            WT_Site::preference('DEFAULT_COLOR_PALETTE', $subColor);
        }
    }
    unset($_GET['themecolor']);
    // Rember that we have selected a value
    $WT_SESSION->subColor = $subColor;
}
// If we are logged in, use our preference
$subColor = null;
if (Auth::id()) {
    $subColor = Auth::user()->getSetting('themecolor');
}
// If not logged in or no preference, use one we selected earlier in the session?
if (!$subColor) {
    $subColor = $WT_SESSION->subColor;
}
// We haven't selected one this session?  Use the site default
if (!$subColor) {
    $subColor = WT_Site::preference('DEFAULT_COLOR_PALETTE');
}
// Make sure our selected palette actually exists
if (!array_key_exists($subColor, $COLOR_THEME_LIST)) {
    $subColor = 'ash';
}
// Theme name - this needs double quotes, as file is scanned/parsed by script
$theme_name = "colors";
Example #15
0
    private function adminPlaces()
    {
        require WT_ROOT . 'includes/functions/functions_edit.php';
        $action = WT_Filter::get('action');
        $parent = WT_Filter::get('parent');
        $inactive = WT_Filter::getBool('inactive');
        $deleteRecord = WT_Filter::get('deleteRecord');
        if (!isset($parent)) {
            $parent = 0;
        }
        $controller = new WT_Controller_Page();
        $controller->restrictAccess(Auth::isAdmin());
        if ($action == 'ExportFile' && Auth::isAdmin()) {
            Zend_Session::writeClose();
            $tmp = $this->placeIdToHierarchy($parent);
            $maxLevel = $this->getHighestLevel();
            if ($maxLevel > 8) {
                $maxLevel = 8;
            }
            $tmp[0] = 'places';
            $outputFileName = preg_replace('/[:;\\/\\\\(\\)\\{\\}\\[\\] $]/', '_', implode('-', $tmp)) . '.csv';
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename="' . $outputFileName . '"');
            echo '"', WT_I18N::translate('Level'), '";"', WT_I18N::translate('Country'), '";';
            if ($maxLevel > 0) {
                echo '"', WT_I18N::translate('State'), '";';
            }
            if ($maxLevel > 1) {
                echo '"', WT_I18N::translate('County'), '";';
            }
            if ($maxLevel > 2) {
                echo '"', WT_I18N::translate('City'), '";';
            }
            if ($maxLevel > 3) {
                echo '"', WT_I18N::translate('Place'), '";';
            }
            if ($maxLevel > 4) {
                echo '"', WT_I18N::translate('Place'), '";';
            }
            if ($maxLevel > 5) {
                echo '"', WT_I18N::translate('Place'), '";';
            }
            if ($maxLevel > 6) {
                echo '"', WT_I18N::translate('Place'), '";';
            }
            if ($maxLevel > 7) {
                echo '"', WT_I18N::translate('Place'), '";';
            }
            echo '"', WT_I18N::translate('Longitude'), '";"', WT_I18N::translate('Latitude'), '";';
            echo '"', WT_I18N::translate('Zoom level'), '";"', WT_I18N::translate('Icon'), '";', WT_EOL;
            $this->outputLevel($parent);
            exit;
        }
        $controller->setPageTitle(WT_I18N::translate('Google Maps™'))->pageHeader();
        ?>
		<table id="gm_config">
			<tr>
				<th>
					<a href="module.php?mod=googlemap&amp;mod_action=admin_config">
						<?php 
        echo WT_I18N::translate('Google Maps™ preferences');
        ?>
					</a>
				</th>
				<th>
					<a class="current" href="module.php?mod=googlemap&amp;mod_action=admin_places">
						<?php 
        echo WT_I18N::translate('Geographic data');
        ?>
					</a>
				</th>
				<th>
					<a href="module.php?mod=googlemap&amp;mod_action=admin_placecheck">
						<?php 
        echo WT_I18N::translate('Place check');
        ?>
					</a>
				</th>
			</tr>
		</table>
		<?php 
        if ($action == 'ImportGedcom') {
            $placelist = array();
            $j = 0;
            $gedcom_records = WT_DB::prepare("SELECT i_gedcom FROM `##individuals` WHERE i_file=? UNION ALL SELECT f_gedcom FROM `##families` WHERE f_file=?")->execute(array(WT_GED_ID, WT_GED_ID))->fetchOneColumn();
            foreach ($gedcom_records as $gedrec) {
                $i = 1;
                $placerec = get_sub_record(2, '2 PLAC', $gedrec, $i);
                while (!empty($placerec)) {
                    if (preg_match("/2 PLAC (.+)/", $placerec, $match)) {
                        $placelist[$j] = array();
                        $placelist[$j]['place'] = trim($match[1]);
                        if (preg_match("/4 LATI (.*)/", $placerec, $match)) {
                            $placelist[$j]['lati'] = trim($match[1]);
                            if ($placelist[$j]['lati'][0] != 'N' && $placelist[$j]['lati'][0] != 'S') {
                                if ($placelist[$j]['lati'] < 0) {
                                    $placelist[$j]['lati'][0] = 'S';
                                } else {
                                    $placelist[$j]['lati'] = 'N' . $placelist[$j]['lati'];
                                }
                            }
                        } else {
                            $placelist[$j]['lati'] = NULL;
                        }
                        if (preg_match("/4 LONG (.*)/", $placerec, $match)) {
                            $placelist[$j]['long'] = trim($match[1]);
                            if ($placelist[$j]['long'][0] != 'E' && $placelist[$j]['long'][0] != 'W') {
                                if ($placelist[$j]['long'] < 0) {
                                    $placelist[$j]['long'][0] = 'W';
                                } else {
                                    $placelist[$j]['long'] = 'E' . $placelist[$j]['long'];
                                }
                            }
                        } else {
                            $placelist[$j]['long'] = NULL;
                        }
                        $j = $j + 1;
                    }
                    $i = $i + 1;
                    $placerec = get_sub_record(2, '2 PLAC', $gedrec, $i);
                }
            }
            asort($placelist);
            $prevPlace = '';
            $prevLati = '';
            $prevLong = '';
            $placelistUniq = array();
            $j = 0;
            foreach ($placelist as $k => $place) {
                if ($place['place'] != $prevPlace) {
                    $placelistUniq[$j] = array();
                    $placelistUniq[$j]['place'] = $place['place'];
                    $placelistUniq[$j]['lati'] = $place['lati'];
                    $placelistUniq[$j]['long'] = $place['long'];
                    $j = $j + 1;
                } elseif ($place['place'] == $prevPlace && ($place['lati'] != $prevLati || $place['long'] != $prevLong)) {
                    if ($placelistUniq[$j - 1]['lati'] == 0 || $placelistUniq[$j - 1]['long'] == 0) {
                        $placelistUniq[$j - 1]['lati'] = $place['lati'];
                        $placelistUniq[$j - 1]['long'] = $place['long'];
                    } elseif ($place['lati'] != '0' || $place['long'] != '0') {
                        echo 'Difference: previous value = ', $prevPlace, ', ', $prevLati, ', ', $prevLong, ' current = ', $place['place'], ', ', $place['lati'], ', ', $place['long'], '<br>';
                    }
                }
                $prevPlace = $place['place'];
                $prevLati = $place['lati'];
                $prevLong = $place['long'];
            }
            $highestIndex = $this->getHighestIndex();
            $default_zoom_level = array(4, 7, 10, 12);
            foreach ($placelistUniq as $k => $place) {
                $parent = preg_split('/ *, */', $place['place']);
                $parent = array_reverse($parent);
                $parent_id = 0;
                for ($i = 0; $i < count($parent); $i++) {
                    if (!isset($default_zoom_level[$i])) {
                        $default_zoom_level[$i] = $default_zoom_level[$i - 1];
                    }
                    $escparent = $parent[$i];
                    if ($escparent == '') {
                        $escparent = 'Unknown';
                    }
                    $row = WT_DB::prepare("SELECT pl_id, pl_long, pl_lati, pl_zoom FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ?")->execute(array($i, $parent_id, $escparent))->fetchOneRow();
                    if ($i < count($parent) - 1) {
                        // Create higher-level places, if necessary
                        if (empty($row)) {
                            $highestIndex++;
                            WT_DB::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_zoom) VALUES (?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $default_zoom_level[$i]));
                            echo WT_Filter::escapeHtml($escparent), '<br>';
                            $parent_id = $highestIndex;
                        } else {
                            $parent_id = $row->pl_id;
                        }
                    } else {
                        // Create lowest-level place, if necessary
                        if (empty($row->pl_id)) {
                            $highestIndex++;
                            WT_DB::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_long, pl_lati, pl_zoom) VALUES (?, ?, ?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $place['long'], $place['lati'], $default_zoom_level[$i]));
                            echo WT_Filter::escapeHtml($escparent), '<br>';
                        } else {
                            if (empty($row->pl_long) && empty($row->pl_lati) && $place['lati'] != '0' && $place['long'] != '0') {
                                WT_DB::prepare("UPDATE `##placelocation` SET pl_lati=?, pl_long=? WHERE pl_id=?")->execute(array($place['lati'], $place['long'], $row->pl_id));
                                echo WT_Filter::escapeHtml($escparent), '<br>';
                            }
                        }
                    }
                }
            }
            $parent = 0;
        }
        if ($action == 'ImportFile') {
            $placefiles = array();
            $this->findFiles(WT_MODULES_DIR . 'googlemap/extra');
            sort($placefiles);
            ?>
		<form method="post" enctype="multipart/form-data" id="importfile" name="importfile" action="module.php?mod=googlemap&amp;mod_action=admin_places&amp;action=ImportFile2">
			<table class="gm_plac_edit">
				<tr>
					<th><?php 
            echo WT_I18N::translate('File containing places (CSV)');
            ?>
</th>
					<td><input type="file" name="placesfile" size="50"></td>
				</tr>
				<?php 
            if (count($placefiles) > 0) {
                ?>
				<tr>
					<th><?php 
                echo WT_I18N::translate('Server file containing places (CSV)'), help_link('PLIF_LOCALFILE', 'googlemap');
                ?>
</th>
					<td>
						<select name="localfile">
							<option></option>
							<?php 
                foreach ($placefiles as $p => $placefile) {
                    ?>
							<option value="<?php 
                    echo WT_Filter::escapeHtml($placefile);
                    ?>
"><?php 
                    if (substr($placefile, 0, 1) == "/") {
                        echo substr($placefile, 1);
                    } else {
                        echo $placefile;
                    }
                    ?>
</option>
							<?php 
                }
                ?>
						</select>
					</td>
				</tr>
				<?php 
            }
            ?>
				<tr>
					<th><?php 
            echo WT_I18N::translate('Delete all existing geographic data before importing the file.');
            ?>
</th>
					<td><input type="checkbox" name="cleardatabase"></td>
				</tr>
				<tr>
					<th><?php 
            echo WT_I18N::translate('Do not create new locations, just import coordinates for existing locations.');
            ?>
</th>
					<td><input type="checkbox" name="updateonly"></td>
				</tr>
				<tr>
					<th><?php 
            echo WT_I18N::translate('Overwrite existing coordinates.');
            ?>
</th>
					<td><input type="checkbox" name="overwritedata"></td>
				</tr>
			</table>
			<input id="savebutton" type="submit" value="<?php 
            echo WT_I18N::translate('Continue adding');
            ?>
"><br>
		</form>
		<?php 
            exit;
        }
        if ($action == 'ImportFile2') {
            $country_names = array();
            foreach (WT_Stats::iso3166() as $key => $value) {
                $country_names[$key] = WT_I18N::translate($key);
            }
            if (isset($_POST['cleardatabase'])) {
                WT_DB::exec("DELETE FROM `##placelocation` WHERE 1=1");
            }
            if (!empty($_FILES['placesfile']['tmp_name'])) {
                $lines = file($_FILES['placesfile']['tmp_name']);
            } elseif (!empty($_REQUEST['localfile'])) {
                $lines = file(WT_MODULES_DIR . 'googlemap/extra' . $_REQUEST['localfile']);
            }
            // Strip BYTE-ORDER-MARK, if present
            if (!empty($lines[0]) && substr($lines[0], 0, 3) == WT_UTF8_BOM) {
                $lines[0] = substr($lines[0], 3);
            }
            asort($lines);
            $highestIndex = $this->getHighestIndex();
            $placelist = array();
            $j = 0;
            $maxLevel = 0;
            foreach ($lines as $p => $placerec) {
                $fieldrec = explode(';', $placerec);
                if ($fieldrec[0] > $maxLevel) {
                    $maxLevel = $fieldrec[0];
                }
            }
            $fields = count($fieldrec);
            $set_icon = true;
            if (!is_dir(WT_MODULES_DIR . 'googlemap/places/flags/')) {
                $set_icon = false;
            }
            foreach ($lines as $p => $placerec) {
                $fieldrec = explode(';', $placerec);
                if (is_numeric($fieldrec[0]) && $fieldrec[0] <= $maxLevel) {
                    $placelist[$j] = array();
                    $placelist[$j]['place'] = '';
                    for ($ii = $fields - 4; $ii > 1; $ii--) {
                        if ($fieldrec[0] > $ii - 2) {
                            $placelist[$j]['place'] .= $fieldrec[$ii] . ',';
                        }
                    }
                    foreach ($country_names as $countrycode => $countryname) {
                        if ($countrycode == strtoupper($fieldrec[1])) {
                            $fieldrec[1] = $countryname;
                            break;
                        }
                    }
                    $placelist[$j]['place'] .= $fieldrec[1];
                    $placelist[$j]['long'] = $fieldrec[$fields - 4];
                    $placelist[$j]['lati'] = $fieldrec[$fields - 3];
                    $placelist[$j]['zoom'] = $fieldrec[$fields - 2];
                    if ($set_icon) {
                        $placelist[$j]['icon'] = trim($fieldrec[$fields - 1]);
                    } else {
                        $placelist[$j]['icon'] = '';
                    }
                    $j = $j + 1;
                }
            }
            $prevPlace = '';
            $prevLati = '';
            $prevLong = '';
            $placelistUniq = array();
            $j = 0;
            foreach ($placelist as $k => $place) {
                if ($place['place'] != $prevPlace) {
                    $placelistUniq[$j] = array();
                    $placelistUniq[$j]['place'] = $place['place'];
                    $placelistUniq[$j]['lati'] = $place['lati'];
                    $placelistUniq[$j]['long'] = $place['long'];
                    $placelistUniq[$j]['zoom'] = $place['zoom'];
                    $placelistUniq[$j]['icon'] = $place['icon'];
                    $j = $j + 1;
                } elseif ($place['place'] == $prevPlace && ($place['lati'] != $prevLati || $place['long'] != $prevLong)) {
                    if ($placelistUniq[$j - 1]['lati'] == 0 || $placelistUniq[$j - 1]['long'] == 0) {
                        $placelistUniq[$j - 1]['lati'] = $place['lati'];
                        $placelistUniq[$j - 1]['long'] = $place['long'];
                        $placelistUniq[$j - 1]['zoom'] = $place['zoom'];
                        $placelistUniq[$j - 1]['icon'] = $place['icon'];
                    } elseif ($place['lati'] != '0' || $place['long'] != '0') {
                        echo 'Difference: previous value = ', $prevPlace, ', ', $prevLati, ', ', $prevLong, ' current = ', $place['place'], ', ', $place['lati'], ', ', $place['long'], '<br>';
                    }
                }
                $prevPlace = $place['place'];
                $prevLati = $place['lati'];
                $prevLong = $place['long'];
            }
            $default_zoom_level = array();
            $default_zoom_level[0] = 4;
            $default_zoom_level[1] = 7;
            $default_zoom_level[2] = 10;
            $default_zoom_level[3] = 12;
            foreach ($placelistUniq as $k => $place) {
                $parent = explode(',', $place['place']);
                $parent = array_reverse($parent);
                $parent_id = 0;
                for ($i = 0; $i < count($parent); $i++) {
                    $escparent = $parent[$i];
                    if ($escparent == '') {
                        $escparent = 'Unknown';
                    }
                    $row = WT_DB::prepare("SELECT pl_id, pl_long, pl_lati, pl_zoom, pl_icon FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place")->execute(array($i, $parent_id, $escparent))->fetchOneRow();
                    if (empty($row)) {
                        // this name does not yet exist: create entry
                        if (!isset($_POST['updateonly'])) {
                            $highestIndex = $highestIndex + 1;
                            if ($i + 1 == count($parent)) {
                                $zoomlevel = $place['zoom'];
                            } elseif (isset($default_zoom_level[$i])) {
                                $zoomlevel = $default_zoom_level[$i];
                            } else {
                                $zoomlevel = $this->getSetting('GM_MAX_ZOOM');
                            }
                            if ($place['lati'] == '0' || $place['long'] == '0' || $i + 1 < count($parent)) {
                                WT_DB::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_zoom, pl_icon) VALUES (?, ?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $zoomlevel, $place['icon']));
                            } else {
                                //delete leading zero
                                $pl_lati = str_replace(array('N', 'S', ','), array('', '-', '.'), $place['lati']);
                                $pl_long = str_replace(array('E', 'W', ','), array('', '-', '.'), $place['long']);
                                if ($pl_lati >= 0) {
                                    $place['lati'] = 'N' . abs($pl_lati);
                                } elseif ($pl_lati < 0) {
                                    $place['lati'] = 'S' . abs($pl_lati);
                                }
                                if ($pl_long >= 0) {
                                    $place['long'] = 'E' . abs($pl_long);
                                } elseif ($pl_long < 0) {
                                    $place['long'] = 'W' . abs($pl_long);
                                }
                                WT_DB::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_long, pl_lati, pl_zoom, pl_icon) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $place['long'], $place['lati'], $zoomlevel, $place['icon']));
                            }
                            $parent_id = $highestIndex;
                        }
                    } else {
                        $parent_id = $row->pl_id;
                        if (isset($_POST['overwritedata']) && $i + 1 == count($parent)) {
                            WT_DB::prepare("UPDATE `##placelocation` SET pl_lati=?, pl_long=?, pl_zoom=?, pl_icon=? WHERE pl_id=?")->execute(array($place['lati'], $place['long'], $place['zoom'], $place['icon'], $parent_id));
                        } else {
                            if (($row->pl_long == '0' || $row->pl_long == null) && ($row->pl_lati == '0' || $row->pl_lati == null)) {
                                WT_DB::prepare("UPDATE `##placelocation` SET pl_lati=?, pl_long=? WHERE pl_id=?")->execute(array($place['lati'], $place['long'], $parent_id));
                            }
                            if (empty($row->pl_icon) && !empty($place['icon'])) {
                                WT_DB::prepare("UPDATE `##placelocation` SET pl_icon=? WHERE pl_id=?")->execute(array($place['icon'], $parent_id));
                            }
                        }
                    }
                }
            }
            $parent = 0;
        }
        if ($action == 'DeleteRecord') {
            $exists = WT_DB::prepare("SELECT 1 FROM `##placelocation` WHERE pl_parent_id=?")->execute(array($deleteRecord))->fetchOne();
            if (!$exists) {
                WT_DB::prepare("DELETE FROM `##placelocation` WHERE pl_id=?")->execute(array($deleteRecord));
            } else {
                echo '<table class="facts_table"><tr><td>', WT_I18N::translate('Location not removed: this location contains sub-locations'), '</td></tr></table>';
            }
        }
        ?>
		<script>
		function updateList(inactive) {
			window.location.href='<?php 
        if (strstr($_SERVER['REQUEST_URI'], '&inactive', true)) {
            $uri = strstr($_SERVER['REQUEST_URI'], '&inactive', true);
        } else {
            $uri = $_SERVER['REQUEST_URI'];
        }
        echo $uri, '&inactive=';
        ?>
'+inactive;
		}

		function edit_place_location(placeid) {
			window.open('module.php?mod=googlemap&mod_action=places_edit&action=update&placeid='+placeid, '_blank', gmap_window_specs);
			return false;
		}

		function add_place_location(placeid) {
			window.open('module.php?mod=googlemap&mod_action=places_edit&action=add&placeid='+placeid, '_blank', gmap_window_specs);
			return false;
		}

		function delete_place(placeid) {
			var answer=confirm('<?php 
        echo WT_I18N::translate('Remove this location?');
        ?>
');
			if (answer == true) {
				window.location = '<?php 
        echo $_SERVER['REQUEST_URI'];
        ?>
&action=DeleteRecord&deleteRecord=' + placeid;
			}
		}
		</script>
		<?php 
        echo '<div id="gm_breadcrumb">';
        $where_am_i = $this->placeIdToHierarchy($parent);
        foreach (array_reverse($where_am_i, true) as $id => $place) {
            if ($id == $parent) {
                if ($place != 'Unknown') {
                    echo WT_Filter::escapeHtml($place);
                } else {
                    echo WT_I18N::translate('unknown');
                }
            } else {
                echo '<a href="module.php?mod=googlemap&mod_action=admin_places&parent=', $id, '&inactive=', $inactive, '">';
                if ($place != 'Unknown') {
                    echo WT_Filter::escapeHtml($place), '</a>';
                } else {
                    echo WT_I18N::translate('unknown'), '</a>';
                }
            }
            echo ' - ';
        }
        echo '<a href="module.php?mod=googlemap&mod_action=admin_places&parent=0&inactive=', $inactive, '">', WT_I18N::translate('Top level'), '</a></div>';
        echo '<form name="active" method="post" action="module.php?mod=googlemap&mod_action=admin_places&parent=', $parent, '&inactive=', $inactive, '"><div id="gm_active">';
        echo '<label for="inactive">', WT_I18N::translate('Show inactive places'), '</label>';
        echo '<input type="checkbox" name="inactive" id="inactive"';
        if ($inactive) {
            echo ' checked="checked"';
        }
        echo ' onclick="updateList(this.checked)"';
        echo '>', help_link('PLE_ACTIVE', 'googlemap'), '</div></form>';
        $placelist = $this->getPlaceListLocation($parent, $inactive);
        echo '<div class="gm_plac_edit">';
        echo '<table class="gm_plac_edit"><tr>';
        echo '<th>', WT_Gedcom_Tag::getLabel('PLAC'), '</th>';
        echo '<th>', WT_Gedcom_Tag::getLabel('LATI'), '</th>';
        echo '<th>', WT_Gedcom_Tag::getLabel('LONG'), '</th>';
        echo '<th>', WT_I18N::translate('Zoom level'), '</th>';
        echo '<th>', WT_I18N::translate('Icon'), '</th>';
        echo '<th>';
        echo WT_I18N::translate('Edit'), '</th><th>', WT_I18N::translate('Delete'), '</th></tr>';
        if (count($placelist) == 0) {
            echo '<tr><td colspan="7" class="accepted">', WT_I18N::translate('No places found'), '</td></tr>';
        }
        foreach ($placelist as $place) {
            echo '<tr><td><a href="module.php?mod=googlemap&mod_action=admin_places&parent=', $place['place_id'], '&inactive=', $inactive, '">';
            if ($place['place'] != 'Unknown') {
                echo WT_Filter::escapeHtml($place['place']), '</a></td>';
            } else {
                echo WT_I18N::translate('unknown'), '</a></td>';
            }
            echo '<td>', $place['lati'], '</td>';
            echo '<td>', $place['long'], '</td>';
            echo '<td>', $place['zoom'], '</td>';
            echo '<td>';
            if ($place['icon'] == NULL || $place['icon'] == '') {
                if ($place['lati'] == NULL || $place['long'] == NULL || $place['lati'] == '0' && $place['long'] == '0') {
                    echo '<img src="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/images/mm_20_yellow.png">';
                } else {
                    echo '<img src="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/images/mm_20_red.png">';
                }
            } else {
                echo '<img src="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/', $place['icon'], '" width="25" height="15">';
            }
            echo '</td>';
            echo '<td class="narrow"><a href="#" onclick="edit_place_location(', $place['place_id'], ');return false;" class="icon-edit" title="', WT_I18N::translate('Edit'), '"></a></td>';
            $noRows = WT_DB::prepare("SELECT COUNT(pl_id) FROM `##placelocation` WHERE pl_parent_id=?")->execute(array($place['place_id']))->fetchOne();
            if ($noRows == 0) {
                ?>
				<td><a href="#" onclick="delete_place(<?php 
                echo $place['place_id'];
                ?>
);return false;" class="icon-delete" title="<?php 
                echo WT_I18N::translate('Remove');
                ?>
"></a></td>
		<?php 
            } else {
                ?>
				<td><i class="icon-delete-grey"></i></td>
		<?php 
            }
            ?>
			</tr>
			<?php 
        }
        ?>
		</table>
		</div>

		<table id="gm_manage">
			<tr>
				<td>
					<?php 
        echo WT_I18N::translate('Add  a new geographic location');
        ?>
				</td>
				<td>
					<form action="?" onsubmit="add_place_location(this.parent_id.options[this.parent_id.selectedIndex].value); return false;">
						<?php 
        echo select_edit_control('parent_id', $where_am_i, WT_I18N::translate('Top level'), $parent);
        ?>
						<input type="submit" value="<?php 
        echo WT_I18N::translate('Add');
        ?>
">
					</form>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
        echo WT_I18N::translate('Import all places from a family tree');
        ?>
				</td>
				<td>
					<form action="module.php" method="get">
						<input type="hidden" name="mod" value="googlemap">
						<input type="hidden" name="mod_action" value="admin_places">
						<input type="hidden" name="action" value="ImportGedcom">
						<?php 
        echo select_edit_control('ged', WT_Tree::getNameList(), null, WT_GEDCOM);
        ?>
						<input type="submit" value="<?php 
        echo WT_I18N::translate('Import');
        ?>
">
					</form>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
        echo WT_I18N::translate('Upload geographic data');
        ?>
				</td>
				<td>
					<form action="module.php" method="get">
						<input type="hidden" name="mod" value="googlemap">
						<input type="hidden" name="mod_action" value="admin_places">
						<input type="hidden" name="action" value="ImportFile">
						<input type="submit" value="<?php 
        echo WT_I18N::translate('Upload');
        ?>
">
					</form>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
        echo WT_I18N::translate('Download geographic data');
        ?>
				</td>
				<td>
					<form action="module.php" method="get">
						<input type="hidden" name="mod" value="googlemap">
						<input type="hidden" name="mod_action" value="admin_places">
						<input type="hidden" name="action" value="ExportFile">
						<?php 
        echo select_edit_control('parent', $where_am_i, WT_I18N::translate('All'), WT_GED_ID);
        ?>
						<input type="submit" value="<?php 
        echo WT_I18N::translate('Download');
        ?>
">
					</form>
				</td>
			</tr>
		</table>
		<?php 
    }
Example #16
0
<?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();
Example #17
0
// UI for online updating of the config file.
//
// webtrees: Web based Family History software
// Copyright (C) 2014 webtrees development team.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// 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 Michelf\MarkdownExtra;
use WT\Auth;
define('WT_SCRIPT_NAME', 'admin_site_readme.php');
require './includes/session.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('README documentation'))->pageHeader();
?>
<div class="markdown" dir="ltr" lang="en">
	<?php 
echo MarkdownExtra::defaultTransform(file_get_contents('README.md'));
?>
</div>
Example #18
0
<?php

// Log out from the current session
//
// webtrees: Web based Family History software
// Copyright (C) 2014 webtrees development team.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// 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;
use WT\Log;
define('WT_SCRIPT_NAME', 'logout.php');
require './includes/session.php';
if (Auth::id()) {
    Log::addAuthenticationLog('Logout: ' . Auth::user()->getUserName() . '/' . Auth::user()->getRealName());
    Auth::logout();
}
header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH);
Example #19
0
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// 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', 'admin_site_clean.php');
require './includes/session.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('Clean up data folder'))->pageHeader();
require WT_ROOT . 'includes/functions/functions_edit.php';
function full_rmdir($dir)
{
    if (!is_writable($dir)) {
        if (!@chmod($dir, WT_PERM_EXE)) {
            return false;
        }
    }
    $d = dir($dir);
    while (false !== ($entry = $d->read())) {
        if ($entry == '.' || $entry == '..') {
            continue;
        }
        $entry = $dir . '/' . $entry;
        if (is_dir($entry)) {
Example #20
0
        }
        // Total filtered/unfiltered rows
        $recordsFiltered = WT_DB::prepare("SELECT FOUND_ROWS()")->fetchColumn();
        $recordsTotal = WT_DB::prepare($SELECT2 . $WHERE)->execute($args)->fetchColumn();
        header('Content-type: application/json');
        echo json_encode(array('sEcho' => WT_Filter::getInteger('sEcho'), '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 . '&text=' . rawurlencode($text) . '&ip=' . rawurlencode($ip) . '&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_log_page_size', 20) . ',
			pagingType: "full_numbers"
		});
	');
$url = WT_SCRIPT_NAME . '?from=' . rawurlencode($from) . '&amp;to=' . rawurlencode($to) . '&amp;type=' . rawurlencode($type) . '&amp;text=' . rawurlencode($text) . '&amp;ip=' . rawurlencode($ip) . '&amp;user='******'&amp;gedc=' . rawurlencode($gedc);
$users_array = array();
foreach (User::all() as $tmp_user) {
    $users_array[$tmp_user->getUserName()] = $tmp_user->getUserName();
}
echo '<form name="logs" method="get" action="' . WT_SCRIPT_NAME . '">', '<input type="hidden" name="action", value="show">', '<table class="site_logs">', '<tr>', '<td colspan="6">', WT_I18N::translate('From %s to %s', '<input class="log-date" name="from" value="' . WT_Filter::escapeHtml($from) . '">', '<input class="log-date" name="to" value="' . WT_Filter::escapeHtml($to) . '">'), '</td>', '</tr><tr>', '<td>', WT_I18N::translate('Type'), '<br>', select_edit_control('type', array('' => '', 'auth' => 'auth', 'config' => 'config', 'debug' => 'debug', 'edit' => 'edit', 'error' => 'error', 'media' => 'media', 'search' => 'search'), null, $type, ''), '</td>', '<td>', WT_I18N::translate('Message'), '<br><input class="log-filter" name="text" value="', WT_Filter::escapeHtml($text), '"> ', '</td>', '<td>', WT_I18N::translate('IP address'), '<br><input class="log-filter" name="ip" value="', WT_Filter::escapeHtml($ip), '"> ', '</td>', '<td>', WT_I18N::translate('User'), '<br>', select_edit_control('user', $users_array, '', $user, ''), '</td>', '<td>', WT_I18N::translate('Family tree'), '<br>', select_edit_control('gedc', WT_Tree::getNameList(), '', $gedc, Auth::isAdmin() ? '' : 'disabled'), '</td>', '</tr><tr>', '<td colspan="6">', '<input type="submit" value="', WT_I18N::translate('Filter'), '">', '<input type="submit" value="', WT_I18N::translate('Export'), '" onclick="document.logs.action.value=\'export\';return true;" ', $action == 'show' ? '' : 'disabled="disabled"', '>', '<input type="submit" value="', WT_I18N::translate('Delete'), '" onclick="if (confirm(\'', WT_Filter::escapeHtml(WT_I18N::translate('Permanently delete these records?')), '\')) {document.logs.action.value=\'delete\';return true;} else {return false;}" ', $action == 'show' ? '' : 'disabled="disabled"', '>', '</td>', '</tr>', '</table>', '</form>';
if ($action) {
    echo '<br>', '<table id="log_list">', '<thead>', '<tr>', '<th>', WT_I18N::translate('Timestamp'), '</th>', '<th>', WT_I18N::translate('Type'), '</th>', '<th>', WT_I18N::translate('Message'), '</th>', '<th>', WT_I18N::translate('IP address'), '</th>', '<th>', WT_I18N::translate('User'), '</th>', '<th>', WT_I18N::translate('Family tree'), '</th>', '</tr>', '</thead>', '<tbody>', '</tbody>', '</table>';
}
Example #21
0
 }
 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()->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 {
         // Cannot determine the latest version
     }
 }
 // Redirect to the target URL
 header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . $url);
 // Explicitly write the session data before we exit,
// the Free Software Foundation; either version 2 of the License or,
// at your discretion, any later version.
//
// 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', 'admin_trees_renumber.php');
require './includes/session.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isManager())->setPageTitle(WT_I18N::translate('Renumber family tree'))->pageHeader();
// Every XREF used by this tree and also used by some other tree
$xrefs = WT_DB::prepare("SELECT xref, type FROM (" . " SELECT i_id AS xref, 'INDI' AS type FROM `##individuals` WHERE i_file = ?" . "  UNION " . " SELECT f_id AS xref, 'FAM' AS type FROM `##families` WHERE f_file = ?" . "  UNION " . " SELECT s_id AS xref, 'SOUR' AS type FROM `##sources` WHERE s_file = ?" . "  UNION " . " SELECT m_id AS xref, 'OBJE' AS type FROM `##media` WHERE m_file = ?" . "  UNION " . " SELECT o_id AS xref, o_type AS type FROM `##other` WHERE o_file = ? AND o_type NOT IN ('HEAD', 'TRLR')" . ") AS this_tree JOIN (" . " SELECT xref FROM `##change` WHERE gedcom_id <> ?" . "  UNION " . " SELECT i_id AS xref FROM `##individuals` WHERE i_file <> ?" . "  UNION " . " SELECT f_id AS xref FROM `##families` WHERE f_file <> ?" . "  UNION " . " SELECT s_id AS xref FROM `##sources` WHERE s_file <> ?" . "  UNION " . " SELECT m_id AS xref FROM `##media` WHERE m_file <> ?" . "  UNION " . " SELECT o_id AS xref FROM `##other` WHERE o_file <> ? AND o_type NOT IN ('HEAD', 'TRLR')" . ") AS other_trees USING (xref)")->execute(array(WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID))->fetchAssoc();
echo '<h2>', $controller->getPageTitle(), ' — ', $WT_TREE->tree_title_html, '</h2>';
if (WT_Filter::get('go')) {
    foreach ($xrefs as $old_xref => $type) {
        WT_DB::exec("START TRANSACTION");
        WT_DB::exec("LOCK TABLE `##individuals` WRITE," . " `##families` WRITE," . " `##sources` WRITE," . " `##media` WRITE," . " `##other` WRITE," . " `##name` WRITE," . " `##placelinks` WRITE," . " `##change` WRITE," . " `##next_id` WRITE," . " `##dates` WRITE," . " `##default_resn` WRITE," . " `##hit_counter` WRITE," . " `##link` WRITE," . " `##user_gedcom_setting` WRITE");
        $new_xref = get_new_xref($type);
        switch ($type) {
            case 'INDI':
                WT_DB::prepare("UPDATE `##individuals` SET i_id = ?, i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_id = ? AND i_file = ?")->execute(array($new_xref, "0 @{$old_xref}@ INDI\n", "0 @{$new_xref}@ INDI\n", $old_xref, WT_GED_ID));
                WT_DB::prepare("UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'HUSB') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?")->execute(array($old_xref, " HUSB @{$old_xref}@", " HUSB @{$new_xref}@", WT_GED_ID));
                WT_DB::prepare("UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'WIFE') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?")->execute(array($old_xref, " WIFE @{$old_xref}@", " WIFE @{$new_xref}@", WT_GED_ID));
                WT_DB::prepare("UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'CHIL') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?")->execute(array($old_xref, " CHIL @{$old_xref}@", " CHIL @{$new_xref}@", WT_GED_ID));
                WT_DB::prepare("UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'ASSO') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?")->execute(array($old_xref, " ASSO @{$old_xref}@", " ASSO @{$new_xref}@", WT_GED_ID));
Example #23
0
// 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();
}
Example #24
0
function whoisonline()
{
    $NumAnonymous = 0;
    $loggedusers = array();
    $content = '';
    foreach (User::allLoggedIn() as $user) {
        if (Auth::isAdmin() || $user->getSetting('visibleonline')) {
            $loggedusers[] = $user;
        } else {
            $NumAnonymous++;
        }
    }
    $LoginUsers = count($loggedusers);
    $content .= '<div class="logged_in_count">';
    if ($NumAnonymous) {
        $content .= WT_I18N::plural('%d anonymous logged-in user', '%d anonymous logged-in users', $NumAnonymous, $NumAnonymous);
        if ($LoginUsers) {
            $content .= '&nbsp;|&nbsp;';
        }
    }
    if ($LoginUsers) {
        $content .= WT_I18N::plural('%d logged-in user', '%d logged-in users', $LoginUsers, $LoginUsers);
    }
    $content .= '</div>';
    $content .= '<div class="logged_in_list">';
    if (WT_USER_ID) {
        foreach ($loggedusers as $user) {
            $content .= '<div class="logged_in_name">';
            $content .= WT_Filter::escapeHtml($user->getRealName()) . ' - ' . WT_Filter::escapeHtml($user->getUserName());
            if (WT_USER_ID != $user->getUserId() && $user->getSetting('contactmethod') != 'none') {
                $content .= ' <a class="icon-email" href="#" onclick="return message(\'' . WT_Filter::escapeJs($user->getUserName()) . '\', \'\', \'' . WT_Filter::escapeJs(get_query_url()) . '\');" title="' . WT_I18N::translate('Send message') . '"></a>';
            }
            $content .= '</div>';
        }
    }
    $content .= '</div>';
    return $content;
}
Example #25
0
    ?>
	<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>
Example #26
0
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::preference('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;
}
Example #27
0
        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 
Example #28
0
        }
        $html .= '</ul>';
    } else {
        $html .= '<div class="error">' . WT_I18N::translate('This media object is not linked to any other record.') . '</div>';
    }
    return $html;
}
////////////////////////////////////////////////////////////////////////////////
// Start here
////////////////////////////////////////////////////////////////////////////////
// Preserver the pagination/filtering/sorting between requests, so that the
// browser’s back button works.  Pagination is dependent on the currently
// selected folder.
$table_id = md5($files . $media_folder . $media_path . $subfolders);
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('Media'))->addExternalJavascript(WT_JQUERY_DATATABLES_URL)->pageHeader()->addInlineJavascript('
	jQuery("#media-table-' . $table_id . '").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&files=' . $files . '&media_folder=' . $media_folder . '&media_path=' . $media_path . '&subfolders=' . $subfolders . '",
		' . WT_I18N::datatablesI18N(array(5, 10, 20, 50, 100, 500, 1000, -1)) . ',
		jQueryUI: true,
		autoWidth:false,
		pageLength: 10,
		pagingType: "full_numbers",
		stateSave: true,
		stateDuration: 300,
		columns: [
			{},
			{ sortable: false },
Example #29
0
            }
        }
        break;
    case 'listusers':
    default:
        echo '<table id="list">', '<thead>', '<tr>', '<th style="margin:0 -2px 1px 1px; padding:6px 0 5px;"> </th>', '<th> user-id </th>', '<th>', WT_I18N::translate('Username'), '</th>', '<th>', WT_I18N::translate('Real name'), '</th>', '<th>', WT_I18N::translate('Email'), '</th>', '<th> </th>', '<th>', WT_I18N::translate('Language'), '</th>', '<th> date_registered </th>', '<th>', WT_I18N::translate('Date registered'), '</th>', '<th> last_login </th>', '<th>', WT_I18N::translate('Last logged in'), '</th>', '<th>', WT_I18N::translate('Verified'), '</th>', '<th>', WT_I18N::translate('Approved'), '</th>', '<th style="margin:0 -2px 1px 1px; padding:3px 0 4px;"> </th>', '</tr>', '</thead>', '<tbody>', '</tbody>', '</table>';
        $controller->addExternalJavascript(WT_JQUERY_DATATABLES_URL)->addExternalJavascript(WT_JQUERY_JEDITABLE_URL)->addInlineJavascript('
			var oTable = jQuery("#list").dataTable({
				dom: \'<"H"pf<"dt-clear">irl>t<"F"pl>\',
				' . WT_I18N::datatablesI18N() . ',
				processing: true,
				serverSide: true,
				ajax: "' . WT_SCRIPT_NAME . '?action=loadrows",
				jQueryUI: true,
				autoWidth: false,
				pageLength: ' . Auth::user()->getSetting('admin_users_page_size', 10) . ',
				pagingType: "full_numbers",
				sorting: [[2,"asc"]],
				columns: [
					/* details           */ { sortable: false, class: "icon-open" },
					/* user-id           */ { visible: false },
					/* user_name         */ null,
					/* real_name         */ null,
					/* email             */ null,
					/* email link        */ { sortable: false },
					/* language          */ null,
					/* registered (sort) */ { visible: false },
					/* registered        */ { dataSort: 7 },
					/* last_login (sort) */ { visible: false },
					/* last_login        */ { dataSort: 9 },
					/* verified          */ { class: "center" },
Example #30
0
}
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&amp;ged=' . WT_GEDURL;
        $show = 'indi';
    } else {
        if ($falpha) {
            $alpha = '';
            $surname = '';
            $legend = WT_I18N::translate('All') . ', ' . WT_Filter::escapeHtml($falpha) . '…';