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 | public 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 | protected 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 | protected function addHeader() |
||
61 | { |
||
62 | $sites = $this->getSiteLinksForHeader(); |
||
63 | $sideNav = $this->getLinksMenus(); |
||
64 | $log = '<a href="'.$this->profilesUrl.'/logout.php"><i class="fa fa-sign-out"></i></a>'; |
||
0 ignored issues
–
show
|
|||
65 | if($this->user === false || $this->user === null) |
||
66 | { |
||
67 | $log = '<a href="'.$this->profilesUrl.'/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 | '.$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 | public function add_card($iconName, $bigText, $littleText, $link = '#', $color = self::CARD_BLUE) |
||
112 | { |
||
113 | $card = '<div class="col-lg-3 col-md-6"> |
||
114 | <div class="panel '.$color.'"> |
||
115 | <div class="panel-heading"> |
||
116 | <div class="row"> |
||
117 | <div class="col-xs-3"> |
||
118 | <i class="fa '.$iconName.'" style="font-size: 5em;"></i> |
||
119 | </div> |
||
120 | <div class="col-xs-9 text-right"> |
||
121 | <div style="font-size: 40px;">'.$bigText.'</div> |
||
122 | <div>'.$littleText.'</div> |
||
123 | </div> |
||
124 | </div> |
||
125 | </div> |
||
126 | <a href="'.$link.'"> |
||
127 | <div class="panel-footer"> |
||
128 | <span class="pull-left">View Details</span> |
||
129 | <span class="pull-right fa fa-arrow-circle-right"></span> |
||
130 | <div class="clearfix"></div> |
||
131 | </div> |
||
132 | </a> |
||
133 | </div> |
||
134 | </div>'; |
||
135 | $this->body .= $card; |
||
136 | } |
||
137 | |||
138 | public function printPage($header = true) |
||
139 | { |
||
140 | if($this->user === false || $this->user === null) |
||
141 | { |
||
142 | $this->body = ' |
||
143 | <div class="row"> |
||
144 | <div class="col-lg-12"> |
||
145 | <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> |
||
146 | </div> |
||
147 | </div>'; |
||
148 | } |
||
149 | else if($this->is_admin === false) |
||
150 | { |
||
151 | $this->body = ' |
||
152 | <div class="row"> |
||
153 | <div class="col-lg-12"> |
||
154 | <h1 class="page-header">The current user does not have access rights to the '.$this->title.' Admin system!</h1> |
||
155 | </div> |
||
156 | </div>'; |
||
157 | } |
||
158 | parent::printPage(); |
||
159 | } |
||
160 | } |
||
161 | /* vim: set tabstop=4 shiftwidth=4 expandtab: */ |
||
162 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: