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();
 }
 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();
 }