11 require_once(
'ChPollCmts.php');
55 $this -> oModule = $oPollModule;
58 if($this -> iPollId) {
59 $this -> aPollInfo = $this -> oModule -> _oDb -> getPollInfo($this -> iPollId);
60 if(!$this -> oModule -> oPrivacy -> check(
'view', $this -> aPollInfo[0][
'id_poll'], $this -> iMemberId) ) {
61 echo $this -> oModule -> _oTemplate -> defaultPage(
_t(
'_ch_poll'),
MsgBox(
_t(
'_ch_poll_access_denied')), 2 );
66 if($this -> aPollInfo) {
67 $this -> aPollInfo = array_shift($this -> aPollInfo);
71 $this -> oCmtsView =
new ChPollCmts(
'ch_poll', $this -> iPollId);
76 $GLOBALS[
'oTopMenu']->setCustomSubHeaderUrl(CH_WSB_URL_ROOT . $this -> oModule -> _oConfig -> getBaseUri() .
'&action=show_poll_info&id=' . $this -> iPollId);
78 $GLOBALS[
'oTopMenu']->setCustomBreadcrumbs(array(
79 _t(
'_ch_poll') => CH_WSB_URL_ROOT . $this -> oModule -> _oConfig -> getBaseUri() .
'&action=poll_home',
80 $this -> aPollInfo[
'poll_question'] =>
'',
86 parent::genColumnsHeader();
88 $this -> sCode .= $this -> oModule -> getInitPollPage();
100 ? (
int)
$_GET[
'page']
104 ? (
int)
$_GET[
'per_page']
105 : $this -> iHomePage_countFeatured;
108 $iPerPage = $this -> iHomePage_countFeatured;
116 $iTotalNum = $this -> oModule -> _oDb -> getFeaturedCount(1,
true);
119 $sOutputCode =
MsgBox(
_t(
'_Empty' ) );
122 $sqlLimit =
"LIMIT {$sLimitFrom}, {$iPerPage}";
123 $aPolls = $this -> oModule -> _oDb -> getAllFeaturedPolls($sqlLimit, 1,
true);
124 $sOutputCode = $this -> oModule -> genPollsList($aPolls);
127 $sModulePath = $this -> oModule -> getModulePath() .
'?action=featured';
135 'on_change_page' =>
'return !loadDynamicBlock({id}, \'' .
$sModulePath .
'&action=poll_home&page={page}&per_page={per_page}\');',
138 $sPaginate = $oPaginate -> getSimplePaginate(
$sModulePath);
141 return array($sOutputCode, array(), $sPaginate);
153 ? (
int)
$_GET[
'page']
157 ? (
int)
$_GET[
'per_page']
158 : $this -> iHomePage_countLatest;
161 $iPerPage = $this -> iHomePage_countLatest;
169 $iTotalNum = $this -> oModule -> _oDb -> getFeaturedCount(0,
true);
172 $sOutputCode =
MsgBox(
_t(
'_Empty' ) );
175 $sqlLimit =
"LIMIT {$sLimitFrom}, {$iPerPage}";
176 $aPolls = $this -> oModule -> _oDb -> getAllFeaturedPolls($sqlLimit, 0,
true);
177 $sOutputCode = $this -> oModule -> genPollsList($aPolls);
188 'on_change_page' =>
'return !loadDynamicBlock({id}, \'' .
$sModulePath .
'&action=poll_home&page={page}&per_page={per_page}\');',
191 $sPaginate = $oPaginate -> getSimplePaginate(
$sModulePath);
194 return array($sOutputCode, array(), $sPaginate);
204 if(!$this -> aPollInfo)
209 'ViewerID' => (
int)$this->iMemberId,
210 'ID' => (
int)$this->aPollInfo[
'id_poll'],
211 'BaseUri' => $this->oModule->_oConfig->getBaseUri(),
214 $aUnitInfo[
'base_url'] = CH_WSB_URL_ROOT . $aUnitInfo[
'BaseUri'];
215 $aUnitInfo[
'approved_cpt'] =
'';
216 $aUnitInfo[
'featured_cpt'] =
'';
218 $aUnitInfo[
'del_poll_title'] = $aUnitInfo[
'del_poll_url'] = $aUnitInfo[
'del_poll_script'];
219 if(
isLogged() && ($this -> aPollInfo[
'id_profile'] == $this->iMemberId ||
isAdmin())) {
220 $sDeleteLink = $this->oModule->getModulePath() .
'&action=delete_poll&id=' . $aUnitInfo[
'ID'];
222 $aUnitInfo[
'del_poll_title'] =
_t(
'_ch_poll_delete');
223 $aUnitInfo[
'del_poll_url'] = $sDeleteLink;
224 $aUnitInfo[
'del_poll_script'] =
"if(confirm('" .
ch_js_string(
_t(
'_Are_you_sure')) .
"')) window.open ('" . $sDeleteLink .
"','_self'); return false;";
227 $sMainPrefix =
'ch_poll';
229 if (
isAdmin($this->iMemberId) || (
isModerator($this->iMemberId) && $this->aPollInfo[
'id_profile'] != $this->iMemberId))
231 $aUnitInfo[
'approved_cpt'] =
_t(
'_' . $sMainPrefix . ($this->aPollInfo[
'poll_approval'] ?
'_dis' :
'_') .
'approve');
232 $aUnitInfo[
'featured_cpt'] =
_t(
'_' . $sMainPrefix . ($this->aPollInfo[
'poll_featured'] ?
'_un' :
'_') .
'featured');
236 $aButton =
$oSubscription -> getButton($this -> iMemberId, $sMainPrefix,
'', $this -> aPollInfo[
'id_poll']);
238 $aUnitInfo[
'sbs_poll_title'] = $aButton[
'title'];
239 $aUnitInfo[
'sbs_poll_script'] = $aButton[
'script'];
241 $aUnitInfo[
'TitleShare'] = $this->oModule->isAllowedShare($this -> aPollInfo) ?
_t(
'_Share') :
'';
243 $aUnitInfo[
'repostCpt'] = $aUnitInfo[
'repostScript'] =
'';
247 $aUnitInfo[
'repostCpt'] =
_t(
'_Repost');
248 $aUnitInfo[
'repostScript'] =
ChWsbService::call(
'wall',
'get_repost_js_click', array($this->iMemberId, $sMainPrefix,
'add', $this->aPollInfo[
'id_poll']));
251 $sActions =
$GLOBALS[
'oFunctions'] -> genObjectsActions($aUnitInfo, $sMainPrefix);
255 return $sCode . $sActions;
263 if(!$this -> aPollInfo) {
267 return $this -> oModule -> getOwnerBlock($this -> aPollInfo[
'id_profile'], $this -> aPollInfo);
275 if(!$this -> aPollInfo)
278 $sContent = $this -> oModule -> getPollBlock($this -> aPollInfo,
false,
true);
287 if(!$this -> aPollInfo)
290 if( $this -> oModule -> oPrivacy -> check(
'comment', $this -> aPollInfo[
'id_poll'],
$oPoll -> aPollSettings[
'member_id']) ) {
291 $sOutputCode = $this -> oCmtsView -> getExtraCss();
292 $sOutputCode .= $this -> oCmtsView -> getExtraJs();
294 $sOutputCode .= ( !$this -> oCmtsView -> isEnabled() )
296 : $this -> oCmtsView -> getCommentsFirst();
298 $sOutputCode =
MsgBox(
_t(
'_ch_poll_privacy_comment_error' ) );
308 if(!$this -> aPollInfo)
311 if( $this -> oModule -> oPrivacy -> check(
'vote', $this -> aPollInfo[
'id_poll'],
$oPoll -> aPollSettings[
'member_id']) ) {
312 if ( $this -> oVotingView -> isEnabled()){
313 $sOutputCode = $this -> oVotingView -> getBigVoting();
316 $sOutputCode =
MsgBox(
_t(
'_ch_poll_privacy_vote_error' ) );
318 return array($sOutputCode);
323 if(!$this->oModule->isAllowedShare($this->aPollInfo))
326 $sUrl = CH_WSB_URL_ROOT . $this -> oModule -> _oConfig -> getBaseUri() .
'&action=show_poll_info&id=' . $this -> aPollInfo[
'id_poll'];
327 $sTitle = $this -> aPollInfo[
'poll_question'];
331 return array(
$sCode, array(), array(),
false);