public function actionEmailConfiguration($id, $redirectUrl = null)
 {
     UserAccessUtil::resolveCanCurrentUserAccessAction(intval($id));
     $user = User::getById(intval($id));
     UserAccessUtil::resolveCanCurrentUserAccessRootUser($user);
     UserAccessUtil::resolveAccessingASystemUser($user);
     $title = Zurmo::t('EmailMessagesModule', 'Email Configuration');
     $breadCrumbLinks = array(strval($user) => array('default/details', 'id' => $id), $title);
     $emailAccount = EmailAccount::resolveAndGetByUserAndName($user);
     $userEmailConfigurationForm = new UserEmailConfigurationForm($emailAccount);
     $userEmailConfigurationForm->emailSignatureHtmlContent = $user->getEmailSignature()->htmlContent;
     $postVariableName = get_class($userEmailConfigurationForm);
     if (isset($_POST[$postVariableName])) {
         $userEmailConfigurationForm->setAttributes($_POST[$postVariableName]);
         if ($userEmailConfigurationForm->validate()) {
             $userEmailConfigurationForm->save();
             Yii::app()->user->setFlash('notification', Zurmo::t('UsersModule', 'User email configuration saved successfully.'));
             if ($redirectUrl != null) {
                 $this->redirect($redirectUrl);
             } else {
                 $this->redirect(array($this->getId() . '/details', 'id' => $user->id));
             }
         } else {
             $userEmailConfigurationForm->outboundPassword = ZurmoPasswordSecurityUtil::decrypt($userEmailConfigurationForm->outboundPassword);
         }
     }
     $titleBarAndEditView = new UserActionBarAndEmailConfigurationEditView($this->getId(), $this->getModule()->getId(), $user, $userEmailConfigurationForm);
     $titleBarAndEditView->setCssClasses(array('AdministrativeArea'));
     $view = new UsersPageView($this->resolveZurmoDefaultOrAdminView($titleBarAndEditView, $breadCrumbLinks, 'UserBreadCrumbView'));
     echo $view->render();
 }
Beispiel #2
0
 public function testActiveUsers()
 {
     $activeUserCount = User::getActiveUserCount();
     $this->assertEquals(28, $activeUserCount);
     $this->assertCount(28, User::getActiveUsers());
     $activeUserCount = User::getActiveUserCount(false);
     $this->assertEquals(28, $activeUserCount);
     $this->assertCount(28, User::getActiveUsers(false));
     $activeUserCount = User::getActiveUserCount(true);
     $this->assertEquals(28, $activeUserCount);
     $this->assertCount(28, User::getActiveUsers(true));
     $user = User::getByUsername('rootuser');
     $this->assertTrue(UserAccessUtil::resolveCanCurrentUserAccessRootUser($user));
     $user->setIsRootUser();
     $this->assertTrue($user->save());
     unset($user);
     $activeUserCount = User::getActiveUserCount();
     $this->assertEquals(27, $activeUserCount);
     $this->assertCount(27, User::getActiveUsers());
     $activeUserCount = User::getActiveUserCount(false);
     $this->assertEquals(27, $activeUserCount);
     $this->assertCount(27, User::getActiveUsers(false));
     $activeUserCount = User::getActiveUserCount(true);
     $this->assertEquals(28, $activeUserCount);
     $this->assertCount(28, User::getActiveUsers(true));
 }
Beispiel #3
0
 /**
  * test for checking hideFromSelecting attribute
  */
 public function testIsRootUserOnUserSave()
 {
     $user = new User();
     $user->username = '******';
     $user->title->value = 'Mr.';
     $user->firstName = 'My';
     $user->lastName = 'rootuser';
     $user->setPassword('myuser');
     $this->assertTrue($user->save());
     unset($user);
     $user = User::getByUsername('rootuser');
     $this->assertNull($user->isRootUser);
     unset($user);
     $superUser = User::getByUsername('leaderboard');
     Yii::app()->user->userModel = $superUser;
     $user = User::getByUsername('rootuser');
     $this->assertTrue(UserAccessUtil::resolveCanCurrentUserAccessRootUser($user));
     $user->setIsRootUser();
     $this->assertTrue($user->save());
     unset($user);
     $user = User::getByUsername('rootuser');
     $this->assertFalse(UserAccessUtil::resolveCanCurrentUserAccessRootUser($user, false));
     $user = new User();
     $user->username = '******';
     $user->title->value = 'Mr.';
     $user->firstName = 'My';
     $user->lastName = 'rootuser2';
     $user->setPassword('myuser');
     $this->assertTrue($user->save());
     unset($user);
     //Get root user count
     $this->assertEquals(1, User::getRootUserCount());
     //Take care that only root user could be there
     $user = User::getByUsername('rootuser2');
     try {
         $user->setIsRootUser();
     } catch (Exception $e) {
         $this->assertEquals('ExistingRootUserException', get_class($e));
     }
 }
 public function actionNotificationConfiguration($id, $redirectUrl = null)
 {
     UserAccessUtil::resolveCanCurrentUserAccessAction(intval($id));
     $user = User::getById(intval($id));
     UserAccessUtil::resolveCanCurrentUserAccessRootUser($user);
     UserAccessUtil::resolveAccessingASystemUser($user);
     $title = Zurmo::t('Core', 'Notifications Configuration');
     $breadCrumbLinks = array(strval($user) => array('default/details', 'id' => $id), $title);
     $userNotificationConfigurationForm = UserNotificationConfigurationFormAdapter::makeFormFromUserConfigurationByUser($user);
     $postVariableName = get_class($userNotificationConfigurationForm);
     if (isset($_POST[$postVariableName])) {
         $userNotificationConfigurationForm->setAttributes($_POST[$postVariableName], false);
         if ($userNotificationConfigurationForm->validate()) {
             if ($user->id != Yii::app()->user->userModel->id) {
                 UserNotificationConfigurationFormAdapter::setConfigurationFromForm($userNotificationConfigurationForm, $user);
             } else {
                 UserNotificationConfigurationFormAdapter::setConfigurationFromFormForCurrentUser($userNotificationConfigurationForm);
             }
             Yii::app()->user->setFlash('notification', Zurmo::t('UsersModule', 'User notifications configuration saved successfully.'));
             if ($redirectUrl != null) {
                 $this->redirect($redirectUrl);
             } else {
                 $this->redirect(array($this->getId() . '/details', 'id' => $user->id));
             }
         }
     }
     $titleBarAndEditView = new UserActionBarAndNotificationConfigurationEditView($this->getId(), $this->getModule()->getId(), $user, $userNotificationConfigurationForm);
     $titleBarAndEditView->setCssClasses(array('AdministrativeArea'));
     $view = new UsersPageView($this->resolveZurmoDefaultOrAdminView($titleBarAndEditView, $breadCrumbLinks, 'UserBreadCrumbView'));
     echo $view->render();
 }