Ejemplo n.º 1
0
             $datum[4] = '<a href="#" onclick="return message(\'' . Filter::escapeHtml($datum[2]) . '\', \'\', \'\');">' . Filter::escapeHtml($datum[4]) . '</i></a>';
         }
         // $datum[2] is the username
         $datum[2] = '<span dir="auto">' . Filter::escapeHtml($datum[2]) . '</span>';
         // $datum[5] is the langauge
         if (array_key_exists($datum[5], $installed_languages)) {
             $datum[5] = $installed_languages[$datum[5]];
         }
         // $datum[6] is the sortable registration timestamp
         $datum[7] = $datum[7] ? FunctionsDate::formatTimestamp($datum[7]) : '';
         if (date("U") - $datum[6] > 604800 && !$datum[10]) {
             $datum[7] = '<span class="red">' . $datum[7] . '</span>';
         }
         // $datum[8] is the sortable last-login timestamp
         if ($datum[8]) {
             $datum[9] = FunctionsDate::formatTimestamp($datum[8]) . '<br>' . I18N::timeAgo(WT_TIMESTAMP - $datum[8]);
         } else {
             $datum[9] = I18N::translate('Never');
         }
         $datum[10] = $datum[10] ? I18N::translate('yes') : I18N::translate('no');
         $datum[11] = $datum[11] ? I18N::translate('yes') : I18N::translate('no');
     }
     // Total filtered/unfiltered rows
     $recordsFiltered = (int) Database::prepare("SELECT FOUND_ROWS()")->fetchOne();
     $recordsTotal = User::count();
     header('Content-type: application/json');
     // See http://www.datatables.net/usage/server-side
     echo json_encode(array('draw' => Filter::getInteger('draw'), 'recordsTotal' => $recordsTotal, 'recordsFiltered' => $recordsFiltered, 'data' => $data));
     return;
 case 'edit':
     $user_id = Filter::getInteger('user_id');
Ejemplo n.º 2
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;
     switch (Filter::get('action')) {
         case 'deletenews':
             $news_id = Filter::getInteger('news_id');
             if ($news_id) {
                 Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id));
             }
             break;
     }
     $articles = Database::prepare("SELECT SQL_CACHE news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) + :offset AS updated, subject, body FROM `##news` WHERE user_id = :user_id ORDER BY updated DESC")->execute(array('offset' => WT_TIMESTAMP_OFFSET, 'user_id' => Auth::id()))->fetchAll();
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     $title = $this->getTitle();
     $content = '';
     if (empty($articles)) {
         $content .= '<p>' . I18N::translate('You have not created any journal items.') . '</p>';
     }
     foreach ($articles as $article) {
         $content .= '<div class="journal_box">';
         $content .= '<div class="news_title">' . Filter::escapeHtml($article->subject) . '</div>';
         $content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($article->updated) . '</div>';
         if ($article->body == strip_tags($article->body)) {
             $article->body = nl2br($article->body, false);
         }
         $content .= $article->body;
         $content .= '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $article->news_id . ', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Edit') . '</a>';
         $content .= ' | ';
         $content .= '<a href="index.php?action=deletenews&amp;news_id=' . $article->news_id . '&amp;ctype=' . $ctype . '&amp;ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($article->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>';
         $content .= '</div><br>';
     }
     $content .= '<p><a href="#" onclick="window.open(\'editnews.php?user_id=' . Auth::id() . '\', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Add a journal entry') . '</a></p>';
     if ($template) {
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
Ejemplo n.º 3
0
 /**
  * Get the last-change timestamp for this record, either as a formatted string
  * (for display) or as a unix timestamp (for sorting)
  *
  * @param bool $sorting
  *
  * @return string
  */
 public function lastChangeTimestamp($sorting = false)
 {
     $chan = $this->getFirstFact('CHAN');
     if ($chan) {
         // The record does have a CHAN event
         $d = $chan->getDate()->minimumDate();
         if (preg_match('/\\n3 TIME (\\d\\d):(\\d\\d):(\\d\\d)/', $chan->getGedcom(), $match)) {
             $t = mktime((int) $match[1], (int) $match[2], (int) $match[3], (int) $d->format('%n'), (int) $d->format('%j'), (int) $d->format('%Y'));
         } elseif (preg_match('/\\n3 TIME (\\d\\d):(\\d\\d)/', $chan->getGedcom(), $match)) {
             $t = mktime((int) $match[1], (int) $match[2], 0, (int) $d->format('%n'), (int) $d->format('%j'), (int) $d->format('%Y'));
         } else {
             $t = mktime(0, 0, 0, (int) $d->format('%n'), (int) $d->format('%j'), (int) $d->format('%Y'));
         }
         if ($sorting) {
             return $t;
         } else {
             return strip_tags(FunctionsDate::formatTimestamp($t));
         }
     } else {
         // The record does not have a CHAN event
         if ($sorting) {
             return '0';
         } else {
             return '&nbsp;';
         }
     }
 }
Ejemplo n.º 4
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;
     }
 }
Ejemplo 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;
     $title = $this->getBlockSetting($block_id, 'title');
     $html = $this->getBlockSetting($block_id, 'html');
     $gedcom = $this->getBlockSetting($block_id, 'gedcom');
     $show_timestamp = $this->getBlockSetting($block_id, 'show_timestamp', '0');
     $languages = $this->getBlockSetting($block_id, 'languages');
     // Only show this block for certain languages
     if ($languages && !in_array(WT_LOCALE, explode(',', $languages))) {
         return '';
     }
     /*
      * Select GEDCOM
      */
     switch ($gedcom) {
         case '__current__':
             $stats = new Stats($WT_TREE);
             break;
         case '__default__':
             $tree = Tree::findByName(Site::getPreference('DEFAULT_GEDCOM'));
             if ($tree) {
                 $stats = new Stats($tree);
             } else {
                 $stats = new Stats($WT_TREE);
             }
             break;
         default:
             $tree = Tree::findByName($gedcom);
             if ($tree) {
                 $stats = new Stats($tree);
             } else {
                 $stats = new Stats($WT_TREE);
             }
             break;
     }
     /*
      * Retrieve text, process embedded variables
      */
     if (strpos($title, '#') !== false || strpos($html, '#') !== false) {
         $title = $stats->embedTags($title);
         $html = $stats->embedTags($html);
     }
     /*
      * Start Of Output
      */
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
         $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>' . $title;
     }
     $content = $html;
     if ($show_timestamp) {
         $content .= '<br>' . FunctionsDate::formatTimestamp($this->getBlockSetting($block_id, 'timestamp', WT_TIMESTAMP) + WT_TIMESTAMP_OFFSET);
     }
     if ($template) {
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
Ejemplo 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;
         }
     }
 }
Ejemplo n.º 7
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;
     switch (Filter::get('action')) {
         case 'deletenews':
             $news_id = Filter::get('news_id');
             if ($news_id) {
                 Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id));
             }
             break;
     }
     if (isset($_REQUEST['gedcom_news_archive'])) {
         $limit = 'nolimit';
         $flag = '0';
     } else {
         $flag = $this->getBlockSetting($block_id, 'flag', 0);
         if ($flag === '0') {
             $limit = 'nolimit';
         } else {
             $limit = $this->getBlockSetting($block_id, 'limit', 'nolimit');
         }
     }
     foreach (array('limit', 'flag') as $name) {
         if (array_key_exists($name, $cfg)) {
             ${$name} = $cfg[$name];
         }
     }
     $usernews = Database::prepare("SELECT SQL_CACHE news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS updated, subject, body FROM `##news` WHERE gedcom_id=? ORDER BY updated DESC")->execute(array($WT_TREE->getTreeId()))->fetchAll();
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
         $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 (count($usernews) == 0) {
         $content .= I18N::translate('No news articles have been submitted.') . '<br>';
     }
     $c = 0;
     foreach ($usernews as $news) {
         if ($limit == 'count') {
             if ($c >= $flag) {
                 break;
             }
             $c++;
         }
         if ($limit == 'date') {
             if ((int) ((WT_TIMESTAMP - $news->updated) / 86400) > $flag) {
                 break;
             }
         }
         $content .= '<div class="news_box" id="article' . $news->news_id . '">';
         $content .= '<div class="news_title">' . Filter::escapeHtml($news->subject) . '</div>';
         $content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($news->updated) . '</div>';
         if ($news->body == strip_tags($news->body)) {
             $news->body = nl2br($news->body, false);
         }
         $content .= $news->body;
         // Print Admin options for this News item
         if (Auth::isManager($WT_TREE)) {
             $content .= '<hr>' . '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $news->news_id . ', \'_blank\', news_window_specs); return false;">' . I18N::translate('Edit') . '</a> | ' . '<a href="index.php?action=deletenews&amp;news_id=' . $news->news_id . '&amp;ctype=' . $ctype . '&amp;ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($news->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>';
         }
         $content .= '</div>';
     }
     $printedAddLink = false;
     if (Auth::isManager($WT_TREE)) {
         $content .= "<a href=\"#\" onclick=\"window.open('editnews.php?gedcom_id=" . $WT_TREE->getTreeId() . "', '_blank', news_window_specs); return false;\">" . I18N::translate('Add a news article') . "</a>";
         $printedAddLink = true;
     }
     if ($limit == 'date' || $limit == 'count') {
         if ($printedAddLink) {
             $content .= '&nbsp;&nbsp;|&nbsp;&nbsp;';
         }
         $content .= '<a href="index.php?gedcom_news_archive=yes&amp;ctype=' . $ctype . '&amp;ged=' . $WT_TREE->getNameHtml() . '">' . I18N::translate('View archive') . "</a>";
         $content .= FunctionsPrint::helpLink('gedcom_news_archive') . '<br>';
     }
     if ($template) {
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
Ejemplo n.º 8
0
use PclZip;
define('WT_SCRIPT_NAME', 'admin_site_upgrade.php');
require './includes/session.php';
// Check for updates
$latest_version_txt = Functions::fetchLatestVersion();
if (preg_match('/^[0-9.]+\\|[0-9.]+\\|/', $latest_version_txt)) {
    list($latest_version, $earliest_version, $download_url) = explode('|', $latest_version_txt);
} else {
    // Cannot determine the latest version
    list($latest_version, $earliest_version, $download_url) = explode('|', '||');
}
$latest_version_html = '<span dir="ltr">' . $latest_version . '</span>';
$download_url_html = '<b dir="auto"><a href="' . Filter::escapeHtml($download_url) . '">' . Filter::escapeHtml($download_url) . '</a></b>';
// Show a friendly message while the site is being upgraded
$lock_file = __DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'offline.txt';
$lock_file_text = I18N::translate('This website is being upgraded. Try again in a few minutes.') . PHP_EOL . FunctionsDate::formatTimestamp(WT_TIMESTAMP) . I18N::translate('UTC');
// Success/failure indicators
$icon_success = '<i class="icon-yes"></i>';
$icon_failure = '<i class="icon-failure"></i>';
// Need confirmation for various actions
$continue = Filter::post('continue', '1') && Filter::checkCsrf();
$modules_action = Filter::post('modules', 'ignore|disable');
$themes_action = Filter::post('themes', 'ignore|disable');
$controller = new PageController();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(I18N::translate('Upgrade wizard'))->pageHeader();
echo '<h1>', $controller->getPageTitle(), '</h1>';
if ($latest_version == '') {
    echo '<p>', I18N::translate('No upgrade information is available.'), '</p>';
    return;
}
if (version_compare(WT_VERSION, $latest_version) >= 0) {
Ejemplo n.º 9
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;
     switch (Filter::get('action')) {
         case 'deletenews':
             $news_id = Filter::get('news_id');
             if ($news_id) {
                 Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id));
             }
             break;
     }
     $more_news = Filter::getInteger('more_news');
     $limit = 5 * (1 + $more_news);
     $articles = Database::prepare("SELECT SQL_CACHE news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) + :offset AS updated, subject, body FROM `##news` WHERE gedcom_id = :tree_id ORDER BY updated DESC LIMIT :limit")->execute(array('offset' => WT_TIMESTAMP_OFFSET, 'tree_id' => $WT_TREE->getTreeId(), 'limit' => $limit))->fetchAll();
     $count = Database::prepare("SELECT SQL_CACHE COUNT(*) FROM `##news` WHERE gedcom_id = :tree_id")->execute(array('tree_id' => $WT_TREE->getTreeId()))->fetchOne();
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     $title = $this->getTitle();
     $content = '';
     if (empty($articles)) {
         $content .= I18N::translate('No news articles have been submitted.');
     }
     foreach ($articles as $article) {
         $content .= '<div class="news_box">';
         $content .= '<div class="news_title">' . Filter::escapeHtml($article->subject) . '</div>';
         $content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($article->updated) . '</div>';
         if ($article->body == strip_tags($article->body)) {
             $article->body = nl2br($article->body, false);
         }
         $content .= $article->body;
         if (Auth::isManager($WT_TREE)) {
             $content .= '<hr>';
             $content .= '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $article->news_id . ', \'_blank\', news_window_specs); return false;">' . I18N::translate('Edit') . '</a>';
             $content .= ' | ';
             $content .= '<a href="index.php?action=deletenews&amp;news_id=' . $article->news_id . '&amp;ctype=' . $ctype . '&amp;ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($article->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>';
         }
         $content .= '</div>';
     }
     if (Auth::isManager($WT_TREE)) {
         $content .= '<a href="#" onclick="window.open(\'editnews.php?gedcom_id=' . $WT_TREE->getTreeId() . '\', \'_blank\', news_window_specs); return false;">' . I18N::translate('Add a news article') . '</a>';
     }
     if ($count > $limit) {
         if (Auth::isManager($WT_TREE)) {
             $content .= ' | ';
         }
         $content .= '<a href="#" onclick="jQuery(\'#' . $id . '\').load(\'index.php?ctype=gedcom&amp;ged=' . $WT_TREE->getNameUrl() . '&amp;block_id=' . $block_id . '&amp;action=ajax&amp;more_news=' . ($more_news + 1) . '\'); return false;">' . I18N::translate('More news articles') . "</a>";
     }
     if ($template) {
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
Ejemplo n.º 10
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;
     switch (Filter::get('action')) {
         case 'deletenews':
             $news_id = Filter::getInteger('news_id');
             if ($news_id) {
                 Database::prepare("DELETE FROM `##news` WHERE news_id = ?")->execute(array($news_id));
             }
             break;
     }
     $block = $this->getBlockSetting($block_id, 'block', '1');
     foreach (array('block') as $name) {
         if (array_key_exists($name, $cfg)) {
             ${$name} = $cfg[$name];
         }
     }
     $usernews = Database::prepare("SELECT SQL_CACHE news_id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS updated, subject, body FROM `##news` WHERE user_id = ? ORDER BY updated DESC")->execute(array(Auth::id()))->fetchAll();
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     $title = '';
     $title .= $this->getTitle();
     $content = '';
     if (!$usernews) {
         $content .= I18N::translate('You have not created any journal items.');
     }
     foreach ($usernews as $news) {
         $content .= '<div class="journal_box">';
         $content .= '<div class="news_title">' . $news->subject . '</div>';
         $content .= '<div class="news_date">' . FunctionsDate::formatTimestamp($news->updated) . '</div>';
         if ($news->body == strip_tags($news->body)) {
             // No HTML?
             $news->body = nl2br($news->body, false);
         }
         $content .= $news->body . '<br><br>';
         $content .= '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $news->news_id . ', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Edit') . '</a> | ';
         $content .= '<a href="index.php?action=deletenews&amp;news_id=' . $news->news_id . '&amp;ctype=' . $ctype . '&amp;ged=' . $WT_TREE->getNameHtml() . '" onclick="return confirm(\'' . I18N::translate('Are you sure you want to delete “%s”?', Filter::escapeHtml($news->subject)) . "');\">" . I18N::translate('Delete') . '</a><br>';
         $content .= "</div><br>";
     }
     $content .= '<br><a href="#" onclick="window.open(\'editnews.php?user_id=' . Auth::id() . '\', \'_blank\', indx_window_specs); return false;">' . I18N::translate('Add a new journal entry') . '</a>';
     if ($template) {
         if ($block) {
             $class .= ' small_inner_block';
         }
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
Ejemplo n.º 11
0
     $output .= '<td class="list_value"><a href="edit_changes.php?action=accept&amp;change_id=' . $change->change_id . '">' . I18N::translate('Accept') . '</a></td>';
     $output .= '<td class="list_value">';
     foreach ($record->getFacts() as $fact) {
         if ($fact->getTag() != 'CHAN') {
             if ($fact->isPendingAddition()) {
                 $output .= '<div class="new" title="' . strip_tags($fact->summary()) . '">' . $fact->getLabel() . '</div>';
             } elseif ($fact->isPendingDeletion()) {
                 $output .= '<div class="old" title="' . strip_tags($fact->summary()) . '">' . $fact->getLabel() . '</div>';
             }
         }
     }
     echo '</td>';
     $output .= '<td class="list_value"><a href="#" onclick="return reply(\'' . $change->user_name . '\', \'' . I18N::translate('Moderate pending changes') . '\')" title="' . I18N::translate('Send a message') . '">';
     $output .= Filter::escapeHtml($change->real_name);
     $output .= ' - ' . Filter::escapeHtml($change->user_name) . '</a></td>';
     $output .= '<td class="list_value">' . FunctionsDate::formatTimestamp($change->change_timestamp) . '</td>';
     $output .= '<td class="list_value">' . $change->gedcom_name . '</td>';
     $output .= '<td class="list_value"><a href="edit_changes.php?action=undo&amp;change_id=' . $change->change_id . '">' . I18N::translate('Reject') . '</a></td>';
     $output .= '</tr>';
 }
 $output .= '</table></td></tr></td></tr></table>';
 //-- Now for the global Action bar:
 $output2 = '<br><table class="list_table">';
 // Row 1 column 1: title "Accept all"
 $output2 .= '<tr><td class="list_label">' . I18N::translate('Accept all changes') . '</td>';
 // Row 1 column 2: title "Undo all"
 $output2 .= '<td class="list_label">' . I18N::translate('Reject all changes') . '</td></tr>';
 // Row 2 column 1: action "Accept all"
 $output2 .= '<tr><td class="list_value">';
 $count = 0;
 foreach ($changed_gedcoms as $gedcom_name) {