Exemplo n.º 1
0
 /**
  * Count the number of administrators.
  *
  * @return string
  */
 public function totalNonAdmins()
 {
     return I18N::number(count(User::all()) - count(User::allAdmins()));
 }
Exemplo n.º 2
0
">
			<?php 
        } else {
            ?>
			<?php 
            echo I18N::translate('Nothing found to cleanup');
            ?>
			<?php 
        }
        ?>
		</p>
	</form>
	<?php 
        break;
    case 'cleanup2':
        foreach (User::all() as $user) {
            if (Filter::post('del_' . $user->getUserId()) == '1') {
                Log::addAuthenticationLog('Deleted user: '******'The user %s has been deleted.', Filter::escapeHtml($user->getUserName()));
            }
        }
        header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
        break;
    default:
        $controller->setPageTitle(I18N::translate('User administration'))->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)->addInlineJavascript('
			jQuery(".table-user-list").dataTable({
				' . I18N::datatablesI18N() . ',
				stateSave: true,
				stateDuration: 300,
				processing: true,
Exemplo n.º 3
0
								<?php 
    echo I18N::translate('After creating the family tree, you will be able to import data from a GEDCOM file.');
    ?>
							</p>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
	<?php 
}
?>
	<!-- display link to PhpGedView-WT transfer wizard on first visit to this page, before any GEDCOM is loaded -->
	<?php 
if (count(Tree::GetAll()) === 0 && count(User::all()) === 1) {
    ?>
	<div class="panel panel-default">
		<div class="panel-heading">
			<h2 class="panel-title">
			<i class="fa fa-fw fa-magic"></i>
			<a data-toggle="collapse" data-parent="#accordion" href="#pgv-import-wizard">
				<?php 
    echo I18N::translate('PhpGedView to webtrees transfer wizard');
    ?>
			</a>
		</h2>
		</div>
		<div id="pgv-import-wizard" class="panel-collapse collapse">
			<div class="panel-body">
				<p>
Exemplo n.º 4
0
			locale: "' . WT_LOCALE . '",
			icons: {
				time: "fa fa-clock-o",
				date: "fa fa-calendar",
				up: "fa fa-arrow-up",
				down: "fa fa-arrow-down",
				previous: "fa fa-arrow-' . (I18N::direction() === 'rtl' ? 'right' : 'left') . '",
				next: "fa fa-arrow-' . (I18N::direction() === 'rtl' ? 'left' : 'right') . '",
				today: "fa fa-trash-o",
				clear: "fa fa-trash-o"
			}
		});
	');
$url = WT_SCRIPT_NAME . '?from=' . rawurlencode($from) . '&amp;to=' . rawurlencode($to) . '&amp;type=' . rawurlencode($type) . '&amp;oldged=' . rawurlencode($oldged) . '&amp;newged=' . rawurlencode($newged) . '&amp;xref=' . rawurlencode($xref) . '&amp;user='******'&amp;gedc=' . rawurlencode($gedc);
$users_array = array();
foreach (User::all() as $tmp_user) {
    $users_array[$tmp_user->getUserName()] = $tmp_user->getUserName();
}
?>
<ol class="breadcrumb small">
	<li><a href="admin.php"><?php 
echo I18N::translate('Control panel');
?>
</a></li>
	<li><a href="admin_trees_manage.php"><?php 
echo I18N::translate('Manage family trees');
?>
</a></li>
	<li class="active"><?php 
echo $controller->getPageTitle();
?>
Exemplo n.º 5
0
 /**
  * Generate the HTML content of this block.
  *
  * @param int      $block_id
  * @param bool     $template
  * @param string[] $cfg
  *
  * @return string
  */
 public function getBlock($block_id, $template = true, $cfg = array())
 {
     global $ctype, $WT_TREE;
     $block = $this->getBlockSetting($block_id, 'block', '1');
     foreach (array('block') as $name) {
         if (array_key_exists($name, $cfg)) {
             ${$name} = $cfg[$name];
         }
     }
     $messages = Database::prepare("SELECT message_id, sender, subject, body, UNIX_TIMESTAMP(created) AS created FROM `##message` WHERE user_id=? ORDER BY message_id DESC")->execute(array(Auth::id()))->fetchAll();
     $count = count($messages);
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     $title = I18N::plural('%s message', '%s messages', $count, I18N::number($count));
     $users = array_filter(User::all(), function (User $user) {
         return $user->getUserId() !== Auth::id() && $user->getPreference('verified_by_admin') && $user->getPreference('contactmethod') !== 'none';
     });
     $content = '<form id="messageform" name="messageform" method="post" action="module.php?mod=user_messages&mod_action=delete" onsubmit="return confirm(\'' . I18N::translate('Are you sure you want to delete this message?  It cannot be retrieved later.') . '\');">';
     $content .= '<input type="hidden" name="ged" value="' . $ctype . '">';
     $content .= '<input type="hidden" name="ctype" value="' . $WT_TREE->getNameHtml() . '">';
     if ($users) {
         $content .= '<label for="touser">' . I18N::translate('Send a message') . '</label>';
         $content .= '<select id="touser" name="touser">';
         $content .= '<option value="">' . I18N::translate('&lt;select&gt;') . '</option>';
         foreach ($users as $user) {
             $content .= sprintf('<option value="%1$s">%2$s - %1$s</option>', Filter::escapeHtml($user->getUserName()), Filter::escapeHtml($user->getRealName()));
         }
         $content .= '</select>';
         $content .= '<input type="button" value="' . I18N::translate('Send') . '" onclick="return message(document.messageform.touser.options[document.messageform.touser.selectedIndex].value, \'messaging2\', \'\');"><br><br>';
     }
     if ($messages) {
         $content .= '<table class="list_table"><tr>';
         $content .= '<th class="list_label">' . I18N::translate('Delete') . '<br><a href="#" onclick="jQuery(\'#' . $this->getName() . $block_id . ' :checkbox\').prop(\'checked\', true); return false;">' . I18N::translate('All') . '</a></th>';
         $content .= '<th class="list_label">' . I18N::translate('Subject') . '</th>';
         $content .= '<th class="list_label">' . I18N::translate('Date sent') . '</th>';
         $content .= '<th class="list_label">' . I18N::translate('Email address') . '</th>';
         $content .= '</tr>';
         foreach ($messages as $message) {
             $content .= '<tr>';
             $content .= '<td class="list_value_wrap"><input type="checkbox" name="message_id[]" value="' . $message->message_id . '" id="cb_message' . $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">' . Filter::escapeHtml($message->subject) . '</b></a></td>';
             $content .= '<td class="list_value_wrap">' . FunctionsDate::formatTimestamp($message->created + WT_TIMESTAMP_OFFSET) . '</td>';
             $content .= '<td class="list_value_wrap">';
             $user = User::findByIdentifier($message->sender);
             if ($user) {
                 $content .= $user->getRealNameHtml();
                 $content .= '  - <span dir="auto">' . $user->getEmail() . '</span>';
             } else {
                 $content .= '<a href="mailto:' . Filter::escapeHtml($message->sender) . '">' . Filter::escapeHtml($message->sender) . '</a>';
             }
             $content .= '</td>';
             $content .= '</tr>';
             $content .= '<tr><td class="list_value_wrap" colspan="4"><div id="message' . $message->message_id . '" style="display:none;">';
             $content .= '<div dir="auto" style="white-space: pre-wrap;">' . Filter::expandUrls($message->body) . '</div><br>';
             if (strpos($message->subject, I18N::translate('RE: ')) !== 0) {
                 $message->subject = I18N::translate('RE: ') . $message->subject;
             }
             if ($user) {
                 $content .= '<button type="button" onclick="reply(\'' . Filter::escapeJs($message->sender) . '\', \'' . Filter::escapeJs($message->subject) . '\'); return false;">' . I18N::translate('Reply') . '</button> ';
             }
             $content .= '<button type="button" onclick="if (confirm(\'' . I18N::translate('Are you sure you want to delete this message?  It cannot be retrieved later.') . '\')) {jQuery(\'#messageform :checkbox\').prop(\'checked\', false); jQuery(\'#cb_message' . $message->message_id . '\').prop(\'checked\', true); document.messageform.submit();}">' . I18N::translate('Delete') . '</button></div></td></tr>';
         }
         $content .= '</table>';
         $content .= '<p><button type="submit">' . I18N::translate('Delete selected messages') . '</button></p>';
     }
     $content .= '</form>';
     if ($template) {
         if ($block) {
             $class .= ' small_inner_block';
         }
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
Exemplo n.º 6
0
 /**
  * Generate the HTML content of this block.
  *
  * @param int      $block_id
  * @param bool     $template
  * @param string[] $cfg
  *
  * @return string
  */
 public function getBlock($block_id, $template = true, $cfg = array())
 {
     global $ctype, $WT_TREE;
     $sendmail = $this->getBlockSetting($block_id, 'sendmail', '1');
     $days = $this->getBlockSetting($block_id, 'days', '1');
     $block = $this->getBlockSetting($block_id, 'block', '1');
     foreach (array('days', 'sendmail', 'block') as $name) {
         if (array_key_exists($name, $cfg)) {
             ${$name} = $cfg[$name];
         }
     }
     $changes = Database::prepare("SELECT 1" . " FROM `##change`" . " WHERE status='pending'" . " LIMIT 1")->fetchOne();
     if ($changes === '1' && $sendmail === '1') {
         // There are pending changes - tell moderators/managers/administrators about them.
         if (WT_TIMESTAMP - Site::getPreference('LAST_CHANGE_EMAIL') > 60 * 60 * 24 * $days) {
             // Which users have pending changes?
             foreach (User::all() as $user) {
                 if ($user->getPreference('contactmethod') !== 'none') {
                     foreach (Tree::getAll() as $tree) {
                         if ($tree->hasPendingEdit() && Auth::isManager($tree, $user)) {
                             I18N::init($user->getPreference('language'));
                             Mail::systemMessage($tree, $user, I18N::translate('Pending changes'), I18N::translate('There are pending changes for you to moderate.') . Mail::EOL . Mail::EOL . '<a href="' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '">' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '</a>');
                             I18N::init(WT_LOCALE);
                         }
                     }
                 }
             }
             Site::setPreference('LAST_CHANGE_EMAIL', WT_TIMESTAMP);
         }
     }
     if (Auth::isEditor($WT_TREE) && $WT_TREE->hasPendingEdit()) {
         $id = $this->getName() . $block_id;
         $class = $this->getName() . '_block';
         if ($ctype === 'user' || Auth::isManager($WT_TREE)) {
             $title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;ctype=' . $ctype . '"></a>';
         } else {
             $title = '';
         }
         $title .= $this->getTitle();
         $content = '';
         if (Auth::isModerator($WT_TREE)) {
             $content .= "<a href=\"#\" onclick=\"window.open('edit_changes.php','_blank', chan_window_specs); return false;\">" . I18N::translate('There are pending changes for you to moderate.') . "</a><br>";
         }
         if ($sendmail === '1') {
             $content .= I18N::translate('Last email reminder was sent ') . FunctionsDate::formatTimestamp(Site::getPreference('LAST_CHANGE_EMAIL')) . "<br>";
             $content .= I18N::translate('Next email reminder will be sent after ') . FunctionsDate::formatTimestamp(Site::getPreference('LAST_CHANGE_EMAIL') + 60 * 60 * 24 * $days) . "<br><br>";
         }
         $content .= '<ul>';
         $changes = Database::prepare("SELECT xref" . " FROM  `##change`" . " WHERE status='pending'" . " AND   gedcom_id=?" . " GROUP BY xref")->execute(array($WT_TREE->getTreeId()))->fetchAll();
         foreach ($changes as $change) {
             $record = GedcomRecord::getInstance($change->xref, $WT_TREE);
             if ($record->canShow()) {
                 $content .= '<li><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></li>';
             }
         }
         $content .= '</ul>';
         if ($template) {
             if ($block) {
                 $class .= ' small_inner_block';
             }
             return Theme::theme()->formatBlock($id, $title, $class, $content);
         } else {
             return $content;
         }
     }
 }
Exemplo n.º 7
0
 /**
  * {@inheritDoc}
  * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::executeSteps()
  */
 protected function executeSteps()
 {
     $res = false;
     // Get the number of days to take into account, either last 7 days or since last check
     $interval_sincelast = 0;
     if ($this->last_updated) {
         $tmpInt = $this->last_updated->diff(new \DateTime('now'), true);
         $interval_sincelast = ($tmpInt->days * 24 + $tmpInt->h) * 60 + $tmpInt->i;
     }
     $interval = max($this->frequency, $interval_sincelast);
     $nbdays = ceil($interval / (24 * 60));
     // Check for updates
     $latest_version_txt = Functions::fetchLatestVersion();
     if (preg_match('/^[0-9.]+\\|[0-9.]+\\|/', $latest_version_txt)) {
         list($latest_version, , $download_url) = explode('|', $latest_version_txt);
     } else {
         // Cannot determine the latest version
         list($latest_version, , $download_url) = explode('|', '||');
     }
     // Users statistics
     $warnusers = 0;
     $nverusers = 0;
     $applusers = 0;
     foreach (User::all() as $user) {
         if (date("U") - (int) $user->getPreference('reg_timestamp') > 604800 && !$user->getPreference('verified')) {
             $warnusers++;
         }
         if (!$user->getPreference('verified_by_admin') && $user->getPreference('verified')) {
             $nverusers++;
         }
         if (!$user->getPreference('verified')) {
             $applusers++;
         }
     }
     // Tree specifics checks
     $one_tree_done = false;
     foreach (Tree::getAll() as $tree) {
         $isTreeEnabled = $tree->getPreference('MAJ_AT_' . $this->getName() . '_ENABLED');
         if ((is_null($isTreeEnabled) || $isTreeEnabled) && ($webmaster = User::find($tree->getPreference('WEBMASTER_USER_ID')))) {
             I18N::init($webmaster->getPreference('language'));
             $subject = I18N::translate('Health Check Report') . ' - ' . I18N::translate('Tree %s', $tree->getTitle());
             $message = I18N::translate('Health Check Report for the last %d days', $nbdays) . Mail::EOL . Mail::EOL . I18N::translate('Tree %s', $tree->getTitle()) . Mail::EOL . '==========================================' . Mail::EOL . Mail::EOL;
             // News
             $message_version = '';
             if ($latest_version && version_compare(WT_VERSION, $latest_version) < 0) {
                 $message_version = I18N::translate('News') . Mail::EOL . '-------------' . Mail::EOL . I18N::translate('A new version of *webtrees* is available: %s. Upgrade as soon as possible.', $latest_version) . Mail::EOL . I18N::translate('Download it here: %s.', $download_url) . Mail::EOL . Mail::EOL;
             }
             $message .= $message_version;
             // Statistics users
             $message_users = I18N::translate('Users') . Mail::EOL . '-------------' . Mail::EOL . WT_BASE_URL . 'admin_users.php' . Mail::EOL . I18N::translate('Total number of users') . "\t\t" . User::count() . Mail::EOL . I18N::translate('Not verified by the user') . "\t\t" . $applusers . Mail::EOL . I18N::translate('Not approved by an administrator') . "\t" . $nverusers . Mail::EOL . Mail::EOL;
             $message .= $message_users;
             // Statistics tree:
             $stats = new Stats($tree);
             $sql = 'SELECT ged_type AS type, COUNT(change_id) AS chgcount FROM wt_change' . ' JOIN (' . ' SELECT "indi" AS ged_type, i_id AS ged_id, i_file AS ged_file FROM wt_individuals' . ' UNION SELECT "fam" AS ged_type, f_id AS ged_id, f_file AS ged_file FROM wt_families' . ' UNION SELECT "sour" AS ged_type, s_id AS ged_id, s_file AS ged_file FROM wt_sources' . ' UNION SELECT "media" AS ged_type, m_id AS ged_id, m_file AS ged_file FROM wt_media' . ' UNION SELECT LOWER(o_type) AS ged_type, o_id AS ged_id, o_file AS ged_file FROM wt_other' . ') AS gedrecords ON (xref = ged_id AND gedcom_id = ged_file)' . ' WHERE change_time >= DATE_ADD( NOW(), INTERVAL - :nb_days DAY)' . ' AND status = :status AND gedcom_id = :gedcom_id' . ' GROUP BY ged_type';
             $changes = Database::prepare($sql)->execute(array('status' => 'accepted', 'gedcom_id' => $tree->getTreeId(), 'nb_days' => $nbdays))->fetchAssoc();
             $message_gedcom = I18N::translate('Tree statistics') . Mail::EOL . '-------------' . Mail::EOL . sprintf('%-25s', I18N::translate('Records')) . "\t" . sprintf('%15s', I18N::translate('Count')) . "\t" . sprintf('%15s', I18N::translate('Changes')) . Mail::EOL . sprintf('%-25s', I18N::translate('Individuals')) . "\t" . sprintf('%15s', $stats->totalIndividuals()) . "\t" . sprintf('%15s', isset($changes['indi']) ? $changes['indi'] : 0) . Mail::EOL . sprintf('%-25s', I18N::translate('Families')) . "\t" . sprintf('%15s', $stats->totalFamilies()) . "\t" . sprintf('%15s', isset($changes['fam']) ? $changes['fam'] : 0) . Mail::EOL . sprintf('%-25s', I18N::translate('Sources')) . "\t" . sprintf('%15s', $stats->totalSources()) . "\t" . sprintf('%15s', isset($changes['sour']) ? $changes['sour'] : 0) . Mail::EOL . sprintf('%-25s', I18N::translate('Repositories')) . "\t" . sprintf('%15s', $stats->totalRepositories()) . "\t" . sprintf('%15s', isset($changes['repo']) ? $changes['repo'] : 0) . Mail::EOL . sprintf('%-25s', I18N::translate('Media objects')) . "\t" . sprintf('%15s', $stats->totalMedia()) . "\t" . sprintf('%15s', isset($changes['media']) ? $changes['media'] : 0) . Mail::EOL . sprintf('%-25s', I18N::translate('Notes')) . "\t" . sprintf('%15s', $stats->totalNotes()) . "\t" . sprintf('%15s', isset($changes['note']) ? $changes['note'] : 0) . Mail::EOL . Mail::EOL;
             $message .= $message_gedcom;
             //Errors
             $sql = 'SELECT SQL_CACHE log_message, gedcom_id, COUNT(log_id) as nblogs, MAX(log_time) as lastoccurred' . ' FROM `##log`' . ' WHERE log_type = :log_type AND (gedcom_id = :gedcom_id OR ISNULL(gedcom_id))' . ' AND log_time >= DATE_ADD( NOW(), INTERVAL - :nb_days DAY)' . ' GROUP BY log_message, gedcom_id' . ' ORDER BY lastoccurred DESC';
             $errors = Database::prepare($sql)->execute(array('log_type' => Log::TYPE_ERROR, 'gedcom_id' => $tree->getTreeId(), 'nb_days' => $nbdays))->fetchAll();
             $nb_errors = 0;
             $tmp_message = '';
             $nb_char_count_title = strlen(I18N::translate('Count'));
             $nb_char_type = max(strlen(I18N::translate('Type')), strlen(I18N::translate('Site')), strlen(I18N::translate('Tree')));
             foreach ($errors as $error) {
                 $tmp_message .= sprintf('%' . $nb_char_count_title . 'd', $error->nblogs) . "\t";
                 $tmp_message .= sprintf('%' . $nb_char_type . 's', is_null($error->gedcom_id) ? I18N::translate('Site') : I18N::translate('Tree'));
                 $tmp_message .= "\t" . sprintf('%20s', $error->lastoccurred) . "\t";
                 $tmp_message .= str_replace("\n", "\n\t\t\t\t\t\t", $error->log_message) . Mail::EOL;
                 $nb_errors += $error->nblogs;
             }
             if ($nb_errors > 0) {
                 $message .= I18N::translate('Errors [%d]', $nb_errors) . Mail::EOL . '-------------' . Mail::EOL . WT_BASE_URL . 'admin_site_logs.php' . Mail::EOL . I18N::translate('Count') . "\t" . sprintf('%-' . $nb_char_type . 's', I18N::translate('Type')) . "\t" . sprintf('%-20s', I18N::translate('Last occurrence')) . "\t" . I18N::translate('Error') . Mail::EOL . str_repeat('-', $nb_char_count_title) . "\t" . str_repeat('-', $nb_char_type) . "\t" . str_repeat('-', 20) . "\t" . str_repeat('-', strlen(I18N::translate('Error'))) . Mail::EOL . $tmp_message . Mail::EOL;
             } else {
                 $message .= I18N::translate('No errors', $nb_errors) . Mail::EOL . Mail::EOL;
             }
             $tmpres = true;
             if ($webmaster->getPreference('contactmethod') !== 'messaging' && $webmaster->getPreference('contactmethod') !== 'none') {
                 $tmpres = Mail::systemMessage($tree, $webmaster, $subject, $message);
             }
             $res = $tmpres && (!$one_tree_done || $one_tree_done && $res);
             $one_tree_done = true;
         }
     }
     return $res;
 }
Exemplo n.º 8
0
 */
namespace Fisharebest\Webtrees;

use Fisharebest\Webtrees\Controller\PageController;
use PDO;
use PDOException;
/**
 * Defined in session.php
 *
 * @global Tree $WT_TREE
 */
global $WT_TREE;
define('WT_SCRIPT_NAME', 'admin_pgv_to_wt.php');
require './includes/session.php';
// We can only import into an empty system, so deny access if we have already created a gedcom or added users.
if ($WT_TREE || count(User::all()) > 1) {
    header('Location: ' . WT_BASE_URL);
    return;
}
$controller = new PageController();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(I18N::translate('PhpGedView to webtrees transfer wizard'));
$error = false;
$PGV_PATH = Filter::post('PGV_PATH');
// We read these variables from PhpGedView's config.php, and set them here in case any are missing.
$INDEX_DIRECTORY = '';
$DBHOST = '';
$DBNAME = '';
$TBLPREFIX = '';
$PGV_SCHEMA_VERSION = '';
$USE_REGISTRATION_MODULE = '';
$ALLOW_USER_THEMES = '';
Exemplo n.º 9
0
 /**
  * Print an edit control for a username.
  *
  * @param string $name
  * @param string $selected
  * @param string $extra
  *
  * @return string
  */
 public static function editFieldUsername($name, $selected = '', $extra = '')
 {
     $users = array();
     foreach (User::all() as $user) {
         $users[$user->getUserName()] = $user->getRealName() . ' - ' . $user->getUserName();
     }
     // The currently selected user may not exist
     if ($selected && !array_key_exists($selected, $users)) {
         $users[$selected] = $selected;
     }
     return self::selectEditControl($name, $users, '-', $selected, $extra);
 }