Cheetah
ChSoundsModule.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbFilesModule');
9 define('PROFILE_SOUND_CATEGORY', 'Profile sounds');
10 
12 {
13  function __construct (&$aModule)
14  {
15  parent::__construct($aModule);
16 
17  // add more sections for administration
18  $this->aSectionsAdmin['processing'] = array('exclude_btns' => 'all');
19  $this->aSectionsAdmin['failed'] = array(
20  'exclude_btns' => array('activate', 'deactivate', 'featured', 'unfeatured')
21  );
22  }
23 
25  {
26  $aInfo = $this->_oDb->getFileInfo(array('fileId'=>(int)$iFileId), false, array('medID', 'medProfId', 'medUri', 'albumId', 'Approved'));
27 
28  if ($aInfo && $this->isAllowedDownload($aInfo)) {
29 
30  $sPathFull = $this->_oConfig->getFilesPath() . $aInfo['medID'] . '.mp3';
31  if (file_exists($sPathFull)) {
32  $this->isAllowedDownload($aInfo, true);
33  header('Connection: close');
34  header('Content-Type: audio/mpeg');
35  header('Content-Length: ' . filesize($sPathFull));
36  header('Last-Modified: ' . gmdate('r', filemtime($sPathFull)));
37  header('Content-Disposition: attachment; filename="' . $aInfo['medUri'] . '.mp3";');
38  readfile($sPathFull);
39  exit;
40  } else {
41  $this->_oTemplate->displayPageNotFound();
42  }
43 
44  } elseif (!$aInfo) {
45  $this->_oTemplate->displayPageNotFound();
46  } else {
47  $this->_oTemplate->displayAccessDenied();
48  }
49  }
50 
52  {
54  }
55 
56  function serviceGetMemberMenuItem ($sIcon = 'music')
57  {
58  return parent::serviceGetMemberMenuItem ($sIcon);
59  }
60  function serviceGetMemberMenuItemAddContent ($sIcon = 'music')
61  {
62  return parent::serviceGetMemberMenuItemAddContent ($sIcon);
63  }
64 
66  {
67  return $this->_oTemplate->getEmbedCode($iFileId);
68  }
69 
70  function isAllowedShare(&$aDataEntry)
71  {
72  if($aDataEntry['AllowAlbumView'] != CH_WSB_PG_ALL)
73  return false;
74 
75  return true;
76  }
77 
78  function isAllowedDownload (&$aFile, $isPerformAction = false)
79  {
80  if (getSettingValue('mp3', "save") != TRUE_VAL)
81  return false;
82  return $this->isAllowedView($aFile, $isPerformAction);
83  }
84 
85  function serviceGetWallPost($aEvent)
86  {
87  return $this->getWallPost($aEvent, 'music');
88  }
89 
90  function serviceGetWallPostOutline($aEvent)
91  {
92  return $this->getWallPostOutline($aEvent, 'music');
93  }
94 
95  function actionView ($sUri) {
96  $aInfo = $this->_oDb->getFileInfo(array('fileUri' => $sUri));
97  if(isBlocked($aInfo['medProfId'], getLoggedId())) {
98  $this->_oTemplate->pageCode($this->aPageTmpl, array('page_main_code' => MsgBox(_t('_sys_txt_error_you_are_blocked'))));
99  return;
100  }
101 
102  parent::actionView($sUri);
103  }
104 
105  function actionBrowse ($sParamName = '', $sParamValue = '', $sParamValue1 = '', $sParamValue2 = '', $sParamValue3 = '') {
106  if ($sParamName == 'album' && $sParamValue1 == 'owner') {
107  $iOwnerId = getID($sParamValue2);
108  if(isBlocked($iOwnerId, getLoggedId())) {
109  $this->_oTemplate->pageCode($this->aPageTmpl, array('page_main_code' => MsgBox(_t('_sys_txt_error_you_are_blocked'))));
110  return;
111  }
112  }
113 
114  parent::actionBrowse($sParamName, $sParamValue, $sParamValue1, $sParamValue2, $sParamValue3);
115  }
116 
117  function actionAlbums ($sParamName = '', $sParamValue = '', $sParamValue1 = '', $sParamValue2 = '', $sParamValue3 = '') {
118  if($sParamName == 'browse' && $sParamValue == 'owner') {
119  $iOwnerId = getID($sParamValue1);
120  if(isBlocked($iOwnerId, getLoggedId())) {
121  $this->_oTemplate->pageCode($this->aPageTmpl, array('page_main_code' => MsgBox(_t('_sys_txt_error_you_are_blocked'))));
122  return;
123  }
124  }
125 
126  parent::actionAlbums($sParamName, $sParamValue, $sParamValue1, $sParamValue2, $sParamValue3);
127  }
128 
129 }
header
</code > Be careful enabling this directive if you have a redirector script that does not use the< code > Location</code > HTTP header
Definition: URI.MungeResources.txt:10
ChSoundsModule\serviceGetWallPost
serviceGetWallPost($aEvent)
Definition: ChSoundsModule.php:85
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
ChWsbFilesModule\isAllowedView
isAllowedView(&$aFile, $isPerformAction=false)
Definition: ChWsbFilesModule.php:1173
ChSoundsModule\actionGetFile
actionGetFile($iFileId)
Definition: ChSoundsModule.php:24
$aModule
$aModule
Definition: classifieds.php:21
ChSoundsModule\__construct
__construct(&$aModule)
Definition: ChSoundsModule.php:13
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
php
PROFILE_SOUND_CATEGORY
const PROFILE_SOUND_CATEGORY
Definition: ChSoundsModule.php:9
$sParamValue
$sParamValue
Definition: actions.inc.php:16
ChWsbFilesModule\getWallPostOutline
getWallPostOutline($aEvent, $sIcon='save', $aParams=array())
Definition: ChWsbFilesModule.php:2034
ChSoundsModule\isAllowedDownload
isAllowedDownload(&$aFile, $isPerformAction=false)
Definition: ChSoundsModule.php:78
$aInfo
$aInfo
Definition: constants.inc.php:21
ChSoundsModule\getEmbedCode
getEmbedCode($iFileId)
Definition: ChSoundsModule.php:65
exit
exit
Definition: cart.php:21
$sParamName
$sParamName
Definition: actions.inc.php:15
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
ChSoundsModule\serviceGetWallPostOutline
serviceGetWallPostOutline($aEvent)
Definition: ChSoundsModule.php:90
ChSoundsModule
Definition: ChSoundsModule.php:12
ChWsbFilesModule
Definition: ChWsbFilesModule.php:13
ChWsbFilesModule\getWallPost
getWallPost($aEvent, $sIcon='save', $aParams=array())
Definition: ChWsbFilesModule.php:1900
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
CH_WSB_PG_ALL
const CH_WSB_PG_ALL
Definition: ChWsbPrivacy.php:12
ChSoundsModule\isAllowedShare
isAllowedShare(&$aDataEntry)
Definition: ChSoundsModule.php:70
isBlocked
isBlocked($iFirstProfile, $iSecondProfile)
Definition: utils.inc.php:128
ChSoundsModule\serviceGetMemberMenuItem
serviceGetMemberMenuItem($sIcon='music')
Definition: ChSoundsModule.php:56
ChSoundsModule\serviceGetProfileCat
serviceGetProfileCat()
Definition: ChSoundsModule.php:51
$iFileId
$iFileId
Definition: embed.php:12
getID
getID( $str, $with_email=1)
Definition: admin.inc.php:139
ChSoundsModule\actionBrowse
actionBrowse($sParamName='', $sParamValue='', $sParamValue1='', $sParamValue2='', $sParamValue3='')
Definition: ChSoundsModule.php:105
getSettingValue
getSettingValue($sWidget, $sSettingKey, $sFile="config", $bFullReturn=false, $sFolder="xml")
Definition: apiFunctions.inc.php:82
ChSoundsModule\actionAlbums
actionAlbums($sParamName='', $sParamValue='', $sParamValue1='', $sParamValue2='', $sParamValue3='')
Definition: ChSoundsModule.php:117
ChSoundsModule\serviceGetMemberMenuItemAddContent
serviceGetMemberMenuItemAddContent($sIcon='music')
Definition: ChSoundsModule.php:60
ChSoundsModule\actionView
actionView($sUri)
Definition: ChSoundsModule.php:95