Add warning message.

pull/2487/head
jmontoyaa 7 years ago
parent 975944f2b9
commit cbf3716b1f
  1. 3
      plugin/nosearchindex/lang/english.php
  2. 31
      plugin/nosearchindex/plugin.php

@ -5,5 +5,4 @@ $strings['plugin_comment'] = "Hide portal from search engine bots.";
$strings['tool_enable'] = 'Enable plugin'; $strings['tool_enable'] = 'Enable plugin';
$strings['CheckTheWritingPermissionsOfRobotsFile'] = 'The plugin needs to create/edit some files: /robots.txt, /robots.dist.txt, /app/home/header_extra_content.txt check your file permissions.'; $strings['CheckTheWritingPermissionsOfRobotsFile'] = 'The plugin needs to create/edit some files: /robots.txt, /robots.dist.txt, /app/home/header_extra_content.txt check your file permissions.';
$strings['CheckDirectoryPermissionsInX'] = 'Check write and read permissions in the path %s ';

@ -13,22 +13,33 @@ $isPlatformAdmin = api_is_platform_admin();
$editFile = false; $editFile = false;
$file = api_get_path(SYS_PATH).'robots.txt'; $file = api_get_path(SYS_PATH).'robots.txt';
$originalFile = api_get_path(SYS_PATH).'robots.dist.txt';
$extraContentFile = api_get_home_path().'header_extra_content.txt';
if ($isPlatformAdmin) { if ($isPlatformAdmin) {
$originalFile = api_get_path(SYS_PATH).'robots.dist.txt';
$extraContentFile = api_get_home_path().'header_extra_content.txt';
if (!file_exists($originalFile)) {
copy($file, $originalFile);
}
if (!file_exists($extraContentFile)) {
file_put_contents($extraContentFile, '');
}
$originalContent = file_get_contents($originalFile);
/** @var FormValidator $form */ /** @var FormValidator $form */
$form = $plugin_info['settings_form']; $form = $plugin_info['settings_form'];
if ($form && $form->validate()) { if ($form && $form->validate()) {
if (is_writable(api_get_path(SYS_PATH))) {
if (!file_exists($originalFile)) {
copy($file, $originalFile);
}
} else {
Display::addFlash(
Display::return_message(
sprintf(
$plugin->get_lang('CheckDirectoryPermissionsInX'),
api_get_path(SYS_PATH)
)
)
);
}
if (!file_exists($extraContentFile) && is_writable($extraContentFile)) {
file_put_contents($extraContentFile, '');
}
$values = $form->getSubmitValues(); $values = $form->getSubmitValues();
$continue = false; $continue = false;
if (is_readable($file) && is_writable($file) && if (is_readable($file) && is_writable($file) &&

Loading…
Cancel
Save