19 if (isset($aCustomForm[
'inputs'][
'allow_post_in_forum_to'][
'type'])) {
22 $aCustomForm[
'inputs'][
'allow_post_in_forum_to'][
'type'] =
'hidden';
25 parent::__construct ($aCustomForm);
42 foreach ($_FILES[
$sName][
'tmp_name']
as $i => $sUploadedFile) {
44 'medTitle' => is_array($aTitles) && isset($aTitles[$i]) && $aTitles[$i] ? stripslashes($aTitles[$i]) : stripslashes($this->
getCleanValue($sTitleAlt)),
45 'medDesc' => is_array($aTitles) && isset($aTitles[$i]) && $aTitles[$i] ? stripslashes($aTitles[$i]) : stripslashes($this->
getCleanValue($sTitleAlt)),
47 'Categories' => array($sCat),
51 if (move_uploaded_file($sUploadedFile, $sTmpFile)) {
52 $iRet =
ChWsbService::call(
'photos',
'perform_photo_upload', array($sTmpFile, $aFileInfo,
false),
'Uploader');
75 foreach ($_FILES[
$sName][
'tmp_name']
as $i => $sUploadedFile) {
77 'title' => is_array($aTitles) && isset($aTitles[$i]) && $aTitles[$i] ? stripslashes($aTitles[$i]) : stripslashes($this->
getCleanValue($sTitleAlt)),
78 'desc' => is_array($aTitles) && isset($aTitles[$i]) && $aTitles[$i] ? stripslashes($aTitles[$i]) : stripslashes($this->
getCleanValue($sTitleAlt)),
80 'categories' => $sCat,
84 if (move_uploaded_file($sUploadedFile, $sTmpFile)) {
85 $iRet =
ChWsbService::call(
'videos',
'perform_video_upload', array($sTmpFile, $aFileInfo,
false),
'Uploader');
108 foreach ($_FILES[
$sName][
'tmp_name']
as $i => $sUploadedFile) {
110 'title' => is_array($aTitles) && isset($aTitles[$i]) && $aTitles[$i] ? stripslashes($aTitles[$i]) : stripslashes($this->
getCleanValue($sTitleAlt)),
111 'desc' => is_array($aTitles) && isset($aTitles[$i]) && $aTitles[$i] ? stripslashes($aTitles[$i]) : stripslashes($this->
getCleanValue($sTitleAlt)),
113 'categories' => $sCat,
117 if (move_uploaded_file($sUploadedFile, $sTmpFile)) {
118 $iRet =
ChWsbService::call(
'sounds',
'perform_music_upload', array($sTmpFile, $aFileInfo,
false),
'Uploader');
141 foreach ($_FILES[
$sName][
'tmp_name']
as $i => $sUploadedFile) {
143 'medTitle' => is_array($aTitles) && isset($aTitles[$i]) && $aTitles[$i] ? stripslashes($aTitles[$i]) : stripslashes($this->
getCleanValue($sTitleAlt)),
144 'medDesc' => is_array($aTitles) && isset($aTitles[$i]) && $aTitles[$i] ? stripslashes($aTitles[$i]) : stripslashes($this->
getCleanValue($sTitleAlt)),
146 'Categories' => array($sCat),
147 'Type' => $_FILES[
$sName][
'type'][$i],
151 if (move_uploaded_file($sUploadedFile, $sTmpFile)) {
152 $iRet =
ChWsbService::call(
'files',
'perform_file_upload', array($sTmpFile, $aFileInfo),
'Uploader');
170 $this->_oDb->insertMedia ($iEntryId, $aMediaValidated, $sMediaType);
181 function updateMedia ($iEntryId, $aMediaAdd, $aMediaDelete, $sMediaType)
184 $this->_oDb->updateMedia ($iEntryId, $aMediaValidated, $aMediaDelete, $sMediaType);
196 $this->_oDb->deleteMedia ($iEntryId, $aMediaValidated, $sMediaType);
204 if (is_array ($aMedia)) {
205 $aMediaValidated = array ();
206 foreach ($aMedia
as $iId) {
210 return $aMediaValidated;
222 $aReadyMedia = array ();
224 $aReadyMedia = $this->_oDb->getMediaIds($iEntryId, $sMediaType);
229 $aDataEntry = $this->_oDb->getEntryById($iEntryId);
232 foreach ($aReadyMedia
as $iMediaId) {
233 switch ($sModuleName) {
235 $aRow =
ChWsbService::call($sModuleName, $sServiceMethod, array($iMediaId,
'icon'),
'Search');
238 $aRow =
ChWsbService::call($sModuleName, $sServiceMethod, array($iMediaId,
'browse'),
'Search');
241 $aRow =
ChWsbService::call($sModuleName, $sServiceMethod, array($iMediaId),
'Search');
244 if (!$this->_oMain->isEntryAdmin($aDataEntry, $iIdProfile) && $aRow[
'owner'] != $iIdProfile)
250 'title' => $aRow[
'title'],
251 'icon' => $aRow[
'file'],
252 'owner' => $aRow[
'owner'],
253 'checked' =>
'checked',
267 $aDataEntry = $this->_oDb->getEntryById($iEntryId);
269 foreach ($this->_aMedia
as $sName => $a) {
271 $aFiles2Delete = array ();
273 foreach ($aFiles
as $aRow)
274 $aFiles2Delete[$aRow[
'id']] = $aRow[
'id'];
282 $sUploadFunc = $a[
'upload_func'];
283 if ($aMedia = $this->$sUploadFunc($a[
'tag'], $a[
'cat'])) {
284 $this->_oDb->insertMedia ($iEntryId, $aMedia,
$sName);
285 if ($a[
'thumb'] && !$aDataEntry[$a[
'thumb']] && !
$_REQUEST[$a[
'thumb']])
286 $this->_oDb->setThumbnail ($iEntryId, 0);
289 $aMediaIds = $this->_oDb->getMediaIds($iEntryId,
$sName);
292 $sThumbFieldName = $a[
'thumb'];
293 if ($aDataEntry[$sThumbFieldName] && !isset($aMediaIds[$aDataEntry[$sThumbFieldName]])) {
294 $this->_oDb->setThumbnail ($iEntryId, 0);
299 $aDeletedMedia = array_diff ($aFiles2Delete, $aMediaIds);
300 if ($aDeletedMedia) {
301 foreach ($aDeletedMedia
as $iMediaId) {
302 if (!$this->_oDb->isMediaInUse($iMediaId,
$sName))
318 $aTemplates = array ();
319 foreach ($this->_aMedia
as $sName => $a) {
324 $aVarsChoice = array (
325 'ch_if:empty' => array(
326 'condition' =>
empty($aFiles),
327 'content' => array ()
329 'ch_repeat:files' => $aFiles,
331 $aTemplates[
$sName][
'choice'] = $aFiles ? $this->_oMain->_oTemplate->parseHtmlByName(
'form_field_files_choice', $aVarsChoice) :
'';
335 foreach ($aFiles
as $k => $r) {
336 $aFiles[$k][
'checked'] = ($iThumb == $r[
'id'] ?
'checked' :
'');
337 $aFiles[$k][
'name'] = $a[
'thumb'];
339 $aVarsThumbsChoice = array (
340 'ch_if:empty' => array (
341 'condition' =>
empty($aFiles),
342 'content' => array ()
344 'ch_repeat:files' => $aFiles,
346 $aTemplates[
$sName][
'thumb_choice'] = $aFiles ? $this->_oMain->_oTemplate->parseHtmlByName(
'form_field_thumb_choice', $aVarsThumbsChoice) :
'';
350 $aVarsUpload = array (
352 'title' => $a[
'title_upload_post'],
353 'file_upload_title' => $a[
'title_upload'],
354 'ch_if:price' => array (
355 'condition' =>
false,
'content' => array(
'price' =>
'',
'file_price_title' =>
'')
357 'ch_if:privacy' => array (
358 'condition' =>
false,
'content' => array(
'select' =>
'',
'file_permission_title' =>
'')
361 $aTemplates[
$sName][
'upload'] = $this->_oMain->_oTemplate->parseHtmlByName(
'form_field_files_upload', $aVarsUpload);
372 if (defined(
'CH_PHOTOS_ADD'))
378 $a = array (
'images' =>
'PHOTOS',
'videos' =>
'VIDEOS',
'sounds' =>
'SOUNDS',
'files' =>
'FILES');
379 foreach ($a
as $k => $v) {
380 if (defined(
"CH_{$v}_ADD"))
383 unset($this->_aMedia[$k]);