FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
demohello.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************
3  Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  ***********************************************************/
25 namespace Fossology\DemoHello;
26 
31 
36 class DemoHello extends DefaultPlugin
37 {
38  const NAME = "demo_hello";
39 
40  public function __construct()
41  {
42  parent::__construct(self::NAME, array(
43  self::TITLE => _("Demo Hello World"),
44  self::MENU_LIST => "Help::Demo::Hello World",
45  self::PERMISSION => Auth::PERM_READ
46  ));
47  }
48 
53  protected function WhoAmI()
54  {
55  $user_pk = Auth::getUserId();
56 
57  if (empty($user_pk))
58  {
59  return _("You are not logged in");
60  }
61 
62  $userDao = $this->getObject('dao.user');
63  return $userDao->getUserName($user_pk);
64  }
65 
69  protected function handle(Request $request)
70  {
71  $UserName = $this->WhoAmI();
72  $Hello = _("Hello");
73  $OutBuf = "<h2>$Hello $UserName </h2>";
74  $OutBuf .= _("Wasn't that easy?");
75 
76  return $this->render('include/base.html.twig', $this->mergeWithDefault(array('message' => $OutBuf)));
77  }
78 
79 }
80 
81 register_plugin(new DemoHello());
static getUserId()
Get the current user&#39;s id.
Definition: Auth.php:69
render($templateName, $vars=null, $headers=null)
WhoAmI()
Find out who I am from my user record.
Definition: demohello.php:53
UI component for demomod (Visible in menu)
Definition: demohello.php:36
handle(Request $request)
Generate response.
Definition: demohello.php:69