forked from nybohansen/rostanvo
/
AuthUser.class.php
108 lines (94 loc) · 3.46 KB
/
AuthUser.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
* @copyright Copyright (c) 2007 Quality Unit s.r.o.
* @package PostAffiliatePro
* @author Andrej Harsani
* @since Version 1.0.0
* $Id: AuthUser.class.php 36619 2012-01-09 16:21:38Z mkendera $
*
* Licensed under the Quality Unit, s.r.o. Standard End User License Agreement,
* Version 1.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.qualityunit.com/licenses/license
*
*/
/**
* @package PostAffiliatePro
*/
class Pap_AuthUser extends Gpf_Auth_User {
/**
* @var Gpf_Data_Record
*/
private $userData;
protected $userId;
protected $type;
public function getAttributes() {
$ret = parent::getAttributes();
if ($this->isLogged()) {
$user = new Pap_Common_User();
$user->setId($this->getPapUserId());
$user->load();
for ($i=1; $i<=25; $i++) {
$ret['data'.$i] = $user->get('data'.$i);
}
$ret[Pap_Db_Table_Users::PARENTUSERID] = $user->getParentUserId();
}
return $ret;
}
/**
* @param Gpf_Auth_Info $authInfo
* @return Gpf_SqlBuilder_SelectBuilder
*/
protected function createAuthSelect(Gpf_Auth_Info $authInfo) {
$select = parent::createAuthSelect($authInfo);
$select->select->add('pu.'.Pap_Db_Table_Users::REFID, 'refid');
$select->select->add('pu.'.Pap_Db_Table_Users::NUMBERUSERID, 'numberuserid');
$select->select->add('pu.'.Pap_Db_Table_Users::PHOTO, 'photo');
for ($i=1; $i<=25; $i++) {
$select->select->add('pu.'.Pap_Db_Table_Users::getDataColumnName($i), 'data'.$i);
}
$select->select->add('pu.'.Pap_Db_Table_Users::PARENTUSERID, Pap_Db_Table_Users::PARENTUSERID);
$select->select->add('pu.'.Pap_Db_Table_Users::ID, 'userid');
$select->select->add('pu.'.Pap_Db_Table_Users::TYPE, 'rtype');
$select->select->add('pu.'.Pap_Db_Table_Users::DATEINSERTED, 'dateinserted');
$select->select->add('pu.'.Pap_Db_Table_Users::DATEAPPROVED, 'dateapproved');
$select->from->addInnerJoin(Pap_Db_Table_Users::getName(), 'pu',
'pu.accountuserid=u.accountuserid');
$select->where->add('pu.'.Pap_Db_Table_Users::TYPE, '=', $authInfo->getRoleType());
return $select;
}
protected function loadAuthData(Gpf_Data_Record $data) {
parent::loadAuthData($data);
$this->userId = $data->get("userid");
$this->type = $data->get("rtype");
$this->userData = $data;
}
public function getUserData() {
return $this->userData;
}
public function isMerchant() {
return $this->type == Pap_Application::ROLETYPE_MERCHANT;
}
public function isAffiliate() {
return $this->type == Pap_Application::ROLETYPE_AFFILIATE;
}
public function getPapUserId() {
return $this->userId;
}
public function createAnonym() {
return new Pap_AnonymUser();
}
public function createPrivilegedUser() {
return new Pap_PrivilegedUser();
}
public function isMasterMerchant() {
return $this->isDefaultAccount() && $this->isMerchant();
}
public function isDefaultAccount() {
return $this->getAccountId() === Gpf_Db_Account::DEFAULT_ACCOUNT_ID;
}
public function isNetworkMerchant() {
return !$this->isDefaultAccount() && $this->isMerchant();
}
}
?>