Beispiel #1
0
 /**
  *
  */
 public function display($cachable = false, $urlparams = false)
 {
     if ($_POST) {
         $params = JRequest::getVar('params');
         $user = JXFactory::getUser();
         $mainframe = JFactory::getApplication();
         $emailChange = false;
         if ($user->email != $params['email']) {
             $emailChange = true;
             $oldEmail = $user->email;
         }
         // Only process this if there is an email change
         if ($emailChange) {
             $dummy = new JXUser();
             $loadUser = $dummy->loadUserByEmail($params['email']);
             // Email is being used by another user;
             if ($loadUser === true && $dummy->id != $user->id) {
                 $mainframe->redirect(JRoute::_('index.php?option=com_profile&view=edit'), JText::_('COM_PROFILE_ACTION_EMAIL_USED'), 'error');
                 return false;
             } else {
                 // update invitation in case there are invitations from the previous email
                 JModel::addIncludePath(JPATH_ROOT . DS . 'components' . DS . 'com_account' . DS . 'models');
                 $usersInvite = JModel::getInstance('usersInvite', 'AccountModel');
                 $usersInvite->updateFromEmail($oldEmail, $params['email'], $user);
             }
         }
         $params['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW);
         $params['password2'] = JRequest::getVar('confirm_password', '', 'post', 'string', JREQUEST_ALLOWRAW);
         // do a password safety check
         if (JString::strlen($params['password']) || JString::strlen($params['password2'])) {
             // so that "0" can be used as password e.g.
             if ($params['password'] != $params['password2']) {
                 $mainframe->redirect(JRoute::_('index.php?option=com_profile&view=edit'), JText::_('COM_REGISTER_ERRMSG_PASSWORD_MISMATCH'), 'error');
                 return false;
             }
         }
         $user->set('name', $params['name']);
         $user->set('email', $params['email']);
         $user->setParam('language', $params['language']);
         $user->setParam('about_me', $params['about_me']);
         $user->setParam('timezone', $params['timezone']);
         $user->setParam('style', $params['style']);
         $user->bind($params);
         if ($user->save()) {
             $percentageFilled = $user->getCalculateCompletion();
             $user->setGettingStartedCompletion(JXUser::GSTARTED_COMPLETE_PROFILE, $percentageFilled);
             // Reload the user session
             $user->reloadSession();
             /* Redirect to clear the previous user values */
             $mainframe->redirect(JRoute::_('index.php?option=com_profile&view=edit'), JText::_('COM_PROFILE_ACTION_SAVE_PROFILE_SUCCESS'));
         } else {
             $mainframe->redirect(JRoute::_('index.php?option=com_profile&view=edit'), JText::_('COM_PROFILE_ACTION_SAVE_PROFILE_FAILED'), 'error');
         }
     }
     parent::display(null);
 }
Beispiel #2
0
 public function ajaxResendInvitation()
 {
     // Only admin can use this function to invite guests
     $jxConfig = new JXConfig();
     $my = JXFactory::getUser();
     $accessHelper = new AccountAccessHelper();
     if (!$my->authorise('stream.setting.edit', $accessHelper)) {
         echo '{"error":"1","info":""';
         exit;
     }
     $invitation = JRequest::getVar('invitation_id', 0);
     $returnData = array();
     //if ($email !== false)
     if ($invitation) {
         $usersInvite = JTable::getInstance('usersInvite', 'AccountTable');
         $usersInvite->load(array('id' => $invitation));
         if ($usersInvite->id) {
             $emailToInvite = $usersInvite->invite_email;
             $dummy = new JXUser();
             $loadUser = $dummy->loadUserByEmail($usersInvite->from_email);
             if (!$loadUser) {
                 // Delete invitations which invitor email cannot be found from registered users
                 $dummy = JXFactory::getUser();
                 $usersInvite->delete();
             }
             $result = $this->processInvitation($dummy, $emailToInvite);
             $now = new JDate();
             if ($result['flag'] == self::SENT_FLAG) {
                 $usersInvite->load(array('from_email' => $dummy->email, 'invite_email' => $emailToInvite));
                 $returnData["info"] = JXDate::formatDate($now->format('Y-m-d h:i:s'));
                 $returnData["html"] = $usersInvite->getRowHtml();
             } elseif ($result['flag'] == self::ALREADY_REGISTERED_FLAG) {
                 $returnData["msg"] = JText::sprintf('COM_ACCOUNT_MSG_INVITATION_EMAIL_ALREADY_REGISTERED', $result['email']);
             }
             $returnData["error"] = '0';
         } else {
             $returnData["error"] = '1';
         }
     } else {
         $returnData["error"] = '1';
     }
     echo json_encode($returnData);
     exit;
 }