Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 3712 Rev 4842
Línea 34... Línea 34...
34
use LeadersLinked\Mapper\NotificationMapper;
34
use LeadersLinked\Mapper\NotificationMapper;
35
use LeadersLinked\Mapper\UserNotificationSettingMapper;
35
use LeadersLinked\Mapper\UserNotificationSettingMapper;
36
use LeadersLinked\Mapper\EmailTemplateMapper;
36
use LeadersLinked\Mapper\EmailTemplateMapper;
37
use LeadersLinked\Model\EmailTemplate;
37
use LeadersLinked\Model\EmailTemplate;
38
use LeadersLinked\Library\QueueEmail;
38
use LeadersLinked\Library\QueueEmail;
-
 
39
use LeadersLinked\Model\Network;
Línea 39... Línea 40...
39
 
40
 
40
class ConnectionController extends AbstractActionController
41
class ConnectionController extends AbstractActionController
41
{
42
{
42
    /**
43
    /**
Línea 98... Línea 99...
98
    public function myConnectionsAction()
99
    public function myConnectionsAction()
99
    {
100
    {
100
        $currentUserPlugin = $this->plugin('currentUserPlugin');
101
        $currentUserPlugin = $this->plugin('currentUserPlugin');
101
        $currentUser = $currentUserPlugin->getUser();
102
        $currentUser = $currentUserPlugin->getUser();
Línea -... Línea 103...
-
 
103
        
-
 
104
        $currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
-
 
105
        $currentNetwork= $currentNetworkPlugin->getNetwork();
-
 
106
        
102
        
107
        
103
        $request = $this->getRequest();
108
        $request = $this->getRequest();
Línea 104... Línea 109...
104
        if($request->isGet()) {
109
        if($request->isGet()) {
Línea 120... Línea 125...
120
                    
125
                    
121
                }
126
                }
Línea 122... Línea 127...
122
            }
127
            }
-
 
128
            
-
 
129
            if($isJson) {
-
 
130
                
-
 
131
               
-
 
132
                
123
            
133
                
Línea 124... Línea 134...
124
            if($isJson) {
134
                $page       = (int) filter_var($this->params()->fromQuery('page'), FILTER_SANITIZE_NUMBER_INT);
125
                $search = trim(filter_var($this->params()->fromQuery('search', ''), FILTER_SANITIZE_STRING));
-
 
Línea -... Línea 135...
-
 
135
                $search = trim(filter_var($this->params()->fromQuery('search', ''), FILTER_SANITIZE_STRING));
-
 
136
                
-
 
137
                
126
                
138
                $connectionMapper = ConnectionMapper::getInstance($this->adapter);
127
                
139
                
128
                $connectionMapper = ConnectionMapper::getInstance($this->adapter);
140
                if($currentNetwork->relationship_user_mode == Network::RELATIONSHIP_USER_MODE_USER_2_USER)  {
-
 
141
                    $user_ids = $connectionMapper->fetchAllConnectionsByUserReturnIds($currentUser->id);
-
 
142
                    
-
 
143
                    $userBlockedMapper = UserBlockedMapper::getInstance($this->adapter);
-
 
144
                    $user_blocked_ids = $userBlockedMapper->fetchAllBlockedReturnIds($currentUser->id);
Línea 129... Línea 145...
129
                $user_ids = $connectionMapper->fetchAllConnectionsByUserReturnIds($currentUser->id);
145
                    $user_ids = array_diff($user_ids, $user_blocked_ids);
Línea 130... Línea 146...
130
                
146
                }
-
 
147
                
-
 
148
                
131
                $userBlockedMapper = UserBlockedMapper::getInstance($this->adapter);
149
               
-
 
150
 
-
 
151
                $queryMapper = QueryMapper::getInstance($this->adapter);
-
 
152
                
132
                $user_blocked_ids = $userBlockedMapper->fetchAllBlockedReturnIds($currentUser->id);
153
                $select = $queryMapper->getSql()->select(UserMapper::_TABLE);
133
                $user_ids = array_diff($user_ids, $user_blocked_ids);
154
                
Línea 134... Línea 155...
134
 
155
                if($currentNetwork->relationship_user_mode == Network::RELATIONSHIP_USER_MODE_USER_2_USER)  {
135
                $queryMapper = QueryMapper::getInstance($this->adapter);
156
                    $select->where->in('id', $user_ids); 
136
                
157
                } else {
137
                $select = $queryMapper->getSql()->select(UserMapper::_TABLE);
158
                    $select->where->notEqualTo('id', $currentUser->id);
Línea -... Línea 159...
-
 
159
                }
-
 
160
                $select->where->equalTo('status', User::STATUS_ACTIVE);
-
 
161
                $select->where->equalTo('network_id', $currentUser->network_id);
-
 
162
                
-
 
163
                if($search) {
-
 
164
                    $select->where->NEST->like('first_name', '%' . $search . '%')->or->like('last_name', '%' . $search . '%')->UNNEST;
138
                $select->where->in('id', $user_ids); 
165
                }
139
                $select->where->equalTo('status', User::STATUS_ACTIVE);
166
                $select->order('first_name ASC, last_name ASC');
140
                $select->where->equalTo('network_id', $currentUser->network_id);
167
                
141
                
168
                $dbSelect = new DbSelect($select, $this->adapter);
Línea -... Línea 169...
-
 
169
                $paginator = new Paginator($dbSelect);
-
 
170
                $paginator->setCurrentPageNumber($page ? $page : 1);
-
 
171
                $paginator->setItemCountPerPage(10);
Línea 142... Línea 172...
142
                if($search) {
172
                
143
                    $select->where->NEST->like('first_name', '%' . $search . '%')->or->like('last_name', '%' . $search . '%')->UNNEST;
173
                
144
                }
174
                $records = $paginator->getCurrentItems();
145
                $select->order('first_name ASC, last_name ASC');
175
                $items = [];
146
                
176
                foreach($records as $record)
147
                $records = $queryMapper->fetchAll($select);
-
 
148
                $items = [];
-
 
-
 
177
                {
Línea 149... Línea 178...
149
                foreach($records as $record)
178
 
Línea -... Línea 179...
-
 
179
                   
-
 
180
                    
-
 
181
                    
-
 
182
                    
-
 
183
                    $item = [
-
 
184
                        'name' => trim($record['first_name'] . ' ' . $record['last_name']),
-
 
185
                        'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $record['uuid'], 'filename' => $record['image'] ]),
-
 
186
                        'link_view' => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']  ]),
-
 
187
                        'link_inmail'   => $this->url()->fromRoute('inmail', ['id' => $record['uuid']  ]),
-
 
188
 
Línea 150... Línea 189...
150
                {
189
 
151
 
190
                    ];
Línea 152... Línea -...
152
                    
-
 
153
                    $item = [
191
                    
154
                        'name' => trim($record['first_name'] . ' ' . $record['last_name']),
192
                    if($currentNetwork->relationship_user_mode == Network::RELATIONSHIP_USER_MODE_ALL_2_ALL) {
155
                        'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $record['uuid'], 'filename' => $record['image'] ]),
193
                        $item['link_cancel'] = '';
-
 
194
                        $item['link_block'] = '';
-
 
195
                        
-
 
196
                    } else {
-
 
197
                        $item['link_cancel'] = $this->url()->fromRoute('connection/cancel', ['id' => $record['uuid']  ]);
-
 
198
                        $item['link_block'] = $this->url()->fromRoute('connection/block', ['id' => $record['uuid']  ]);
-
 
199
                    }
-
 
200
                    
-
 
201
                    
-
 
202
 
-
 
203
                    
156
                        'link_view' => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']  ]),
204
                    array_push($items, $item);
157
                        'link_inmail'   => $this->url()->fromRoute('inmail', ['id' => $record['uuid']  ]),
205
                }
158
                        'link_cancel' => $this->url()->fromRoute('connection/cancel', ['id' => $record['uuid']  ]),
206
                
Línea 159... Línea 207...
159
                        'link_block'=> $this->url()->fromRoute('connection/block', ['id' => $record['uuid']  ]),
207