Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16768 | Rev 16798 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
16766 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Controller;
6
 
7
use Laminas\Db\Adapter\AdapterInterface;
16768 efrain 8
 
16766 efrain 9
use Laminas\Mvc\Controller\AbstractActionController;
10
use Laminas\Log\LoggerInterface;
11
use Laminas\View\Model\JsonModel;
12
use LeadersLinked\Mapper\CalendarEventMapper;
13
use LeadersLinked\Mapper\CompanyFollowerMapper;
14
use LeadersLinked\Mapper\CompanyServiceMapper;
15
use LeadersLinked\Mapper\JobDescriptionMapper;
16
use LeadersLinked\Mapper\PerformanceEvaluationFormMapper;
17
use LeadersLinked\Mapper\PerformanceEvaluationTestMapper;
18
use LeadersLinked\Mapper\QueryMapper;
19
use LeadersLinked\Mapper\RecruitmentSelectionCandidateMapper;
20
use LeadersLinked\Mapper\RecruitmentSelectionInterviewMapper;
21
use LeadersLinked\Mapper\RecruitmentSelectionVacancyMapper;
22
use LeadersLinked\Mapper\UserMapper;
23
use LeadersLinked\Mapper\ZoomMeetingMapper;
24
use LeadersLinked\Library\Functions;
25
use LeadersLinked\Mapper\UserNotificationSettingMapper;
26
 
27
use LeadersLinked\Model\CalendarEvent;
28
use LeadersLinked\Model\PerformanceEvaluationTest;
29
use LeadersLinked\Model\RecruitmentSelectionInterview;
30
use LeadersLinked\Model\User;
31
use LeadersLinked\Mapper\ConnectionMapper;
32
use LeadersLinked\Mapper\ProfileVisitMapper;
33
use LeadersLinked\Mapper\GroupMemberMapper;
34
use LeadersLinked\Model\GroupMember;
35
use LeadersLinked\Mapper\GroupMapper;
36
use LeadersLinked\Model\Group;
37
use Laminas\Db\Sql\Expression;
38
use LeadersLinked\Mapper\CompanyUserMapper;
39
use LeadersLinked\Model\CompanyUser;
40
use LeadersLinked\Model\UserType;
41
use LeadersLinked\Mapper\CompanyMicrolearningCapsuleUserMapper;
42
use LeadersLinked\Model\Notification;
43
use LeadersLinked\Mapper\NotificationMapper;
44
use LeadersLinked\Mapper\EmailTemplateMapper;
45
use LeadersLinked\Model\EmailTemplate;
46
use LeadersLinked\Library\QueueEmail;
47
use LeadersLinked\Mapper\PostMapper;
48
use LeadersLinked\Mapper\CompanyMapper;
49
use LeadersLinked\Model\Company;
50
use LeadersLinked\Model\Connection;
51
use LeadersLinked\Model\Service;
52
use LeadersLinked\Mapper\DailyPulseEmojiMapper;
53
use LeadersLinked\Mapper\UserProfileMapper;
54
use LeadersLinked\Mapper\NetworkMapper;
55
use LeadersLinked\Model\Network;
56
use LeadersLinked\Mapper\LocationMapper;
57
 
58
class HelperController extends AbstractActionController
59
{
60
    /**
61
     *
16769 efrain 62
     * @var \Laminas\Db\Adapter\AdapterInterface
16766 efrain 63
     */
64
    private $adapter;
16768 efrain 65
 
16766 efrain 66
    /**
67
     *
16769 efrain 68
     * @var \LeadersLinked\Cache\CacheInterface
16766 efrain 69
     */
16769 efrain 70
    private $cache;
71
 
72
 
73
    /**
74
     *
75
     * @var \Laminas\Log\LoggerInterface
76
     */
16766 efrain 77
    private $logger;
16768 efrain 78
 
16766 efrain 79
    /**
80
     *
81
     * @var array
82
     */
83
    private $config;
16768 efrain 84
 
16769 efrain 85
 
16766 efrain 86
    /**
87
     *
16769 efrain 88
     * @var \Laminas\Mvc\I18n\Translator
89
     */
90
    private $translator;
91
 
92
 
93
    /**
94
     *
95
     * @param \Laminas\Db\Adapter\AdapterInterface $adapter
96
     * @param \LeadersLinked\Cache\CacheInterface $cache
97
     * @param \Laminas\Log\LoggerInterface LoggerInterface $logger
16766 efrain 98
     * @param array $config
16769 efrain 99
     * @param \Laminas\Mvc\I18n\Translator $translator
16766 efrain 100
     */
16769 efrain 101
    public function __construct($adapter, $cache, $logger, $config, $translator)
16766 efrain 102
    {
16769 efrain 103
        $this->adapter      = $adapter;
104
        $this->cache        = $cache;
105
        $this->logger       = $logger;
106
        $this->config       = $config;
107
        $this->translator   = $translator;
16766 efrain 108
    }
109
 
110
 
111
 
112
    public function searchPeopleAction()
113
    {
114
        $request = $this->getRequest();
115
        if ($request->isGet()) {
116
 
117
            $currentUserPlugin = $this->plugin('currentUserPlugin');
118
            $currentUser = $currentUserPlugin->getUser();
119
 
120
            $search = Functions::sanitizeFilterString($this->params()->fromQuery('search'));
121
            if (strlen($search) >= 3) {
122
 
123
 
124
                $userMapper = UserMapper::getInstance($this->adapter);
125
                $records  = $userMapper->fetchAllSuggestByNetworkIdAndSearch($currentUser->network_id, $search);
126
 
127
                $users = [];
128
                foreach ($records as $record) {
129
                    if ($currentUser->id == $record->id) {
130
                        continue;
131
                    }
132
 
133
 
134
                    array_push($users, [
135
                        'id' => $record->uuid,
136
                        'text' => trim($record->first_name . ' ' . $record->last_name) . ' (' . $record->email . ')'
137
 
138
                    ]);
139
                }
140
 
141
                return new JsonModel([
142
                    'success' => true,
143
                    'data' => $users
144
                ]);
145
            } else {
146
                return new JsonModel([
147
                    'success' => true,
148
                    'data' => []
149
                ]);
150
            }
151
        } else {
152
            return new JsonModel([
153
                'success' => false,
154
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
155
            ]);
156
        }
157
    }
158
}