| 1 |
www |
1 |
<?php
|
|
|
2 |
namespace LeadersLinked\Helper;
|
|
|
3 |
|
|
|
4 |
use Laminas\View\Helper\AbstractHelper;
|
|
|
5 |
use Laminas\Db\Adapter\AdapterInterface;
|
|
|
6 |
use LeadersLinked\Mapper\UserMapper;
|
|
|
7 |
use LeadersLinked\Model\UserType;
|
| 1445 |
efrain |
8 |
use LeadersLinked\Mapper\ConnectionMapper;
|
|
|
9 |
use LeadersLinked\Mapper\LocationMapper;
|
|
|
10 |
use LeadersLinked\Mapper\ProfileVisitMapper;
|
| 4283 |
efrain |
11 |
use LeadersLinked\Model\SelfEvaluationFormUser;
|
|
|
12 |
use LeadersLinked\Mapper\SelfEvaluationFormUserMapper;
|
| 4113 |
efrain |
13 |
use LeadersLinked\Mapper\QueryMapper;
|
|
|
14 |
use Laminas\Db\Sql\Expression;
|
| 4283 |
efrain |
15 |
use LeadersLinked\Mapper\SelfEvaluationFormMapper;
|
|
|
16 |
use LeadersLinked\Model\SelfEvaluationForm;
|
| 4842 |
efrain |
17 |
use LeadersLinked\Mapper\NetworkMapper;
|
|
|
18 |
use LeadersLinked\Model\Network;
|
|
|
19 |
use LeadersLinked\Mapper\CompanyMapper;
|
|
|
20 |
use LeadersLinked\Mapper\CompanyUserMapper;
|
|
|
21 |
use LeadersLinked\Model\CompanyUser;
|
| 1 |
www |
22 |
|
|
|
23 |
class MenuHelper extends AbstractHelper
|
|
|
24 |
{
|
|
|
25 |
/**
|
|
|
26 |
*
|
|
|
27 |
* @var AdapterInterface
|
|
|
28 |
*/
|
|
|
29 |
private $adapter;
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
*
|
|
|
33 |
* @var array
|
|
|
34 |
*/
|
|
|
35 |
private $config;
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
/**
|
|
|
39 |
*
|
|
|
40 |
* @param AdapterInterface $adapter
|
|
|
41 |
* @param array $config
|
|
|
42 |
*/
|
|
|
43 |
public function __construct($adapter, $config)
|
|
|
44 |
{
|
|
|
45 |
$this->adapter = $adapter;
|
|
|
46 |
$this->config = $config;
|
|
|
47 |
}
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
*
|
|
|
51 |
* @param int $user_id
|
|
|
52 |
* @return string
|
|
|
53 |
*/
|
|
|
54 |
public function __invoke($user_id)
|
|
|
55 |
{
|
| 1445 |
efrain |
56 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
57 |
$user = $userMapper->fetchOne($user_id);
|
| 1 |
www |
58 |
|
| 5765 |
efrain |
59 |
|
|
|
60 |
$pages = [];
|
|
|
61 |
|
| 1662 |
efrain |
62 |
if($user) {
|
| 4113 |
efrain |
63 |
|
| 4842 |
efrain |
64 |
$networkMapper = NetworkMapper::getInstance($this->adapter);
|
|
|
65 |
$network = $networkMapper->fetchOne($user->network_id);
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
if($network->default == Network::DEFAULT_YES) {
|
|
|
70 |
if($network->relationship_user_mode == Network::RELATIONSHIP_USER_MODE_USER_2_USER) {
|
|
|
71 |
$pages = getAclMenuDefaultNetworkConnectionUser2User();
|
|
|
72 |
} else {
|
|
|
73 |
$pages = getAclMenuDefaultNetworkConnectionAll2All();
|
|
|
74 |
}
|
|
|
75 |
} else {
|
|
|
76 |
if($network->relationship_user_mode == Network::RELATIONSHIP_USER_MODE_USER_2_USER) {
|
|
|
77 |
|
|
|
78 |
$pages = getAclMenuNonDefaulNetworkConnectionUser2User();
|
|
|
79 |
|
|
|
80 |
} else {
|
|
|
81 |
$pages = getAclMenuNonDefaultNetworkConnectionAll2All();
|
|
|
82 |
}
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
|
| 4114 |
efrain |
86 |
/*
|
| 4113 |
efrain |
87 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
88 |
|
|
|
89 |
$select = $queryMapper->getSql()->select();
|
|
|
90 |
$select->columns(['total' => new Expression('COUNT(*)')]);
|
| 4283 |
efrain |
91 |
$select->from(['u' => SelfEvaluationFormUserMapper::_TABLE]);
|
|
|
92 |
$select->join(['f' => SelfEvaluationFormMapper::_TABLE], 'u.form_id = f.id');
|
| 4113 |
efrain |
93 |
$select->where->equalTo('u.user_i', $user_id);
|
| 4283 |
efrain |
94 |
$select->where->equalTo('f.status', SelfEvaluationForm::STATUS_ACTIVE);
|
| 4113 |
efrain |
95 |
|
|
|
96 |
|
|
|
97 |
$record = $queryMapper->fetchOne($select);
|
|
|
98 |
$access_for_self_evaluation = $record['total'] > 0;
|
|
|
99 |
|
| 4114 |
efrain |
100 |
*/
|
| 4113 |
efrain |
101 |
|
| 1662 |
efrain |
102 |
$user_uuid = $user->uuid;
|
|
|
103 |
$fullname = trim($user->first_name . ' ' . $user->last_name);
|
| 1445 |
efrain |
104 |
|
| 1662 |
efrain |
105 |
$profileVisitMapper = ProfileVisitMapper::getInstance($this->adapter);
|
|
|
106 |
$visits = $profileVisitMapper->getTotalByVisitedId($user->id);
|
|
|
107 |
|
|
|
108 |
$connectionMapper = ConnectionMapper::getInstance($this->adapter);
|
|
|
109 |
$connections = $connectionMapper->fetchTotalConnectionByUser($user->id);
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
if($user->location_id) {
|
|
|
113 |
$locationMapper = LocationMapper::getInstance($this->adapter);
|
|
|
114 |
$location = $locationMapper->fetchOne($user->location_id);
|
|
|
115 |
|
|
|
116 |
$country = $location->country;
|
|
|
117 |
} else {
|
|
|
118 |
$country = '';
|
|
|
119 |
}
|
|
|
120 |
|
| 7329 |
efrain |
121 |
|
| 1662 |
efrain |
122 |
|
|
|
123 |
|
|
|
124 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
125 |
$user = $userMapper->fetchOne($user_id);
|
| 7329 |
efrain |
126 |
|
|
|
127 |
|
|
|
128 |
|
| 1662 |
efrain |
129 |
if($user && $user->usertype_id == UserType::ADMIN) {
|
|
|
130 |
$link_admin = '/backend/signin-admin';
|
|
|
131 |
} else {
|
|
|
132 |
$link_admin = '';
|
|
|
133 |
}
|
| 4842 |
efrain |
134 |
|
| 7329 |
efrain |
135 |
|
|
|
136 |
|
| 4842 |
efrain |
137 |
$link_company = '';
|
|
|
138 |
if($network->default != Network::DEFAULT_YES) {
|
|
|
139 |
$companyMapper = CompanyMapper::getInstance($this->adapter);
|
|
|
140 |
$company = $companyMapper->fetchDefaultForNetworkByNetworkId($network->id);
|
|
|
141 |
if($company) {
|
|
|
142 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
|
|
143 |
$companyUser = $companyUserMapper->fetchOneByCompanyIdAndUserId($company->id, $user->id);
|
|
|
144 |
if($companyUser) {
|
|
|
145 |
if($companyUser && $companyUser->status == CompanyUser::STATUS_ACCEPTED && $companyUser->backend == CompanyUser::BACKEND_YES ) {
|
|
|
146 |
$link_company = ['route' => 'backend/signin-company', 'id' => $company->uuid ];
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
}
|
|
|
150 |
}
|
|
|
151 |
|
| 1445 |
efrain |
152 |
} else {
|
| 1662 |
efrain |
153 |
$user_uuid= '';
|
|
|
154 |
$fullname = '';
|
| 1445 |
efrain |
155 |
$country = '';
|
| 1662 |
efrain |
156 |
$visits = 0;
|
|
|
157 |
$connections = 0;
|
|
|
158 |
$link_admin = '';
|
| 4842 |
efrain |
159 |
$link_company = '';
|
| 1445 |
efrain |
160 |
}
|
|
|
161 |
|
|
|
162 |
$data = [
|
| 1662 |
efrain |
163 |
'user_uuid' => $user_uuid,
|
|
|
164 |
'fullname' => $fullname,
|
| 1445 |
efrain |
165 |
'country' => $country,
|
|
|
166 |
'visits' => $visits,
|
|
|
167 |
'connections' => $connections,
|
| 4842 |
efrain |
168 |
'link_admin' => $link_admin,
|
|
|
169 |
'link_company' => $link_company,
|
|
|
170 |
'pages' => $pages
|
| 1445 |
efrain |
171 |
];
|
|
|
172 |
|
|
|
173 |
return $this->getView()->render('helpers/menu.phtml', $data);
|
| 1 |
www |
174 |
}
|
|
|
175 |
}
|