Working on user context
This commit is contained in:
parent
c184469219
commit
96120bc744
32
api/businesslogic/security/UserContext.php
Normal file
32
api/businesslogic/security/UserContext.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace BusinessLogic\Security;
|
||||
|
||||
|
||||
class UserContext {
|
||||
public $id;
|
||||
public $username;
|
||||
public $admin;
|
||||
public $name;
|
||||
public $email;
|
||||
public $signature;
|
||||
public $language;
|
||||
public $categories;
|
||||
public $permissions;
|
||||
|
||||
/**
|
||||
* @var UserContextPreferences
|
||||
*/
|
||||
public $preferences;
|
||||
|
||||
/**
|
||||
* @var UserContextNotifications
|
||||
*/
|
||||
public $notificationSettings;
|
||||
public $autoAssign;
|
||||
public $ratingNegative;
|
||||
public $ratingPositive;
|
||||
public $rating;
|
||||
public $totalNumberOfReplies;
|
||||
public $active;
|
||||
}
|
38
api/businesslogic/security/UserContextBuilder.php
Normal file
38
api/businesslogic/security/UserContextBuilder.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace BusinessLogic\Security;
|
||||
|
||||
|
||||
class UserContextBuilder {
|
||||
static function buildUserContext($authToken, $hesk_settings) {
|
||||
//$userForToken = gateway.getUserForToken($authToken);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a user context based on the current session. **The session must be active!**
|
||||
* @return UserContext the built user context
|
||||
*/
|
||||
static function fromSession() {
|
||||
require_once(__DIR__ . '/UserContext.php');
|
||||
require_once(__DIR__ . '/UserContextPreferences.php');
|
||||
|
||||
$userContext = new UserContext();
|
||||
$userContext->id = $_SESSION['id'];
|
||||
$userContext->username = $_SESSION['user'];
|
||||
$userContext->admin = $_SESSION['isadmin'];
|
||||
$userContext->name = $_SESSION['name'];
|
||||
$userContext->email = $_SESSION['email'];
|
||||
$userContext->signature = $_SESSION['signature'];
|
||||
$userContext->language = $_SESSION['language'];
|
||||
$userContext->categories = explode(',', $_SESSION['categories']);
|
||||
|
||||
$preferences = new UserContextPreferences();
|
||||
$preferences->afterReply = $_SESSION['afterreply'];
|
||||
$preferences->autoStartTimeWorked = $_SESSION['autostart'];
|
||||
$preferences-
|
||||
|
||||
|
||||
return $userContext;
|
||||
}
|
||||
}
|
21
api/businesslogic/security/UserContextNotifications.php
Normal file
21
api/businesslogic/security/UserContextNotifications.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: user
|
||||
* Date: 1/19/17
|
||||
* Time: 8:51 PM
|
||||
*/
|
||||
|
||||
namespace BusinessLogic\Security;
|
||||
|
||||
|
||||
class UserContextNotifications {
|
||||
public $newUnassigned;
|
||||
public $newAssignedToMe;
|
||||
public $replyUnassigned;
|
||||
public $replyToMe;
|
||||
public $privateMessage;
|
||||
public $noteOnTicketAssignedToMe;
|
||||
public $noteOnTicketNotAssignedToMe;
|
||||
public $overdueTicketUnassigned;
|
||||
}
|
21
api/businesslogic/security/UserContextPreferences.php
Normal file
21
api/businesslogic/security/UserContextPreferences.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: user
|
||||
* Date: 1/19/17
|
||||
* Time: 8:49 PM
|
||||
*/
|
||||
|
||||
namespace BusinessLogic\Security;
|
||||
|
||||
|
||||
class UserContextPreferences {
|
||||
public $afterReply;
|
||||
public $autoStartTimeWorked;
|
||||
public $autoreload;
|
||||
public $defaultNotifyCustomerNewTicket;
|
||||
public $defaultNotifyCustomerReply;
|
||||
public $showSuggestedKnowledgebaseArticles;
|
||||
public $defaultCalendarView;
|
||||
public $defaultTicketView;
|
||||
}
|
@ -39,6 +39,8 @@ class CategoryGateway {
|
||||
$results[$category->id] = $category;
|
||||
}
|
||||
|
||||
hesk_dbClose();
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
@ -35,8 +35,15 @@ function handle404() {
|
||||
print json_encode('404 found');
|
||||
}
|
||||
|
||||
function assertApiIsEnabled() {
|
||||
//-- TODO
|
||||
}
|
||||
|
||||
// Must use fully-qualified namespace to controllers
|
||||
Link::before('assertApiIsEnabled');
|
||||
|
||||
Link::all(array(
|
||||
'/' => 'assertApiIsEnabled',
|
||||
'/test/{i}' => '\Controllers\Category\CategoryController',
|
||||
'404' => 'handle404'
|
||||
));
|
Loading…
x
Reference in New Issue
Block a user