BxDolJoinProcessor::registerMember PHP Method

registerMember() public method

public registerMember ( )
    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');
            }
        }
        bx_login($iId1);
        check_logged();
        //--- upload profile photo
        if (isset($aProfile1['ProfilePhoto']) && !empty($aProfile1['ProfilePhoto'])) {
            if ('sys_avatar' == getParam('sys_member_info_thumb') && BxDolRequest::serviceExists('avatar', 'set_image_for_cropping')) {
                BxDolService::call('avatar', 'set_image_for_cropping', array($iId1, $GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto']));
            } elseif (BxDolRequest::serviceExists('photos', 'perform_photo_upload', 'Uploader')) {
                bx_import('BxDolPrivacyQuery');
                $oPrivacy = new BxDolPrivacyQuery();
                $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' => $oPrivacy->getDefaultValueModule('photos', 'album_view'));
                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);
    }