Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 16769 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 16769 Rev 16798
Línea 105... Línea 105...
105
        $this->logger       = $logger;
105
        $this->logger       = $logger;
106
        $this->config       = $config;
106
        $this->config       = $config;
107
        $this->translator   = $translator;
107
        $this->translator   = $translator;
108
    }
108
    }
Línea -... Línea 109...
-
 
109
 
-
 
110
    public function searchPeopleByCompanyAction()
-
 
111
    {
-
 
112
        $request = $this->getRequest();
-
 
113
        if ($request->isGet()) {
-
 
114
            
-
 
115
            $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
116
            $currentUser = $currentUserPlugin->getUser();
-
 
117
            $currentCompany = $currentUserPlugin->getCompany();
-
 
118
            
-
 
119
            $search = Functions::sanitizeFilterString($this->params()->fromQuery('search'));
-
 
120
            if (strlen($search) >= 3) {
-
 
121
                
-
 
122
                
-
 
123
                $userMapper = UserMapper::getInstance($this->adapter);
-
 
124
                $records  = $userMapper->fetchAllByNetworkIdAndCompanyIdAndSearch($currentUser->network_id, $currentCompany->id,  $search);
-
 
125
                
-
 
126
                $users = [];
-
 
127
                foreach ($records as $record) {
-
 
128
 
-
 
129
                    
-
 
130
                    array_push($users, [
-
 
131
                        'id' => $record->uuid,
-
 
132
                        'text' => trim($record->first_name . ' ' . $record->last_name) . ' (' . $record->email . ')'
-
 
133
                        
-
 
134
                    ]);
-
 
135
                }
-
 
136
                
-
 
137
                return new JsonModel([
-
 
138
                    'success' => true,
-
 
139
                    'data' => $users
-
 
140
                ]);
-
 
141
            } else {
-
 
142
                return new JsonModel([
-
 
143
                    'success' => true,
-
 
144
                    'data' => []
-
 
145
                ]);
-
 
146
            }
-
 
147
        } else {
-
 
148
            return new JsonModel([
-
 
149
                'success' => false,
-
 
150
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
151
            ]);
-
 
152
        }
Línea 109... Línea 153...
109
 
153
    }
110
 
154
 
111
        
155