FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
User.php
Go to the documentation of this file.
1 <?php
2 /***************************************************************
3 Copyright (C) 2017 Siemens AG
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  ***************************************************************/
22 namespace Fossology\UI\Api\Models;
23 
24 require_once dirname(dirname(dirname(dirname(__DIR__)))) .
25  '/lib/php/Plugin/FO_Plugin.php';
26 
31 class User
32 {
37  private $id;
42  private $name;
47  private $description;
52  private $email;
57  private $accessLevel;
62  private $rootFolderId;
72  private $agents;
77  private $analysis;
78 
91  {
92  $this->id = intval($id);
93  $this->name = $name;
94  $this->description = $description;
95  $this->email = $email;
96  switch ($accessLevel) {
97  case PLUGIN_DB_READ:
98  $this->accessLevel = "read_only";
99  break;
100  case PLUGIN_DB_WRITE:
101  $this->accessLevel = "read_write";
102  break;
103  case PLUGIN_DB_ADMIN:
104  $this->accessLevel = "admin";
105  break;
106  default:
107  $this->accessLevel = "none";
108  }
109  $this->rootFolderId = intval($root_folder_id);
110  $this->emailNotification = $emailNotification;
111  $this->agents = $agents;
112  $this->analysis = new Analysis();
113  $this->analysis->setUsingString($this->agents);
114  }
115 
117 
120  public function getId()
121  {
122  return $this->id;
123  }
124 
128  public function getName()
129  {
130  return $this->name;
131  }
132 
136  public function getDescription()
137  {
138  return $this->description;
139  }
140 
144  public function getEmail()
145  {
146  return $this->email;
147  }
148 
152  public function getAccessLevel()
153  {
154  return $this->accessLevel;
155  }
156 
160  public function getRootFolderId()
161  {
162  return $this->rootFolderId;
163  }
164 
168  public function getEmailNotification()
169  {
171  }
172 
176  public function getAgents()
177  {
178  return $this->agents;
179  }
180 
185  public function getJSON()
186  {
187  return json_encode($this->getArray());
188  }
189 
194  public function getArray()
195  {
196  $returnUser = array();
197  $returnUser["id"] = $this->id;
198  $returnUser["name"] = $this->name;
199  $returnUser["description"] = $this->description;
200  if ($this->email !== null) {
201  $returnUser["email"] = $this->email;
202  $returnUser["accessLevel"] = $this->accessLevel;
203  }
204  if ($this->rootFolderId !== null && $this->rootFolderId != 0) {
205  $returnUser["rootFolderId"] = $this->rootFolderId;
206  }
207  if ($this->emailNotification !== null) {
208  $returnUser["emailNotification"] = $this->emailNotification;
209  }
210  if ($this->agents !== null) {
211  $returnUser["agents"] = $this->analysis->getArray();
212  }
213  return $returnUser;
214  }
215 }
#define PLUGIN_DB_ADMIN
Plugin requires admin level permission on DB.
Definition: libfossology.h:51
#define PLUGIN_DB_READ
Plugin requires read permission on DB.
Definition: libfossology.h:49
#define PLUGIN_DB_WRITE
Plugin requires write permission on DB.
Definition: libfossology.h:50
__construct($id, $name, $description, $email, $accessLevel, $root_folder_id, $emailNotification, $agents)
Definition: User.php:90
Model to hold analysis settings.
Definition: Analysis.php:30
Model to hold user information.
Definition: User.php:31