Added feature #15812: Add backend maintenance for login news
authorIngo Renner <ingo.renner@typo3.org>
Tue, 28 Sep 2010 09:54:47 +0000 (09:54 +0000)
committerIngo Renner <ingo.renner@typo3.org>
Tue, 28 Sep 2010 09:54:47 +0000 (09:54 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8916 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/stddb/tables.php
t3lib/stddb/tables.sql
t3lib/stddb/tbl_be.php
typo3/index.php
typo3/sysext/lang/locallang_csh_sysnews.xml [new file with mode: 0755]
typo3/sysext/lang/locallang_tca.xml
typo3/sysext/t3skin/images/icons/mimetypes/x-sys_news.png [new file with mode: 0644]

index 3c6d7b7..524deeb 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-09-28  Ingo Renner  <ingo@typo3.org>
+
+       * Added feature #15812: Add backend maintenance for login news
+
 2010-09-28  Ernesto Baschny  <ernst@cron-it.de>
 
        * Fixed bug #15829: ExtDirect wrong XCLASS registration code (Thanks to Stefan Galinski)
index 8a33c2b..002498c 100644 (file)
@@ -424,6 +424,35 @@ $TCA['sys_language'] = array(
 );
 
 
+/**
+ * Table "sys_news":
+ * Holds news records to be displayed in the login screen
+ * This is only the 'header' part (ctrl). The full configuration is found
+ * in t3lib/stddb/tbl_be.php
+ */
+$TCA['sys_news'] = array(
+       'ctrl' => array(
+               'title'             => 'LLL:EXT:lang/locallang_tca.xml:sys_news',
+               'label'             => 'title',
+               'tstamp'            => 'tstamp',
+               'crdate'            => 'crdate',
+               'cruser_id'         => 'cruser_id',
+               'adminOnly'         => TRUE,
+               'rootLevel'         => TRUE,
+               'delete'            => 'deleted',
+               'enablecolumns'     => array(
+                       'disabled'  => 'hidden',
+                       'starttime' => 'starttime',
+                       'endtime'   => 'endtime'
+               ),
+               'default_sortby'    => 'crdate DESC',
+               'typeicon_classes'  => array(
+                       'default' => 'mimetypes-x-sys_news',
+               ),
+               'dynamicConfigFile' => 'T3LIB:tbl_be.php',
+               'dividers2tabs'     => TRUE
+       )
+);
 
 
 
@@ -471,6 +500,7 @@ t3lib_extMgm::addLLrefForTCAdescr('be_users','EXT:lang/locallang_csh_be_users.xm
 t3lib_extMgm::addLLrefForTCAdescr('be_groups','EXT:lang/locallang_csh_be_groups.xml');
 t3lib_extMgm::addLLrefForTCAdescr('sys_filemounts','EXT:lang/locallang_csh_sysfilem.xml');
 t3lib_extMgm::addLLrefForTCAdescr('sys_language','EXT:lang/locallang_csh_syslang.xml');
+t3lib_extMgm::addLLrefForTCAdescr('sys_news','EXT:lang/locallang_csh_sysnews.xml');
 t3lib_extMgm::addLLrefForTCAdescr('sys_workspace','EXT:lang/locallang_csh_sysws.xml');
 t3lib_extMgm::addLLrefForTCAdescr('xMOD_csh_corebe','EXT:lang/locallang_csh_corebe.xml');      // General Core
 t3lib_extMgm::addLLrefForTCAdescr('_MOD_tools_em','EXT:lang/locallang_csh_em.xml');            // Extension manager
index 50e5ead..4a97891 100644 (file)
@@ -243,6 +243,27 @@ CREATE TABLE sys_be_shortcuts (
 
 
 #
+# Table structure for table 'sys_news'
+#
+CREATE TABLE sys_news (
+  uid int(11) unsigned NOT NULL auto_increment,
+  pid int(11) unsigned DEFAULT '0' NOT NULL,
+  tstamp int(11) unsigned DEFAULT '0' NOT NULL,
+  crdate int(11) unsigned DEFAULT '0' NOT NULL,
+  cruser_id int(11) unsigned DEFAULT '0' NOT NULL,
+  deleted tinyint(3) unsigned DEFAULT '0' NOT NULL,
+  hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
+  starttime int(11) unsigned DEFAULT '0' NOT NULL,
+  endtime int(11) unsigned DEFAULT '0' NOT NULL,
+  title varchar(255) DEFAULT '' NOT NULL,
+  content mediumtext,
+
+  PRIMARY KEY (uid),
+  KEY parent (pid)
+);
+
+
+#
 # Table structure for table 'sys_preview'
 #
 CREATE TABLE sys_preview (
index 40ebafa..37b53f7 100644 (file)
@@ -820,4 +820,74 @@ $TCA['sys_language'] = array(
        )
 );
 
+
+
+
+/**
+ * System News (displayed on Login screen)
+ */
+$TCA['sys_news'] = array(
+       'ctrl' => $TCA['sys_news']['ctrl'],
+       'interface' => array(
+               'showRecordFieldList' => 'hidden,title,content,starttime,endtime'
+       ),
+       'columns' => array(
+               'hidden' => array(
+                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.disable',
+                       'exclude' => 1,
+                       'config' => array(
+                               'type' => 'check',
+                               'default' => '0'
+                       )
+               ),
+               'starttime' => array(
+                       'exclude' => 1,
+                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.starttime',
+                       'config' => array(
+                               'type' => 'input',
+                               'size' => '8',
+                               'max' => '20',
+                               'eval' => 'date',
+                               'checkbox' => '0',
+                               'default' => '0'
+                       )
+               ),
+               'endtime' => array(
+                       'exclude' => 1,
+                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.endtime',
+                       'config' => array(
+                               'type' => 'input',
+                               'size' => '8',
+                               'max' => '20',
+                               'eval' => 'date',
+                               'checkbox' => '0',
+                               'default' => '0'
+                       )
+               ),
+               'title' => array(
+                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.title',
+                       'config' => array(
+                               'type' => 'input',
+                               'size' => '30',
+                               'max' => '255',
+                               'eval' => 'required'
+                       )
+               ),
+               'content' => array(
+                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.text',
+                       'config' => array(
+                               'type' => 'text',
+                               'cols' => '48',
+                               'rows' => '5'
+                       )
+               )
+       ),
+       'types' => array(
+               '1' => array('showitem' => '
+                       hidden, title, content,
+                       --div--;LLL:EXT:lang/locallang_tca.xml:sys_news.tabs.access, starttime, endtime'
+               )
+       )
+);
+
 ?>
\ No newline at end of file
index 2d36d1f..5874ac9 100644 (file)
@@ -560,6 +560,19 @@ class SC_index {
        function makeLoginNews() {
                $newsContent = '';
 
+               $systemNews = $this->getSystemNews();
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'])) {
+                       /** @deprecated since 4.5. Use system news records instead. */
+                       t3lib_div::logDeprecatedFunction();
+
+                       $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] = array_merge(
+                               $systemNews,
+                               $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews']
+                       );
+               } else {
+                       $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] = $systemNews;
+               }
+
                        // Traverse news array IF there are records in it:
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews']) && count($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews']) && !t3lib_div::_GP('loginRefresh')) {
 
@@ -579,8 +592,8 @@ class SC_index {
                                $newsItemMarker = array(
                                        '###HEADER###'  => htmlspecialchars($newsItem['header']),
                                        '###DATE###'    => htmlspecialchars($newsItem['date']),
-                                       '###CONTENT###' => trim($newsItem['content']),
-                                       '###CLASS###'   => $additionalClass
+                                       '###CONTENT###' => nl2br(htmlspecialchars(trim($newsItem['content']))),
+                                       '###CLASS###'   => $additionalClass
                                );
 
                                $count++;
@@ -597,6 +610,40 @@ class SC_index {
        }
 
        /**
+        * Gets news from sys_news and converts them into a format suitable for
+        * showing them at the login screen.
+        *
+        * @return      array   An array of login news.
+        */
+       protected function getSystemNews() {
+               $systemNewsTable = 'sys_news';
+               $systemNews      = array();
+
+               $systemNewsRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                       'title, content, crdate',
+                       $systemNewsTable,
+                       '1=1' .
+                               t3lib_BEfunc::BEenableFields($systemNewsTable) .
+                               t3lib_BEfunc::deleteClause($systemNewsTable),
+                       '',
+                       'crdate DESC'
+               );
+
+               foreach ($systemNewsRecords as $systemNewsRecord) {
+                       $systemNews[] = array(
+                               'date'    => date(
+                                       $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],
+                                       $systemNewsRecord['crdate']
+                               ),
+                               'header'  => $systemNewsRecord['title'],
+                               'content' => $systemNewsRecord['content']
+                       );
+               }
+
+               return $systemNews;
+       }
+
+       /**
         * Returns the form tag
         *
         * @return      string          Opening form tag string
diff --git a/typo3/sysext/lang/locallang_csh_sysnews.xml b/typo3/sysext/lang/locallang_csh_sysnews.xml
new file mode 100755 (executable)
index 0000000..37f5ab5
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+       <meta type="array">
+               <description>CSH for System News table.</description>
+               <type>CSH</type>
+               <csh_table>sys_news</csh_table>
+       </meta>
+       <data type="array">
+               <languageKey index="default" type="array">
+                       <label index="hidden.description">This option will hide the news from showing up at the login screen.</label>
+                       <label index="title.description">Enter the title of the news.</label>
+                       <label index="content.description">The news content to let editors know what's coming up. HTML is disabled, however, you can use line breaks.</label>
+                       <label index=".description">System news are shown at the TYPO3 login screen, allowing admins to inform editors about upcoming system maintenance and similar events.</label>
+               </languageKey>
+       </data>
+</T3locallang>
\ No newline at end of file
index a123bce..132745a 100755 (executable)
@@ -72,6 +72,8 @@
                        <label index="sys_filemounts.base">Base:</label>
                        <label index="sys_filemounts.base_absolute">absolute (root) / </label>
                        <label index="sys_filemounts.base_relative">relative ../fileadmin/</label>
+                       <label index="sys_news">System News</label>
+                       <label index="sys_news.tabs.access">Access</label>
                        <label index="sys_workspace.adminusers">Owners:</label>
                        <label index="sys_workspace.members">Members:</label>
                        <label index="sys_workspace.reviewers">Reviewers:</label>
diff --git a/typo3/sysext/t3skin/images/icons/mimetypes/x-sys_news.png b/typo3/sysext/t3skin/images/icons/mimetypes/x-sys_news.png
new file mode 100644 (file)
index 0000000..9fc5a0a
Binary files /dev/null and b/typo3/sysext/t3skin/images/icons/mimetypes/x-sys_news.png differ