index.php 3.86 KB
Newer Older
1
2
<?php
/**
Francois Marier's avatar
Francois Marier committed
3
 * Mahara: Electronic portfolio, weblog, resume builder and social networking
4
5
 * Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
 *                         http://wiki.mahara.org/Contributors
6
 *
Francois Marier's avatar
Francois Marier committed
7
8
9
10
 * This program 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 3 of the License, or
 * (at your option) any later version.
11
 *
Francois Marier's avatar
Francois Marier committed
12
13
14
15
 * This program 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.
16
 *
Francois Marier's avatar
Francois Marier committed
17
18
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20
 *
 * @package    mahara
21
 * @subpackage core
22
 * @author     Catalyst IT Ltd
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
24
 * @copyright  (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
25
26
27
 *
 */

28
29
define('INTERNAL', 1);
define('PUBLIC', 1);
30
define('MENUITEM', '');
31
define('HOME', 1);
32
33
require('init.php');

34
35
// Check for whether the user is logged in, before processing the page. After
// this, we can guarantee whether the user is logged in or not for this page.
36
if (!$USER->is_logged_in()) {
37
    define('TITLE', get_string('home'));
Richard Mansfield's avatar
Richard Mansfield committed
38
39
40
    $pagename = 'loggedouthome';
}
else {
41
    define('TITLE', get_string('dashboard', 'view'));
Richard Mansfield's avatar
Richard Mansfield committed
42
    $pagename = 'home';
43
44
}

45
46
47
if ($USER->is_logged_in()) {
    // get the user's dashboard view
    require_once(get_config('libroot') . 'view.php');
48
    $view = $USER->get_view_by_type('dashboard');
49

50
    $javascript = array('paginator');
51
52
53
    $blocktype_js = $view->get_all_blocktype_javascript();
    $javascript = array_merge($javascript, $blocktype_js['jsfiles']);
    $inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
54
55
    $stylesheets = array('<link rel="stylesheet" type="text/css" href="' . get_config('wwwroot') . 'theme/views.css">');
    $smarty = smarty(
56
        $javascript,
57
58
59
60
61
62
        $stylesheets,
        array(),
        array(
            'stylesheets' => array('style/views.css'),
        )
    );
63

64
    if (get_config('homepageinfo') && $USER->get_account_preference('showhomeinfo')) {
65
        // allow the user to choose never to see the info boxes again
66
        $strhowtodisable = json_encode(get_string('howtodisable', 'mahara', get_config('wwwroot') . 'account'));
67
68
        $js = <<<JAVASCRIPT
function hideinfo() {
69
70
71
    var m = SPAN();
    m.innerHTML = {$strhowtodisable};
    slideUp('home-info-container', {afterFinish: function() {displayMessage(m, 'ok');}});
72
73
74
75
76
77
78
}

function nevershow() {
    var data = {'showhomeinfo' : 0};
    sendjsonrequest('homeinfo.json.php', data, 'POST', hideinfo);
}
addLoadEvent(function () {
79
80
81
    if ($('hideinfo')) {
        $('hideinfo').onclick = nevershow;
    }
82
83
84
});
JAVASCRIPT;

85
        $smarty->assign('INLINEJAVASCRIPT', $js . $inlinejs);
86
87
    }

88
89
90
91
92
93
    $smarty->assign('dashboardview', true);
    $smarty->assign('viewcontent', $view->build_columns());
    $smarty->assign('viewid', $view->get('id'));
}
else {
    $smarty = smarty();
94
95
}

96
97
98
99
100
101
102
103
104
105
// Assign urls used in homeinfo.tpl
$wwwroot = get_config('wwwroot');
$urls = array(
    'profile' => $wwwroot . 'artefact/internal',
    'files'   => $wwwroot . 'artefact/file',
    'resume'  => $wwwroot . 'artefact/resume',
    'blog'    => $wwwroot . 'artefact/blog',
    'views'   => $wwwroot . 'view',
    'friends' => $wwwroot . 'user/find.php',
    'groups'  => $wwwroot . 'group/find.php',
106
107
    'topics'  => $wwwroot . 'group/topics.php',
    'share'   => $wwwroot . 'view/share.php',
108
109
110
);
$smarty->assign('url', $urls);

111
$smarty->assign('page_content', get_site_page_content($pagename));
112
113
114
115

// handheld device flag
$smarty->assign('handheld_device', $SESSION->get('handheld_device'));

116
$smarty->display('index.tpl');