/** * Manage updates sent from the AdminConfig@index form. */ protected function update() { if (Auth::isAdmin()) { $this->module->setSetting('MAJ_SHOW_CERT', Filter::post('MAJ_SHOW_CERT')); $this->module->setSetting('MAJ_SHOW_NO_WATERMARK', Filter::post('MAJ_SHOW_NO_WATERMARK')); if ($MAJ_WM_DEFAULT = Filter::post('MAJ_WM_DEFAULT')) { $this->module->setSetting('MAJ_WM_DEFAULT', $MAJ_WM_DEFAULT); } if ($MAJ_WM_FONT_MAXSIZE = Filter::postInteger('MAJ_WM_FONT_MAXSIZE')) { $this->module->setSetting('MAJ_WM_FONT_MAXSIZE', $MAJ_WM_FONT_MAXSIZE); } // Only accept valid color for MAJ_WM_FONT_COLOR $MAJ_WM_FONT_COLOR = Filter::post('MAJ_WM_FONT_COLOR', '#([a-fA-F0-9]{3}){1,2}'); if ($MAJ_WM_FONT_COLOR) { $this->module->setSetting('MAJ_WM_FONT_COLOR', $MAJ_WM_FONT_COLOR); } // Only accept valid folders for MAJ_CERT_ROOTDIR $MAJ_CERT_ROOTDIR = preg_replace('/[\\/\\\\]+/', '/', Filter::post('MAJ_CERT_ROOTDIR') . '/'); if (substr($MAJ_CERT_ROOTDIR, 0, 1) === '/') { $MAJ_CERT_ROOTDIR = substr($MAJ_CERT_ROOTDIR, 1); } if ($MAJ_CERT_ROOTDIR) { if (is_dir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) { $this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR); } elseif (File::mkdir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) { $this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR); FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'info'); } else { FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'danger'); } } FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success'); return; } }
/** * Manage updates sent from the AdminConfig@index form. */ protected function update() { global $WT_TREE; if (Auth::isAdmin()) { $this->module->setSetting('MAJ_TITLE_PREFIX', Filter::post('MAJ_TITLE_PREFIX')); $this->module->setSetting('MAJ_ADD_HTML_HEADER', Filter::postInteger('MAJ_ADD_HTML_HEADER', 0, 1)); $this->module->setSetting('MAJ_SHOW_HTML_HEADER', Filter::postInteger('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE)); $this->module->setSetting('MAJ_HTML_HEADER', Filter::post('MAJ_HTML_HEADER')); $this->module->setSetting('MAJ_ADD_HTML_FOOTER', Filter::postInteger('MAJ_ADD_HTML_FOOTER', 0, 1)); $this->module->setSetting('MAJ_SHOW_HTML_FOOTER', Filter::postInteger('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE)); $this->module->setSetting('MAJ_HTML_FOOTER', Filter::post('MAJ_HTML_FOOTER')); $this->module->setSetting('MAJ_DISPLAY_CNIL', Filter::postInteger('MAJ_DISPLAY_CNIL', 0, 1)); $this->module->setSetting('MAJ_CNIL_REFERENCE', Filter::post('MAJ_CNIL_REFERENCE')); FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success'); return; } }
/** * Manage updates sent from the AdminConfig@index form. */ protected function update() { if (Auth::isAdmin()) { $ihooks = HookProvider::getInstance()->getInstalledHooks(); $module_names = Database::prepare("SELECT module_name FROM `##module` WHERE status='disabled'")->fetchOneColumn(); if ($ihooks !== null) { foreach ($ihooks as $ihook => $params) { if (Filter::post('hook-' . $params['id']) === 'yes') { $array_hook = explode('#', $ihook); //Update status $new_status = Filter::postBool('status-' . $params['id']); if (in_array($array_hook[0], $module_names)) { $new_status = false; } $previous_status = $params['status']; if ($new_status !== null) { $new_status = $new_status ? 'enabled' : 'disabled'; if ($new_status != $previous_status) { $chook = new Hook($array_hook[1], $array_hook[2]); switch ($new_status) { case 'enabled': $chook->enable($array_hook[0]); break; case 'disabled': $chook->disable($array_hook[0]); break; default: break; } } } //Update priority $new_priority = Filter::postInteger("moduleorder-{$params['id']}"); $previous_priority = $params['priority']; if ($new_priority !== null) { if ($new_priority != $previous_priority) { $chook = new Hook($array_hook[1], $array_hook[2]); $chook->setPriority($array_hook[0], $new_priority); } } } } } } }
/** * Saves Sosa's user preferences (root individual for the user). * * @param BaseController $controller * @return bool True is saving successfull */ protected function update(BaseController $controller) { global $WT_TREE; if ($this->canUpdate() && Filter::checkCsrf()) { $indi = Individual::getInstance(Filter::post('rootid'), $WT_TREE); $user = User::find(Filter::postInteger('userid', -1)); if ($user && $indi) { $WT_TREE->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $indi->getXref()); $controller->addInlineJavascript(' $( document ).ready(function() { majComputeSosa(' . $user->getUserId() . '); });'); FlashMessages::addMessage(I18N::translate('The preferences have been updated.')); return true; } } FlashMessages::addMessage(I18N::translate('An error occurred while saving data...'), 'danger'); return false; }
/** * Show and process a form to edit a story. */ private function edit() { global $WT_TREE; if (Auth::isEditor($WT_TREE)) { if (Filter::postBool('save') && Filter::checkCsrf()) { $block_id = Filter::postInteger('block_id'); if ($block_id) { Database::prepare("UPDATE `##block` SET gedcom_id=?, xref=? WHERE block_id=?")->execute(array(Filter::postInteger('gedcom_id'), Filter::post('xref', WT_REGEX_XREF), $block_id)); } else { Database::prepare("INSERT INTO `##block` (gedcom_id, xref, module_name, block_order) VALUES (?, ?, ?, ?)")->execute(array(Filter::postInteger('gedcom_id'), Filter::post('xref', WT_REGEX_XREF), $this->getName(), 0)); $block_id = Database::getInstance()->lastInsertId(); } $this->setBlockSetting($block_id, 'title', Filter::post('title')); $this->setBlockSetting($block_id, 'story_body', Filter::post('story_body')); $languages = Filter::postArray('lang'); $this->setBlockSetting($block_id, 'languages', implode(',', $languages)); $this->config(); } else { $block_id = Filter::getInteger('block_id'); $controller = new PageController(); if ($block_id) { $controller->setPageTitle(I18N::translate('Edit story')); $title = $this->getBlockSetting($block_id, 'title'); $story_body = $this->getBlockSetting($block_id, 'story_body'); $xref = Database::prepare("SELECT xref FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne(); } else { $controller->setPageTitle(I18N::translate('Add a story')); $title = ''; $story_body = ''; $xref = Filter::get('xref', WT_REGEX_XREF); } $controller->pageHeader()->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL)->addInlineJavascript('autocomplete();'); if (Module::getModuleByName('ckeditor')) { CkeditorModule::enableEditor($controller); } $individual = Individual::getInstance($xref, $WT_TREE); ?> <ol class="breadcrumb small"> <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?> </a></li> <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?> </a></li> <li><a href="module.php?mod=<?php echo $this->getName(); ?> &mod_action=admin_config"><?php echo $this->getTitle(); ?> </a></li> <li class="active"><?php echo $controller->getPageTitle(); ?> </li> </ol> <h1><?php echo $controller->getPageTitle(); ?> </h1> <form class="form-horizontal" method="post" action="module.php?mod=<?php echo $this->getName(); ?> &mod_action=admin_edit"> <?php echo Filter::getCsrf(); ?> <input type="hidden" name="save" value="1"> <input type="hidden" name="block_id" value="<?php echo $block_id; ?> "> <input type="hidden" name="gedcom_id" value="<?php echo $WT_TREE->getTreeId(); ?> "> <div class="form-group"> <label for="title" class="col-sm-3 control-label"> <?php echo I18N::translate('Story title'); ?> </label> <div class="col-sm-9"> <input type="text" class="form-control" name="title" id="title" value="<?php echo Filter::escapeHtml($title); ?> "> </div> </div> <div class="form-group"> <label for="story_body" class="col-sm-3 control-label"> <?php echo I18N::translate('Story'); ?> </label> <div class="col-sm-9"> <textarea name="story_body" id="story_body" class="html-edit form-control" rows="10"><?php echo Filter::escapeHtml($story_body); ?> </textarea> </div> </div> <div class="form-group"> <label for="xref" class="col-sm-3 control-label"> <?php echo I18N::translate('Individual'); ?> </label> <div class="col-sm-9"> <input data-autocomplete-type="INDI" type="text" name="xref" id="xref" size="4" value="<?php echo $xref; ?> "> <?php echo FunctionsPrint::printFindIndividualLink('xref'); ?> <?php if ($individual) { ?> <?php echo $individual->formatList('span'); ?> <?php } ?> </div> </div> <div class="form-group"> <label for="xref" class="col-sm-3 control-label"> <?php echo I18N::translate('Show this block for which languages?'); ?> </label> <div class="col-sm-9"> <?php echo FunctionsEdit::editLanguageCheckboxes('lang', explode(',', $this->getBlockSetting($block_id, 'languages'))); ?> </div> </div> <div class="form-group"> <div class="col-sm-offset-3 col-sm-9"> <button type="submit" class="btn btn-primary"> <i class="fa fa-check"></i> <?php echo I18N::translate('save'); ?> </button> </div> </div> </form> <?php } } else { header('Location: ' . WT_BASE_URL); } }
/** * {@inheritDoc} * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\ConfigurableTaskInterface::saveConfig() */ public function saveConfig() { try { foreach (Tree::getAll() as $tree) { if (Auth::isManager($tree)) { $tree_enabled = Filter::postInteger('HEALTHCHECK_ENABLED_' . $tree->getTreeId(), 0, 1); $tree->setPreference('MAJ_AT_' . $this->getName() . '_ENABLED', $tree_enabled); } } return true; } catch (\Exception $ex) { Log::addErrorLog(sprintf('Error while updating the Admin Task "%s". Exception: %s', $this->getName(), $ex->getMessage())); return false; } }
/** * Task@save */ public function save() { $tmp_contrl = new PageController(); $tmp_contrl->restrictAccess(Auth::isAdmin() && Filter::checkCsrf()); $task_name = Filter::post('task'); $frequency = Filter::postInteger('frequency'); $is_limited = Filter::postInteger('is_limited', 0, 1); $nb_occur = Filter::postInteger('nb_occur'); $task = $this->provider->getTask($task_name, false); $success = false; if ($task) { $task->setFrequency($frequency); if ($is_limited == 1) { $task->setRemainingOccurrences($nb_occur); } else { $task->setRemainingOccurrences(0); } $res = $task->save(); if ($res) { if ($task instanceof MyArtJaub\Webtrees\Module\AdminTasks\Model\ConfigurableTaskInterface) { $res = $task->saveConfig(); if (!$res) { FlashMessages::addMessage(I18N::translate('An error occured while updating the specific settings of administrative task “%s”', $task->getTitle()), 'danger'); Log::addConfigurationLog('Module ' . $this->module->getName() . ' : AdminTask “' . $task->getName() . '” specific settings could not be updated. See error log.'); } } if ($res) { FlashMessages::addMessage(I18N::translate('The administrative task “%s” has been successfully updated', $task->getTitle()), 'success'); Log::addConfigurationLog('Module ' . $this->module->getName() . ' : AdminTask “' . $task->getName() . '” has been updated.'); $success = true; } } else { FlashMessages::addMessage(I18N::translate('An error occured while updating the administrative task “%s”', $task->getTitle()), 'danger'); Log::addConfigurationLog('Module ' . $this->module->getName() . ' : AdminTask “' . $task->getName() . '” could not be updated. See error log.'); } } $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'; if (!$success) { $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@edit&task=' . $task->getName(); } header('Location: ' . WT_BASE_URL . $redirection_url); }
/** * Action from the configuration page */ private function editSave() { if (Filter::checkCsrf()) { $block_id = Filter::postInteger('block_id'); if ($block_id) { Database::prepare("UPDATE `##block` SET gedcom_id = NULLIF(:tree_id, '0'), block_order = :block_order WHERE block_id = :block_id")->execute(array('tree_id' => Filter::postInteger('gedcom_id'), 'block_order' => Filter::postInteger('block_order'), 'block_id' => $block_id)); } else { Database::prepare("INSERT INTO `##block` (gedcom_id, module_name, block_order) VALUES (NULLIF(:tree_id, '0'), :module_name, :block_order)")->execute(array('tree_id' => Filter::postInteger('gedcom_id'), 'module_name' => $this->getName(), 'block_order' => Filter::postInteger('block_order'))); $block_id = Database::getInstance()->lastInsertId(); } $this->setBlockSetting($block_id, 'header', Filter::post('header')); $this->setBlockSetting($block_id, 'faqbody', Filter::post('faqbody')); $languages = Filter::postArray('lang'); $this->setBlockSetting($block_id, 'languages', implode(',', $languages)); } }
$tree->setPreference('keep_media', $keep_media); $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); if (isset($_FILES['tree_name'])) { if ($_FILES['tree_name']['error'] == 0 && is_readable($_FILES['tree_name']['tmp_name'])) { $tree->importGedcomFile($_FILES['tree_name']['tmp_name'], $_FILES['tree_name']['name']); } } else { FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); } } header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); return; case 'replace_import': $basename = basename(Filter::post('tree_name')); $gedcom_id = Filter::postInteger('gedcom_id'); $keep_media = Filter::post('keep_media', '1', '0'); $GEDCOM_MEDIA_PATH = Filter::post('GEDCOM_MEDIA_PATH'); $WORD_WRAPPED_NOTES = Filter::post('WORD_WRAPPED_NOTES', '1', '0'); $tree = Tree::findById($gedcom_id); if (Filter::checkCsrf() && $tree) { $tree->setPreference('keep_media', $keep_media); $tree->setPreference('GEDCOM_MEDIA_PATH', $GEDCOM_MEDIA_PATH); $tree->setPreference('WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES); if ($basename) { $tree->importGedcomFile(WT_DATA_DIR . $basename, $basename); } else { FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); } } header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
/** * AdminConfig@save */ public function save() { global $WT_TREE; $tmp_contrl = new PageController(); $tmp_contrl->restrictAccess(Auth::isManager($WT_TREE) && Filter::checkCsrf()); $ga_id = Filter::postInteger('ga_id'); $description = Filter::post('description'); $analysislevel = Filter::postInteger('analysislevel'); $use_map = Filter::postBool('use_map'); if ($use_map) { $map_file = base64_decode(Filter::post('map_file')); $map_top_level = Filter::postInteger('map_top_level'); } $use_flags = Filter::postBool('use_flags'); $gen_details = Filter::postInteger('gen_details'); $success = false; if ($ga_id) { $ga = $this->provider->getGeoAnalysis($ga_id, false); if ($ga) { $ga->setTitle($description); $ga->setAnalysisLevel($analysislevel + 1); $options = $ga->getOptions(); if ($options) { $options->setUsingFlags($use_flags); $options->setMaxDetailsInGen($gen_details); if ($use_map) { $options->setMap(new OutlineMap($map_file)); $options->setMapLevel($map_top_level + 1); } else { $options->setMap(null); } } $res = $this->provider->updateGeoAnalysis($ga); if ($res) { FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully updated', $res->getTitle()), 'success'); Log::addConfigurationLog('Module ' . $this->module->getName() . ' : Geo Analysis ID “' . $res->getId() . '” has been updated.'); $ga = $res; $success = true; } else { FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger'); Log::addConfigurationLog('Module ' . $this->module->getName() . ' : Geo Analysis ID “' . $ga->getId() . '” could not be updated. See error log.'); } } } else { $ga = $this->provider->createGeoAnalysis($description, $analysislevel + 1, $use_map ? $map_file : null, $use_map ? $map_top_level + 1 : null, $use_flags, $gen_details); if ($ga) { FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully added.', $ga->getTitle()), 'success'); Log::addConfigurationLog('Module ' . $this->module->getName() . ' : Geo Analysis ID “' . $ga->getId() . '” has been added.'); $success = true; } else { FlashMessages::addMessage(I18N::translate('An error occured while adding the geographical dispersion analysis “%s”', $description), 'danger'); Log::addConfigurationLog('Module ' . $this->module->getName() . ' : Geo Analysis “' . $description . '” could not be added. See error log.'); } } $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl(); if (!$success) { if ($ga) { $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id=' . $ga->getId() . '&ged=' . $WT_TREE->getNameUrl(); } else { $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $WT_TREE->getNameUrl(); } } header('Location: ' . WT_BASE_URL . $redirection_url); }
/** * An HTML form to edit block settings * * @param int $block_id */ public function configureBlock($block_id) { if (Filter::postBool('save') && Filter::checkCsrf()) { $this->setBlockSetting($block_id, 'days', Filter::postInteger('days', 1, 30, 7)); $this->setBlockSetting($block_id, 'filter', Filter::postBool('filter')); $this->setBlockSetting($block_id, 'onlyBDM', Filter::postBool('onlyBDM')); $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table', 'table')); $this->setBlockSetting($block_id, 'sortStyle', Filter::post('sortStyle', 'alpha|anniv', 'alpha')); $this->setBlockSetting($block_id, 'block', Filter::postBool('block')); } $days = $this->getBlockSetting($block_id, 'days', '7'); $filter = $this->getBlockSetting($block_id, 'filter', '1'); $onlyBDM = $this->getBlockSetting($block_id, 'onlyBDM', '0'); $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); $sortStyle = $this->getBlockSetting($block_id, 'sortStyle', 'alpha'); $block = $this->getBlockSetting($block_id, 'block', '1'); echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Number of days to show'); echo '</td><td class="optionbox">'; echo '<input type="text" name="days" size="2" value="', $days, '">'; echo ' <em>', I18N::plural('maximum %s day', 'maximum %s days', 30, I18N::number(30)), '</em>'; echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Show only events of living individuals'); echo '</td><td class="optionbox">'; echo FunctionsEdit::editFieldYesNo('filter', $filter); echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Show only births, deaths, and marriages'); echo '</td><td class="optionbox">'; echo FunctionsEdit::editFieldYesNo('onlyBDM', $onlyBDM); echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Presentation style'); echo '</td><td class="optionbox">'; echo FunctionsEdit::selectEditControl('infoStyle', array('list' => I18N::translate('list'), 'table' => I18N::translate('table')), null, $infoStyle, ''); echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Sort order'); echo '</td><td class="optionbox">'; echo FunctionsEdit::selectEditControl('sortStyle', array('alpha' => I18N::translate('sort by name'), 'anniv' => I18N::translate('sort by date')), null, $sortStyle, ''); echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Add a scrollbar when block contents grow'); echo '</td><td class="optionbox">'; echo FunctionsEdit::editFieldYesNo('block', $block); echo '</td></tr>'; }
/** {@inheritdoc} */ public function configureBlock($block_id) { if (Filter::postBool('save') && Filter::checkCsrf()) { $this->setBlockSetting($block_id, 'days', Filter::postInteger('days', 1, self::MAX_DAYS)); $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table')); $this->setBlockSetting($block_id, 'sortStyle', Filter::post('sortStyle', 'name|date_asc|date_desc')); $this->setBlockSetting($block_id, 'show_user', Filter::postBool('show_user')); $this->setBlockSetting($block_id, 'hide_empty', Filter::postBool('hide_empty')); $this->setBlockSetting($block_id, 'block', Filter::postBool('block')); } $days = $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS); $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_INFO_STYLE); $sortStyle = $this->getBlockSetting($block_id, 'sortStyle', self::DEFAULT_SORT_STYLE); $show_user = $this->getBlockSetting($block_id, 'show_user', self::DEFAULT_SHOW_USER); $block = $this->getBlockSetting($block_id, 'block', self::DEFAULT_BLOCK); $hide_empty = $this->getBlockSetting($block_id, 'hide_empty', self::DEFAULT_HIDE_EMPTY); echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Number of days to show'); echo '</td><td class="optionbox">'; echo '<input type="text" name="days" size="2" value="', $days, '">'; echo ' <em>', I18N::plural('maximum %s day', 'maximum %s days', I18N::number(self::MAX_DAYS), I18N::number(self::MAX_DAYS)), '</em>'; echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Presentation style'); echo '</td><td class="optionbox">'; echo FunctionsEdit::selectEditControl('infoStyle', array('list' => I18N::translate('list'), 'table' => I18N::translate('table')), null, $infoStyle, ''); echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Sort order'); echo '</td><td class="optionbox">'; echo FunctionsEdit::selectEditControl('sortStyle', array('name' => I18N::translate('sort by name'), 'date_asc' => I18N::translate('sort by date, oldest first'), 'date_desc' => I18N::translate('sort by date, newest first')), null, $sortStyle, ''); echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Show the user who made the change'); echo '</td><td class="optionbox">'; echo FunctionsEdit::editFieldYesNo('show_user', $show_user); echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Add a scrollbar when block contents grow'); echo '</td><td class="optionbox">'; echo FunctionsEdit::editFieldYesNo('block', $block); echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Should this block be hidden when it is empty'); echo '</td><td class="optionbox">'; echo FunctionsEdit::editFieldYesNo('hide_empty', $hide_empty); echo '</td></tr>'; echo '<tr><td colspan="2" class="optionbox wrap">'; echo '<span class="error">', I18N::translate('If you hide an empty block, you will not be able to change its configuration until it becomes visible by no longer being empty.'), '</span>'; echo '</td></tr>'; }
use PDO; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; define('WT_SCRIPT_NAME', 'editnews.php'); require './includes/session.php'; $controller = new SimpleController(); $controller->setPageTitle(I18N::translate('Add/edit a journal/news entry'))->restrictAccess(Auth::isMember($WT_TREE))->pageHeader(); $action = Filter::get('action', 'compose|save', 'compose'); $news_id = Filter::getInteger('news_id'); $user_id = Filter::get('user_id', WT_REGEX_INTEGER, Filter::post('user_id', WT_REGEX_INTEGER)); $gedcom_id = Filter::get('gedcom_id', WT_REGEX_INTEGER, Filter::post('gedcom_id', WT_REGEX_INTEGER)); $date = Filter::postInteger('date', 0, PHP_INT_MAX, WT_TIMESTAMP); $title = Filter::post('title'); $text = Filter::post('text'); switch ($action) { case 'compose': if (Module::getModuleByName('ckeditor')) { CkeditorModule::enableEditor($controller); } echo '<h3>' . I18N::translate('Add/edit a journal/news entry') . '</h3>'; echo '<form style="overflow: hidden;" name="messageform" method="post" action="editnews.php?action=save&news_id=' . $news_id . '">'; if ($news_id) { $news = Database::prepare("SELECT SQL_CACHE news_id AS id, user_id, gedcom_id, UNIX_TIMESTAMP(updated) AS date, subject, body FROM `##news` WHERE news_id=?")->execute(array($news_id))->fetchOneRow(PDO::FETCH_ASSOC); } else { $news = array(); $news['user_id'] = $user_id; $news['gedcom_id'] = $gedcom_id;
/** * An HTML form to edit block settings * * @param int $block_id */ public function configureBlock($block_id) { if (Filter::postBool('save') && Filter::checkCsrf()) { $this->setBlockSetting($block_id, 'show_last_update', Filter::postBool('show_last_update')); $this->setBlockSetting($block_id, 'show_common_surnames', Filter::postBool('show_common_surnames')); $this->setBlockSetting($block_id, 'number_of_surnames', Filter::postInteger('number_of_surnames')); $this->setBlockSetting($block_id, 'stat_indi', Filter::postBool('stat_indi')); $this->setBlockSetting($block_id, 'stat_fam', Filter::postBool('stat_fam')); $this->setBlockSetting($block_id, 'stat_sour', Filter::postBool('stat_sour')); $this->setBlockSetting($block_id, 'stat_other', Filter::postBool('stat_other')); $this->setBlockSetting($block_id, 'stat_media', Filter::postBool('stat_media')); $this->setBlockSetting($block_id, 'stat_repo', Filter::postBool('stat_repo')); $this->setBlockSetting($block_id, 'stat_surname', Filter::postBool('stat_surname')); $this->setBlockSetting($block_id, 'stat_events', Filter::postBool('stat_events')); $this->setBlockSetting($block_id, 'stat_users', Filter::postBool('stat_users')); $this->setBlockSetting($block_id, 'stat_first_birth', Filter::postBool('stat_first_birth')); $this->setBlockSetting($block_id, 'stat_last_birth', Filter::postBool('stat_last_birth')); $this->setBlockSetting($block_id, 'stat_first_death', Filter::postBool('stat_first_death')); $this->setBlockSetting($block_id, 'stat_last_death', Filter::postBool('stat_last_death')); $this->setBlockSetting($block_id, 'stat_long_life', Filter::postBool('stat_long_life')); $this->setBlockSetting($block_id, 'stat_avg_life', Filter::postBool('stat_avg_life')); $this->setBlockSetting($block_id, 'stat_most_chil', Filter::postBool('stat_most_chil')); $this->setBlockSetting($block_id, 'stat_avg_chil', Filter::postBool('stat_avg_chil')); } $show_last_update = $this->getBlockSetting($block_id, 'show_last_update', '1'); $show_common_surnames = $this->getBlockSetting($block_id, 'show_common_surnames', '1'); $number_of_surnames = $this->getBlockSetting($block_id, 'number_of_surnames', self::DEFAULT_NUMBER_OF_SURNAMES); $stat_indi = $this->getBlockSetting($block_id, 'stat_indi', '1'); $stat_fam = $this->getBlockSetting($block_id, 'stat_fam', '1'); $stat_sour = $this->getBlockSetting($block_id, 'stat_sour', '1'); $stat_media = $this->getBlockSetting($block_id, 'stat_media', '1'); $stat_repo = $this->getBlockSetting($block_id, 'stat_repo', '1'); $stat_surname = $this->getBlockSetting($block_id, 'stat_surname', '1'); $stat_events = $this->getBlockSetting($block_id, 'stat_events', '1'); $stat_users = $this->getBlockSetting($block_id, 'stat_users', '1'); $stat_first_birth = $this->getBlockSetting($block_id, 'stat_first_birth', '1'); $stat_last_birth = $this->getBlockSetting($block_id, 'stat_last_birth', '1'); $stat_first_death = $this->getBlockSetting($block_id, 'stat_first_death', '1'); $stat_last_death = $this->getBlockSetting($block_id, 'stat_last_death', '1'); $stat_long_life = $this->getBlockSetting($block_id, 'stat_long_life', '1'); $stat_avg_life = $this->getBlockSetting($block_id, 'stat_avg_life', '1'); $stat_most_chil = $this->getBlockSetting($block_id, 'stat_most_chil', '1'); $stat_avg_chil = $this->getBlockSetting($block_id, 'stat_avg_chil', '1'); ?> <tr> <td class="descriptionbox wrap width33"> <label for="show-last-update"> <?php echo I18N::translate('Show date of last update'); ?> </label> </td> <td class="optionbox"> <input type="checkbox" value="yes" id="show-last-update" name="show_last_update" <?php echo $show_last_update ? 'checked' : ''; ?> > </td> </tr> <tr> <td class="descriptionbox wrap width33"> <?php echo I18N::translate('Statistics'); ?> </td> <td class="optionbox"> <table> <tbody> <tr> <td> <label> <input type="checkbox" value="yes" name="stat_indi" <?php echo $stat_indi ? 'checked' : ''; ?> > <?php echo I18N::translate('Individuals'); ?> </label> </td> <td> <label> <input type="checkbox" value="yes" name="stat_first_birth" <?php echo $stat_first_birth ? 'checked' : ''; ?> > <?php echo I18N::translate('Earliest birth year'); ?> </label> </td> </tr> <tr> <td> <label> <input type="checkbox" value="yes" name="stat_surname" <?php echo $stat_surname ? 'checked' : ''; ?> > <?php echo I18N::translate('Total surnames'); ?> </label> </td> <td> <label> <input type="checkbox" value="yes" name="stat_last_birth" <?php echo $stat_last_birth ? 'checked' : ''; ?> > <?php echo I18N::translate('Latest birth year'); ?> </label> </td> </tr> <tr> <td> <label> <input type="checkbox" value="yes" name="stat_fam" <?php echo $stat_fam ? 'checked' : ''; ?> > <?php echo I18N::translate('Families'); ?> </label> </td> <td> <label> <input type="checkbox" value="yes" name="stat_first_death" <?php echo $stat_first_death ? 'checked' : ''; ?> > <?php echo I18N::translate('Earliest death year'); ?> </label> </td> </tr> <tr> <td> <label> <input type="checkbox" value="yes" name="stat_sour" <?php echo $stat_sour ? 'checked' : ''; ?> > <?php echo I18N::translate('Sources'); ?> </label> </td> <td> <label> <input type="checkbox" value="yes" name="stat_last_death" <?php echo $stat_last_death ? 'checked' : ''; ?> > <?php echo I18N::translate('Latest death year'); ?> </label> </td> </tr> <tr> <td> <label> <input type="checkbox" value="yes" name="stat_media" <?php echo $stat_media ? 'checked' : ''; ?> > <?php echo I18N::translate('Media objects'); ?> </label> </td> <td> <label> <input type="checkbox" value="yes" name="stat_long_life" <?php echo $stat_long_life ? 'checked' : ''; ?> > <?php echo I18N::translate('Individual who lived the longest'); ?> </label> </td> </tr> <tr> <td> <label> <input type="checkbox" value="yes" name="stat_repo" <?php echo $stat_repo ? 'checked' : ''; ?> > <?php echo I18N::translate('Repositories'); ?> </label> </td> <td> <label> <input type="checkbox" value="yes" name="stat_avg_life" <?php echo $stat_avg_life ? 'checked' : ''; ?> > <?php echo I18N::translate('Average age at death'); ?> </label> </td> </tr> <tr> <td> <label> <input type="checkbox" value="yes" name="stat_events" <?php echo $stat_events ? 'checked' : ''; ?> > <?php echo I18N::translate('Total events'); ?> </label> </td> <td> <label> <input type="checkbox" value="yes" name="stat_most_chil" <?php echo $stat_most_chil ? 'checked' : ''; ?> > <?php echo I18N::translate('Family with the most children'); ?> </label> </td> </tr> <tr> <td> <label> <input type="checkbox" value="yes" name="stat_users" <?php echo $stat_users ? 'checked' : ''; ?> > <?php echo I18N::translate('Total users'); ?> </label> </td> <td> <label> <input type="checkbox" value="yes" name="stat_avg_chil" <?php echo $stat_avg_chil ? 'checked' : ''; ?> > <?php echo I18N::translate('Average number of children per family'); ?> </label> </td> </tr> </tbody> </table> </td> </tr> <tr> <td class="descriptionbox wrap width33"> <label for="show-common-surnames"> <?php echo I18N::translate('Most common surnames'); ?> </label> </td> <td class="optionbox"> <input type="checkbox" value="yes" id="show-common-surnames" name="show_common_surnames" <?php echo $show_common_surnames ? 'checked' : ''; ?> > </td> </tr> <tr> <td class="descriptionbox wrap width33"> <label for="number-of-surnames"> <?php echo I18N::translate('Number of surnames'); ?> </label> </td> <td class="optionbox"> <input id="number-of-surnames" maxlength="5" name="number_of_surnames" pattern="[1-9][0-9]*" required type="text" value="<?php echo Filter::escapeHtml($number_of_surnames); ?> " > </td> </tr> <?php }
/** * An HTML form to edit block settings * * @param int $block_id */ public function configureBlock($block_id) { if (Filter::postBool('save') && Filter::checkCsrf()) { $this->setBlockSetting($block_id, 'num', Filter::postInteger('num', 1, 10000, 10)); $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|array|table|tagcloud', 'table')); } $num = $this->getBlockSetting($block_id, 'num', '10'); $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Number of surnames'); echo '</td><td class="optionbox">'; echo '<input type="text" name="num" size="2" value="', $num, '">'; echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Presentation style'); echo '</td><td class="optionbox">'; echo FunctionsEdit::selectEditControl('infoStyle', array('list' => I18N::translate('bullet list'), 'array' => I18N::translate('compact list'), 'table' => I18N::translate('table'), 'tagcloud' => I18N::translate('tag cloud')), null, $infoStyle, ''); echo '</td></tr>'; }
/** * AdminConfig@jsonTasksList */ public function jsonTasksList() { global $WT_TREE; $controller = new JsonController(); $controller->restrictAccess(Auth::isAdmin()); // Generate an AJAX/JSON response for datatables to load a block of rows $search = Filter::postArray('search'); if ($search) { $search = $search['value']; } $start = Filter::postInteger('start'); $length = Filter::postInteger('length'); $order = Filter::postArray('order'); $order_by_name = false; foreach ($order as $key => &$value) { switch ($value['column']) { case 3: $order_by_name = true; unset($order[$key]); break; case 4: $value['column'] = 'majat_last_run'; break; case 4: $value['column'] = 'majat_last_result'; break; default: unset($order[$key]); } } $list = $this->provider->getFilteredTasksList($search, $order, $start, $length); if ($order_by_name) { usort($list, function (AbstractTask $a, AbstractTask $b) { return I18N::strcasecmp($a->getTitle(), $b->getTitle()); }); } $recordsFiltered = count($list); $recordsTotal = $this->provider->getTasksCount(); $data = array(); foreach ($list as $task) { $datum = array(); $datum[0] = ' <div class="btn-group"> <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> <i class="fa fa-pencil"></i><span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li> <a href="#" onclick="return set_admintask_status(\'' . $task->getName() . '\', ' . ($task->isEnabled() ? 'false' : 'true') . ');"> <i class="fa fa-fw ' . ($task->isEnabled() ? 'fa-times' : 'fa-check') . '"></i> ' . ($task->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')) . ' </a> </li> <li> <a href="module.php?mod=' . $this->module->getName() . '&mod_action=Task@edit&task=' . $task->getName() . '"> <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit') . ' </a> </li> </ul> </div>'; $datum[1] = $task->getName(); $datum[2] = $task->isEnabled() ? '<i class="fa fa-check"></i><span class="sr-only">' . I18N::translate('Enabled') . '</span>' : '<i class="fa fa-times"></i><span class="sr-only">' . I18N::translate('Disabled') . '</span>'; $datum[3] = $task->getTitle(); $date_format = str_replace('%', '', I18N::dateFormat()) . ' H:i:s'; $datum[4] = $task->getLastUpdated()->format($date_format); $datum[5] = $task->isLastRunSuccess() ? '<i class="fa fa-check"></i><span class="sr-only">' . I18N::translate('Yes') . '</span>' : '<i class="fa fa-times"></i><span class="sr-only">' . I18N::translate('No') . '</span>'; $dtF = new \DateTime('@0'); $dtT = new \DateTime('@' . $task->getFrequency() * 60); $datum[6] = $dtF->diff($dtT)->format(I18N::translate('%a d %h h %i m')); $datum[7] = $task->getRemainingOccurrences() > 0 ? I18N::number($task->getRemainingOccurrences()) : I18N::translate('Unlimited'); $datum[8] = $task->isRunning() ? '<i class="fa fa-cog fa-spin fa-fw"></i><span class="sr-only">' . I18N::translate('Running') . '</span>' : '<i class="fa fa-times"></i><span class="sr-only">' . I18N::translate('Not running') . '</span>'; if ($task->isEnabled() && !$task->isRunning()) { $datum[9] = ' <button id="bt_runtask_' . $task->getName() . '" class="btn btn-primary" href="#" onclick="return run_admintask(\'' . $task->getName() . '\')"> <div id="bt_runtasktext_' . $task->getName() . '"><i class="fa fa-cog fa-fw" ></i>' . I18N::translate('Run') . '</div> </button>'; } else { $datum[9] = ''; } $data[] = $datum; } $controller->pageHeader(); $controller->encode(array('draw' => Filter::getInteger('draw'), 'recordsTotal' => $recordsTotal, 'recordsFiltered' => $recordsFiltered, 'data' => $data)); }
/** {@inheritdoc} */ public function modAction($mod_action) { switch ($mod_action) { case 'admin_config': if (Filter::postBool('save') && Filter::checkCsrf()) { $this->setSetting('FTV_PDF_ACCESS_LEVEL', Filter::postInteger('NEW_FTV_PDF_ACCESS_LEVEL')); Log::addConfigurationLog($this->getTitle() . ' config updated'); } $template = new AdminTemplate(); return $template->pageContent(); case 'full_pdf': echo $this->module()->printPage(0); break; case 'write_pdf': $tmp_dir = WT_DATA_DIR . 'ftv_pdf_tmp/'; if (file_exists($tmp_dir)) { File::delete($tmp_dir); } File::mkdir($tmp_dir); $template = new PdfTemplate(); return $template->pageBody(); case 'output_pdf': $file = WT_DATA_DIR . 'ftv_pdf_tmp/' . Filter::get('title') . '.pdf'; if (file_exists($file)) { ob_start(); header('Content-Description: File Transfer'); header('Content-Type: application/pdf'); header('Content-Disposition: attachment; filename="' . basename($file) . '"'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); ob_clean(); ob_end_flush(); readfile($file); File::delete(dirname($file)); } else { FlashMessages::addMessage(I18N::translate('The file %s could not be created.', basename($file)), 'danger'); Header('Location:' . WT_BASE_URL . 'module.php?mod=fancy_treeview&mod_action=page&rootid=' . Filter::get('rootid') . '&ged=' . Filter::get('ged')); } break; default: http_response_code(404); break; } }
/** * An HTML form to edit block settings * * @param int $block_id */ public function configureBlock($block_id) { if (Filter::postBool('save') && Filter::checkCsrf()) { $this->setBlockSetting($block_id, 'days', Filter::postInteger('days', 1, 30, 7)); $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table', 'table')); $this->setBlockSetting($block_id, 'calendar', Filter::post('calendar', 'jewish|gregorian', 'jewish')); $this->setBlockSetting($block_id, 'block', Filter::postBool('block')); } $days = $this->getBlockSetting($block_id, 'days', '7'); $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); $calendar = $this->getBlockSetting($block_id, 'calendar', 'jewish'); $block = $this->getBlockSetting($block_id, 'block', '1'); echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Number of days to show'); echo '</td><td class="optionbox">'; echo '<input type="text" name="days" size="2" value="' . $days . '">'; echo ' <em>', I18N::plural('maximum %s day', 'maximum %s days', 30, I18N::number(30)), '</em>'; echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Presentation style'); echo '</td><td class="optionbox">'; echo FunctionsEdit::selectEditControl('infoStyle', array('list' => I18N::translate('list'), 'table' => I18N::translate('table')), null, $infoStyle, ''); echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Calendar'); echo '</td><td class="optionbox">'; echo FunctionsEdit::selectEditControl('calendar', array('jewish' => I18N::translate('Jewish'), 'gregorian' => I18N::translate('Gregorian')), null, $calendar, ''); echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Add a scrollbar when block contents grow'); echo '</td><td class="optionbox">'; echo FunctionsEdit::editFieldYesNo('block', $block); echo '</td></tr>'; }
// Do not allow a path length to be set if the individual ID is not $tree->setUserPreference($user, 'RELATIONSHIP_PATH_LENGTH', null); } } } } header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); return; } switch (Filter::get('action')) { case 'load_json': // Generate an AJAX/JSON response for datatables to load a block of rows $search = Filter::postArray('search'); $search = $search['value']; $start = Filter::postInteger('start'); $length = Filter::postInteger('length'); $order = Filter::postArray('order'); $sql_select = "SELECT SQL_CACHE SQL_CALC_FOUND_ROWS '', u.user_id, user_name, real_name, email, us1.setting_value, us2.setting_value, us2.setting_value, us3.setting_value, us3.setting_value, us4.setting_value, us5.setting_value" . " FROM `##user` u" . " LEFT JOIN `##user_setting` us1 ON (u.user_id=us1.user_id AND us1.setting_name='language')" . " LEFT JOIN `##user_setting` us2 ON (u.user_id=us2.user_id AND us2.setting_name='reg_timestamp')" . " LEFT JOIN `##user_setting` us3 ON (u.user_id=us3.user_id AND us3.setting_name='sessiontime')" . " LEFT JOIN `##user_setting` us4 ON (u.user_id=us4.user_id AND us4.setting_name='verified')" . " LEFT JOIN `##user_setting` us5 ON (u.user_id=us5.user_id AND us5.setting_name='verified_by_admin')" . " WHERE u.user_id > 0"; $args = array(); if ($search) { $sql_select .= " AND (user_name LIKE CONCAT('%', :search_1, '%') OR real_name LIKE CONCAT('%', :search_2, '%') OR email LIKE CONCAT('%', :search_3, '%'))"; $args['search_1'] = $search; $args['search_2'] = $search; $args['search_3'] = $search; } if ($order) { $sql_select .= " ORDER BY "; foreach ($order as $key => $value) { if ($key > 0) { $sql_select .= ','; }
/** * An HTML form to edit block settings * * @param int $block_id */ public function configureBlock($block_id) { if (Filter::postBool('save') && Filter::checkCsrf()) { $this->setBlockSetting($block_id, 'days', Filter::postInteger('num', 1, 180, 1)); $this->setBlockSetting($block_id, 'sendmail', Filter::postBool('sendmail')); $this->setBlockSetting($block_id, 'block', Filter::postBool('block')); } $sendmail = $this->getBlockSetting($block_id, 'sendmail', '1'); $days = $this->getBlockSetting($block_id, 'days', '1'); $block = $this->getBlockSetting($block_id, 'block', '1'); ?> <tr> <td colspan="2"> <?php echo I18N::translate('This block will show editors a list of records with pending changes that need to be approved by a moderator. It also generates daily emails to moderators whenever pending changes exist.'); ?> </td> </tr> <?php echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Send out reminder emails?'); echo '</td><td class="optionbox">'; echo FunctionsEdit::editFieldYesNo('sendmail', $sendmail); echo '<br>'; echo I18N::translate('Reminder email frequency (days)') . " <input type='text' name='days' value='" . $days . "' size='2'>"; echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Add a scrollbar when block contents grow'); echo '</td><td class="optionbox">'; echo FunctionsEdit::editFieldYesNo('block', $block); echo '</td></tr>'; }
/** * An HTML form to edit block settings * * @param int $block_id */ public function configureBlock($block_id) { if (Filter::postBool('save') && Filter::checkCsrf()) { $this->setBlockSetting($block_id, 'num', Filter::postInteger('num', 1, 10000, 10)); $this->setBlockSetting($block_id, 'threshold', Filter::postInteger('threshold', 1, 100, 5)); $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|array|table|tagcloud', 'table')); $this->setBlockSetting($block_id, 'block', Filter::postBool('block')); } $num = $this->getBlockSetting($block_id, 'num', '10'); $threshold = $this->getBlockSetting($block_id, 'threshold', '5'); $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); $block = $this->getBlockSetting($block_id, 'block', '0'); echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Number of items to show'); echo '</td><td class="optionbox">'; echo '<input type="text" name="num" size="2" value="', $num, '">'; echo '</td></tr>'; // The new input row in the form. Its copied from Control Panel’s Preferences // page echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Minimum number of occurrences to be a “common surname”'); echo '</td><td class="optionbox">'; echo '<input type="text" name="threshold" size="2" value="', $threshold, '">'; echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Presentation style'); echo '</td><td class="optionbox">'; echo FunctionsEdit::selectEditControl('infoStyle', array('list' => I18N::translate('bullet list'), 'array' => I18N::translate('compact list'), 'table' => I18N::translate('table'), 'tagcloud' => I18N::translate('tag cloud')), null, $infoStyle, ''); echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Add a scrollbar when block contents grow'); echo '</td><td class="optionbox">'; echo FunctionsEdit::editFieldYesNo('block', $block); echo '</td></tr>'; }
/** * Action from the configuration page */ private function edit() { global $WT_TREE; if (Filter::postBool('save') && Filter::checkCsrf()) { $block_id = Filter::postInteger('block_id'); if ($block_id) { Database::prepare("UPDATE `##block` SET gedcom_id = NULLIF(:tree_id, '0'), block_order = :block_order WHERE block_id = :block_id")->execute(array('tree_id' => Filter::postInteger('gedcom_id'), 'block_order' => Filter::postInteger('block_order'), 'block_id' => $block_id)); } else { Database::prepare("INSERT INTO `##block` (gedcom_id, module_name, block_order) VALUES (NULLIF(:tree_id, '0'), :module_name, :block_order)")->execute(array('tree_id' => Filter::postInteger('gedcom_id'), 'module_name' => $this->getName(), 'block_order' => Filter::postInteger('block_order'))); $block_id = Database::getInstance()->lastInsertId(); } $this->setBlockSetting($block_id, 'header', Filter::post('header')); $this->setBlockSetting($block_id, 'faqbody', Filter::post('faqbody')); $languages = Filter::postArray('lang'); $this->setBlockSetting($block_id, 'languages', implode(',', $languages)); $this->config(); } else { $block_id = Filter::getInteger('block_id'); $controller = new PageController(); if ($block_id) { $controller->setPageTitle(I18N::translate('Edit FAQ item')); $header = $this->getBlockSetting($block_id, 'header'); $faqbody = $this->getBlockSetting($block_id, 'faqbody'); $block_order = Database::prepare("SELECT block_order FROM `##block` WHERE block_id = :block_id")->execute(array('block_id' => $block_id))->fetchOne(); $gedcom_id = Database::prepare("SELECT gedcom_id FROM `##block` WHERE block_id = :block_id")->execute(array('block_id' => $block_id))->fetchOne(); } else { $controller->setPageTitle(I18N::translate('Add an FAQ item')); $header = ''; $faqbody = ''; $block_order = Database::prepare("SELECT IFNULL(MAX(block_order)+1, 0) FROM `##block` WHERE module_name = :module_name")->execute(array('module_name' => $this->getName()))->fetchOne(); $gedcom_id = $WT_TREE->getTreeId(); } $controller->pageHeader(); if (Module::getModuleByName('ckeditor')) { CkeditorModule::enableEditor($controller); } ?> <ol class="breadcrumb small"> <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?> </a></li> <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?> </a></li> <li><a href="module.php?mod=<?php echo $this->getName(); ?> &mod_action=admin_config"><?php echo I18N::translate('Frequently asked questions'); ?> </a> </li> <li class="active"><?php echo $controller->getPageTitle(); ?> </li> </ol> <h1><?php echo $controller->getPageTitle(); ?> </h1> <form name="faq" class="form-horizontal" method="post" action="module.php?mod=<?php echo $this->getName(); ?> &mod_action=admin_edit"> <?php echo Filter::getCsrf(); ?> <input type="hidden" name="save" value="1"> <input type="hidden" name="block_id" value="<?php echo $block_id; ?> "> <div class="form-group"> <label for="header" class="col-sm-3 control-label"> <?php echo I18N::translate('Question'); ?> </label> <div class="col-sm-9"> <input type="text" class="form-control" name="header" id="header" value="<?php echo Filter::escapeHtml($header); ?> "> </div> </div> <div class="form-group"> <label for="faqbody" class="col-sm-3 control-label"> <?php echo I18N::translate('Answer'); ?> </label> <div class="col-sm-9"> <textarea name="faqbody" id="faqbody" class="form-control html-edit" rows="10"><?php echo Filter::escapeHtml($faqbody); ?> </textarea> </div> </div> <div class="form-group"> <label for="xref" class="col-sm-3 control-label"> <?php echo I18N::translate('Show this block for which languages?'); ?> </label> <div class="col-sm-9"> <?php echo FunctionsEdit::editLanguageCheckboxes('lang', explode(',', $this->getBlockSetting($block_id, 'languages'))); ?> </div> </div> <div class="form-group"> <label for="block_order" class="col-sm-3 control-label"> <?php echo I18N::translate('FAQ position'); ?> </label> <div class="col-sm-9"> <input type="text" name="block_order" id="block_order" class="form-control" value="<?php echo $block_order; ?> "> </div> </div> <div class="form-group"> <label for="gedcom_id" class="col-sm-3 control-label"> <?php echo I18N::translate('FAQ visibility'); ?> </label> <div class="col-sm-9"> <?php echo FunctionsEdit::selectEditControl('gedcom_id', Tree::getIdList(), I18N::translate('All'), $gedcom_id, 'class="form-control"'); ?> <p class="small text-muted"> <?php echo I18N::translate('A FAQ item can be displayed on just one of the family trees, or on all the family trees.'); ?> </p> </div> </div> <div class="form-group"> <div class="col-sm-offset-3 col-sm-9"> <button type="submit" class="btn btn-primary"> <i class="fa fa-check"></i> <?php echo I18N::translate('save'); ?> </button> </div> </div> </form> <?php } }
/** * An HTML form to edit block settings * * @param int $block_id */ public function configureBlock($block_id) { if (Filter::postBool('save') && Filter::checkCsrf()) { $this->setBlockSetting($block_id, 'num', Filter::postInteger('num', 1, 10000, 10)); $this->setBlockSetting($block_id, 'count_placement', Filter::post('count_placement', 'before|after', 'before')); $this->setBlockSetting($block_id, 'block', Filter::postBool('block')); } $num = $this->getBlockSetting($block_id, 'num', '10'); $count_placement = $this->getBlockSetting($block_id, 'count_placement', 'before'); $block = $this->getBlockSetting($block_id, 'block', '0'); echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Number of items to show'); echo '</td><td class="optionbox">'; echo '<input type="text" name="num" size="2" value="', $num, '">'; echo '</td></tr>'; echo "<tr><td class=\"descriptionbox wrap width33\">"; echo I18N::translate('Place counts before or after name?'); echo "</td><td class=\"optionbox\">"; echo FunctionsEdit::selectEditControl('count_placement', array('before' => I18N::translate('before'), 'after' => I18N::translate('after')), null, $count_placement, ''); echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Add a scrollbar when block contents grow'); echo '</td><td class="optionbox">'; echo FunctionsEdit::editFieldYesNo('block', $block); echo '</td></tr>'; }
break; case 'language': // Change the current language $language = Filter::post('language'); try { I18N::init($language); Session::put('locale', $language); // Remember our selection Auth::user()->setPreference('language', $language); } catch (\Exception $ex) { // Request for a non-existant language. http_response_code(406); } break; case 'masquerade': $user = User::find(Filter::postInteger('user_id')); if ($user && Auth::isAdmin() && Auth::user() !== $user) { Log::addAuthenticationLog('Masquerade as user: '******'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. $source = Individual::getInstance(Filter::post('source', WT_REGEX_XREF), $WT_TREE); $target = Filter::post('target', WT_REGEX_XREF); if ($source && $source->canShow() && $source->canEdit() && $target) { // Consider the individual and their spouse-family records $sources = $source->getSpouseFamilies();
if ($oops) { FlashMessages::addMessage(I18N::translate('You cannot create a rule which would prevent yourself from accessing the website.'), 'danger'); } elseif ($site_access_rule_id === null) { Database::prepare("INSERT INTO `##site_access_rule` (ip_address_start, ip_address_end, user_agent_pattern, rule, comment) VALUES (INET_ATON(:ip_address_start), INET_ATON(:ip_address_end), :user_agent_pattern, :rule, :comment)")->execute(array('ip_address_start' => $ip_address_start, 'ip_address_end' => $ip_address_end, 'user_agent_pattern' => $user_agent_pattern, 'rule' => $rule, 'comment' => $comment)); FlashMessages::addMessage(I18N::translate('The website access rule has been created.'), 'success'); } else { Database::prepare("UPDATE `##site_access_rule` SET ip_address_start = INET_ATON(:ip_address_start), ip_address_end = INET_ATON(:ip_address_end), user_agent_pattern = :user_agent_pattern, rule = :rule, comment = :comment WHERE site_access_rule_id = :site_access_rule_id")->execute(array('ip_address_start' => $ip_address_start, 'ip_address_end' => $ip_address_end, 'user_agent_pattern' => $user_agent_pattern, 'rule' => $rule, 'comment' => $comment, 'site_access_rule_id' => $site_access_rule_id)); FlashMessages::addMessage(I18N::translate('The website access rule has been updated.'), 'success'); } } } header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); return; case 'delete': if (Filter::checkCsrf()) { $site_access_rule_id = Filter::postInteger('site_access_rule_id'); Database::prepare("DELETE FROM `##site_access_rule` WHERE site_access_rule_id = :site_access_rule_id")->execute(array('site_access_rule_id' => $site_access_rule_id)); FlashMessages::addMessage(I18N::translate('The website access rule has been deleted.'), 'success'); } header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); return; } // Delete any "unknown" visitors that are now "known". // This could happen every time we create/update a rule. Database::exec("DELETE unknown" . " FROM `##site_access_rule` AS unknown" . " JOIN `##site_access_rule` AS known ON (unknown.user_agent_pattern LIKE known.user_agent_pattern)" . " WHERE unknown.rule='unknown' AND known.rule<>'unknown'" . " AND unknown.ip_address_start BETWEEN known.ip_address_start AND known.ip_address_end"); $controller = new PageController(); $controller->restrictAccess(Auth::isAdmin())->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)->setPageTitle(I18N::translate('Website access rules')); $action = Filter::get('action'); switch ($action) { case 'load': // AJAX callback for datatables
/** * An HTML form to edit block settings * * @param int $block_id */ public function configureBlock($block_id) { if (Filter::postBool('save') && Filter::checkCsrf()) { $this->setBlockSetting($block_id, 'num', Filter::postInteger('num', 1, 10000, 10)); $this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table', 'table')); $this->setBlockSetting($block_id, 'block', Filter::postBool('block')); } $num = $this->getBlockSetting($block_id, 'num', '10'); $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table'); $block = $this->getBlockSetting($block_id, 'block', '0'); echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Number of items to show'); echo '</td><td class="optionbox">'; echo '<input type="text" name="num" size="2" value="', $num, '">'; echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Presentation style'); echo '</td><td class="optionbox">'; echo FunctionsEdit::selectEditControl('infoStyle', array('list' => I18N::translate('list'), 'table' => I18N::translate('table')), null, $infoStyle, ''); echo '</td></tr>'; echo '<tr><td class="descriptionbox wrap width33">'; echo I18N::translate('Add a scrollbar when block contents grow'); echo '</td><td class="optionbox">'; echo FunctionsEdit::editFieldYesNo('block', $block); echo '</td></tr>'; }
/** {@inheritdoc} */ public function modAction($mod_action) { Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); switch ($mod_action) { case 'admin_config': $template = new AdminTemplate(); return $template->pageContent(); case 'admin_search': // new settings $surname = Filter::post('SURNAME'); $pid = Filter::post('PID'); if ($surname) { $soundex_std = Filter::postBool('soundex_std'); $soundex_dm = Filter::postBool('soundex_dm'); $indis = $this->module()->indisArray($surname, $soundex_std, $soundex_dm); usort($indis, 'Fisharebest\\Webtrees\\Individual::compareBirthDate'); if (isset($indis) && count($indis) > 0) { $pid = $indis[0]->getXref(); } else { $result['error'] = I18N::translate('Error: The surname you entered doesn’t exist in this tree.'); } } if (isset($pid)) { $FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS')); if ($this->module()->searchArray($this->module()->searchArray($FTV_SETTINGS, 'TREE', Filter::getInteger('tree')), 'PID', $pid)) { if ($surname) { $result['error'] = I18N::translate('Error: The root person belonging to this surname already exists'); } else { $result['error'] = I18N::translate('Error: A root person with ID %s already exists', $pid); } } else { $record = Individual::getInstance($pid, $this->tree); if ($record) { $root = $record->getFullName() . ' (' . $record->getLifeSpan() . ')'; $title = $this->module()->getPageLink($pid); $result = array('access_level' => '2', 'pid' => $pid, 'root' => $root, 'sort' => count($this->module()->searchArray($FTV_SETTINGS, 'TREE', Filter::getInteger('tree'))) + 1, 'surname' => $this->module()->getSurname($pid), 'title' => $title, 'tree' => Filter::getInteger('tree')); } else { if (empty($result['error'])) { $result['error'] = I18N::translate('Error: A person with ID %s does not exist in this tree', $pid); } } } } echo json_encode($result); break; case 'admin_add': $FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS')); $NEW_FTV_SETTINGS = $FTV_SETTINGS; $NEW_FTV_SETTINGS[] = array('TREE' => Filter::getInteger('tree'), 'SURNAME' => Filter::post('surname'), 'PID' => Filter::post('pid'), 'ACCESS_LEVEL' => Filter::postInteger('access_level'), 'SORT' => Filter::postInteger('sort')); $this->setSetting('FTV_SETTINGS', serialize(array_values($NEW_FTV_SETTINGS))); Log::addConfigurationLog($this->getTitle() . ' config updated'); break; case 'admin_update': $FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS')); $new_surname = Filter::postArray('surname'); $new_access_level = Filter::postArray('access_level'); $new_sort = Filter::postArray('sort'); foreach ($new_surname as $key => $new_surname) { $FTV_SETTINGS[$key]['SURNAME'] = $new_surname; } foreach ($new_access_level as $key => $new_access_level) { $FTV_SETTINGS[$key]['ACCESS_LEVEL'] = $new_access_level; } foreach ($new_sort as $key => $new_sort) { $FTV_SETTINGS[$key]['SORT'] = $new_sort; } $NEW_FTV_SETTINGS = $this->module()->sortArray($FTV_SETTINGS, 'SORT'); $this->setSetting('FTV_SETTINGS', serialize($NEW_FTV_SETTINGS)); break; case 'admin_save': $FTV_OPTIONS = unserialize($this->getSetting('FTV_OPTIONS')); $FTV_OPTIONS[Filter::getInteger('tree')] = Filter::postArray('NEW_FTV_OPTIONS'); $this->setSetting('FTV_OPTIONS', serialize($FTV_OPTIONS)); Log::addConfigurationLog($this->getTitle() . ' config updated'); // the cache has to be recreated because the image options could have been changed $this->module()->emptyCache(); break; case 'admin_reset': $FTV_OPTIONS = unserialize($this->getSetting('FTV_OPTIONS')); unset($FTV_OPTIONS[Filter::getInteger('tree')]); $this->setSetting('FTV_OPTIONS', serialize($FTV_OPTIONS)); Log::addConfigurationLog($this->getTitle() . ' options set to default'); break; case 'admin_delete': $FTV_SETTINGS = unserialize($this->getSetting('FTV_SETTINGS')); unset($FTV_SETTINGS[Filter::getInteger('key')]); $this->setSetting('FTV_SETTINGS', serialize($FTV_SETTINGS)); Log::addConfigurationLog($this->getTitle() . ' item deleted'); break; case 'page': $template = new PageTemplate(); return $template->pageContent(); // See mediafirewall.php // See mediafirewall.php case 'thumbnail': $mid = Filter::get('mid', WT_REGEX_XREF); $media = Media::getInstance($mid, $this->tree); $mimetype = $media->mimeType(); $cache_filename = $this->module()->cacheFileName($media); $filetime = filemtime($cache_filename); $filetimeHeader = gmdate('D, d M Y H:i:s', $filetime) . ' GMT'; $expireOffset = 3600 * 24 * 7; // tell browser to cache this image for 7 days $expireHeader = gmdate('D, d M Y H:i:s', WT_TIMESTAMP + $expireOffset) . ' GMT'; $etag = $media->getEtag(); $filesize = filesize($cache_filename); // parse IF_MODIFIED_SINCE header from client $if_modified_since = 'x'; if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $if_modified_since = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']); } // parse IF_NONE_MATCH header from client $if_none_match = 'x'; if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) { $if_none_match = str_replace('"', '', $_SERVER['HTTP_IF_NONE_MATCH']); } // add caching headers. allow browser to cache file, but not proxy header('Last-Modified: ' . $filetimeHeader); header('ETag: "' . $etag . '"'); header('Expires: ' . $expireHeader); header('Cache-Control: max-age=' . $expireOffset . ', s-maxage=0, proxy-revalidate'); // if this file is already in the user’s cache, don’t resend it // first check if the if_modified_since param matches if ($if_modified_since === $filetimeHeader) { // then check if the etag matches if ($if_none_match === $etag) { http_response_code(304); return; } } // send headers for the image header('Content-Type: ' . $mimetype); header('Content-Disposition: filename="' . basename($cache_filename) . '"'); header('Content-Length: ' . $filesize); // Some servers disable fpassthru() and readfile() if (function_exists('readfile')) { readfile($cache_filename); } else { $fp = fopen($cache_filename, 'rb'); if (function_exists('fpassthru')) { fpassthru($fp); } else { while (!feof($fp)) { echo fread($fp, 65536); } } fclose($fp); } break; case 'show_pdf': $template = new PdfTemplate(); return $template->pageBody(); case 'pdf_data': $template = new PdfTemplate(); return $template->pageData(); case 'pdf_thumb_data': $xref = Filter::get('mid'); $mediaobject = Media::getInstance($xref, $this->tree); $thumb = Filter::get('thumb'); if ($thumb === '2') { // Fancy thumb echo $this->module()->cacheFileName($mediaobject); } else { echo $mediaobject->getServerFilename('thumb'); } break; default: http_response_code(404); break; } }