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