9921 |
nelberth |
1 |
<?php
|
|
|
2 |
declare(strict_types=1);
|
|
|
3 |
|
|
|
4 |
namespace LeadersLinked\Controller;
|
|
|
5 |
|
|
|
6 |
use Laminas\Authentication\AuthenticationService;
|
|
|
7 |
use Laminas\Authentication\Result as AuthResult;
|
|
|
8 |
use Laminas\Db\Adapter\AdapterInterface;
|
|
|
9 |
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
|
|
|
10 |
use Laminas\Mvc\Controller\AbstractActionController;
|
|
|
11 |
use Laminas\Mvc\I18n\Translator;
|
|
|
12 |
use Laminas\Log\LoggerInterface;
|
|
|
13 |
use Laminas\View\Model\ViewModel;
|
|
|
14 |
use Laminas\View\Model\JsonModel;
|
|
|
15 |
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
|
9931 |
nelberth |
16 |
use LeadersLinked\Form\CreateFeedForm;
|
|
|
17 |
use LeadersLinked\Library\Functions;
|
|
|
18 |
use LeadersLinked\Mapper\UserMapper;
|
9921 |
nelberth |
19 |
|
9931 |
nelberth |
20 |
use LeadersLinked\Mapper\CompanyMapper;
|
|
|
21 |
use LeadersLinked\Mapper\TopicMapper;
|
|
|
22 |
use LeadersLinked\Model\Feed;
|
11194 |
nelberth |
23 |
use LeadersLinked\Model\HighPerformanceTeamsGroups;
|
9931 |
nelberth |
24 |
use LeadersLinked\Mapper\FeedMapper;
|
|
|
25 |
use LeadersLinked\Mapper\HighPerformanceTeamsGroupsMapper;
|
|
|
26 |
use LeadersLinked\Model\HighPerformanceTeamsGroupsMembers;
|
|
|
27 |
use LeadersLinked\Form\HighPerformanceTeamsGroupsMembersForm;
|
|
|
28 |
use LeadersLinked\Mapper\HighPerformanceTeamsGroupsMembersMapper;
|
|
|
29 |
|
9921 |
nelberth |
30 |
class HighPerformanceTeamsGroupsViewForoArticlesViewController extends AbstractActionController
|
|
|
31 |
{
|
|
|
32 |
/**
|
|
|
33 |
*
|
|
|
34 |
* @var AdapterInterface
|
|
|
35 |
*/
|
|
|
36 |
private $adapter;
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
/**
|
|
|
40 |
*
|
|
|
41 |
* @var AbstractAdapter
|
|
|
42 |
*/
|
|
|
43 |
private $cache;
|
|
|
44 |
|
|
|
45 |
/**
|
|
|
46 |
*
|
|
|
47 |
* @var LoggerInterface
|
|
|
48 |
*/
|
|
|
49 |
private $logger;
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
*
|
|
|
53 |
* @var array
|
|
|
54 |
*/
|
|
|
55 |
private $config;
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
/**
|
|
|
60 |
*
|
|
|
61 |
* @param AdapterInterface $adapter
|
|
|
62 |
* @param AbstractAdapter $cache
|
|
|
63 |
* @param LoggerInterface $logger
|
|
|
64 |
* @param array $config
|
|
|
65 |
*/
|
|
|
66 |
public function __construct($adapter, $cache , $logger, $config)
|
|
|
67 |
{
|
|
|
68 |
$this->adapter = $adapter;
|
|
|
69 |
$this->cache = $cache;
|
|
|
70 |
$this->logger = $logger;
|
|
|
71 |
$this->config = $config;
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
public function indexAction()
|
|
|
77 |
{
|
9932 |
nelberth |
78 |
|
|
|
79 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
80 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
81 |
$currentCompany = $currentUserPlugin->getCompany();
|
11085 |
nelberth |
82 |
$group_uuid = $this->params()->fromRoute('group_id');
|
|
|
83 |
$category_uuid = $this->params()->fromRoute('category_id');
|
|
|
84 |
$article_uuid = $this->params()->fromRoute('article_id');
|
9932 |
nelberth |
85 |
$request = $this->getRequest();
|
10121 |
nelberth |
86 |
|
9931 |
nelberth |
87 |
if(!$group_uuid) {
|
|
|
88 |
$data = [
|
|
|
89 |
'success' => false,
|
|
|
90 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
91 |
];
|
|
|
92 |
|
|
|
93 |
return new JsonModel($data);
|
|
|
94 |
}
|
11193 |
nelberth |
95 |
if(!$article_uuid) {
|
|
|
96 |
$data = [
|
|
|
97 |
'success' => false,
|
|
|
98 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
99 |
];
|
|
|
100 |
|
|
|
101 |
return new JsonModel($data);
|
|
|
102 |
}
|
9931 |
nelberth |
103 |
if(!$category_uuid) {
|
|
|
104 |
$data = [
|
|
|
105 |
'success' => false,
|
|
|
106 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
107 |
];
|
|
|
108 |
|
|
|
109 |
return new JsonModel($data);
|
|
|
110 |
}
|
|
|
111 |
|
11193 |
nelberth |
112 |
|
9931 |
nelberth |
113 |
$highPerformanceTeamsGroupsMapper = HighPerformanceTeamsGroupsMapper::getInstance($this->adapter);
|
|
|
114 |
$highPerformanceTeamsGroups = $highPerformanceTeamsGroupsMapper->fetchOneByUuid($group_uuid);
|
11193 |
nelberth |
115 |
$this->layout()->setTemplate('layout/layout-backend');
|
|
|
116 |
$viewModel = new ViewModel();
|
9931 |
nelberth |
117 |
if (!$highPerformanceTeamsGroups) {
|
11193 |
nelberth |
118 |
$viewModel->setTemplate('leaders-linked/no-access/index.phtml');
|
|
|
119 |
return $viewModel;
|
|
|
120 |
}
|
|
|
121 |
if($highPerformanceTeamsGroups->status != HighPerformanceTeamsGroups::STATUS_ACTIVE) {
|
|
|
122 |
$viewModel->setTemplate('leaders-linked/no-access/index.phtml');
|
|
|
123 |
return $viewModel;
|
9931 |
nelberth |
124 |
|
11193 |
nelberth |
125 |
}
|
|
|
126 |
$highPerformanceTeamsGroupsMembersMapper = HighPerformanceTeamsGroupsMembersMapper::getInstance($this->adapter);
|
|
|
127 |
$highPerformanceTeamsGroupsMember = $highPerformanceTeamsGroupsMembersMapper->fetchOneByGroupIdAndUserId($highPerformanceTeamsGroups->id, $currentUser->id);
|
9931 |
nelberth |
128 |
if(!$highPerformanceTeamsGroupsMember) {
|
11193 |
nelberth |
129 |
$viewModel->setTemplate('leaders-linked/no-access/index.phtml');
|
|
|
130 |
return $viewModel;
|
9931 |
nelberth |
131 |
}
|
|
|
132 |
if(!($highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ACCEPTED || $highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ADDED_BY_ADMIN) ){
|
11193 |
nelberth |
133 |
$viewModel->setTemplate('leaders-linked/no-access/index.phtml');
|
|
|
134 |
return $viewModel;
|
9931 |
nelberth |
135 |
}
|
|
|
136 |
|
11193 |
nelberth |
137 |
$topicMapper = TopicMapper::getInstance($this->adapter);
|
|
|
138 |
$topic = $topicMapper->fetchOneByUuidAndGroupId($category_uuid,$highPerformanceTeamsGroups->id);
|
|
|
139 |
|
|
|
140 |
if(!$topic){
|
|
|
141 |
$viewModel->setTemplate('leaders-linked/no-access/index.phtml');
|
|
|
142 |
return $viewModel;
|
|
|
143 |
}
|
|
|
144 |
|
9921 |
nelberth |
145 |
if($request->isGet()) {
|
9931 |
nelberth |
146 |
$formAdd = new CreateFeedForm($this->adapter);
|
9921 |
nelberth |
147 |
$this->layout()->setTemplate('layout/layout-backend');
|
|
|
148 |
$viewModel = new ViewModel();
|
9930 |
nelberth |
149 |
$viewModel->setTemplate('leaders-linked/high-performance-teams-groups-view-foro-articles-view/index.phtml');
|
9931 |
nelberth |
150 |
$viewModel->setVariables([
|
|
|
151 |
'formAdd' => $formAdd,
|
|
|
152 |
'group_uuid'=>$group_uuid,
|
|
|
153 |
'group_title'=>$highPerformanceTeamsGroups->title,
|
10121 |
nelberth |
154 |
'category_uuid'=>$category_uuid,
|
|
|
155 |
'article_uuid'=>$article_uuid
|
9931 |
nelberth |
156 |
]);
|
9921 |
nelberth |
157 |
return $viewModel ;
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
} else {
|
|
|
161 |
return new JsonModel([
|
|
|
162 |
'success' => false,
|
|
|
163 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
164 |
]);;
|
|
|
165 |
}
|
|
|
166 |
}
|
|
|
167 |
}
|