[850] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[2297] | 4 | // +-----------------------------------------------------------------------+ |
---|
[19703] | 5 | // | Copyright(C) 2008-2013 Piwigo Team http://piwigo.org | |
---|
[2297] | 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
| 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
[850] | 23 | |
---|
| 24 | // +-----------------------------------------------------------------------+ |
---|
| 25 | // | initialization | |
---|
| 26 | // +-----------------------------------------------------------------------+ |
---|
| 27 | |
---|
| 28 | define('PHPWG_ROOT_PATH','./'); |
---|
| 29 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
| 30 | |
---|
[13240] | 31 | /** |
---|
| 32 | * search an available feed_id |
---|
| 33 | * |
---|
| 34 | * @return string feed identifier |
---|
| 35 | */ |
---|
| 36 | function find_available_feed_id() |
---|
| 37 | { |
---|
| 38 | while (true) |
---|
| 39 | { |
---|
| 40 | $key = generate_key(50); |
---|
| 41 | $query = ' |
---|
| 42 | SELECT COUNT(*) |
---|
| 43 | FROM '.USER_FEED_TABLE.' |
---|
| 44 | WHERE id = \''.$key.'\' |
---|
| 45 | ;'; |
---|
| 46 | list($count) = pwg_db_fetch_row(pwg_query($query)); |
---|
| 47 | if (0 == $count) |
---|
| 48 | { |
---|
| 49 | return $key; |
---|
| 50 | } |
---|
| 51 | } |
---|
| 52 | } |
---|
| 53 | |
---|
[850] | 54 | // +-----------------------------------------------------------------------+ |
---|
[1072] | 55 | // | Check Access and exit when user status is not ok | |
---|
| 56 | // +-----------------------------------------------------------------------+ |
---|
| 57 | check_status(ACCESS_GUEST); |
---|
| 58 | |
---|
[18063] | 59 | trigger_action('loc_begin_notification'); |
---|
| 60 | |
---|
[1072] | 61 | // +-----------------------------------------------------------------------+ |
---|
[850] | 62 | // | new feed creation | |
---|
| 63 | // +-----------------------------------------------------------------------+ |
---|
| 64 | |
---|
| 65 | $page['feed'] = find_available_feed_id(); |
---|
| 66 | |
---|
| 67 | $query = ' |
---|
| 68 | INSERT INTO '.USER_FEED_TABLE.' |
---|
| 69 | (id, user_id, last_check) |
---|
| 70 | VALUES |
---|
| 71 | (\''.$page['feed'].'\', '.$user['id'].', NULL) |
---|
| 72 | ;'; |
---|
| 73 | pwg_query($query); |
---|
| 74 | |
---|
[1636] | 75 | |
---|
[1750] | 76 | $feed_url=PHPWG_ROOT_PATH.'feed.php'; |
---|
[2029] | 77 | if (is_a_guest()) |
---|
[1750] | 78 | { |
---|
| 79 | $feed_image_only_url=$feed_url; |
---|
| 80 | $feed_url .= '?feed='.$page['feed']; |
---|
| 81 | } |
---|
| 82 | else |
---|
| 83 | { |
---|
| 84 | $feed_url .= '?feed='.$page['feed']; |
---|
| 85 | $feed_image_only_url=$feed_url.'&image_only'; |
---|
| 86 | } |
---|
| 87 | |
---|
[850] | 88 | // +-----------------------------------------------------------------------+ |
---|
| 89 | // | template initialization | |
---|
| 90 | // +-----------------------------------------------------------------------+ |
---|
| 91 | |
---|
| 92 | $title = l10n('Notification'); |
---|
| 93 | $page['body_id'] = 'theNotificationPage'; |
---|
[1703] | 94 | $page['meta_robots']=array('noindex'=>1, 'nofollow'=>1); |
---|
| 95 | |
---|
[1539] | 96 | |
---|
[850] | 97 | $template->set_filenames(array('notification'=>'notification.tpl')); |
---|
| 98 | |
---|
[2288] | 99 | $template->assign( |
---|
[850] | 100 | array( |
---|
[1636] | 101 | 'U_FEED' => $feed_url, |
---|
| 102 | 'U_FEED_IMAGE_ONLY' => $feed_image_only_url, |
---|
[850] | 103 | ) |
---|
| 104 | ); |
---|
[10812] | 105 | |
---|
| 106 | // include menubar |
---|
| 107 | $themeconf = $template->get_template_vars('themeconf'); |
---|
[10824] | 108 | if (!isset($themeconf['hide_menu_on']) OR !in_array('theNotificationPage', $themeconf['hide_menu_on'])) |
---|
[10812] | 109 | { |
---|
| 110 | include( PHPWG_ROOT_PATH.'include/menubar.inc.php'); |
---|
| 111 | } |
---|
[850] | 112 | |
---|
| 113 | // +-----------------------------------------------------------------------+ |
---|
| 114 | // | html code display | |
---|
| 115 | // +-----------------------------------------------------------------------+ |
---|
[2288] | 116 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
[18063] | 117 | trigger_action('loc_end_notification'); |
---|
[20609] | 118 | flush_page_messages(); |
---|
[2446] | 119 | $template->pparse('notification'); |
---|
[850] | 120 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
| 121 | |
---|
| 122 | ?> |
---|