Ejemplo n.º 1
0
 /**
  * This is a general purpose hook, allowing modules to respond to routes
  * of the form module.php?mod=FOO&mod_action=BAR
  *
  * @param string $mod_action
  */
 public function modAction($mod_action)
 {
     switch ($mod_action) {
         case 'delete':
             $stmt = Database::prepare("DELETE FROM `##message` WHERE user_id = :user_id AND message_id = :message_id");
             foreach (Filter::postArray('message_id') as $id) {
                 $stmt->execute(array('message_id' => $id, 'user_id' => Auth::id()));
             }
     }
     $ged = Filter::post('ged');
     $ctype = Filter::post('ctype', 'user|gedcom', 'user');
     header('Location: ' . WT_BASE_URL . 'index.php?ged=' . Filter::escapeUrl($ged) . '&ctype=' . $ctype);
 }
Ejemplo n.º 2
0
 /**
  * Startup activity
  */
 public function __construct()
 {
     global $WT_TREE;
     parent::__construct();
     // $action comes from GET (search) or POST (replace)
     if (Filter::post('action')) {
         $this->action = Filter::post('action', 'replace', 'general');
         $this->query = Filter::post('query');
         $this->replace = Filter::post('replace');
         $this->replaceNames = Filter::post('replaceNames', 'checked', '');
         $this->replacePlaces = Filter::post('replacePlaces', 'checked', '');
         $this->replacePlacesWord = Filter::post('replacePlacesWord', 'checked', '');
         $this->replaceAll = Filter::post('replaceAll', 'checked', '');
     } else {
         $this->action = Filter::get('action', 'advanced|general|soundex|replace|header', 'general');
         $this->query = Filter::get('query');
         $this->replace = Filter::get('replace');
         $this->replaceNames = Filter::get('replaceNames', 'checked', '');
         $this->replacePlaces = Filter::get('replacePlaces', 'checked', '');
         $this->replacePlacesWord = Filter::get('replacePlacesWord', 'checked', '');
         $this->replaceAll = Filter::get('replaceAll', 'checked', '');
     }
     // Only editors can use search/replace
     if ($this->action === 'replace' && !Auth::isEditor($WT_TREE)) {
         $this->action = 'general';
     }
     $this->srindi = Filter::get('srindi', 'checked', '');
     $this->srfams = Filter::get('srfams', 'checked', '');
     $this->srsour = Filter::get('srsour', 'checked', '');
     $this->srnote = Filter::get('srnote', 'checked', '');
     $this->soundex = Filter::get('soundex', 'DaitchM|Russell', 'DaitchM');
     $this->showasso = Filter::get('showasso');
     $this->firstname = Filter::get('firstname');
     $this->lastname = Filter::get('lastname');
     $this->place = Filter::get('place');
     $this->year = Filter::get('year');
     // If no record types specified, search individuals
     if (!$this->srfams && !$this->srsour && !$this->srnote) {
         $this->srindi = 'checked';
     }
     // If no replace types specifiied, replace full records
     if (!$this->replaceNames && !$this->replacePlaces && !$this->replacePlacesWord) {
         $this->replaceAll = 'checked';
     }
     // Trees to search
     if (Site::getPreference('ALLOW_CHANGE_GEDCOM')) {
         foreach (Tree::getAll() as $search_tree) {
             if (Filter::get('tree_' . $search_tree->getTreeId())) {
                 $this->search_trees[] = $search_tree;
             }
         }
         if (!$this->search_trees) {
             $this->search_trees[] = $WT_TREE;
         }
     } else {
         $this->search_trees[] = $WT_TREE;
     }
     // If we want to show associated persons, build the list
     switch ($this->action) {
         case 'header':
             // We can type in an XREF into the header search, and jump straight to it.
             // Otherwise, the header search is the same as the general search
             if (preg_match('/' . WT_REGEX_XREF . '/', $this->query)) {
                 $record = GedcomRecord::getInstance($this->query, $WT_TREE);
                 if ($record && $record->canShowName()) {
                     header('Location: ' . WT_BASE_URL . $record->getRawUrl());
                     exit;
                 }
             }
             $this->action = 'general';
             $this->srindi = 'checked';
             $this->srfams = 'checked';
             $this->srsour = 'checked';
             $this->srnote = 'checked';
             $this->setPageTitle(I18N::translate('General search'));
             $this->generalSearch();
             break;
         case 'general':
             $this->setPageTitle(I18N::translate('General search'));
             $this->generalSearch();
             break;
         case 'soundex':
             // Create a dummy search query to use as a title to the results list
             $this->query = trim($this->firstname . ' ' . $this->lastname . ' ' . $this->place);
             $this->setPageTitle(I18N::translate('Phonetic search'));
             $this->soundexSearch();
             break;
         case 'replace':
             $this->setPageTitle(I18N::translate('Search and replace'));
             $this->search_trees = array($WT_TREE);
             $this->srindi = 'checked';
             $this->srfams = 'checked';
             $this->srsour = 'checked';
             $this->srnote = 'checked';
             if (Filter::post('query')) {
                 $this->searchAndReplace($WT_TREE);
                 header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=replace&query=' . Filter::escapeUrl($this->query) . '&replace=' . Filter::escapeUrl($this->replace) . '&replaceAll=' . $this->replaceAll . '&replaceNames=' . $this->replaceNames . '&replacePlaces=' . $this->replacePlaces . '&replacePlacesWord=' . $this->replacePlacesWord);
                 exit;
             }
     }
 }
Ejemplo n.º 3
0
         FlashMessages::addMessage(I18N::translate('The family tree “%s” will be shown to visitors when they first arrive at this website.', $WT_TREE->getTitleHtml()), 'success');
     }
     header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
     return;
 case 'new_tree':
     $basename = basename(Filter::post('tree_name'));
     $tree_title = Filter::post('tree_title');
     if (Filter::checkCsrf() && $basename && $tree_title) {
         if (Tree::findByName($basename)) {
             FlashMessages::addMessage(I18N::translate('The family tree “%s” already exists.', Filter::escapeHtml($basename)), 'danger');
         } else {
             Tree::create($basename, $tree_title);
             FlashMessages::addMessage(I18N::translate('The family tree “%s” has been created.', Filter::escapeHtml($basename)), 'success');
         }
     }
     header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?ged=' . Filter::escapeUrl($basename));
     return;
 case 'replace_upload':
     $gedcom_id = Filter::postInteger('gedcom_id');
     $keep_media = Filter::post('keep_media', '1', '0');
     $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH');
     $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0');
     $tree = Tree::findById($gedcom_id);
     if (Filter::checkCsrf() && $tree) {
         $tree->setPreference('keep_media', $keep_media);
         $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH);
         $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES);
         if (isset($_FILES['tree_name'])) {
             if ($_FILES['tree_name']['error'] == 0 && is_readable($_FILES['tree_name']['tmp_name'])) {
                 $tree->importGedcomFile($_FILES['tree_name']['tmp_name'], $_FILES['tree_name']['name']);
             }
Ejemplo n.º 4
0
 /**
  * Print read-more link
  * 
  * @param type $root
  * @return string
  */
 private function printReadMoreLink($root)
 {
     return '<div id="read-more-link">' . '<a href="module.php?mod=' . $this->getName() . '&amp;mod_action=page&rootid=' . $root . '&amp;ged=' . Filter::escapeUrl(Tree::findById($this->tree_id)->getName()) . '">' . I18N::translate('Read more') . '</a>' . '</div>';
 }
Ejemplo n.º 5
0
 /**
  * The name of this tree
  *
  * @return string
  */
 public function getNameUrl()
 {
     return Filter::escapeUrl($this->name);
 }
Ejemplo n.º 6
0
?>
					</button>
					<button type="submit" name="action" value="reset">
						<?php 
echo I18N::translate('reset');
?>
					</button>
				</td>
			</tr>
		</tbody>
	</table>
</form>

<?php 
if ($action === 'submit') {
    $url = 'medialist.php?action=submit' . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;folder=' . Filter::escapeUrl($folder) . '&amp;sortby=' . Filter::escapeUrl($sortby) . '&amp;subdirs=' . Filter::escapeUrl($subdirs) . '&amp;filter=' . Filter::escapeUrl($filter) . '&amp;form_type=' . Filter::escapeUrl($form_type) . '&amp;columns=' . Filter::escapeUrl($columns) . '&amp;max=' . Filter::escapeUrl($max);
    $count = count($medialist);
    $pages = (int) (($count + $max - 1) / $max);
    $page = max(min($page, $pages), 1);
    if ($page === $pages && $count % $max !== 0) {
        // Last page may have    fewer than $max pages
        $number_on_page = $count % $max;
    } else {
        $number_on_page = $max;
    }
    if (I18N::direction() === 'ltr') {
        $icons = array('first' => 'ldarrow', 'previous' => 'larrow', 'next' => 'rarrow', 'last' => 'rdarrow');
    } else {
        $icons = array('first' => 'rdarrow', 'previous' => 'rarrow', 'next' => 'larrow', 'last' => 'ldarrow');
    }
    echo '<div><p>', I18N::translate('Media objects found'), ' ', $count, '</p>';
Ejemplo n.º 7
0
			<div>
				<input type="submit" value="', I18N::translate('Send'), '">
			</div>
		</form>
	</div>';
        break;
    case 'verify_hash':
        if (!Site::getPreference('USE_REGISTRATION_MODULE')) {
            header('Location: ' . WT_BASE_URL);
            return;
        }
        // switch language to webmaster settings
        $webmaster = User::find($WT_TREE->getPreference('WEBMASTER_USER_ID'));
        I18N::init($webmaster->getPreference('language'));
        $user = User::findByIdentifier($user_name);
        $mail1_body = I18N::translate('Hello administrator…') . Mail::EOL . Mail::EOL . I18N::translate('A new user (%1$s) has requested an account (%2$s) and verified an email address (%3$s).', $user->getRealNameHtml(), Filter::escapeHtml($user->getUserName()), Filter::escapeHtml($user->getEmail())) . Mail::EOL . Mail::EOL . I18N::translate('You now need to review the account details, and set the “approved” status to “yes”.') . Mail::EOL . '<a href="' . WT_BASE_URL . "admin_users.php?filter=" . Filter::escapeUrl($user->getUserName()) . '">' . WT_BASE_URL . "admin_users.php?filter=" . Filter::escapeUrl($user->getUserName()) . '</a>' . Mail::auditFooter();
        $mail1_subject = I18N::translate('New user at %s', WT_BASE_URL . ' ' . $WT_TREE->getTitle());
        // Change to the new user’s language
        I18N::init($user->getPreference('language'));
        $controller->setPageTitle(I18N::translate('User verification'));
        $controller->pageHeader();
        echo '<div id="login-register-page">';
        echo '<h2>' . I18N::translate('User verification') . '</h2>';
        echo '<div id="user-verify">';
        if ($user && $user->checkPassword($user_password) && $user->getPreference('reg_hashcode') === $user_hashcode) {
            Mail::send($WT_TREE, $webmaster->getEmail(), $webmaster->getRealName(), $WT_TREE->getPreference('WEBTREES_EMAIL'), $WT_TREE->getPreference('WEBTREES_EMAIL'), $mail1_subject, $mail1_body);
            $mail1_method = $webmaster->getPreference('CONTACT_METHOD');
            if ($mail1_method != 'messaging3' && $mail1_method != 'mailto' && $mail1_method != 'none') {
                Database::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)")->execute(array($user_name, WT_CLIENT_IP, $webmaster->getUserId(), $mail1_subject, Filter::unescapeHtml($mail1_body)));
            }
            $user->setPreference('verified', '1')->setPreference('reg_timestamp', date('U'))->deletePreference('reg_hashcode');
Ejemplo n.º 8
0
     Log::addAuthenticationLog('Possible spam registration from "' . $user_name . '"/"' . $user_email . '" comments="' . $user_comments . '"');
 } else {
     // Everything looks good - create the user
     $controller->pageHeader();
     Log::addAuthenticationLog('User registration requested for: ' . $user_name);
     $user = User::create($user_name, $user_realname, $user_email, $user_password01);
     $user->setPreference('language', WT_LOCALE)->setPreference('verified', '0')->setPreference('verified_by_admin', 0)->setPreference('reg_timestamp', date('U'))->setPreference('reg_hashcode', md5(Uuid::uuid4()))->setPreference('contactmethod', 'messaging2')->setPreference('comment', $user_comments)->setPreference('visibleonline', '1')->setPreference('auto_accept', '0')->setPreference('canadmin', '0')->setPreference('sessiontime', '0');
     // Generate an email in the admin’s language
     $webmaster = User::find($WT_TREE->getPreference('WEBMASTER_USER_ID'));
     I18N::init($webmaster->getPreference('language'));
     $mail1_body = I18N::translate('Hello administrator…') . Mail::EOL . Mail::EOL . I18N::translate('A prospective user has registered with webtrees at %s.', WT_BASE_URL . ' ' . $WT_TREE->getTitleHtml()) . Mail::EOL . Mail::EOL . I18N::translate('Username') . ' ' . Filter::escapeHtml($user->getUserName()) . Mail::EOL . I18N::translate('Real name') . ' ' . $user->getRealNameHtml() . Mail::EOL . I18N::translate('Email address') . ' ' . Filter::escapeHtml($user->getEmail()) . Mail::EOL . I18N::translate('Comments') . ' ' . Filter::escapeHtml($user_comments) . Mail::EOL . Mail::EOL . I18N::translate('The user has been sent an e-mail with the information necessary to confirm the access request.') . Mail::EOL . Mail::EOL . I18N::translate('You will be informed by e-mail when this prospective user has confirmed the request. You can then complete the process by activating the user name. The new user will not be able to login until you activate the account.');
     $mail1_subject = I18N::translate('New registration at %s', WT_BASE_URL . ' ' . $WT_TREE->getTitle());
     I18N::init(WT_LOCALE);
     echo '<div id="login-register-page">';
     // Generate an email in the user’s language
     $mail2_body = I18N::translate('Hello %s…', $user->getRealNameHtml()) . Mail::EOL . Mail::EOL . I18N::translate('You (or someone claiming to be you) has requested an account at %1$s using the email address %2$s.', WT_BASE_URL . ' ' . $WT_TREE->getTitleHtml(), $user->getEmail()) . ' ' . I18N::translate('Information about the request is shown under the link below.') . Mail::EOL . I18N::translate('Please click on the following link and fill in the requested data to confirm your request and email address.') . Mail::EOL . Mail::EOL . '<a href="' . WT_LOGIN_URL . '?user_name=' . Filter::escapeUrl($user->getUserName()) . '&amp;user_hashcode=' . $user->getPreference('reg_hashcode') . '&amp;action=userverify&amp;ged=' . $WT_TREE->getNameUrl() . '">' . WT_LOGIN_URL . "?user_name=" . Filter::escapeHtml($user->getUserName()) . "&amp;user_hashcode=" . urlencode($user->getPreference('reg_hashcode')) . '&amp;action=userverify&amp;ged=' . $WT_TREE->getNameHtml() . '</a>' . Mail::EOL . Mail::EOL . I18N::translate('Username') . " - " . Filter::escapeHtml($user->getUserName()) . Mail::EOL . I18N::translate('Verification code') . " - " . $user->getPreference('reg_hashcode') . Mail::EOL . I18N::translate('Comments') . " - " . $user->getPreference('comment') . Mail::EOL . I18N::translate('If you didn’t request an account, you can just delete this message.') . Mail::EOL;
     $mail2_subject = I18N::translate('Your registration at %s', WT_BASE_URL);
     $mail2_to = $user->getEmail();
     $mail2_from = $WT_TREE->getPreference('WEBTREES_EMAIL');
     // Send user message by email only
     Mail::send($WT_TREE, $mail2_to, $mail2_to, $mail2_from, $mail2_from, $mail2_subject, $mail2_body);
     // Send admin message by email and/or internal messaging
     Mail::send($WT_TREE, $webmaster->getEmail(), $webmaster->getRealName(), $user->getEmail(), $user->getRealName(), $mail1_subject, $mail1_body);
     $mail1_method = $webmaster->getPreference('contact_method');
     if ($mail1_method != 'messaging3' && $mail1_method != 'mailto' && $mail1_method != 'none') {
         Database::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)")->execute(array($user->getEmail(), WT_CLIENT_IP, $webmaster->getUserId(), $mail1_subject, Filter::unescapeHtml($mail1_body)));
     }
     echo '<div class="confirm"><p>', I18N::translate('Hello %s…<br>Thank you for your registration.', $user->getRealNameHtml()), '</p>';
     echo '<p>', I18N::translate('We will now send a confirmation email to the address <b>%s</b>. You must verify your account request by following instructions in the confirmation email. If you do not confirm your account request within seven days, your application will be rejected automatically. You will have to apply again.<br><br>After you have followed the instructions in the confirmation email, the administrator still has to approve your request before your account can be used.<br><br>To login to this website, you will need to know your user name and password.', $user->getEmail()), '</p>';
     echo '</div>';
     echo '</div>';
Ejemplo n.º 9
0
 /** {@inheritdoc} */
 public function getMenu()
 {
     global $controller;
     if (!Auth::isSearchEngine()) {
         Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION);
         static $menu;
         // Function has already run
         if ($menu !== null && count($menu->getSubmenus()) > 0) {
             return $menu;
         }
         $FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS'));
         if (!empty($FTV_SETTINGS)) {
             foreach ($FTV_SETTINGS as $FTV_ITEM) {
                 if ($FTV_ITEM['TREE'] == $this->tree_id && !empty($FTV_ITEM['PID']) && $FTV_ITEM['ACCESS_LEVEL'] >= Auth::accessLevel($this->tree)) {
                     $FTV_GED_SETTINGS[] = $FTV_ITEM;
                 }
             }
             if (!empty($FTV_GED_SETTINGS)) {
                 if (Theme::theme()->themeId() !== '_administration') {
                     // load the module stylesheets
                     echo $this->module()->getStylesheet();
                     // add javascript files and scripts
                     $this->module()->includeJs($controller, 'menu');
                     if (WT_SCRIPT_NAME === 'individual.php') {
                         $this->module()->includeJs($controller, 'tab');
                     }
                 }
                 $tree_name = Filter::escapeUrl($this->tree->getName());
                 $menu = new Menu(I18N::translate('Family tree overview'), 'module.php?mod=' . $this->getName() . '&amp;mod_action=page&amp;rootid=' . $FTV_GED_SETTINGS[0]['PID'] . '&amp;ged=' . $tree_name, 'menu-fancy_treeview');
                 foreach ($FTV_GED_SETTINGS as $FTV_ITEM) {
                     $record = Individual::getInstance($FTV_ITEM['PID'], $this->tree);
                     if ($record && $record->canShowName()) {
                         if ($this->module()->options('use_fullname') == true) {
                             $submenu = new Menu(I18N::translate('Descendants of %s', $record->getFullName()), 'module.php?mod=' . $this->getName() . '&amp;mod_action=page&amp;rootid=' . $FTV_ITEM['PID'] . '&amp;ged=' . $tree_name, 'menu-fancy_treeview-' . $FTV_ITEM['PID']);
                         } else {
                             $submenu = new Menu(I18N::translate('Descendants of the %s family', $FTV_ITEM['SURNAME']), 'module.php?mod=' . $this->getName() . '&amp;mod_action=page&amp;rootid=' . $FTV_ITEM['PID'] . '&amp;ged=' . $tree_name, 'menu-fancy_treeview-' . $FTV_ITEM['PID']);
                         }
                         $menu->addSubmenu($submenu);
                     }
                 }
                 if (count($menu->getSubmenus()) > 0) {
                     return $menu;
                 }
             }
         }
     }
 }
Ejemplo n.º 10
0
 /**
  * Print a tagcloud of surnames.
  *
  * @param string[][] $surnames array (of SURN, of array of SPFX_SURN, of array of PID)
  * @param string $script indilist or famlist
  * @param bool $totals show totals after each name
  * @param Tree $tree generate links to this tree
  *
  * @return string
  */
 public static function surnameTagCloud($surnames, $script, $totals, Tree $tree)
 {
     $minimum = PHP_INT_MAX;
     $maximum = 1;
     foreach ($surnames as $surn => $surns) {
         foreach ($surns as $spfxsurn => $indis) {
             $maximum = max($maximum, count($indis));
             $minimum = min($minimum, count($indis));
         }
     }
     $html = '';
     foreach ($surnames as $surn => $surns) {
         foreach ($surns as $spfxsurn => $indis) {
             if ($maximum === $minimum) {
                 // All surnames occur the same number of times
                 $size = 150.0;
             } else {
                 $size = 75.0 + 125.0 * (count($indis) - $minimum) / ($maximum - $minimum);
             }
             $html .= '<a style="font-size:' . $size . '%" href="' . $script . '?surname=' . Filter::escapeUrl($surn) . '&amp;ged=' . $tree->getNameUrl() . '">';
             if ($totals) {
                 $html .= I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $spfxsurn . '</span>', I18N::number(count($indis)));
             } else {
                 $html .= $spfxsurn;
             }
             $html .= '</a> ';
         }
     }
     return '<div class="tag_cloud">' . $html . '</div>';
 }
Ejemplo n.º 11
0
     Log::addAuthenticationLog('Possible spam registration from "' . $user_name . '"/"' . $user_email . '" comments="' . $user_comments . '"');
 } else {
     // Everything looks good - create the user
     $controller->pageHeader();
     Log::addAuthenticationLog('User registration requested for: ' . $user_name);
     $user = User::create($user_name, $user_realname, $user_email, $user_password01);
     $user->setPreference('language', WT_LOCALE)->setPreference('verified', '0')->setPreference('verified_by_admin', 0)->setPreference('reg_timestamp', date('U'))->setPreference('reg_hashcode', md5(Uuid::uuid4()))->setPreference('contactmethod', 'messaging2')->setPreference('comment', $user_comments)->setPreference('visibleonline', '1')->setPreference('auto_accept', '0')->setPreference('canadmin', '0')->setPreference('sessiontime', '0');
     // Generate an email in the admin’s language
     $webmaster = User::find($WT_TREE->getPreference('WEBMASTER_USER_ID'));
     I18N::init($webmaster->getPreference('language'));
     $mail1_body = I18N::translate('Hello administrator…') . Mail::EOL . Mail::EOL . I18N::translate('A prospective user has registered with webtrees at %s.', WT_BASE_URL . ' ' . $WT_TREE->getTitleHtml()) . Mail::EOL . Mail::EOL . I18N::translate('Username') . ' ' . Filter::escapeHtml($user->getUserName()) . Mail::EOL . I18N::translate('Real name') . ' ' . $user->getRealNameHtml() . Mail::EOL . I18N::translate('Email address') . ' ' . Filter::escapeHtml($user->getEmail()) . Mail::EOL . I18N::translate('Comments') . ' ' . Filter::escapeHtml($user_comments) . Mail::EOL . Mail::EOL . I18N::translate('The user has been sent an email with the information necessary to confirm the access request.') . Mail::EOL . Mail::EOL . I18N::translate('You will be informed by email when this prospective user has confirmed the request. You can then complete the process by activating the username. The new user will not be able to sign in until you activate the account.');
     $mail1_subject = I18N::translate('New registration at %s', WT_BASE_URL . ' ' . $WT_TREE->getTitle());
     I18N::init(WT_LOCALE);
     echo '<div id="login-register-page">';
     // Generate an email in the user’s language
     $mail2_body = I18N::translate('Hello %s…', $user->getRealNameHtml()) . Mail::EOL . Mail::EOL . I18N::translate('You (or someone claiming to be you) has requested an account at %1$s using the email address %2$s.', WT_BASE_URL . ' ' . $WT_TREE->getTitleHtml(), $user->getEmail()) . Mail::EOL . Mail::EOL . I18N::translate('Follow this link to verify your email address.') . Mail::EOL . Mail::EOL . '<a href="' . WT_LOGIN_URL . '?user_name=' . Filter::escapeUrl($user->getUserName()) . '&amp;user_hashcode=' . $user->getPreference('reg_hashcode') . '&amp;action=userverify&amp;ged=' . $WT_TREE->getNameUrl() . '">' . WT_LOGIN_URL . "?user_name=" . Filter::escapeHtml($user->getUserName()) . "&amp;user_hashcode=" . urlencode($user->getPreference('reg_hashcode')) . '&amp;action=userverify&amp;ged=' . $WT_TREE->getNameHtml() . '</a>' . Mail::EOL . Mail::EOL . I18N::translate('Username') . " - " . Filter::escapeHtml($user->getUserName()) . Mail::EOL . I18N::translate('Comments') . " - " . $user->getPreference('comment') . Mail::EOL . I18N::translate('If you didn’t request an account, you can just delete this message.') . Mail::EOL;
     $mail2_subject = I18N::translate('Your registration at %s', WT_BASE_URL);
     $mail2_to = $user->getEmail();
     $mail2_from = $WT_TREE->getPreference('WEBTREES_EMAIL');
     // Send user message by email only
     Mail::send($WT_TREE, $mail2_to, $mail2_to, $mail2_from, $mail2_from, $mail2_subject, $mail2_body);
     // Send admin message by email and/or internal messaging
     Mail::send($WT_TREE, $webmaster->getEmail(), $webmaster->getRealName(), $user->getEmail(), $user->getRealName(), $mail1_subject, $mail1_body);
     $mail1_method = $webmaster->getPreference('contact_method');
     if ($mail1_method != 'messaging3' && $mail1_method != 'mailto' && $mail1_method != 'none') {
         Database::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)")->execute(array($user->getEmail(), WT_CLIENT_IP, $webmaster->getUserId(), $mail1_subject, Filter::unescapeHtml($mail1_body)));
     }
     echo '<div class="confirm"><p>', I18N::translate('Hello %s…<br>Thank you for your registration.', $user->getRealNameHtml()), '</p>';
     echo '<p>', I18N::translate('We will now send a confirmation email to the address <b>%s</b>. You must verify your account request by following instructions in the confirmation email. If you do not confirm your account request within seven days, your application will be rejected automatically. You will have to apply again.<br><br>After you have followed the instructions in the confirmation email, the administrator still has to approve your request before your account can be used.<br><br>To sign in to this website, you will need to know your username and password.', $user->getEmail()), '</p>';
     echo '</div>';
     echo '</div>';
Ejemplo n.º 12
0
    /**
     * Print a fact record, for the individual/family/source/repository/etc. pages.
     *
     * Although a Fact has a parent object, we also need to know
     * the GedcomRecord for which we are printing it. For example,
     * we can show the death of X on the page of Y, or the marriage
     * of X+Y on the page of Z. We need to know both records to
     * calculate ages, relationships, etc.
     *
     * @param Fact $fact
     * @param GedcomRecord $record
     */
    public static function printFact(Fact $fact, GedcomRecord $record)
    {
        static $n_chil = 0, $n_gchi = 0;
        $parent = $fact->getParent();
        // Some facts don't get printed here ...
        switch ($fact->getTag()) {
            case 'NOTE':
                self::printMainNotes($fact, 1);
                return;
            case 'SOUR':
                self::printMainSources($fact, 1);
                return;
            case 'OBJE':
                self::printMainMedia($fact, 1);
                return;
            case 'FAMC':
            case 'FAMS':
            case 'CHIL':
            case 'HUSB':
            case 'WIFE':
                // These are internal links, not facts
                return;
            case '_WT_OBJE_SORT':
                // These links are used internally to record the sort order.
                return;
            default:
                // Hide unrecognized/custom tags?
                if ($fact->getParent()->getTree()->getPreference('HIDE_GEDCOM_ERRORS') && !GedcomTag::isTag($fact->getTag())) {
                    return;
                }
                break;
        }
        // Who is this fact about? Need it to translate fact label correctly
        if ($parent instanceof Family && $record instanceof Individual) {
            // Family event
            $label_person = $fact->getParent()->getSpouse($record);
        } else {
            // Individual event
            $label_person = $parent;
        }
        // New or deleted facts need different styling
        $styleadd = '';
        if ($fact->isPendingAddition()) {
            $styleadd = 'new';
        }
        if ($fact->isPendingDeletion()) {
            $styleadd = 'old';
        }
        // Event of close relative
        if (preg_match('/^_[A-Z_]{3,5}_[A-Z0-9]{4}$/', $fact->getTag())) {
            $styleadd = trim($styleadd . ' rela');
        }
        // Event of close associates
        if ($fact->getFactId() == 'asso') {
            $styleadd = trim($styleadd . ' rela');
        }
        // historical facts
        if ($fact->getFactId() == 'histo') {
            $styleadd = trim($styleadd . ' histo');
        }
        // Does this fact have a type?
        if (preg_match('/\\n2 TYPE (.+)/', $fact->getGedcom(), $match)) {
            $type = $match[1];
        } else {
            $type = '';
        }
        switch ($fact->getTag()) {
            case 'EVEN':
            case 'FACT':
                if (GedcomTag::isTag($type)) {
                    // Some users (just Meliza?) use "1 EVEN/2 TYPE BIRT". Translate the TYPE.
                    $label = GedcomTag::getLabel($type, $label_person);
                    $type = '';
                    // Do not print this again
                } elseif ($type) {
                    // We don't have a translation for $type - but a custom translation might exist.
                    $label = I18N::translate(Filter::escapeHtml($type));
                    $type = '';
                    // Do not print this again
                } else {
                    // An unspecified fact/event
                    $label = $fact->getLabel();
                }
                break;
            case 'MARR':
                // This is a hack for a proprietory extension. Is it still used/needed?
                $utype = strtoupper($type);
                if ($utype == 'CIVIL' || $utype == 'PARTNERS' || $utype == 'RELIGIOUS') {
                    $label = GedcomTag::getLabel('MARR_' . $utype, $label_person);
                    $type = '';
                    // Do not print this again
                } else {
                    $label = $fact->getLabel();
                }
                break;
            default:
                // Normal fact/event
                $label = $fact->getLabel();
                break;
        }
        echo '<tr class="', $styleadd, '">';
        echo '<td class="descriptionbox width20">';
        if ($fact->getParent()->getTree()->getPreference('SHOW_FACT_ICONS')) {
            echo Theme::theme()->icon($fact), ' ';
        }
        if ($fact->getFactId() != 'histo' && $fact->canEdit()) {
            ?>
			<a
				href="#"
				title="<?php 
            echo I18N::translate('Edit');
            ?>
"
				onclick="return edit_record('<?php 
            echo $parent->getXref();
            ?>
', '<?php 
            echo $fact->getFactId();
            ?>
');"
				><?php 
            echo $label;
            ?>
</a>
			<div class="editfacts">
				<div class="editlink">
					<a
						href="#"
						title="<?php 
            echo I18N::translate('Edit');
            ?>
"
						class="editicon"
						onclick="return edit_record('<?php 
            echo $parent->getXref();
            ?>
', '<?php 
            echo $fact->getFactId();
            ?>
');"
						><span class="link_text"><?php 
            echo I18N::translate('Edit');
            ?>
</span></a>
				</div>
				<div class="copylink">
					<a
						href="#"
						title="<?php 
            echo I18N::translate('Copy');
            ?>
"
						class="copyicon"
						onclick="return copy_fact('<?php 
            echo $parent->getXref();
            ?>
', '<?php 
            echo $fact->getFactId();
            ?>
');"
						><span class="link_text"><?php 
            echo I18N::translate('Copy');
            ?>
</span></a>
				</div>
				<div class="deletelink">
					<a
						href="#"
						title="<?php 
            echo I18N::translate('Delete');
            ?>
"
						class="deleteicon"
						onclick="return delete_fact('<?php 
            echo I18N::translate('Are you sure you want to delete this fact?');
            ?>
', '<?php 
            echo $parent->getXref();
            ?>
', '<?php 
            echo $fact->getFactId();
            ?>
');"
						><span class="link_text"><?php 
            echo I18N::translate('Delete');
            ?>
</span></a>
				</div>
			</div>
		<?php 
        } else {
            echo $label;
        }
        switch ($fact->getTag()) {
            case '_BIRT_CHIL':
                echo '<br>', I18N::translate('#%s', ++$n_chil);
                break;
            case '_BIRT_GCHI':
            case '_BIRT_GCH1':
            case '_BIRT_GCH2':
                echo '<br>', I18N::translate('#%s', ++$n_gchi);
                break;
        }
        echo '</td><td class="optionbox ', $styleadd, ' wrap">';
        // Event from another record?
        if ($parent !== $record) {
            if ($parent instanceof Family) {
                foreach ($parent->getSpouses() as $spouse) {
                    if ($record !== $spouse) {
                        echo '<a href="', $spouse->getHtmlUrl(), '">', $spouse->getFullName(), '</a> — ';
                    }
                }
                echo '<a href="', $parent->getHtmlUrl(), '">', I18N::translate('View family'), '</a><br>';
            } elseif ($parent instanceof Individual) {
                echo '<a href="', $parent->getHtmlUrl(), '">', $parent->getFullName(), '</a><br>';
            }
        }
        // Print the value of this fact/event
        switch ($fact->getTag()) {
            case 'ADDR':
                echo $fact->getValue();
                break;
            case 'AFN':
                echo '<div class="field"><a href="https://familysearch.org/search/tree/results#count=20&query=afn:', Filter::escapeUrl($fact->getValue()), '">', Filter::escapeHtml($fact->getValue()), '</a></div>';
                break;
            case 'ASSO':
                // we handle this later, in format_asso_rela_record()
                break;
            case 'EMAIL':
            case 'EMAI':
            case '_EMAIL':
                echo '<div class="field"><a href="mailto:', Filter::escapeHtml($fact->getValue()), '">', Filter::escapeHtml($fact->getValue()), '</a></div>';
                break;
            case 'FILE':
                if (Auth::isEditor($fact->getParent()->getTree())) {
                    echo '<div class="field">', Filter::escapeHtml($fact->getValue()), '</div>';
                }
                break;
            case 'RESN':
                echo '<div class="field">';
                switch ($fact->getValue()) {
                    case 'none':
                        // Note: "1 RESN none" is not valid gedcom.
                        // However, webtrees privacy rules will interpret it as "show an otherwise private record to public".
                        echo '<i class="icon-resn-none"></i> ', I18N::translate('Show to visitors');
                        break;
                    case 'privacy':
                        echo '<i class="icon-class-none"></i> ', I18N::translate('Show to members');
                        break;
                    case 'confidential':
                        echo '<i class="icon-confidential-none"></i> ', I18N::translate('Show to managers');
                        break;
                    case 'locked':
                        echo '<i class="icon-locked-none"></i> ', I18N::translate('Only managers can edit');
                        break;
                    default:
                        echo Filter::escapeHtml($fact->getValue());
                        break;
                }
                echo '</div>';
                break;
            case 'PUBL':
                // Publication details might contain URLs.
                echo '<div class="field">', Filter::expandUrls($fact->getValue()), '</div>';
                break;
            case 'REPO':
                if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $fact->getValue(), $match)) {
                    self::printRepositoryRecord($match[1]);
                } else {
                    echo '<div class="error">', Filter::escapeHtml($fact->getValue()), '</div>';
                }
                break;
            case 'URL':
            case '_URL':
            case 'WWW':
                echo '<div class="field"><a href="', Filter::escapeHtml($fact->getValue()), '">', Filter::escapeHtml($fact->getValue()), '</a></div>';
                break;
            case 'TEXT':
                // 0 SOUR / 1 TEXT
                echo '<div class="field">', nl2br(Filter::escapeHtml($fact->getValue()), false), '</div>';
                break;
            default:
                // Display the value for all other facts/events
                switch ($fact->getValue()) {
                    case '':
                        // Nothing to display
                        break;
                    case 'N':
                        // Not valid GEDCOM
                        echo '<div class="field">', I18N::translate('No'), '</div>';
                        break;
                    case 'Y':
                        // Do not display "Yes".
                        break;
                    default:
                        if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $fact->getValue(), $match)) {
                            $target = GedcomRecord::getInstance($match[1], $fact->getParent()->getTree());
                            if ($target) {
                                echo '<div><a href="', $target->getHtmlUrl(), '">', $target->getFullName(), '</a></div>';
                            } else {
                                echo '<div class="error">', Filter::escapeHtml($fact->getValue()), '</div>';
                            }
                        } else {
                            echo '<div class="field"><span dir="auto">', Filter::escapeHtml($fact->getValue()), '</span></div>';
                        }
                        break;
                }
                break;
        }
        // Print the type of this fact/event
        if ($type) {
            $utype = strtoupper($type);
            // Events of close relatives, e.g. _MARR_CHIL
            if (substr($fact->getTag(), 0, 6) == '_MARR_' && ($utype == 'CIVIL' || $utype == 'PARTNERS' || $utype == 'RELIGIOUS')) {
                // Translate MARR/TYPE using the code that supports MARR_CIVIL, etc. tags
                $type = GedcomTag::getLabel('MARR_' . $utype);
            } else {
                // Allow (custom) translations for other types
                $type = I18N::translate($type);
            }
            echo GedcomTag::getLabelValue('TYPE', Filter::escapeHtml($type));
        }
        // Print the date of this fact/event
        echo FunctionsPrint::formatFactDate($fact, $record, true, true);
        // Print the place of this fact/event
        echo '<div class="place">', FunctionsPrint::formatFactPlace($fact, true, true, true), '</div>';
        // A blank line between the primary attributes (value, date, place) and the secondary ones
        echo '<br>';
        $addr = $fact->getAttribute('ADDR');
        if ($addr) {
            echo GedcomTag::getLabelValue('ADDR', $addr);
        }
        // Print the associates of this fact/event
        if ($fact->getFactId() !== 'asso') {
            echo self::formatAssociateRelationship($fact);
        }
        // Print any other "2 XXXX" attributes, in the order in which they appear.
        preg_match_all('/\\n2 (' . WT_REGEX_TAG . ') (.+)/', $fact->getGedcom(), $matches, PREG_SET_ORDER);
        foreach ($matches as $match) {
            switch ($match[1]) {
                case 'DATE':
                case 'TIME':
                case 'AGE':
                case 'PLAC':
                case 'ADDR':
                case 'ALIA':
                case 'ASSO':
                case '_ASSO':
                case 'DESC':
                case 'RELA':
                case 'STAT':
                case 'TEMP':
                case 'TYPE':
                case 'FAMS':
                case 'CONT':
                    // These were already shown at the beginning
                    break;
                case 'NOTE':
                case 'OBJE':
                case 'SOUR':
                    // These will be shown at the end
                    break;
                case 'EVEN':
                    // 0 SOUR / 1 DATA / 2 EVEN / 3 DATE / 3 PLAC
                    $events = array();
                    foreach (preg_split('/ *, */', $match[2]) as $event) {
                        $events[] = GedcomTag::getLabel($event);
                    }
                    if (count($events) == 1) {
                        echo GedcomTag::getLabelValue('EVEN', $event);
                    } else {
                        echo GedcomTag::getLabelValue('EVEN', implode(I18N::$list_separator, $events));
                    }
                    if (preg_match('/\\n3 DATE (.+)/', $fact->getGedcom(), $date_match)) {
                        $date = new Date($date_match[1]);
                        echo GedcomTag::getLabelValue('DATE', $date->display());
                    }
                    if (preg_match('/\\n3 PLAC (.+)/', $fact->getGedcom(), $plac_match)) {
                        echo GedcomTag::getLabelValue('PLAC', $plac_match[1]);
                    }
                    break;
                case 'FAMC':
                    // 0 INDI / 1 ADOP / 2 FAMC / 3 ADOP
                    $family = Family::getInstance(str_replace('@', '', $match[2]), $fact->getParent()->getTree());
                    if ($family) {
                        echo GedcomTag::getLabelValue('FAM', '<a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . '</a>');
                        if (preg_match('/\\n3 ADOP (HUSB|WIFE|BOTH)/', $fact->getGedcom(), $match)) {
                            echo GedcomTag::getLabelValue('ADOP', GedcomCodeAdop::getValue($match[1], $label_person));
                        }
                    } else {
                        echo GedcomTag::getLabelValue('FAM', '<span class="error">' . $match[2] . '</span>');
                    }
                    break;
                case '_WT_USER':
                    $user = User::findByIdentifier($match[2]);
                    // may not exist
                    if ($user) {
                        echo GedcomTag::getLabelValue('_WT_USER', $user->getRealNameHtml());
                    } else {
                        echo GedcomTag::getLabelValue('_WT_USER', Filter::escapeHtml($match[2]));
                    }
                    break;
                case 'RESN':
                    switch ($match[2]) {
                        case 'none':
                            // Note: "2 RESN none" is not valid gedcom.
                            // However, webtrees privacy rules will interpret it as "show an otherwise private fact to public".
                            echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-none"></i> ' . I18N::translate('Show to visitors'));
                            break;
                        case 'privacy':
                            echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-privacy"></i> ' . I18N::translate('Show to members'));
                            break;
                        case 'confidential':
                            echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-confidential"></i> ' . I18N::translate('Show to managers'));
                            break;
                        case 'locked':
                            echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-locked"></i> ' . I18N::translate('Only managers can edit'));
                            break;
                        default:
                            echo GedcomTag::getLabelValue('RESN', Filter::escapeHtml($match[2]));
                            break;
                    }
                    break;
                case 'CALN':
                    echo GedcomTag::getLabelValue('CALN', Filter::expandUrls($match[2]));
                    break;
                case 'FORM':
                    // 0 OBJE / 1 FILE / 2 FORM / 3 TYPE
                    echo GedcomTag::getLabelValue('FORM', $match[2]);
                    if (preg_match('/\\n3 TYPE (.+)/', $fact->getGedcom(), $type_match)) {
                        echo GedcomTag::getLabelValue('TYPE', GedcomTag::getFileFormTypeValue($type_match[1]));
                    }
                    break;
                case 'URL':
                case '_URL':
                case 'WWW':
                    $link = '<a href="' . Filter::escapeHtml($match[2]) . '">' . Filter::escapeHtml($match[2]) . '</a>';
                    echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], $link);
                    break;
                default:
                    if (!$fact->getParent()->getTree()->getPreference('HIDE_GEDCOM_ERRORS') || GedcomTag::isTag($match[1])) {
                        if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $match[2], $xmatch)) {
                            // Links
                            $linked_record = GedcomRecord::getInstance($xmatch[1], $fact->getParent()->getTree());
                            if ($linked_record) {
                                $link = '<a href="' . $linked_record->getHtmlUrl() . '">' . $linked_record->getFullName() . '</a>';
                                echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], $link);
                            } else {
                                echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], Filter::escapeHtml($match[2]));
                            }
                        } else {
                            // Non links
                            echo GedcomTag::getLabelValue($fact->getTag() . ':' . $match[1], Filter::escapeHtml($match[2]));
                        }
                    }
                    break;
            }
        }
        echo self::printFactSources($fact->getGedcom(), 2);
        echo FunctionsPrint::printFactNotes($fact->getGedcom(), 2);
        self::printMediaLinks($fact->getGedcom(), 2);
        echo '</td></tr>';
    }
Ejemplo n.º 13
0
 protected function menuMedia()
 {
     $resns = $this->tree->getFactPrivacy();
     if (isset($resns['OBJE'])) {
         $resn = $resns['OBJE'];
     } else {
         $resn = Auth::PRIV_PRIVATE;
     }
     if ($resn >= Auth::accessLevel($this->tree)) {
         $MEDIA_DIRECTORY = $this->tree->getPreference('MEDIA_DIRECTORY');
         $folders = $this->themeOption('mediafolders');
         $show_subfolders = $this->themeOption('show_subfolders') ? '&amp;subdirs=on' : '';
         if (count($folders) > 1) {
             $menu = new Menu(I18N::translate('Media'), '', 'menu-media');
             $submenu = new Menu(I18N::translate('Media'), 'medialist.php?' . $this->tree_url . '&amp;action=filter&amp;search=no&amp;folder=&amp;sortby=title' . $show_subfolders . '&amp;max=20&amp;columns=2&amp;action=submit', 'menu-media-all');
             $menu->addSubmenu($submenu);
             // divider
             $divider = new Menu('', '#', 'menu-media-divider divider');
             $menu->addSubmenu($divider);
             foreach ($folders as $key => $folder) {
                 if ($key !== $MEDIA_DIRECTORY) {
                     $submenu = new Menu(ucfirst($folder), 'medialist.php?' . $this->tree_url . '&amp;action=filter&amp;search=no&amp;folder=' . Filter::escapeUrl($key) . '&amp;sortby=title' . $show_subfolders . '&amp;max=20&amp;columns=2&amp;action=submit', 'menu-media-' . preg_replace('/[^A-Za-z0-9\\. -]/', '', str_replace(" ", "-", $folder)));
                     $menu->addSubmenu($submenu);
                 }
             }
         } else {
             // fallback if we don't have any subfolders added to the list
             $menu = new Menu(I18N::translate('Media'), 'medialist.php?' . $this->tree_url . '&amp;sortby=title&amp;max=20&amp;columns=2&amp;action=submit', 'menu-media');
         }
         return $menu;
     }
 }