Changeset 833
- Timestamp:
- Aug 19, 2005, 3:54:40 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r825 r833 1293 1293 $tables = 1294 1294 array( 1295 USER_FEED_TABLE, 1295 1296 USER_INFOS_TABLE, 1296 1297 USER_ACCESS_TABLE, -
trunk/admin/maintenance.php
r809 r833 73 73 break; 74 74 } 75 case 'feeds' : 76 { 77 $query = ' 78 DELETE 79 FROM '.USER_FEED_TABLE.' 80 WHERE last_check IS NULL 81 ;'; 82 pwg_query($query); 83 break; 84 } 75 85 default : 76 86 { … … 92 102 'U_MAINT_IMAGES' => add_session_id($start_url.'images'), 93 103 'U_MAINT_HISTORY' => add_session_id($start_url.'history'), 94 'U_MAINT_SESSIONS' => add_session_id($start_url.'sessions') 104 'U_MAINT_SESSIONS' => add_session_id($start_url.'sessions'), 105 'U_MAINT_FEEDS' => add_session_id($start_url.'feeds'), 95 106 ) 96 107 ); -
trunk/category.php
r808 r833 305 305 )); 306 306 307 // notification feed307 // notification 308 308 $template->assign_block_vars( 309 309 'summary', 310 310 array( 311 'TITLE'=>l10n('RSS notification feed'), 312 'NAME'=>l10n('Notification feed'), 313 'U_SUMMARY'=> 314 'feed.php'.($user['is_the_guest'] ? '?feed='.$user['feed_id'] : '') 311 'TITLE'=>l10n('notification'), 312 'NAME'=>l10n('Notification'), 313 'U_SUMMARY'=>add_session_id(PHPWG_ROOT_PATH.'notification.php') 315 314 )); 316 315 -
trunk/doc/ChangeLog
r832 r833 1 2005-08-19 Pierrick LE GALL 2 3 * modification : RSS feed work only with a given feed 4 identifier. Thus we can avoid fixed frequency notification to 5 concentrate on variable frequency notification, which is much more 6 interesting. To do this, feeds have moved to a dedicated table 7 allowing each user (including guest user) to have more than on 8 feed. 9 1 10 2005-08-18 Pierrick LE GALL 2 11 -
trunk/feed.php
r808 r833 269 269 { 270 270 $query = ' 271 SELECT user_id AS id, 272 status, 273 last_feed_check 274 FROM '.USER_INFOS_TABLE.' 275 WHERE feed_id = \''.$_GET['feed'].'\' 271 SELECT uf.user_id AS id, 272 ui.status, 273 uf.last_check, 274 u.'.$conf['user_fields']['username'].' AS username 275 FROM '.USER_FEED_TABLE.' AS uf 276 INNER JOIN '.USER_INFOS_TABLE.' AS ui 277 ON ui.user_id = uf.user_id 278 INNER JOIN '.USERS_TABLE.' AS u 279 ON u.'.$conf['user_fields']['id'].' = uf.user_id 280 WHERE uf.id = \''.$_GET['feed'].'\' 276 281 ;'; 277 282 $user = mysql_fetch_array(pwg_query($query)); … … 279 284 else 280 285 { 281 $user = array('id' => $conf['guest_id'],282 'status' => 'guest');286 echo l10n('Unknown feed identifier'); 287 exit(); 283 288 } 284 289 … … 295 300 296 301 $rss = new UniversalFeedCreator(); 297 // $rss->useCached(); // use cached version if age<1 hour 298 $rss->title = 'PhpWebGallery notifications'; 299 $rss->link = 'http://phpwebgallery.net'; 302 303 $rss->title = $conf['gallery_title'].', notifications'; 304 $rss->title.= ' (as '.$user['username'].')'; 305 306 $rss->link = $conf['gallery_url']; 300 307 301 308 // +-----------------------------------------------------------------------+ … … 303 310 // +-----------------------------------------------------------------------+ 304 311 305 if ($conf['guest_id'] != $user['id']) 306 { 307 $news = news($user['last_feed_check'], $dbnow); 308 309 if (count($news) > 0) 310 { 311 // echo '<pre>'; 312 // print_r($news); 313 // echo '</pre>'; 314 315 $item = new FeedItem(); 316 $item->title = sprintf(l10n('New on %s'), $dbnow); 317 $item->link = 'http://phpwebgallery.net'; 318 319 // content creation 320 $item->description = '<ul>'; 321 foreach ($news as $line) 322 { 323 $item->description.= '<li>'.$line.'</li>'; 324 } 325 $item->description.= '</ul>'; 326 $item->descriptionHtmlSyndicated = true; 327 328 $item->date = $dbnow; 329 $item->author = 'PhpWebGallery notifier'; 330 331 $rss->addItem($item); 332 } 333 334 $query = ' 335 UPDATE '.USER_INFOS_TABLE.' 336 SET last_feed_check = \''.$dbnow.'\' 337 WHERE user_id = '.$user['id'].' 338 ;'; 339 pwg_query($query); 340 } 341 else 342 { 343 // The feed is filled with periodical blocks of informations. Date 344 // "checkpoints" cut the blocks. The first step is to find those 345 // checkpoints according to the configured feed period. 346 // 347 // checkpoints are first calculated in Unix timestamp (number of seconds 348 // since 1970-01-01 00:00:00 GMT) and then converted to MySQL datetime 349 // format. 350 351 $now = explode_mysqldt($dbnow); 352 353 $checkpoints = array(); 354 $checkpoints[0] = mysqldt_to_ts($dbnow); 355 356 // if the feed period was not configured the right way (ie among the list 357 // of possible values), the configuration is overloaded here. 358 if (!in_array($conf['feed_period'], 359 array('hour', 'half day', 'day', 'week', 'month'))) 360 { 361 $conf['feed_period'] = 'week'; 362 } 363 364 // foreach feed_period possible, we need to find the beginning of the 365 // current period. The variable $timeshift contains the shift to apply to 366 // each checkpoint to find the previous one with strtotime function 367 switch ($conf['feed_period']) 368 { 369 // 2005-07-14 23:36:19 => 2005-07-14 23:00:00 370 case 'hour' : 371 { 372 $checkpoints[1] = mktime($now['hour'],0,0, 373 $now['month'],$now['day'],$now['year']); 374 $timeshift = '1 hour ago'; 375 break; 376 } 377 // 2005-07-14 23:36:19 => 2005-07-14 12:00:00 378 case 'half day' : 379 { 380 $checkpoints[1] = mktime(($now['hour'] < 12) ? 0 : 12,0,0, 381 $now['month'],$now['day'],$now['year']); 382 $timeshift = '12 hours ago'; 383 break; 384 } 385 // 2005-07-14 23:36:19 => 2005-07-14 00:00:00 386 case 'day' : 387 { 388 $checkpoints[1] = mktime(0,0,0,$now['month'],$now['day'],$now['year']); 389 $timeshift = '1 day ago'; 390 break; 391 } 392 // 2005-07-14 23:36:19 => 2005-07-11 00:00:00 393 case 'week' : 394 { 395 $checkpoints[1] = strtotime('last monday', $checkpoints[0]); 396 $timeshift = '1 week ago'; 397 break; 398 } 399 // 2005-07-14 23:36:19 => 2005-07-01 00:00:00 400 case 'month' : 401 { 402 $checkpoints[1] = mktime(0,0,0,$now['month'],1,$now['year']); 403 $timeshift = '1 month ago'; 404 break; 405 } 406 } 407 408 for ($i = 2; $i <= 11; $i++) 409 { 410 $checkpoints[$i] = strtotime($timeshift, $checkpoints[$i-1]); 411 } 412 413 // converts all timestamp values to MySQL datetime format 414 $checkpoints = array_map('ts_to_mysqldt', $checkpoints); 415 416 for ($i = 1; $i <= max(array_keys($checkpoints)); $i++) 417 { 418 $news = news($checkpoints[$i], $checkpoints[$i-1]); 419 420 if (count($news) > 0) 421 { 422 $item = new FeedItem(); 423 $item->title = sprintf(l10n('New from %s to %s'), 424 $checkpoints[$i], 425 $checkpoints[$i-1]); 426 $item->link = 'http://phpwebgallery.net'; 427 428 // content creation 429 $item->description = '<ul>'; 430 foreach ($news as $line) 431 { 432 $item->description.= '<li>'.$line.'</li>'; 433 } 434 $item->description.= '</ul>'; 435 $item->descriptionHtmlSyndicated = true; 436 437 $item->date = ts_to_iso8601(mysqldt_to_ts($checkpoints[$i-1])); 438 $item->author = 'PhpWebGallery notifier'; 439 440 $rss->addItem($item); 441 } 442 } 443 } 312 $news = news($user['last_check'], $dbnow); 313 314 if (count($news) > 0) 315 { 316 $item = new FeedItem(); 317 $item->title = sprintf(l10n('New on %s'), $dbnow); 318 $item->link = 'http://phpwebgallery.net'; 319 320 // content creation 321 $item->description = '<ul>'; 322 foreach ($news as $line) 323 { 324 $item->description.= '<li>'.$line.'</li>'; 325 } 326 $item->description.= '</ul>'; 327 $item->descriptionHtmlSyndicated = true; 328 329 $item->date = ts_to_iso8601(mysqldt_to_ts($dbnow)); 330 $item->author = 'PhpWebGallery notifier'; 331 332 $rss->addItem($item); 333 } 334 335 $query = ' 336 UPDATE '.USER_FEED_TABLE.' 337 SET last_check = \''.$dbnow.'\' 338 WHERE id = \''.$_GET['feed'].'\' 339 ;'; 340 pwg_query($query); 444 341 445 342 // send XML feed -
trunk/include/config_default.inc.php
r825 r833 270 270 // category and element description. 271 271 $conf['allow_html_descriptions'] = true; 272 273 // gallery_title : Title for RSS feed 274 $conf['gallery_title'] = 'PhpWebGallery demo'; 275 276 // galery_url : URL given in RSS feed 277 $conf['gallery_url'] = 'http://demo.phpwebgallery.net'; 272 278 ?> -
trunk/include/constants.php
r808 r833 53 53 define('USERS_TABLE', $conf['users_table']); 54 54 define('USER_INFOS_TABLE', $prefixeTable.'user_infos'); 55 define('USER_FEED_TABLE', $prefixeTable.'user_feed'); 55 56 define('WAITING_TABLE', $prefixeTable.'waiting'); 56 57 define('IMAGE_METADATA_TABLE', $prefixeTable.'image_metadata'); -
trunk/include/functions_user.inc.php
r832 r833 430 430 $query = ' 431 431 SELECT COUNT(*) 432 FROM '.USER_ INFOS_TABLE.'433 WHERE feed_id = \''.$key.'\'432 FROM '.USER_FEED_TABLE.' 433 WHERE id = \''.$key.'\' 434 434 ;'; 435 435 list($count) = mysql_fetch_row(pwg_query($query)); … … 461 461 'language' => $conf['default_language'], 462 462 'recent_period' => $conf['recent_period'], 463 'feed_id' => find_available_feed_id(),464 463 'expand' => boolean_to_string($conf['auto_expand']), 465 464 'show_nb_comments' => boolean_to_string($conf['show_nb_comments']), -
trunk/install/phpwebgallery_structure.sql
r808 r833 225 225 226 226 -- 227 -- Table structure for table `phpwebgallery_user_feed` 228 -- 229 230 DROP TABLE IF EXISTS `phpwebgallery_user_feed`; 231 CREATE TABLE `phpwebgallery_user_feed` ( 232 `id` varchar(50) binary NOT NULL default '', 233 `user_id` smallint(5) unsigned NOT NULL default '0', 234 `last_check` datetime default NULL, 235 PRIMARY KEY (`id`) 236 ) TYPE=MyISAM; 237 238 -- 227 239 -- Table structure for table `phpwebgallery_user_group` 228 240 -- … … 252 264 `recent_period` tinyint(3) unsigned NOT NULL default '7', 253 265 `template` varchar(255) NOT NULL default 'default', 254 `last_feed_check` datetime default NULL,255 `feed_id` varchar(50) binary default NULL,256 266 `registration_date` datetime NOT NULL default '0000-00-00 00:00:00', 257 267 UNIQUE KEY `user_infos_ui1` (`user_id`) -
trunk/template/default/admin/maintenance.tpl
r817 r833 6 6 <li><a href="{U_MAINT_HISTORY}">{lang:purge history}</a></li> 7 7 <li><a href="{U_MAINT_SESSIONS}">{lang:purge sessions}</a></li> 8 <!-- 9 <li><a href="{U_FEEDS}">{lang:purge obsolete notification feed}</a></li> 10 --> 8 <li><a href="{U_MAINT_FEEDS}">{lang:purge never used notification feeds}</a></li> 11 9 </ul>
Note: See TracChangeset
for help on using the changeset viewer.