Proyectos de Subversion LeadersLinked - Services

Rev

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

Rev 247 Rev 283
Línea 1... Línea 1...
1
<?php
1
<?php
2
declare(strict_types=1);
2
declare(strict_types=1);
Línea 3... Línea 3...
3
 
3
 
Línea 4... Línea -...
4
namespace LeadersLinked\Controller;
-
 
5
 
-
 
6
use Laminas\Db\Adapter\AdapterInterface;
4
namespace LeadersLinked\Controller;
7
 
-
 
8
use Laminas\Mvc\Controller\AbstractActionController;
5
 
9
use Laminas\Log\LoggerInterface;
-
 
10
use Laminas\View\Model\JsonModel;
6
use Laminas\Mvc\Controller\AbstractActionController;
11
 
7
use Laminas\View\Model\JsonModel;
12
use LeadersLinked\Library\Functions;
8
use LeadersLinked\Library\Functions;
13
use LeadersLinked\Mapper\CompanyUserMapper;
9
use LeadersLinked\Mapper\CompanyUserMapper;
14
use LeadersLinked\Form\Feed\CreateForm;
10
use LeadersLinked\Form\Feed\CreateForm;
Línea 49... Línea 45...
49
use LeadersLinked\Model\FastSurveyVote;
45
use LeadersLinked\Model\FastSurveyVote;
50
use LeadersLinked\Mapper\AbuseReportMapper;
46
use LeadersLinked\Mapper\AbuseReportMapper;
51
use LeadersLinked\Mapper\UserBlockedMapper;
47
use LeadersLinked\Mapper\UserBlockedMapper;
52
use LeadersLinked\Model\AbuseReport;
48
use LeadersLinked\Model\AbuseReport;
53
use LeadersLinked\Model\User;
49
use LeadersLinked\Model\User;
-
 
50
use LeadersLinked\Library\S3Files;
-
 
51
use LeadersLinked\Library\Storage;
Línea 54... Línea 52...
54
 
52
 
55
 
53
 
56
class FeedController extends AbstractActionController
54
class FeedController extends AbstractActionController
Línea 255... Línea 253...
255
        $id = $this->params()->fromRoute('id');
253
        $id = $this->params()->fromRoute('id');
Línea 256... Línea 254...
256
        
254
        
257
        $request = $this->getRequest();
255
        $request = $this->getRequest();
258
        $request = $this->getRequest();
256
        $request = $this->getRequest();
259
        if ($request->isGet()) {
257
        if ($request->isGet()) {
260
            
258
 
261
            $currentUserPlugin = $this->plugin('currentUserPlugin');
259
            $currentUserPlugin = $this->plugin('currentUserPlugin');
Línea 262... Línea 260...
262
            $currentUser = $currentUserPlugin->getUser();
260
            $currentUser = $currentUserPlugin->getUser();
263
            
261
            
Línea 276... Línea 274...
276
            
274
            
Línea 277... Línea 275...
277
            $items = [];
275
            $items = [];
278
            
276
            
-
 
277
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
Línea 279... Línea 278...
279
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
278
            $records = $contentReactionMapper->fetchAllByFeedId($feed->id);
280
            $records = $contentReactionMapper->fetchAllByFeedId($feed->id);
279
            $storage = Storage::getInstance($this->config);
281
            
280
            
282
            foreach($records as $record)
281
            foreach($records as $record)
-
 
282
            {
Línea 283... Línea 283...
283
            {
283
                $user = $userMapper->fetchOne($record->user_id);
284
                $user = $userMapper->fetchOne($record->user_id);
284
                if($user && $user->status == User::STATUS_ACTIVE) {
285
                if($user && $user->status == User::STATUS_ACTIVE) {
285
             
286
                    
286
                    
287
                    array_push($items, [
287
                    array_push($items, [
288
                        'first_name' => $user->first_name,
288
                        'first_name' => $user->first_name,
289
                        'last_name' => $user->last_name,
289
                        'last_name' => $user->last_name,
290
                        'email' => $user->email,
290
                        'email' => $user->email,
291
                        'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image], ['force_canonical' => true]),
291
                        'image' => $storage->getUserImage($user),
Línea 560... Línea 560...
560
                }
560
                }
Línea 561... Línea 561...
561
 
561
 
562
                $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
562
                $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
Línea 563... Línea -...
563
                $companyUser = $companyUserMapper->fetchOneByCompanyIdAndUserId($company->id, $currentUser->id);
-
 
564
 
-
 
Línea 565... Línea 563...
565
                //print_r($companyUser); exit;
563
                $companyUser = $companyUserMapper->fetchOneByCompanyIdAndUserId($company->id, $currentUser->id);
566
 
564
 
567
 
565
 
568
                if (!$companyUser || $companyUser->status != CompanyUser::STATUS_ACCEPTED) {
566
                if (!$companyUser || $companyUser->status != CompanyUser::STATUS_ACCEPTED) {
Línea 662... Línea 660...
662
 
660
 
663
 
661
 
Línea 664... Línea -...
664
            $files = $this->getRequest()->getFiles()->toArray();
-
 
665
            $file_type = '';
-
 
666
 
-
 
667
            $encoding = $this->params()->fromRoute('encoding');
-
 
668
            if ($encoding == 'base64') {
-
 
669
 
-
 
670
 
-
 
671
                $fileBase64Name = $this->params()->fromPost('file_base64_name');
662
            $files = $this->getRequest()->getFiles()->toArray();
672
                $fileBase64Content = $this->params()->fromPost('file_base64_content');
-
 
673
 
-
 
674
                if ($fileBase64Name && $fileBase64Content) {
663
            $file_type = '';
675
 
-
 
676
                    try {
664
 
677
                        $fileBase64Content = base64_decode($fileBase64Content);
-
 
678
                        if ($fileBase64Content) {
-
 
679
                            $feed_filename      = $this->normalizeString($fileBase64Name);
-
 
680
                            $feed_tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp';
-
 
681
                            if (!file_exists($feed_tmp_filename)) {
-
 
682
                                mkdir($feed_tmp_filename, 0755, true);
-
 
683
                            }
665
            if (isset($files['file']) && empty($files['file']['error'])) {
684
 
-
 
685
 
666
                $feed_tmp_filename  = $files['file']['tmp_name'];
Línea 686... Línea -...
686
 
-
 
687
                            $feed_tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $feed_filename;
-
 
688
                            file_put_contents($feed_tmp_filename, $fileBase64Content);
-
 
689
 
-
 
690
 
-
 
691
 
-
 
692
                            $mime_type = mime_content_type($feed_tmp_filename);
-
 
693
                            //echo '$mime_type = '. $mime_type; exit;
-
 
694
 
-
 
695
 
-
 
696
                            if ($mime_type == 'image/jpg' || $mime_type == 'image/jpeg' || $mime_type == 'image/png') {
-
 
697
                                $file_type = Feed::FILE_TYPE_IMAGE;
-
 
698
                            } else if ($mime_type ==  'video/quicktime' ||  $mime_type == 'video/webm' || $mime_type == 'video/mpeg' || $mime_type == 'video/mpg' || $mime_type == 'video/mp4') {
-
 
699
                                $file_type = Feed::FILE_TYPE_VIDEO;
-
 
700
                            } else if ($mime_type == 'application/pdf') {
-
 
701
                                $file_type = Feed::FILE_TYPE_DOCUMENT;
-
 
702
                            }
-
 
703
                        }
-
 
704
                    } catch (\Exception $e) {
-
 
705
                    }
-
 
706
                }
-
 
707
            } else {
-
 
708
 
-
 
709
                if (isset($files['file']) && empty($files['file']['error'])) {
-
 
710
                    $feed_tmp_filename  = $files['file']['tmp_name'];
-
 
711
                    $feed_filename      = $this->normalizeString($files['file']['name']);
667
                $feed_filename      = $this->normalizeString($files['file']['name']);
712
 
668
 
713
                    $mime_type = mime_content_type($feed_tmp_filename);
669
                $mime_type = mime_content_type($feed_tmp_filename);
714
 
670
 
715
 
671
 
716
                    if ($mime_type == 'image/jpg' || $mime_type == 'image/jpeg' || $mime_type == 'image/png') {
672
                if ($mime_type == 'image/jpg' || $mime_type == 'image/jpeg' || $mime_type == 'image/png') {
717
                        $file_type = Feed::FILE_TYPE_IMAGE;
-
 
718
                    } else if ($mime_type ==  'video/quicktime' ||  $mime_type == 'video/webm' || $mime_type == 'video/mpeg' || $mime_type == 'video/mpg' || $mime_type == 'video/mp4') {
673
                    $file_type = Feed::FILE_TYPE_IMAGE;
719
                        $file_type = Feed::FILE_TYPE_VIDEO;
674
                } else if ($mime_type ==  'video/quicktime' ||  $mime_type == 'video/webm' || $mime_type == 'video/mpeg' || $mime_type == 'video/mpg' || $mime_type == 'video/mp4') {
Línea 720... Línea 675...
720
                    } else if ($mime_type == 'application/pdf') {
675
                    $file_type = Feed::FILE_TYPE_VIDEO;
Línea 772... Línea 727...
772
 
727
 
Línea 773... Línea 728...
773
 
728
 
774
                $feed = $feedMapper->fetchOne($feed->id);
-
 
775
 
-
 
776
                if ($file_type == Feed::FILE_TYPE_DOCUMENT) {
729
                $feed = $feedMapper->fetchOne($feed->id);
777
                    try {
730
 
778
                        $target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
-
 
779
                        if (!file_exists($target_path)) {
731
                if ($file_type == Feed::FILE_TYPE_DOCUMENT) {
780
                            mkdir($target_path, 0755, true);
732
                    $storage = Storage::getInstance($this->config);
781
                        }
-
 
782
 
-
 
783
                        $full_filename = $target_path  . DIRECTORY_SEPARATOR . $feed_filename;
-
 
784
 
-
 
785
                        if ($encoding == 'base64') {
-
 
786
                            $resultMoveOrRename = rename($feed_tmp_filename, $full_filename);
-
 
787
                        } else {
-
 
788
                            $resultMoveOrRename = move_uploaded_file($feed_tmp_filename, $full_filename);
-
 
789
                        }
-
 
790
 
733
                    $target_path = $storage->getPathFeed();
791
                        if ($resultMoveOrRename) {
734
                    
792
 
735
                    if ($storage->putFile($target_path, $feed->uuid, $feed_filename)) {
793
                            $feed->file_type = $file_type;
-
 
794
                            $feed->file_name = basename($feed_filename);
-
 
795
                            $feedMapper->update($feed);
-
 
796
                        } else {
-
 
797
                            error_log('no se pudo mover o renombrar el documento : ' . $feed_tmp_filename . ' al directorio : ' . $full_filename);
-
 
798
                        }
736
                        $feed->file_type = $file_type;
799
                    } catch (\Throwable $e) {
-
 
-
 
737
                        $feed->file_name = $feed_filename;
800
                        error_log($e->getTraceAsString());
738
                        $feedMapper->update($feed);
801
                    }
-
 
802
                }
-
 
803
                if ($file_type == Feed::FILE_TYPE_IMAGE) {
739
                    }
804
                    try {
740
                    
805
                        $target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
-
 
806
                        if (!file_exists($target_path)) {
-
 
807
                            mkdir($target_path, 0755, true);
-
 
Línea 808... Línea -...
808
                        }
-
 
809
 
-
 
810
                        list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.feed_image_size']);
-
 
811
 
741
                } else if ($file_type == Feed::FILE_TYPE_IMAGE) {
Línea -... Línea 742...
-
 
742
                    $image = Image::getInstance($this->config);
812
                        $feed_filename = substr($feed_filename, 0, strrpos($feed_filename, '.'))  . '.png';
743
                    $target_path = $image->getStorage()->getPathFeed();
813
                        //$crop_to_dimensions = false;
744
 
814
                        //if(Image::uploadImage($feed_tmp_filename, $target_path, $feed_filename, $target_width, $target_height, $crop_to_dimensions )) {
745
                    list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.feed_image_size']);
-
 
746
 
-
 
747
               
815
                        if (Image::uploadImageWithoutCompletationSize($feed_tmp_filename, $target_path, $feed_filename, $target_width, $target_height)) {
748
                    $feed_filename = substr($feed_filename, 0, strrpos($feed_filename, '.'))  . '.png';
816
 
749
                    $crop_to_dimensions = false;
817
                            $feed->file_type = $file_type;
750
                    $unlink_source = true;
818
                            $feed->file_name = basename($feed_filename);
751
                    
819
                            $feedMapper->update($feed);
752
                    if(!$image->uploadImageChangeSize($feed_tmp_filename, $target_path, $feed->uuid, $feed_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
820
                        }
753
                        $feed->file_type = $file_type;
821
                    } catch (\Throwable $e) {
754
                        $feed->file_name = $feed_filename;
-
 
755
                        $feedMapper->update($feed);
822
                        error_log($e->getTraceAsString());
756
                    }
-
 
757
                }
-
 
758
                if ($file_type == Feed::FILE_TYPE_VIDEO) {
-
 
759
                    try {
-
 
760
                        
-
 
761
                        $full_filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $feed_filename;
-
 
762
                        rename($feed_tmp_filename, $full_filename);
-
 
763
 
-
 
764
                        //extracción del cover
-
 
765
                        $generate_filename = substr($feed_filename, 0, strrpos($feed_filename, '.')).  '.jpg';
-
 
766
                        $generate_full_filename =  sys_get_temp_dir()  . DIRECTORY_SEPARATOR . $generate_filename; 
-
 
767
                 
-
 
768
                        
-
 
769
                        $cmd        = "/usr/bin/ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width,duration  $full_filename";
823
                    }
770
                        $response   = trim(shell_exec($cmd));
-
 
771
 
824
                }
772
                        $source_duration = 0;
-
 
773
                        $lines = explode("\n", $response);
-
 
774
                        foreach ($lines as $line) {
825
                if ($file_type == Feed::FILE_TYPE_VIDEO) {
775
                            $line = trim(strtolower($line));
Línea 826... Línea -...
826
                    try {
-
 
Línea 827... Línea 776...
827
                        $target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
776
                            if (strpos($line, 'duration') !== false) {
828
                        if (!file_exists($target_path)) {
777
                                $values = explode('=', $line);
829
                            mkdir($target_path, 0755, true);
778
                                $source_duration = intval(str_replace($values[1], '#', ''), 10);
830
                        }
-
 
831
 
-
 
832
                        $full_filename = $target_path  . DIRECTORY_SEPARATOR . $feed_filename;
-
 
833
 
-
 
834
                        if ($encoding == 'base64') {
-
 
835
                            $resultMoveOrRename = rename($feed_tmp_filename, $full_filename);
-
 
836
                        } else {
-
 
837
                            $resultMoveOrRename = move_uploaded_file($feed_tmp_filename, $full_filename);
-
 
838
                        }
-
 
839
 
-
 
840
                        if ($resultMoveOrRename) {
-
 
841
 
-
 
842
 
-
 
843
                            // $getFromSecound = 2;
-
 
844
 
-
 
845
                            //extracción del cover
-
 
846
                            $generateFileName = substr($feed_filename, 0, strrpos($feed_filename, '.'));
-
 
847
                            $generateFile =  $target_path  . DIRECTORY_SEPARATOR . $generateFileName .  '.jpg';
-
 
848
 
-
 
849
                            $cmd        = "/usr/bin/ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width,duration  $full_filename";
-
 
850
                            //error_log($cmd);
-
 
851
 
-
 
852
                            $response   = trim(shell_exec($cmd));
-
 
853
 
-
 
854
                            $source_duration = 0;
-
 
855
 
-
 
856
 
-
 
857
                            $lines = explode("\n", $response);
-
 
858
                            foreach ($lines as $line) {
-
 
859
                                $line = trim(strtolower($line));
-
 
860
                                if (strpos($line, 'duration') !== false) {
779
                            }
861
                                    $values = explode('=', $line);
780
                        }
862
                                    $source_duration = intval(str_replace($values[1], '#', ''), 10);
781
 
863
                                }
-
 
864
                            }
-
 
865
 
-
 
866
 
782
 
867
                            if ($source_duration == 0) {
-
 
868
                                $second_extract = '00:00:02';
783
                        if ($source_duration == 0) {
-
 
784
                            $second_extract = '00:00:02';
Línea 869... Línea 785...
869
                            } else {
785
                        } else {
870
                                if ($source_duration > 10) {
-
 
871
                                    $second_extract = '00:00:10';
-
 
872
                                } else {
-
 
873
                                    $second_extract = '00:00:02';
-
 
874
                                }
-
 
875
                            }
-
 
876
 
-
 
877
                            $imageSize = $this->config['leaderslinked.image_sizes.feed_image_size'];
-
 
878
 
-
 
Línea -... Línea 786...
-
 
786
                            if ($source_duration > 10) {
-
 
787
                                $second_extract = '00:00:10';
-
 
788
                            } else {
-
 
789
                                $second_extract = '00:00:02';
-
 
790
                            }
-
 
791
                        }
-
 
792
 
-
 
793
                        //$imageSize = $this->config['leaderslinked.image_sizes.feed_image_size'];
-
 
794
 
-
 
795
                        //$cmd = "/usr/bin/ffmpeg -y -i $full_filename  -pix_fmt yuvj422p -deinterlace -an -ss $second_extract -f mjpeg -t 1 -r 1 -y -s $imageSize $generateFile";
-
 
796
                        // $cmd = "/usr/bin/ffmpeg -y -i $full_filename  -pix_fmt yuvj422p -an -ss $second_extract -f mjpeg -t 1 -r 1 -y -s $imageSize $generateFile";
879
                            //$cmd = "/usr/bin/ffmpeg -y -i $full_filename  -pix_fmt yuvj422p -deinterlace -an -ss $second_extract -f mjpeg -t 1 -r 1 -y -s $imageSize $generateFile";
797
                        $cmd = "/usr/bin/ffmpeg -y -i $full_filename  -pix_fmt yuvj422p -an -ss $second_extract -f mjpeg -t 1 -r 1 -y  $generate_full_filename";
880
                           // $cmd = "/usr/bin/ffmpeg -y -i $full_filename  -pix_fmt yuvj422p -an -ss $second_extract -f mjpeg -t 1 -r 1 -y -s $imageSize $generateFile";
798
                        exec($cmd);
881
                            $cmd = "/usr/bin/ffmpeg -y -i $full_filename  -pix_fmt yuvj422p -an -ss $second_extract -f mjpeg -t 1 -r 1 -y  $generateFile";
799
                        
882
                            //error_log($cmd);
800
                        $storage = Storage::getInstance($this->config);
Línea 883... Línea 801...
883
 
801
                        $target_path = $storage->getPathFeed();
884
                            
802
                        
885
                            exec($cmd);
803
                        if($storage->putFile($target_path, $feed->uuid, $generate_full_filename) || $storage->putFile($target_path, $feed->uuid, $full_filename)) {
Línea 886... Línea 804...
886
 
804
 
887
 
805
 
888
                            $feed->file_type = $file_type;
-
 
889
                            $feed->file_name = basename($feed_filename);
-
 
890
                            $feed->file_image_preview = basename($generateFile);
806
                            $feed->file_type            = $file_type;
-
 
807
                            $feed->file_name            = $feed_filename;
-
 
808
                            $feed->file_image_preview   = $generate_filename;
-
 
809
                            $feedMapper->update($feed);
-
 
810
 
-
 
811
                            $videoConvert = new VideoConvert();
891
                            $feedMapper->update($feed);
812
                            $videoConvert->filename = $full_filename;
892
 
813
                            $videoConvert->type = VideoConvert::TYPE_FEED;
893
                            $videoConvert = new VideoConvert();
814
 
894
                            $videoConvert->filename = $full_filename;
815
                            $videoConvertMapper = VideoConvertMapper::getInstance($this->adapter);
Línea 1621... Línea 1542...
1621
     * @param int[] $abuse_report_comment_ids
1542
     * @param int[] $abuse_report_comment_ids
1622
     * @return array
1543
     * @return array
1623
     */
1544
     */
1624
    private function renderFeed($feed_id, $now, $feedHighlighted = 0,  $user_blocked_ids  = [], $abuse_report_comment_ids = [])
1545
    private function renderFeed($feed_id, $now, $feedHighlighted = 0,  $user_blocked_ids  = [], $abuse_report_comment_ids = [])
1625
    {
1546
    {
-
 
1547
 
1626
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1548
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1627
        $currentUser = $currentUserPlugin->getUser();
1549
        $currentUser = $currentUserPlugin->getUser();
Línea 1628... Línea 1550...
1628
 
1550
 
1629
        $currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
1551
        $currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
Línea 1741... Línea 1663...
1741
        }
1663
        }
Línea 1742... Línea 1664...
1742
        
1664
        
Línea 1743... Línea -...
1743
 
-
 
-
 
1665
 
1744
        if ($feed->posted_or_shared == Feed::POSTED) {
1666
        if ($feed->posted_or_shared == Feed::POSTED) {
-
 
1667
 
-
 
1668
            $storage = Storage::getInstance($this->config);
1745
 
1669
            if ($feed->type == Feed::TYPE_COMPANY) {
1746
 
1670
                
-
 
1671
                
1747
            if ($feed->type == Feed::TYPE_COMPANY) {
1672
                $companyMapper = CompanyMapper::getInstance($this->adapter);
1748
                $companyMapper = CompanyMapper::getInstance($this->adapter);
1673
                $company = $companyMapper->fetchOne($feed->company_id);
1749
                $company = $companyMapper->fetchOne($feed->company_id);
1674
                
1750
                $item['owner_url'] = $this->url()->fromRoute('company/view', ['id' => $company->uuid],  ['force_canonical' => true]);
-
 
1751
                $item['owner_image'] = $this->url()->fromRoute('storage', ['code' => $company->uuid, 'type' => 'company', 'filename' => $company->image],['force_canonical' => true]);
1675
                $item['owner_url'] = $this->url()->fromRoute('company/view', ['id' => $company->uuid],  ['force_canonical' => true]);
1752
                $item['owner_name'] = $company->name;
-
 
1753
                /*
-
 
1754
                 
-
 
1755
                $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
-
 
1756
                $companyUser = $companyUserMapper->fetchOneByCompanyIdAndUserId($company->id, $currentUser->id);
-
 
1757
                
-
 
1758
                
-
 
1759
                if( $companyUser && $acl->isAllowed( $currentUser->usertype_id, 'my-company/feed' ) ) {
-
 
1760
                    $item['feed_delete_url'] = $this->url()->fromRoute('feed/delete',  $params);
1676
                $item['owner_image'] = $storage->getCompanyImage($company);
1761
                }
1677
                $item['owner_name'] = $company->name;
1762
                */
1678
        
-
 
1679
            } else if ($feed->type == Feed::TYPE_GROUP) {
-
 
1680
                $groupMapper = GroupMapper::getInstance($this->adapter);
1763
            } else if ($feed->type == Feed::TYPE_GROUP) {
1681
                $group = $groupMapper->fetchOne($feed->group_id);
1764
                $groupMapper = GroupMapper::getInstance($this->adapter);
1682
                
1765
                $group = $groupMapper->fetchOne($feed->group_id);
1683
               
Línea 1766... Línea 1684...
1766
                $item['owner_url'] = '';
1684
                $item['owner_url'] = '';
1767
                $item['owner_image'] = $this->url()->fromRoute('storage', ['code' => $group->uuid, 'type' => 'group', 'filename' => $group->image],['force_canonical' => true]);
1685
                $item['owner_image'] = $storage->getGroupImage($group);
1768
                $item['owner_name'] = $group->name;
1686
                $item['owner_name'] = $group->name;
1769
 
1687
 
1770
                if ($group->user_id == $currentUser->id) {
1688
                if ($group->user_id == $currentUser->id) {
1771
                    $item['feed_delete_url'] = $this->url()->fromRoute('feed/delete',  $params,  ['force_canonical' => true]);
1689
                    $item['feed_delete_url'] = $this->url()->fromRoute('feed/delete',  $params,  ['force_canonical' => true]);
-
 
1690
                }
1772
                }
1691
            } else {
1773
            } else {
1692
                $userMapper = UserMapper::getInstance($this->adapter);
1774
                $userMapper = UserMapper::getInstance($this->adapter);
1693
                $user = $userMapper->fetchOne($feed->user_id);
1775
                $user = $userMapper->fetchOne($feed->user_id);
1694
                
Línea 1776... Línea 1695...
1776
 
1695
                
1777
                $item['owner_url'] = $this->url()->fromRoute('profile/view', ['id' => $user->uuid]);
1696
                $item['owner_url'] = $this->url()->fromRoute('profile/view', ['id' => $user->uuid]);
1778
                $item['owner_image'] = $this->url()->fromRoute('storage', ['code' => $user->uuid, 'type' => 'user', 'filename' => $user->image],['force_canonical' => true]);
1697
                $item['owner_image'] = $storage->getUserImage($user); 
Línea 1792... Línea 1711...
1792
        $user = $userMapper->fetchOne($feed->user_id);
1711
        $user = $userMapper->fetchOne($feed->user_id);
Línea 1793... Línea 1712...
1793
        
1712
        
-
 
1713
       
1794
       
1714
 
1795
 
1715
        if ($feed->posted_or_shared == Feed::SHARED) {
1796
        if ($feed->posted_or_shared == Feed::SHARED) {
1716
           
1797
            $item['owner_url'] = $this->url()->fromRoute('profile/view', ['id' => $user->uuid],['force_canonical' => true]);
1717
            $item['owner_url'] = $this->url()->fromRoute('profile/view', ['id' => $user->uuid],['force_canonical' => true]);
Línea 1798... Línea 1718...
1798
            $item['owner_image'] = $this->url()->fromRoute('storage', ['code' => $user->uuid, 'type' => 'user', 'filename' => $user->image],['force_canonical' => true]);
1718
            $item['owner_image'] = $storage->getUserImage($user);
1799
            $item['owner_name'] = $user->first_name . ' ' . $user->last_name;
1719
            $item['owner_name'] = $user->first_name . ' ' . $user->last_name;
Línea 1848... Línea 1768...
1848
 
1768
 
Línea 1849... Línea 1769...
1849
 
1769
 
-
 
1770
        $item['owner_time_elapse'] = Functions::timeAgo($feed->added_on, $now);
-
 
1771
 
1850
        $item['owner_time_elapse'] = Functions::timeAgo($feed->added_on, $now);
1772
        if ($feed->file_type == Feed::FILE_TYPE_IMAGE) {
1851
 
1773
            
1852
        if ($feed->file_type == Feed::FILE_TYPE_IMAGE) {
1774
            $path = $storage->getPathFeed();
-
 
1775
            $item['owner_file_image'] = $storage->getGenericImage($path,  $feed->uuid, $feed->file_name); 
-
 
1776
        }
1853
            $item['owner_file_image'] = $this->url()->fromRoute('storage', ['code' => $feed->uuid, 'type' => 'feed', 'filename' => $feed->file_name],['force_canonical' => true]);
1777
        if ($feed->file_type == Feed::FILE_TYPE_DOCUMENT) {
1854
        }
1778
            
1855
        if ($feed->file_type == Feed::FILE_TYPE_DOCUMENT) {
1779
            $path = $storage->getPathFeed();
-
 
1780
            $item['owner_file_document'] = $storage->getGenericFile($path,  $feed->uuid, $feed->file_name); 
1856
            $item['owner_file_document'] = $this->url()->fromRoute('storage', ['code' => $feed->uuid, 'type' => 'feed', 'filename' => $feed->file_name],['force_canonical' => true]);
1781
        }
1857
        }
1782
        if ($feed->file_type == Feed::FILE_TYPE_VIDEO) {
1858
        if ($feed->file_type == Feed::FILE_TYPE_VIDEO) {
1783
            $path = $storage->getPathFeed();
Línea 1859... Línea 1784...
1859
            $item['owner_file_image_preview'] = $this->url()->fromRoute('storage', ['code' => $feed->uuid, 'type' => 'feed', 'filename' => $feed->file_image_preview],['force_canonical' => true]);
1784
            $item['owner_file_image_preview'] = $item['owner_file_image'] = $storage->getGenericImage($path,  $feed->uuid, $feed->file_image_preview); 
1860
            $item['owner_file_video'] = $this->url()->fromRoute('storage', ['code' => $feed->uuid, 'type' => 'feed', 'filename' => $feed->file_name],['force_canonical' => true]);
-
 
1861
        }
-
 
1862
 
1785
            $item['owner_file_video']  = $storage->getGenericFile($path,  $feed->uuid, $feed->file_name); 
Línea 1863... Línea -...
1863
        if ($feed->posted_or_shared == Feed::SHARED) {
-
 
1864
 
-
 
1865
 
-
 
1866
            $sharedFeed = $feedMapper->fetchOneAnyStatus($feed->shared_feed_id);
1786
        }
1867
 
1787
 
Línea 1868... Línea 1788...
1868
 
1788
        if ($feed->posted_or_shared == Feed::SHARED) {
-
 
1789
            $sharedFeed = $feedMapper->fetchOneAnyStatus($feed->shared_feed_id);
1869
 
1790
 
1870
 
1791
            $item['shared_description'] = $sharedFeed->description;
1871
            $item['shared_description'] = $sharedFeed->description;
1792
            $item['shared_time_elapse'] = Functions::timeAgo($sharedFeed->added_on, $now);
-
 
1793
 
1872
            $item['shared_time_elapse'] = Functions::timeAgo($sharedFeed->added_on, $now);
1794
            if ($sharedFeed->file_type == Feed::FILE_TYPE_IMAGE) {
1873
 
1795
                $path = $storage->getPathFeed();
1874
            if ($sharedFeed->file_type == Feed::FILE_TYPE_IMAGE) {
1796
                $item['shared_file_image'] = $storage->getGenericImage($path, $sharedFeed->uuid, $sharedFeed->file_name);
-
 
1797
            }
1875
                $item['shared_file_image'] = $this->url()->fromRoute('storage', ['code' => $sharedFeed->uuid, 'type' => 'feed', 'filename' => $sharedFeed->file_name],['force_canonical' => true]);
1798
            if ($sharedFeed->file_type == Feed::FILE_TYPE_DOCUMENT) {
1876
            }
1799
                $path = $storage->getPathFeed();
-
 
1800
                $item['shared_file_document'] = $storage->getGenericFile($path, $sharedFeed->uuid, $sharedFeed->file_name);
1877
            if ($sharedFeed->file_type == Feed::FILE_TYPE_DOCUMENT) {
1801
            }
Línea 1878... Línea 1802...
1878
                $item['shared_file_document'] = $this->url()->fromRoute('storage', ['code' => $sharedFeed->uuid, 'type' => 'feed', 'filename' => $sharedFeed->file_name],['force_canonical' => true]);
1802
            if ($sharedFeed->file_type == Feed::FILE_TYPE_VIDEO) {
Línea 1879... Línea 1803...
1879
            }
1803
                $path = $storage->getPathFeed();
Línea 1880... Línea 1804...
1880
            if ($sharedFeed->file_type == Feed::FILE_TYPE_VIDEO) {
1804
                $item['shared_file_image_preview'] = $storage->getGenericImage($path, $sharedFeed->uuid, $sharedFeed->file_image_preview);
1881
                $item['shared_file_image_preview'] = $this->url()->fromRoute('storage', ['code' => $sharedFeed->uuid, 'type' => 'feed', 'filename' => $sharedFeed->file_image_preview],['force_canonical' => true]);
1805
                $item['shared_file_video'] = $storage->getGenericFile($path, $sharedFeed->uuid, $sharedFeed->file_name);
-
 
1806
               
-
 
1807
            }
1882
                $item['shared_file_video'] = $this->url()->fromRoute('storage', ['code' => $sharedFeed->uuid, 'type' => 'feed', 'filename' => $sharedFeed->file_name],['force_canonical' => true]);
1808
 
1883
            }
1809
            $item['shared_content_type'] = $sharedFeed->file_type ? $sharedFeed->file_type : '';
1884
 
1810
 
1885
            $item['shared_content_type'] = $sharedFeed->file_type ? $sharedFeed->file_type : '';
1811
            if ($feed->company_id) {
1886
 
1812
 
1887
            if ($feed->company_id) {
1813
                $companyMapper = CompanyMapper::getInstance($this->adapter);
-
 
1814
                $sharedCompany = $companyMapper->fetchOne($feed->company_id);
-
 
1815
    
1888
 
1816
                
1889
                $companyMapper = CompanyMapper::getInstance($this->adapter);
1817
                $item['shared_url'] = $this->url()->fromRoute('company/view', ['id' => $sharedCompany->uuid]);
1890
                $sharedCompany = $companyMapper->fetchOne($feed->company_id);
1818
                $item['shared_image'] = $storage->getCompanyImage($sharedCompany);
1891
                $item['shared_url'] = $this->url()->fromRoute('company/view', ['id' => $sharedCompany->uuid]);
1819
                $item['shared_name'] = $sharedCompany->name;
1892
                $item['shared_image'] = $this->url()->fromRoute('storage', ['code' => $sharedCompany->uuid, 'type' => 'company', 'filename' => $sharedCompany->image],['force_canonical' => true]);
-
 
1893
                $item['shared_name'] = $sharedCompany->name;
1820
            } else if ($feed->group_id) {
-
 
1821
                $groupMapper = GroupMapper::getInstance($this->adapter);
1894
            } else if ($feed->group_id) {
1822
                $sharedGroup = $groupMapper->fetchOne($feed->group_id);
1895
                $groupMapper = GroupMapper::getInstance($this->adapter);
1823
 
1896
                $sharedGroup = $groupMapper->fetchOne($feed->group_id);
1824
                
1897
                $item['shared_url'] = '';
1825
                $item['shared_url'] = '';
1898
                $item['shared_image'] = $this->url()->fromRoute('storage', ['code' => $sharedGroup->uuid, 'type' => 'group', 'filename' =>  $sharedGroup->image],['force_canonical' => true]);
1826
                $item['shared_image'] = $storage->getGroupImage($sharedGroup);
Línea 1911... Línea 1839...
1911
        if($feed->file_type == Feed::FILE_TYPE_FAST_SURVEY) {
1839
        if($feed->file_type == Feed::FILE_TYPE_FAST_SURVEY) {
1912
            $item['comment_add_url'] = '';
1840
            $item['comment_add_url'] = '';
1913
            $item['comments'] = [];
1841
            $item['comments'] = [];
1914
        } else {
1842
        } else {
Línea 1915... Línea 1843...
1915
            
1843
            
1916
            $item['comment_add_url'] = $this->url()->fromRoute('feed/comment', ['id' => $feed->uuid]);
1844
            $item['comment_add_url'] = $this->url()->fromRoute('feed/comment', ['id' => $feed->uuid],['force_canonical' => true]);
Línea 1917... Línea 1845...
1917
            $item['comments'] = [];
1845
            $item['comments'] = [];
1918
 
1846
 
Línea 1926... Línea 1854...
1926
            foreach ($records as $record) {
1854
            foreach ($records as $record) {
1927
                $user = $userMapper->fetchOne($record->user_id);
1855
                $user = $userMapper->fetchOne($record->user_id);
Línea 1928... Línea 1856...
1928
               
1856
               
1929
    
1857
    
1930
                if ($user->id == $currentUser->id) {
1858
                if ($user->id == $currentUser->id) {
1931
                    $link_delete = $this->url()->fromRoute('feed/comment/delete', ['id' => $feed->uuid, 'comment' => $record->uuid]);
1859
                    $link_delete = $this->url()->fromRoute('feed/comment/delete', ['id' => $feed->uuid, 'comment' => $record->uuid],['force_canonical' => true]);
1932
                } else {
1860
                } else {
-
 
1861
                    $link_delete = '';
1933
                    $link_delete = '';
1862
                }
1934
                }
1863
 
1935
                array_push($comments , [
1864
                array_push($comments , [
1936
                    'unique' => uniqid(),
1865
                    'unique' => uniqid(),
1937
                    'user_url' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
1866
                    'user_url' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid],['force_canonical' => true]),
1938
                    'user_name' => $user->first_name . ' ' . $user->last_name,
1867
                    'user_name' => $user->first_name . ' ' . $user->last_name,
1939
                    'company' => $owner,
1868
                    'company' => $owner,
1940
                    'user_image' => $this->url()->fromRoute('storage', ['type' => 'user',  'code' => $user->uuid, 'filename' =>  $user->image],['force_canonical' => true]),
1869
                    'user_image' => $storage->getUserImage($user),
1941
                    'time_elapsed' => Functions::timeAgo($record->added_on, $now),
1870
                    'time_elapsed' => Functions::timeAgo($record->added_on, $now),
1942
                    'comment' => $record->comment,
1871
                    'comment' => $record->comment,
1943
                    'link_abuse_report' => $user->id == $currentUser->id ? '' : $this->url()->fromRoute('helpers/abuse-report', ['type' => 'comment', 'id' => $record->uuid], ['force_canonical' => true]),
1872
                    'link_abuse_report' => $user->id == $currentUser->id ? '' : $this->url()->fromRoute('helpers/abuse-report', ['type' => 'comment', 'id' => $record->uuid], ['force_canonical' => true]),
1944
                    'link_delete' => $link_delete
1873
                    'link_delete' => $link_delete
Línea 1945... Línea 1874...
1945
                ]);
1874
                ]);
1946
            }
1875
            }
Línea 1947... Línea -...
1947
            
-
 
1948
            $item['comments'] = $comments;
-
 
1949
        }
-
 
1950
        
-
 
1951
        /*
-
 
1952
        echo '<pre>';
-
 
Línea 1953... Línea 1876...
1953
        print_r($feed);
1876
            
1954
        print_r($item);
1877
            $item['comments'] = $comments;
Línea 1955... Línea 1878...
1955
        echo '</pre>';
1878
        }
Línea 1975... Línea 1898...
1975
 
1898
 
1976
        $feedMapper = FeedMapper::getInstance($this->adapter);
1899
        $feedMapper = FeedMapper::getInstance($this->adapter);
Línea 1977... Línea 1900...
1977
        $feed = $feedMapper->fetchOne($record->feed_id);
1900
        $feed = $feedMapper->fetchOne($record->feed_id);
-
 
1901
 
-
 
1902
        if ($record) {
1978
 
1903
            $storage = Storage::getInstance($this->config);
Línea 1979... Línea 1904...
1979
        if ($record) {
1904
            
Línea 1980... Línea 1905...
1980
            $userMapper = UserMapper::getInstance($this->adapter);
1905
            $userMapper = UserMapper::getInstance($this->adapter);
1981
 
1906
 
1982
            $user = $userMapper->fetchOne($record->user_id);
1907
            $user = $userMapper->fetchOne($record->user_id);
1983
 
1908
 
1984
            $item['unique'] = uniqid();
1909
            $item['unique'] = uniqid();
1985
            //$item['user_image'] = $this->url()->fromRoute('storage', ['type' => 'user',  'code' => $user->uuid, 'filename' =>  $user->image],['force_canonical' => true]);
1910
            $item['user_image'] = $storage->getUserImage($user);
1986
            $item['user_url'] = $this->url()->fromRoute('profile', ['id' => $user->uuid]);
1911
            $item['user_url'] = $this->url()->fromRoute('profile', ['id' => $user->uuid]);