public function executeRequestConnection() { $user1 = $this->getUser()->getProfile(); $user2 = SfGuardUserProfilePeer::retrieveByUuid($this->getRequestParameter('connect')); $this->forward404Unless($user2, 'User2 not found, unable to request connections'); if ($user1->isConnected($user2->getUserId())) { $this->message = "This user is already in your network, or a request is still pending"; $this->forward404($this->message); } $result = $user1->addConnection($user2->getUserId()); if ($result == false) { $this->forward404('Error adding SoCon'); } $message = array(); $message["from"] = $user1->getUserId(); $message["to"] = $user2->getUserId(); $message["owner"] = $user2->getUserId(); $message["parent"] = null; $message["folder"] = "inbox"; $message["subject"] = $user1->getFullName() . ' has requested to add you to their network.'; $message["text"] = 'You can view, accept or decline the request by going to My Network'; $options = array(); $options["copyTo"] = "sent"; MessagePeer::sendSimpleMessage($message, $options); $user1->addHistoryEvent($user1->getFullName() . ' requested ' . $user2->getFullName() . ' to join their network.', $user1->getFullName() . ' has asked ' . $user2->getFullName() . ' to join their network.'); $user2->addHistoryEvent($user1->getFullName() . ' requested ' . $user2->getFullName() . ' to join their network.', $user1->getFullName() . ' has asked ' . $user2->getFullName() . ' to join their network.'); $this->redirect('networks/index?tab=pending'); }