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; }
</div> <div> <input type="submit" value="', WT_I18N::translate('Send'), '"> </div> </form> </div>'; break; case 'verify_hash': if (!WT_Site::preference('USE_REGISTRATION_MODULE')) { header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH); exit; } // switch language to webmaster settings $webmaster = User::find(get_gedcom_setting(WT_GED_ID, 'WEBMASTER_USER_ID')); WT_I18N::init($webmaster->getSetting('language')); $user = User::findByIdentifier($user_name); $mail1_body = WT_I18N::translate('Hello administrator…') . WT_Mail::EOL . WT_Mail::EOL . WT_I18N::translate('A new user (%1$s) has requested an account (%2$s) and verified an email address (%3$s).', $user->getRealName(), $user->getUserName(), $user->getEmail()) . WT_Mail::EOL . WT_Mail::EOL; if ($REQUIRE_ADMIN_AUTH_REGISTRATION && !$user->getSetting('verified_by_admin')) { $mail1_body .= WT_I18N::translate('You now need to review the account details, and set the “approved” status to “yes”.'); } else { $mail1_body .= WT_I18N::translate('You do not have to take any action; the user can now login.'); } $mail1_body .= WT_Mail::EOL . '<a href="' . WT_SERVER_NAME . WT_SCRIPT_PATH . "admin_users.php?filter=" . rawurlencode($user->getUserName()) . '">' . WT_SERVER_NAME . WT_SCRIPT_PATH . "admin_users.php?filter=" . rawurlencode($user->getUserName()) . '</a>' . WT_Mail::auditFooter(); $mail1_subject = WT_I18N::translate('New user at %s', WT_SERVER_NAME . WT_SCRIPT_PATH . ' ' . $WT_TREE->tree_title); // Change to the new user’s language WT_I18N::init($user->getSetting('language')); $controller->setPageTitle(WT_I18N::translate('User verification')); $controller->pageHeader(); echo '<div id="login-register-page">'; echo '<h2>' . WT_I18N::translate('User verification') . '</h2>'; echo '<div id="user-verify">';
function user_contact_link($user_id) { $user = User::find($user_id); if ($user) { $method = $user->getSetting('contactmethod'); switch ($method) { case 'none': return ''; case 'mailto': return '<a href="mailto:' . WT_Filter::escapeHtml($user->getEmail()) . '">' . WT_Filter::escapeHtml($user->getRealName($user_id)) . '</a>'; default: return "<a href='#' onclick='message(\"" . WT_Filter::escapeJs($user->getUserName()) . "\", \"" . $method . "\", \"" . WT_SERVER_NAME . WT_SCRIPT_PATH . WT_Filter::escapeJs(get_query_url()) . "\", \"\");return false;'>" . WT_Filter::escapeHtml($user->getRealName($user_id)) . '</a>'; } } else { return ''; } }
private static function _getHitCount($page_name, $params) { if (is_array($params) && isset($params[0]) && $params[0] != '') { $page_parameter = $params[0]; } else { $page_parameter = ''; } if ($page_name === null) { // index.php?ctype=gedcom $page_name = 'index.php'; $page_parameter = 'gedcom:' . get_id_from_gedcom($page_parameter ? $page_parameter : WT_GEDCOM); } elseif ($page_name == 'index.php') { // index.php?ctype=user $user = User::findByIdentifier($page_parameter); $page_parameter = 'user:'******'<span class="hit-counter">' . WT_I18N::number($count) . '</span>'; }
/** * Send an automated system message (such as a password reminder) from a tree to a user. * * @param WT_Tree $tree * @param User $user * @param string $subject * @param string $message * * @return bool */ public static function systemMessage(WT_Tree $tree, User $user, $subject, $message) { return self::send($tree, $user->getEmail(), $user->getRealName(), WT_Site::getPreference('SMTP_FROM_NAME'), $tree->preference('title'), $subject, $message); }
function print_fact(WT_Fact $fact, WT_GedcomRecord $record) { global $HIDE_GEDCOM_ERRORS, $SHOW_FACT_ICONS; static $n_chil = 0, $n_gchi = 0; $parent = $fact->getParent(); // Some facts don't get printed here ... switch ($fact->getTag()) { case 'NOTE': print_main_notes($fact, 1); return; case 'SOUR': print_main_sources($fact, 1); return; case 'OBJE': print_main_media($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 ($HIDE_GEDCOM_ERRORS && !WT_Gedcom_Tag::isTag($fact->getTag())) { return; } break; } // Who is this fact about? Need it to translate fact label correctly if ($parent instanceof WT_Family && $record instanceof WT_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->isNew()) { $styleadd = 'new'; } if ($fact->isOld()) { $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 (WT_Gedcom_Tag::isTag($type)) { // Some users (just Meliza?) use "1 EVEN/2 TYPE BIRT". Translate the TYPE. $label = WT_Gedcom_Tag::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 = WT_I18N::translate(WT_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 = WT_Gedcom_Tag::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 ($SHOW_FACT_ICONS) { echo $fact->Icon(), ' '; } if ($fact->getFactId() != 'histo' && $fact->canEdit()) { ?> <a href="#" title="<?php echo WT_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 WT_I18N::translate('Edit'); ?> " class="editicon" onclick="return edit_record('<?php echo $parent->getXref(); ?> ', '<?php echo $fact->getFactId(); ?> ');" ><span class="link_text"><?php echo WT_I18N::translate('Edit'); ?> </span></a> </div> <div class="copylink"> <a href="#" title="<?php echo WT_I18N::translate('Copy'); ?> " class="copyicon" onclick="return copy_fact('<?php echo $parent->getXref(); ?> ', '<?php echo $fact->getFactId(); ?> ');" ><span class="link_text"><?php echo WT_I18N::translate('Copy'); ?> </span></a> </div> <div class="deletelink"> <a href="#" title="<?php echo WT_I18N::translate('Delete'); ?> " class="deleteicon" onclick="return delete_fact('<?php echo WT_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 WT_I18N::translate('Delete'); ?> </span></a> </div> </div> <?php } else { echo $label; } switch ($fact->getTag()) { case '_BIRT_CHIL': echo '<br>', WT_I18N::translate('#%s', ++$n_chil); break; case '_BIRT_GCHI': case '_BIRT_GCH1': case '_BIRT_GCH2': echo '<br>', WT_I18N::translate('#%s', ++$n_gchi); break; } echo '</td><td class="optionbox ', $styleadd, ' wrap">'; // Event from another record? if ($parent !== $record) { if ($parent instanceof WT_Family) { foreach ($parent->getSpouses() as $spouse) { if ($record !== $spouse) { echo '<a href="', $spouse->getHtmlUrl(), '">', $spouse->getFullName(), '</a> — '; } } echo '<a href="', $parent->getHtmlUrl(), '">', WT_I18N::translate('View family'), '</a><br>'; } elseif ($parent instanceof WT_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:', rawurlencode($fact->getValue()), '" target="new">', WT_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:', WT_Filter::escapeHtml($fact->getValue()), '">', WT_Filter::escapeHtml($fact->getValue()), '</a></div>'; break; case 'FILE': if (WT_USER_CAN_EDIT || WT_USER_CAN_ACCEPT) { echo '<div class="field">', WT_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> ', WT_I18N::translate('Show to visitors'); break; case 'privacy': echo '<i class="icon-class-none"></i> ', WT_I18N::translate('Show to members'); break; case 'confidential': echo '<i class="icon-confidential-none"></i> ', WT_I18N::translate('Show to managers'); break; case 'locked': echo '<i class="icon-locked-none"></i> ', WT_I18N::translate('Only managers can edit'); break; default: echo WT_Filter::escapeHtml($fact->getValue()); break; } echo '</div>'; break; case 'PUBL': // Publication details might contain URLs. echo '<div class="field">', WT_Filter::expandUrls($fact->getValue()), '</div>'; break; case 'REPO': if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $fact->getValue(), $match)) { print_repository_record($match[1]); } else { echo '<div class="error">', WT_Filter::escapeHtml($fact->getValue()), '</div>'; } break; case 'URL': case '_URL': case 'WWW': echo '<div class="field"><a href="', WT_Filter::escapeHtml($fact->getValue()), '">', WT_Filter::escapeHtml($fact->getValue()), '</a></div>'; break; case 'TEXT': // 0 SOUR / 1 TEXT echo '<div class="field">', nl2br(WT_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">', WT_I18N::translate('No'), '</div>'; break; case 'Y': // Do not display "Yes". break; default: if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $fact->getValue(), $match)) { $target = WT_GedcomRecord::getInstance($match[1]); if ($target) { echo '<div><a href="', $target->getHtmlUrl(), '">', $target->getFullName(), '</a></div>'; } else { echo '<div class="error">', WT_Filter::escapeHtml($fact->getValue()), '</div>'; } } else { echo '<div class="field"><span dir="auto">', WT_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 = WT_Gedcom_Tag::getLabel('MARR_' . $utype); } else { // Allow (custom) translations for other types $type = WT_I18N::translate($type); } echo WT_Gedcom_Tag::getLabelValue('TYPE', WT_Filter::escapeHtml($type)); } // Print the date of this fact/event echo format_fact_date($fact, $record, true, true); // Print the place of this fact/event echo '<div class="place">', format_fact_place($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 WT_Gedcom_Tag::getLabelValue('ADDR', $addr); } // Print the associates of this fact/event echo format_asso_rela_record($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[] = WT_Gedcom_Tag::getLabel($event); } if (count($events) == 1) { echo WT_Gedcom_Tag::getLabelValue('EVEN', $event); } else { echo WT_Gedcom_Tag::getLabelValue('EVEN', implode(WT_I18N::$list_separator, $events)); } if (preg_match('/\\n3 DATE (.+)/', $fact->getGedcom(), $date_match)) { $date = new WT_Date($date_match[1]); echo WT_Gedcom_Tag::getLabelValue('DATE', $date->Display()); } if (preg_match('/\\n3 PLAC (.+)/', $fact->getGedcom(), $plac_match)) { echo WT_Gedcom_Tag::getLabelValue('PLAC', $plac_match[1]); } break; case 'FAMC': // 0 INDI / 1 ADOP / 2 FAMC / 3 ADOP $family = WT_Family::getInstance(str_replace('@', '', $match[2])); if ($family) { // May be a pointer to a non-existant record echo WT_Gedcom_Tag::getLabelValue('FAM', '<a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . '</a>'); if (preg_match('/\\n3 ADOP (HUSB|WIFE|BOTH)/', $fact->getGedcom(), $match)) { echo WT_Gedcom_Tag::getLabelValue('ADOP', WT_Gedcom_Code_Adop::getValue($match[1], $label_person)); } } else { echo WT_Gedcom_Tag::getLabelValue('FAM', '<span class="error">' . $match[2] . '</span>'); } break; case '_WT_USER': $user = User::findByIdentifier($match[2]); // may not exist if ($user) { echo WT_Gedcom_Tag::getLabelValue('_WT_USER', WT_Filter::escapeHtml($user->getRealName())); } else { echo WT_Gedcom_Tag::getLabelValue('_WT_USER', WT_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 WT_Gedcom_Tag::getLabelValue('RESN', '<i class="icon-resn-none"></i> ' . WT_I18N::translate('Show to visitors')); break; case 'privacy': echo WT_Gedcom_Tag::getLabelValue('RESN', '<i class="icon-resn-privacy"></i> ' . WT_I18N::translate('Show to members')); break; case 'confidential': echo WT_Gedcom_Tag::getLabelValue('RESN', '<i class="icon-resn-confidential"></i> ' . WT_I18N::translate('Show to managers')); break; case 'locked': echo WT_Gedcom_Tag::getLabelValue('RESN', '<i class="icon-resn-locked"></i> ' . WT_I18N::translate('Only managers can edit')); break; default: echo WT_Gedcom_Tag::getLabelValue('RESN', WT_Filter::escapeHtml($match[2])); break; } break; case 'CALN': echo WT_Gedcom_Tag::getLabelValue('CALN', WT_Filter::expandUrls($match[2])); break; case 'FORM': // 0 OBJE / 1 FILE / 2 FORM / 3 TYPE echo WT_Gedcom_Tag::getLabelValue('FORM', $match[2]); if (preg_match('/\\n3 TYPE (.+)/', $fact->getGedcom(), $type_match)) { echo WT_Gedcom_Tag::getLabelValue('TYPE', WT_Gedcom_Tag::getFileFormTypeValue($type_match[1])); } break; case 'URL': case '_URL': case 'WWW': $link = '<a href="' . WT_Filter::escapeHtml($match[2]) . '">' . WT_Filter::escapeHtml($match[2]) . '</a>'; echo WT_Gedcom_Tag::getLabelValue($fact->getTag() . ':' . $match[1], $link); break; default: if (!$HIDE_GEDCOM_ERRORS || WT_Gedcom_Tag::isTag($match[1])) { if (preg_match('/^@(' . WT_REGEX_XREF . ')@$/', $match[2], $xmatch)) { // Links $linked_record = WT_GedcomRecord::getInstance($xmatch[1]); if ($linked_record) { $link = '<a href="' . $linked_record->getHtmlUrl() . '">' . $linked_record->getFullName() . '</a>'; echo WT_Gedcom_Tag::getLabelValue($fact->getTag() . ':' . $match[1], $link); } else { echo WT_Gedcom_Tag::getLabelValue($fact->getTag() . ':' . $match[1], WT_Filter::escapeHtml($match[2])); } } else { // Non links echo WT_Gedcom_Tag::getLabelValue($fact->getTag() . ':' . $match[1], WT_Filter::escapeHtml($match[2])); } } break; } } echo print_fact_sources($fact->getGedcom(), 2); echo print_fact_notes($fact->getGedcom(), 2); print_media_links($fact->getGedcom(), 2); echo '</td></tr>'; }
/** * print information for a name record * * @param WT_Fact $event the event object */ function print_name_record(WT_Fact $event) { global $WT_TREE; $factrec = $event->getGedcom(); // Create a dummy record, so we can extract the formatted NAME value from the event. $dummy = new WT_Individual('xref', "0 @xref@ INDI\n1 DEAT Y\n" . $factrec, null, WT_GED_ID); $all_names = $dummy->getAllNames(); $primary_name = $all_names[0]; $this->name_count++; if ($this->name_count > 1) { echo '<h3 class="name_two">', $dummy->getFullName(), '</h3>'; } //Other names accordion element echo '<div class="indi_name_details'; if ($event->isOld()) { echo ' old'; } if ($event->isNew()) { echo ' new'; } echo '">'; echo '<div class="name1">'; echo '<dl><dt class="label">', WT_I18N::translate('Name'), '</dt>'; $dummy->setPrimaryName(0); echo '<dd class="field">', $dummy->getFullName(); if ($this->name_count == 1) { if (Auth::isAdmin()) { $user = User::findByGenealogyRecord($WT_TREE, $this->record); if ($user) { echo '<span> - <a class="warning" href="admin_users.php?filter=' . WT_Filter::escapeHtml($user->getUserName()) . '">' . WT_Filter::escapeHtml($user->getUserName()) . '</a></span>'; } } } if ($this->record->canEdit() && !$event->isOld()) { echo "<div class=\"deletelink\"><a class=\"deleteicon\" href=\"#\" onclick=\"return delete_fact('" . WT_I18N::translate('Are you sure you want to delete this fact?') . "', '" . $this->record->getXref() . "', '" . $event->getFactId() . "');\" title=\"" . WT_I18N::translate('Delete this name') . "\"><span class=\"link_text\">" . WT_I18N::translate('Delete this name') . "</span></a></div>"; echo "<div class=\"editlink\"><a href=\"#\" class=\"editicon\" onclick=\"edit_name('" . $this->record->getXref() . "', '" . $event->getFactId() . "'); return false;\" title=\"" . WT_I18N::translate('Edit name') . "\"><span class=\"link_text\">" . WT_I18N::translate('Edit name') . "</span></a></div>"; } echo '</dd>'; echo '</dl>'; echo '</div>'; $ct = preg_match_all('/\\n2 (\\w+) (.*)/', $factrec, $nmatch, PREG_SET_ORDER); for ($i = 0; $i < $ct; $i++) { echo '<div>'; $fact = $nmatch[$i][1]; if ($fact != 'SOUR' && $fact != 'NOTE' && $fact != 'SPFX') { echo '<dl><dt class="label">', WT_Gedcom_Tag::getLabel($fact, $this->record), '</dt>'; echo '<dd class="field">'; // Before using dir="auto" on this field, note that Gecko treats this as an inline element but WebKit treats it as a block element if (isset($nmatch[$i][2])) { $name = WT_Filter::escapeHtml($nmatch[$i][2]); $name = str_replace('/', '', $name); $name = preg_replace('/(\\S*)\\*/', '<span class="starredname">\\1</span>', $name); switch ($fact) { case 'TYPE': echo WT_Gedcom_Code_Name::getValue($name, $this->record); break; case 'SURN': // The SURN field is not necessarily the surname. // Where it is not a substring of the real surname, show it after the real surname. $surname = WT_Filter::escapeHtml($primary_name['surname']); if (strpos($primary_name['surname'], str_replace(',', ' ', $nmatch[$i][2])) !== false) { echo $surname; } else { echo WT_I18N::translate('%1$s (%2$s)', $surname, $name); } break; default: echo $name; break; } } echo '</dd>'; echo '</dl>'; } echo '</div>'; } if (preg_match("/\n2 SOUR/", $factrec)) { echo '<div id="indi_sour" class="clearfloat">', print_fact_sources($factrec, 2), '</div>'; } if (preg_match("/\n2 NOTE/", $factrec)) { echo '<div id="indi_note" class="clearfloat">', print_fact_notes($factrec, 2), '</div>'; } echo '</div>'; }
// Cannot determine the latest version $latest_version = ''; } // Delete old files (if we can). $old_files = array(); foreach (old_paths() as $path) { if (file_exists($path)) { delete_recursively($path); // we may not have permission to delete. Is it still there? if (file_exists($path)) { $old_files[] = $path; } } } // Total number of users $total_users = User::count(); // Total number of administrators $total_administrators = WT_DB::prepare("SELECT COUNT(*) FROM `##user_setting` WHERE setting_name='canadmin' AND setting_value=1")->fetchOne(); // Total numbers of managers $total_managers = WT_DB::prepare("SELECT gs.setting_value, COUNT(*)" . " FROM `##gedcom_setting` gs" . " JOIN `##user_gedcom_setting` ugs USING (gedcom_id)" . " WHERE ugs.setting_name = 'canedit' AND ugs.setting_value='admin'" . " AND gs.setting_name ='title'" . " GROUP BY gedcom_id" . " ORDER BY gs.setting_value")->fetchAssoc(); // Number of users who have not verified their email address $unverified = WT_DB::prepare("SELECT COUNT(*) FROM `##user_setting` WHERE setting_name='verified' AND setting_value=0")->fetchOne(); // Number of users whose accounts are not approved by an administrator $unapproved = WT_DB::prepare("SELECT COUNT(*) FROM `##user_setting` WHERE setting_name='verified_by_admin' AND setting_value=0")->fetchOne(); // Number of users of each language $user_languages = WT_DB::prepare("SELECT setting_value, COUNT(*)" . " FROM `##user_setting`" . " WHERE setting_name = 'language'" . " GROUP BY setting_value")->fetchAssoc(); $stats = new WT_Stats(WT_GEDCOM); ?> <div id="content_container" style="visibility: hidden;"> <div id="x"> <h2><?php
$in_progress = WT_DB::prepare("SELECT 1 FROM `##gedcom_chunk` WHERE gedcom_id=? AND imported=1 LIMIT 1")->execute(array($tree->tree_id))->fetchOne(); if (!$in_progress) { echo '<div id="import', $tree->tree_id, '"><div id="progressbar', $tree->tree_id, '"><div style="position:absolute;">', WT_I18N::translate('Deleting old genealogy data…'), '</div></div></div>'; $controller->addInlineJavascript('jQuery("#progressbar' . $tree->tree_id . '").progressbar({value: 0});'); } else { echo '<div id="import', $tree->tree_id, '"></div>'; } $controller->addInlineJavascript('jQuery("#import' . $tree->tree_id . '").load("import.php?gedcom_id=' . $tree->tree_id . '&keep_media' . $tree->tree_id . '=' . WT_Filter::get('keep_media' . $tree->tree_id) . '");'); echo '<table border="0" width="100%" id="actions', $tree->tree_id, '" style="display:none">'; } else { echo '<table border="0" width="100%" id="actions', $tree->tree_id, '">'; } echo '<tr align="center">', '<td><a href="admin_trees_export.php?ged=', $tree->tree_name_url, '" onclick="return modalDialog(\'admin_trees_export.php?ged=', $tree->tree_name_url, '\', \'', WT_I18N::translate('Export'), '\');">', WT_I18N::translate('Export'), '</a>', help_link('export_gedcom'), '</td>', '<td><a href="', WT_SCRIPT_NAME, '?action=importform&gedcom_id=', $tree->tree_id, '">', WT_I18N::translate('Import'), '</a>', help_link('import_gedcom'), '</td>', '<td><a href="admin_trees_download.php?ged=', $tree->tree_name_url, '">', WT_I18N::translate('Download'), '</a>', help_link('download_gedcom'), '</td>', '<td><a href="', WT_SCRIPT_NAME, '?action=uploadform&gedcom_id=', $tree->tree_id, '">', WT_I18N::translate('Upload'), '</a>', help_link('upload_gedcom'), '</td>', '<td>', '<a href="#" onclick="if (confirm(\'' . WT_Filter::escapeJs(WT_I18N::translate('Are you sure you want to delete “%s”?', $tree->tree_name)), '\')) document.delete_form', $tree->tree_id, '.submit(); return false;">', WT_I18N::translate('Delete'), '</a>', '<form name="delete_form', $tree->tree_id, '" method="post" action="', WT_SCRIPT_NAME, '">', '<input type="hidden" name="action" value="delete">', '<input type="hidden" name="gedcom_id" value="', $tree->tree_id, '">', WT_Filter::getCsrf(), '</form>', '</td></tr></table></td></tr></table><br>'; } } // Options for creating new gedcoms and setting defaults if (Auth::isAdmin()) { echo '<table class="gedcom_table2"><tr>'; if (count(WT_Tree::GetAll()) > 1) { echo '<th>', WT_I18N::translate('Default family tree'), help_link('default_gedcom'), '</th>'; } echo '<th>', WT_I18N::translate('Create a new family tree'), help_link('add_new_gedcom'), '</th></tr><tr>'; if (count(WT_Tree::GetAll()) > 1) { echo '<td><form name="defaultform" method="post" action="', WT_SCRIPT_NAME, '">', '<input type="hidden" name="action" value="setdefault">', WT_Filter::getCsrf(), select_edit_control('default_ged', WT_Tree::getNameList(), '', WT_Site::preference('DEFAULT_GEDCOM'), 'onchange="document.defaultform.submit();"'), '</form></td>'; } echo '<td class="button">', '<form name="createform" method="post" action="', WT_SCRIPT_NAME, '">', WT_Filter::getCsrf(), '<input type="hidden" name="action" value="new_tree">', '<input name="ged_name">', ' <input type="submit" value="', WT_I18N::translate('save'), '">', '</form>', '</td>', '</tr></table><br>'; // display link to PGV-WT transfer wizard on first visit to this page, before any GEDCOM is loaded if (count(WT_Tree::GetAll()) == 0 && count(User::all()) == 1) { echo '<div class="center">', '<a style="color:green; font-weight:bold;" href="admin_pgv_to_wt.php">', WT_I18N::translate('Click here for PhpGedView to <b>webtrees</b> transfer wizard'), '</a>', help_link('PGV_WIZARD'), '</div>'; } }
public function getBlock($block_id, $template = true, $cfg = null) { global $ctype; require_once WT_ROOT . 'includes/functions/functions_print_facts.php'; // Block actions $action = WT_Filter::get('action'); $message_id = WT_Filter::getArray('message_id'); if ($action == 'deletemessage') { foreach ($message_id as $msg_id) { deleteMessage($msg_id); } } $block = get_block_setting($block_id, 'block', true); if ($cfg) { foreach (array('block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } } $messages = getUserMessages(WT_USER_ID); $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; $title = WT_I18N::plural('%s message', '%s messages', count($messages), WT_I18N::number(count($messages))); $content = '<form name="messageform" action="index.php?ctype=' . $ctype . '" method="get" onsubmit="return confirm(\'' . WT_I18N::translate('Are you sure you want to delete this message? It cannot be retrieved later.') . '\');">'; if (count(User::all()) > 1) { $content .= '<br>' . WT_I18N::translate('Send message') . " <select name=\"touser\">"; $content .= '<option value="">' . WT_I18N::translate('<select>') . '</option>'; foreach (User::all() as $user) { if ($user->getUserId() != WT_USER_ID && $user->getSetting('verified_by_admin') && $user->getSetting('contactmethod') != 'none') { $content .= '<option value="' . WT_Filter::escapeHtml($user->getUserName()) . '">'; $content .= '<span dir="auto">' . WT_Filter::escapeHtml($user->getRealName()) . '</span> - <span dir="auto">' . WT_Filter::escapeHtml($user->getUserName()) . '</span>'; $content .= '</option>'; } } $content .= '</select> <input type="button" value="' . WT_I18N::translate('Send') . '" onclick="message(document.messageform.touser.options[document.messageform.touser.selectedIndex].value, \'messaging2\', \'\'); return false;"><br><br>'; } if (count($messages) == 0) { $content .= WT_I18N::translate('You have no pending messages.') . "<br>"; } else { $content .= '<input type="hidden" name="action" value="deletemessage">'; $content .= '<table class="list_table"><tr>'; $content .= '<td class="list_label">' . WT_I18N::translate('Delete') . '<br><a href="#" onclick="jQuery(\'#' . $this->getName() . $block_id . ' :checkbox\').prop(\'checked\', true); return false;">' . WT_I18N::translate('All') . '</a></td>'; $content .= '<td class="list_label">' . WT_I18N::translate('Subject:') . '</td>'; $content .= '<td class="list_label">' . WT_I18N::translate('Date sent:') . '</td>'; $content .= '<td class="list_label">' . WT_I18N::translate('Email address:') . '</td>'; $content .= '</tr>'; foreach ($messages as $message) { $content .= '<tr>'; $content .= '<td class="list_value_wrap"><input type="checkbox" id="cb_message' . $message->message_id . '" name="message_id[]" value="' . $message->message_id . '"></td>'; $content .= '<td class="list_value_wrap"><a href="#" onclick="return expand_layer(\'message' . $message->message_id . '\');"><i id="message' . $message->message_id . '_img" class="icon-plus"></i> <b dir="auto">' . WT_Filter::escapeHtml($message->subject) . '</b></a></td>'; $content .= '<td class="list_value_wrap">' . format_timestamp($message->created) . '</td>'; $content .= '<td class="list_value_wrap">'; $user = User::findByIdentifier($message->sender); if ($user) { $content .= '<span dir="auto">' . $user->getRealName() . '</span>'; $content .= ' - <span dir="auto">' . $user->getEmail() . '</span>'; } else { $content .= '<a href="mailto:' . WT_Filter::escapeHtml($message->sender) . '">' . WT_Filter::escapeHtml($message->sender) . '</a>'; } $content .= '</td>'; $content .= '</tr>'; $content .= '<tr><td class="list_value_wrap" colspan="5"><div id="message' . $message->message_id . '" style="display:none;">'; $content .= '<div dir="auto" style="white-space: pre-wrap;">' . WT_Filter::expandUrls($message->body) . '</div><br>'; if (strpos($message->subject, WT_I18N::translate('RE: ')) !== 0) { $message->subject = WT_I18N::translate('RE: ') . $message->subject; } if ($user) { $content .= '<a href="#" onclick="reply(\'' . WT_Filter::escapeJs($message->sender) . '\', \'' . WT_Filter::escapeJs($message->subject) . '\'); return false;">' . WT_I18N::translate('Reply') . '</a> | '; } $content .= '<a href="index.php?action=deletemessage&message_id[]=' . $message->message_id . '" onclick="return confirm(\'' . WT_I18N::translate('Are you sure you want to delete this message? It cannot be retrieved later.') . '\');">' . WT_I18N::translate('Delete') . '</a></div></td></tr>'; } $content .= '</table>'; $content .= '<input type="submit" value="' . WT_I18N::translate('Delete selected messages') . '"><br>'; } $content .= '</form>'; if ($template) { if ($block) { require WT_THEME_DIR . 'templates/block_small_temp.php'; } else { require WT_THEME_DIR . 'templates/block_main_temp.php'; } } else { return $content; } }
$form_action = WT_Filter::post('form_action'); $form_username = WT_Filter::post('form_username'); $form_realname = WT_Filter::post('form_realname'); $form_pass1 = WT_Filter::post('form_pass1', WT_REGEX_PASSWORD); $form_pass2 = WT_Filter::post('form_pass2', WT_REGEX_PASSWORD); $form_email = WT_Filter::postEmail('form_email'); $form_rootid = WT_Filter::post('form_rootid', WT_REGEX_XREF); $form_theme = WT_Filter::post('form_theme', implode('|', $ALL_THEME_DIRS)); $form_language = WT_Filter::post('form_language', implode('|', array_keys(WT_I18N::installed_languages())), WT_LOCALE); $form_contact_method = WT_Filter::post('form_contact_method'); $form_visible_online = WT_Filter::postBool('form_visible_online'); // Respond to form action if ($form_action == 'update' && WT_Filter::checkCsrf()) { if ($form_username != Auth::user()->getUserName() && User::findByIdentifier($form_username)) { WT_FlashMessages::addMessage(WT_I18N::translate('Duplicate user name. A user with that user name already exists. Please choose another user name.')); } elseif ($form_email != Auth::user()->getEmail() && User::findByIdentifier($form_email)) { WT_FlashMessages::addMessage(WT_I18N::translate('Duplicate email address. A user with that email already exists.')); } else { // Change username if ($form_username != WT_USER_NAME) { Log::addAuthenticationLog('User ' . Auth::user()->getUserName() . ' renamed to ' . $form_username); Auth::user()->setUserName($form_username); } // Change password if ($form_pass1 && $form_pass1 == $form_pass2) { Auth::user()->setPassword($form_pass1); } // Change other settings Auth::user()->setRealName($form_realname)->setEmail($form_email)->setSetting('theme', $form_theme)->setSetting('language', $form_language)->setSetting('contactmethod', $form_contact_method)->setSetting('visibleonline', $form_visible_online); $WT_TREE->userPreference(WT_USER_ID, 'rootid', $form_rootid); // Reload page to pick up changes such as theme and user_id
public function __construct() { global $SCRIPT_NAME, $MEDIA_DIRECTORY, $WT_SESSION; // Our cart is an array of items in the session if (!is_array($WT_SESSION->cart)) { $WT_SESSION->cart = array(); } if (!array_key_exists(WT_GED_ID, $WT_SESSION->cart)) { $WT_SESSION->cart[WT_GED_ID] = array(); } $this->action = WT_Filter::get('action'); $this->id = WT_Filter::get('id'); $convert = WT_Filter::get('convert', 'yes|no', 'no'); $this->Zip = WT_Filter::get('Zip'); $this->IncludeMedia = WT_Filter::get('IncludeMedia'); $this->conv_path = WT_Filter::get('conv_path'); $this->privatize_export = WT_Filter::get('privatize_export', 'none|visitor|user|gedadmin', 'visitor'); $this->level1 = WT_Filter::getInteger('level1'); $this->level2 = WT_Filter::getInteger('level2'); $this->level3 = WT_Filter::getInteger('level3'); $others = WT_Filter::get('others'); $this->type = WT_Filter::get('type'); if (($this->privatize_export == 'none' || $this->privatize_export == 'none') && !WT_USER_GEDCOM_ADMIN) { $this->privatize_export = 'visitor'; } if ($this->privatize_export == 'user' && !WT_USER_CAN_ACCESS) { $this->privatize_export = 'visitor'; } if ($this->action == 'add') { if (empty($this->type) && !empty($this->id)) { $this->type = ""; $obj = WT_GedcomRecord::getInstance($this->id); if (is_null($obj)) { $this->id = ""; $this->action = ""; } else { $this->type = strtolower($obj::RECORD_TYPE); } } else { if (empty($this->id)) { $this->action = ""; } } if (!empty($this->id) && $this->type != 'fam' && $this->type != 'indi' && $this->type != 'sour') { $this->action = 'add1'; } } if ($this->action == 'add1') { $obj = WT_GedcomRecord::getInstance($this->id); $this->addClipping($obj); if ($this->type == 'sour') { if ($others == 'linked') { foreach ($obj->linkedIndividuals('SOUR') as $indi) { $this->addClipping($indi); } foreach ($obj->linkedFamilies('SOUR') as $fam) { $this->addClipping($fam); } } } if ($this->type == 'fam') { if ($others == 'parents') { $this->addClipping($obj->getHusband()); $this->addClipping($obj->getWife()); } elseif ($others == "members") { $this->addFamilyMembers(WT_Family::getInstance($this->id)); } elseif ($others == "descendants") { $this->addFamilyDescendancy(WT_Family::getInstance($this->id)); } } elseif ($this->type == 'indi') { if ($others == 'parents') { foreach (WT_Individual::getInstance($this->id)->getChildFamilies() as $family) { $this->addFamilyMembers($family); } } elseif ($others == 'ancestors') { $this->addAncestorsToCart(WT_Individual::getInstance($this->id), $this->level1); } elseif ($others == 'ancestorsfamilies') { $this->addAncestorsToCartFamilies(WT_Individual::getInstance($this->id), $this->level2); } elseif ($others == 'members') { foreach (WT_Individual::getInstance($this->id)->getSpouseFamilies() as $family) { $this->addFamilyMembers($family); } } elseif ($others == 'descendants') { foreach (WT_Individual::getInstance($this->id)->getSpouseFamilies() as $family) { $this->addClipping($family); $this->addFamilyDescendancy($family, $this->level3); } } uksort($WT_SESSION->cart[WT_GED_ID], array('WT_Controller_Clippings', 'compareClippings')); } } elseif ($this->action == 'remove') { unset($WT_SESSION->cart[WT_GED_ID][$this->id]); } elseif ($this->action == 'empty') { $WT_SESSION->cart[WT_GED_ID] = array(); } elseif ($this->action == 'download') { $media = array(); $mediacount = 0; $filetext = gedcom_header(WT_GEDCOM); // Include SUBM/SUBN records, if they exist $subn = WT_DB::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?")->execute(array('SUBN', WT_GED_ID))->fetchOne(); if ($subn) { $filetext .= $subn . "\n"; } $subm = WT_DB::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?")->execute(array('SUBM', WT_GED_ID))->fetchOne(); if ($subm) { $filetext .= $subm . "\n"; } if ($convert == "yes") { $filetext = str_replace("UTF-8", "ANSI", $filetext); $filetext = utf8_decode($filetext); } switch ($this->privatize_export) { case 'gedadmin': $access_level = WT_PRIV_NONE; break; case 'user': $access_level = WT_PRIV_USER; break; case 'visitor': $access_level = WT_PRIV_PUBLIC; break; case 'none': $access_level = WT_PRIV_HIDE; break; } foreach (array_keys($WT_SESSION->cart[WT_GED_ID]) as $xref) { $object = WT_GedcomRecord::getInstance($xref); if ($object) { // The object may have been deleted since we added it to the cart.... $record = $object->privatizeGedcom($access_level); // Remove links to objects that aren't in the cart preg_match_all('/\\n1 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\\n[2-9].*)*/', $record, $matches, PREG_SET_ORDER); foreach ($matches as $match) { if (!array_key_exists($match[1], $WT_SESSION->cart[WT_GED_ID])) { $record = str_replace($match[0], '', $record); } } preg_match_all('/\\n2 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\\n[3-9].*)*/', $record, $matches, PREG_SET_ORDER); foreach ($matches as $match) { if (!array_key_exists($match[1], $WT_SESSION->cart[WT_GED_ID])) { $record = str_replace($match[0], '', $record); } } preg_match_all('/\\n3 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\\n[4-9].*)*/', $record, $matches, PREG_SET_ORDER); foreach ($matches as $match) { if (!array_key_exists($match[1], $WT_SESSION->cart[WT_GED_ID])) { $record = str_replace($match[0], '', $record); } } $record = convert_media_path($record, $this->conv_path); $savedRecord = $record; // Save this for the "does this file exist" check if ($convert == 'yes') { $record = utf8_decode($record); } switch ($object::RECORD_TYPE) { case 'INDI': $filetext .= $record . "\n"; $filetext .= "1 SOUR @WEBTREES@\n"; $filetext .= "2 PAGE " . WT_SERVER_NAME . WT_SCRIPT_PATH . $object->getRawUrl() . "\n"; break; case 'FAM': $filetext .= $record . "\n"; $filetext .= "1 SOUR @WEBTREES@\n"; $filetext .= "2 PAGE " . WT_SERVER_NAME . WT_SCRIPT_PATH . $object->getRawUrl() . "\n"; break; case 'SOUR': $filetext .= $record . "\n"; $filetext .= "1 NOTE " . WT_SERVER_NAME . WT_SCRIPT_PATH . $object->getRawUrl() . "\n"; break; default: $ft = preg_match_all("/\n\\d FILE (.+)/", $savedRecord, $match, PREG_SET_ORDER); for ($k = 0; $k < $ft; $k++) { // Skip external files and non-existant files if (file_exists(WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1])) { $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1], PCLZIP_ATT_FILE_NEW_FULL_NAME => $match[$k][1]); $mediacount++; } } $filetext .= trim($record) . "\n"; break; } } } if ($this->IncludeMedia == "yes") { $this->media_list = $media; } $filetext .= "0 @WEBTREES@ SOUR\n1 TITL " . WT_SERVER_NAME . WT_SCRIPT_PATH . "\n"; if ($user_id = get_gedcom_setting(WT_GED_ID, 'CONTACT_EMAIL')) { $user = User::find($user_id); $filetext .= "1 AUTH " . $user->getRealName() . "\n"; } $filetext .= "0 TRLR\n"; //-- make sure the preferred line endings are used $filetext = preg_replace("/[\r\n]+/", WT_EOL, $filetext); $this->download_data = $filetext; $this->downloadClipping(); } }
public function getFacebookUsernameForINDI($indi) { global $WT_TREE; // If they have an account, look for the link on their user record. if ($user = User::findByGenealogyRecord($WT_TREE, $indi)) { return $user->getPreference(self::user_setting_facebook_username); } // Otherwise, look in the list of pre-approved users. $preApproved = unserialize($this->getSetting('preapproved')); if (empty($preApproved)) { return NULL; } foreach ($preApproved as $fbUsername => $details) { if ($indi->getXref() == @$details[$WT_TREE->tree_id]['gedcomid']) { return $fbUsername; } } return NULL; }
} } ?> </select> </td> </tr> <tr> <td> <?php echo WT_I18N::translate('Technical help contact'), help_link('WEBMASTER_USER_ID'); ?> </td> <td><select name="NEW_WEBMASTER_USER_ID"> <?php $WEBMASTER_USER_ID = get_gedcom_setting(WT_GED_ID, 'WEBMASTER_USER_ID'); foreach (User::allAdmins() as $user) { echo '<option value="' . $user->getUserId() . '"'; if ($WEBMASTER_USER_ID == $user->getUserId()) { echo ' selected="selected"'; } echo '>' . $user->getRealName() . ' - ' . $user->getUserName() . '</option>'; } ?> </select> </td> </tr> </table> <table> <tr> <th colspan="2"><?php echo WT_I18N::translate('Web site and META tag settings');
public function getBlock($block_id, $template = true, $cfg = null) { global $ctype, $WEBTREES_EMAIL; $changes = WT_DB::prepare("SELECT 1" . " FROM `##change`" . " WHERE status='pending'" . " LIMIT 1")->fetchOne(); $days = get_block_setting($block_id, 'days', 1); $sendmail = get_block_setting($block_id, 'sendmail', true); $block = get_block_setting($block_id, 'block', true); if ($cfg) { foreach (array('days', 'sendmail', 'block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } } if ($changes && $sendmail == 'yes') { // There are pending changes - tell moderators/managers/administrators about them. if (WT_TIMESTAMP - WT_Site::getPreference('LAST_CHANGE_EMAIL') > 60 * 60 * 24 * $days) { // Which users have pending changes? foreach (User::all() as $user) { if ($user->getSetting('contactmethod') !== 'none') { foreach (WT_Tree::getAll() as $tree) { if (exists_pending_change($user, $tree)) { WT_I18N::init($user->getSetting('language')); WT_Mail::systemMessage($tree, $user, WT_I18N::translate('Pending changes'), WT_I18N::translate('There are pending changes for you to moderate.') . WT_Mail::EOL . WT_MAIL::EOL . '<a href="' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'index.php?ged=' . WT_GEDURL . '">' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'index.php?ged=' . WT_GEDURL . '</a>'); WT_I18N::init(WT_LOCALE); } } } } WT_Site::setPreference('LAST_CHANGE_EMAIL', WT_TIMESTAMP); } if (WT_USER_CAN_EDIT) { $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) { $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; } $title .= $this->getTitle() . help_link('review_changes', $this->getName()); $content = ''; if (WT_USER_CAN_ACCEPT) { $content .= "<a href=\"#\" onclick=\"window.open('edit_changes.php','_blank', chan_window_specs); return false;\">" . WT_I18N::translate('There are pending changes for you to moderate.') . "</a><br>"; } if ($sendmail == "yes") { $content .= WT_I18N::translate('Last email reminder was sent ') . format_timestamp(WT_Site::getPreference('LAST_CHANGE_EMAIL')) . "<br>"; $content .= WT_I18N::translate('Next email reminder will be sent after ') . format_timestamp(WT_Site::getPreference('LAST_CHANGE_EMAIL') + 60 * 60 * 24 * $days) . "<br><br>"; } $changes = WT_DB::prepare("SELECT xref" . " FROM `##change`" . " WHERE status='pending'" . " AND gedcom_id=?" . " GROUP BY xref")->execute(array(WT_GED_ID))->fetchAll(); foreach ($changes as $change) { $record = WT_GedcomRecord::getInstance($change->xref); if ($record->canShow()) { $content .= '<b>' . $record->getFullName() . '</b>'; $content .= $block ? '<br>' : ' '; $content .= '<a href="' . $record->getHtmlUrl() . '">' . WT_I18N::translate('View the changes') . '</a>'; $content .= '<br>'; } } if ($template) { if ($block) { require WT_THEME_DIR . 'templates/block_small_temp.php'; } else { require WT_THEME_DIR . 'templates/block_main_temp.php'; } } else { return $content; } } } }
} // Delete the record itself $record->deleteRecord(); } else { header('HTTP/1.0 406 Not Acceptable'); } break; case 'delete-user': $user = User::find(WT_Filter::postInteger('user_id')); if ($user && Auth::isAdmin() && Auth::user() !== $user) { Log::addAuthenticationLog('Deleted user: '******'masquerade': $user = User::find(WT_Filter::postInteger('user_id')); if ($user && Auth::isAdmin() && Auth::user() !== $user) { Log::addAuthenticationLog('Masquerade as user: '******'HTTP/1.0 406 Not Acceptable'); } break; case 'unlink-media': // Remove links from an individual and their spouse-family records to a media object. // Used by the "unlink" option on the album (lightbox) tab. require WT_ROOT . 'includes/functions/functions_edit.php'; $source = WT_Individual::getInstance(WT_Filter::post('source', WT_REGEX_XREF)); $target = WT_Filter::post('target', WT_REGEX_XREF); if ($source && $source->canShow() && $source->canEdit() && $target) { // Consider the individual and their spouse-family records
/** * Create a new user. * * The calling code needs to check for duplicates identifiers before calling * this function. * * @param string $user_name * @param string $real_name * @param string $email * @param string $password * * @return User */ public static function create($user_name, $real_name, $email, $password) { WT_DB::prepare("INSERT INTO `##user` (user_name, real_name, email, password) VALUES (?, ?, ?, ?)")->execute(array($user_name, $real_name, $email, password_hash($password, PASSWORD_DEFAULT))); return User::findByIdentifier($user_name); }
/** * Login directly as an explicit user - for masquerading. * * @param User $user */ public static function login(User $user) { global $WT_SESSION; $WT_SESSION->wt_user = $user->getUserId(); Zend_Session::regenerateId(); }
} // 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) . '&to=' . rawurlencode($to) . '&type=' . rawurlencode($type) . '&text=' . rawurlencode($text) . '&ip=' . rawurlencode($ip) . '&user='******'&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>'; }
case 'themes/simplygreen/': case 'themes/simplyred/': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'colors')); break; case 'themes/xenea/': $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'xenea')); break; default: $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'webtrees')); break; } $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THUMBNAIL_WIDTH', $THUMBNAIL_WIDTH)); $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'USE_RELATIONSHIP_PRIVACY', $USE_RELATIONSHIP_PRIVACY)); $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'USE_RIN', $USE_RIN)); $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'WATERMARK_THUMB', $WATERMARK_THUMB)); @$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'WEBMASTER_USER_ID', User::findByIdentifier($WEBMASTER_EMAIL)->getUserId())); $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES)); } WT_DB::prepare("DELETE FROM `##gedcom_setting` WHERE setting_name in ('config', 'privacy', 'path', 'pgv_ver', 'imported')")->execute(); // webtrees 1.0.5 combines user and gedcom settings for relationship privacy // into a combined user-gedcom setting, for more granular control WT_DB::exec("INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value)" . " SELECT u.user_id, g.gedcom_id, 'RELATIONSHIP_PATH_LENGTH', LEAST(us1.setting_value, gs1.setting_value)" . " FROM `##user` u" . " CROSS JOIN `##gedcom` g" . " LEFT JOIN `##user_setting` us1 ON (u.user_id =us1.user_id AND us1.setting_name='max_relation_path')" . " LEFT JOIN `##user_setting` us2 ON (u.user_id =us2.user_id AND us2.setting_name='relationship_privacy')" . " LEFT JOIN `##gedcom_setting` gs1 ON (g.gedcom_id=gs1.gedcom_id AND gs1.setting_name='MAX_RELATION_PATH_LENGTH')" . " LEFT JOIN `##gedcom_setting` gs2 ON (g.gedcom_id=gs2.gedcom_id AND gs2.setting_name='USE_RELATIONSHIP_PRIVACY')" . " WHERE us2.setting_value AND gs2.setting_value"); WT_DB::exec("DELETE FROM `##gedcom_setting` WHERE setting_name IN ('MAX_RELATION_PATH_LENGTH', 'USE_RELATIONSHIP_PRIVACY')"); WT_DB::exec("DELETE FROM `##user_setting` WHERE setting_name IN ('relationship_privacy', 'max_relation_path_length')"); //////////////////////////////////////////////////////////////////////////////// // The PGV blocks don't migrate easily. // Just give everybody and every tree default blocks //////////////////////////////////////////////////////////////////////////////// WT_DB::prepare("INSERT INTO `##block` (user_id, location, block_order, module_name)" . " SELECT `##user`.user_id, location, block_order, module_name" . " FROM `##block`" . " JOIN `##user`" . " WHERE `##block`.user_id = -1" . " AND `##user`.user_id > 0")->execute(); WT_DB::prepare("INSERT INTO `##block` (gedcom_id, location, block_order, module_name)" . " SELECT `##gedcom`.gedcom_id, location, block_order, module_name" . " FROM `##block`" . " JOIN `##gedcom`" . " WHERE `##block`.gedcom_id = -1" . " AND `##gedcom`.gedcom_id > 0")->execute(); ////////////////////////////////////////////////////////////////////////////////
</table> <p> <?php if ($ucnt > 0) { ?> <input type="submit" value="<?php echo WT_I18N::translate('continue'); ?> "> <?php } ?> </p> </form><?php break; case 'cleanup2': foreach (User::all() as $user) { if (WT_Filter::post('del_' . $user->getUserId()) == '1') { Log::addAuthenticationLog('Deleted user: '******'Deleted user: '******'<br>'; $user->delete(); } } 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,
case 'RELATIONSHIP_PATH_LENGTH': $tree = WT_Tree::get($id2); if (Auth::isManager($tree)) { $tree->userPreference($id1, $id3, $value); ok(); break; } } fail(); break; case 'user_setting': ////////////////////////////////////////////////////////////////////////////// // Table name: WT_USER_SETTING // ID format: user_setting-{user_id}-{setting_name} ////////////////////////////////////////////////////////////////////////////// $user = User::find($id1); // Authorisation if (!(Auth::isAdmin() || $user && $user->getSetting('editaccount') && in_array($id2, array('language', 'visible_online', 'contact_method')))) { fail(); } // Validation switch ($id2) { case 'canadmin': // Cannot change our own admin status - either to add it or remove it if (Auth::user() == $user) { fail(); } break; case 'verified_by_admin': // Approving for the first time? Send a confirmation email if ($value && !$user->getSetting('verified_by_admin') && $user->getSetting('sessiontime') == 0) {