Conditions | 46 |
Total Lines | 778 |
Code Lines | 433 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
627 | public function getPersonalDataToJson(int $userId, array $substitutionTerms) |
||
628 | { |
||
629 | $em = $this->getEntityManager(); |
||
630 | $dateFormat = Datetime::ATOM; |
||
631 | |||
632 | /** @var User $user */ |
||
633 | $user = $this->find($userId); |
||
634 | |||
635 | $user->setPassword($substitutionTerms['password']); |
||
636 | $user->setSalt($substitutionTerms['salt']); |
||
637 | |||
638 | $noDataLabel = $substitutionTerms['empty']; |
||
639 | |||
640 | // Dummy content |
||
641 | $user->setDateOfBirth(null); |
||
642 | //$user->setBiography($noDataLabel); |
||
643 | /*$user->setFacebookData($noDataLabel); |
||
644 | $user->setFacebookName($noDataLabel); |
||
645 | $user->setFacebookUid($noDataLabel);*/ |
||
646 | //$user->setImageName($noDataLabel); |
||
647 | //$user->setTwoStepVerificationCode($noDataLabel); |
||
648 | //$user->setGender($noDataLabel); |
||
649 | /*$user->setGplusData($noDataLabel); |
||
650 | $user->setGplusName($noDataLabel); |
||
651 | $user->setGplusUid($noDataLabel);*/ |
||
652 | $user->setLocale($noDataLabel); |
||
653 | $user->setTimezone($noDataLabel); |
||
654 | /*$user->setTwitterData($noDataLabel); |
||
655 | $user->setTwitterName($noDataLabel); |
||
656 | $user->setTwitterUid($noDataLabel);*/ |
||
657 | $user->setWebsite($noDataLabel); |
||
658 | //$user->setToken($noDataLabel); |
||
659 | |||
660 | $friends = SocialManager::get_friends($userId); |
||
661 | $friendList = []; |
||
662 | if (!empty($friends)) { |
||
663 | foreach ($friends as $friend) { |
||
664 | $friendList[] = $friend['user_info']['complete_name']; |
||
665 | } |
||
666 | } |
||
667 | |||
668 | $agenda = new Agenda('personal'); |
||
669 | $events = $agenda->getEvents(0, 0, 0, 0, $userId, 'array'); |
||
670 | $eventList = []; |
||
671 | if (!empty($events)) { |
||
672 | foreach ($events as $event) { |
||
673 | $eventList[] = $event['title'].' '.$event['start_date_localtime'].' / '.$event['end_date_localtime']; |
||
674 | } |
||
675 | } |
||
676 | |||
677 | // GradebookCertificate |
||
678 | $result = $em->getRepository(GradebookCertificate::class)->findBy([ |
||
679 | 'user' => $userId, |
||
680 | ]); |
||
681 | $gradebookCertificate = []; |
||
682 | /** @var GradebookCertificate $item */ |
||
683 | foreach ($result as $item) { |
||
684 | $createdAt = $item->getCreatedAt()->format($dateFormat); |
||
685 | $list = [ |
||
686 | 'Score: '.$item->getScoreCertificate(), |
||
687 | 'Path: '.$item->getPathCertificate(), |
||
688 | 'Created at: '.$createdAt, |
||
689 | ]; |
||
690 | $gradebookCertificate[] = implode(', ', $list); |
||
691 | } |
||
692 | |||
693 | // TrackEExercises |
||
694 | $criteria = [ |
||
695 | 'exeUserId' => $userId, |
||
696 | ]; |
||
697 | $result = $em->getRepository(TrackEExercises::class)->findBy($criteria); |
||
698 | $trackEExercises = []; |
||
699 | /** @var TrackEExercises $item */ |
||
700 | foreach ($result as $item) { |
||
701 | $date = $item->getExeDate()->format($dateFormat); |
||
702 | $list = [ |
||
703 | 'IP: '.$item->getUserIp(), |
||
704 | 'Start: '.$date, |
||
705 | 'Status: '.$item->getStatus(), |
||
706 | // 'Result: '.$item->getExeResult(), |
||
707 | // 'Weighting: '.$item->getExeWeighting(), |
||
708 | ]; |
||
709 | $trackEExercises[] = implode(', ', $list); |
||
710 | } |
||
711 | |||
712 | // TrackEAttempt |
||
713 | $criteria = [ |
||
714 | 'user' => $userId, |
||
715 | ]; |
||
716 | $result = $em->getRepository(TrackEAttempt::class)->findBy($criteria); |
||
717 | $trackEAttempt = []; |
||
718 | /** @var TrackEAttempt $item */ |
||
719 | foreach ($result as $item) { |
||
720 | $date = $item->getTms()->format($dateFormat); |
||
721 | $list = [ |
||
722 | 'Attempt #'.$item->getExeId(), |
||
723 | 'Course # '.$item->getCourse()->getCode(), |
||
724 | //'Answer: '.$item->getAnswer(), |
||
725 | 'Session #'.$item->getSessionId(), |
||
726 | //'Marks: '.$item->getMarks(), |
||
727 | 'Position: '.$item->getPosition(), |
||
728 | 'Date: '.$date, |
||
729 | ]; |
||
730 | $trackEAttempt[] = implode(', ', $list); |
||
731 | } |
||
732 | |||
733 | // TrackECourseAccess |
||
734 | $criteria = [ |
||
735 | 'user' => $userId, |
||
736 | ]; |
||
737 | $result = $em->getRepository(TrackECourseAccess::class)->findBy($criteria); |
||
738 | $trackECourseAccessList = []; |
||
739 | /** @var TrackECourseAccess $item */ |
||
740 | foreach ($result as $item) { |
||
741 | $startDate = $item->getLoginCourseDate()->format($dateFormat); |
||
742 | $endDate = null !== $item->getLogoutCourseDate() ? $item->getLogoutCourseDate()->format($dateFormat) : ''; |
||
743 | $list = [ |
||
744 | 'IP: '.$item->getUserIp(), |
||
745 | 'Start: '.$startDate, |
||
746 | 'End: '.$endDate, |
||
747 | ]; |
||
748 | $trackECourseAccessList[] = implode(', ', $list); |
||
749 | } |
||
750 | |||
751 | $checkEntities = [ |
||
752 | TrackELogin::class => 'loginUserId', |
||
753 | TrackEAccess::class => 'accessUserId', |
||
754 | TrackEOnline::class => 'loginUserId', |
||
755 | TrackEDefault::class => 'defaultUserId', |
||
756 | TrackELastaccess::class => 'accessUserId', |
||
757 | TrackEUploads::class => 'uploadUserId', |
||
758 | GradebookResult::class => 'user', |
||
759 | TrackEDownloads::class => 'downUserId', |
||
760 | ]; |
||
761 | |||
762 | $maxResults = 1000; |
||
763 | $trackResults = []; |
||
764 | foreach ($checkEntities as $entity => $field) { |
||
765 | $qb = $em->createQueryBuilder(); |
||
766 | $qb->select($qb->expr()->count('l')) |
||
767 | ->from($entity, 'l') |
||
768 | ->where("l.$field = :login") |
||
769 | ->setParameter('login', $userId) |
||
770 | ; |
||
771 | $query = $qb->getQuery(); |
||
772 | $count = $query->getSingleScalarResult(); |
||
773 | |||
774 | if ($count > $maxResults) { |
||
775 | $qb = $em->getRepository($entity)->createQueryBuilder('l'); |
||
776 | $qb |
||
777 | ->select('l') |
||
778 | ->where("l.$field = :login") |
||
779 | ->setParameter('login', $userId) |
||
780 | ; |
||
781 | $qb |
||
782 | ->setFirstResult(0) |
||
783 | ->setMaxResults($maxResults) |
||
784 | ; |
||
785 | $result = $qb->getQuery()->getResult(); |
||
786 | } else { |
||
787 | $criteria = [ |
||
788 | $field => $userId, |
||
789 | ]; |
||
790 | $result = $em->getRepository($entity)->findBy($criteria); |
||
791 | } |
||
792 | $trackResults[$entity] = $result; |
||
793 | } |
||
794 | |||
795 | $trackELoginList = []; |
||
796 | /** @var TrackELogin $item */ |
||
797 | foreach ($trackResults[TrackELogin::class] as $item) { |
||
798 | $startDate = $item->getLoginDate()->format($dateFormat); |
||
799 | $endDate = null !== $item->getLogoutDate() ? $item->getLogoutDate()->format($dateFormat) : ''; |
||
800 | $list = [ |
||
801 | 'IP: '.$item->getUserIp(), |
||
802 | 'Start: '.$startDate, |
||
803 | 'End: '.$endDate, |
||
804 | ]; |
||
805 | $trackELoginList[] = implode(', ', $list); |
||
806 | } |
||
807 | |||
808 | // TrackEAccess |
||
809 | $trackEAccessList = []; |
||
810 | /** @var TrackEAccess $item */ |
||
811 | foreach ($trackResults[TrackEAccess::class] as $item) { |
||
812 | $date = $item->getAccessDate()->format($dateFormat); |
||
813 | $list = [ |
||
814 | 'IP: '.$item->getUserIp(), |
||
815 | 'Tool: '.$item->getAccessTool(), |
||
816 | 'End: '.$date, |
||
817 | ]; |
||
818 | $trackEAccessList[] = implode(', ', $list); |
||
819 | } |
||
820 | |||
821 | // TrackEOnline |
||
822 | $trackEOnlineList = []; |
||
823 | /** @var TrackEOnline $item */ |
||
824 | foreach ($trackResults[TrackEOnline::class] as $item) { |
||
825 | $date = $item->getLoginDate()->format($dateFormat); |
||
826 | $list = [ |
||
827 | 'IP: '.$item->getUserIp(), |
||
828 | 'Login date: '.$date, |
||
829 | 'Course # '.$item->getCId(), |
||
830 | 'Session # '.$item->getSessionId(), |
||
831 | ]; |
||
832 | $trackEOnlineList[] = implode(', ', $list); |
||
833 | } |
||
834 | |||
835 | // TrackEDefault |
||
836 | $trackEDefault = []; |
||
837 | /** @var TrackEDefault $item */ |
||
838 | foreach ($trackResults[TrackEDefault::class] as $item) { |
||
839 | $date = $item->getDefaultDate()->format($dateFormat); |
||
840 | $list = [ |
||
841 | 'Type: '.$item->getDefaultEventType(), |
||
842 | 'Value: '.$item->getDefaultValue(), |
||
843 | 'Value type: '.$item->getDefaultValueType(), |
||
844 | 'Date: '.$date, |
||
845 | 'Course #'.$item->getCId(), |
||
846 | 'Session # '.$item->getSessionId(), |
||
847 | ]; |
||
848 | $trackEDefault[] = implode(', ', $list); |
||
849 | } |
||
850 | |||
851 | // TrackELastaccess |
||
852 | $trackELastaccess = []; |
||
853 | /** @var TrackELastaccess $item */ |
||
854 | foreach ($trackResults[TrackELastaccess::class] as $item) { |
||
855 | $date = $item->getAccessDate()->format($dateFormat); |
||
856 | $list = [ |
||
857 | 'Course #'.$item->getCId(), |
||
858 | 'Session # '.$item->getAccessSessionId(), |
||
859 | 'Tool: '.$item->getAccessTool(), |
||
860 | 'Access date: '.$date, |
||
861 | ]; |
||
862 | $trackELastaccess[] = implode(', ', $list); |
||
863 | } |
||
864 | |||
865 | // TrackEUploads |
||
866 | $trackEUploads = []; |
||
867 | /** @var TrackEUploads $item */ |
||
868 | foreach ($trackResults[TrackEUploads::class] as $item) { |
||
869 | $date = $item->getUploadDate()->format($dateFormat); |
||
870 | $list = [ |
||
871 | 'Course #'.$item->getCId(), |
||
872 | 'Uploaded at: '.$date, |
||
873 | 'Upload id # '.$item->getUploadId(), |
||
874 | ]; |
||
875 | $trackEUploads[] = implode(', ', $list); |
||
876 | } |
||
877 | |||
878 | $gradebookResult = []; |
||
879 | /** @var GradebookResult $item */ |
||
880 | foreach ($trackResults[GradebookResult::class] as $item) { |
||
881 | $date = $item->getCreatedAt()->format($dateFormat); |
||
882 | $list = [ |
||
883 | 'Evaluation id# '.$item->getEvaluation()->getId(), |
||
884 | //'Score: '.$item->getScore(), |
||
885 | 'Creation date: '.$date, |
||
886 | ]; |
||
887 | $gradebookResult[] = implode(', ', $list); |
||
888 | } |
||
889 | |||
890 | $trackEDownloads = []; |
||
891 | /** @var TrackEDownloads $item */ |
||
892 | foreach ($trackResults[TrackEDownloads::class] as $item) { |
||
893 | $date = $item->getDownDate()->format($dateFormat); |
||
894 | $list = [ |
||
895 | 'File: '.$item->getDownDocPath(), |
||
896 | 'Download at: '.$date, |
||
897 | ]; |
||
898 | $trackEDownloads[] = implode(', ', $list); |
||
899 | } |
||
900 | |||
901 | // UserCourseCategory |
||
902 | $criteria = [ |
||
903 | 'user' => $userId, |
||
904 | ]; |
||
905 | $result = $em->getRepository(UserCourseCategory::class)->findBy($criteria); |
||
906 | $userCourseCategory = []; |
||
907 | /** @var UserCourseCategory $item */ |
||
908 | foreach ($result as $item) { |
||
909 | $list = [ |
||
910 | 'Title: '.$item->getTitle(), |
||
911 | ]; |
||
912 | $userCourseCategory[] = implode(', ', $list); |
||
913 | } |
||
914 | |||
915 | // Forum |
||
916 | $criteria = [ |
||
917 | 'user' => $userId, |
||
918 | ]; |
||
919 | $result = $em->getRepository(CForumPost::class)->findBy($criteria); |
||
920 | $cForumPostList = []; |
||
921 | /** @var CForumPost $item */ |
||
922 | foreach ($result as $item) { |
||
923 | $date = $item->getPostDate()->format($dateFormat); |
||
924 | $list = [ |
||
925 | 'Title: '.$item->getPostTitle(), |
||
926 | 'Creation date: '.$date, |
||
927 | ]; |
||
928 | $cForumPostList[] = implode(', ', $list); |
||
929 | } |
||
930 | |||
931 | // CForumThread |
||
932 | $criteria = [ |
||
933 | 'user' => $userId, |
||
934 | ]; |
||
935 | $result = $em->getRepository(CForumThread::class)->findBy($criteria); |
||
936 | $cForumThreadList = []; |
||
937 | /** @var CForumThread $item */ |
||
938 | foreach ($result as $item) { |
||
939 | $date = $item->getThreadDate()->format($dateFormat); |
||
940 | $list = [ |
||
941 | 'Title: '.$item->getThreadTitle(), |
||
942 | 'Creation date: '.$date, |
||
943 | ]; |
||
944 | $cForumThreadList[] = implode(', ', $list); |
||
945 | } |
||
946 | |||
947 | // CForumAttachment |
||
948 | /*$criteria = [ |
||
949 | 'threadPosterId' => $userId, |
||
950 | ]; |
||
951 | $result = $em->getRepository('ChamiloCourseBundle:CForumAttachment')->findBy($criteria); |
||
952 | $cForumThreadList = []; |
||
953 | * @var CForumThread $item |
||
954 | foreach ($result as $item) { |
||
955 | $list = [ |
||
956 | 'Title: '.$item->getThreadTitle(), |
||
957 | 'Creation date: '.$item->getThreadDate()->format($dateFormat), |
||
958 | ]; |
||
959 | $cForumThreadList[] = implode(', ', $list); |
||
960 | }*/ |
||
961 | |||
962 | // cGroupRelUser |
||
963 | $criteria = [ |
||
964 | 'user' => $userId, |
||
965 | ]; |
||
966 | $result = $em->getRepository(CGroupRelUser::class)->findBy($criteria); |
||
967 | $cGroupRelUser = []; |
||
968 | /** @var CGroupRelUser $item */ |
||
969 | foreach ($result as $item) { |
||
970 | $list = [ |
||
971 | 'Course # '.$item->getCId(), |
||
972 | 'Group #'.$item->getGroup()->getIid(), |
||
973 | 'Role: '.$item->getStatus(), |
||
974 | ]; |
||
975 | $cGroupRelUser[] = implode(', ', $list); |
||
976 | } |
||
977 | |||
978 | // CAttendanceSheet |
||
979 | $criteria = [ |
||
980 | 'user' => $userId, |
||
981 | ]; |
||
982 | $result = $em->getRepository(CAttendanceSheet::class)->findBy($criteria); |
||
983 | $cAttendanceSheetList = []; |
||
984 | /** @var CAttendanceSheet $item */ |
||
985 | foreach ($result as $item) { |
||
986 | $list = [ |
||
987 | 'Presence: '.$item->getPresence(), |
||
988 | 'Calendar id: '.$item->getAttendanceCalendar()->getIid(), |
||
989 | ]; |
||
990 | $cAttendanceSheetList[] = implode(', ', $list); |
||
991 | } |
||
992 | |||
993 | // CBlogPost |
||
994 | $criteria = [ |
||
995 | 'authorId' => $userId, |
||
996 | ]; |
||
997 | $result = $em->getRepository(CBlogPost::class)->findBy($criteria); |
||
998 | $cBlog = []; |
||
999 | /** @var CBlogPost $item */ |
||
1000 | foreach ($result as $item) { |
||
1001 | $date = $item->getDateCreation()->format($dateFormat); |
||
1002 | $list = [ |
||
1003 | 'Title: '.$item->getTitle(), |
||
1004 | 'Date: '.$date, |
||
1005 | ]; |
||
1006 | $cBlog[] = implode(', ', $list); |
||
1007 | } |
||
1008 | |||
1009 | // CAttendanceResult |
||
1010 | $criteria = [ |
||
1011 | 'user' => $userId, |
||
1012 | ]; |
||
1013 | $result = $em->getRepository(CAttendanceResult::class)->findBy($criteria); |
||
1014 | $cAttendanceResult = []; |
||
1015 | /** @var CAttendanceResult $item */ |
||
1016 | foreach ($result as $item) { |
||
1017 | $list = [ |
||
1018 | 'Score : '.$item->getScore(), |
||
1019 | 'Calendar id: '.$item->getAttendance()->getIid(), |
||
1020 | ]; |
||
1021 | $cAttendanceResult[] = implode(', ', $list); |
||
1022 | } |
||
1023 | |||
1024 | // Message |
||
1025 | $criteria = [ |
||
1026 | 'userSender' => $userId, |
||
1027 | ]; |
||
1028 | $result = $em->getRepository(Message::class)->findBy($criteria); |
||
1029 | $messageList = []; |
||
1030 | /** @var Message $item */ |
||
1031 | foreach ($result as $item) { |
||
1032 | $date = $item->getSendDate()->format($dateFormat); |
||
1033 | $userName = ''; |
||
1034 | if ($item->getUserReceiver()) { |
||
1035 | $userName = $item->getUserReceiver()->getUsername(); |
||
1036 | } |
||
1037 | $list = [ |
||
1038 | 'Title: '.$item->getTitle(), |
||
1039 | 'Sent date: '.$date, |
||
1040 | 'To user: '.$userName, |
||
1041 | 'Status'.$item->getMsgStatus(), |
||
1042 | ]; |
||
1043 | $messageList[] = implode(', ', $list); |
||
1044 | } |
||
1045 | |||
1046 | // CSurveyAnswer |
||
1047 | $criteria = [ |
||
1048 | 'user' => $userId, |
||
1049 | ]; |
||
1050 | $result = $em->getRepository(CSurveyAnswer::class)->findBy($criteria); |
||
1051 | $cSurveyAnswer = []; |
||
1052 | /** @var CSurveyAnswer $item */ |
||
1053 | foreach ($result as $item) { |
||
1054 | $list = [ |
||
1055 | 'Answer # '.$item->getIid(), |
||
1056 | 'Value: '.$item->getValue(), |
||
1057 | ]; |
||
1058 | $cSurveyAnswer[] = implode(', ', $list); |
||
1059 | } |
||
1060 | |||
1061 | // CDropboxFile |
||
1062 | $criteria = [ |
||
1063 | 'uploaderId' => $userId, |
||
1064 | ]; |
||
1065 | $result = $em->getRepository(CDropboxFile::class)->findBy($criteria); |
||
1066 | $cDropboxFile = []; |
||
1067 | /** @var CDropboxFile $item */ |
||
1068 | foreach ($result as $item) { |
||
1069 | $date = $item->getUploadDate()->format($dateFormat); |
||
1070 | $list = [ |
||
1071 | 'Title: '.$item->getTitle(), |
||
1072 | 'Uploaded date: '.$date, |
||
1073 | 'File: '.$item->getFilename(), |
||
1074 | ]; |
||
1075 | $cDropboxFile[] = implode(', ', $list); |
||
1076 | } |
||
1077 | |||
1078 | // CDropboxPerson |
||
1079 | $criteria = [ |
||
1080 | 'userId' => $userId, |
||
1081 | ]; |
||
1082 | $result = $em->getRepository(CDropboxPerson::class)->findBy($criteria); |
||
1083 | $cDropboxPerson = []; |
||
1084 | /** @var CDropboxPerson $item */ |
||
1085 | foreach ($result as $item) { |
||
1086 | $list = [ |
||
1087 | 'File #'.$item->getFileId(), |
||
1088 | 'Course #'.$item->getCId(), |
||
1089 | ]; |
||
1090 | $cDropboxPerson[] = implode(', ', $list); |
||
1091 | } |
||
1092 | |||
1093 | // CDropboxPerson |
||
1094 | $criteria = [ |
||
1095 | 'authorUserId' => $userId, |
||
1096 | ]; |
||
1097 | $result = $em->getRepository(CDropboxFeedback::class)->findBy($criteria); |
||
1098 | $cDropboxFeedback = []; |
||
1099 | /** @var CDropboxFeedback $item */ |
||
1100 | foreach ($result as $item) { |
||
1101 | $date = $item->getFeedbackDate()->format($dateFormat); |
||
1102 | $list = [ |
||
1103 | 'File #'.$item->getFileId(), |
||
1104 | 'Feedback: '.$item->getFeedback(), |
||
1105 | 'Date: '.$date, |
||
1106 | ]; |
||
1107 | $cDropboxFeedback[] = implode(', ', $list); |
||
1108 | } |
||
1109 | |||
1110 | // CNotebook |
||
1111 | $criteria = [ |
||
1112 | 'user' => $userId, |
||
1113 | ]; |
||
1114 | $result = $em->getRepository(CNotebook::class)->findBy($criteria); |
||
1115 | $cNotebook = []; |
||
1116 | /** @var CNotebook $item */ |
||
1117 | foreach ($result as $item) { |
||
1118 | $date = $item->getUpdateDate()->format($dateFormat); |
||
1119 | $list = [ |
||
1120 | 'Title: '.$item->getTitle(), |
||
1121 | 'Date: '.$date, |
||
1122 | ]; |
||
1123 | $cNotebook[] = implode(', ', $list); |
||
1124 | } |
||
1125 | |||
1126 | // CLpView |
||
1127 | $criteria = [ |
||
1128 | 'user' => $userId, |
||
1129 | ]; |
||
1130 | $result = $em->getRepository(CLpView::class)->findBy($criteria); |
||
1131 | $cLpView = []; |
||
1132 | /** @var CLpView $item */ |
||
1133 | foreach ($result as $item) { |
||
1134 | $list = [ |
||
1135 | //'Id #'.$item->getId(), |
||
1136 | 'LP #'.$item->getLp()->getIid(), |
||
1137 | 'Progress: '.$item->getProgress(), |
||
1138 | //'Course #'.$item->getCId(), |
||
1139 | //'Session #'.$item->getSessionId(), |
||
1140 | ]; |
||
1141 | $cLpView[] = implode(', ', $list); |
||
1142 | } |
||
1143 | |||
1144 | // CStudentPublication |
||
1145 | $criteria = [ |
||
1146 | 'user' => $userId, |
||
1147 | ]; |
||
1148 | $result = $em->getRepository(CStudentPublication::class)->findBy($criteria); |
||
1149 | $cStudentPublication = []; |
||
1150 | /** @var CStudentPublication $item */ |
||
1151 | foreach ($result as $item) { |
||
1152 | $list = [ |
||
1153 | 'Title: '.$item->getTitle(), |
||
1154 | //'URL: '.$item->getTitle(), |
||
1155 | ]; |
||
1156 | $cStudentPublication[] = implode(', ', $list); |
||
1157 | } |
||
1158 | |||
1159 | // CStudentPublicationComment |
||
1160 | $criteria = [ |
||
1161 | 'user' => $userId, |
||
1162 | ]; |
||
1163 | $result = $em->getRepository(CStudentPublicationComment::class)->findBy($criteria); |
||
1164 | $cStudentPublicationComment = []; |
||
1165 | /** @var CStudentPublicationComment $item */ |
||
1166 | foreach ($result as $item) { |
||
1167 | $date = $item->getSentAt()->format($dateFormat); |
||
1168 | $list = [ |
||
1169 | 'Commment: '.$item->getComment(), |
||
1170 | 'File '.$item->getFile(), |
||
1171 | //'Course # '.$item->getCId(), |
||
1172 | 'Date: '.$date, |
||
1173 | ]; |
||
1174 | $cStudentPublicationComment[] = implode(', ', $list); |
||
1175 | } |
||
1176 | |||
1177 | // CWiki |
||
1178 | $criteria = [ |
||
1179 | 'userId' => $userId, |
||
1180 | ]; |
||
1181 | $result = $em->getRepository(CWiki::class)->findBy($criteria); |
||
1182 | $cWiki = []; |
||
1183 | /** @var CWiki $item */ |
||
1184 | foreach ($result as $item) { |
||
1185 | $list = [ |
||
1186 | 'Title: '.$item->getTitle(), |
||
1187 | 'Progress: '.$item->getProgress(), |
||
1188 | 'IP: '.$item->getUserIp(), |
||
1189 | ]; |
||
1190 | $cWiki[] = implode(', ', $list); |
||
1191 | } |
||
1192 | |||
1193 | // Ticket |
||
1194 | $criteria = [ |
||
1195 | 'insertUserId' => $userId, |
||
1196 | ]; |
||
1197 | $result = $em->getRepository(Ticket::class)->findBy($criteria); |
||
1198 | $ticket = []; |
||
1199 | /** @var Ticket $item */ |
||
1200 | foreach ($result as $item) { |
||
1201 | $list = [ |
||
1202 | 'Code: '.$item->getCode(), |
||
1203 | 'Subject: '.$item->getSubject(), |
||
1204 | ]; |
||
1205 | $ticket[] = implode(', ', $list); |
||
1206 | } |
||
1207 | |||
1208 | // Message |
||
1209 | $criteria = [ |
||
1210 | 'insertUserId' => $userId, |
||
1211 | ]; |
||
1212 | $result = $em->getRepository(TicketMessage::class)->findBy($criteria); |
||
1213 | $ticketMessage = []; |
||
1214 | /** @var TicketMessage $item */ |
||
1215 | foreach ($result as $item) { |
||
1216 | $date = $item->getInsertDateTime()->format($dateFormat); |
||
1217 | $list = [ |
||
1218 | 'Subject: '.$item->getSubject(), |
||
1219 | 'IP: '.$item->getIpAddress(), |
||
1220 | 'Status: '.$item->getStatus(), |
||
1221 | 'Creation date: '.$date, |
||
1222 | ]; |
||
1223 | $ticketMessage[] = implode(', ', $list); |
||
1224 | } |
||
1225 | |||
1226 | // SkillRelUserComment |
||
1227 | $criteria = [ |
||
1228 | 'feedbackGiver' => $userId, |
||
1229 | ]; |
||
1230 | $result = $em->getRepository(SkillRelUserComment::class)->findBy($criteria); |
||
1231 | $skillRelUserComment = []; |
||
1232 | /** @var SkillRelUserComment $item */ |
||
1233 | foreach ($result as $item) { |
||
1234 | $date = $item->getFeedbackDateTime()->format($dateFormat); |
||
1235 | $list = [ |
||
1236 | 'Feedback: '.$item->getFeedbackText(), |
||
1237 | 'Value: '.$item->getFeedbackValue(), |
||
1238 | 'Created at: '.$date, |
||
1239 | ]; |
||
1240 | $skillRelUserComment[] = implode(', ', $list); |
||
1241 | } |
||
1242 | |||
1243 | // UserRelCourseVote |
||
1244 | $criteria = [ |
||
1245 | 'user' => $userId, |
||
1246 | ]; |
||
1247 | $result = $em->getRepository(UserRelCourseVote::class)->findBy($criteria); |
||
1248 | $userRelCourseVote = []; |
||
1249 | /** @var UserRelCourseVote $item */ |
||
1250 | foreach ($result as $item) { |
||
1251 | $list = [ |
||
1252 | 'Course #'.$item->getCourse()->getId(), |
||
1253 | //'Session #'.$item->getSession()->getId(), |
||
1254 | 'Vote: '.$item->getVote(), |
||
1255 | ]; |
||
1256 | $userRelCourseVote[] = implode(', ', $list); |
||
1257 | } |
||
1258 | |||
1259 | /*$user->setDropBoxSentFiles( |
||
1260 | [ |
||
1261 | 'Friends' => $friendList, |
||
1262 | 'Events' => $eventList, |
||
1263 | 'GradebookCertificate' => $gradebookCertificate, |
||
1264 | |||
1265 | 'TrackECourseAccess' => $trackECourseAccessList, |
||
1266 | 'TrackELogin' => $trackELoginList, |
||
1267 | 'TrackEAccess' => $trackEAccessList, |
||
1268 | 'TrackEDefault' => $trackEDefault, |
||
1269 | 'TrackEOnline' => $trackEOnlineList, |
||
1270 | 'TrackEUploads' => $trackEUploads, |
||
1271 | 'TrackELastaccess' => $trackELastaccess, |
||
1272 | 'GradebookResult' => $gradebookResult, |
||
1273 | 'Downloads' => $trackEDownloads, |
||
1274 | 'UserCourseCategory' => $userCourseCategory, |
||
1275 | 'SkillRelUserComment' => $skillRelUserComment, |
||
1276 | 'UserRelCourseVote' => $userRelCourseVote, |
||
1277 | |||
1278 | // courses |
||
1279 | 'AttendanceResult' => $cAttendanceResult, |
||
1280 | 'Blog' => $cBlog, |
||
1281 | 'DocumentsAdded' => $documents, |
||
1282 | 'Chat' => $chatFiles, |
||
1283 | 'ForumPost' => $cForumPostList, |
||
1284 | 'ForumThread' => $cForumThreadList, |
||
1285 | 'TrackEExercises' => $trackEExercises, |
||
1286 | 'TrackEAttempt' => $trackEAttempt, |
||
1287 | |||
1288 | 'GroupRelUser' => $cGroupRelUser, |
||
1289 | 'Message' => $messageList, |
||
1290 | 'Survey' => $cSurveyAnswer, |
||
1291 | 'StudentPublication' => $cStudentPublication, |
||
1292 | 'StudentPublicationComment' => $cStudentPublicationComment, |
||
1293 | 'DropboxFile' => $cDropboxFile, |
||
1294 | 'DropboxPerson' => $cDropboxPerson, |
||
1295 | 'DropboxFeedback' => $cDropboxFeedback, |
||
1296 | |||
1297 | 'LpView' => $cLpView, |
||
1298 | 'Notebook' => $cNotebook, |
||
1299 | |||
1300 | 'Wiki' => $cWiki, |
||
1301 | // Tickets |
||
1302 | |||
1303 | 'Ticket' => $ticket, |
||
1304 | 'TicketMessage' => $ticketMessage, |
||
1305 | ] |
||
1306 | );*/ |
||
1307 | |||
1308 | //$user->setDropBoxReceivedFiles([]); |
||
1309 | //$user->setGroups([]); |
||
1310 | //$user->setCurriculumItems([]); |
||
1311 | |||
1312 | /*$portals = $user->getPortals(); |
||
1313 | if (!empty($portals)) { |
||
1314 | $list = []; |
||
1315 | /** @var AccessUrlRelUser $portal */ |
||
1316 | /*foreach ($portals as $portal) { |
||
1317 | $portalInfo = UrlManager::get_url_data_from_id($portal->getUrl()->getId()); |
||
1318 | $list[] = $portalInfo['url']; |
||
1319 | } |
||
1320 | } |
||
1321 | $user->setPortals($list);*/ |
||
1322 | |||
1323 | /*$skillRelUserList = $user->getAchievedSkills(); |
||
1324 | $list = []; |
||
1325 | foreach ($skillRelUserList as $skillRelUser) { |
||
1326 | $list[] = $skillRelUser->getSkill()->getName(); |
||
1327 | } |
||
1328 | $user->setAchievedSkills($list); |
||
1329 | $user->setCommentedUserSkills([]);*/ |
||
1330 | |||
1331 | //$extraFieldValues = new \ExtraFieldValue('user'); |
||
1332 | |||
1333 | $lastLogin = $user->getLastLogin(); |
||
1334 | if (empty($lastLogin)) { |
||
1335 | $login = $this->getLastLogin($user); |
||
1336 | if (null !== $login) { |
||
1337 | $lastLogin = $login->getLoginDate(); |
||
1338 | } |
||
1339 | } |
||
1340 | $user->setLastLogin($lastLogin); |
||
1341 | |||
1342 | /*$dateNormalizer = new GetSetMethodNormalizer(); |
||
1343 | $dateNormalizer->setCircularReferenceHandler(function ($object) { |
||
1344 | return get_class($object); |
||
1345 | });*/ |
||
1346 | |||
1347 | $ignore = [ |
||
1348 | 'twoStepVerificationCode', |
||
1349 | 'biography', |
||
1350 | 'dateOfBirth', |
||
1351 | 'gender', |
||
1352 | 'facebookData', |
||
1353 | 'facebookName', |
||
1354 | 'facebookUid', |
||
1355 | 'gplusData', |
||
1356 | 'gplusName', |
||
1357 | 'gplusUid', |
||
1358 | 'locale', |
||
1359 | 'timezone', |
||
1360 | 'twitterData', |
||
1361 | 'twitterName', |
||
1362 | 'twitterUid', |
||
1363 | 'gplusUid', |
||
1364 | 'token', |
||
1365 | 'website', |
||
1366 | 'plainPassword', |
||
1367 | 'completeNameWithUsername', |
||
1368 | 'completeName', |
||
1369 | 'completeNameWithClasses', |
||
1370 | 'salt', |
||
1371 | 'dropBoxSentFiles', |
||
1372 | 'dropBoxReceivedFiles', |
||
1373 | 'currentUrl', |
||
1374 | 'uuid', |
||
1375 | 'curriculumItems', |
||
1376 | 'currentSession', |
||
1377 | 'currentCourse', |
||
1378 | 'resourceNode', |
||
1379 | ]; |
||
1380 | |||
1381 | $callback = function ($dateTime) { |
||
1382 | return $dateTime instanceof DateTime ? $dateTime->format(DateTime::ATOM) : ''; |
||
1383 | }; |
||
1384 | |||
1385 | $defaultContext = [ |
||
1386 | AbstractNormalizer::CALLBACKS => [ |
||
1387 | 'createdAt' => $callback, |
||
1388 | 'lastLogin' => $callback, |
||
1389 | 'registrationDate' => $callback, |
||
1390 | 'memberSince' => $callback, |
||
1391 | ], |
||
1392 | AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => function ($object, $format, $context) { |
||
1393 | return \get_class($object); |
||
1394 | }, |
||
1395 | ]; |
||
1396 | |||
1397 | $normalizer = new GetSetMethodNormalizer(null, null, null, null, null, $defaultContext); |
||
1398 | $serializer = new Serializer( |
||
1399 | [$normalizer], |
||
1400 | [new JsonEncoder()] |
||
1401 | ); |
||
1402 | |||
1403 | return $serializer->serialize($user, 'json', [ |
||
1404 | AbstractNormalizer::IGNORED_ATTRIBUTES => $ignore, |
||
1405 | ]); |
||
1538 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.