Completed
Push — master ( 12d1e3...236763 )
by Patrick
03:09
created

class.FlipAdminPage.php (5 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
require_once('class.FlipPage.php');
3
4
class FlipAdminPage extends FlipPage
5
{
6
    public $user;
7
    public $is_admin = false;
8
9
    function __construct($title, $adminGroup='LDAPAdmins')
10
    {
11
        $this->user = FlipSession::getUser();
12
        $this->is_admin = $this->userIsAdmin($adminGroup);
13
        parent::__construct($title);
14
        $adminCSS = '/css/common/admin.min.css';
15
        if($this->minified !== 'min')
16
        {
17
            $adminCSS = '/css/common/admin.css';
18
        }
19
        $this->addCSSByURI($adminCSS);
20
        $this->addWellKnownJS(JS_METISMENU, false);
21
    }
22
23
    protected function userIsAdmin($adminGroup)
24
    {
25
        if($this->user === false || $this->user === null)
26
        {
27
            return false;
28
        }
29
        return $this->user->isInGroupNamed($adminGroup);
30
    }
31
32
    function addAllLinks()
33
    {
34
        if($this->user === false || $this->user === null)
35
        {
36
            $this->addLink('<i class="fa fa-sign-in"></i> Login', $this->loginUrl);
37
        }
38
        else
39
        {
40
            $this->add_links();
41
            $this->addLink('<i class="fa fa-sign-out"></i> Logout', $this->logoutUrl);
42
        }
43
    }
44
45
    protected function getDropdown($link, $name)
46
    {
47
        $ret  = '<li>';
48
        $href = $this->getHrefForDropdown($link);
49
        $ret .= $this->createLink($name.' <i class="fa fa-arrow-right"></i>', $href);
50
        $ret.='<ul>';
51
        $subNames = array_keys($link);
52
        foreach($subNames as $subName)
53
        {
54
            $ret.=$this->getLinkByName($subName, $link);
55
        }
56
        $ret.='</ul></li>';
57
        return $ret;
58
    }
59
60
    function addHeader()
61
    {
62
        $sites   = $this->getSiteLinksForHeader();
63
        $sideNav = $this->getLinksMenus();
64
        $log     = '<a href="https://profiles.burningflipside.com/logout.php"><i class="fa fa-sign-out"></i></a>';
65
        if($this->user === false || $this->user === null)
66
        {
67
            $log = '<a href="https://profiles.burningflipside.com/login.php?return='.$this->currentUrl().'"><i class="fa fa-sign-in"></i></a>';
68
        }
69
        $this->body = '<div id="wrapper">
70
                  <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
71
                      <div class="navbar-header">
72
                          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
73
                              <span class="sr-only">Toggle Navigation</span>
74
                              <span class="icon-bar"></span>
75
                              <span class="icon-bar"></span>
76
                              <span class="icon-bar"></span>
77
                          </button>
78
                          <a class="navbar-brand" href="index.php">'.$this->title.'</a>
79
                      </div>
80
                      <ul class="nav navbar-top-links navbar-right">
81
                          <a href="..">
82
                              <i class="fa fa-home"></i>
83
                          </a>
84
                          &nbsp;&nbsp;'.$log.'
85
                          <li class="dropdown">
86
                              <a href="#" class="dropdown-toggle" data-toggle="dropdown">
87
                                  <i class="fa fa-link"></i>
88
                                  <b class="caret"></b>
89
                              </a>
90
                              <ul class="dropdown-menu dropdown-sites">
91
                                  '.$sites.'
92
                              </ul>
93
                          </li>
94
                      </ul>
95
                      <div class="navbar-default sidebar" role="navigation">
96
                          <div class="sidebar-nav navbar-collapse" style="height: 1px;">
97
                              <ul class="nav" id="side-menu">
98
                                  '.$sideNav.'
99
                              </ul>
100
                          </div>
101
                      </div>
102
                  </nav>
103
                  <div id="page-wrapper" style="min-height: 538px;">'.$this->body.'</div></div>';
104
    }
105
106
    const CARD_GREEN  = 'panel-green';
107
    const CARD_BLUE   = 'panel-primary';
108
    const CARD_YELLOW = 'panel-yellow';
109
    const CARD_RED    = 'panel-red';
110
111
    function add_card($iconName, $bigText, $littleText, $link='#', $color = self::CARD_BLUE, $textColor=false)
112
    {
113
        if($textColor === false)
114
        {
115
            switch($color)
116
            {
117
                default:
118
                    $textColor='';
0 ignored issues
show
$textColor is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
119
                    break;
120
                case self::CARD_BLUE:
121
                    $textColor='text-primary';
0 ignored issues
show
$textColor is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
122
                    break;
123
                case self::CARD_GREEN:
124
                    $textColor='text-success';
0 ignored issues
show
$textColor is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
125
                    break;
126
                case self::CARD_YELLOW:
127
                    $textColor='text-warning';
0 ignored issues
show
$textColor is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
128
                    break;
129
                case self::CARD_RED:
130
                    $textColor='text-danger';
0 ignored issues
show
$textColor is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
131
                    break;
132
            }
133
        }
134
        $card = '<div class="col-lg-3 col-md-6">
135
                     <div class="panel '.$color.'">
136
                         <div class="panel-heading">
137
                             <div class="row">
138
                                 <div class="col-xs-3">
139
                                     <i class="fa '.$iconName.'" style="font-size: 5em;"></i>
140
                                 </div>
141
                                 <div class="col-xs-9 text-right">
142
                                     <div style="font-size: 40px;">'.$bigText.'</div>
143
                                     <div>'.$littleText.'</div>
144
                                 </div>
145
                             </div>
146
                         </div>
147
                         <a href="'.$link.'">
148
                         <div class="panel-footer">
149
                             <span class="pull-left">View Details</span>
150
                             <span class="pull-right fa fa-arrow-circle-right"></span>
151
                             <div class="clearfix"></div>
152
                         </div>
153
                         </a>
154
                     </div>
155
                 </div>';
156
        $this->body .= $card;
157
    }
158
159
    function printPage($header=true)
160
    {
161
        if($this->user === false || $this->user === null)
162
        {
163
            $this->body = '
164
        <div class="row">
165
            <div class="col-lg-12">
166
                <h1 class="page-header">You must <a href="'.$this->loginUrl.'?return='.$this->currentUrl().'">log in <span class="glyphicon glyphicon-log-in"></span></a> to access the '.$this->title.' Admin system!</h1>
167
            </div>
168
        </div>';
169
        }
170
        else if($this->is_admin === false)
171
        {
172
            $this->body = '
173
        <div class="row">
174
            <div class="col-lg-12">
175
                <h1 class="page-header">The current user does not have access rights to the '.$this->title.' Admin system!</h1>
176
            </div>
177
        </div>';
178
        }
179
        parent::printPage();
180
    }
181
}
182
/* vim: set tabstop=4 shiftwidth=4 expandtab: */
183
?>
184