Proyectos de Subversion LeadersLinked - Services

Rev

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

Rev 268 Rev 283
Línea 25... Línea 25...
25
use LeadersLinked\Mapper\AbuseReportMapper;
25
use LeadersLinked\Mapper\AbuseReportMapper;
26
use LeadersLinked\Model\AbuseReport;
26
use LeadersLinked\Model\AbuseReport;
27
use LeadersLinked\Library\ExternalCredentials;
27
use LeadersLinked\Library\ExternalCredentials;
28
use LeadersLinked\Library\Storage;
28
use LeadersLinked\Library\Storage;
29
use LeadersLinked\Form\InMail\SendForm;
29
use LeadersLinked\Form\InMail\SendForm;
30
use PHPMailer\PHPMailer\PHPMailer;
30
use Eden\Mail\File;
-
 
31
 
Línea 31... Línea 32...
31
 
32
 
32
 
33
 
33
class InMailController extends AbstractActionController
34
class InMailController extends AbstractActionController
34
{
-
 
-
 
35
{
Línea 35... Línea 36...
35
    const _SIZE_PAGE = 10;
36
    const _SIZE_PAGE = 10;
36
    const _USE_S3 = false;
37
 
37
    
38
    
38
    /**
39
    /**
Línea 119... Línea 120...
119
            $currentUserPlugin = $this->plugin('currentUserPlugin');
120
            $currentUserPlugin = $this->plugin('currentUserPlugin');
120
            $currentUser = $currentUserPlugin->getUser();
121
            $currentUser = $currentUserPlugin->getUser();
Línea 121... Línea 122...
121
            
122
            
Línea 122... Línea -...
122
            $page = intval($this->params()->fromQuery('page', 0), 10);
-
 
123
            
123
            $page = intval($this->params()->fromQuery('page', 0), 10);
124
            if(self::_USE_S3) {
-
 
125
                $storage = Storage::getInstance($this->config);
-
 
126
            } else {
-
 
127
                $storage = '';
124
            
128
            }
125
            $storage = Storage::getInstance($this->config);
129
 
126
            
Línea 130... Línea 127...
130
            $externalCredentials = ExternalCredentials::getInstancia($this->config, $this->adapter);
127
            $externalCredentials = ExternalCredentials::getInstancia($this->config, $this->adapter);
131
            $externalCredentials->getUserBy($currentUser->id);
128
            $externalCredentials->getUserBy($currentUser->id);
Línea 210... Línea 207...
210
                 
207
                 
211
                        
208
                        
212
                        $message =  [
209
                        $message =  [
213
                            'uuid' => $user->uuid,
210
                            'uuid' => $user->uuid,
214
                            'name' => $user->first_name . ' ' . $user->last_name,
211
                            'name' => $user->first_name . ' ' . $user->last_name,
215
                            'image' => $storage ? $storage->getUserImage($user) : $this->url()->fromRoute('storage', ['code' => $user->uuid, 'type' => '$user', 'filename' => $user->image]), 
212
                            'image' => $storage->getUserImage($user), 
216
                            'subject' => $email['subject'],
213
                            'subject' => $email['subject'],
-
 
214
                            'date' => date('Y-m-d h:i a', $email['date']),
217
                            'date' => date('Y-m-d h:i a', $email['date']),
215
                            'seen' => $seen,
218
                            'seen' => $seen,
216
                            'email_id' => $email['uid'],
219
                            'block_link' => $this->url()->fromRoute('inmail/user/block',[ 'id' => $user->uuid ], ['force_canonical' => true]),
217
                            'block_link' => $this->url()->fromRoute('inmail/user/block',[ 'id' => $user->uuid ], ['force_canonical' => true]),
220
                            'send_link' => $this->url()->fromRoute('inmail/message/send',[ 'id' => $user->uuid ], ['force_canonical' => true]),
218
                            'send_link' => $this->url()->fromRoute('inmail/message/send',[ 'id' => $user->uuid ], ['force_canonical' => true]),
221
                            'get_link' =>  $this->url()->fromRoute('inmail/message/get',[ 'id' => $email['uid'] ], ['force_canonical' => true]),
219
                            'get_link' =>  $this->url()->fromRoute('inmail/message/get',[ 'id' => $email['uid'] ], ['force_canonical' => true]),
Línea 512... Línea 510...
512
            $currentUserPlugin = $this->plugin('currentUserPlugin');
510
            $currentUserPlugin = $this->plugin('currentUserPlugin');
513
            $currentUser = $currentUserPlugin->getUser();
511
            $currentUser = $currentUserPlugin->getUser();
Línea 514... Línea 512...
514
            
512
            
Línea 515... Línea -...
515
            $id = intval($this->params()->fromRoute('id'), 10);
-
 
516
            
513
            $id = intval($this->params()->fromRoute('id'), 10);
517
            if(self::_USE_S3) {
-
 
518
                $storage = Storage::getInstance($this->config);
-
 
519
            } else {
-
 
Línea 520... Línea 514...
520
                $storage = '';
514
            
521
            }
515
            $storage = Storage::getInstance($this->config);
Línea 522... Línea 516...
522
            
516
            
Línea 591... Línea 585...
591
                    return new JsonModel([
585
                    return new JsonModel([
592
                        'success' => true,
586
                        'success' => true,
593
                        'data' => [
587
                        'data' => [
594
                            'uuid' => $user->uuid,
588
                            'uuid' => $user->uuid,
595
                            'name' => $user->first_name . ' ' . $user->last_name,
589
                            'name' => $user->first_name . ' ' . $user->last_name,
596
                            'image' => $storage ? $storage->getUserImage($user) : $this->url()->fromRoute('storage', ['code' => $user->uuid, 'type' => '$user', 'filename' => $user->image]), 
590
                            'image' => $storage->getUserImage($user),
597
                            'subject' => $subject,
591
                            'subject' => $subject,
598
                            'body' => $body,
592
                            'body' => $body,
599
                            'date' => date('Y-m-d h:i a', $email['date']),
593
                            'date' => date('Y-m-d h:i a', $email['date']),
600
                            'seen' => $seen,
594
                            'seen' => $seen,
601
                            'block_link' => $this->url()->fromRoute('inmail/user/block',[ 'id' => $user->uuid ], ['force_canonical' => true]),
595
                            'block_link' => $this->url()->fromRoute('inmail/user/block',[ 'id' => $user->uuid ], ['force_canonical' => true]),
Línea 765... Línea 759...
765
                    $smtp->setBody( $dataPost['body'], true);
759
                    $smtp->setBody( $dataPost['body'], true);
766
                    $smtp->setBody($dataPost['body']);
760
                    $smtp->setBody($dataPost['body']);
767
                    $smtp->addTo($user->username_inmail);
761
                    $smtp->addTo($user->username_inmail);
Línea 768... Línea 762...
768
    
762
    
769
                    $files  = $this->getRequest()->getFiles()->toArray();
763
                    $files  = $this->getRequest()->getFiles()->toArray();
770
                    if (isset($files['file']) && empty($files['file']['error'])) {
764
                    if (isset($files['filename']) && empty($files['filename']['error'])) {
Línea 771... Línea 765...
771
                        $smtp->addAttachment($files['file']['name'], $files['file']['tmp_name']);
765
                        $smtp->addAttachment($files['filename']['name'], $files['filename']['tmp_name']);
Línea 788... Línea 782...
788
                        'success'   => false,
782
                        'success'   => false,
789
                        'data'   => 'ERROR_INMAIL_MESSAGE_NOT_SENT'
783
                        'data'   => 'ERROR_INMAIL_MESSAGE_NOT_SENT'
790
                    ]);
784
                    ]);
791
                }
785
                }
Línea 792... Línea -...
792
                
-
 
793
                $phpMailer = new PHPMailer();
-
 
794
                $phpMailer->isSMTP();
-
 
795
                
-
 
796
                $phpMailer->addAddress($user->username_inmail, $user->first_name . ' ' . $user->last_name);
-
 
797
                $phpMailer->setFrom($currentUser->username_inmail, $currentUser->first_name . ' ' . $currentUser->last_name);
-
 
798
                $phpMailer->SMTPDebug    = false;
-
 
799
                $phpMailer->Host         = $host;
-
 
800
                $phpMailer->Port         = $port;
-
 
801
                $phpMailer->IsHTML(true);
-
 
802
                $phpMailer->SMTPAuth    = true;
-
 
803
                //$phpMailer->SMTPSecure   = 'tls';
-
 
804
                $phpMailer->SMTPAuth     = true;
-
 
805
                $phpMailer->Username     = $username;
-
 
806
                $phpMailer->Password     = $password;
-
 
807
                $phpMailer->Subject      = $dataPost['subject'];
-
 
808
                $phpMailer->Body         = $dataPost['body'];
-
 
809
                $phpMailer->AltBody      = $dataPost['body'];
-
 
810
                $phpMailer->CharSet      = 'UTF-8';
-
 
811
                
-
 
812
                $files  = $this->getRequest()->getFiles()->toArray();
-
 
813
                if (isset($files['file']) && empty($files['file']['error'])) {
-
 
814
                    $phpMailer->addAttachment($files['file']['tmp_name'],
-
 
815
                        $files['file']['name']);
-
 
816
            
-
 
817
                }
-
 
818
                
-
 
Línea 819... Línea -...
819
                
-
 
820
                
-
 
821
                
-
 
822
                
-
 
823
                if($phpMailer->send()) {
-
 
824
                    return new JsonModel([
-
 
825
                        'success'   => true,
-
 
826
                        'data'   => 'LABEL_INMAIL_MESSAGE_SENT'
-
 
827
                    ]);
-
 
828
                } else {
-
 
829
              
-
 
830
               
-
 
831
                    return new JsonModel([
-
 
832
                        'success'   => false,
-
 
833
                        'data'   => 'ERROR_INMAIL_MESSAGE_NOT_SENT'
-
 
834
                    ]);
786
                
Línea 835... Línea 787...
835
                }
787
                
836
            } else {
788
            } else {