| Línea 104... |
Línea 104... |
| 104 |
$conversationMapper = ConversationMapper::getInstance($this->adapter);
|
104 |
$conversationMapper = ConversationMapper::getInstance($this->adapter);
|
| 105 |
$messageMapper = MessageMapper::getInstance($this->adapter);
|
105 |
$messageMapper = MessageMapper::getInstance($this->adapter);
|
| 106 |
$conversations = [];
|
106 |
$conversations = [];
|
| 107 |
$selected_user_id = 0;
|
107 |
$selected_user_id = 0;
|
| Línea -... |
Línea 108... |
| - |
|
108 |
|
| - |
|
109 |
$uuid = $this->params()->fromRoute('uuid');
|
| - |
|
110 |
|
| - |
|
111 |
if ($uuid) {
|
| - |
|
112 |
$companyMapper = CompanyMapper::getInstance($this->adapter);
|
| - |
|
113 |
$company = $companyMapper->fetchOneByUuid($uuid);
|
| - |
|
114 |
|
| - |
|
115 |
if ($company) {
|
| - |
|
116 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
| - |
|
117 |
$companyUser = $companyUserMapper->fetchOwnerByCompanyId($company->id);
|
| - |
|
118 |
|
| - |
|
119 |
if(!in_array($companyUser->user_id, $user_blocked_ids) && !in_array($companyUser->id, $user_blocked_me_ids)) {
|
| - |
|
120 |
$user = $userMapper->fetchOne($companyUser->user_id);
|
| - |
|
121 |
|
| - |
|
122 |
|
| 108 |
|
123 |
$selected_user_id = $user->id;
|
| - |
|
124 |
$conversation = $conversationMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
|
| - |
|
125 |
|
| - |
|
126 |
|
| - |
|
127 |
$timeElapsedString = '';
|
| - |
|
128 |
if ($conversation) {
|
| - |
|
129 |
$unread = $messageMapper->fetchCountUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
|
| - |
|
130 |
$lastMessage = $messageMapper->fetchLastUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
|
| - |
|
131 |
|
| - |
|
132 |
if ($lastMessage) {
|
| - |
|
133 |
$timeElapsedString = $this->timeAgo($lastMessage, $now);
|
| - |
|
134 |
}
|
| - |
|
135 |
} else {
|
| - |
|
136 |
$unread = 0;
|
| - |
|
137 |
}
|
| - |
|
138 |
|
| - |
|
139 |
|
| - |
|
140 |
array_push($conversations, [
|
| - |
|
141 |
'uuid' => $company->uuid,
|
| - |
|
142 |
'name' => $company->name,
|
| - |
|
143 |
'last_message' => $timeElapsedString,
|
| - |
|
144 |
'count_unread' => $unread,
|
| - |
|
145 |
'selected' => 1,
|
| - |
|
146 |
'image' => $storage->getCompanyImage($company),
|
| - |
|
147 |
'profile' => $this->url()->fromRoute('company/view', ['id' => $company->uuid]),
|
| - |
|
148 |
'messages_link' => $this->url()->fromRoute('inmail/messages', ['uuid' => $user->uuid]),
|
| - |
|
149 |
'send_link' => $this->url()->fromRoute('inmail/messages/send', ['uuid' => $user->uuid]),
|
| - |
|
150 |
'delete_link' => $this->url()->fromRoute('inmail/messages/delete', ['uuid' => $user->uuid]),
|
| - |
|
151 |
]);
|
| - |
|
152 |
}
|
| - |
|
153 |
} else {
|
| - |
|
154 |
$user = $userMapper->fetchOneByUuid($uuid);
|
| - |
|
155 |
|
| - |
|
156 |
if ($user) {
|
| - |
|
157 |
if(!in_array($user->id, $user_blocked_ids) && !in_array($user->id, $user_blocked_me_ids)) {
|
| - |
|
158 |
|
| Línea -... |
Línea 159... |
| - |
|
159 |
$timeElapsedString = '';
|
| - |
|
160 |
|
| - |
|
161 |
$selected_user_id = $user->id;
|
| - |
|
162 |
$conversation = $conversationMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
|
| - |
|
163 |
if ($conversation) {
|
| 109 |
$records = $conversationMapper->fetchAllByUserId($currentUser->id);
|
164 |
$unread = $messageMapper->fetchCountUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
|
| - |
|
165 |
$lastMessage = $messageMapper->fetchLastUnreadMessagesByConversationIdAndReceiverId($conversation->id, $currentUser->id);
|
| - |
|
166 |
if ($lastMessage) {
|
| - |
|
167 |
$timeElapsedString = $this->timeAgo($lastMessage, $now);
|
| - |
|
168 |
}
|
| - |
|
169 |
} else {
|
| - |
|
170 |
$unread = 0;
|
| - |
|
171 |
}
|
| - |
|
172 |
|
| - |
|
173 |
|
| - |
|
174 |
array_push($conversations, [
|
| - |
|
175 |
'uuid' => $user->uuid,
|
| - |
|
176 |
'name' => trim($user->first_name . ' ' . $user->last_name),
|
| - |
|
177 |
'image' => $storage->getUserImage($user),
|
| - |
|
178 |
'profile' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
|
| - |
|
179 |
'last_message' => $timeElapsedString,
|
| - |
|
180 |
'count_unread' => $unread,
|
| - |
|
181 |
'selected' => 1,
|
| - |
|
182 |
'messages_link' => $this->url()->fromRoute('inmail/messages', ['uuid' => $user->uuid]),
|
| - |
|
183 |
'send_link' => $this->url()->fromRoute('inmail/messages/send', ['uuid' => $user->uuid]),
|
| - |
|
184 |
'delete_link' => $this->url()->fromRoute('inmail/messages/delete', ['uuid' => $user->uuid]),
|
| - |
|
185 |
]);
|
| - |
|
186 |
}
|
| - |
|
187 |
}
|
| - |
|
188 |
}
|
| - |
|
189 |
}
|
| - |
|
190 |
|
| Línea 110... |
Línea 191... |
| 110 |
|
191 |
|
| 111 |
$id = $this->params()->fromRoute('id');
|
192 |
$records = $conversationMapper->fetchAllByUserId($currentUser->id);
|
| 112 |
|
193 |
|
| 113 |
foreach ($records as $record) {
|
194 |
foreach ($records as $record) {
|