CMS  Version 3.9
APIToken Class Reference

Inherits DataItem.

Public Member Functions

 User ()
 
 __construct ()
 

Static Public Member Functions

static getUserToken ($user_id)
 
static getToken ($token)
 

Public Attributes

 $table = "api_token"
 
 $primary_key = "token_id"
 
 $pretty_class_name = "API Token"
 
 $fields
 
 $related = array("User" => '')
 

Detailed Description

Definition at line 8 of file api_token.inc.

Constructor & Destructor Documentation

◆ __construct()

APIToken::__construct ( )

Definition at line 30 of file api_token.inc.

31  {
32  // Patch in the user class, since this can be overridden by the application
33  $mgr = new UserManager();
34  $this->relations["User"] = $mgr->getUserClass();
35 
36  $this->DataItem(func_get_args());
37  }
Provides the interface to the user model for the application.

Member Function Documentation

◆ getToken()

static APIToken::getToken (   $token)
static

Definition at line 49 of file api_token.inc.

50  {
51  $tokens = Query::create('APIToken', "WHERE token=:t AND active=1 AND (expiry_date IS NULL OR expiry_date > NOW()) ORDER BY created_date DESC LIMIT 1")
52  ->bind(":t", $token)
53  ->execute();
54 
55  if (count($tokens)) return $tokens[0];
56  return null;
57  }

◆ getUserToken()

static APIToken::getUserToken (   $user_id)
static

Definition at line 39 of file api_token.inc.

40  {
41  $tokens = Query::create('APIToken', "WHERE user_id=:u AND active=1 AND (expiry_date IS NULL OR expiry_date > NOW()) ORDER BY created_date DESC LIMIT 1")
42  ->bind(":u", $user_id)
43  ->execute();
44 
45  if (count($tokens)) return $tokens[0];
46  return null;
47  }
$user_id

◆ User()

APIToken::User ( )

Definition at line 24 of file api_token.inc.

25  {
26  $mgr = new UserManager();
27  return $mgr->getUser($this->user_id);
28  }
$feedback user_id
Definition: save.inc:14

Member Data Documentation

◆ $fields

APIToken::$fields
Initial value:
= array("token_id" => 'Number',
"token" => 'String',
"user_id" => 'Number',
"created_date" => 'DateTime',
"expiry_date" => 'DateTime',
"last_access" => 'DateTime',
"active" => 'Boolean')

Definition at line 14 of file api_token.inc.

◆ $pretty_class_name

APIToken::$pretty_class_name = "API Token"

Definition at line 12 of file api_token.inc.

◆ $primary_key

APIToken::$primary_key = "token_id"

Definition at line 11 of file api_token.inc.

◆ $related

APIToken::$related = array("User" => '')

Definition at line 22 of file api_token.inc.

◆ $table

APIToken::$table = "api_token"

Definition at line 10 of file api_token.inc.


The documentation for this class was generated from the following file: