Initial import
authordmitry <dmitry@735d13b6-9817-0410-8766-e36946ffe9aa>
Thu, 15 Nov 2007 10:49:42 +0000 (10:49 +0000)
committerdmitry <dmitry@735d13b6-9817-0410-8766-e36946ffe9aa>
Thu, 15 Nov 2007 10:49:42 +0000 (10:49 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/comments_ic/trunk@7238 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog [new file with mode: 0644]
class.tx_commentsic_hooks.php [new file with mode: 0644]
ext_emconf.php [new file with mode: 0644]
ext_icon.gif [new file with mode: 0644]
ext_localconf.php [new file with mode: 0644]
ext_tables.php [new file with mode: 0644]
ext_tables.sql [new file with mode: 0644]
locallang_db.xml [new file with mode: 0644]

diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..4419659
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,3 @@
+2007-11-15 Dmitry Dulepov  <dmitry@typo3.org>
+
+       * Created
diff --git a/class.tx_commentsic_hooks.php b/class.tx_commentsic_hooks.php
new file mode 100644 (file)
index 0000000..df7ebc2
--- /dev/null
@@ -0,0 +1,96 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2007 Dmitry Dulepov (dmitry@typo3.org)
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+/**
+* class.tx_commentsic_hooks.php
+*
+* Commenting system hooks.
+*
+* $Id: $
+*
+* @author Dmitry Dulepov <dmitry@typo3.org>
+*/
+/**
+ * [CLASS/FUNCTION INDEX of SCRIPT]
+ */
+
+/**
+ * Commenting system hooks. Each hook receives the following in <code>$params</code>:
+ * <ul>
+ *     <li><code>uid</code> - uid of the item</li>
+ * </ul>
+ * Each hook returns time when commenting should be stopped. Thus 0 disables commenting and
+ * <code>PHP_INT_MAX</code> means there is no limit.
+ *
+ * @author Dmitry Dulepov <dmitry@typo3.org>
+ *
+ */
+class tx_commentsic_hooks {
+       /**
+        * Provides comment closing date to comments extension for tt_news items
+        *
+        * @param       array   $params Parameters to the function
+        * @param       tx_comments_pi1 $pObj   Parent object
+        */
+       function ttNewsHook(&$params, &$pObj) {
+               return $this->getCloseTime('tt_news', $params['uid'], $pObj->cObj);
+       }
+
+       /**
+        * Provides comment closing date to comments extension for commerce products
+        *
+        * @param       array   $params Parameters to the function
+        * @param       tx_comments_pi1 $pObj   Parent object
+        */
+       function commerceProductHook(&$params, &$pObj) {
+               return $this->getCloseTime('tx_commerce_products', $params['uid'], $pObj->cObj);
+       }
+
+       /**
+        * Gets closing time from a record
+        *
+        * @param       string  $table  Table name
+        * @param       int     $uid    UID of the record
+        * @param       tslib_cObj      $cObj   COBJECT
+        * @return      int     Closing timestamp
+        */
+       private function getCloseTime($table, $uid, &$cObj) {
+               $result = 0;
+               $recs = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('tx_commentsic_disable,tx_commentsic_closetime',
+                                       $table, 'uid=' . intval($uid) . $cObj->enableFields($table));
+               if (count($recs)) {
+                       $result = $recs[0]['tx_commentsic_disable'] ? 0 :
+                                                       ($recs[0]['tx_commentsic_closetime'] ? $recs[0]['tx_commentsic_closetime'] : PHP_INT_MAX);
+               }
+               return $result;
+       }
+}
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/comments_ic/class.tx_commentsic_hooks.php']) {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/comments_ic/class.tx_commentsic_hooks.php']);
+}
+
+?>
\ No newline at end of file
diff --git a/ext_emconf.php b/ext_emconf.php
new file mode 100644 (file)
index 0000000..f39512b
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+
+########################################################################
+# Extension Manager/Repository config file for ext: "comments_ic"
+#
+# Auto generated 15-11-2007 11:34
+#
+# Manual updates:
+# Only the data in the array - anything else is removed by next write.
+# "version" and "dependencies" must not be touched!
+########################################################################
+
+$EM_CONF[$_EXTKEY] = array(
+       'title' => 'Comments: individual closing',
+       'description' => 'Adds individual closing of comments for some records',
+       'category' => 'fe',
+       'author' => 'Dmitry Dulepov',
+       'author_email' => 'dmitry@typo3.org',
+       'shy' => '',
+       'dependencies' => '',
+       'conflicts' => '',
+       'priority' => '',
+       'module' => '',
+       'state' => 'beta',
+       'internal' => '',
+       'uploadfolder' => 0,
+       'createDirs' => '',
+       'modify_tables' => 'tt_news,tx_commerce_products',
+       'clearCacheOnLoad' => 0,
+       'lockType' => '',
+       'author_company' => '',
+       'version' => '0.1.0',
+       'constraints' => array(
+               'depends' => array(
+                       'php' => '5.0.0-',
+               ),
+               'conflicts' => array(
+               ),
+               'suggests' => array(
+                       'tt_news' => '',
+                       'comments' => '',
+               ),
+       ),
+       '_md5_values_when_last_written' => 'a:8:{s:9:"ChangeLog";s:4:"0a42";s:10:"README.txt";s:4:"ee2d";s:12:"ext_icon.gif";s:4:"1bdc";s:14:"ext_tables.php";s:4:"25aa";s:14:"ext_tables.sql";s:4:"da71";s:16:"locallang_db.xml";s:4:"68e3";s:19:"doc/wizard_form.dat";s:4:"2e0d";s:20:"doc/wizard_form.html";s:4:"fba8";}',
+);
+
+?>
\ No newline at end of file
diff --git a/ext_icon.gif b/ext_icon.gif
new file mode 100644 (file)
index 0000000..7b39be4
Binary files /dev/null and b/ext_icon.gif differ
diff --git a/ext_localconf.php b/ext_localconf.php
new file mode 100644 (file)
index 0000000..19b269c
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+/* $Id: $ */
+
+if (!defined ('TYPO3_MODE')) die('Access denied.');
+
+// Hook to comments for comments closing
+$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['comments/pi1/class.tx_comments_pi1.php']['tx_ttnews'] = 'EXT:comments_ic/class.tx_commentsic_hooks.php:tx_commentsic_hooks->ttNewsHook';
+$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['comments/pi1/class.tx_comments_pi1.php']['tx_commerce_products'] = 'EXT:comments_ic/class.tx_commentsic_hooks.php:tx_commentsic_hooks->commerceProductHook';
+?>
\ No newline at end of file
diff --git a/ext_tables.php b/ext_tables.php
new file mode 100644 (file)
index 0000000..d6bd1c2
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+if (!defined ('TYPO3_MODE'))   die ('Access denied.');
+
+// New columns
+$tempColumns = array (
+       'tx_commentsic_disable' => Array (
+               'exclude' => 1,
+               'label' => 'LLL:EXT:comments_ic/locallang_db.xml:tx_commentsic_disable',
+               'config' => array (
+                       'type'     => 'check',
+                       'items'    => array(
+                               array('', '')
+                       ),
+                       'default'  => '0'
+               )
+       ),
+       'tx_commentsic_closetime' => Array (
+               'exclude' => 1,
+               'label' => 'LLL:EXT:comments_ic/locallang_db.xml:tx_commentsic_closetime',
+               'displayCond' => 'FIELD:tx_commentsic_disable:=:0',
+               'config' => array (
+                       'type'     => 'input',
+                       'size'     => '12',
+                       'max'      => '20',
+                       'eval'     => 'datetime',
+                       'checkbox' => '0',
+                       'default'  => PHP_INT_MAX,
+               )
+       ),
+);
+
+// tt_news
+if (isset($TCA['tt_news'])) {
+       t3lib_div::loadTCA('tt_news');
+       t3lib_extMgm::addTCAcolumns('tt_news', $tempColumns, 1);
+       t3lib_extMgm::addToAllTCAtypes('tt_news', 'tx_commentsic_disable;;;;1-1-1, tx_commentsic_closetime');
+       $TCA['tt_news']['ctrl']['requestUpdate'] = ',tx_commentsic_disable';
+}
+
+// tx_commerce_products
+if (isset($TCA['tx_commerce_products'])) {
+       t3lib_div::loadTCA('tx_commerce_products');
+       t3lib_extMgm::addTCAcolumns('tx_commerce_products', $tempColumns, 1);
+       t3lib_extMgm::addToAllTCAtypes('tx_commerce_products', 'tx_commentsic_disable;;;;1-1-1, tx_commentsic_closetime');
+       $TCA['tx_commerce_products']['ctrl']['requestUpdate'] = ',tx_commentsic_disable';
+}
+?>
\ No newline at end of file
diff --git a/ext_tables.sql b/ext_tables.sql
new file mode 100644 (file)
index 0000000..f490a34
--- /dev/null
@@ -0,0 +1,15 @@
+#
+# Table structure for table 'tt_news'
+#
+CREATE TABLE tt_news (
+       tx_commentsic_disable int(1) DEFAULT '0' NOT NULL,
+       tx_commentsic_closetime int(11) DEFAULT '0' NOT NULL
+);
+
+#
+# Table structure for table 'tx_commerce_products'
+#
+CREATE TABLE tx_commerce_products (
+       tx_commentsic_disable int(1) DEFAULT '0' NOT NULL,
+       tx_commentsic_closetime int(11) DEFAULT '0' NOT NULL
+);
diff --git a/locallang_db.xml b/locallang_db.xml
new file mode 100644 (file)
index 0000000..2b7f53a
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+       <meta type="array">
+               <type>database</type>
+               <description>Language labels for database tables/fields belonging to extension 'comments_ic'</description>
+       </meta>
+       <data type="array">
+               <languageKey index="default" type="array">
+                       <label index="tx_commentsic_disable">Disable comments:</label>
+                       <label index="tx_commentsic_closetime">Close comments at:</label>
+               </languageKey>
+       </data>
+</T3locallang>
\ No newline at end of file