function getProfilesMatch($iPID1 = 0, $iPID2 = 0)
{
    $iPID1 = (int) $iPID1;
    $iPID2 = (int) $iPID2;
    if (!$iPID1 or !$iPID2) {
        return 0;
    }
    if ($iPID1 == $iPID2) {
        return 0;
    }
    //maybe need to return 100?? :)
    // try to find in cache
    $sQuery = "SELECT `Percent` FROM `ProfilesMatch` WHERE `PID1` = {$iPID1} AND `PID2` = {$iPID2}";
    $aPercent = db_assoc_arr($sQuery);
    if ($aPercent) {
        return (int) $aPercent['Percent'];
    }
    //not found in cache
    $aProf1 = getProfileInfo($iPID1);
    $aProf2 = getProfileInfo($iPID2);
    if (!$aProf1 or !$aProf2) {
        return 0;
    }
    $oPF = new BxDolProfileFields(101);
    //matching area
    $iMatch = $oPF->getProfilesMatch($aProf1, $aProf2);
    //write to cache
    $sQuery = "INSERT INTO `ProfilesMatch` ( `PID1`, `PID2`, `Percent` ) VALUES ( {$iPID1}, {$iPID2}, {$iMatch} )";
    db_res($sQuery);
    return $iMatch;
}
Пример #2
0
 function BxGroupsFormAdd($oMain, $iProfileId, $iEntryId = 0, $iThumb = 0)
 {
     $this->_oMain = $oMain;
     $this->_oDb = $oMain->_oDb;
     $this->_aMedia = array('images' => array('post' => 'ready_images', 'upload_func' => 'uploadPhotos', 'tag' => BX_GROUPS_PHOTOS_TAG, 'cat' => BX_GROUPS_PHOTOS_CAT, 'thumb' => 'thumb', 'module' => 'photos', 'title_upload_post' => 'images_titles', 'title_upload' => _t('_bx_groups_form_caption_file_title'), 'service_method' => 'get_photo_array'), 'videos' => array('post' => 'ready_videos', 'upload_func' => 'uploadVideos', 'tag' => BX_GROUPS_VIDEOS_TAG, 'cat' => BX_GROUPS_VIDEOS_CAT, 'thumb' => false, 'module' => 'videos', 'title_upload_post' => 'videos_titles', 'title_upload' => _t('_bx_groups_form_caption_file_title'), 'service_method' => 'get_video_array'), 'sounds' => array('post' => 'ready_sounds', 'upload_func' => 'uploadSounds', 'tag' => BX_GROUPS_SOUNDS_TAG, 'cat' => BX_GROUPS_SOUNDS_CAT, 'thumb' => false, 'module' => 'sounds', 'title_upload_post' => 'sounds_titles', 'title_upload' => _t('_bx_groups_form_caption_file_title'), 'service_method' => 'get_music_array'), 'files' => array('post' => 'ready_files', 'upload_func' => 'uploadFiles', 'tag' => BX_GROUPS_FILES_TAG, 'cat' => BX_GROUPS_FILES_CAT, 'thumb' => false, 'module' => 'files', 'title_upload_post' => 'files_titles', 'title_upload' => _t('_bx_groups_form_caption_file_title'), 'service_method' => 'get_file_array'));
     bx_import('BxDolCategories');
     $oCategories = new BxDolCategories();
     $oProfileFields = new BxDolProfileFields(0);
     $aCountries = $oProfileFields->convertValues4Input('#!Country');
     asort($aCountries);
     // generate templates for custom form's elements
     $aCustomMediaTemplates = $this->generateCustomMediaTemplates($oMain->_iProfileId, $iEntryId, $iThumb);
     // privacy
     $aInputPrivacyCustom = array();
     $aInputPrivacyCustom[] = array('key' => '', 'value' => '----');
     $aInputPrivacyCustom[] = array('key' => 'f', 'value' => _t('_bx_groups_privacy_fans_only'));
     $aInputPrivacyCustomPass = array('pass' => 'Preg', 'params' => array('/^([0-9f]+)$/'));
     $aInputPrivacyCustom2 = array(array('key' => 'f', 'value' => _t('_bx_groups_privacy_fans')), array('key' => 'a', 'value' => _t('_bx_groups_privacy_admins_only')));
     $aInputPrivacyCustom2Pass = array('pass' => 'Preg', 'params' => array('/^([fa]+)$/'));
     $aInputPrivacyViewFans = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'view_fans');
     $aInputPrivacyViewFans['values'] = array_merge($aInputPrivacyViewFans['values'], $aInputPrivacyCustom);
     $aInputPrivacyComment = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'comment');
     $aInputPrivacyComment['values'] = array_merge($aInputPrivacyComment['values'], $aInputPrivacyCustom);
     $aInputPrivacyComment['db'] = $aInputPrivacyCustomPass;
     $aInputPrivacyRate = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'rate');
     $aInputPrivacyRate['values'] = array_merge($aInputPrivacyRate['values'], $aInputPrivacyCustom);
     $aInputPrivacyRate['db'] = $aInputPrivacyCustomPass;
     $aInputPrivacyForum = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'post_in_forum');
     $aInputPrivacyForum['values'] = array_merge($aInputPrivacyForum['values'], $aInputPrivacyCustom);
     $aInputPrivacyForum['db'] = $aInputPrivacyCustomPass;
     $aInputPrivacyUploadPhotos = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'upload_photos');
     $aInputPrivacyUploadPhotos['values'] = $aInputPrivacyCustom2;
     $aInputPrivacyUploadPhotos['db'] = $aInputPrivacyCustom2Pass;
     $aInputPrivacyUploadVideos = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'upload_videos');
     $aInputPrivacyUploadVideos['values'] = $aInputPrivacyCustom2;
     $aInputPrivacyUploadVideos['db'] = $aInputPrivacyCustom2Pass;
     $aInputPrivacyUploadSounds = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'upload_sounds');
     $aInputPrivacyUploadSounds['values'] = $aInputPrivacyCustom2;
     $aInputPrivacyUploadSounds['db'] = $aInputPrivacyCustom2Pass;
     $aInputPrivacyUploadFiles = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'upload_files');
     $aInputPrivacyUploadFiles['values'] = $aInputPrivacyCustom2;
     $aInputPrivacyUploadFiles['db'] = $aInputPrivacyCustom2Pass;
     $aCustomForm = array('form_attrs' => array('name' => 'form_groups', 'action' => '', 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => 'bx_groups_main', 'key' => 'id', 'uri' => 'uri', 'uri_title' => 'title', 'submit_name' => 'submit_form')), 'inputs' => array('header_info' => array('type' => 'block_header', 'caption' => _t('_bx_groups_form_header_info')), 'title' => array('type' => 'text', 'name' => 'title', 'caption' => _t('_bx_groups_form_caption_title'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 100), 'error' => _t('_bx_groups_form_err_title')), 'db' => array('pass' => 'Xss'), 'display' => true), 'desc' => array('type' => 'textarea', 'name' => 'desc', 'caption' => _t('_bx_groups_form_caption_desc'), 'required' => true, 'html' => 2, 'checker' => array('func' => 'length', 'params' => array(20, 64000), 'error' => _t('_bx_groups_form_err_desc')), 'db' => array('pass' => 'XssHtml')), 'country' => array('type' => 'select', 'name' => 'country', 'caption' => _t('_bx_groups_form_caption_country'), 'values' => $aCountries, 'required' => false, 'db' => array('pass' => 'Preg', 'params' => array('/([a-zA-Z]{2})/')), 'display' => true), 'city' => array('type' => 'text', 'name' => 'city', 'caption' => _t('_bx_groups_form_caption_city'), 'required' => false, 'db' => array('pass' => 'Xss'), 'display' => true), 'zip' => array('type' => 'text', 'name' => 'zip', 'caption' => _t('_bx_groups_form_caption_zip'), 'required' => false, 'db' => array('pass' => 'Xss'), 'display' => true), 'tags' => array('type' => 'text', 'name' => 'tags', 'caption' => _t('_Tags'), 'info' => _t('_sys_tags_note'), 'required' => true, 'checker' => array('func' => 'avail', 'error' => _t('_bx_groups_form_err_tags')), 'db' => array('pass' => 'Tags')), 'categories' => $oCategories->getGroupChooser('bx_groups', (int) $iProfileId, true), 'header_images' => array('type' => 'block_header', 'caption' => _t('_bx_groups_form_header_images'), 'collapsable' => true, 'collapsed' => false), 'thumb' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['thumb_choice'], 'name' => 'thumb', 'caption' => _t('_bx_groups_form_caption_thumb_choice'), 'info' => _t('_bx_groups_form_info_thumb_choice'), 'required' => false, 'db' => array('pass' => 'Int')), 'images_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['choice'], 'name' => 'images_choice[]', 'caption' => _t('_bx_groups_form_caption_images_choice'), 'info' => _t('_bx_groups_form_info_images_choice'), 'required' => false), 'images_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['upload'], 'name' => 'images_upload[]', 'caption' => _t('_bx_groups_form_caption_images_upload'), 'info' => _t('_bx_groups_form_info_images_upload'), 'required' => false), 'header_videos' => array('type' => 'block_header', 'caption' => _t('_bx_groups_form_header_videos'), 'collapsable' => true, 'collapsed' => false), 'videos_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['videos']['choice'], 'name' => 'videos_choice[]', 'caption' => _t('_bx_groups_form_caption_videos_choice'), 'info' => _t('_bx_groups_form_info_videos_choice'), 'required' => false), 'videos_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['videos']['upload'], 'name' => 'videos_upload[]', 'caption' => _t('_bx_groups_form_caption_videos_upload'), 'info' => _t('_bx_groups_form_info_videos_upload'), 'required' => false), 'header_sounds' => array('type' => 'block_header', 'caption' => _t('_bx_groups_form_header_sounds'), 'collapsable' => true, 'collapsed' => false), 'sounds_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['sounds']['choice'], 'name' => 'sounds_choice[]', 'caption' => _t('_bx_groups_form_caption_sounds_choice'), 'info' => _t('_bx_groups_form_info_sounds_choice'), 'required' => false), 'sounds_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['sounds']['upload'], 'name' => 'sounds_upload[]', 'caption' => _t('_bx_groups_form_caption_sounds_upload'), 'info' => _t('_bx_groups_form_info_sounds_upload'), 'required' => false), 'header_files' => array('type' => 'block_header', 'caption' => _t('_bx_groups_form_header_files'), 'collapsable' => true, 'collapsed' => false), 'files_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['files']['choice'], 'name' => 'files_choice[]', 'caption' => _t('_bx_groups_form_caption_files_choice'), 'info' => _t('_bx_groups_form_info_files_choice'), 'required' => false), 'files_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['files']['upload'], 'name' => 'files_upload[]', 'caption' => _t('_bx_groups_form_caption_files_upload'), 'info' => _t('_bx_groups_form_info_files_upload'), 'required' => false), 'header_privacy' => array('type' => 'block_header', 'caption' => _t('_bx_groups_form_header_privacy')), 'allow_view_group_to' => $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'view_group'), 'allow_view_fans_to' => $aInputPrivacyViewFans, 'allow_comment_to' => $aInputPrivacyComment, 'allow_rate_to' => $aInputPrivacyRate, 'allow_post_in_forum_to' => $aInputPrivacyForum, 'allow_join_to' => $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'join'), 'join_confirmation' => array('type' => 'select', 'name' => 'join_confirmation', 'caption' => _t('_bx_groups_form_caption_join_confirmation'), 'info' => _t('_bx_groups_form_info_join_confirmation'), 'values' => array(0 => _t('_bx_groups_form_join_confirmation_disabled'), 1 => _t('_bx_groups_form_join_confirmation_enabled')), 'checker' => array('func' => 'int', 'error' => _t('_bx_groups_form_err_join_confirmation')), 'db' => array('pass' => 'Int')), 'allow_upload_photos_to' => $aInputPrivacyUploadPhotos, 'allow_upload_videos_to' => $aInputPrivacyUploadVideos, 'allow_upload_sounds_to' => $aInputPrivacyUploadSounds, 'allow_upload_files_to' => $aInputPrivacyUploadFiles, 'Submit' => array('type' => 'submit', 'name' => 'submit_form', 'value' => _t('_Submit'), 'colspan' => false)));
     if (!$aCustomForm['inputs']['images_choice']['content']) {
         unset($aCustomForm['inputs']['thumb']);
         unset($aCustomForm['inputs']['images_choice']);
     }
     if (!$aCustomForm['inputs']['videos_choice']['content']) {
         unset($aCustomForm['inputs']['videos_choice']);
     }
     if (!$aCustomForm['inputs']['sounds_choice']['content']) {
         unset($aCustomForm['inputs']['sounds_choice']);
     }
     if (!$aCustomForm['inputs']['files_choice']['content']) {
         unset($aCustomForm['inputs']['files_choice']);
     }
     $this->processMembershipChecksForMediaUploads($aCustomForm['inputs']);
     parent::BxDolFormMedia($aCustomForm);
 }
Пример #3
0
 function BxEventsFormSearch()
 {
     $oProfileFields = new BxDolProfileFields(0);
     $aCountries = $oProfileFields->convertValues4Input('#!Country');
     $aCountries = array_merge(array('' => _t('_bx_events_all_countries')), $aCountries);
     $aCustomForm = array('form_attrs' => array('name' => 'form_search_events', 'action' => '', 'method' => 'get'), 'params' => array('db' => array('submit_name' => 'submit_form'), 'csrf' => array('disable' => true)), 'inputs' => array('Keyword' => array('type' => 'text', 'name' => 'Keyword', 'caption' => _t('_bx_events_caption_keyword'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 100), 'error' => _t('_bx_events_err_keyword')), 'db' => array('pass' => 'Xss')), 'Country' => array('type' => 'select_box', 'name' => 'Country', 'caption' => _t('_bx_events_caption_country'), 'values' => $aCountries, 'required' => true, 'checker' => array('func' => 'preg', 'params' => array('/^[a-zA-Z]{0,2}$/'), 'error' => _t('_bx_events_err_country')), 'db' => array('pass' => 'Preg', 'params' => array('/([a-zA-Z]{0,2})/'))), 'Submit' => array('type' => 'submit', 'name' => 'submit_form', 'value' => _t('_Submit'), 'colspan' => true)));
     parent::BxTemplFormView($aCustomForm);
 }
Пример #4
0
 function getBlockCode_QuickSearch()
 {
     $aProfile = isLogged() ? getProfileInfo() : array();
     // default params for search form
     $aDefaultParams = array('LookingFor' => !empty($aProfile['Sex']) ? $aProfile['Sex'] : 'male', 'Sex' => !empty($aProfile['LookingFor']) ? $aProfile['LookingFor'] : 'female', 'Country' => !empty($aProfile['Country']) ? $aProfile['Country'] : getParam('default_country'), 'DateOfBirth' => getParam('search_start_age') . '-' . getParam('search_end_age'));
     $oPF = new BxDolProfileFields(10);
     return array($oPF->getFormCode(array('default_params' => $aDefaultParams)), array(), array(), false);
 }
Пример #5
0
 function getBlockCode_People()
 {
     global $logged;
     $aProfile = $logged['member'] ? getProfileInfo((int) $_COOKIE['memberID']) : array();
     // default params for search form
     $aDefaultParams = array('LookingFor' => $aProfile['Sex'] ? $aProfile['Sex'] : 'male', 'Sex' => $aProfile['LookingFor'] ? $aProfile['LookingFor'] : 'female', 'Country' => $aProfile['Country'] ? $aProfile['Country'] : getParam('default_country'), 'DateOfBirth' => getParam('search_start_age') . '-' . getParam('search_end_age'));
     bx_import('BxDolProfileFields');
     $oPF = new BxDolProfileFields(9);
     $a = array('default_params' => $aDefaultParams);
     return $oPF->getFormCode($a);
 }
Пример #6
0
 function getBlockCode_People()
 {
     $iMemberId = getLoggedId();
     $aProfile = $iMemberId ? getProfileInfo($iMemberId) : array();
     // default params for search form
     $aDefaultParams = array('LookingFor' => $aProfile['Sex'] ? $aProfile['Sex'] : 'male', 'Sex' => $aProfile['LookingFor'] ? $aProfile['LookingFor'] : 'female', 'Country' => $aProfile['Country'] ? $aProfile['Country'] : getParam('default_country'), 'DateOfBirth' => getParam('search_start_age') . '-' . getParam('search_end_age'));
     bx_import('BxDolProfileFields');
     $oPF = new BxDolProfileFields(9);
     $a = array('default_params' => $aDefaultParams);
     return array($oPF->getFormCode($a), array(), array(), false);
 }
Пример #7
0
 function getCountries($sUser, $sPwd, $sLang)
 {
     $aRet = array();
     if (!($iId = BxDolXMLRPCUtil::checkLogin($sUser, $sPwd))) {
         return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1, "int")), "struct"));
     }
     BxDolXMLRPCUtil::setLanguage($sLang);
     $oProfileFields = new BxDolProfileFields(0);
     $aCountriesList = $oProfileFields->convertValues4Input('#!Country');
     $aCountries = array();
     foreach ($aCountriesList as $sCode => &$sName) {
         $a = array('Name' => new xmlrpcval($sName), 'Code' => new xmlrpcval($sCode));
         $aCountries[] = new xmlrpcval($a, 'struct');
     }
     return new xmlrpcval($aCountries, "array");
 }
Пример #8
0
 function getBlockCode_Description()
 {
     global $oSysTemplate;
     $sName = 'DescriptionMe';
     $oPF = new BxDolProfileFields(2);
     if (!$oPF->aBlocks) {
         return '';
     }
     $aItem = false;
     foreach ($oPF->aBlocks as $aBlock) {
         foreach ($aBlock['Items'] as $a) {
             if ($sName == $a['Name']) {
                 $aItem = $a;
                 break 2;
             }
         }
     }
     $aProfileInfo = getProfileInfo($this->oProfileGen->_iProfileID);
     if (!trim($aProfileInfo[$sName])) {
         return MsgBox(_t('_Empty'));
     }
     return array($aItem ? $oPF->getViewableValue($aItem, $aProfileInfo[$sName]) : htmlspecialchars_adv($aProfileInfo[$sName]));
 }
Пример #9
0
 function getBlockCode_Search()
 {
     global $logged;
     $aProfile = $logged['member'] ? getProfileInfo((int) $_COOKIE['memberID']) : array();
     // default params for search form
     $sCountry = '';
     $mixedCountry = bx_get('Country');
     if ($mixedCountry && is_array($mixedCountry)) {
         $sCountry = process_pass_data($mixedCountry[0], 1);
     } elseif ($mixedCountry && is_string($mixedCountry)) {
         $sCountry = process_pass_data($mixedCountry, 1);
     }
     $sSex = '';
     $mixedSex = bx_get('Sex');
     if ($mixedSex && is_array($mixedSex)) {
         $sSex = array();
         foreach ($mixedSex as $v) {
             $sSex[] = process_pass_data($v, 1);
         }
     } elseif ($mixedSex && is_string($mixedSex)) {
         $sSex = process_pass_data($mixedSex, 1);
     }
     $aDefaultParams = array('LookingFor' => bx_get('LookingFor') ? process_pass_data(bx_get('LookingFor'), 1) : ($aProfile['Sex'] ? $aProfile['Sex'] : 'male'), 'Sex' => $sSex ? $sSex : ($aProfile['LookingFor'] ? $aProfile['LookingFor'] : 'female'), 'Country' => $sCountry ? $sCountry : ($aProfile['Country'] ? $aProfile['Country'] : getParam('default_country')), 'DateOfBirth' => bx_get('DateOfBirth') ? process_pass_data(bx_get('DateOfBirth'), 1) : getParam('search_start_age') . '-' . getParam('search_end_age'), 'Tags' => bx_get('Tags') ? process_pass_data(bx_get('Tags'), 1) : '', 'online_only' => bx_get('online_only') ? process_pass_data(bx_get('online_only'), 1) : '', 'photos_only' => bx_get('photos_only') ? process_pass_data(bx_get('photos_only'), 1) : '');
     bx_import('BxDolProfileFields');
     $oPF = new BxDolProfileFields(9);
     $a = array('default_params' => $aDefaultParams, 'form_attrs' => array('action' => $this->oConfig->getBaseUri()), 'inputs' => array(array('type' => 'hidden', 'name' => 'r', 'value' => $this->oMain->_aModule['uri'])));
     $aVars = array('content' => $oPF->getFormCode($a));
     return $this->oTemplate->parseHtmlByName('search_form_wrapper', $aVars);
 }
Пример #10
0
    /**
     * Generate Form for NewPost/EditPost for Ads
     *
     * @param $iPostID - Post ID
     * @return HTML presentation of data
     */
    function AddNewPostForm($iPostID = 0, $bBox = true)
    {
        bx_import('BxDolProfileFields');
        $this->CheckLogged();
        if ($iPostID == 0) {
            if (!$this->isAllowedAdd()) {
                return $this->_oTemplate->displayAccessDenied();
            }
        } else {
            $aAdUnitInfo = $this->_oDb->getAdInfo($iPostID);
            $iOwnerID = (int) $aAdUnitInfo['OwnerID'];
            if (!$this->isAllowedEdit($iOwnerID)) {
                return $this->_oTemplate->displayAccessDenied();
            }
        }
        $sMsgDeleteImage = '';
        $sNewAdC = _t('_Add Post');
        $sDaysC = _t('_days');
        $iMaxLt = (int) getParam('bx_ads_max_live_days');
        $sMaxedString = _t('_bx_ads_Warn_max_live_days');
        $sAdsAddLink = $this->bUseFriendlyLinks ? 'ads/my_page/add/' : "{$this->sCurrBrowsedFile}?action=my_page&mode=add";
        // Life time values
        $aLifeTimeValues = array();
        for ($i = 5; $i <= $iMaxLt; $i += 5) {
            $aLifeTimeValues[] = array('key' => $i, 'value' => $i);
        }
        // Categories and custom values
        $iCategoryID = (int) bx_get('Classified');
        $iSubCategoryID = (int) bx_get('IDClassifiedsSubs');
        $sCustomValues = $sScriptHandle = '';
        if (false !== bx_get('IDClassifiedsSubs')) {
            $sScriptHandle = <<<EOF
<script type="text/javascript">
    addEvent( window, 'load', function(){ \$('#Classified').val('{$iCategoryID}'); } );
</script>
EOF;
        }
        $sCity = $sCountry = '';
        $aAllowView = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'ads', 'view', array(), _t('_bx_ads_privacy_view'));
        $aAllowRate = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'ads', 'rate', array(), _t('_bx_ads_privacy_rate'));
        $aAllowComment = $this->oPrivacy->getGroupChooser($this->_iVisitorID, 'ads', 'comment', array(), _t('_bx_ads_privacy_comment'));
        if ($iPostID > 0) {
            $sMsgDeleteImage = $this->ActionDeletePicture();
            if ($sMsgDeleteImage) {
                $aAdUnitInfo = $this->_oDb->getAdInfo($iPostID);
            }
            $sAdsAddLink = $this->bUseFriendlyLinks ? 'ads/my_page/edit/' . $iPostID : "{$this->sCurrBrowsedFile}?action=my_page&mode=add&EditPostID={$iPostID}";
            $aAdUnitInfo = is_array($aAdUnitInfo) && count($aAdUnitInfo) > 0 ? $aAdUnitInfo : $this->_oDb->getAdInfo($iPostID);
            $iCategoryID = (int) $aAdUnitInfo['CatID'];
            $iSubCategoryID = (int) $aAdUnitInfo['SubID'];
            $sCity = $aAdUnitInfo['City'];
            $sCountry = $aAdUnitInfo['Country'];
            $sScriptHandle = <<<EOF
<script type="text/javascript">
    addEvent( window, 'load', function(){ \$('#Classified').val('{$iCategoryID}'); } );
    addEvent( window, 'load', function(){ \$('#SubClassified').val('{$iSubCategoryID}'); } );
</script>
EOF;
            $sSubsRows = '';
            $vSubs = $this->_oDb->getSubsNameIDCountAdsByAdID($iCategoryID);
            while ($aSub = mysql_fetch_assoc($vSubs)) {
                $iSubID = (int) $aSub['ID'];
                $iSubName = $aSub['Name'];
                $sSubsRows .= '<option value="' . $iSubID . '">' . $iSubName . '</option>';
            }
            $sFieldSec = $aAdUnitInfo['CustomFieldName2'] ? "{$aAdUnitInfo['CustomFieldName2']} {$aAdUnitInfo['Unit2']} <input type=\"text\" name=\"CustomFieldValue2\" value=\"{$aAdUnitInfo['CustomFieldValue2']}\" size=\"20\" maxlength=\"20\" />" : "";
            $sCustomValues = <<<EOF
{$aAdUnitInfo['CustomFieldName1']} {$aAdUnitInfo['Unit1']} <input type="text" name="CustomFieldValue1" value="{$aAdUnitInfo['CustomFieldValue1']}" size="20" maxlength="20" />
{$sFieldSec}
EOF;
            $sNewAdC = _t('_Save Changes');
            $sMaxedString = _t('_bx_ads_Warn_max_live_days');
        }
        //Main categories
        $vSqlRes = $this->_oDb->getAllCatsInfo();
        if (db_affected_rows() == -1) {
            return _t('_Error Occured');
        }
        $sCatOptions = '';
        while ($aSqlResStr = mysql_fetch_assoc($vSqlRes)) {
            $sCatOptions .= "<option value=\"{$aSqlResStr['ID']}\">{$aSqlResStr['Name']}</option>\n";
        }
        $iSubCatID = (int) bx_get('IDClassifiedsSubs');
        $sExclamationIcon = $GLOBALS['oSysTemplate']->getIconUrl('exclamation.png');
        $aVars = array('sCatOptions' => $sCatOptions, 'sSubsRows' => $sSubsRows, 'sScriptHandle' => $sScriptHandle, 'sCustomValues' => $sCustomValues, 'bx_if:cat_warning' => array('condition' => false !== bx_get('add_button') && !$iSubCatID, 'content' => array()));
        $sCustomCategories = $this->_oTemplate->parseHtmlByName('ads_add_categ_form.html', $aVars);
        $oProfileFields = new BxDolProfileFields(0);
        $aCountries = $oProfileFields->convertValues4Input('#!Country');
        //adding form
        $aForm = array('form_attrs' => array('name' => 'CreateAdsForm', 'action' => $sAdsAddLink, 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => $this->_oConfig->sSQLPostsTable, 'key' => 'ID', 'submit_name' => 'add_button')), 'inputs' => array('CustomCategories' => array('caption' => _t('_Category'), 'type' => 'custom', 'name' => 'CustomCategories', 'content' => $sCustomCategories), 'Subject' => array('type' => 'text', 'name' => 'Subject', 'caption' => _t('_Caption'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 255), 'error' => _t('_bx_ads_Caption_error')), 'db' => array('pass' => 'Xss')), 'LifeTime' => array('type' => 'select', 'name' => 'LifeTime', 'caption' => _t('_bx_ads_Life_Time') . " ({$sDaysC})", 'info' => $sMaxedString, 'value' => $iMaxLt, 'values' => $aLifeTimeValues, 'required' => true, 'checker' => array('func' => 'length', 'params' => array(1, 3), 'error' => _t('_Error Occured')), 'db' => array('pass' => 'Int')), 'Tags' => array('type' => 'text', 'name' => 'Tags', 'caption' => _t('_Tags'), 'info' => _t('_sys_tags_note'), 'required' => false, 'db' => array('pass' => 'Xss')), 'Message' => array('type' => 'textarea', 'name' => 'Message', 'caption' => _t('_bx_ads_post_text'), 'required' => true, 'html' => 2, 'checker' => array('func' => 'length', 'params' => array(3, 65535), 'error' => _t('_bx_ads_Text_error')), 'db' => array('pass' => 'XssHtml')), 'Country' => array('type' => 'select', 'name' => 'Country', 'caption' => _t('_bx_ads_caption_country'), 'values' => $aCountries, 'value' => $sCountry, 'required' => true, 'checker' => array('func' => 'preg', 'params' => array('/^[a-zA-Z]{2}$/'), 'error' => _t('_bx_ads_err_country')), 'db' => array('pass' => 'Preg', 'params' => array('/([a-zA-Z]{2})/'))), 'City' => array('type' => 'text', 'name' => 'City', 'caption' => _t('_bx_ads_caption_city'), 'required' => true, 'value' => $sCity, 'checker' => array('func' => 'length', 'params' => array(3, 50), 'error' => _t('_bx_ads_err_city')), 'db' => array('pass' => 'Xss')), 'File' => array('type' => 'file', 'name' => 'userfile[]', 'caption' => _t('_associated_image'), 'attrs' => array('multiplyable' => 'true')), 'ExistedImages' => array('type' => 'hidden'), 'allowView' => $aAllowView, 'allowRate' => $aAllowRate, 'allowComment' => $aAllowComment, 'add_button' => array('type' => 'submit', 'name' => 'add_button', 'value' => $sNewAdC)));
        $sExistedMedia = '';
        if ($iPostID > 0) {
            $aAdUnitInfo = is_array($aAdUnitInfo) && count($aAdUnitInfo) > 0 ? $aAdUnitInfo : $this->_oDb->getAdInfo($iPostID);
            $sExistedMedia = $aAdUnitInfo['Media'];
            $sSubject = $aAdUnitInfo['Subject'];
            $sMessage = $aAdUnitInfo['Message'];
            $sPostTags = $aAdUnitInfo['Tags'];
            $sPostLifeTime = (int) $aAdUnitInfo['LifeTime'];
            $sPostPictureElements = $sMsgDeleteImage . $this->getImageManagingCode($aAdUnitInfo['Media'], $iPostID);
            if ($sPostPictureElements != '') {
                $aForm['inputs']['ExistedImages']['type'] = 'custom';
                $aForm['inputs']['ExistedImages']['content'] = $sPostPictureElements;
                $aForm['inputs']['ExistedImages']['caption'] = _t('_bx_ads_Existed_images');
            }
            $aForm['inputs']['Subject']['value'] = $sSubject;
            $aForm['inputs']['Message']['value'] = $sMessage;
            $aForm['inputs']['Tags']['value'] = $sPostTags;
            $aForm['inputs']['LifeTime']['value'] = $sPostLifeTime;
            $aForm['inputs']['allowView']['value'] = $aAdUnitInfo['AllowView'];
            $aForm['inputs']['allowRate']['value'] = $aAdUnitInfo['AllowRate'];
            $aForm['inputs']['allowComment']['value'] = $aAdUnitInfo['AllowComment'];
            $aForm['inputs']['hidden_postid'] = array('type' => 'hidden', 'name' => 'EditPostID', 'value' => $iPostID);
        }
        if (empty($aForm['inputs']['allowView']['value']) || !$aForm['inputs']['allowView']['value']) {
            $aForm['inputs']['allowView']['value'] = BX_DOL_PG_ALL;
        }
        if (empty($aForm['inputs']['allowRate']['value']) || !$aForm['inputs']['allowRate']['value']) {
            $aForm['inputs']['allowRate']['value'] = BX_DOL_PG_ALL;
        }
        if (empty($aForm['inputs']['allowComment']['value']) || !$aForm['inputs']['allowComment']['value']) {
            $aForm['inputs']['allowComment']['value'] = BX_DOL_PG_ALL;
        }
        $oForm = new BxTemplFormView($aForm);
        $oForm->initChecker();
        if ($oForm->isSubmittedAndValid() && $iSubCatID) {
            $this->CheckLogged();
            $sCurTime = time();
            $sPostUri = uriGenerate(bx_get('Subject'), $this->_oConfig->sSQLPostsTable, 'EntryUri');
            $sAutoApprovalVal = getParam('bx_ads_auto_approving') == 'on' ? 'active' : 'new';
            $sCustomFieldValue1 = floatval(bx_get('CustomFieldValue1'));
            $sCustomFieldValue2 = floatval(bx_get('CustomFieldValue2'));
            ob_start();
            $sMedIds = $this->parseUploadedFiles();
            $sErrorImageProcessing = ob_get_clean();
            $aValsAdd = array('DateTime' => $sCurTime, 'Status' => $sAutoApprovalVal, 'IDClassifiedsSubs' => $iSubCatID, 'CustomFieldValue1' => $sCustomFieldValue1, 'CustomFieldValue2' => $sCustomFieldValue2);
            if ($sMedIds != '') {
                $sMedIds = $sExistedMedia != '' ? $sExistedMedia . ',' . $sMedIds : $sMedIds;
                $aValsAdd['Media'] = $sMedIds;
            }
            $iLastId = -1;
            if ($iPostID > 0) {
                $oForm->update($iPostID, $aValsAdd);
                $iLastId = $iPostID;
            } else {
                $aValsAdd['EntryUri'] = $sPostUri;
                $aValsAdd['IDProfile'] = $this->_iVisitorID;
                $iLastId = $oForm->insert($aValsAdd);
            }
            if ($iLastId > 0) {
                $iPostID > 0 ? $this->isAllowedEdit($iAdvOwner, true) : $this->isAllowedAdd(true);
                // perform action
                //reparse tags
                bx_import('BxDolTags');
                $oTags = new BxDolTags();
                $oTags->reparseObjTags('ad', $iLastId);
                if (BxDolModule::getInstance('BxWmapModule')) {
                    BxDolService::call('wmap', $iPostID ? 'response_entry_change' : 'response_entry_add', array($this->_oConfig->getUri(), $iLastId ? $iLastId : $iPostID));
                }
                bx_import('BxDolAlerts');
                $sAlertAction = $iPostID ? 'edit' : 'create';
                $oZ = new BxDolAlerts('ads', $sAlertAction, $iLastId, $this->_iVisitorID);
                $oZ->alert();
                $sResult = $iPostID > 0 ? _t('_bx_ads_Ad_succ_updated') : _t('_bx_ads_Ad_succ_added');
                return ($sErrorImageProcessing ? $sErrorImageProcessing : '') . MsgBox($sResult) . (!$iPostID ? '<script>setTimeout(function () { document.location="' . $this->genUrl($iLastId, '', 'entry', true) . '"; } , 1000);</script>' : '');
            } else {
                return MsgBox(_t('_Error Occured'));
            }
        } else {
            $sNewAdFormVal = '<div class="blogs-view bx-def-bc-margin">' . $oForm->getCode() . '</div>';
            return $bBox ? DesignBoxContent(_t('_bx_ads_Add_ad'), $sNewAdFormVal, 1) : $sNewAdFormVal;
        }
    }
Пример #11
0
 function BxEventsFormAdd($oMain, $iProfileId, $iEntryId = 0, $iThumb = 0)
 {
     $this->_oMain = $oMain;
     $this->_oDb = $oMain->_oDb;
     $this->_aMedia = array('images' => array('post' => 'ready_images', 'upload_func' => 'uploadPhotos', 'tag' => BX_EVENTS_PHOTOS_TAG, 'cat' => BX_EVENTS_PHOTOS_CAT, 'thumb' => 'PrimPhoto', 'module' => 'photos', 'title_upload_post' => 'images_titles', 'title_upload' => _t('_bx_events_form_caption_file_title'), 'service_method' => 'get_photo_array'), 'videos' => array('post' => 'ready_videos', 'upload_func' => 'uploadVideos', 'tag' => BX_EVENTS_VIDEOS_TAG, 'cat' => BX_EVENTS_VIDEOS_CAT, 'thumb' => false, 'module' => 'videos', 'title_upload_post' => 'videos_titles', 'title_upload' => _t('_bx_events_form_caption_file_title'), 'service_method' => 'get_video_array'), 'sounds' => array('post' => 'ready_sounds', 'upload_func' => 'uploadSounds', 'tag' => BX_EVENTS_SOUNDS_TAG, 'cat' => BX_EVENTS_SOUNDS_CAT, 'thumb' => false, 'module' => 'sounds', 'title_upload_post' => 'sounds_titles', 'title_upload' => _t('_bx_events_form_caption_file_title'), 'service_method' => 'get_music_array'), 'files' => array('post' => 'ready_files', 'upload_func' => 'uploadFiles', 'tag' => BX_EVENTS_FILES_TAG, 'cat' => BX_EVENTS_FILES_CAT, 'thumb' => false, 'module' => 'files', 'title_upload_post' => 'files_titles', 'title_upload' => _t('_bx_events_form_caption_file_title'), 'service_method' => 'get_file_array'));
     bx_import('BxDolCategories');
     $oCategories = new BxDolCategories();
     $oCategories->getTagObjectConfig();
     $oProfileFields = new BxDolProfileFields(0);
     $aCountries = $oProfileFields->convertValues4Input('#!Country');
     asort($aCountries);
     // generate templates for form custom elements
     $aCustomMediaTemplates = $this->generateCustomMediaTemplates($this->_oMain->_iProfileId, $iEntryId, $iThumb);
     // privacy
     $aInputPrivacyCustom = array();
     $aInputPrivacyCustom[] = array('key' => '', 'value' => '----');
     $aInputPrivacyCustom[] = array('key' => 'p', 'value' => _t('_bx_events_privacy_participants_only'));
     $aInputPrivacyCustomPass = array('pass' => 'Preg', 'params' => array('/^([0-9p]+)$/'));
     $aInputPrivacyCustom2 = array(array('key' => 'p', 'value' => _t('_bx_events_privacy_participants')), array('key' => 'a', 'value' => _t('_bx_events_privacy_admins_only')));
     $aInputPrivacyCustom2Pass = array('pass' => 'Preg', 'params' => array('/^([pa]+)$/'));
     $aInputPrivacyViewParticipants = $GLOBALS['oBxEventsModule']->_oPrivacy->getGroupChooser($iProfileId, 'events', 'view_participants');
     $aInputPrivacyViewParticipants['values'] = array_merge($aInputPrivacyViewParticipants['values'], $aInputPrivacyCustom);
     $aInputPrivacyComment = $GLOBALS['oBxEventsModule']->_oPrivacy->getGroupChooser($iProfileId, 'events', 'comment');
     $aInputPrivacyComment['values'] = array_merge($aInputPrivacyComment['values'], $aInputPrivacyCustom);
     $aInputPrivacyComment['db'] = $aInputPrivacyCustomPass;
     $aInputPrivacyRate = $GLOBALS['oBxEventsModule']->_oPrivacy->getGroupChooser($iProfileId, 'events', 'rate');
     $aInputPrivacyRate['values'] = array_merge($aInputPrivacyRate['values'], $aInputPrivacyCustom);
     $aInputPrivacyRate['db'] = $aInputPrivacyCustomPass;
     $aInputPrivacyForum = $GLOBALS['oBxEventsModule']->_oPrivacy->getGroupChooser($iProfileId, 'events', 'post_in_forum');
     $aInputPrivacyForum['values'] = array_merge($aInputPrivacyForum['values'], $aInputPrivacyCustom);
     $aInputPrivacyForum['db'] = $aInputPrivacyCustomPass;
     $aInputPrivacyUploadPhotos = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'events', 'upload_photos');
     $aInputPrivacyUploadPhotos['values'] = $aInputPrivacyCustom2;
     $aInputPrivacyUploadPhotos['db'] = $aInputPrivacyCustom2Pass;
     $aInputPrivacyUploadVideos = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'events', 'upload_videos');
     $aInputPrivacyUploadVideos['values'] = $aInputPrivacyCustom2;
     $aInputPrivacyUploadVideos['db'] = $aInputPrivacyCustom2Pass;
     $aInputPrivacyUploadSounds = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'events', 'upload_sounds');
     $aInputPrivacyUploadSounds['values'] = $aInputPrivacyCustom2;
     $aInputPrivacyUploadSounds['db'] = $aInputPrivacyCustom2Pass;
     $aInputPrivacyUploadFiles = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'events', 'upload_files');
     $aInputPrivacyUploadFiles['values'] = $aInputPrivacyCustom2;
     $aInputPrivacyUploadFiles['db'] = $aInputPrivacyCustom2Pass;
     $aCustomForm = array('form_attrs' => array('name' => 'form_events', 'action' => '', 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => 'bx_events_main', 'key' => 'ID', 'uri' => 'EntryUri', 'uri_title' => 'Title', 'submit_name' => 'submit_form')), 'inputs' => array('header_info' => array('type' => 'block_header', 'caption' => _t('_bx_events_form_header_info')), 'Title' => array('type' => 'text', 'name' => 'Title', 'caption' => _t('_bx_events_caption_title'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 100), 'error' => _t('_bx_events_err_title')), 'db' => array('pass' => 'Xss'), 'display' => true), 'Description' => array('type' => 'textarea', 'name' => 'Description', 'caption' => _t('_bx_events_caption_desc'), 'required' => true, 'html' => 2, 'checker' => array('func' => 'length', 'params' => array(20, 64000), 'error' => _t('_bx_events_err_desc')), 'db' => array('pass' => 'XssHtml')), 'Country' => array('type' => 'select', 'name' => 'Country', 'caption' => _t('_bx_events_caption_country'), 'values' => $aCountries, 'required' => true, 'checker' => array('func' => 'preg', 'params' => array('/^[a-zA-Z]{2}$/'), 'error' => _t('_bx_events_err_country')), 'db' => array('pass' => 'Preg', 'params' => array('/([a-zA-Z]{2})/'))), 'City' => array('type' => 'text', 'name' => 'City', 'caption' => _t('_bx_events_caption_city'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 50), 'error' => _t('_bx_events_err_city')), 'db' => array('pass' => 'Xss')), 'Place' => array('type' => 'text', 'name' => 'Place', 'caption' => _t('_bx_events_caption_place'), 'required' => true, 'checker' => array('func' => 'avail', 'error' => _t('_bx_events_err_place')), 'db' => array('pass' => 'Xss'), 'display' => true), 'EventStart' => array('type' => 'datetime', 'name' => 'EventStart', 'caption' => _t('_bx_events_caption_event_start'), 'required' => true, 'checker' => array('func' => 'DateTime', 'error' => _t('_bx_events_err_event_start')), 'db' => array('pass' => 'DateTime'), 'display' => 'filterDate'), 'EventEnd' => array('type' => 'datetime', 'name' => 'EventEnd', 'caption' => _t('_bx_events_caption_event_end'), 'required' => true, 'checker' => array('func' => 'DateTime', 'error' => _t('_bx_events_err_event_end')), 'db' => array('pass' => 'DateTime'), 'display' => 'filterDate'), 'Tags' => array('type' => 'text', 'name' => 'Tags', 'caption' => _t('_Tags'), 'info' => _t('_sys_tags_note'), 'required' => true, 'checker' => array('func' => 'avail', 'error' => _t('_bx_events_err_tags')), 'db' => array('pass' => 'Tags')), 'Categories' => $oCategories->getGroupChooser('bx_events', (int) $iProfileId, true), 'header_images' => array('type' => 'block_header', 'caption' => _t('_bx_events_form_header_images'), 'collapsable' => true, 'collapsed' => false), 'PrimPhoto' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['thumb_choice'], 'name' => 'PrimPhoto', 'caption' => _t('_bx_events_form_caption_thumb_choice'), 'info' => _t('_bx_events_form_info_thumb_choice'), 'required' => false, 'db' => array('pass' => 'Int')), 'images_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['choice'], 'name' => 'images_choice[]', 'caption' => _t('_bx_events_form_caption_images_choice'), 'info' => _t('_bx_events_form_info_images_choice'), 'required' => false), 'images_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['upload'], 'name' => 'images_upload[]', 'caption' => _t('_bx_events_form_caption_images_upload'), 'info' => _t('_bx_events_form_info_images_upload'), 'required' => false), 'header_videos' => array('type' => 'block_header', 'caption' => _t('_bx_events_form_header_videos'), 'collapsable' => true, 'collapsed' => false), 'videos_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['videos']['choice'], 'name' => 'videos_choice[]', 'caption' => _t('_bx_events_form_caption_videos_choice'), 'info' => _t('_bx_events_form_info_videos_choice'), 'required' => false), 'videos_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['videos']['upload'], 'name' => 'videos_upload[]', 'caption' => _t('_bx_events_form_caption_videos_upload'), 'info' => _t('_bx_events_form_info_videos_upload'), 'required' => false), 'header_sounds' => array('type' => 'block_header', 'caption' => _t('_bx_events_form_header_sounds'), 'collapsable' => true, 'collapsed' => false), 'sounds_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['sounds']['choice'], 'name' => 'sounds_choice[]', 'caption' => _t('_bx_events_form_caption_sounds_choice'), 'info' => _t('_bx_events_form_info_sounds_choice'), 'required' => false), 'sounds_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['sounds']['upload'], 'name' => 'sounds_upload[]', 'caption' => _t('_bx_events_form_caption_sounds_upload'), 'info' => _t('_bx_events_form_info_sounds_upload'), 'required' => false), 'header_files' => array('type' => 'block_header', 'caption' => _t('_bx_events_form_header_files'), 'collapsable' => true, 'collapsed' => false), 'files_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['files']['choice'], 'name' => 'files_choice[]', 'caption' => _t('_bx_events_form_caption_files_choice'), 'info' => _t('_bx_events_form_info_files_choice'), 'required' => false), 'files_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['files']['upload'], 'name' => 'files_upload[]', 'caption' => _t('_bx_events_form_caption_files_upload'), 'info' => _t('_bx_events_form_info_files_upload'), 'required' => false), 'header_privacy' => array('type' => 'block_header', 'caption' => _t('_bx_events_form_header_privacy')), 'allow_view_event_to' => $GLOBALS['oBxEventsModule']->_oPrivacy->getGroupChooser($iProfileId, 'events', 'view_event'), 'allow_view_participants_to' => $aInputPrivacyViewParticipants, 'allow_comment_to' => $aInputPrivacyComment, 'allow_rate_to' => $aInputPrivacyRate, 'allow_post_in_forum_to' => $aInputPrivacyForum, 'allow_join_to' => $GLOBALS['oBxEventsModule']->_oPrivacy->getGroupChooser($iProfileId, 'events', 'join'), 'JoinConfirmation' => array('type' => 'select', 'name' => 'JoinConfirmation', 'caption' => _t('_bx_events_form_caption_join_confirmation'), 'info' => _t('_bx_events_form_info_join_confirmation'), 'values' => array(0 => _t('_bx_events_form_join_confirmation_disabled'), 1 => _t('_bx_events_form_join_confirmation_enabled')), 'checker' => array('func' => 'int', 'error' => _t('_bx_events_form_err_join_confirmation')), 'db' => array('pass' => 'Int')), 'allow_upload_photos_to' => $aInputPrivacyUploadPhotos, 'allow_upload_videos_to' => $aInputPrivacyUploadVideos, 'allow_upload_sounds_to' => $aInputPrivacyUploadSounds, 'allow_upload_files_to' => $aInputPrivacyUploadFiles));
     if (!$aCustomForm['inputs']['images_choice']['content']) {
         unset($aCustomForm['inputs']['PrimPhoto']);
         unset($aCustomForm['inputs']['images_choice']);
     }
     if (!$aCustomForm['inputs']['videos_choice']['content']) {
         unset($aCustomForm['inputs']['videos_choice']);
     }
     if (!$aCustomForm['inputs']['sounds_choice']['content']) {
         unset($aCustomForm['inputs']['sounds_choice']);
     }
     if (!$aCustomForm['inputs']['files_choice']['content']) {
         unset($aCustomForm['inputs']['files_choice']);
     }
     $aFormInputsAdminPart = array();
     if ($GLOBALS['oBxEventsModule']->isAdmin()) {
         require_once BX_DIRECTORY_PATH_INC . 'membership_levels.inc.php';
         $aMemberships = getMemberships();
         unset($aMemberships[MEMBERSHIP_ID_NON_MEMBER]);
         // unset Non-member
         $aMemberships = array('' => _t('_bx_events_membership_filter_none')) + $aMemberships;
         $aFormInputsAdminPart = array('EventMembershipFilter' => array('type' => 'select', 'name' => 'EventMembershipFilter', 'caption' => _t('_bx_events_caption_membership_filter'), 'info' => _t('_bx_events_info_membership_filter'), 'values' => $aMemberships, 'value' => '', 'checker' => array('func' => 'preg', 'params' => array('/^[0-9a-zA-Z]*$/'), 'error' => _t('_bx_events_err_membership_filter')), 'db' => array('pass' => 'Preg', 'params' => array('/([0-9a-zA-Z]*)/'))));
     }
     $aFormInputsSubmit = array('Submit' => array('type' => 'submit', 'name' => 'submit_form', 'value' => _t('_Submit'), 'colspan' => true));
     $aCustomForm['inputs'] = array_merge($aCustomForm['inputs'], $aFormInputsAdminPart, $aFormInputsSubmit);
     $this->processMembershipChecksForMediaUploads($aCustomForm['inputs']);
     parent::BxDolFormMedia($aCustomForm);
 }
Пример #12
0
 function getFormJoin($aParams)
 {
     $aForm = parent::getFormJoin($aParams);
     $aForm['form_attrs']['action'] = BX_DOL_URL_ROOT . $this->_oMain->_oConfig->getBaseUri() . 'join';
     return $aForm;
 }
Пример #13
0
 function BxStoreFormAdd($oMain, $iProfileId, $isRemovePhotoFieldAllowed = true, $iEntryId = 0, $iThumb = 0)
 {
     $this->_aMedia = array();
     if (BxDolRequest::serviceExists('photos', 'perform_photo_upload', 'Uploader')) {
         $this->_aMedia['images'] = array('post' => 'ready_images', 'upload_func' => 'uploadPhotos', 'tag' => BX_STORE_PHOTOS_TAG, 'cat' => BX_STORE_PHOTOS_CAT, 'thumb' => 'thumb', 'module' => 'photos', 'title_upload_post' => 'images_titles', 'title_upload' => _t('_bx_store_form_caption_file_title'), 'service_method' => 'get_photo_array');
     }
     if (BxDolRequest::serviceExists('videos', 'perform_video_upload', 'Uploader')) {
         $this->_aMedia['videos'] = array('post' => 'ready_videos', 'upload_func' => 'uploadVideos', 'tag' => BX_STORE_VIDEOS_TAG, 'cat' => BX_STORE_VIDEOS_CAT, 'thumb' => false, 'module' => 'videos', 'title_upload' => _t('_bx_store_form_caption_file_title'), 'service_method' => 'get_video_array');
     }
     $this->_oMain = $oMain;
     $this->_oDb = $oMain->_oDb;
     bx_import('BxDolCategories');
     $oCategories = new BxDolCategories();
     $oCategories->getTagObjectConfig();
     $oProfileFields = new BxDolProfileFields(0);
     $aCountries = $oProfileFields->convertValues4Input('#!Country');
     asort($aCountries);
     // generate templates for form custom elements
     $aCustomMediaTemplates = $this->generateCustomMediaTemplates($iProfileId, $iEntryId, $iThumb);
     // files
     $aFilesChoiceOrig = $this->_getFilesInEntry('files', 'get_file_array', 'ready_files', 'files', (int) $iProfileId, $iEntryId);
     $aFilesChoice = array();
     $sCurrencySign = getParam('pmt_default_currency_sign');
     foreach ($aFilesChoiceOrig as $k => $r) {
         if (!$r['checked']) {
             continue;
         }
         $a = $GLOBALS['oBxStoreModule']->_oDb->getFileInfo($iEntryId, $r['id']);
         $r['file_id'] = $a['id'];
         $r['title'] .= ' - ' . $sCurrencySign . ' ' . $a['price'] . ' (' . $GLOBALS['oBxStoreModule']->getGroupName($a['allow_purchase_to']) . ')';
         $r['visibility'] = $a['hidden'] ? _t('_bx_store_product_file_hidden') : _t('_bx_store_product_file_visible');
         $aFilesChoice[] = $r;
     }
     $aVarsFilesChoice = array('bx_store_base_url' => $this->_oMain->_oConfig->getBaseUri(), 'bx_if:empty' => array('condition' => empty($aFilesChoice), 'content' => array()), 'bx_repeat:files' => $aFilesChoice);
     $aInputPrivacyPurchase = $GLOBALS['oBxStoreModule']->_oPrivacyProduct->getGroupChooser($iProfileId, 'store', 'purchase');
     foreach ($aInputPrivacyPurchase['values'] as $k => $r) {
         if ($r['key'] == BX_DOL_PG_ALL) {
             unset($aInputPrivacyPurchase['values'][$k]);
             break;
         }
     }
     require_once BX_DIRECTORY_PATH_INC . 'membership_levels.inc.php';
     $aMemberships = getMemberships();
     unset($aMemberships[MEMBERSHIP_ID_NON_MEMBER]);
     // unset Non-member
     unset($aMemberships[MEMBERSHIP_ID_STANDARD]);
     // unset member
     $aMemberships = array('' => '----') + $aMemberships;
     $aMembershipsValues = array();
     foreach ($aMemberships as $k => $v) {
         $aMembershipsValues[] = array('key' => $k ? 'm' . $k : $k, 'value' => $v);
     }
     $aInputPrivacyPurchase['values'] = array_merge($aInputPrivacyPurchase['values'], $aMembershipsValues);
     /*
            if (empty($aInputPrivacyPurchase['value']) || !$aInputPrivacyPurchase['value'])
                $aInputPrivacyPurchase['value'] = BX_DOL_PG_MEMBERS;
     */
     $sInputPrivacyPurchase = str_replace('name="allow_purchase_to"', 'name="allow_purchase_to[]"', $this->genInputSelect($aInputPrivacyPurchase));
     $aVarsFilesUpload = array('file' => 'files', 'title' => 'files_titles', 'file_upload_title' => _t('_bx_store_form_caption_file_title'), 'bx_if:price' => array('condition' => true, 'content' => array('price' => 'files_prices', 'file_price_title' => _t('_bx_store_form_caption_file_price'))), 'bx_if:privacy' => array('condition' => true, 'content' => array('select' => $sInputPrivacyPurchase, 'file_permission_title' => _t('_bx_store_form_caption_file_allow_purcase_to'))));
     // privacy
     $aInputPrivacyCustom = array();
     $aInputPrivacyCustom[] = array('key' => '', 'value' => '----');
     $aInputPrivacyCustom[] = array('key' => 'c', 'value' => _t('_bx_store_privacy_customers_only'));
     $aInputPrivacyPostInForum = $GLOBALS['oBxStoreModule']->_oPrivacyProduct->getGroupChooser($iProfileId, 'store', 'post_in_forum');
     $aInputPrivacyPostInForum['values'] = array_merge($aInputPrivacyPostInForum['values'], $aInputPrivacyCustom);
     $aInputPrivacyPostInForum['db'] = array('pass' => 'Preg', 'params' => array('/^([0-9c]+)$/'));
     $aCustomForm = array('form_attrs' => array('name' => 'form_store', 'action' => '', 'method' => 'post', 'enctype' => 'multipart/form-data'), 'params' => array('db' => array('table' => 'bx_store_products', 'key' => 'id', 'uri' => 'uri', 'uri_title' => 'title', 'submit_name' => 'submit_form')), 'inputs' => array('header_info' => array('type' => 'block_header', 'caption' => _t('_bx_store_form_header_info')), 'title' => array('type' => 'text', 'name' => 'title', 'caption' => _t('_bx_store_form_caption_title'), 'required' => true, 'checker' => array('func' => 'length', 'params' => array(3, 100), 'error' => _t('_bx_store_form_err_title')), 'db' => array('pass' => 'Xss')), 'desc' => array('type' => 'textarea', 'name' => 'desc', 'caption' => _t('_bx_store_form_caption_desc'), 'required' => true, 'html' => 2, 'checker' => array('func' => 'length', 'params' => array(20, 64000), 'error' => _t('_bx_store_form_err_desc')), 'db' => array('pass' => 'XssHtml')), 'tags' => array('type' => 'text', 'name' => 'tags', 'caption' => _t('_Tags'), 'info' => _t('_sys_tags_note'), 'required' => true, 'checker' => array('func' => 'avail', 'error' => _t('_bx_store_form_err_tags')), 'db' => array('pass' => 'Tags')), 'categories' => $oCategories->getGroupChooser('bx_store', (int) $iProfileId, true), 'header_images' => array('type' => 'block_header', 'caption' => _t('_bx_store_form_header_images'), 'collapsable' => true, 'collapsed' => false), 'thumb' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['thumb_choice'], 'name' => 'thumb', 'caption' => _t('_bx_store_form_caption_thumb_choice'), 'info' => _t('_bx_store_form_info_thumb_choice'), 'required' => false, 'db' => array('pass' => 'Int')), 'images_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['choice'], 'name' => 'images_choice[]', 'caption' => _t('_bx_store_form_caption_images_choice'), 'info' => _t('_bx_store_form_info_images_choice'), 'required' => false), 'images_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['images']['upload'], 'name' => 'images_upload[]', 'caption' => _t('_bx_store_form_caption_images_upload'), 'info' => _t('_bx_store_form_info_images_upload'), 'required' => false), 'header_videos' => array('type' => 'block_header', 'caption' => _t('_bx_store_form_header_videos'), 'collapsable' => true, 'collapsed' => false), 'videos_choice' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['videos']['choice'], 'name' => 'videos_choice[]', 'caption' => _t('_bx_store_form_caption_videos_choice'), 'info' => _t('_bx_store_form_info_videos_choice'), 'required' => false), 'videos_upload' => array('type' => 'custom', 'content' => $aCustomMediaTemplates['videos']['upload'], 'name' => 'videos_upload[]', 'caption' => _t('_bx_store_form_caption_videos_upload'), 'info' => _t('_bx_store_form_info_videos_upload'), 'required' => false), 'header_files' => array('type' => 'block_header', 'caption' => _t('_bx_store_form_header_files'), 'collapsable' => true, 'collapsed' => false), 'files_choice' => array('type' => 'custom', 'content' => $aFilesChoice ? $GLOBALS['oBxStoreModule']->_oTemplate->parseHtmlByName('form_field_product_files_choice', $aVarsFilesChoice) : '', 'name' => 'files_choice[]', 'caption' => _t('_bx_store_form_caption_files_choice'), 'info' => _t('_bx_store_form_info_files_choice'), 'required' => false), 'files_upload' => array('type' => 'custom', 'content' => $GLOBALS['oBxStoreModule']->_oTemplate->parseHtmlByName('form_field_files_upload', $aVarsFilesUpload), 'name' => 'files_upload[]', 'caption' => _t('_bx_store_form_caption_files_upload'), 'info' => _t('_bx_store_form_info_files_upload'), 'required' => false), 'header_privacy' => array('type' => 'block_header', 'caption' => _t('_bx_store_form_header_privacy')), 'allow_view_product_to' => $GLOBALS['oBxStoreModule']->_oPrivacyProduct->getGroupChooser($iProfileId, 'store', 'view_product'), 'allow_post_in_forum_to' => $aInputPrivacyPostInForum));
     if (!$aCustomForm['inputs']['images_choice']['content']) {
         unset($aCustomForm['inputs']['thumb']);
         unset($aCustomForm['inputs']['images_choice']);
     }
     if (!$aCustomForm['inputs']['videos_choice']['content']) {
         unset($aCustomForm['inputs']['videos_choice']);
     }
     if (!$aFilesChoice) {
         unset($aCustomForm['inputs']['files_choice']);
     }
     if (!isset($this->_aMedia['images'])) {
         unset($aCustomForm['inputs']['header_images']);
         unset($aCustomForm['inputs']['PrimPhoto']);
         unset($aCustomForm['inputs']['images_choice']);
         unset($aCustomForm['inputs']['images_upload']);
         unset($aCustomForm['inputs']['allow_upload_photos_to']);
     }
     if (!isset($this->_aMedia['videos'])) {
         unset($aCustomForm['inputs']['header_videos']);
         unset($aCustomForm['inputs']['videos_choice']);
         unset($aCustomForm['inputs']['videos_upload']);
         unset($aCustomForm['inputs']['allow_upload_videos_to']);
     }
     $aFormInputsSubmit = array('Submit' => array('type' => 'submit', 'name' => 'submit_form', 'value' => _t('_Submit')));
     $aCustomForm['inputs'] = array_merge($aCustomForm['inputs'], $aFormInputsSubmit);
     $this->processMembershipChecksForMediaUploads($aCustomForm['inputs']);
     parent::BxDolFormMedia($aCustomForm);
 }
Пример #14
0
switch ($_REQUEST['search_mode']) {
    case 'quick':
        $iPFArea = 10;
        $_page['header_text'] = $sPageHeader = _t('_Quick Search');
        break;
    case 'adv':
        $iPFArea = 11;
        $_page['header_text'] = $sPageHeader = _t('_Advanced Search');
        break;
    default:
        $iPFArea = 9;
        $sSearchMode = 'simple';
        $_page['header_text'] = $sPageHeader = _t('_Simple Search');
}
//collect inputs
$oPF = new BxDolProfileFields($iPFArea);
$aRequestParams = $oPF->collectSearchRequestParams();
if (isset($_REQUEST['ID']) and (int) $_REQUEST['ID']) {
    $aRequestParams['ID'] = (int) $_REQUEST['ID'];
}
if (isset($_REQUEST['NickName']) and trim($_REQUEST['NickName'])) {
    $aRequestParams['NickName'] = trim(process_pass_data($_REQUEST['NickName']));
}
if (isset($_REQUEST['Tags']) and trim($_REQUEST['Tags'])) {
    $aRequestParams['Tags'] = trim(process_pass_data($_REQUEST['Tags']));
}
if (isset($_REQUEST['distance']) and (int) $_REQUEST['distance']) {
    $aRequestParams['distance'] = (int) $_REQUEST['distance'];
}
// start page generation
ob_start();
Пример #15
0
 function _getProfilesByFilter($sFilter)
 {
     $aGetParams = unserialize(base64_decode(str_replace('-slash-', '/', $sFilter)));
     if ($aGetParams && is_array($aGetParams)) {
         $aGetParams = $_REQUEST = $_GET = array_merge($_REQUEST, $aGetParams);
     }
     bx_import('BxDolProfileFields');
     $oPF = new BxDolProfileFields(9);
     $aRequestParams = $oPF->collectSearchRequestParams();
     bx_import('BxTemplProfileView');
     $oProfileGenerator = new BxBaseProfileGenerator(getLoggedId());
     list($aWhere, $sJoin, $sPossibleOrder) = $oProfileGenerator->GenSqlConditions($oPF->aBlocks, $aRequestParams);
     $iPage = isset($aGetParams['page']) && (int) $aGetParams['page'] > 0 ? (int) $aGetParams['page'] : 1;
     $iPerPage = isset($aGetParams['per_page']) && (int) $aGetParams['per_page'] > 0 ? (int) $aGetParams['per_page'] : getParam('bx_map_per_page');
     $iStart = ($iPage - 1) * $iPerPage;
     $sQuery = 'SELECT DISTINCT `Profiles`.`ID`, `Profiles`.`Avatar`, `Profiles`.`NickName`, `m`.`id`, `m`.`lat`, `m`.`lng`
         FROM `Profiles` 
         INNER JOIN `' . $this->_oDb->_sPrefix . 'profiles` AS `m` ON (`Profiles`.`ID` = `m`.`id`) 
         ' . $sJoin . ' 
         WHERE ' . implode(' AND ', $aWhere) . ' AND `m`.`failed` = 0 ' . $sPossibleOrder . " \n            LIMIT {$iStart}, {$iPerPage}";
     // ID is ambiguous
     $sQuery = str_replace(' `ID`', ' `Profiles`.`ID`', $sQuery);
     $aProfiles = $GLOBALS['MySQL']->getAll($sQuery);
     return $aProfiles;
 }