Bläddra i källkod

Implemented friend requests in the backend

Michael Francis 14 år sedan
förälder
incheckning
b099b7e6f2
1 ändrade filer med 12 tillägg och 4 borttagningar
  1. 12 4
      controllers/UsersController.php

+ 12 - 4
controllers/UsersController.php

@@ -411,7 +411,11 @@ class UsersController extends \lithium\action\Controller {
 		return compact('user');
 	}
 
-	public function requestFriend($username) {
+	public function requestFriend($username = null) {
+		if ($username == null)
+		{
+			$username = $this->request->query['username'];
+		}
 		//If the user isn't blocking this user, 
 
 		//And the user doesn't have private set 
@@ -419,10 +423,14 @@ class UsersController extends \lithium\action\Controller {
 		//Send them a DM with a confirm key
 		$key = confirmKey::create();
 		$thisUser = auth::check('default');
-		$link = Html::link('here', "/users/confirmFriend/$this->username/$key->key");
-		$post = Post::create(array('body' => "$thisUser->username want's to be your friend. Click $link to confirm"));
+		$url = \lithium\net\http\Router::match(array('controller' => 'users',
+										 'action' => 'confirmFriend',
+										 'args'=>array($thisUser['username'], $key->key)), null, array('absolute' => 'false')); 
+		$post = Post::create(array('body' => $thisUser['username'] . " want's to be your friend. Click $url to confirm"));
+
+		$post->directMessage($thisUser);
 
-		$post->directMessage($username);
+		return $this->redirect('users::feed');
 
 	}