| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -106,6 +106,12 @@ class StudentFollowUpPlugin extends Plugin | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } else { | 
					 | 
					 | 
					 | 
					        } else { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            $isDrh = api_is_drh(); | 
					 | 
					 | 
					 | 
					            $isDrh = api_is_drh(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            $isCareTaker = false; | 
					 | 
					 | 
					 | 
					            $isCareTaker = false; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            $isDrhRelatedViaPost = false; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            $isCourseCoach = false; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            $isDrhRelatedToSession = false; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            // Only admins and DRH that follow the user | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            $isAdmin = api_is_platform_admin(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            // Check if user is care taker | 
					 | 
					 | 
					 | 
					            // Check if user is care taker | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if ($isDrh) { | 
					 | 
					 | 
					 | 
					            if ($isDrh) { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -113,42 +119,45 @@ class StudentFollowUpPlugin extends Plugin | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    'user' => $studentId, | 
					 | 
					 | 
					 | 
					                    'user' => $studentId, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    'insertUser' => $currentUserId | 
					 | 
					 | 
					 | 
					                    'insertUser' => $currentUserId | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                ]; | 
					 | 
					 | 
					 | 
					                ]; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					                $repo = Database::getManager()->getRepository('ChamiloPluginBundle:StudentFollowUp\CarePost'); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                $post = Database::getManager()->getRepository('ChamiloPluginBundle:StudentFollowUp\CarePost')->findOneBy($criteria); | 
					 | 
					 | 
					 | 
					                $post = $repo->findOneBy($criteria); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if ($post) { | 
					 | 
					 | 
					 | 
					                if ($post) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    $isCareTaker = true; | 
					 | 
					 | 
					 | 
					                    $isDrhRelatedViaPost = true; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                } | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            // Only admins and DRH that follow the user | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            $isAdmin = api_is_platform_admin(); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            // Check if course session coach | 
					 | 
					 | 
					 | 
					                // Check if course session coach | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            $sessions = SessionManager::get_sessions_by_user($studentId); | 
					 | 
					 | 
					 | 
					                $sessions = SessionManager::get_sessions_by_user($studentId); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            $isCourseCoach = false; | 
					 | 
					 | 
					 | 
					                if (!empty($sessions)) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            $isDrhSession = false; | 
					 | 
					 | 
					 | 
					                    foreach ($sessions as $session) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (!empty($sessions)) { | 
					 | 
					 | 
					 | 
					                        $sessionId = $session['session_id']; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                foreach ($sessions as $session) { | 
					 | 
					 | 
					 | 
					                        $sessionDrhInfo = SessionManager::getSessionFollowedByDrh( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    $sessionId = $session['session_id']; | 
					 | 
					 | 
					 | 
					                            $currentUserId, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    $sessionDrhInfo = SessionManager::getSessionFollowedByDrh($currentUserId, $sessionId); | 
					 | 
					 | 
					 | 
					                            $sessionId | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    if (!empty($sessionDrhInfo)) { | 
					 | 
					 | 
					 | 
					                        ); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        $isDrhSession = true; | 
					 | 
					 | 
					 | 
					                        if (!empty($sessionDrhInfo)) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        break; | 
					 | 
					 | 
					 | 
					                            $isDrhRelatedToSession = true; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    } | 
					 | 
					 | 
					 | 
					                            break; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    foreach ($session['courses'] as $course) { | 
					 | 
					 | 
					 | 
					                        } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        //$isCourseCoach = api_is_coach($sessionId, $course['real_id']); | 
					 | 
					 | 
					 | 
					                        foreach ($session['courses'] as $course) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        $coachList = SessionManager::getCoachesByCourseSession($sessionId, $course['real_id']); | 
					 | 
					 | 
					 | 
					                            //$isCourseCoach = api_is_coach($sessionId, $course['real_id']); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        if (!empty($coachList) && in_array($currentUserId, $coachList)) { | 
					 | 
					 | 
					 | 
					                            $coachList = SessionManager::getCoachesByCourseSession( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                            $isCourseCoach = true; | 
					 | 
					 | 
					 | 
					                                $sessionId, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                            break(2); | 
					 | 
					 | 
					 | 
					                                $course['real_id'] | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                            ); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                            if (!empty($coachList) && in_array($currentUserId, $coachList)) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                                $isCourseCoach = true; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                                break(2); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        } | 
					 | 
					 | 
					 | 
					                        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    } | 
					 | 
					 | 
					 | 
					                    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                } | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                $isCareTaker = $isDrhRelatedViaPost && $isDrhRelatedToSession; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            $isAllow = $isAdmin || $isDrhSession || $isCourseCoach; | 
					 | 
					 | 
					 | 
					            $isAllow = $isAdmin || $isCareTaker || $isDrhRelatedToSession || $isCourseCoach; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            $showPrivate = $isAdmin || ($isDrhSession && $isCareTaker); | 
					 | 
					 | 
					 | 
					            $showPrivate = $isAdmin || $isCareTaker; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return [ | 
					 | 
					 | 
					 | 
					        return [ | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |