| 
					
				 | 
			
			
				@@ -15,20 +15,22 @@ class Mattermost 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     protected $url; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     protected $token; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     protected $channelId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected $channelIdAdmin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     protected $router; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * Mattermost Manager 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public function __construct($url, $token, $channelId, UrlGeneratorInterface $router) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function __construct($url, $token, $channelId, $channelIdAdmin, UrlGeneratorInterface $router) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $this->url = $url . "/api/v4/posts"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $this->token = $token; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $this->channelId = $channelId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $this->channelIdAdmin = $channelIdAdmin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $this->router = $router; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    protected function SendNotif($message) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected function SendNotif($message, $isChanAdmin = False) :void 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // crée une nouvelle ressource cURL 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $ch = curl_init(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -37,7 +39,7 @@ class Mattermost 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $options = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             CURLOPT_URL => $this->url, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             CURLOPT_HTTPHEADER => array('Content-Type: application/json', 'Authorization: Bearer ' . $this->token), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            CURLOPT_POSTFIELDS  =>  '{"channel_id": "' . $this->channelId . '", "message": "' . $message . '"}' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            CURLOPT_POSTFIELDS  =>  '{"channel_id": "' . ($isChanAdmin ? $this->channelIdAdmin : $this->channelId) . '", "message": "' . $message . '"}' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         curl_setopt_array($ch, $options); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -49,7 +51,7 @@ class Mattermost 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         curl_close($ch); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public function sendNouveauFilm(Film $film) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function sendNouveauFilm(Film $film) :void 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $message = 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ":new: **" 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -57,11 +59,13 @@ class Mattermost 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ."** vient d'ajouter **" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ."[".$film->getTitre()."](" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             .$this->router->generate('videotheque_voirfilm', ['id' => $film->getId()], UrlGeneratorInterface::ABSOLUTE_URL) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            .")** dans la [vidéothèque](https://videotheque.fdlibre.eu)."; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .")** dans la [vidéothèque](" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .$this->router->generate('videotheque_liste', [], UrlGeneratorInterface::ABSOLUTE_URL) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .")."; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $this->SendNotif($message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public function sendNouveauCommentaire(User $user, Film $film) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function sendNouveauCommentaire(User $user, Film $film) :void 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $message = 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ":new: **" 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -69,10 +73,26 @@ class Mattermost 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ."** vient d'ajouter un commentaire sur le film **" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ."[".$film->getTitre()."](" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             .$this->router->generate('videotheque_voirfilm', ['id' => $film->getId()], UrlGeneratorInterface::ABSOLUTE_URL) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            .")** dans la [vidéothèque](https://videotheque.fdlibre.eu)."; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .")** dans la [vidéothèque](" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .$this->router->generate('videotheque_liste', [], UrlGeneratorInterface::ABSOLUTE_URL) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .")."; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $this->SendNotif($message); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function sendNewUser($userName) : void 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $message = 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ":warning: Un utilisateur vient de s'enregistrer dans la [vidéothèque](" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        .$this->router->generate('videotheque_liste', [], UrlGeneratorInterface::ABSOLUTE_URL) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        .")** : " 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        .$userName 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ."**. Accéder à la [liste des utilisateurs](" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        .$this->router->generate('admin_index', [],  UrlGeneratorInterface::ABSOLUTE_URL) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        .")."; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $this->sendNotif($message, True); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |