ProfilesPage::addLinks()   B
last analyzed

Complexity

Conditions 8
Paths 5

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
nc 5
nop 0
dl 0
loc 15
rs 8.4444
c 0
b 0
f 0
1
<?php
2
require_once('Autoload.php');
3
class ProfilesPage extends \Flipside\Http\WebPage
4
{
5
    public $profiles_root;
6
7
    public function __construct($title)
8
    {
9
        parent::__construct($title, true);
10
        $root = $_SERVER['DOCUMENT_ROOT'];
11
        $script_dir = dirname(__FILE__);
12
        if(strstr($script_dir, $root) === false)
13
        {
14
            $this->profiles_root = dirname($_SERVER['SCRIPT_NAME']);
15
        }
16
        else
17
        {
18
            $this->profiles_root = substr($script_dir, strlen($root));
19
        }
20
        $this->content['root'] = $this->profiles_root;
21
        $this->addTemplateDir('./templates', 'Profiles');
22
        $this->setTemplateName('@Profiles/profile-main.html');
23
    }
24
25
    public function addLinks()
26
    {
27
        if($this->user !== false && $this->user !== null)
28
        {
29
            if($this->user->isInGroupNamed('LDAPAdmins') || $this->user->isInGroupNamed('AFs'))
30
            {
31
                $this->addLink('Admin', $this->profiles_root.'/_admin/index.php');
32
            }
33
            if(($this->user->isInGroupNamed('Leads') || $this->user->isInGroupNamed('CC')) || $this->user->isInGroupNamed('AFs'))
34
            {
35
                $this->addLink('Leads', $this->profiles_root.'/lead/index.php');
36
            }
37
            $this->addLink('My Profile', $this->profiles_root.'/profile.php');
38
        }
39
    }
40
}
41
/* vim: set tabstop=4 shiftwidth=4 expandtab: */
42