Skip to content
Snippets Groups Projects
Commit fe2fdeca authored by Peter Rotich's avatar Peter Rotich Committed by Peter Rotich
Browse files

Make collaborator extends ticket user - necessary for authtoken support

Make Clientession extends EndUser

Allow variable replacer to call __call functions
parent 0071a7ad
No related branches found
No related tags found
No related merge requests found
......@@ -14,19 +14,18 @@
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
require_once(INCLUDE_DIR . 'class.user.php');
require_once(INCLUDE_DIR . 'class.client.php');
class Collaborator {
class Collaborator extends TicketUser {
var $ht;
var $user;
var $ticket;
static private $token_regex = '/^c(?P<id>\d+)x(?P<algo>\d+)h(?P<hash>.*)$/i';
function __construct($id) {
$this->load($id);
parent::__construct($this->getUser());
}
function load($id) {
......@@ -38,13 +37,14 @@ class Collaborator {
.' WHERE id='.db_input($id);
$this->ht = db_fetch_array(db_query($sql));
$this->ticket = $this->user = null;
$this->ticket = null;
}
function reload() {
return $this->load();
}
<<<<<<< HEAD
function __call($name, $args) {
if(!($user=$this->getUser()) || !method_exists($user, $name))
......@@ -60,6 +60,8 @@ class Collaborator {
$this->getEmail()));
}
=======
>>>>>>> efe5b0f... Make collaborator extends ticket user - necessary for authtoken support
function getId() {
return $this->ht['id'];
}
......@@ -68,6 +70,10 @@ class Collaborator {
return ($this->ht['isactive']);
}
function getCreateDate() {
return $this->ht['created'];
}
function getTicketId() {
return $this->ht['ticket_id'];
}
......@@ -149,27 +155,11 @@ class Collaborator {
.' WHERE ticket_id='.db_input($info['ticketId'])
.' AND user_id='.db_input($info['userId']);
list($id) = db_fetch_row(db_query($sql));
return $id;
}
static function lookupByAuthToken($token) {
//Expecting well formatted token see getAuthToken routine for details.
$matches = array();
if (preg_match(static::$token_regex, $token, $matches)
&& $matches['id']
&& ($c = self::lookup($matches['id']))
&& strcasecmp($c->getAuthToken($matches['algo']), $token) == 0
)
return $c;
return null;
return db_result(db_query($sql));
}
static function lookup($criteria) {
$id = is_numeric($criteria)
? $criteria : self::getIdByInfo($criteria);
......
......@@ -103,13 +103,13 @@ class UserSession {
}
class ClientSession extends Client {
class ClientSession extends EndUser {
var $session;
function ClientSession($email, $id){
parent::Client($id, $email);
$this->session= new UserSession($email);
function __construct($user) {
parent::__construct($user);
$this->session= new UserSession($user->getUserName());
}
function isValid(){
......@@ -145,13 +145,13 @@ class StaffSession extends Staff {
var $session;
function StaffSession($var){
parent::Staff($var);
function __construct($var) {
parent::__construct($var);
$this->session= new UserSession($this->getId());
}
function isValid(){
global $_SESSION,$cfg;
global $_SESSION, $cfg;
if(!$this->getId() || $this->session->getSessionId()!=session_id())
return false;
......
......@@ -67,8 +67,7 @@ class VariableReplacer {
return call_user_func(array($obj, 'asVar'));
list($v, $part) = explode('.', $var, 2);
if ($v && method_exists($obj, 'get'.ucfirst($v))
&& is_callable(array($obj, 'get'.ucfirst($v)))) {
if ($v && is_callable(array($obj, 'get'.ucfirst($v)))) {
$rv = call_user_func(array($obj, 'get'.ucfirst($v)));
if(!$rv || !is_object($rv))
return $rv;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment