index.php 3.92 KB
Newer Older
1
2
3
4
<?php
/**
 *
 * @package    mahara
5
 * @subpackage core
6
 * @author     Catalyst IT Ltd
7
8
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
 * @copyright  For copyright information on Mahara, please see the README file distributed with this software.
9
10
11
 *
 */

12
13
define('INTERNAL', 1);
define('PUBLIC', 1);
14
define('MENUITEM', 'home');
15
define('HOME', 1);
16
17
require('init.php');

18
19
// 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.
20
if (!$USER->is_logged_in()) {
21
    define('TITLE', get_string('home'));
Richard Mansfield's avatar
Richard Mansfield committed
22
23
24
    $pagename = 'loggedouthome';
}
else {
25
    define('TITLE', get_string('dashboard', 'view'));
Richard Mansfield's avatar
Richard Mansfield committed
26
    $pagename = 'home';
27
28
}

29
30
31
if ($USER->is_logged_in()) {
    // get the user's dashboard view
    require_once(get_config('libroot') . 'view.php');
32
    $view = $USER->get_view_by_type('dashboard');
33

34
    $javascript = array('paginator', 'author');
35
36
37
    $blocktype_js = $view->get_all_blocktype_javascript();
    $javascript = array_merge($javascript, $blocktype_js['jsfiles']);
    $inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
38
    $stylesheets = array('<link rel="stylesheet" type="text/css" href="' . append_version_number(get_config('wwwroot') . 'theme/views.css') . '">');
39
    $stylesheets = array_merge($stylesheets, $view->get_all_blocktype_css());
40
41
42
43

    // include slimbox2 js and css files, if it is enabled...
    if (get_config_plugin('blocktype', 'gallery', 'useslimbox2')) {
        $langdir = (get_string('thisdirection', 'langconfig') == 'rtl' ? '-rtl' : '');
44
        $stylesheets = array_merge($stylesheets, array('<script type="application/javascript" src="' . append_version_number(get_config('wwwroot') . 'lib/slimbox2/js/slimbox2.js') . '"></script>',
45
46
           '<link rel="stylesheet" type="text/css" href="' . append_version_number(get_config('wwwroot') . 'lib/slimbox2/css/slimbox2' . $langdir . '.css') . '">'
           ));
47
48
    }

49
    $viewcontent = $view->build_rows(); // Build content before initialising smarty in case pieform elements define headers.
50
    $smarty = smarty(
51
        $javascript,
52
53
54
55
56
57
        $stylesheets,
        array(),
        array(
            'stylesheets' => array('style/views.css'),
        )
    );
58

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

function nevershow() {
    var data = {'showhomeinfo' : 0};
    sendjsonrequest('homeinfo.json.php', data, 'POST', hideinfo);
}
addLoadEvent(function () {
74
75
76
    if ($('hideinfo')) {
        $('hideinfo').onclick = nevershow;
    }
77
78
79
});
JAVASCRIPT;

80
        $smarty->assign('INLINEJAVASCRIPT', $js . $inlinejs);
81
82
    }

83
    $smarty->assign('dashboardview', true);
84
    $smarty->assign('viewcontent', $viewcontent);
85
86
87
88
    $smarty->assign('viewid', $view->get('id'));
}
else {
    $smarty = smarty();
89
90
    // Used to set a 'loggedout' class on body tag for styling purposes
    $smarty->assign('loggedout', true);
91
92
}

93
94
95
96
97
98
99
100
101
102
// 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',
103
104
    'topics'  => $wwwroot . 'group/topics.php',
    'share'   => $wwwroot . 'view/share.php',
105
106
107
);
$smarty->assign('url', $urls);

108
$smarty->assign('page_content', get_site_page_content($pagename));
109

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