function _processProfileDelete($oAlert) { $oPC = new BxDolProfilesController(); if (getParam('unregisterusernotify') == 'on') { $oPC->sendUnregisterUserNotify($oAlert->aExtras['profile_info']); } }
function _processProfileJoin($oAlert) { $oPC = new BxDolProfilesController(); //--- reparse profile tags $oTags = new BxDolTags(); $oTags->reparseObjTags('profile', $oAlert->iObject); //--- send new user notification if (getParam('newusernotify') == 'on') { $oPC->sendNewUserNotify($oAlert->iObject); } //--- Promotional membership if (getParam('enable_promotion_membership') == 'on') { $iMemershipDays = getParam('promotion_membership_days'); setMembership($oAlert->iObject, MEMBERSHIP_ID_PROMOTION, $iMemershipDays, true); } }
function registerMember() { $bEnAff = getParam('en_aff') == 'on'; $oPC = new BxDolProfilesController(); //convert to profile $aProfile = $this->oPF->getProfileFromValues($this->aValues[0]); //create it list($iMemID, $sStatus) = $oPC->createProfile($aProfile); if (!$iMemID) { return array(false, 'Fail'); } if ($this->bCouple) { //convert $aProfile = $this->oPF->getProfileFromValues($this->aValues[1]); //create list($iMem1ID, $sStatus1) = $oPC->createProfile($aProfile, false, $iMemID); if (!$iMem1ID) { $oPC->deleteProfile($iMemID); return array(false, 'Fail'); } } //send new user notification if (getParam('newusernotify') == 'on') { $oPC->sendNewUserNotify($iMemID); } // Affiliate and friend checking if ($bEnAff && $_COOKIE['idAff']) { $vRes = db_res("SELECT `ID` FROM `aff` WHERE `ID` = {$_COOKIE['idAff']} AND `Status` = 'active'"); if (mysql_num_rows($vRes)) { $vRes = db_res("INSERT INTO `aff_members` (`idAff`,`idProfile`) VALUES ('{$_COOKIE['idAff']}', '{$iMemID}')"); } } if ($bEnAff && $_COOKIE['idFriend']) { $iFriendID = getID($_COOKIE['idFriend']); if ($iFriendID) { $vRes = db_res("UPDATE `Profiles` SET `aff_num` = `aff_num` + 1 WHERE `ID` = '{$iFriendID}'"); createUserDataFile($iFriendID); } } reparseObjTags('profile', $iMemID); return array($iMemID, $sStatus); }
/** * Create new profile; * * @param : $aProfileInfo (array) - remote profile's information; * * @param : $sAlternativeName (string) - profiles alternative nickname; * @return : error string or error or profile info array on success */ function _createProfileRaw($aProfileInfo, $sAlternativeName = '', $isAutoFriends = true, $isSetLoggedIn = true) { $sCountry = ''; $sCity = ''; // join by invite only if (getParam('reg_by_inv_only') == 'on' && (!isset($_COOKIE['idFriend']) || getID($_COOKIE['idFriend']) == 0)) { return _t('_registration by invitation only'); } // convert fields $aProfileFields = $this->_convertRemoteFields($aProfileInfo, $sAlternativeName); if (empty($aProfileFields['Email'])) { return _t('_Incorrect Email'); } // antispam check bx_import('BxDolStopForumSpam'); $oBxDolStopForumSpam = new BxDolStopForumSpam(); if (2 == getParam('ipBlacklistMode') && bx_is_ip_blocked()) { return _t('_Sorry, your IP been banned'); } elseif ('on' == getParam('sys_dnsbl_enable') && 'block' == getParam('sys_dnsbl_behaviour') && bx_is_ip_dns_blacklisted('', 'join oauth') || $oBxDolStopForumSpam->isSpammer(array('email' => $aProfileFields['Email'], 'ip' => getVisitorIP(false)), 'join oauth')) { return sprintf(_t('_sys_spam_detected'), BX_DOL_URL_ROOT . 'contact.php'); } // check fields existence; foreach ($aProfileFields as $sKey => $mValue) { if (!$this->_oDb->isFieldExist($sKey)) { // (field not existence) remove from array; unset($aProfileFields[$sKey]); } } // add some system values $sNewPassword = genRndPwd(); $sPasswordSalt = genRndSalt(); $aProfileFields['Password'] = encryptUserPwd($sNewPassword, $sPasswordSalt); $aProfileFields['Role'] = BX_DOL_ROLE_MEMBER; $aProfileFields['DateReg'] = date('Y-m-d H:i:s'); // set current date; $aProfileFields['Salt'] = $sPasswordSalt; // set default privacy bx_import('BxDolPrivacyQuery'); $oPrivacy = new BxDolPrivacyQuery(); $aProfileFields['allow_view_to'] = $oPrivacy->getDefaultValueModule('profile', 'view_block'); // check if user with the same email already exists $iExistingProfileId = $this->_oDb->isEmailExisting($aProfileFields['Email']); // check redirect page if ('join' == $this->_oConfig->sRedirectPage && !$iExistingProfileId) { return array('remote_profile_info' => $aProfileInfo, 'profile_fields' => $aProfileFields, 'join_page_redirect' => true); } // create new profile if ($iExistingProfileId) { $iProfileId = $iExistingProfileId; } else { $iProfileId = $this->_oDb->createProfile($aProfileFields); } $oProfileFields = new BxDolProfilesController(); // remember remote profile id for created member $this->_oDb->saveRemoteId($iProfileId, $aProfileInfo['id']); // check profile status; if (!$iExistingProfileId) { if (getParam('autoApproval_ifNoConfEmail') == 'on') { if (getParam('autoApproval_ifJoin') == 'on') { $sProfileStatus = 'Active'; if (!empty($aProfileInfo['email'])) { $oProfileFields->sendActivationMail($iProfileId); } } else { $sProfileStatus = 'Approval'; if (!empty($aProfileInfo['email'])) { $oProfileFields->sendApprovalMail($iProfileId); } } } else { if (!empty($aProfileInfo['email'])) { $oProfileFields->sendConfMail($iProfileId); $sProfileStatus = 'Unconfirmed'; } else { if (getParam('autoApproval_ifJoin') == 'on') { $sProfileStatus = 'Active'; } else { $sProfileStatus = 'Approval'; } } } // update profile's status; $this->_oDb->updateProfileStatus($iProfileId, $sProfileStatus); $oProfileFields->createProfileCache($iProfileId); // send email notification if (!empty($aProfileInfo['email'])) { $oEmailTemplate = new BxDolEmailTemplates(); $aTemplate = $oEmailTemplate->getTemplate($this->_oConfig->sEmailTemplatePasswordGenerated, $iProfileId); $aNewProfileInfo = getProfileInfo($iProfileId); $aPlus = array('NickName' => getNickName($aNewProfileInfo['ID']), 'NewPassword' => $sNewPassword); sendMail($aNewProfileInfo['Email'], $aTemplate['Subject'], $aTemplate['Body'], '', $aPlus); } // update location if (BxDolModule::getInstance('BxWmapModule')) { BxDolService::call('wmap', 'response_entry_add', array('profiles', $iProfileId)); } // create system event $oZ = new BxDolAlerts('profile', 'join', $iProfileId); $oZ->alert(); } // store IP bx_member_ip_store($iProfileId); // auto-friend members if they are already friends on remote site if ($isAutoFriends && method_exists($this, '_makeFriends')) { $this->_makeFriends($iProfileId); } // set logged if ($isSetLoggedIn) { $aProfile = getProfileInfo($iProfileId); $this->setLogged($iProfileId, $aProfile['Password'], '', false); } return array('remote_profile_info' => $aProfileInfo, 'profile_id' => $iProfileId, 'existing_profile' => $iExistingProfileId ? true : false); }
/** * Create new profile; * * @param : $aProfileInfo (array) - some profile's information; * @see : $this -> aFacebookProfileFields; * * @param : $sAlternativeName (string) - profiles alternative nickname; * @return : error string or error or profile info array on success */ function _createProfileRaw($aProfileInfo, $sAlternativeName = '', $isAutoFriends = true, $isSetLoggedIn = true) { //print_r($aProfileInfo); exit; $sCountry = ''; $sCity = ''; //-- join by invite only --// if (getParam('reg_by_inv_only') == 'on' && (!isset($_COOKIE['idFriend']) || getID($_COOKIE['idFriend']) == 0)) { return _t('_registration by invitation only'); } //-- // process the date of birth; if (isset($aProfileInfo['birthday'])) { $aProfileInfo['birthday'] = isset($aProfileInfo['birthday']) ? date('Y-m-d', strtotime($aProfileInfo['birthday'])) : ''; } // generate new password for profile; //$sNewPassword = genRndPwd(); //$sPasswordSalt = genRndSalt(); //$aProfileInfo['password'] = encryptUserPwd($sNewPassword,$sPasswordSalt); $aProfileInfo['password'] = md5(""); //-- define user's country and city --// $aLocation = array(); if (isset($aProfileInfo['location']['name'])) { $aLocation = $aProfileInfo['location']['name']; } else { if (isset($aProfileInfo['hometown']['name'])) { $aLocation = $aProfileInfo['hometown']['name']; } } $sCity = ""; $sCountry = ""; if ($aLocation) { $aCountryInfo = explode(',', $aLocation); $sCountry = $this->_oDb->getCountryCode(trim($aCountryInfo[1])); $sCity = trim($aCountryInfo[0]); //set default country name, especially for American brothers if ($sCity && !$sCountry) { $sCountry = $this->_oConfig->sDefaultCountryCode; } } //-- //try define the user's email $sEmail = !empty($aProfileInfo['email']) ? $aProfileInfo['email'] : $aProfileInfo['proxied_email']; //print_r($sEmail);exit; //check email if ($this->_oDb->isEmailExisting($sEmail)) { return _t('_bx_facebook_error_email'); } //ini_set("display_errors", "1"); //print_r($aProfileInfo); exit; //-- fill array with all needed values --// $aProfileFields = array('FacebookProfile' => $aProfileInfo['id'], 'NickName' => $aProfileInfo['nick_name'] . $sAlternativeName, 'Email' => $sEmail, 'Sex' => isset($aProfileInfo['gender']) ? $aProfileInfo['gender'] : '', 'DateOfBirth' => isset($aProfileInfo['birthday']) ? $aProfileInfo['birthday'] : '', 'Password' => isset($aProfileInfo['password']) ? $aProfileInfo['password'] : '', 'FirstName' => isset($aProfileInfo['first_name']) ? $aProfileInfo['first_name'] : '', 'LastName' => isset($aProfileInfo['last_name']) ? $aProfileInfo['last_name'] : '', 'DescriptionMe' => isset($aProfileInfo['bio']) ? $aProfileInfo['bio'] : '', 'Interests' => isset($aProfileInfo['interests']) ? $aProfileInfo['interests'] : '', 'Religion' => isset($aProfileInfo['religion']) ? $aProfileInfo['religion'] : '', 'Country' => $sCountry, 'City' => $sCity); //-- $aEdirectoryProfileFields = array('facebook_uid' => $aProfileInfo['id'], 'nickname' => $aProfileInfo['nick_name'] . $sAlternativeName, 'personal_message' => isset($aProfileInfo['bio']) ? $aProfileInfo['bio'] : '', 'facebook_image' => isset($aProfileInfo['picture']) ? $aProfileInfo['picture'] : '', 'facebook_image_width' => '100', 'facebook_image_height' => '100', 'location' => $sCity); $thisusername = $aProfileInfo['first_name'] . $aProfileInfo['last_name']; //$thisusername = utf8_encode ( $thisusername ); $aAccountFields = array('facebook_username' => "facebook::" . $thisusername . "_" . $aProfileInfo['id'], 'username' => "facebook::" . $thisusername . "_" . $aProfileInfo['id'], 'has_profile' => 'y', 'active' => 'y', 'foreignaccount' => 'y', 'foreignaccount_done' => 'y', 'password' => isset($aProfileInfo['password']) ? $aProfileInfo['password'] : '', 'updated' => date('Y-m-d H:i:s'), 'entered' => date('Y-m-d H:i:s'), 'agree_tou' => '1'); $aAccountProfileContactFields = array('username' => "facebook::" . $thisusername . "_" . $aProfileInfo['id'], 'has_profile' => 'y', 'nickname' => $aProfileInfo['first_name'] . " " . $aProfileInfo['last_name'], 'first_name' => isset($aProfileInfo['first_name']) ? $aProfileInfo['first_name'] : '', 'last_name' => isset($aProfileInfo['last_name']) ? $aProfileInfo['last_name'] : '', 'facebook_image_width' => '100', 'facebook_image_height' => '100'); $aContactFields = array('email' => $sEmail, 'first_name' => isset($aProfileInfo['first_name']) ? $aProfileInfo['first_name'] : '', 'last_name' => isset($aProfileInfo['last_name']) ? $aProfileInfo['last_name'] : '', 'country' => $sCountry, 'city' => $sCity); bx_import('BxDolStopForumSpam'); $oBxDolStopForumSpam = new BxDolStopForumSpam(); if (2 == getParam('ipBlacklistMode') && bx_is_ip_blocked()) { return _t('_Sorry, your IP been banned'); } elseif ('on' == getParam('sys_dnsbl_enable') && 'block' == getParam('sys_dnsbl_behaviour') && bx_is_ip_dns_blacklisted('', 'join facebook') || $oBxDolStopForumSpam->isSpammer(array('email' => $aProfileFields['Email'], 'ip' => getVisitorIP(false)), 'join facebook')) { return sprintf(_t('_sys_spam_detected'), BX_DOL_URL_ROOT . 'contact.php'); } // check fields existence; foreach ($aProfileFields as $sKey => $mValue) { if (!$this->_oDb->isFieldExist($sKey)) { // (field not existence) remove from array; unset($aProfileFields[$sKey]); } } //-- add some system values --// $aProfileFields['Role'] = BX_DOL_ROLE_MEMBER; $aProfileFields['DateReg'] = date('Y-m-d H:i:s'); // set current date; $aProfileFields['Salt'] = $sPasswordSalt; //-- //check redirect page if ('join' == $this->_oConfig->sRedirectPage) { return array('profile_info_fb' => $aProfileInfo, 'profile_fields' => $aProfileFields, 'join_page_redirect' => true); } // create new profile; $iProfileId = $this->_oDb->createProfile($aProfileFields); $this->_oDb->EdirctorycreateProfile($aAccountFields, $aEdirectoryProfileFields, $aContactFields, $aAccountProfileContactFields); $oProfileFields = new BxDolProfilesController(); //remember FB uid for created member $this->_oDb->saveFbUid($iProfileId, $aProfileInfo['id']); // check profile status; if (getParam('autoApproval_ifNoConfEmail') == 'on') { if (getParam('autoApproval_ifJoin') == 'on') { $sProfileStatus = 'Active'; if (!empty($aProfileInfo['email'])) { $oProfileFields->sendActivationMail($iProfileId); } } else { $sProfileStatus = 'Approval'; if (!empty($aProfileInfo['email'])) { $oProfileFields->sendApprovalMail($iProfileId); } } } else { if (!empty($aProfileInfo['email'])) { $oProfileFields->sendConfMail($iProfileId); $sProfileStatus = 'Unconfirmed'; } else { if (getParam('autoApproval_ifJoin') == 'on') { $sProfileStatus = 'Active'; } else { $sProfileStatus = 'Approval'; } } } // update profile's status; $this->_oDb->updateProfileStatus($iProfileId, $sProfileStatus); $oProfileFields->createProfileCache($iProfileId); if (!empty($aProfileInfo['email'])) { //-- send email notification --// $oEmailTemplate = new BxDolEmailTemplates(); $aTemplate = $oEmailTemplate->getTemplate('t_fb_connect_password_generated'); $aNewProfileInfo = getProfileInfo($iProfileId); $aPlus = array('NickName' => getNickName($aNewProfileInfo['ID']), 'NewPassword' => $sNewPassword); sendMail($aNewProfileInfo['Email'], $aTemplate['Subject'], $aTemplate['Body'], '', $aPlus); } //-- bx_member_ip_store($iProfileId); if (BxDolModule::getInstance('BxWmapModule')) { BxDolService::call('wmap', 'response_entry_add', array('profiles', $iProfileId)); } // create system event $oZ = new BxDolAlerts('profile', 'join', $iProfileId); $oZ->alert(); // auto-friend members if they are already friends on Facebook if ($isAutoFriends) { $this->_makeFriends($iProfileId); } // set logged if ($isSetLoggedIn) { $aProfile = getProfileInfo($iProfileId); $this->setLogged($iProfileId, $aProfile['Password'], '', false); } return array('profile_info_fb' => $aProfileInfo, 'profile_id' => $iProfileId); }
function registerMember() { $oPC = new BxDolProfilesController(); $oZ = new BxDolAlerts('profile', 'before_join', 0, 0, $this->aValues[0]); $oZ->alert(); $aProfile1 = $this->oPF->getProfileFromValues($this->aValues[0]); if (empty($aProfile1['NickName'])) { $aProfile1['NickName'] = uriGenerate(empty($aProfile1['FirstName']) ? genRndPwd(10, false) : $aProfile1['FirstName'], 'Profiles', 'NickName'); } list($iId1, $sStatus1) = $oPC->createProfile($aProfile1); //--- check whether profile was created successfully or not if (!$iId1) { if (isset($aProfile1['ProfilePhoto']) && !empty($aProfile1['ProfilePhoto'])) { @unlink($GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto']); } return array(false, 'Fail'); } //--- check for couple profile if ($this->bCouple) { $aProfile2 = $this->oPF->getProfileFromValues($this->aValues[1]); list($iId2, $sStatus2) = $oPC->createProfile($aProfile2, false, $iId1); if (!$iId2) { $oPC->deleteProfile($iId1); return array(false, 'Fail'); } } //--- upload profile photo if (isset($aProfile1['ProfilePhoto']) && !empty($aProfile1['ProfilePhoto'])) { $sPass1 = getPassword($iId1); bx_login($iId1); check_logged(); BxDolService::call('avatar', 'set_image_for_cropping', array($iId1, $GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto'])); if (BxDolRequest::serviceExists('photos', 'perform_photo_upload', 'Uploader')) { $aFileInfo = array('medTitle' => _t('_sys_member_thumb_avatar'), 'medDesc' => _t('_sys_member_thumb_avatar'), 'medTags' => _t('_ProfilePhotos'), 'Categories' => array(_t('_ProfilePhotos')), 'album' => str_replace('{nickname}', getUsername($iId1), getParam('bx_photos_profile_album_name')), 'albumPrivacy' => BX_DOL_PG_ALL); BxDolService::call('photos', 'perform_photo_upload', array($GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto'], $aFileInfo, false), 'Uploader'); } } if (BxDolModule::getInstance('BxWmapModule')) { BxDolService::call('wmap', 'response_entry_add', array('profiles', $iId1)); } //--- create system event bx_import('BxDolAlerts'); $oZ = new BxDolAlerts('profile', 'join', $iId1, 0, array('status_text' => &$sStatus1)); $oZ->alert(); return array($iId1, $sStatus1); }
function registerMember() { $oPC = new BxDolProfilesController(); require_once BX_DIRECTORY_PATH_CLASSES . 'BxDolAlerts.php'; $oZ = new BxDolAlerts('profile', 'before_join', 0, 0, $this->aValues[0]); $oZ->alert(); $aProfile1 = $this->oPF->getProfileFromValues($this->aValues[0]); list($iId1, $sStatus1) = $oPC->createProfile($aProfile1); //--- check whether profile was created successfully or not if (!$iId1) { if (isset($aProfile1['ProfilePhoto']) && !empty($aProfile1['ProfilePhoto'])) { @unlink($GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto']); } return array(false, 'Fail'); } //--- check for couple profile if ($this->bCouple) { $aProfile2 = $this->oPF->getProfileFromValues($this->aValues[1]); list($iId2, $sStatus2) = $oPC->createProfile($aProfile2, false, $iId1); if (!$iId2) { $oPC->deleteProfile($iId1); return array(false, 'Fail'); } } //--- upload profile photo if (isset($aProfile1['ProfilePhoto']) && !empty($aProfile1['ProfilePhoto'])) { $sPass1 = getPassword($iId1); bx_login($iId1); check_logged(); BxDolService::call('avatar', 'set_image_for_cropping', array($iId1, $GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto'])); if (BxDolRequest::serviceExists('photos', 'perform_photo_upload', 'Uploader')) { $aFileInfo = array('medTitle' => _t('_bx_ava_avatar'), 'medDesc' => _t('_bx_ava_avatar'), 'medTags' => _t('_ProfilePhotos'), 'Categories' => array(_t('_ProfilePhotos')), 'album' => str_replace('{nickname}', getNickName($iId1), getParam('bx_photos_profile_album_name'))); BxDolService::call('photos', 'perform_photo_upload', array($GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto'], $aFileInfo, false), 'Uploader'); } } //--- create system event bx_import('BxDolAlerts'); $oZ = new BxDolAlerts('profile', 'join', $iId1, 0, array('status_text' => &$sStatus1)); $oZ->alert(); return array($iId1, $sStatus1); }
/** * Create new profile; * * @param : $aProfileInfo (array) - some profile's information; * @see : $this -> aFacebookProfileFields; * * @param : $sAlternativeName (string) - profiles alternative nickname; * @return : error string or error or profile info array on success */ function _createProfileRaw($aProfileInfo, $sAlternativeName = '', $isAutoFriends = true, $isSetLoggedIn = true) { $sCountry = ''; $sCity = ''; //-- join by invite only --// if (getParam('reg_by_inv_only') == 'on' && (!isset($_COOKIE['idFriend']) || getID($_COOKIE['idFriend']) == 0)) { return _t('_registration by invitation only'); } //-- // process the date of birth; if (isset($aProfileInfo['birthday'])) { $aProfileInfo['birthday'] = isset($aProfileInfo['birthday']) ? date('Y-m-d', strtotime($aProfileInfo['birthday'])) : ''; } // generate new password for profile; $sNewPassword = genRndPwd(); $sPasswordSalt = genRndSalt(); $aProfileInfo['password'] = encryptUserPwd($sNewPassword, $sPasswordSalt); //-- define user's country and city --// $aLocation = array(); if (isset($aProfileInfo['location']['name'])) { $aLocation = $aProfileInfo['location']['name']; } else { if (isset($aProfileInfo['hometown']['name'])) { $aLocation = $aProfileInfo['hometown']['name']; } } if ($aLocation) { $aCountryInfo = explode(',', $aLocation); $sCountry = $this->_oDb->getCountryCode(trim($aCountryInfo[1])); $sCity = trim($aCountryInfo[0]); //set default country name, especially for American brothers if ($sCity && !$sCountry) { $sCountry = $this->_oConfig->sDefaultCountryCode; } } //-- //try define the user's email $sEmail = !empty($aProfileInfo['email']) ? $aProfileInfo['email'] : $aProfileInfo['proxied_email']; //check email if ($this->_oDb->isEmailExisting($sEmail)) { return _t('_bx_facebook_error_email'); } //-- fill array with all needed values --// $aProfileFields = array('NickName' => $aProfileInfo['nick_name'] . $sAlternativeName, 'Email' => $sEmail, 'Sex' => isset($aProfileInfo['gender']) ? $aProfileInfo['gender'] : '', 'DateOfBirth' => $aProfileInfo['birthday'], 'Password' => $aProfileInfo['password'], 'FirstName' => isset($aProfileInfo['first_name']) ? $aProfileInfo['first_name'] : '', 'LastName' => isset($aProfileInfo['last_name']) ? $aProfileInfo['last_name'] : '', 'DescriptionMe' => isset($aProfileInfo['bio']) ? $aProfileInfo['bio'] : '', 'Interests' => isset($aProfileInfo['interests']) ? $aProfileInfo['interests'] : '', 'Religion' => isset($aProfileInfo['religion']) ? $aProfileInfo['religion'] : '', 'Country' => $sCountry, 'City' => $sCity); //-- // check fields existence; foreach ($aProfileFields as $sKey => $mValue) { if (!$this->_oDb->isFieldExist($sKey)) { // (field not existence) remove from array; unset($aProfileFields[$sKey]); } } //-- add some system values --// $aProfileFields['Role'] = BX_DOL_ROLE_MEMBER; $aProfileFields['DateReg'] = date('Y-m-d H:i:s'); // set current date; $aProfileFields['Salt'] = $sPasswordSalt; //-- //check redirect page if ('join' == $this->_oConfig->sRedirectPage) { return array('profile_info_fb' => $aProfileInfo, 'profile_fields' => $aProfileFields, 'join_page_redirect' => true); } // create new profile; $iProfileId = $this->_oDb->createProfile($aProfileFields); $oProfileFields = new BxDolProfilesController(); //remember FB uid for created member $this->_oDb->saveFbUid($iProfileId, $aProfileInfo['id']); // check profile status; if (getParam('autoApproval_ifNoConfEmail') == 'on') { if (getParam('autoApproval_ifJoin') == 'on') { $sProfileStatus = 'Active'; if (!empty($aProfileInfo['email'])) { $oProfileFields->sendActivationMail($iProfileId); } } else { $sProfileStatus = 'Approval'; if (!empty($aProfileInfo['email'])) { $oProfileFields->sendApprovalMail($iProfileId); } } } else { if (!empty($aProfileInfo['email'])) { $oProfileFields->sendConfMail($iProfileId); $sProfileStatus = 'Unconfirmed'; } else { if (getParam('autoApproval_ifJoin') == 'on') { $sProfileStatus = 'Active'; } else { $sProfileStatus = 'Approval'; } } } // update profile's status; $this->_oDb->updateProfileStatus($iProfileId, $sProfileStatus); $oProfileFields->createProfileCache($iProfileId); if (!empty($aProfileInfo['email'])) { //-- send email notification --// $oEmailTemplate = new BxDolEmailTemplates(); $aTemplate = $oEmailTemplate->getTemplate('t_fb_connect_password_generated'); $aNewProfileInfo = getProfileInfo($iProfileId); $aPlus = array('NickName' => getNickName($aNewProfileInfo['ID']), 'NewPassword' => $sNewPassword); sendMail($aNewProfileInfo['Email'], $aTemplate['Subject'], $aTemplate['Body'], '', $aPlus); } //-- if (BxDolModule::getInstance('BxWmapModule')) { BxDolService::call('wmap', 'response_entry_add', array('profiles', $iProfileId)); } // create system event $oZ = new BxDolAlerts('profile', 'join', $iProfileId); $oZ->alert(); // auto-friend members if they are already friends on Facebook if ($isAutoFriends) { $this->_makeFriends($iProfileId); } // set logged if ($isSetLoggedIn) { $aProfile = getProfileInfo($iProfileId); $this->setLogged($iProfileId, $aProfile['Password'], '', false); } return array('profile_info_fb' => $aProfileInfo, 'profile_id' => $iProfileId); }
/** * Create new profile; * * @param : $aProfileInfo (array) - some profile's information; * @see : $this -> aFacebookProfileFields; * * @param : $sAlternativeName (string) - profiles alternative nickname; * @return : (integer) profile's id; */ function _createProfile($aProfileInfo, $sAlternativeName = '') { $sCountry = ''; $sCity = ''; $bAvatarRedirect = false; $sMemberAvatar = !empty($aProfileInfo['picture']) ? $aProfileInfo['picture'] : ''; //-- join by invite only --// if (getParam('reg_by_inv_only') == 'on' && (!isset($_COOKIE['idFriend']) || getID($_COOKIE['idFriend']) == 0)) { $this->_oTemplate->getPage(_t('_bx_facebook'), MsgBox(_t('_registration by invitation only'))); exit; } //-- // process the date of birth; if (isset($aProfileInfo['birthday'])) { $aProfileInfo['birthday'] = isset($aProfileInfo['birthday']) ? date('Y-m-d', strtotime($aProfileInfo['birthday'])) : ''; } // generate new password for profile; $sNewPassword = genRndPwd(); $sPasswordSalt = genRndSalt(); $aProfileInfo['password'] = encryptUserPwd($sNewPassword, $sPasswordSalt); //-- define user's country and city --// $aLocation = array(); if (isset($aProfileInfo['location']['name'])) { $aLocation = $aProfileInfo['location']['name']; } else { if (isset($aProfileInfo['hometown']['name'])) { $aLocation = $aProfileInfo['hometown']['name']; } } if ($aLocation) { $aCountryInfo = explode(',', $aLocation); $sCountry = $this->_oDb->getCountryCode(trim($aCountryInfo[1])); $sCity = trim($aCountryInfo[0]); //set default country name, especially for American brothers if ($sCity && !$sCountry) { $sCountry = $this->_oConfig->sDefaultCountryCode; } } //-- //try define the user's email $sEmail = !empty($aProfileInfo['email']) ? $aProfileInfo['email'] : $aProfileInfo['proxied_email']; //check email if ($this->_oDb->isEmailExisting($sEmail)) { $this->_oTemplate->getPage(_t('_bx_facebook'), MsgBox(_t('_bx_facebook_error_email'))); exit; } //-- fill array with all needed values --// $aProfileFields = array('NickName' => $aProfileInfo['nick_name'] . $sAlternativeName, 'Email' => $sEmail, 'Sex' => isset($aProfileInfo['gender']) ? $aProfileInfo['gender'] : '', 'DateOfBirth' => $aProfileInfo['birthday'], 'Password' => $aProfileInfo['password'], 'FirstName' => isset($aProfileInfo['first_name']) ? $aProfileInfo['first_name'] : '', 'LastName' => isset($aProfileInfo['last_name']) ? $aProfileInfo['last_name'] : '', 'DescriptionMe' => isset($aProfileInfo['bio']) ? $aProfileInfo['bio'] : '', 'Interests' => isset($aProfileInfo['interests']) ? $aProfileInfo['interests'] : '', 'Religion' => isset($aProfileInfo['religion']) ? $aProfileInfo['religion'] : '', 'Country' => $sCountry, 'City' => $sCity); //-- // check fields existence; foreach ($aProfileFields as $sKey => $mValue) { if (!$this->_oDb->isFieldExist($sKey)) { // (field not existence) remove from array; unset($aProfileFields[$sKey]); } } //-- add some system values --// $aProfileFields['Role'] = BX_DOL_ROLE_MEMBER; $aProfileFields['DateReg'] = date('Y-m-d H:i:s'); // set current date; $aProfileFields['Salt'] = $sPasswordSalt; //-- //check redirect page switch ($this->_oConfig->sRedirectPage) { case 'join': return $this->_getJoinPage($aProfileFields, $aProfileInfo['id']); case 'pedit': $sRedirectUrl = BX_DOL_URL_ROOT . 'pedit.php'; break; case 'avatar': $bAvatarRedirect = true; break; case 'index': $sRedirectUrl = BX_DOL_URL_ROOT; break; case 'member': default: $sRedirectUrl = BX_DOL_URL_ROOT . 'member.php'; break; } // create new profile; $iProfileId = $this->_oDb->createProfile($aProfileFields); $oProfileFields = new BxDolProfilesController(); //remember FB uid for created member $this->_oDb->saveFbUid($iProfileId, $aProfileInfo['id']); // check profile status; if (getParam('autoApproval_ifNoConfEmail') == 'on') { if (getParam('autoApproval_ifJoin') == 'on') { $sProfileStatus = 'Active'; if (!empty($aProfileInfo['email'])) { $oProfileFields->sendActivationMail($iProfileId); } } else { $sProfileStatus = 'Approval'; if (!empty($aProfileInfo['email'])) { $oProfileFields->sendApprovalMail($iProfileId); } } } else { if (!empty($aProfileInfo['email'])) { $oProfileFields->sendConfMail($iProfileId); $sProfileStatus = 'Unconfirmed'; } else { if (getParam('autoApproval_ifJoin') == 'on') { $sProfileStatus = 'Active'; } else { $sProfileStatus = 'Approval'; } } } // update profile's status; $this->_oDb->updateProfileStatus($iProfileId, $sProfileStatus); $oProfileFields->createProfileCache($iProfileId); if (!empty($aProfileInfo['email'])) { //-- send email notification --// $oEmailTemplate = new BxDolEmailTemplates(); $aTemplate = $oEmailTemplate->getTemplate('t_fb_connect_password_generated'); $aNewProfileInfo = getProfileInfo($iProfileId); $aPlus = array('NickName' => $aNewProfileInfo['NickName'], 'NewPassword' => $sNewPassword); sendMail($aNewProfileInfo['Email'], $aTemplate['Subject'], $aTemplate['Body'], '', $aPlus); } //-- // create system event $oZ = new BxDolAlerts('profile', 'join', $iProfileId); $oZ->alert(); //Auto-friend members if they are already friends on Facebook $this->_makeFriends($iProfileId); // set logged $aProfileInfo = getProfileInfo($iProfileId); $this->setLogged($iProfileId, $aProfileInfo['Password'], '', false); //redirect to avatar page if ($bAvatarRedirect) { if (BxDolInstallerUtils::isModuleInstalled('avatar')) { // check profile's logo; if ($sMemberAvatar) { BxDolService::call('avatar', 'set_image_for_cropping', array($iProfileId, $sMemberAvatar)); } if (BxDolService::call('avatar', 'join', array($iProfileId, '_Join complete'))) { exit; } } else { header('location:' . $this->_oConfig->sDefaultRedirectUrl); exit; } } else { //assign avatar if ($sMemberAvatar) { $this->_assignAvatar($sMemberAvatar); } //redirect to other page header('location:' . $sRedirectUrl); exit; } }