Cheetah
ChGroupsFormAdd.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import ('ChWsbProfileFields');
9 ch_import ('ChWsbFormMedia');
10 
12 {
13  var $_oMain, $_oDb;
14 
15  function __construct ($oMain, $iProfileId, $iEntryId = 0, $iThumb = 0)
16  {
17  $this->_oMain = $oMain;
18  $this->_oDb = $oMain->_oDb;
19 
20  $this->_aMedia = array ();
21  if (ChWsbRequest::serviceExists('photos', 'perform_photo_upload', 'Uploader'))
22  $this->_aMedia['images'] = array (
23  'post' => 'ready_images',
24  'upload_func' => 'uploadPhotos',
25  'tag' => CH_GROUPS_PHOTOS_TAG,
26  'cat' => CH_GROUPS_PHOTOS_CAT,
27  'thumb' => 'thumb',
28  'module' => 'photos',
29  'title_upload_post' => 'images_titles',
30  'title_upload' => _t('_ch_groups_form_caption_file_title'),
31  'service_method' => 'get_photo_array',
32  );
33 
34  if (ChWsbRequest::serviceExists('videos', 'perform_video_upload', 'Uploader'))
35  $this->_aMedia['videos'] = array (
36  'post' => 'ready_videos',
37  'upload_func' => 'uploadVideos',
38  'tag' => CH_GROUPS_VIDEOS_TAG,
39  'cat' => CH_GROUPS_VIDEOS_CAT,
40  'thumb' => false,
41  'module' => 'videos',
42  'title_upload_post' => 'videos_titles',
43  'title_upload' => _t('_ch_groups_form_caption_file_title'),
44  'service_method' => 'get_video_array',
45  );
46 
47  if (ChWsbRequest::serviceExists('sounds', 'perform_music_upload', 'Uploader'))
48  $this->_aMedia['sounds'] = array (
49  'post' => 'ready_sounds',
50  'upload_func' => 'uploadSounds',
51  'tag' => CH_GROUPS_SOUNDS_TAG,
52  'cat' => CH_GROUPS_SOUNDS_CAT,
53  'thumb' => false,
54  'module' => 'sounds',
55  'title_upload_post' => 'sounds_titles',
56  'title_upload' => _t('_ch_groups_form_caption_file_title'),
57  'service_method' => 'get_music_array',
58  );
59 
60  if (ChWsbRequest::serviceExists('files', 'perform_file_upload', 'Uploader'))
61  $this->_aMedia['files'] = array (
62  'post' => 'ready_files',
63  'upload_func' => 'uploadFiles',
64  'tag' => CH_GROUPS_FILES_TAG,
65  'cat' => CH_GROUPS_FILES_CAT,
66  'thumb' => false,
67  'module' => 'files',
68  'title_upload_post' => 'files_titles',
69  'title_upload' => _t('_ch_groups_form_caption_file_title'),
70  'service_method' => 'get_file_array',
71  );
72 
73  ch_import('ChWsbCategories');
74  $oCategories = new ChWsbCategories();
75 
76  $oProfileFields = new ChWsbProfileFields(0);
77  $aCountries = $oProfileFields->convertValues4Input('#!Country');
78 
79  // generate templates for custom form's elements
80  $aCustomMediaTemplates = $this->generateCustomMediaTemplates ($oMain->_iProfileId, $iEntryId, $iThumb);
81 
82  // privacy
83 
84  $aInputPrivacyCustom = array ();
85  $aInputPrivacyCustom[] = array ('key' => '', 'value' => '----');
86  $aInputPrivacyCustom[] = array ('key' => 'f', 'value' => _t('_ch_groups_privacy_fans_only'));
87  $aInputPrivacyCustomPass = array (
88  'pass' => 'Preg',
89  'params' => array('/^([0-9f]+)$/'),
90  );
91 
92  $aInputPrivacyCustom2 = array (
93  array('key' => 'f', 'value' => _t('_ch_groups_privacy_fans')),
94  array('key' => 'a', 'value' => _t('_ch_groups_privacy_admins_only'))
95  );
96  $aInputPrivacyCustom2Pass = array (
97  'pass' => 'Preg',
98  'params' => array('/^([fa]+)$/'),
99  );
100 
101  $aInputPrivacyViewFans = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'view_fans');
102  $aInputPrivacyViewFans['values'] = array_merge($aInputPrivacyViewFans['values'], $aInputPrivacyCustom);
103  $aInputPrivacyViewFans['db'] = $aInputPrivacyCustomPass;
104 
105  $aInputPrivacyComment = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'comment');
106  $aInputPrivacyComment['values'] = array_merge($aInputPrivacyComment['values'], $aInputPrivacyCustom);
107  $aInputPrivacyComment['db'] = $aInputPrivacyCustomPass;
108 
109  $aInputPrivacyRate = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'rate');
110  $aInputPrivacyRate['values'] = array_merge($aInputPrivacyRate['values'], $aInputPrivacyCustom);
111  $aInputPrivacyRate['db'] = $aInputPrivacyCustomPass;
112 
113  $aInputPrivacyForum = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'post_in_forum');
114  $aInputPrivacyForum['values'] = array_merge($aInputPrivacyForum['values'], $aInputPrivacyCustom);
115  $aInputPrivacyForum['db'] = $aInputPrivacyCustomPass;
116 
117  $aInputPrivacyForumView = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'view_forum');
118  $aInputPrivacyForumView['values'] = array_merge($aInputPrivacyForumView['values'], $aInputPrivacyCustom);
119  $aInputPrivacyForumView['db'] = $aInputPrivacyCustomPass;
120 
121  $aInputPrivacyUploadPhotos = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'upload_photos');
122  $aInputPrivacyUploadPhotos['values'] = $aInputPrivacyCustom2;
123  $aInputPrivacyUploadPhotos['db'] = $aInputPrivacyCustom2Pass;
124 
125  $aInputPrivacyUploadVideos = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'upload_videos');
126  $aInputPrivacyUploadVideos['values'] = $aInputPrivacyCustom2;
127  $aInputPrivacyUploadVideos['db'] = $aInputPrivacyCustom2Pass;
128 
129  $aInputPrivacyUploadSounds = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'upload_sounds');
130  $aInputPrivacyUploadSounds['values'] = $aInputPrivacyCustom2;
131  $aInputPrivacyUploadSounds['db'] = $aInputPrivacyCustom2Pass;
132 
133  $aInputPrivacyUploadFiles = $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'upload_files');
134  $aInputPrivacyUploadFiles['values'] = $aInputPrivacyCustom2;
135  $aInputPrivacyUploadFiles['db'] = $aInputPrivacyCustom2Pass;
136 
137  $aCustomForm = array(
138 
139  'form_attrs' => array(
140  'name' => 'form_groups',
141  'action' => '',
142  'method' => 'post',
143  'enctype' => 'multipart/form-data',
144  ),
145 
146  'params' => array (
147  'db' => array(
148  'table' => 'ch_groups_main',
149  'key' => 'id',
150  'uri' => 'uri',
151  'uri_title' => 'title',
152  'submit_name' => 'submit_form',
153  ),
154  ),
155 
156  'inputs' => array(
157 
158  'header_info' => array(
159  'type' => 'block_header',
160  'caption' => _t('_ch_groups_form_header_info')
161  ),
162 
163  'title' => array(
164  'type' => 'text',
165  'name' => 'title',
166  'caption' => _t('_ch_groups_form_caption_title'),
167  'required' => true,
168  'checker' => array (
169  'func' => 'length',
170  'params' => array(3,100),
171  'error' => _t ('_ch_groups_form_err_title'),
172  ),
173  'db' => array (
174  'pass' => 'Xss',
175  ),
176  ),
177  'desc' => array(
178  'type' => 'textarea',
179  'name' => 'desc',
180  'caption' => _t('_ch_groups_form_caption_desc'),
181  'required' => true,
182  'html' => 2,
183  'checker' => array (
184  'func' => 'length',
185  'params' => array(20,64000),
186  'error' => _t ('_ch_groups_form_err_desc'),
187  ),
188  'db' => array (
189  'pass' => 'XssHtml',
190  ),
191  ),
192  'country' => array(
193  'type' => 'select',
194  'name' => 'country',
195  'caption' => _t('_ch_groups_form_caption_country'),
196  'values' => $aCountries,
197  'required' => false,
198  'db' => array (
199  'pass' => 'Preg',
200  'params' => array('/([a-zA-Z]{2})/'),
201  ),
202  ),
203  'city' => array(
204  'type' => 'text',
205  'name' => 'city',
206  'caption' => _t('_ch_groups_form_caption_city'),
207  'required' => false,
208  'db' => array (
209  'pass' => 'Xss',
210  ),
211  ),
212  'zip' => array(
213  'type' => 'text',
214  'name' => 'zip',
215  'caption' => _t('_ch_groups_form_caption_zip'),
216  'required' => false,
217  'db' => array (
218  'pass' => 'Xss',
219  ),
220  'display' => true,
221  ),
222  'tags' => array(
223  'type' => 'text',
224  'name' => 'tags',
225  'caption' => _t('_Tags'),
226  'info' => _t('_sys_tags_note'),
227  'required' => true,
228  'checker' => array (
229  'func' => 'avail',
230  'error' => _t ('_ch_groups_form_err_tags'),
231  ),
232  'db' => array (
233  'pass' => 'Tags',
234  ),
235  ),
236 
237  'categories' => $oCategories->getGroupChooser ('ch_groups', (int)$iProfileId, true),
238 
239  // images
240 
241  'header_images' => array(
242  'type' => 'block_header',
243  'caption' => _t('_ch_groups_form_header_images'),
244  'collapsable' => true,
245  'collapsed' => false,
246  ),
247  'thumb' => array(
248  'type' => 'custom',
249  'content' => $aCustomMediaTemplates['images']['thumb_choice'],
250  'name' => 'thumb',
251  'caption' => _t('_ch_groups_form_caption_thumb_choice'),
252  'info' => _t('_ch_groups_form_info_thumb_choice'),
253  'required' => false,
254  'db' => array (
255  'pass' => 'Int',
256  ),
257  ),
258  'images_choice' => array(
259  'type' => 'custom',
260  'content' => $aCustomMediaTemplates['images']['choice'],
261  'name' => 'images_choice[]',
262  'caption' => _t('_ch_groups_form_caption_images_choice'),
263  'info' => _t('_ch_groups_form_info_images_choice'),
264  'required' => false,
265  ),
266  'images_upload' => array(
267  'type' => 'custom',
268  'content' => $aCustomMediaTemplates['images']['upload'],
269  'name' => 'images_upload[]',
270  'caption' => _t('_ch_groups_form_caption_images_upload'),
271  'info' => _t('_ch_groups_form_info_images_upload'),
272  'required' => false,
273  ),
274 
275  // videos
276 
277  'header_videos' => array(
278  'type' => 'block_header',
279  'caption' => _t('_ch_groups_form_header_videos'),
280  'collapsable' => true,
281  'collapsed' => false,
282  ),
283  'videos_choice' => array(
284  'type' => 'custom',
285  'content' => $aCustomMediaTemplates['videos']['choice'],
286  'name' => 'videos_choice[]',
287  'caption' => _t('_ch_groups_form_caption_videos_choice'),
288  'info' => _t('_ch_groups_form_info_videos_choice'),
289  'required' => false,
290  ),
291  'videos_upload' => array(
292  'type' => 'custom',
293  'content' => $aCustomMediaTemplates['videos']['upload'],
294  'name' => 'videos_upload[]',
295  'caption' => _t('_ch_groups_form_caption_videos_upload'),
296  'info' => _t('_ch_groups_form_info_videos_upload'),
297  'required' => false,
298  ),
299 
300  // sounds
301 
302  'header_sounds' => array(
303  'type' => 'block_header',
304  'caption' => _t('_ch_groups_form_header_sounds'),
305  'collapsable' => true,
306  'collapsed' => false,
307  ),
308  'sounds_choice' => array(
309  'type' => 'custom',
310  'content' => $aCustomMediaTemplates['sounds']['choice'],
311  'name' => 'sounds_choice[]',
312  'caption' => _t('_ch_groups_form_caption_sounds_choice'),
313  'info' => _t('_ch_groups_form_info_sounds_choice'),
314  'required' => false,
315  ),
316  'sounds_upload' => array(
317  'type' => 'custom',
318  'content' => $aCustomMediaTemplates['sounds']['upload'],
319  'name' => 'sounds_upload[]',
320  'caption' => _t('_ch_groups_form_caption_sounds_upload'),
321  'info' => _t('_ch_groups_form_info_sounds_upload'),
322  'required' => false,
323  ),
324 
325  // files
326 
327  'header_files' => array(
328  'type' => 'block_header',
329  'caption' => _t('_ch_groups_form_header_files'),
330  'collapsable' => true,
331  'collapsed' => false,
332  ),
333  'files_choice' => array(
334  'type' => 'custom',
335  'content' => $aCustomMediaTemplates['files']['choice'],
336  'name' => 'files_choice[]',
337  'caption' => _t('_ch_groups_form_caption_files_choice'),
338  'info' => _t('_ch_groups_form_info_files_choice'),
339  'required' => false,
340  ),
341  'files_upload' => array(
342  'type' => 'custom',
343  'content' => $aCustomMediaTemplates['files']['upload'],
344  'name' => 'files_upload[]',
345  'caption' => _t('_ch_groups_form_caption_files_upload'),
346  'info' => _t('_ch_groups_form_info_files_upload'),
347  'required' => false,
348  ),
349 
350  // privacy
351 
352  'header_privacy' => array(
353  'type' => 'block_header',
354  'caption' => _t('_ch_groups_form_header_privacy'),
355  ),
356 
357  'allow_view_group_to' => $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'view_group'),
358 
359  'allow_view_fans_to' => $aInputPrivacyViewFans,
360 
361  'allow_comment_to' => $aInputPrivacyComment,
362 
363  'allow_rate_to' => $aInputPrivacyRate,
364 
365  'allow_post_in_forum_to' => $aInputPrivacyForum,
366 
367  'allow_view_forum_to' => $aInputPrivacyForumView,
368 
369  'allow_join_to' => $this->_oMain->_oPrivacy->getGroupChooser($iProfileId, 'groups', 'join'),
370 
371  'join_confirmation' => array (
372  'type' => 'select',
373  'name' => 'join_confirmation',
374  'caption' => _t('_ch_groups_form_caption_join_confirmation'),
375  'info' => _t('_ch_groups_form_info_join_confirmation'),
376  'values' => array(
377  0 => _t('_ch_groups_form_join_confirmation_disabled'),
378  1 => _t('_ch_groups_form_join_confirmation_enabled'),
379  ),
380  'checker' => array (
381  'func' => 'int',
382  'error' => _t ('_ch_groups_form_err_join_confirmation'),
383  ),
384  'db' => array (
385  'pass' => 'Int',
386  ),
387  ),
388 
389  'allow_upload_photos_to' => $aInputPrivacyUploadPhotos,
390 
391  'allow_upload_videos_to' => $aInputPrivacyUploadVideos,
392 
393  'allow_upload_sounds_to' => $aInputPrivacyUploadSounds,
394 
395  'allow_upload_files_to' => $aInputPrivacyUploadFiles,
396 
397  'Submit' => array (
398  'type' => 'submit',
399  'name' => 'submit_form',
400  'value' => _t('_Submit'),
401  'colspan' => false,
402  ),
403  ),
404  );
405 
406  if (!$aCustomForm['inputs']['images_choice']['content']) {
407  unset ($aCustomForm['inputs']['thumb']);
408  unset ($aCustomForm['inputs']['images_choice']);
409  }
410 
411  if (!$aCustomForm['inputs']['videos_choice']['content'])
412  unset ($aCustomForm['inputs']['videos_choice']);
413 
414  if (!$aCustomForm['inputs']['sounds_choice']['content'])
415  unset ($aCustomForm['inputs']['sounds_choice']);
416 
417  if (!$aCustomForm['inputs']['files_choice']['content'])
418  unset ($aCustomForm['inputs']['files_choice']);
419 
420  if (!isset($this->_aMedia['images'])) {
421  unset ($aCustomForm['inputs']['header_images']);
422  unset ($aCustomForm['inputs']['thumb']);
423  unset ($aCustomForm['inputs']['images_choice']);
424  unset ($aCustomForm['inputs']['images_upload']);
425  unset ($aCustomForm['inputs']['allow_upload_photos_to']);
426  }
427 
428  if (!isset($this->_aMedia['videos'])) {
429  unset ($aCustomForm['inputs']['header_videos']);
430  unset ($aCustomForm['inputs']['videos_choice']);
431  unset ($aCustomForm['inputs']['videos_upload']);
432  unset ($aCustomForm['inputs']['allow_upload_videos_to']);
433  }
434 
435  if (!isset($this->_aMedia['sounds'])) {
436  unset ($aCustomForm['inputs']['header_sounds']);
437  unset ($aCustomForm['inputs']['sounds_choice']);
438  unset ($aCustomForm['inputs']['sounds_upload']);
439  unset ($aCustomForm['inputs']['allow_upload_sounds_to']);
440  }
441 
442  if (!isset($this->_aMedia['files'])) {
443  unset ($aCustomForm['inputs']['header_files']);
444  unset ($aCustomForm['inputs']['files_choice']);
445  unset ($aCustomForm['inputs']['files_upload']);
446  unset ($aCustomForm['inputs']['allow_upload_files_to']);
447  }
448 
449  $this->processMembershipChecksForMediaUploads ($aCustomForm['inputs']);
450 
451  parent::__construct ($aCustomForm);
452  }
453 
454 }
CH_GROUPS_PHOTOS_TAG
const CH_GROUPS_PHOTOS_TAG
Definition: ChGroupsModule.php:24
ChGroupsFormAdd\__construct
__construct($oMain, $iProfileId, $iEntryId=0, $iThumb=0)
Definition: ChGroupsFormAdd.php:15
ChWsbProfileFields
Definition: ChWsbProfileFields.php:13
ChWsbRequest\serviceExists
static serviceExists($mixedModule, $sMethod, $sClass="Module")
Definition: ChWsbRequest.php:70
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
CH_GROUPS_VIDEOS_TAG
const CH_GROUPS_VIDEOS_TAG
Definition: ChGroupsModule.php:27
php
CH_GROUPS_FILES_TAG
const CH_GROUPS_FILES_TAG
Definition: ChGroupsModule.php:33
ChWsbCategories
Definition: ChWsbCategories.php:13
CH_GROUPS_SOUNDS_TAG
const CH_GROUPS_SOUNDS_TAG
Definition: ChGroupsModule.php:30
ChWsbFormMedia
Definition: ChWsbFormMedia.php:14
CH_GROUPS_PHOTOS_CAT
const CH_GROUPS_PHOTOS_CAT
Definition: ChGroupsModule.php:23
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
CH_GROUPS_VIDEOS_CAT
const CH_GROUPS_VIDEOS_CAT
Definition: ChGroupsModule.php:26
ChWsbFormMedia\processMembershipChecksForMediaUploads
processMembershipChecksForMediaUploads(&$aInputs)
Definition: ChWsbFormMedia.php:366
ChGroupsFormAdd\$_oDb
$_oDb
Definition: ChGroupsFormAdd.php:13
ChGroupsFormAdd
Definition: ChGroupsFormAdd.php:12
CH_GROUPS_SOUNDS_CAT
const CH_GROUPS_SOUNDS_CAT
Definition: ChGroupsModule.php:29
ChWsbFormMedia\generateCustomMediaTemplates
generateCustomMediaTemplates($iProfileId, $iEntryId, $iThumb=0)
Definition: ChWsbFormMedia.php:316
ChGroupsFormAdd\$_oMain
$_oMain
Definition: ChGroupsFormAdd.php:13
CH_GROUPS_FILES_CAT
const CH_GROUPS_FILES_CAT
Definition: ChGroupsModule.php:32
$iProfileId
if( $sMembersList) $iProfileId
Definition: communicator.php:29