Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 16983 Rev 17002
Línea 1... Línea 1...
1
<?php
1
<?php
Línea 2... Línea -...
2
 
-
 
3
/**
-
 
4
 * 
-
 
5
 * Controlador: Mis Perfiles 
-
 
6
 * 
-
 
Línea 7... Línea 2...
7
 */
2
 
Línea 8... Línea 3...
8
 
3
 
Línea 41... Línea 36...
41
 
36
 
42
use LeadersLinked\Mapper\TopicMapper;
37
use LeadersLinked\Mapper\TopicMapper;
43
use LeadersLinked\Mapper\FastSurveyMapper;
38
use LeadersLinked\Mapper\FastSurveyMapper;
44
use LeadersLinked\Model\FastSurvey;
39
use LeadersLinked\Model\FastSurvey;
-
 
40
use LeadersLinked\Form\FastSurvey\FastSurveyForm;
Línea 45... Línea 41...
45
use LeadersLinked\Form\FastSurvey\FastSurveyForm;
41
use LeadersLinked\Library\Storage;
46
 
42
 
47
class FeedController extends AbstractActionController
43
class FeedController extends AbstractActionController
48
{
44
{
Línea 504... Línea 500...
504
        $currentNetwork = $currentNetworkPlugin->getNetwork();
500
        $currentNetwork = $currentNetworkPlugin->getNetwork();
Línea 505... Línea 501...
505
        
501
        
506
        
502
        
507
        $currentCompany = $currentUserPlugin->getCompany();
-
 
Línea 508... Línea 503...
508
        $myt_id =  $this->params()->fromRoute('myt_id');
503
        $currentCompany = $currentUserPlugin->getCompany();
509
        $hptg_uuid =  $this->params()->fromRoute('hptg_id');
504
        $myt_id =  $this->params()->fromRoute('myt_id');
Línea 615... Línea 610...
615
    
610
    
616
    
611
    
617
                    $hydrator = new ObjectPropertyHydrator();
612
                    $hydrator = new ObjectPropertyHydrator();
618
                    $feed = new Feed();
-
 
619
                    $hydrator->hydrate($dataPost, $feed);
-
 
620
                    /*
-
 
621
                    if ($hptg_uuid) {
-
 
622
    
-
 
623
    
-
 
624
    
-
 
625
                        $highPerformanceTeamsGroupsMapper = HighPerformanceTeamsGroupsMapper::getInstance($this->adapter);
-
 
626
                        $highPerformanceTeamsGroups = $highPerformanceTeamsGroupsMapper->fetchOneByUuid($hptg_uuid);
-
 
627
    
-
 
628
                        if (!$highPerformanceTeamsGroups) {
-
 
629
                            $data = [
-
 
630
                                'success' => false,
-
 
631
                                'data' => 'ERROR_RECORD_NOT_FOUND'
-
 
632
                            ];
-
 
633
    
-
 
634
                            return new JsonModel($data);
-
 
635
                        }
-
 
636
    
-
 
637
                        if ($highPerformanceTeamsGroups->status != HighPerformanceTeamsGroups::STATUS_ACTIVE) {
-
 
638
    
-
 
639
                            return new JsonModel([
-
 
640
                                'success' => false,
-
 
641
                                'data' => 'ERROR_UNAUTHORIZED'
-
 
642
                            ]);
-
 
643
                        }
-
 
644
    
-
 
645
                        $highPerformanceTeamsGroupsMemberMapper = HighPerformanceTeamsGroupsMembersMapper::getInstance($this->adapter);
-
 
646
                        $highPerformanceTeamsGroupsMember = $highPerformanceTeamsGroupsMemberMapper->fetchOneByGroupIdAndUserId($highPerformanceTeamsGroups->id, $currentUser->id);
-
 
647
                        if ($highPerformanceTeamsGroupsMember) {
-
 
648
                            if ($highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ACCEPTED || $highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ADDED_BY_ADMIN) {
-
 
649
                                $id =  $highPerformanceTeamsGroups->id;
-
 
650
                            } else {
-
 
651
    
-
 
652
                                return new JsonModel([
-
 
653
                                    'success' => false,
-
 
654
                                    'data' => 'ERROR_UNAUTHORIZED'
-
 
655
                                ]);
-
 
656
                            }
-
 
657
                        } else {
-
 
658
    
-
 
659
                            return new JsonModel([
-
 
660
                                'success' => false,
-
 
661
                                'data' => 'ERROR_RECORD_NOT_FOUND'
-
 
662
                            ]);
-
 
663
                        }
-
 
664
                        $topic_uuid =  $this->params()->fromRoute('topic_id');
-
 
665
                        if ($topic_uuid) {
-
 
666
                            $topicMapper = TopicMapper::getInstance($this->adapter);
-
 
667
                            $topic = $topicMapper->fetchOneByUuid($topic_uuid);
-
 
668
                            if ($topic) {
-
 
669
                                $feed->topic_id = $topic->id;
-
 
670
                            } else {
-
 
671
                                return new JsonModel([
-
 
672
                                    'success' => false,
-
 
673
                                    'data' => 'ERROR_RECORD_NOT_FOUND'
-
 
674
                                ]);
-
 
675
                            }
-
 
676
                        }
-
 
677
    
-
 
678
    
-
 
679
                        $feed->network_id       = $currentUser->network_id;
-
 
680
                        $feed->company_id       = $currentCompany->id;
-
 
681
                        $feed->group_id         = null;
-
 
682
                        $feed->high_performance_group_id = $id;
-
 
683
                        $feed->user_id          = $currentUser->id;
-
 
684
                        $feed->type             = Feed::TYPE_HPTG;
-
 
685
                        $feed->posted_or_shared = Feed::POSTED;
-
 
686
                        $feed->shared_with      = Feed::SHARE_WITH_CONNECTIONS;
613
                    $feed = new Feed();
687
                    } else 
-
 
688
                        
614
                    $hydrator->hydrate($dataPost, $feed);
689
                    */    
615
                     
690
                    if ($myt_id) {
616
                    if ($myt_id) {
691
                        $feedMapper = FeedMapper::getInstance($this->adapter);
617
                        $feedMapper = FeedMapper::getInstance($this->adapter);
692
                        $myt  = $feedMapper->fetchOneByUuid($myt_id);
618
                        $myt  = $feedMapper->fetchOneByUuid($myt_id);
Línea 738... Línea 664...
738
    
664
    
Línea 739... Línea 665...
739
    
665
    
-
 
666
                    if ($result) {
740
                    if ($result) {
667
    
-
 
668
                        $feed = $feedMapper->fetchOne($feed->id);
-
 
669
                        
-
 
670
                        
-
 
671
                        $storage = Storage::getInstance($this->config);
-
 
672
                        $target_path = $storage->getPathFeed();
-
 
673
                        $interal_path   = 'data' . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR . 'tmp';
741
    
674
                        if(!file_exists($interal_path)) {
742
                        $feed = $feedMapper->fetchOne($feed->id);
-
 
743
    
-
 
744
                        if ($file_type == Feed::FILE_TYPE_DOCUMENT) {
-
 
745
                            try {
-
 
746
                                $target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
-
 
747
                                if (!file_exists($target_path)) {
675
                            mkdir($interal_path, 0775);
748
                                    mkdir($target_path, 0755, true);
-
 
749
                                }
-
 
750
    
-
 
751
                                $full_filename = $target_path  . DIRECTORY_SEPARATOR . $feed_filename;
676
                        }
752
                                $result = move_uploaded_file($feed_tmp_filename, $full_filename);
-
 
753
                                if ($result) {
677
                        if ($file_type == Feed::FILE_TYPE_DOCUMENT) {
754
    
678
                           
755
                                    $feed->file_type = $file_type;
-
 
756
                                    $feed->file_name = basename($feed_filename);
-
 
757
                                    $feedMapper->update($feed);
-
 
758
                                } else {
679
                            
759
                                    error_log('no se pudo mover o renombrar el documento : ' . $feed_tmp_filename . ' al directorio : ' . $full_filename);
680
                            if ($storage->putFile($target_path, $feed->uuid, $feed_filename)) {
760
                                }
681
                                $feed->file_type = $file_type;
761
                            } catch (\Throwable $e) {
-
 
-
 
682
                                $feed->file_name = $feed_filename;
762
                                error_log($e->getTraceAsString());
683
                                $feedMapper->update($feed);
763
                            }
-
 
764
                        }
-
 
765
                        if ($file_type == Feed::FILE_TYPE_IMAGE) {
684
                            }
766
                            try {
685
                            
767
                                $target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
-
 
768
                                if (!file_exists($target_path)) {
686
                        } else if ($file_type == Feed::FILE_TYPE_IMAGE) {
769
                                    mkdir($target_path, 0755, true);
687
                            $image = Image::getInstance($this->config);
-
 
688
                            $target_path = $image->getStorage()->getPathFeed();
770
                                }
689
                            
771
    
690
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.feed_image_size']);
772
                                list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.feed_image_size']);
691
                            
-
 
692
                            
-
 
693
                            $feed_filename = substr($feed_filename, 0, strrpos($feed_filename, '.'))  . '.png';
773
    
694
                            $crop_to_dimensions = false;
774
                                $feed_filename = substr($feed_filename, 0, strrpos($feed_filename, '.'))  . '.png';
695
                            $unlink_source = true;
775
                                $crop_to_dimensions = false;
696
                            
776
                                if (Image::uploadImage($feed_tmp_filename, $target_path, $feed_filename, $target_width, $target_height, $crop_to_dimensions)) {
697
                            if(!$image->uploadImageChangeSize($feed_tmp_filename, $target_path, $feed->uuid, $feed_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
777
                                    $feed->file_type = $file_type;
-
 
778
                                    $feed->file_name = basename($feed_filename);
-
 
779
                                    $feedMapper->update($feed);
-
 
780
                                }
698
                                $feed->file_type = $file_type;
781
                            } catch (\Throwable $e) {
699
                                $feed->file_name = $feed_filename;
782
                                error_log($e->getTraceAsString());
700
                                $feedMapper->update($feed);
783
                            }
701
                            }
-
 
702
                        }
784
                        }
703
                        if ($file_type == Feed::FILE_TYPE_VIDEO) {
785
                        if ($file_type == Feed::FILE_TYPE_VIDEO) {
704
                            try {
786
                            try {
-
 
787
                                $target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
-
 
788
                                if (!file_exists($target_path)) {
-
 
789
                                    mkdir($target_path, 0755);
705
                                
790
                                }
706
                                $full_filename          = $interal_path . DIRECTORY_SEPARATOR. $feed_filename;
791
    
707
                                $poster_filename        = substr($feed_filename, 0, strrpos($feed_filename, '.')).  '.jpg';
792
                                $full_filename = $target_path  . DIRECTORY_SEPARATOR . $feed_filename;
-
 
793
    
708
                                $poster_full_filename   = $interal_path . DIRECTORY_SEPARATOR . $poster_filename;
794
                                $result = move_uploaded_file($feed_tmp_filename, $full_filename);
-
 
795
                                if ($result) {
709
                                
796
    
-
 
797
                                    $size = $this->config['leaderslinked.image_sizes.feed_image_size'];
-
 
798
                                    $cmd        = "/usr/bin/ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width,duration  $full_filename";
710
                                move_uploaded_file($feed_tmp_filename, $full_filename);
799
                                    //error_log($cmd);
711
                                
800
        
712
                                $cmd        = "/usr/bin/ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width,duration  $full_filename";
801
                                    $response   = trim(shell_exec($cmd));
-
 
802
        
-
 
803
                                    $source_duration = 0;
713
                                $response   = trim(shell_exec($cmd));
804
        
714
                                
805
        
715
                                $source_duration = 0;
806
                                    $lines = explode("\n", $response);
716
                                $lines = explode("\n", $response);
807
                                    foreach ($lines as $line) {
717
                                foreach ($lines as $line) {
808
                                        $line = trim(strtolower($line));
718
                                    $line = trim(strtolower($line));
809
                                        if (strpos($line, 'duration') !== false) {
-
 
810
                                            $values = explode('=', $line);
719
                                    if (strpos($line, 'duration') !== false) {
-
 
720
                                        $values = explode('=', $line);
811
                                            $source_duration = intval(str_replace($values[1], '#', ''), 10);
721
                                        $source_duration = intval(str_replace($values[1], '#', ''), 10);
812
                                        }
722
                                    }
-
 
723
                                }
-
 
724
                                
-
 
725
                                
813
                                    }
726
                                if ($source_duration == 0) {
814
        
727
                                    $second_extract = '00:00:02';
815
        
728
                                } else {
816
                                    if ($source_duration == 0) {
-
 
817
                                        $second_extract = '00:00:02';
-
 
818
                                    } else {
-
 
819
                                        if ($source_duration > 10) {
729
                                    if ($source_duration > 10) {
820
                                            $second_extract = '00:00:10';
-
 
821
                                        } else {
730
                                        $second_extract = '00:00:10';
-
 
731
                                    } else {
822
                                            $second_extract = '00:00:02';
732
                                        $second_extract = '00:00:02';
823
                                        }
-
 
824
                                    }
733
                                    }
-
 
734
                                }
825
    
735
                                
826
                                    //extracción del cover
736
                                //$imageSize = $this->config['leaderslinked.image_sizes.feed_image_size'];
827
                                    $generateFileName = substr($feed_filename, 0, strrpos($feed_filename, '.'));
737
                                
828
                                    $generateFile =  $target_path  . DIRECTORY_SEPARATOR . $generateFileName .  '.jpg';
738
                                //$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";
-
 
739
                                // $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";
-
 
740
                                $cmd = "/usr/bin/ffmpeg -y -i $full_filename  -pix_fmt yuvj422p -an -ss $second_extract -f mjpeg -t 1 -r 1 -y  $poster_full_filename";
-
 
741
                                exec($cmd);
-
 
742
                                
829
                                    //$cmd            = "/usr/bin/ffmpeg -i $full_filename -an -ss $getFromSecound -s $size $generateFile";
743
                                
-
 
744
                                $ok = $this->storage->putFile($target_path, $feed->uuid, $poster_full_filename);
830
                                    $cmd = "/usr/bin/ffmpeg -y -i $full_filename  -pix_fmt yuvj422p -an -ss  $second_extract -f mjpeg -t 1 -r 1 -y  $generateFile";
745
                                $ok = $ok && $this->storage->putFile($target_path, $feed->uuid, $full_filename);
831
                                    exec($cmd);
746
                                
832
    
747
                                if( $ok ) {
833
    
748
                                    
-
 
749
                                    $feed->file_type = $file_type;
-
 
750
                                    $feed->file_name = basename($feed_filename);
-
 
751
                                    $feed->file_image_preview = basename($poster_filename);;
834
                                    $feed->file_type = $file_type;
752
                                    
835
                                    $feed->file_name = basename($feed_filename);
753
                                    
836
                                    $feed->file_image_preview = basename($generateFile);
754
                                    
-
 
755
                                    if($feedMapper->update($feed)) {
837
                                    $feedMapper->update($feed);
756
                                        
838
    
757
                                        $videoConvert               = new VideoConvert();
839
                                    $videoConvert = new VideoConvert();
758
                                        $videoConvert->uuid         = $feed->uuid;
840
                                    $videoConvert->filename = $full_filename;
759
                                        $videoConvert->filename     = basename($feed_filename);
841
                                    $videoConvert->type = VideoConvert::TYPE_FEED;
760
                                        $videoConvert->type         = VideoConvert::TYPE_FEED;
842
    
761
                                        
843
                                    $videoConvertMapper = VideoConvertMapper::getInstance($this->adapter);
-
 
844
                                    $videoConvertMapper->insert($videoConvert);
762
                                        $videoConvertMapper = VideoConvertMapper::getInstance($this->adapter);
-
 
763
                                        $videoConvertMapper->insert($videoConvert);
-
 
764
                                    }
-
 
765
                                }
-
 
766
                                
-
 
767
                                // @unlink($full_filename);
845
                                } else {
768
                                //@unlink($generate_full_filename);
846
                                    error_log('no se pudo mover o renombrar el documento : ' . $feed_tmp_filename . ' al directorio : ' . $full_filename);
769
                                
847
                                }
770
                                
848
                            } catch (\Throwable $e) {
771
                            } catch (\Throwable $e) {
Línea 900... Línea 823...
900
 
823
 
901
 
824
 
Línea 902... Línea 825...
902
        $request = $this->getRequest();
825
        $request = $this->getRequest();
903
        if ($request->isGet()) {
-
 
904
 
-
 
905
            $page = (int) $this->params()->fromQuery('page');
-
 
906
            $type   = $this->params()->fromRoute('type');
826
        if ($request->isGet()) {
907
            $topic_uuid   = $this->params()->fromRoute('topic_id');
-
 
908
            $urgent   = $this->params()->fromRoute('urgent');
-
 
909
            $myt_id =  $this->params()->fromRoute('myt_id');
-
 
910
            //$hptg_uuid =  $this->params()->fromRoute('hptg_id');
-
 
911
 
-
 
912
 
-
 
913
            /*
-
 
914
            if ($hptg_uuid) {
-
 
915
 
-
 
916
 
-
 
917
                $highPerformanceTeamsGroupsMapper = HighPerformanceTeamsGroupsMapper::getInstance($this->adapter);
-
 
918
                $now = $highPerformanceTeamsGroupsMapper->getDatebaseNow();
-
 
919
                
-
 
920
                $highPerformanceTeamsGroups = $highPerformanceTeamsGroupsMapper->fetchOneByUuid($hptg_uuid);
-
 
921
 
-
 
922
                if (!$highPerformanceTeamsGroups) {
-
 
923
                    $data = [
-
 
924
                        'success' => false,
-
 
925
                        'data' => 'ERROR_RECORD_NOT_FOUND'
-
 
926
                    ];
-
 
927
 
-
 
928
                    return new JsonModel($data);
-
 
929
                }
-
 
930
 
-
 
931
                if ($highPerformanceTeamsGroups->status != HighPerformanceTeamsGroups::STATUS_ACTIVE) {
-
 
932
 
-
 
933
                    return new JsonModel([
-
 
934
                        'success' => false,
-
 
935
                        'data' => 'ERROR_UNAUTHORIZED'
-
 
936
                    ]);
-
 
937
                }
-
 
938
 
-
 
939
                $highPerformanceTeamsGroupsMemberMapper = HighPerformanceTeamsGroupsMembersMapper::getInstance($this->adapter);
-
 
940
                $highPerformanceTeamsGroupsMember = $highPerformanceTeamsGroupsMemberMapper->fetchOneByGroupIdAndUserId($highPerformanceTeamsGroups->id, $currentUser->id);
-
 
941
                if ($highPerformanceTeamsGroupsMember) {
-
 
942
                    if ($highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ACCEPTED || $highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ADDED_BY_ADMIN) {
-
 
943
                        $queryMapper = QueryMapper::getInstance($this->adapter);
-
 
944
                        $select = $queryMapper->getSql()->select(FeedMapper::_TABLE);
-
 
945
                        $select->columns(['id']);
-
 
946
                        $select->where->equalTo('status', Feed::STATUS_PUBLISHED);
-
 
947
                        $select->where->equalTo('company_id', $currentCompany->id);
-
 
948
                        $select->where->equalTo('high_performance_group_id', $highPerformanceTeamsGroups->id);
-
 
949
 
-
 
950
 
-
 
951
                        if (isset($topic_uuid)) {
-
 
952
                            $topicMapper = TopicMapper::getInstance($this->adapter);
-
 
953
                            $topic = $topicMapper->fetchOneByUuid($topic_uuid);
-
 
954
                            if ($topic) {
-
 
955
                                if ($topic->status != 'a') {
-
 
956
                                    return new JsonModel([
-
 
957
                                        'success' => false,
-
 
958
                                        'data' => 'ERROR_YOU_DO_NOT_HAVE_ACCESS'
-
 
959
                                    ]);
-
 
960
                                }
-
 
961
                                $select->where->equalTo('topic_id', $topic->id);
-
 
962
                            } else {
-
 
963
                                return new JsonModel([
-
 
964
                                    'success' => false,
-
 
965
                                    'data' => 'ERROR_RECORD_NOT_FOUND'
-
 
966
                                ]);
-
 
967
                            }
-
 
968
                        } else {
-
 
969
                            if (isset($urgent)) {
-
 
970
                                $select->where->equalTo('priority', Feed::PRIORITY_URGENT);
-
 
971
                            } else {
-
 
972
                                $select->where->IsNull('topic_id');
-
 
973
                            }
-
 
974
                        }
-
 
975
 
-
 
976
 
-
 
977
                        $select->where->and->equalTo('type', Feed::TYPE_HPTG);
-
 
978
                        $select->order('added_on desc');
-
 
979
                    } else {
-
 
980
                        return new JsonModel([
-
 
981
                            'success' => false,
-
 
982
                            'data' => 'ERROR_UNAUTHORIZED'
-
 
983
                        ]);
827
 
984
                    }
-
 
985
                } else {
-
 
986
 
-
 
987
                    return new JsonModel([
-
 
988
                        'success' => false,
-
 
989
                        'data' => 'ERROR_RECORD_NOT_FOUND'
-
 
990
                    ]);
-
 
991
                }
828
            $page   = (int) $this->params()->fromQuery('page');
992
            } else 
829
            $myt_id = $this->params()->fromRoute('myt_id');
993
            */
830
            
Línea 994... Línea 831...
994
            if ($myt_id) {
831
            if ($myt_id) {
Línea 1273... Línea 1110...
1273
 
1110
 
1274
        $params = [
1111
        $params = [
1275
            'id' => $feed->uuid
1112
            'id' => $feed->uuid
Línea -... Línea 1113...
-
 
1113
        ];
-
 
1114
 
Línea 1276... Línea 1115...
1276
        ];
1115
        $storage = Storage::getInstance($this->config);
1277
 
1116
        $path = $storage->getPathFeed();
1278
 
1117
 
1279
        $item = [
1118
        $item = [
1280
            'feed_unique' => uniqid(),
1119
            'feed_unique' => uniqid(),
1281
            'feed_uuid' => $feed->uuid,
1120
            'feed_uuid' => $feed->uuid,
1282
            'feed_content_type' => $feed->file_type ? $feed->file_type : '',
1121
            'feed_content_type' => $feed->file_type ? $feed->file_type : '',
1283
            'owner_url' =>  'https://' . $network->main_hostname . '/company/view/' . $company->uuid,
1122
            'owner_url' =>  'https://' . $network->main_hostname . '/company/view/' . $company->uuid,
Línea 1346... Línea 1185...
1346
 
1185
 
Línea 1347... Línea 1186...
1347
 
1186
 
1348
        $item['owner_time_elapse'] = Functions::timeAgo($feed->added_on, $now);
1187
        $item['owner_time_elapse'] = Functions::timeAgo($feed->added_on, $now);
1349
 
1188
 
1350
        if ($feed->file_type == Feed::FILE_TYPE_IMAGE) {
1189
        if ($feed->file_type == Feed::FILE_TYPE_IMAGE) {
1351
            $item['owner_file_image'] = $this->url()->fromRoute('storage', ['code' => $feed->uuid, 'type' => 'feed', 'filename' => $feed->file_name]);
1190
            $item['owner_file_image'] = $storage->getGenericImage($path, $feed->uuid,  $feed->file_name);
1352
        }
1191
        }
1353
        if ($feed->file_type == Feed::FILE_TYPE_DOCUMENT) {
1192
        if ($feed->file_type == Feed::FILE_TYPE_DOCUMENT) {
1354
            $item['owner_file_document'] = $this->url()->fromRoute('storage', ['code' => $feed->uuid, 'type' => 'feed', 'filename' => $feed->file_name]);
1193
            $item['owner_file_document'] = $storage->getGenericFile($path, $feed->uuid,  $feed->file_name);
1355
        }
1194
        }
1356
        if ($feed->file_type == Feed::FILE_TYPE_VIDEO) {
1195
        if ($feed->file_type == Feed::FILE_TYPE_VIDEO) {
Línea 1378... Línea 1217...
1378
                $comment['unique'] = uniqid();
1217
                $comment['unique'] = uniqid();
1379
                $comment_count++;
1218
                $comment_count++;
1380
                $comment['comment_index'] = $comment_count;
1219
                $comment['comment_index'] = $comment_count;
1381
                $user = $userMapper->fetchOne($record->user_id);
1220
                $user = $userMapper->fetchOne($record->user_id);
1382
                if ($user->id == $owner->user_id) {
1221
                if ($user->id == $owner->user_id) {
1383
                    $comment['user_image'] = $this->url()->fromRoute('storage', ['type' => 'company',  'code' => $company->uuid, 'filename' =>  $company->image]);
1222
                    $comment['user_image'] = $storage->getCompanyImage($company);
1384
                    $comment['user_url'] =  'https://' . $network->main_hostname . '/company/view/' . $company->uuid;
1223
                    $comment['user_url'] =  'https://' . $network->main_hostname . '/company/view/' . $company->uuid;
1385
                    $comment['user_name'] = $company->name;
1224
                    $comment['user_name'] = $company->name;
1386
                } else {
1225
                } else {
1387
                    $comment['user_image'] = $this->url()->fromRoute('storage', ['type' => 'user',  'code' => $user->uuid, 'filename' =>  $user->image]);
1226
                    $comment['user_image'] = $storage->getUserImage($user->uuid);
1388
                    $comment['user_url'] = 'https://' . $network->main_hostname . '/profile/view/' . $user->uuid;
1227
                    $comment['user_url'] = 'https://' . $network->main_hostname . '/profile/view/' . $user->uuid;
1389
                    $comment['user_name'] = $user->first_name . ' ' . $user->last_name;
1228
                    $comment['user_name'] = $user->first_name . ' ' . $user->last_name;
1390
                }
1229
                }
1391
                $comment['link_delete'] = $this->url()->fromRoute('feeds/comments/delete', ['id' => $feed->uuid, 'comment' => $record->uuid]);
1230
                $comment['link_delete'] = $this->url()->fromRoute('feeds/comments/delete', ['id' => $feed->uuid, 'comment' => $record->uuid]);
1392
                $comment['link_answer_add'] = $this->url()->fromRoute('feeds/comments/answer', ['id' => $feed->uuid, 'comment' => $record->uuid]);
1231
                $comment['link_answer_add'] = $this->url()->fromRoute('feeds/comments/answer', ['id' => $feed->uuid, 'comment' => $record->uuid]);
Línea 1404... Línea 1243...
1404
                    $answer['unique'] = uniqid();
1243
                    $answer['unique'] = uniqid();
Línea 1405... Línea 1244...
1405
    
1244
    
1406
    
1245
    
1407
                    $user = $userMapper->fetchOne($record2->user_id);
1246
                    $user = $userMapper->fetchOne($record2->user_id);
1408
                    if ($user->id == $owner->user_id) {
1247
                    if ($user->id == $owner->user_id) {
1409
                        $answer['user_image'] = $this->url()->fromRoute('storage', ['type' => 'company',  'code' => $company->uuid, 'filename' =>  $company->image]);
1248
                        $answer['user_image'] = $storage->getCompanyImage($company);
1410
                        $answer['user_url'] =  'https://' . $network->main_hostname . '/company/view/' . $company->uuid;
1249
                        $answer['user_url'] =  'https://' . $network->main_hostname . '/company/view/' . $company->uuid;
1411
                        $answer['user_name'] = $company->name;
1250
                        $answer['user_name'] = $company->name;
1412
                    } else {
1251
                    } else {
1413
                        $answer['user_image'] = $this->url()->fromRoute('storage', ['type' => 'user',  'code' => $user->uuid, 'filename' =>  $user->image]);
1252
                        $answer['user_image'] = $storage->getUserImage( $user);
1414
                        $answer['user_url'] = 'https://' . $network->main_hostname . '/profile/view/' . $user->uuid;
1253
                        $answer['user_url'] = 'https://' . $network->main_hostname . '/profile/view/' . $user->uuid;
1415
                        $answer['user_name'] = $user->first_name . ' ' . $user->last_name;
1254
                        $answer['user_name'] = $user->first_name . ' ' . $user->last_name;
1416
                    }
1255
                    }
Línea 1428... Línea 1267...
1428
                array_push($comments, $comment);
1267
                array_push($comments, $comment);
1429
            }
1268
            }
1430
            $item['comment_add_url'] = $this->url()->fromRoute('feeds/comments', ['id' => $feed->uuid]);
1269
            $item['comment_add_url'] = $this->url()->fromRoute('feeds/comments', ['id' => $feed->uuid]);
1431
            $item['comments'] = $comments;
1270
            $item['comments'] = $comments;
1432
        }
1271
        }
1433
        
-
 
1434
        //echo '<pre>';
-
 
1435
       // print_r($item);
-
 
1436
        //echo '</pre>';
-
 
1437
        //exit;
-
 
Línea 1438... Línea 1272...
1438
 
1272
 
1439
 
1273
 
Línea 1481... Línea 1315...
1481
 
1315
 
1482
 
1316
 
Línea -... Línea 1317...
-
 
1317
            $item = [];
-
 
1318
            $item['unique'] = uniqid();
Línea 1483... Línea 1319...
1483
            $item = [];
1319
 
1484
            $item['unique'] = uniqid();
1320
            $storage = Storage::getInstance($this->config);
1485
 
1321
            
1486
 
1322
 
1487
            $user = $userMapper->fetchOne($record->user_id);
1323
            $user = $userMapper->fetchOne($record->user_id);
1488
            if ($user->id == $owner->user_id) {
1324
            if ($user->id == $owner->user_id) {
1489
                $item['user_image'] = $this->url()->fromRoute('storage', ['type' => 'company',  'code' => $company->uuid, 'filename' =>  $company->image]);
1325
                $item['user_image'] = $storage->getCompanyImage($company);
1490
                $item['user_url'] =  'https://' . $network->main_hostname . '/company/view/' . $company->uuid;
1326
                $item['user_url'] =  'https://' . $network->main_hostname . '/company/view/' . $company->uuid;
1491
                $item['user_name'] = $company->name;
1327
                $item['user_name'] = $company->name;
1492
            } else {
1328
            } else {