From c2581d945a4e7db192298436f6a5b1c6a523deb6 Mon Sep 17 00:00:00 2001 From: Garvin Hicking Date: Thu, 2 Feb 2012 19:54:52 +0100 Subject: [PATCH] upstream patch by gregor voeltz --- .../UTF-8/lang_de.inc.php | 7 ++- .../UTF-8/lang_fr.inc.php | 6 +++ serendipity_event_entrycheck/lang_de.inc.php | 6 +++ serendipity_event_entrycheck/lang_en.inc.php | 6 +++ serendipity_event_entrycheck/lang_fr.inc.php | 6 +++ .../serendipity_event_entrycheck.php | 49 +++++++++++++++++-- 6 files changed, 74 insertions(+), 6 deletions(-) mode change 100755 => 100644 serendipity_event_entrycheck/serendipity_event_entrycheck.php diff --git a/serendipity_event_entrycheck/UTF-8/lang_de.inc.php b/serendipity_event_entrycheck/UTF-8/lang_de.inc.php index 38642df6..5ad5db5f 100644 --- a/serendipity_event_entrycheck/UTF-8/lang_de.inc.php +++ b/serendipity_event_entrycheck/UTF-8/lang_de.inc.php @@ -8,7 +8,12 @@ @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE', 'Leeren Titel verhindern?'); @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE_DESC', 'Wenn auf "ja" gesetzt, muss ein Artikel einen Titel besitzten.'); @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE_WARNING', 'Es ist nicht erlaubt einen Eintrag ohne Titel zu veröffentlichen. Bitte einen Titel eintragen und erneut speichern!'); - @define('PLUGIN_EVENT_ENTRYCHECK_DEFAULTCAT', 'Standardkategorie definieren'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY', 'Leeren Eintrag verhindern?'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY_DESC', 'Wenn auf "ja" gesetzt, muss ein Artikel Text im Feld "Eintrag" enthalten.'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY_WARNING', 'Es ist nicht erlaubt einen Artikel mit leerem "Eintrag" zu veröffentlichen. Bitte einen Text in das Feld "Eintrag" eingeben und erneut speichern!'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED', 'Leeren erweiterten Eintrag verhindern?'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED_DESC', 'Wenn auf "ja" gesetzt, muss ein Artikel Text im Feld "Erweiterter Eintrag" enthalten.'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED_WARNING', 'Es ist nicht erlaubt einen Eintrag mit leerem "Erweiterter Eintrag" zu veröffentlichen. Bitte einen Text in das Feld "Erweiterter Eintrag" eingeben und erneut speichern!'); @define('PLUGIN_EVENT_ENTRYCHECK_DEFAULTCAT', 'Standardkategorie definieren'); @define('PLUGIN_EVENT_ENTRYCHECK_DEFAULTCAT_DESC', 'Falls der Benutzer eine Kategorie leergelassen hat, kann der Eintrag automatisch dieser angegebenen Kategorie zugewiesen werden.'); @define('PLUGIN_EVENT_ENTRYCHECK_LOCKED', 'Dieser Artikel wurde vom Autoren %s am %s gesperrt'); diff --git a/serendipity_event_entrycheck/UTF-8/lang_fr.inc.php b/serendipity_event_entrycheck/UTF-8/lang_fr.inc.php index bd737ba7..2e58aa53 100644 --- a/serendipity_event_entrycheck/UTF-8/lang_fr.inc.php +++ b/serendipity_event_entrycheck/UTF-8/lang_fr.inc.php @@ -8,6 +8,12 @@ @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE', 'Ne pas autoriser les titres vides ?'); @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE_DESC', 'Si la valeur "oui" est sélectionnée, un billet ne pourra pas avoir un titre vide.'); @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE_WARNING', 'Il n\'est pas autorisé de publier un billet dont le titre est vide. Merci de saisir un titre pour ce billet et de l\'enregistrer à nouveau !'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY', 'Ne pas autoriser les introduction vides ?'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY_DESC', 'Si la valeur "oui" est sélectionnée, un billet ne pourra pas avoir un introduction vide.'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY_WARNING', 'Il n\'est pas autorisé de publier un billet dont le introduction est vide. Merci de saisir un introduction pour ce billet et de l\'enregistrer à nouveau !'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED', 'Ne pas autoriser les corps du billet vides ?'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED_DESC', 'Si la valeur "oui" est sélectionnée, un billet ne pourra pas avoir un corps du billet vide.'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED_WARNING', 'Il n\'est pas autorisé de publier un billet dont le corps du billet est vide. Merci de saisir un corps du billet pour ce billet et de l\'enregistrer à nouveau !'); @define('PLUGIN_EVENT_ENTRYCHECK_DEFAULTCAT', 'Définir une catégorie par défaut'); @define('PLUGIN_EVENT_ENTRYCHECK_DEFAULTCAT_DESC', 'Vous pouvez sélectionner ici la catégorie qui sera affectée par défaut aux billets si l\'auteur n\'en spécifie pas.'); diff --git a/serendipity_event_entrycheck/lang_de.inc.php b/serendipity_event_entrycheck/lang_de.inc.php index 08b12622..fbc428d1 100644 --- a/serendipity_event_entrycheck/lang_de.inc.php +++ b/serendipity_event_entrycheck/lang_de.inc.php @@ -8,6 +8,12 @@ @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE', 'Leeren Titel verhindern?'); @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE_DESC', 'Wenn auf "ja" gesetzt, muss ein Artikel einen Titel besitzten.'); @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE_WARNING', 'Es ist nicht erlaubt einen Eintrag ohne Titel zu veröffentlichen. Bitte einen Titel eintragen und erneut speichern!'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY', 'Leeren Eintrag verhindern?'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY_DESC', 'Wenn auf "ja" gesetzt, muss ein Artikel Text im Feld "Eintrag" enthalten.'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY_WARNING', 'Es ist nicht erlaubt einen Artikel mit leerem "Eintrag" zu veröffentlichen. Bitte einen Text in das Feld "Eintrag" eingeben und erneut speichern!'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED', 'Leeren erweiterten Eintrag verhindern?'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED_DESC', 'Wenn auf "ja" gesetzt, muss ein Artikel Text im Feld "Erweiterter Eintrag" enthalten.'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED_WARNING', 'Es ist nicht erlaubt einen Eintrag mit leerem "Erweiterter Eintrag" zu veröffentlichen. Bitte einen Text in das Feld "Erweiterter Eintrag" eingeben und erneut speichern!'); @define('PLUGIN_EVENT_ENTRYCHECK_DEFAULTCAT', 'Standardkategorie definieren'); @define('PLUGIN_EVENT_ENTRYCHECK_DEFAULTCAT_DESC', 'Falls der Benutzer eine Kategorie leergelassen hat, kann der Eintrag automatisch dieser angegebenen Kategorie zugewiesen werden.'); diff --git a/serendipity_event_entrycheck/lang_en.inc.php b/serendipity_event_entrycheck/lang_en.inc.php index b5eefb0f..ec14665c 100644 --- a/serendipity_event_entrycheck/lang_en.inc.php +++ b/serendipity_event_entrycheck/lang_en.inc.php @@ -14,6 +14,12 @@ @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE', 'Do not allow empty titles'); @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE_DESC', 'If set to "true", an entry must not have an empty title.'); @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE_WARNING', 'It is not allowed to publish an entry without assigning a title. Please enter a title for the entry and save again!'); +@define('PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY', 'Do not allow empty entry bodies'); +@define('PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY_DESC', 'If set to "true", an entry must not have an empty entry body.'); +@define('PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY_WARNING', 'It is not allowed to publish an entry without entry body. Please enter text into the entry body and save again!'); +@define('PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED', 'Do not allow empty extended bodies'); +@define('PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED_DESC', 'If set to "true", an entry must not have an empty extended body.'); +@define('PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED_WARNING', 'It is not allowed to publish an entry without extended body. Please enter text into the extended body and save again!'); @define('PLUGIN_EVENT_ENTRYCHECK_DEFAULTCAT', 'Set a default category'); @define('PLUGIN_EVENT_ENTRYCHECK_DEFAULTCAT_DESC', 'If the user left the category association empty, you can set the used default category here.'); diff --git a/serendipity_event_entrycheck/lang_fr.inc.php b/serendipity_event_entrycheck/lang_fr.inc.php index bc2bb3e8..9e239e1e 100644 --- a/serendipity_event_entrycheck/lang_fr.inc.php +++ b/serendipity_event_entrycheck/lang_fr.inc.php @@ -8,6 +8,12 @@ @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE', 'Ne pas autoriser les titres vides ?'); @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE_DESC', 'Si la valeur "oui" est sélectionnée, un billet ne pourra pas avoir un titre vide.'); @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE_WARNING', 'Il n\'est pas autorisé de publier un billet dont le titre est vide. Merci de saisir un titre pour ce billet et de l\'enregistrer à nouveau !'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY', 'Ne pas autoriser les introduction vides ?'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY_DESC', 'Si la valeur "oui" est sélectionnée, un billet ne pourra pas avoir un introduction vide.'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY_WARNING', 'Il n\'est pas autorisé de publier un billet dont le introduction est vide. Merci de saisir un introduction pour ce billet et de l\'enregistrer à nouveau !'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED', 'Ne pas autoriser les corps du billet vides ?'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED_DESC', 'Si la valeur "oui" est sélectionnée, un billet ne pourra pas avoir un corps du billet vide.'); + @define('PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED_WARNING', 'Il n\'est pas autorisé de publier un billet dont le corps du billet est vide. Merci de saisir un corps du billet pour ce billet et de l\'enregistrer à nouveau !'); @define('PLUGIN_EVENT_ENTRYCHECK_DEFAULTCAT', 'Définir une catégorie par défaut'); @define('PLUGIN_EVENT_ENTRYCHECK_DEFAULTCAT_DESC', 'Vous pouvez sélectionner ici la catégorie qui sera affectée par défaut aux billets si l\'auteur n\'en spécifie pas.'); diff --git a/serendipity_event_entrycheck/serendipity_event_entrycheck.php b/serendipity_event_entrycheck/serendipity_event_entrycheck.php old mode 100755 new mode 100644 index 15869f47..51cf2ab0 --- a/serendipity_event_entrycheck/serendipity_event_entrycheck.php +++ b/serendipity_event_entrycheck/serendipity_event_entrycheck.php @@ -24,8 +24,8 @@ class serendipity_event_entrycheck extends serendipity_event $propbag->add('name', PLUGIN_EVENT_ENTRYCHECK_TITLE); $propbag->add('description', PLUGIN_EVENT_ENTRYCHECK_DESC); $propbag->add('stackable', false); - $propbag->add('author', 'Garvin Hicking'); - $propbag->add('version', '1.12'); + $propbag->add('author', 'Garvin Hicking, Gregor Voeltz'); + $propbag->add('version', '1.13'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', @@ -38,7 +38,7 @@ class serendipity_event_entrycheck extends serendipity_event 'css_backend' => true )); $propbag->add('groups', array('BACKEND_EDITOR')); - $propbag->add('configuration', array('emptyCategories', 'emptyTitle', 'defaultCat', 'locking')); + $propbag->add('configuration', array('emptyCategories', 'emptyTitle', 'emptyBody', 'emptyExtended', 'defaultCat', 'locking')); } function introspect_config_item($name, &$propbag) @@ -65,6 +65,20 @@ class serendipity_event_entrycheck extends serendipity_event $propbag->add('default', true); break; + case 'emptyBody': + $propbag->add('type', 'boolean'); + $propbag->add('name', PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY); + $propbag->add('description', PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY_DESC); + $propbag->add('default', true); + break; + + case 'emptyExtended': + $propbag->add('type', 'boolean'); + $propbag->add('name', PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED); + $propbag->add('description', PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED_DESC); + $propbag->add('default', true); + break; + case 'defaultCat': $cats = serendipity_fetchCategories($serendipity['authorid']); if (!is_array($cats)) { @@ -162,14 +176,22 @@ class serendipity_event_entrycheck extends serendipity_event break; case 'backend_entry_updertEntry': - if (!serendipity_db_bool($this->get_config('emptyCategories')) && count($addData['categories']) == 1 && $addData['categories'][0] == '0') { + if (serendipity_db_bool($this->get_config('emptyCategories') == true) && count($addData['categories']) < 1 || $addData['categories'][0] == '0') { $eventData[] = PLUGIN_EVENT_ENTRYCHECK_EMPTYCATEGORIES_WARNING; } - if (!serendipity_db_bool($this->get_config('emptyTitle')) && strlen($addData['title']) < 1) { + if (serendipity_db_bool($this->get_config('emptyTitle') == true) && strlen($addData['title']) < 1) { $eventData[] = PLUGIN_EVENT_ENTRYCHECK_EMPTYTITLE_WARNING; } + if (serendipity_db_bool($this->get_config('emptyBody') == true) && strlen($addData['body']) < 1) { + $eventData[] = PLUGIN_EVENT_ENTRYCHECK_EMPTYBODY_WARNING; + } + + if (serendipity_db_bool($this->get_config('emptyExtended') == true) && strlen($addData['extended']) < 1) { + $eventData[] = PLUGIN_EVENT_ENTRYCHECK_EMPTYEXTENDED_WARNING; + } + if ($addData['id'] > 0 && serendipity_db_bool($this->get_config('locking'))) { $state = 'unlocked'; if (!$this->checkLock($state, $addData['id'])) { @@ -221,10 +243,26 @@ class serendipity_event_entrycheck extends serendipity_event } } + get_config('emptyTitle')) == true) { ?> if (document.getElementById('entryTitle').value.length < 1) { alert(''); error = true; } + + + get_config('emptyBody')) == true) { ?> + if (document.getElementById('serendipity[body]').value.length < 1) { + alert(''); + error = true; + } + + + get_config('emptyExtended')) == true) { ?> + if (document.getElementById('serendipity[extended]').value.length < 1) { + alert(''); + error = true; + } + if (error) { return false; @@ -241,3 +279,4 @@ class serendipity_event_entrycheck extends serendipity_event } /* vim: set sts=4 ts=4 expandtab : */ +?> \ No newline at end of file