Changeset 1652
- Timestamp:
- 05/25/2007 09:27:40 PM (20 months ago)
- Files:
-
- 1 modified
-
trunk/plugins/CommentCloser.jplug.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/CommentCloser.jplug.php
r1651 r1652 23 23 $lifeTime = defined('COMMENT_CLOSER_LIFETIME') ? 24 24 COMMENT_CLOSER_LIFETIME : ''; 25 $timeUnit = defined('COMMENT_CLOSER_TIMEUNIT') ? 26 COMMENT_CLOSER_TIMEUNIT : ''; 25 27 $self = htmlspecialchars($_SERVER['REQUEST_URI']); 26 28 27 29 if (array_key_exists('commclose_do', $_POST)) { 28 $lifeTime = $_POST['commclose_lifetime'] * 29 $_POST['commclose_unit']; 30 $lifeTime = $_POST['commclose_lifetime']; 31 $timeUnit = $_POST['commclose_unit']; 32 30 33 // keine negative Zeiten 31 34 if ($lifeTime < 0) 32 35 $lifeTime = 0; 36 37 # XXX MySQL bug: WEEK wird bei mir nicht 38 # erkannt, deshalb manuelles Umrechnen: 39 if ($timeUnit == 'WEEK') { 40 $lifeTime *= 7; 41 $timeUnit = 'DAY'; 42 } 33 43 34 44 $mask = umask(0); … … 39 49 @fwrite($f, 'define(\'COMMENT_CLOSER_'. 40 50 "LIFETIME', $lifeTime);\n"); 51 @fwrite($f, 'define(\'COMMENT_CLOSER_'. 52 "TIMEUNIT', $timeUnit);\n"); 41 53 @fwrite($f, '?>'); 42 54 @fclose($f); … … 51 63 <input type="text" name="commclose_lifetime" size="5" value="$lifeTime" /> 52 64 <select name="commclose_unit" size="1"> 53 <option value=" 1">Sekunden</option>54 <option value=" 60">Minuten</option>55 <option value=" 3600">Stunden</option>56 <option value=" 86400">Tagen</option>57 <option value=" 604800">Wochen</option>58 <option value=" 2592000">Monaten</option>59 <option value=" 31536000">Jahren</option>65 <option value="SECOND">Sekunden</option> 66 <option value="MINUTE">Minuten</option> 67 <option value="HOUR">Stunden</option> 68 <option value="DAY">Tagen</option> 69 <option value="WEEK">Wochen</option> 70 <option value="MONTH">Monaten</option> 71 <option value="YEAR">Jahren</option> 60 72 </select> 61 73 automatisch … … 68 80 // Pruefen auf zu schliessende Beitraege 69 81 function hook_onUpdate($data) { 70 if (! defined('COMMENT_CLOSER_LIFETIME') || 71 COMMENT_CLOSER_LIFETIME == 0) 82 if (!defined('COMMENT_CLOSER_LIFETIME') || 83 COMMENT_CLOSER_LIFETIME == 0 || 84 !defined('COMMENT_CLOSER_TIMEUNIT')) 72 85 { 73 86 return $data; 74 87 } 75 88 76 # TODO77 89 $q = new Query('UPDATE kolumne_content SET comments=0 ' . 78 'WHERE UNIX_TIMESTAMP(date) < ' . 79 'UNIX_TIMESTAMP(NOW()) - ' . 90 'WHERE date < DATE_SUB(NOW(), INTERVAL ' . 80 91 COMMENT_CLOSER_LIFETIME . 81 ' AND comments=1'); 92 COMMENT_CLOSER_TIMEUNIT . 93 ') AND comments=1'); 94 # TODO error handling 82 95 83 96 return $data;
