function getUserMusicLink()
{
    global $sModulesUrl;
    if (BxDolInstallerUtils::isModuleInstalled("sounds")) {
        return $sModulesUrl . "mp3/soundslink.php?id=#user#";
    }
    return "";
}
function getUserMusicLink()
{
    global $sRootURL;
    if (BxDolInstallerUtils::isModuleInstalled("sounds")) {
        $oDolPermalinks = new BxDolPermalinks();
        return $sRootURL . $oDolPermalinks->permalink("modules?r=sounds/") . "browse/owner/#nick#";
    }
    return "";
}
function isModuleAvailable($sModuleName, $sUserId = "", $sAction = "")
{
    $bResult = BxDolInstallerUtils::isModuleInstalled($sModuleName);
    if ($bResult && !empty($sUserId) && !empty($sAction)) {
        $aResult = checkAction($sUserId, $sAction);
        $bResult = $aResult[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED;
    }
    return $bResult;
}
 /**
  * get redirect URL
  * 
  * @param $iProfileId integer - profile ID
  * @return string redirect URL
  */
 function _getRedirectUrl($iProfileId, $isExistingProfile = false)
 {
     if ($isExistingProfile) {
         return 'index' == $this->_oConfig->sRedirectPage ? BX_DOL_URL_ROOT : BX_DOL_URL_ROOT . 'member.php';
     }
     $sRedirectUrl = $this->_oConfig->sDefaultRedirectUrl;
     switch ($this->_oConfig->sRedirectPage) {
         case 'join':
         case 'pedit':
             $sRedirectUrl = BX_DOL_URL_ROOT . 'pedit.php?ID=' . (int) $iProfileId;
             break;
         case 'avatar':
             if (BxDolInstallerUtils::isModuleInstalled('avatar') && BxDolService::call('avatar', 'join', array($iProfileId, '_Join complete'))) {
                 exit;
             }
             break;
         case 'index':
             $sRedirectUrl = BX_DOL_URL_ROOT;
             break;
         case 'member':
         default:
             $sRedirectUrl = BX_DOL_URL_ROOT . 'member.php';
             break;
     }
     return $sRedirectUrl;
 }
 /**
  * Create new profile;
  *
  * @param  : $aProfileInfo (array) - some profile's information;
  *          @see : $this -> aFacebookProfileFields;
  *
  * @param  : $sAlternativeName (string) - profiles alternative nickname;
  */
 function _createProfile($aProfileInfo, $sAlternativeName = '')
 {
     $mixed = $this->_createProfileRaw($aProfileInfo, $sAlternativeName);
     //print_r($mixed); exit;
     if (is_string($mixed)) {
         $this->_oTemplate->getPage(_t('_bx_facebook'), MsgBox($mixed));
         exit;
     } elseif (is_array($mixed) && isset($mixed['join_page_redirect'])) {
         $this->_getJoinPage($mixed['profile_fields'], $mixed['profile_info_fb']['id']);
         exit;
     } elseif (is_array($mixed) && isset($mixed['profile_id'])) {
         $bAvatarRedirect = false;
         //check redirect page
         switch ($this->_oConfig->sRedirectPage) {
             case 'join':
                 //handled above
                 //$sRedirectUrl = BX_DOL_URL_ROOT;
                 //break;
                 exit;
             case 'pedit':
                 $sRedirectUrl = BX_DOL_URL_ROOT . 'pedit.php?ID=' . (int) $mixed['profile_id'];
                 break;
             case 'avatar':
                 $bAvatarRedirect = true;
                 break;
             case 'index':
                 $sRedirectUrl = BX_DOL_URL_ROOT . 'member.php';
                 break;
             case 'member':
                 $sRedirectUrl = BX_DOL_URL_ROOT . 'member.php';
                 break;
             default:
                 $sRedirectUrl = BX_DOL_URL_ROOT . 'member.php';
                 break;
         }
         $iProfileId = $mixed['profile_id'];
         $sMemberAvatar = !empty($mixed['profile_info_fb']['picture']) ? $mixed['profile_info_fb']['picture'] : '';
         //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;
         }
     } else {
         $this->_oTemplate->getPage(_t('_bx_facebook'), MsgBox(_t('_Error Occured')));
         exit;
     }
 }
Beispiel #6
0
$oSysTemplate->addJs('view_edit.js');
$_ni = 5;
$_page['name_index'] = $_ni;
$_page['css_name'] = array('profile_view.css', 'profile_view_tablet.css', 'profile_view_phone.css');
$p_arr = $oProfile->_aProfile;
$sUserInfo = $oFunctions->getUserInfo($p_arr['ID']);
if (!empty($sUserInfo)) {
    $sUserInfo = ': ' . htmlspecialchars_adv($sUserInfo);
}
$_page['header'] = process_line_output(getNickName($p_arr['ID'])) . $sUserInfo;
$oPPV = new BxTemplProfileView($oProfile, $site, $dir);
$_page_cont[$_ni]['page_main_code'] = $oPPV->getCode();
$_page_cont[$_ni]['custom_block'] = '';
$_page_cont[$_ni]['page_main_css'] = '';
// add profile customizer
if (BxDolInstallerUtils::isModuleInstalled("profile_customize")) {
    $_page_cont[$_ni]['custom_block'] = '<div id="profile_customize_page" style="display: none;">' . BxDolService::call('profile_customize', 'get_customize_block', array()) . '</div>';
    $_page_cont[$_ni]['page_main_css'] = '<style type="text/css">' . BxDolService::call('profile_customize', 'get_profile_style', array($profileID)) . '</style>';
}
// Submenu actions
$iId = $profileID;
$iMemberId = $memberID;
$sTxtProfileAccountPage = _t('_sys_am_profile_account_page');
$sTxtProfileMessage = _t('_sys_am_profile_message');
$sTxtFriendAdd = _t('_sys_am_profile_friend_add');
$sTxtFriendAccept = _t('_sys_am_profile_friend_accept');
$sTxtFriendCancel = _t('_sys_am_profile_friend_cancel');
$aVars = array('ID' => $iId, 'member_id' => $iMemberId, 'BaseUri' => BX_DOL_URL_ROOT, 'cpt_am_profile_account_page' => $sTxtProfileAccountPage);
if (isFriendRequest($iMemberId, $iId)) {
    $aVars['cpt_am_friend_add'] = '';
    $aVars['cpt_am_profile_message'] = $sTxtProfileMessage;
 /**
  * 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;
     }
 }