37 parent::__construct(
'Sound');
40 $this->sWorkingFile = CH_WSB_URL_ROOT . $this->oModule->_oConfig->getBaseUri() .
'albums/my/add_objects';
42 $iMaxByAdmin = 1024*1024*(int)
getParam($this->oModule->_oConfig->getMainPrefix() .
'_max_file_size');
43 if ($iMaxByAdmin > 0 && $iMaxByAdmin < $this->iMaxFilesize)
44 $this->iMaxFilesize = $iMaxByAdmin;
46 $this->sAcceptMimeType =
'audio/*';
57 $aPossibleDuration = array();
58 $aPossibleDuration[
'duration'] = array(
61 'value' => isset($aDefaultValues[
'duration']) ? $aDefaultValues[
'duration'] :
"0"
71 return isset($a[
'id']) && $a[
'id'] ? $a[
'id'] :
false;
83 $sJSMusicId = (int)$_POST[
'file_id'];
84 switch($_POST[
'type']) {
87 $sFileName = $iAuthorId . TEMP_FILE_NAME . MP3_EXTENSION;
89 $this->
addObjectToAlbum($this->oModule->oAlbums, $_POST[
'extra_param_album'], $iMusicID,
false);
93 $iMusicID = $sJSMusicId;
97 if ($iMusicID && $iAuthorId) {
100 $sDescription = $_POST[
'description'];
102 $aCategories = array();
103 foreach ($_POST[
'Categories']
as $sKey => $sVal) {
105 $aCategories[] = $sVal;
111 return '<script type="text/javascript">parent.' . $this->_sJsPostObject .
'.onSuccessSendingFileInfo("' . $sJSMusicId .
'");</script>';
114 return '<script type="text/javascript">parent.' . $this->_sJsPostObject .
'.showErrorMsg("sound_failed_message");</script>';
120 if(
empty($sAuthorCheck)) {
122 if($sEmbedThumbUrl) {
123 $aDefault = array(
'music' => $sMusicId,
'title' =>
$sTitle,
'description' =>
$sDesc,
'tags' =>
$sTags,
'duration' => $iDuration,
'image' => $sEmbedThumbUrl,
'type' =>
"embed");
128 return $sAuthorCheck;
134 if(
empty($sAuthorCheck)) {
140 return $sAuthorCheck;
148 function performUpload ($sFilePath, $sRealFilename =
'',
$aInfo = array(), $isMoveUploadedFile =
true, $aExtraParams = array())
150 $bUpdateAlbumCounter =
false;
152 if ($this->_iOwnerId)
156 $sRealFilename = pathinfo($sFilePath, PATHINFO_BASENAME);
161 return array(
'error' =>
_t(
'_LOGIN_REQUIRED_AE1'));
163 if (!$this->oModule->_oConfig->checkAllowedExtsByFilename($sRealFilename))
164 return array(
'error' =>
_t(
'_sys_txt_wrong_file_extension'));
166 if (!$this->oModule->isAllowedAdd())
167 return array(
'error' =>
_t(
'_Access denied'));
172 include(
$GLOBALS[
'sModulesPath'] .
$GLOBALS[
'sModule'] .
'/inc/header.inc.php');
174 $this->sTempFilename = pathinfo($sRealFilename, PATHINFO_FILENAME);
176 return array(
'error' =>
_t(
'_sys_txt_upload_failed'));
179 $sFile1 =
$GLOBALS[
'dir'][
'root'] .
'flash/modules/mp3/files/' . $iMID;
180 $sFile2 =
$GLOBALS[
'dir'][
'root'] .
'flash/modules/mp3/files/' . $iMID .
'.mp3';
182 if($aAudioData[
'CodecName'] ==
'mp3') {
183 $sAutoApprove =
'on' ==
getParam(
'audioAutoApprove') ?
'approved' :
'disapproved';
184 rename($sFile1, $sFile2);
186 'Time' => (
int)$aAudioData[
'Duration']*1000,
188 'Status' => $sAutoApprove,
190 $this->oModule->_oDb->updateAudio($iMID, $aData);
191 $bUpdateAlbumCounter =
true;
193 $this->oModule->_oDb->updateAudio($iMID, array(
'Status' =>
'pending'));
199 foreach (array(
'title',
'categories',
'tags',
'desc')
as $sKey)
207 $sExt = strtolower(pathinfo($sRealFilename, PATHINFO_EXTENSION));
208 $sAlbum = !
empty($_POST[
'extra_param_album']) > 0 ? $_POST[
'extra_param_album'] :
getParam(
'sys_album_default_name');
209 $sAlbum = isset(
$aInfo[
'album']) ?
$aInfo[
'album'] : $sAlbum;
211 $this->
addObjectToAlbum($this->oModule->oAlbums, $sAlbum, $iMID, $bUpdateAlbumCounter);
213 $this->oModule->isAllowedAdd(
true,
true);
215 return array(
'id' => $iMID);