예제 #1
0
 protected function changeStatus($sStatus, $sAlertActionName, $iAction, $iProfileId = 0)
 {
     if (!$iProfileId) {
         $iProfileId = $this->_iProfileID;
     }
     // get account and profile objects
     $oProfile = BxDolProfile::getInstance($iProfileId);
     $oAccount = $oProfile->getAccountObject();
     if (!$oProfile || !$oAccount) {
         return false;
     }
     // change status
     if (!$this->_oQuery->changeStatus($iProfileId, $sStatus)) {
         return false;
     }
     // alert about status changing
     bx_alert('profile', $sAlertActionName, $iProfileId, false, array('action' => $iAction));
     // send email to member about status change
     sendMailTemplate('t_ChangeStatus' . ucfirst($sStatus), $oAccount->id(), $iProfileId, array('status' => $sStatus), BX_EMAIL_SYSTEM);
     return true;
 }
예제 #2
0
 /**
  * Create new profile;
  *
  * @param  : $aProfileInfo (array) - remote profile's information;
  *
  * @param  : $sAlternativeName (string) - profiles alternative nickname;
  * @return : error string or error or request invite form or profile info array on success
  */
 function _createProfileRaw($aProfileInfo, $sAlternativeName = '', $isAutoFriends = true, $isSetLoggedIn = true)
 {
     // join by invite only
     if (BxDolRequest::serviceExists('bx_invites', 'account_add_form_check') && ($sCode = BxDolService::call('bx_invites', 'account_add_form_check'))) {
         return $sCode;
     }
     // convert fields to unique format
     $aFieldsProfile = $aFieldsAccount = $this->_convertRemoteFields($aProfileInfo, $sAlternativeName);
     if (empty($aFieldsProfile['email'])) {
         return _t('_Incorrect Email');
     }
     // prepare fields for particular module
     $aFieldsAccount = BxDolService::call('system', 'prepare_fields', array($aFieldsAccount));
     $aFieldsProfile = BxDolService::call($this->_oConfig->sProfilesModule, 'prepare_fields', array($aFieldsProfile));
     // check fields existence in Account
     $oFormHelperAccount = BxDolService::call('system', 'forms_helper');
     $oFormAccount = $oFormHelperAccount->getObjectFormAdd();
     foreach ($aFieldsAccount as $sKey => $mValue) {
         if (!$oFormAccount->isFieldExist($sKey)) {
             unset($aFieldsAccount[$sKey]);
         }
     }
     // check fields existence in Profile
     if ('system' != $this->_oConfig->sProfilesModule && ($oFormHelperProfile = BxDolService::call($this->_oConfig->sProfilesModule, 'forms_helper'))) {
         $oFormProfile = $oFormHelperProfile->getObjectFormAdd();
         foreach ($aFieldsProfile as $sKey => $mValue) {
             if (!$oFormProfile->isFieldExist($sKey)) {
                 unset($aFieldsProfile[$sKey]);
             }
         }
     }
     // antispam check
     $sErrorMsg = '';
     $bSetPendingApproval = false;
     bx_alert('account', 'check_join', 0, false, array('error_msg' => &$sErrorMsg, 'email' => $aFieldsAccount['email'], 'approve' => &$bSetPendingApproval));
     if ($sErrorMsg) {
         return $sErrorMsg;
     }
     // check if user with the same email already exists
     $oExistingAccount = BxDolAccount::getInstance($aFieldsAccount['email']);
     // check redirect page
     if ('join' == $this->_oConfig->sRedirectPage && !$oExistingAccount) {
         return array('remote_profile_info' => $aProfileInfo, 'profile_fields' => $aFieldsAccount, 'join_page_redirect' => true);
     }
     // create new profile
     if ($oExistingAccount) {
         if (!($oExistingProfile = BxDolProfile::getInstanceByAccount($oExistingAccount->id()))) {
             return _t('_sys_txt_error_account_creation');
         }
         $iProfileId = $oExistingProfile->id();
         $this->setLogged($iProfileId);
     } else {
         // create account
         $aFieldsAccount['password'] = genRndPwd();
         $aFieldsAccount['email_confirmed'] = $this->_oConfig->isAlwaysConfirmEmail;
         if (!($iAccountId = $oFormAccount->insert($aFieldsAccount))) {
             return _t('_sys_txt_error_account_creation');
         }
         $isSetPendingApproval = $this->_oConfig->isAlwaysAutoApprove ? false : !(bool) getParam('sys_account_autoapproval');
         $iAccountProfileId = $oFormHelperAccount->onAccountCreated($iAccountId, $isSetPendingApproval, BX_PROFILE_ACTION_EXTERNAL);
         // create profile
         if (isset($oFormProfile) && $oFormProfile) {
             $aFieldsProfile['picture'] = $this->_processImage($aFieldsProfile, $iAccountProfileId, $oFormHelperProfile);
             if (!($iContentId = $oFormProfile->insert($aFieldsProfile))) {
                 return _t('_sys_txt_error_account_creation');
             }
             $oFormHelperProfile->setAutoApproval($oFormHelperProfile->isAutoApproval() ? true : $this->_oConfig->isAlwaysAutoApprove);
             if ($sErrorMsg = $oFormHelperProfile->onDataAddAfter($iAccountId, $iContentId)) {
                 return $sErrorMsg;
             }
             $oProfile = BxDolProfile::getInstanceByAccount($iAccountId);
             $iProfileId = $oProfile->id();
         } else {
             $iProfileId = $iAccountProfileId;
         }
         // send email with password
         sendMailTemplate($this->_oConfig->sEmailTemplatePasswordGenerated, $iAccountId, $iProfileId, array('password' => $aFieldsAccount['password']), BX_EMAIL_SYSTEM);
     }
     // remember remote profile id for created member
     $this->_oDb->saveRemoteId($iProfileId, $aProfileInfo['id']);
     // auto-friend members if they are already friends on remote site
     if ($isAutoFriends && method_exists($this, '_makeFriends')) {
         $this->_makeFriends($iProfileId);
     }
     return array('remote_profile_info' => $aProfileInfo, 'profile_id' => $iProfileId, 'existing_profile' => $oExistingAccount ? true : false);
 }