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);
 }
 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);
 }
 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();
     // 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]+)$/'));
     $aInputPrivacyViewForum = $GLOBALS['oBxStoreModule']->_oPrivacyProduct->getGroupChooser($iProfileId, 'store', 'view_forum');
     $aInputPrivacyViewForum['values'] = array_merge($aInputPrivacyViewForum['values'], $aInputPrivacyCustom);
     $aInputPrivacyViewForum['db'] = $aInputPrivacyPostInForum['db'];
     $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, 'allow_view_forum_to' => $aInputPrivacyViewForum));
     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);
 }