Marius Cramer
2015-08-06 37b29231e47a0c4458dc1c15d98588f16f07e1e2
commit | author | age
8896ab 1 <?php
N 2
3 /*
4 Copyright (c) 2010 Till Brehm, projektfarm Gmbh
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9
10     * Redistributions of source code must retain the above copyright notice,
11       this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright notice,
13       this list of conditions and the following disclaimer in the documentation
14       and/or other materials provided with the distribution.
15     * Neither the name of ISPConfig nor the names of its contributors
16       may be used to endorse or promote products derived from this software without
17       specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 $app->uses('simplepie');
32 $app->uses('auth');
33
34 $app->tpl->newTemplate('dashboard/templates/custom_menu.htm');
35
36 $app->uses('getconf');
37 $misc_config = $app->getconf->get_global_config('misc');
38
39
40 switch($_SESSION['s']['user']['typ']) {
b1a6a5 41 case 'admin':
MC 42     $atom_url = $misc_config['dashboard_atom_url_admin'];
43     break;
44 case 'user':
45     if ($app->auth->has_clients($_SESSION['s']['user']['userid']) === true)
46         $atom_url = $misc_config['dashboard_atom_url_reseller'];
47     else
48         $atom_url = $misc_config['dashboard_atom_url_client'];
49     break;
50 default:
51     $atom_url = "";
8896ab 52 }
N 53
8cf78b 54 $rows = array();
T 55
8896ab 56 if( $atom_url != '' ) {
N 57     if(!isset($_SESSION['s']['rss_news'])) {
b1a6a5 58
8896ab 59         $app->simplepie->set_feed_url($atom_url);
N 60         $app->simplepie->enable_cache(false);
61         $app->simplepie->init();
62         $items = $app->simplepie->get_items();
63
64         $rows = array();
65         $n = 1;
66
67         foreach ($items as $item)
68         {
69             //* We want to show only the first 10 news records
70             if($n <= 10) {
71                 $rows[] = array('title' => $item->get_title(),
b1a6a5 72                     'link' => $item->get_link(),
MC 73                     'content' => $item->get_content(),
a563d5 74                     'date' => $item->get_date($app->lng('conf_format_dateshort'))
b1a6a5 75                 );
8896ab 76             }
N 77             $n++;
78         }
b1a6a5 79
8896ab 80         $_SESSION['s']['rss_news'] = $rows;
b1a6a5 81
8896ab 82     } else {
N 83         $rows = $_SESSION['s']['rss_news'];
84     }
b1a6a5 85
MC 86     $app->tpl->setVar('latest_news_txt', $app->lng('latest_news_txt'));
8896ab 87
N 88 }
89
b1a6a5 90 $app->tpl->setLoop('news', $rows);
8896ab 91
N 92 ?>