コード例 #1
0
 public function testSendJoinRequest_PropertiesFromToBodyOk()
 {
     $e = new LexiconMongoTestEnvironment();
     $e->clean();
     $adminId = $e->createUser('admin', 'Admin', '*****@*****.**');
     $admin = new UserModel($adminId);
     $userId = $e->createUser('User', 'Name', '*****@*****.**');
     $user = new UserModel($userId);
     $project = $e->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE);
     $delivery = new MockCommunicateDelivery();
     $project->addUser($adminId, $e->website->userDefaultSiteRole);
     $project->write();
     $admin->addProject($project->id->asString());
     $admin->write();
     Communicate::sendJoinRequest($user, $admin, $project, $e->website, $delivery);
     // What's in the delivery?
     $senderEmail = 'no-reply@' . $e->website->domain;
     $expectedFrom = array($senderEmail => $e->website->name);
     $expectedTo = array($admin->email => $admin->name);
     $this->assertEqual($expectedFrom, $delivery->from);
     $this->assertEqual($expectedTo, $delivery->to);
     $this->assertPattern('/' . $user->name . '/', $delivery->subject);
     $this->assertPattern('/' . $e->website->domain . '\\/app\\/usermanagement/', $delivery->content);
 }
コード例 #2
0
 /**
  * Sends an email to request joining of the project
  * @param string $projectId
  * @param string $inviterUserId
  * @param Website $website
  * @param string $toEmail
  * @param DeliveryInterface $delivery
  * @throws \Exception
  * @return string $userId
  */
 public static function sendJoinRequest($projectId, $userId, $website, DeliveryInterface $delivery = null)
 {
     $newUser = new UserModel($userId);
     $project = new ProjectModel();
     $project->read($projectId['id']);
     // Make sure the user exists on the site
     if (!$newUser->hasRoleOnSite($website)) {
         $newUser->siteRole[$website->domain] = $website->userDefaultSiteRole;
     }
     // Determine if user is already a member of the project
     if ($project->userIsMember($newUser->id->asString())) {
         return $newUser->id;
     }
     // Add the user to the project
     $project->createUserJoinRequest($userId, ProjectRoles::CONTRIBUTOR);
     $project->write();
     $admin = new UserModel($project->ownerRef->asString());
     if ($admin->email != '') {
         Communicate::sendJoinRequest($newUser, $admin, $project, $website, $delivery);
         Communicate::sendJoinRequestConfirmation($newUser, $project, $website, $delivery);
     }
     return $admin;
 }