public static function sendMessage($projectId, $userIds, $subject, $smsTemplate, $emailTemplate, $htmlEmailTemplate = '')
 {
     $project = new ProjectSettingsModel($projectId);
     $users = array();
     foreach ($userIds as $id) {
         $users[] = new UserModel($id);
     }
     return Communicate::communicateToUsers($users, $project, $subject, $smsTemplate, $emailTemplate, $htmlEmailTemplate);
 }
 public function forgotPassword(Request $request, Application $app)
 {
     $usernameOrEmail = $request->request->get('_username');
     $user = new UserModel();
     if (!$user->readByUsernameOrEmail($usernameOrEmail)) {
         $app['session']->getFlashBag()->add('errorMessage', 'User not found.');
         return $this->view($request, $app, 'forgot_password');
     }
     $identityCheck = UserCommands::checkIdentity($user->username, $user->email, $this->website);
     if (!$identityCheck->usernameExistsOnThisSite) {
         $user->siteRole[$this->website->domain] = $this->website->userDefaultSiteRole;
     }
     Communicate::sendForgotPasswordVerification($user, $this->website);
     $app['session']->getFlashBag()->add('infoMessage', 'Password Reset email sent for username "' . $usernameOrEmail . '"');
     return $app->redirect('/auth/login');
 }
Example #3
0
 public function forgotPassword(Request $request, Application $app)
 {
     $username = $request->request->get('_username');
     $identityCheck = UserCommands::checkIdentity($username, '', $this->website);
     if (!$identityCheck->usernameExists) {
         $app['session']->getFlashBag()->add('errorMessage', 'User not found.');
         return $this->view($request, $app, 'forgot_password');
     }
     $user = new UserModel();
     $user->readByUserName($username);
     if (!$identityCheck->usernameExistsOnThisSite and $user->role != SystemRoles::SYSTEM_ADMIN) {
         $app['session']->getFlashBag()->add('errorMessage', sprintf('Username "%s" not available on "%s". Use "Create an Account".', $username, $this->website->domain));
         return $this->view($request, $app, 'forgot_password');
     }
     Communicate::sendForgotPasswordVerification($user, $this->website);
     $app['session']->getFlashBag()->add('infoMessage', 'Password Reset email sent for username "' . $username . '"');
     return $app->redirect('/auth/login');
 }
 public function testSendJoinRequestAccepted_PropertiesFromToBodyOk()
 {
     $e = new LexiconMongoTestEnvironment();
     $e->clean();
     $userId = $e->createUser('User', 'Name', '*****@*****.**');
     $user = new UserModel($userId);
     $project = $e->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE);
     $delivery = new MockCommunicateDelivery();
     Communicate::sendJoinRequestAccepted($user, $project, $e->website, $delivery);
     // What's in the delivery?
     $senderEmail = 'no-reply@' . $e->website->domain;
     $expectedFrom = array($senderEmail => $e->website->name);
     $expectedTo = array($user->email => $user->name);
     $this->assertEqual($expectedFrom, $delivery->from);
     $this->assertEqual($expectedTo, $delivery->to);
     $this->assertPattern('/' . SF_TESTPROJECT . '/', $delivery->subject);
     $this->assertPattern('/' . $e->website->name . '/', $delivery->subject);
     $this->assertPattern('/' . SF_TESTPROJECT . '/', $delivery->content);
     $this->assertPattern('/has been accepted/', $delivery->content);
     $this->assertPattern('/' . $e->website->domain . '\\/app\\/semdomtrans/', $delivery->content);
 }
 /**
  * 
  * @param string $projectId
  * @param string $userId
  * @param string $website
  * @param role $role
  * @param DeliveryInterface $delivery
  * @return \Api\Model\Mapper\IdReference|\Api\Model\UserModel
  */
 public static function acceptJoinRequest($projectId, $userId, $website, $role, DeliveryInterface $delivery = null)
 {
     $newUser = new UserModel($userId);
     $project = new ProjectModel();
     $project->read($projectId);
     ProjectCommands::updateUserRole($projectId, $userId, $role);
     // 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;
     }
     $admin = new UserModel($project->ownerRef->asString());
     if ($admin->email != '') {
         Communicate::sendJoinRequestAccepted($newUser, $project, $website, $delivery);
     }
     return $admin;
 }