Cheetah
ChPollModule.php
Go to the documentation of this file.
1 <?php
2 
8  require_once(CH_DIRECTORY_PATH_CLASSES . 'ChWsbModule.php');
9  require_once(CH_DIRECTORY_PATH_CLASSES . 'ChWsbAlerts.php');
10  require_once(CH_DIRECTORY_PATH_CLASSES . 'ChWsbCategories.php');
11 
12  require_once('ChPollCalendar.php');
13  require_once('ChPollPrivacy.php');
14  require_once('ChPollSearch.php');
15 
16  define( 'CH_POLL_VOTE_UNIQ', 60*60*24*30); // within 1 month vote poll is uniq
17  define( 'CH_POLL_ANS_DIVIDER', '<delim>');
18  define( 'CH_POLL_RES_DIVIDER', ';');
19 
20  define( 'POLL_ERROR_OCCURED', _t( '_Error occured') );
21  define( 'POLL_EMPTY_FIELDS', _t( '_please_fill_next_fields_first') );
22  define( 'POLL_CREATED', _t( '_ch_poll_created') );
23  define( 'POLL_EDITED', _t( '_ch_poll_was_edited') );
24  define( 'POLL_MAX_REACHED', _t( '_ch_poll_max_reached') );
25  define( 'POLL_NOT_ALLOW', _t( '_ch_poll_not_available') );
26 
28  {
29  function checkAnswers($aItems, $iLenMin, $iLenMax)
30  {
31  if (count($aItems) < 2) {
32  return false;
33  }
34 
35  return parent::checkLength ($aItems, $iLenMin, $iLenMax);
36  }
37 
38  function passAnswers ($a)
39  {
40  if (is_array($a))
41  foreach ($a as $k => $v)
42  $a[$k] = $this->passXss ($v);
43  return is_array($a) ? implode(',', $a) : $a;
44 
45  }
46  }
47 
116  class ChPollModule extends ChWsbModule
117  {
119 
120  // contain all needed templates name;
122 
123  // contain some of needed poll's settings;
125 
126  // contain some module information ;
128 
129  // contain answer for some member's action ;
130  var $sActionAnswer = null;
131 
132  // contain path to current module;
133  var $sPathToModule = null;
134 
135  // privacy object;
136  var $oPrivacy = null;
137 
138  // title of poll's home page;
140 
141  // number of polls elements for per line;
143 
144  var $oSearch;
145 
166  function __construct($aModule, $aPollSettings = array() )
167  {
168  global $logged;
169 
170  parent::__construct($aModule);
171  $this -> sHomeUrl = $this ->_oConfig -> _sHomeUrl;
172 
173  $this -> aPollSettings = $aPollSettings;
174 
175  $this -> aPollSettings['question_min_length'] = 10;
176  $this -> aPollSettings['question_max_length'] = 300;
177 
178  $this -> aPollSettings['answer_min_length'] = 1;
179  $this -> aPollSettings['answer_max_length'] = 300;
180 
181  // init some pagination parameters;
182  if( !$this -> aPollSettings['per_page'] )
183  $this -> aPollSettings['per_page'] = 10;
184 
185  if ( $this -> aPollSettings['per_page'] > 100 )
186  $this -> aPollSettings['per_page'] = 100;
187 
188  if( $this -> aPollSettings['page'] < 1 )
189  $this -> aPollSettings['page'] = 1;
190 
191  // fill array with templates name;
192  $this -> aUsedTemplates = array
193  (
194  'poll_init' => 'poll_init.html',
195  'poll_block' => 'poll_block.html',
196  'poll_view_block' => 'poll_view_block.html',
197  'poll_block_ajax' => 'poll_block_ajax.html',
198  'poll_questions_list' => 'poll_questions_list.xml',
199  'poll_results_list' => 'poll_results_list.xml',
200  'server_answer' => 'server_answer.xml',
201  'poll_creation_form' => 'poll_creation_form.html',
202  'poll_edit_form' => 'poll_edit_form.html',
203  'poll_actions' => 'poll_actions.html',
204  'poll_premoderation' => 'poll_premoderation.html',
205  'poll_owner' => 'entry_view_block_info.html',
206  );
207 
208  $this -> aModuleInfo = $aModule;
209 
210  // prepare the location link ;
211  $this -> sPathToModule = CH_WSB_URL_ROOT . $this -> _oConfig -> getBaseUri();
212  if ($this -> aPollSettings['action']) {
213  $this -> sPathToModule .= '&action=' . rawurlencode($this -> aPollSettings['action']);
214  }
215 
216  $this -> oPrivacy = new ChPollPrivacy($this);
217  $this -> oSearch = new ChPollSearch($this);
218  }
219 
225  function getModulePath()
226  {
227  return CH_WSB_URL_ROOT . $this -> _oConfig -> getBaseUri();
228  }
229 
237  function getOwnerBlock($iPollOwner, $aPollInfo)
238  {
239  $aMemberInfo = getProfileInfo($iPollOwner);
240  $sThumbImg = get_member_thumbnail($aMemberInfo['ID'], 'none', true);
241 
242  $aTemplateKeys = array(
243  'author_unit' => $sThumbImg,
244  'author_username' => $aMemberInfo['NickName'],
245  'author_url' => getProfileLink($aMemberInfo['ID']),
246  'date' => getLocaleDate($aPollInfo['poll_date'], CH_WSB_LOCALE_DATE_SHORT),
247  'date_ago' => defineTimeInterval($aPollInfo['poll_date'], false),
248  'tags' => getLinkSet($aPollInfo['poll_tags'], $this -> getModulePath() . '&action=tag&tag=', CH_WSB_TAGS_DIVIDER),
249  'fields' => null,
250  'cats' => getLinkSet($aPollInfo['poll_categories'], $this -> getModulePath() . '&action=category&category=', CATEGORIES_DIVIDER),
251  );
252 
253  $sOutpuCode = $this -> _oTemplate -> parseHtmlByName($this -> aUsedTemplates['poll_owner'], $aTemplateKeys);
254 
255  return array($sOutpuCode);
256  }
257 
264  {
265  global $_page;
266 
267  switch($this -> aPollSettings['mode']) {
268 
269  case 'edit_poll' :
270  $sPageCaption = _t('_ch_poll_edit_poll');
271 
272  $_page['header'] = $sPageCaption ;
273  $_page['header_text'] = $sPageCaption ;
274 
275  $sOutputCode = $this -> getEditForm();
276  break;
277 
278  case 'add' :
279  $sPageCaption = _t('_ch_poll_add');
280 
281  $_page['header'] = $sPageCaption ;
282  $_page['header_text'] = $sPageCaption ;
283 
284  $sOutputCode = $this -> getCreationForm();
285  break;
286 
287  case 'manage' :
288  case 'pending' :
289 
290  $sPageCaption = _t($this->aPollSettings['mode'] == 'manage' ? '_ch_poll_manage_poll' : '_ch_poll_pending_poll');
291  $_page['header'] = $sPageCaption ;
292  $_page['header_text'] = $sPageCaption ;
293 
294  if(!empty($_POST['poll_id']) && is_array($_POST['poll_id']))
295  foreach($_POST['poll_id'] as $iKey)
296  $this->deletePoll($iKey);
297 
298  // select approvedn polls or not;
299  $sOutputCode = $this -> getInitPollPage();
300  $sOutputCode .= $this -> getManagePollsPage($this -> aPollSettings['mode'] == 'manage');
301  break;
302 
303  case 'main' :
304  default :
305  $sOutputCode = '<center class="ch-def-font-large">' . _t('_ch_poll_have_not_approval',
306  '<b>' . $this -> _oDb -> getUnApprovedPolls($this -> aPollSettings['member_id']) . '</b>') . '</center>';
307 
308  $aTemplateKeys = array(
309  'content' => $sOutputCode,
310  );
311 
312  $sOutputCode = $GLOBALS['oSysTemplate'] -> parseHtmlByName('default_padding.html', $aTemplateKeys);
313  }
314 
315  return DesignBoxContent(_t('_ch_poll_administration'), $sOutputCode, 1, $this->genToggleElements());
316  }
317 
318  function genToggleElements()
319  {
320  // generate toggle ellements ;
321  $aToggleItems = array (
322  'main' => _t('_ch_poll_main'),
323  'add' => _t('_ch_poll_add'),
324  'manage' => _t('_ch_poll_manage'),
325  'pending' => _t('_ch_poll_pending'),
326  );
327 
328  // set default
329  if(!$this->aPollSettings['mode'])
330  $this->aPollSettings['mode'] = 'main';
331 
332  // add new toggle el;
333  if($this->aPollSettings['mode'] == 'edit_poll')
334  $aToggleItems['edit_poll'] = _t('_ch_poll_edit');
335 
336  $aItems = array();
337  foreach($aToggleItems as $sKey => $sValue)
338  $aItems[$sValue] = array('href' => $this->sPathToModule . '&mode=' . $sKey, 'active' => $this->aPollSettings['mode'] == $sKey ? 1 : 0);
339 
340  ch_import('ChWsbPageView');
341  return ChWsbPageView::getBlockCaptionItemCode(0, $aItems);
342  }
343 
350  function getManagePollsPage($bApproval = true)
351  {
352  // try to get all approved polls;
353  if($bApproval) {
354  $this -> oSearch -> aCurrent['restriction']['my']['value'] = $this -> aPollSettings['member_id'];
355  $this -> oSearch -> aCurrent['restriction']['activeStatus']['value'] = '';
356  $sExtraParam = '&mode=manage';
357  $sOutputCode = $this -> showSearchResult(null, $sExtraParam, 0, true, 0, false);
358  } else {
359  // get all anapproved polls;
360  $this -> oSearch -> aCurrent['restriction']['my']['value'] = $this -> aPollSettings['member_id'];
361  $this -> oSearch -> aCurrent['restriction']['approvalStatus']['operator'] = '!=';
362  $sExtraParam = '&mode=pending';
363  $sOutputCode = $this -> showSearchResult(null, $sExtraParam, 0, true, 0, false);
364  }
365 
366  // draw manage elements;
367  $aAdminSection = $this -> showAdminActionsPanel('manage_form', array( _t('_ch_poll_delete') ), 'poll_id');
368 
369  $sOutputCode =
370  '
371  <div id="pol_container">
372  <form id="manage_form" method="post">
373  ' . $sOutputCode . $aAdminSection . '
374  </form>
375  </div>
376  ';
377 
378  return $sOutputCode;
379  }
380 
381  function showAdminActionsPanel($sWrapperId, $aButtons, $sCheckboxName = 'entry', $bSelectAll = true, $bSelectAllChecked = false)
382  {
383  $aUnit = $aBtns = array();
384  if(is_array($aButtons) && !empty($aButtons))
385  foreach ($aButtons as $k => $v) {
386  if(is_array($v)) {
387  $aBtns[] = $v;
388  continue;
389  }
390  $aBtns[] = array(
391  'type' => 'submit',
392  'name' => $k,
393  'value' => ('_' == $v[0] ? _t($v) : $v),
394  'onclick' => ''
395  );
396  }
397  $aUnit['ch_if:actionButtons'] = array(
398  'condition' => !empty($aBtns),
399  'content' => array(
400  'ch_repeat:buttons' => $aBtns
401  )
402  );
403  $aUnit['ch_if:selectAll'] = array(
404  'condition' => $bSelectAll,
405  'content' => array(
406  'wrapperId' => $sWrapperId,
407  'checkboxName' => $sCheckboxName,
408  'checked' => ($bSelectAll && $bSelectAllChecked ? 'checked="checked"' : '')
409  )
410  );
411  $aUnit['ch_if:customHTML'] = array(
412  'condition' => false,
413  'content' => array(),
414  );
415 
416  return $GLOBALS['oSysTemplate']->parseHtmlByName('adminActionsPanel.html', $aUnit, array('{','}'));
417  }
418 
429  function getPrivatePollBlock(&$aPollInfo)
430  {
431  $aTemplateKeys = array ();
432  return $this -> _oTemplate -> parseHtmlByName('poll_private_block.html', $aTemplateKeys);
433  }
434 
445  function getPollBlock(&$aPollInfo, $bAjaxQuery = false, $bViewMode = false, $bAdminMode = false)
446  {
447  if(!$this -> oPrivacy -> check('view', $aPollInfo['id_poll'], $this -> aPollSettings['member_id']))
448  return $this -> getPrivatePollBlock($aPollInfo);
449 
450  // ** init some needed variables ;
451  $sPollActions = null;
452  $aMemberInfo = array();
453 
454  // language keys ;
455  $aLanguageKeys = array (
456  'results' => _t('_ch_poll_result'),
457  'delete' => _t('_ch_poll_delete'),
458  'edit' => _t('_ch_poll_edit'),
459  'active' => _t('_ch_poll_active'),
460  'sure' => _t('_Are_you_sure'),
461  'by' => _t('_ch_poll_by' ),
462  'poll' => _t('_ch_poll'),
463 
464  'featured' => _t('_ch_poll_featured'),
465  'unfeatured' => _t('_ch_poll_unfeatured'),
466  'poll_approved' => _t('_ch_poll_approved'),
467  'poll_unapproved' => _t('_ch_poll_unapproved'),
468  );
469 
470  // ** generate the some of poll's information ;
471  $sDateAdd = defineTimeInterval($aPollInfo['poll_date']);
472 
473  // need to modify (move the top member's info to bottom)
474  $aTemplateKeys = array (
475  'ch_if:start_tag' => array (
476  'condition' => !$bAjaxQuery,
477  'content' => array('uid' => $aPollInfo['id_poll']),
478  ),
479 
480  'ch_if:manage_page' => array (
481  'condition' => $bAdminMode || (in_array($this->aPollSettings['mode'], array('manage', 'pending')) && $this->aPollSettings['member_id'] && $this->aPollSettings['member_id'] == $aPollInfo['id_profile']),
482  'content' => array(
483  ),
484  ),
485 
486  'ch_if:end_tag' => array (
487  'condition' => !$bAjaxQuery,
488  'content' => array(),
489  ),
490 
491  'uid' => $aPollInfo['id_poll'],
492  'poll_url' => CH_WSB_URL_ROOT . $this -> _oConfig -> getBaseUri() . '&action=show_poll_info&id=' . $aPollInfo['id_poll'],
493  'ch_if:show_link' => array(
494  'condition' => $aPollInfo['id_profile'],
495  'content' => array(
496  'link' => getProfileLink($aPollInfo['id_profile']),
497  'content' => getNickName($aPollInfo['id_profile'])
498  )
499  ),
500  'ch_if:show_text' => array(
501  'condition' => !$aPollInfo['id_profile'],
502  'content' => array(
503  'content' => _t( '_Admin' )
504  )
505  ),
506  'date_add' => $sDateAdd ,
507  'result' => $aLanguageKeys['results'],
508  'actions' => $sPollActions,
509  'by' => $aLanguageKeys['by'],
510 
511  'ch_if:show_status' => array(
512  'condition' => $bAdminMode,
513  'content' => array(
514  'status' => $aPollInfo['poll_approval'] ? $aLanguageKeys['poll_approved'] : $aLanguageKeys['poll_unapproved'],
515  'featured' => $aPollInfo['poll_featured'] ? $aLanguageKeys['featured'] : $aLanguageKeys['unfeatured'],
516  )
517  ),
518 
519  'ch_if:show_actions' => array(
520  'condition' => $bAdminMode,
521  'content' => array(
522  'url_edit' => $this -> sPathToModule . '&action=my&mode=edit_poll&edit_poll_id=' . $aPollInfo['id_poll'],
523  )
524  ),
525 
526  // poll's corner's images ;
527  'pool_down_src' => $this -> _oTemplate -> getIconUrl ( 'poll_down.png' ),
528  'pool_up_src' => $this -> _oTemplate -> getIconUrl ( 'poll_up.png' ),
529 
530  'spacer' => $this -> _oTemplate -> getIconUrl ( 'spacer.gif' ),
531 
532  'back' => $aLanguageKeys['poll'],
533  );
534 
535  $sTemplateName = !$bViewMode ? $this->aUsedTemplates['poll_block'] : $this->aUsedTemplates['poll_view_block'];
536  return $this->_oTemplate->parseHtmlByName($sTemplateName, $aTemplateKeys);
537  }
538 
545  function getInitPollPage($bDynamic = true)
546  {
547  global $site;
548  $sJS = '';
549 
550  if($bDynamic) {
551  $this -> _oTemplate -> addJs('profile_poll.js');
552  } else {
553  $sJS = $this -> _oTemplate -> addJs('profile_poll.js', true);
554  }
555 
556  // language keys;
557  $aLanguageKeys = array
558  (
559  'delete' => _t('_ch_poll_delete'),
560  'loading' => _t('_ch_poll_loading') . '...',
561  'poll_deleted' => _t('_ch_poll_was_deleted'),
562  'make_it' => _t('_ch_poll_make_it'),
563  'you_should' => _t('_ch_poll_specify_least'),
564  );
565 
566  $aTemplateKeys = array
567  (
568  // init some of needed poll's parameters ;
569  'delete' => $aLanguageKeys['delete'],
570  'loading' => $aLanguageKeys['loading'],
571  'poll_deleted' => $aLanguageKeys['poll_deleted'],
572  'make_it' => $aLanguageKeys['make_it'],
573  'you_should' => $aLanguageKeys['you_should'],
574  'path_to_script' => $this -> sHomeUrl,
575  'module_name' => $this -> aModuleInfo['uri'],
576  'site' => $site['url'],
577  );
578 
579  // generate init page ;
580  $sInitPart = $this -> _oTemplate -> parseHtmlByName( $this -> aUsedTemplates['poll_init'], $aTemplateKeys );
581 
582  return $sJS . $sInitPart;
583  }
584 
588  function proccesData()
589  {
590  $sPollAnsers = null;
591  $sPollResults = null;
592 
593  if (isset($_POST['question'])
594  and ( $this -> aPollSettings['member_id'] or $this -> aPollSettings['admin_mode'] ) ) {
595 
596  // process the poll's question ;
597  $sPollQuestion = strip_tags( trim($_POST['question']) );
598 
599  if( $_POST['answers'] and is_array($_POST['answers']) ) {
600  // procces the answers list ;
601  foreach( $_POST['answers'] as $iKey => $sValue ) {
602  if ($sValue) {
603  $sValue = strip_tags( trim($sValue) );
604 
605  $sPollAnsers .= $sValue . CH_POLL_ANS_DIVIDER;
606  $sPollResults .= '0;';
607  }
608  }
609  } else {
610  // try define answer list as separate values;
611  foreach($_POST as $sKey => $sValue) {
612  if( strstr($sKey, 'answers_') ) {
613  $sPollAnsers .= $sValue . CH_POLL_ANS_DIVIDER;
614  }
615  }
616  }
617 
618  // procces recived tags;
619  $sTags = null;
620  if( isset($_POST['tags']) ) {
621  $sTags = strip_tags( trim($_POST['tags']) );
622  }
623 
624  $sCategory = null;
625  if( isset($_POST['Categories']) && is_array($_POST['Categories']) ) {
626  foreach($_POST['Categories'] as $iKey => $sValue) {
627  if($sValue) {
628  $sCategory .= strip_tags( trim($sValue, CH_TAGS_STRIP) ) . CATEGORIES_DIVIDER;
629  }
630  }
631  }
632 
633  // define the privacy group value;
634  $iCommentGroupValue = ( isset($_POST['allow_comment_to']) )
635  ? (int) $_POST['allow_comment_to']
636  : 3;
637 
638  $iVoteGroupValue = ( isset($_POST['allow_vote_to']) )
639  ? (int) $_POST['allow_vote_to']
640  : 3;
641 
642  $iViewGroupValue = ( isset($_POST['allow_view_to']) )
643  ? (int) $_POST['allow_view_to']
644  : 3;
645 
646  if ($_GET['mode'] == 'add' && $sPollAnsers) {
647  // create new poll ;
648  $this -> createPoll
649  (
650  $sPollQuestion,
651  $sPollAnsers,
652  $sPollResults,
653  $sTags,
654  $iCommentGroupValue,
655  $iVoteGroupValue,
656  $sCategory,
657  $iViewGroupValue
658  );
659  } else if ($_GET['mode'] == 'edit_poll' && $sPollAnsers) {
660 
661  $bActive = ( isset($_POST['active']) ) ? true : false ;
662  $bApprove = ( isset($_POST['approve']) && isAdmin() ) ? true : false ;
663 
664  $this -> editPoll
665  (
666  $this -> aPollSettings['edit_poll_id'],
667  $sPollQuestion,
668  $sPollAnsers,
669  $sCategory,
670  $bActive,
671  $bApprove,
672  $sTags,
673  $iCommentGroupValue,
674  $iVoteGroupValue,
675  $iViewGroupValue
676  );
677  }
678  }
679  }
680 
686  function getCreationForm()
687  {
688  // check membership;
689  if(!$this -> isPollCreateAlowed($this -> aPollSettings['member_id'], false) ) {
690  return MsgBox( _t('_ch_poll_access_denied') );
691  }
692 
693  $iDefaultAnswerCount = 2;
694 
695  $aLanguageKeys = array
696  (
697  'create' => _t('_ch_poll_create'),
698  'tags' => _t('_ch_poll_tags'),
699  'tags_sep' => _t('_sys_tags_note'),
700  'generate' => _t('_ch_poll_generate'),
701  'question' => _t('_ch_poll_question'),
702  'answer' => _t('_ch_poll_answer'),
703  'add_answer' => _t('_ch_poll_add'),
704  'max_pool' => _t('_ch_poll_max_reached'),
705 
706  'question_length_req' => _t('_ch_poll_question_length_required',
707  $this -> aPollSettings['question_min_length'], $this -> aPollSettings['question_max_length']),
708 
709  'answer_length_req' => _t('_ch_poll_answer_length_required',
710  $this -> aPollSettings['answer_min_length'], $this -> aPollSettings['answer_max_length']),
711  );
712 
713  $aForm = array (
714 
715  'form_attrs' => array (
716  'action' => $this -> sPathToModule . '&mode=' . $this -> aPollSettings['mode'],
717  'method' => 'post',
718  'name' => 'poll_creation_form'
719  ),
720 
721  'params' => array (
722  'checker_helper' => 'ChCheckerPoll',
723  'db' => array(
724  'submit_name' => 'do_submit', // some filed name with non empty value to determine if the for was submitted,
725  ),
726  ),
727 
728  'inputs' => array(
729  'question' => array (
730  'type' => 'text',
731  'name' => 'question',
732  'caption' => $aLanguageKeys['question'],
733  'required' => true,
734 
735  // checker params
736  'checker' => array (
737  'func' => 'length',
738  'params' => array($this -> aPollSettings['question_min_length'], $this -> aPollSettings['question_max_length']),
739  'error' => $aLanguageKeys['question_length_req'],
740  ),
741  ),
742 
743  'answers' => array (
744  'type' => 'text',
745  'name' => 'answers[]',
746  'caption' => $aLanguageKeys['answer'],
747  'required' => true,
748  'value' => array ('', ''),
749 
750  'attrs' => array(
751  'multiplyable' => 'true',
752  ),
753 
754  // checker params
755  'checker' => array (
756  'func' => 'answers',
757  'params' => array($this -> aPollSettings['answer_min_length'], $this -> aPollSettings['answer_max_length']),
758  'error' => $aLanguageKeys['answer_length_req'],
759  ),
760 
761  'db' => array (
762  'pass' => 'Anwers',
763  ),
764  ),
765 
766  'category' => array(),
767 
768  'tags' => array (
769  'type' => 'text',
770  'name' => 'tags',
771  'caption' => $aLanguageKeys['tags'],
772  'required' => false,
773  'info' => $aLanguageKeys['tags_sep'],
774  ),
775 
776  'allow_view_to' => $this -> oPrivacy -> getGroupChooser($this -> aPollSettings['member_id']
777  , $this -> aModuleInfo['uri'], 'view', array(), _t('_ch_poll_allow_view') ),
778 
779  'allow_comments_to' => $this -> oPrivacy -> getGroupChooser($this -> aPollSettings['member_id']
780  , $this -> aModuleInfo['uri'], 'comment', array(), _t('_ch_poll_allow_comment') ),
781 
782  'allow_vote_to' => $this -> oPrivacy -> getGroupChooser($this -> aPollSettings['member_id']
783  , $this -> aModuleInfo['uri'], 'vote', array(), _t('_ch_poll_allow_vote') ),
784  ),
785  );
786 
787  // generate categories;
788  $oCategories = new ChWsbCategories();
789  $oCategories -> getTagObjectConfig();
790  $aForm['inputs']['category'] = $oCategories -> getGroupChooser ('ch_poll', $this -> aPollSettings['member_id'], true);
791 
792  // add submit button;
793  $aForm['inputs'][] = array (
794  'type' => 'submit',
795  'name' => 'do_submit',
796  'value' => $aLanguageKeys['generate'],
797  );
798 
800  $oForm -> initChecker();
801 
802  // create new poll
803  if ( $oForm -> isSubmittedAndValid() ) {
804  $this -> proccesData();
805  $sOutputCode .= $this -> sActionAnswer;
806  } else {
807  $sOutputCode .= $oForm -> getCode();
808  }
809 
810  return $this->_oTemplate->parseHtmlByName('default_margin.html', array('content' => $sOutputCode));
811  }
812 
818  {
820 
821  if( $iProfileId && isMember() ) {
822  $aOpt = array('only_menu' => 1, 'BaseUri' => $this -> _oConfig -> getBaseUri());
823  $GLOBALS['oTopMenu'] -> setCustomSubActions($aOpt, 'ch_poll_title');
824  }
825  }
826 
832  function getEditForm()
833  {
834  if($this -> aPollSettings['edit_poll_id']) {
835  $aPollInfo = $this -> _oDb -> getPollInfo($this -> aPollSettings['edit_poll_id']);
836  $aPollInfo = array_shift($aPollInfo);
837 
838  // check poll's permission;
839  if ($this -> aPollSettings['admin_mode']
840  || $aPollInfo['id_profile'] == $this -> aPollSettings['member_id'] ) {
841 
842  $aLanguageKeys = array
843  (
844  'question' => _t('_ch_poll_question'),
845  'answer' => _t('_ch_poll_answer'),
846  'save' => _t('_ch_poll_save'),
847  'close' => _t('_ch_poll_close'),
848  'active' => _t('_ch_poll_active'),
849  'approve' => _t('_ch_poll_approve'),
850  'tags' => _t('_ch_poll_tags'),
851  'tags_sep' => _t('_ch_poll_tags_separeted'),
852 
853  'question_length_req' => _t('_ch_poll_question_length_required',
854  $this -> aPollSettings['question_min_length'], $this -> aPollSettings['question_max_length']),
855 
856  'answer_length_req' => _t('_ch_poll_answer_length_required',
857  $this -> aPollSettings['answer_min_length'], $this -> aPollSettings['answer_max_length']),
858  );
859 
860  // generate edit form;
861  $aForm = array (
862  'form_attrs' => array (
863  'action' => $this -> sPathToModule . '&mode=' . $this -> aPollSettings['mode'] . '&edit_poll_id=' . $this -> aPollSettings['edit_poll_id'],
864  'method' => 'post',
865  'name' => 'poll_edit_form'
866  ),
867 
868  'params' => array (
869  'checker_helper' => 'ChCheckerPoll',
870  'db' => array(
871  'submit_name' => 'do_submit', // some filed name with non empty value to determine if the for was submitted,
872  ),
873  ),
874 
875  'inputs' => array (
876  'question' => array (
877  'type' => 'text',
878  'name' => 'question',
879  'caption' => $aLanguageKeys['question'],
880  'required' => true,
881  'value' => $aPollInfo['poll_question'],
882 
883  // checker params
884  'checker' => array (
885  'func' => 'length',
886  'params' => array($this -> aPollSettings['question_min_length'], $this -> aPollSettings['question_max_length']),
887  'error' => $aLanguageKeys['question_length_req'],
888  ),
889  ),
890  ),
891  );
892 
893  // generate answers list ;
894  $aAnswers = explode(CH_POLL_ANS_DIVIDER, $aPollInfo['poll_answers']);
895  $iIndex = 0;
896 
897  foreach($aAnswers as $iKey => $sValue) {
898  if ($sValue) {
899  $iIndex++;
900 
901  $aForm['inputs'][] = array(
902  'type' => 'text',
903  'name' => 'answers_' . $iIndex,
904  'caption' => $aLanguageKeys['answer'] . ' ' . $iIndex,
905  'required' => true,
906  'value' => $sValue,
907 
908  // checker params
909  'checker' => array (
910  'func' => 'length',
911  'params' => array($this -> aPollSettings['answer_min_length'], $this -> aPollSettings['answer_max_length']),
912  'error' => $aLanguageKeys['answer_length_req'],
913  ),
914  );
915  }
916  }
917 
918  // generate categories;
919  $oCategories = new ChWsbCategories();
920  $oCategories -> getTagObjectConfig();
921  $aCurrentCategories = explode(CATEGORIES_DIVIDER, $aPollInfo['poll_categories']);
922 
923  $aForm['inputs']['category'] = $oCategories -> getGroupChooser ('ch_poll', $this -> aPollSettings['member_id'], true, $aPollInfo['poll_categories']);
924  $aForm['inputs']['category']['value'] = $aCurrentCategories;
925 
926  // generate tags el;
927  $aForm['inputs'][] = array (
928  'type' => 'text',
929  'name' => 'tags',
930  'caption' => $aLanguageKeys['tags'],
931  'required' => false,
932  'info' => $aLanguageKeys['tags_sep'],
933  'value' => $aPollInfo['poll_tags'],
934  );
935 
936  $aForm['inputs'] = array_merge($aForm['inputs'], array(
937  'allow_view_to' => $this -> oPrivacy -> getGroupChooser($this -> aPollSettings['member_id'], $this -> aModuleInfo['uri'], 'view', array(), _t('_ch_poll_allow_view') ),
938  'allow_comments_to' => $this -> oPrivacy -> getGroupChooser($this -> aPollSettings['member_id'], $this -> aModuleInfo['uri'], 'comment', array(), _t('_ch_poll_allow_comment') ),
939  'allow_vote_to' => $this -> oPrivacy -> getGroupChooser($this -> aPollSettings['member_id'], $this -> aModuleInfo['uri'], 'vote', array(), _t('_ch_poll_allow_vote') ),
940  ));
941 
942  // add status checkbox;
943  $aForm['inputs'][] = array (
944  'type' => 'checkbox',
945  'name' => 'active',
946  'caption' => $aLanguageKeys['active'],
947 
948  'attrs' => array(
949  'checked' => ($aPollInfo['poll_status']) ? 'checked' : null,
950  ),
951  );
952 
953  // add approve checkbox;
954  if(isAdmin())
955  $aForm['inputs'][] = array (
956  'type' => 'checkbox',
957  'name' => 'approve',
958  'caption' => $aLanguageKeys['approve'],
959 
960  'attrs' => array(
961  'checked' => ($aPollInfo['poll_approval']) ? 'checked' : null,
962  )
963  );
964 
965  // add submit button;
966  $aForm['inputs'][] = array (
967  'type' => 'submit',
968  'name' => 'do_submit',
969  'value' => $aLanguageKeys['save'],
970  );
971 
972  $aForm['inputs']['allow_view_to']['value'] = (string) $aPollInfo['allow_view_to'];
973  $aForm['inputs']['allow_comments_to']['value'] = (string) $aPollInfo['allow_comment_to'];
974  $aForm['inputs']['allow_vote_to']['value'] = (string) $aPollInfo['allow_vote_to'];
975 
977  $oForm -> initChecker();
978 
979  // create new poll
980  if ( $oForm -> isSubmittedAndValid() ) {
981  $this -> proccesData();
982  $sOutputCode = MsgBox( _t('_ch_poll_was_edited') );
983  } else {
984  $sOutputCode = $oForm -> getCode();
985  }
986  }
987  }
988 
989  return $this->_oTemplate->parseHtmlByName('default_margin.html', array('content' => $sOutputCode));
990  }
991 
998  function actionResultsList($iPollID)
999  {
1000  // ** init some needed variables ;
1001 
1002  $aPoints = array();
1003  $aNames = array();
1004 
1005  // get information about received pool ;
1006  $aPoll = $this -> _oDb -> getPollInfo( (int) $iPollID );
1007 
1008  $aAnswersResult = explode(CH_POLL_RES_DIVIDER, $aPoll[0]['poll_results'] );
1009  $aAnswersNames = explode(CH_POLL_ANS_DIVIDER, $aPoll[0]['poll_answers'] );
1010  $iTotalVotes = $aPoll[0]['poll_total_votes'];
1011 
1012  foreach ($aAnswersResult as $value) {
1013  if ( $value ) {
1014  $aPoints[] = array
1015  (
1016  'point' => round( (0 != $iTotalVotes ? (( $value / $iTotalVotes ) * 100) : 0), 1),
1017  'number' => htmlspecialchars ( $value ),
1018  );
1019  } else if ( $value != '' ) {
1020  $aPoints[] = array
1021  (
1022  'point' => 0,
1023  'number' => 0,
1024  );
1025  }
1026  }
1027 
1028  foreach ($aAnswersNames as $value) {
1029  if ( $value ) {
1030  $aNames[] = array
1031  (
1032  'name' => htmlspecialchars ( $value ),
1033  );
1034  }
1035  }
1036 
1037  // return the generated poll's results list ;
1038  header('Content-Type: application/xml');
1039 
1040  $aTemplateKeys = array
1041  (
1042  'ch_repeat:points' => $aPoints,
1043  'ch_repeat:names' => $aNames,
1044  );
1045 
1046  $this -> _oTemplate -> _bCacheEnable = false;
1047  echo $this -> _oTemplate -> parseHtmlByName( $this -> aUsedTemplates['poll_results_list'], $aTemplateKeys );
1048  }
1049 
1056  function actionGetQuestions($iPollID)
1057  {
1058  // ** init some needed variables ;
1059 
1060  // contain processed answer list ;
1061  $aQuestionsList = array();
1062 
1063  // get information about received pool ;
1064  $aPoll = $this -> _oDb -> getPollInfo( (int) $iPollID );
1065 
1066  // processing received answer list ;
1067  if ($aPoll) {
1068  $aQuestions = explode(CH_POLL_ANS_DIVIDER, $aPoll[0]['poll_answers']);
1069  foreach ($aQuestions as $sValue) {
1070  if ($sValue) {
1071  $aQuestionsList[] = array
1072  (
1073  'answer' => htmlspecialchars($sValue),
1074  );
1075  }
1076  }
1077  } else {
1078  $aQuestionsList[] = array
1079  (
1080  'answer' => _t( '_Empty' ),
1081  );
1082  }
1083 
1084  // prepare to output ;
1085  $aTemplateKeys = array
1086  (
1087  'question' => ( isset($aPoll[0]['poll_question']) )
1088  ? htmlspecialchars( $aPoll[0]['poll_question'] )
1089  : null,
1090 
1091  'ch_repeat:answer_list' => $aQuestionsList,
1092  );
1093 
1094  header('Content-Type: application/xml; charset=utf-8');
1095  $this -> _oTemplate -> _bCacheEnable = false;
1096  echo $this -> _oTemplate -> parseHtmlByName( $this -> aUsedTemplates['poll_questions_list'], $aTemplateKeys );
1097  }
1098 
1105  function actionSetAnswer($iPollID, $iVoteNumber)
1106  {
1107  if ( (int) $iVoteNumber >= 0 ) {
1108  // get information about received pool ;
1109  $aPoll = $this -> _oDb -> getPollInfo( (int) $iPollID );
1110 
1111  // explode all votes results ;
1112  $aVotes = explode(CH_POLL_RES_DIVIDER, $aPoll[0]['poll_results'] );
1113  $aVotes[$iVoteNumber]++;
1114 
1115  $iPoll_total_votes = array_sum($aVotes);
1116  $sVotes = implode(';', $aVotes);
1117 
1118  if ( !isset($_COOKIE['profile_polls_question_' . $iPollID]) ) {
1119  if ( $this -> _oDb -> setVotes( (int) $iPollID, $sVotes, $iPoll_total_votes) ) {
1120  // if vote was created ;
1121  $aUrl = parse_url($GLOBALS['site']['url']);
1122  $sPath = isset($aUrl['path']) && !empty($aUrl['path']) ? $aUrl['path'] : '/';
1123  setcookie( 'profile_polls_question_' . $iPollID, 1 , time() + CH_POLL_VOTE_UNIQ, $sPath );
1124 
1125  // create system event
1126  $oZ = new ChWsbAlerts('ch_poll', 'answered', $aPoll[0]['id_profile'], $this -> aPollSettings['member_id'], array('poll_id' => $iPollID, 'vote' => $iVoteNumber));
1127  $oZ->alert();
1128  }
1129  }
1130  }
1131 
1132  // return the poll's votes result ;
1133  header('Content-Type: application/xml; charset=utf-8');
1134  echo $this -> actionResultsList( $iPollID );
1135  }
1136 
1143  function actionSharePopup ($iEntryId = 0)
1144  {
1145  $iEntryId = (int)$iEntryId;
1146  if ( !($aDataEntry = $this -> _oDb -> getPollInfo($iEntryId)) ) {
1147  echo MsgBox(_t('_Empty'));
1148  exit;
1149  }
1150 
1151  $aDataEntry = array_shift($aDataEntry);
1152  require_once (CH_DIRECTORY_PATH_INC . "shared_sites.inc.php");
1153 
1154  $sEntryUrl = CH_WSB_URL_ROOT . $this -> _oConfig -> getBaseUri()
1155  . '&action=show_poll_info&id=' . $aDataEntry['id_poll'];
1156 
1157  $aSitesPrepare = getSitesArray ($sEntryUrl);
1158  $sIconsUrl = getTemplateIcon('digg.png');
1159  $sIconsUrl = str_replace('digg.png', '', $sIconsUrl);
1160  $aSites = array ();
1161  foreach ($aSitesPrepare as $k => $r) {
1162  $aSites[] = array (
1163  'icon' => $sIconsUrl . $r['icon'],
1164  'name' => $k,
1165  'url' => $r['url'],
1166  );
1167  }
1168 
1169  $aVarsContent = array (
1170  'ch_repeat:sites' => $aSites,
1171  );
1172  $aVarsPopup = array (
1173  'title' => _t('_Share'),
1174  'content' => $this->_oTemplate->parseHtmlByName('popup_share.html', $aVarsContent),
1175  );
1176 
1177  header('Content-Type: text/html; charset=utf-8');
1178  echo $GLOBALS['oFunctions']->transBox($this->_oTemplate->parseHtmlByName('popup.html', $aVarsPopup), true);
1179  exit;
1180  }
1181 
1188  {
1189  $iPollId = (int)$iPollId;
1190  $bResult = $this->deletePoll($iPollId);
1191 
1192  $aTemplateKeys = array(
1193  'answer' => $bResult ? 'ok' : _t('_Error Occured'),
1194  );
1195 
1196  header('Content-Type: application/xml');
1197  $this -> _oTemplate -> _bCacheEnable = false;
1198  echo $this -> _oTemplate -> parseHtmlByName( $this -> aUsedTemplates['server_answer'], $aTemplateKeys );
1199  }
1200 
1208  function actionGetPollBlock($iPollId, $bViewMode = false)
1209  {
1210  $aPollInfo = $this -> _oDb -> getPollInfo( (int) $iPollId );
1211  $aPoll = array_shift($aPollInfo);
1212 
1213  header('Content-Type: application/xml; charset=utf-8');
1214  echo $this -> getPollBlock($aPoll, true, $bViewMode) ;
1215  }
1216 
1220  function actionViewCalendar($iYear = 0, $iMonth = 0, $iDay = 0)
1221  {
1222  global $_page;
1224 
1225  $sCaption = _t('_ch_poll_browse_by_day')
1226  . ': ' . getLocaleDate( strtotime("{$iYear}-{$iMonth}-{$iDay}"), CH_WSB_LOCALE_DATE_SHORT);
1227 
1228  $iIndex = 57;
1229  $_page['name_index'] = $iIndex;
1230  $_page['css_name'] = 'main.css';
1231  $_page['header'] = $sCaption ;
1232  $_page['header_text'] = $sCaption ;
1233 
1234  $sSearchResult = $this -> searchByDate($sCaption, $iYear, $iMonth, $iDay);
1235  $_page_cont[$iIndex]['page_main_code'] = $sSearchResult;
1236 
1237  PageCode($this -> _oTemplate);
1238  }
1239 
1240  function actionCalendar($iYear = null, $iMonth = null )
1241  {
1242  global $_page;
1243 
1244  $sPageCaption = _t('_ch_poll_calendar');
1245 
1246  $_page['header'] = $sPageCaption ;
1247  $_page['header_text'] = $sPageCaption ;
1248 
1249  $this -> getCustomActionButton();
1250  $oCalendar = new ChPollCalendar($iYear, $iMonth, $this->_oDb, $this->_oTemplate, $this->_oConfig);
1251  $sCode = $oCalendar->display();
1252  $this->_oTemplate->pageCode($this->aPageTmpl, array('page_main_code' => $sCode));
1253  }
1254 
1255  function actionCategories()
1256  {
1257  $this -> getCustomActionButton();
1258  ch_import('ChTemplCategoriesModule');
1259 
1260  $aParam = array(
1261  'type' => 'ch_poll'
1262  );
1263 
1264  $oCateg = new ChTemplCategoriesModule($aParam, '', CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'categories');
1265  $sCode = $oCateg->getCode();
1266  $this -> _oTemplate -> defaultPage( _t('_ch_poll_categories'), $sCode);
1267  }
1268 
1275  function actionTag($sTag = '')
1276  {
1277  $sProccessed = uri2title($sTag);
1278  $sExtraParam = 'tag/' . urlencode($sTag);
1279 
1280  $this -> _oTemplate -> addCss('main.css');
1281  echo $this -> _oTemplate -> defaultPage( _t('_ch_poll_view_tag')
1282  , $this -> searchTags($sProccessed, $sExtraParam ) );
1283  }
1284 
1290  function actionTags()
1291  {
1292  $this -> getCustomActionButton();
1293  ch_import('ChTemplTagsModule');
1294 
1295  $aParam = array(
1296  'type' => 'ch_poll',
1297  'pagination' => ( isset($_GET['per_page']) )
1298  ? (int) $_GET['per_page']
1299  : getParam('tags_perpage_browse'),
1300  );
1301 
1302  $oTags = new ChTemplTagsModule($aParam, '', CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'tags');
1303  $sCode = $oTags->getCode();
1304  $this -> _oTemplate -> defaultPage( _t('_ch_poll_tags'), $sCode);
1305  }
1306 
1307  function getAdminForm()
1308  {
1309  ch_import('ChTemplSearchResult');
1310 
1311  $oNewSearchresult = new ChTemplSearchResult();
1312 
1313  $aPolls = array();
1314  $aPollsList = array();
1315 
1316  $iPage = ( isset($_GET['page']) )
1317  ? (int) $_GET['page']
1318  : 1;
1319 
1320  $iPerPage = ( isset($_GET['per_page']) )
1321  ? (int) $_GET['per_page']
1322  : 6;
1323 
1324  if ( $iPerPage > 100 ) {
1325  $iPerPage = 100;
1326  }
1327 
1328  if ($iPerPage <= 0 ) {
1329  $iPerPage = 6;
1330  }
1331 
1332  if ( !$iPage ) {
1333  $iPage = 1;
1334  }
1335 
1336  // proccessed all post datas ;
1337  if ( isset($_POST['poll_id']) and is_array($_POST['poll_id']) ) {
1338  foreach($_POST['poll_id'] as $iKey => $iValue ) {
1339  $iValue = (int) $iValue;
1340 
1341  // set as approved;
1342  if (isset($_POST['approve']) || isset($_POST['disapprove']))
1343  {
1344  $this -> _oDb -> setOption($iValue);
1345  } else if( isset($_POST['delete']))
1346  {
1347  $this->deletePoll($iValue);
1348  } else if(isset($_POST['featured']) || isset($_POST['unfeatured']))
1349  $this -> _oDb -> setOption($iValue, 'featured');
1350 
1351  $oTag = new ChWsbTags();
1352  $oTag -> reparseObjTags('ch_poll', $iValue);
1353 
1354  $oCateg = new ChWsbCategories();
1355  $oCateg->reparseObjTags('ch_poll', $iValue);
1356  }
1357  }
1358 
1359  $aLanguageKeys = array
1360  (
1361  'premoderation' => _t('_ch_poll_moderation'),
1362  'select_all' => _t('_ch_poll_select_all'),
1363  'approve' => _t('_ch_poll_approve'),
1364  'disapprove' => _t('_ch_poll_disapprove'),
1365 
1366  'delete' => _t('_ch_poll_delete'),
1367  'sure' => _t('_Are_you_sure'),
1368  'featured' => _t('_ch_poll_featured'),
1369  'unfeatured' => _t('_ch_poll_unfeatured'),
1370  );
1371 
1372  // get only the member's polls ;
1373  $iTotalNum = $this -> _oDb -> getPollsCount(0, true);
1374 
1375  if(!$iTotalNum)
1376  $sOutputHtml = MsgBox(_t( '_Empty' ));
1377 
1378  $sLimitFrom = ( $iPage - 1 ) * $iPerPage;
1379  $sqlLimit = "LIMIT {$sLimitFrom}, {$iPerPage}";
1380 
1381  $aPolls = $this->_oDb -> getAllPolls($sqlLimit, 0, true);
1382  foreach($aPolls as $iKey => $aItems)
1383  $aPollsList[] = array (
1384  'poll' => $this->getPollBlock($aItems, false, false, true),
1385  );
1386 
1387  // generate init page ;
1388  $sInitPart = $this -> getInitPollPage();
1389 
1390  // generate page pagination ;
1391  $sRequest = $this -> sPathToModule . 'administration&amp;page={page}&amp;per_page={per_page}';
1392  $oPaginate = new ChWsbPaginate
1393  (
1394  array
1395  (
1396  'page_url' => $sRequest,
1397  'count' => $iTotalNum,
1398  'per_page' => $iPerPage,
1399  'sorting' => null,
1400  'page' => $iPage,
1401  )
1402  );
1403 
1404  $sPagination = $oPaginate -> getPaginate();
1405 
1406  // generate needed buttons;
1407  $aButtons = array(
1408  'approve' => $aLanguageKeys['approve'],
1409  'disapprove' => $aLanguageKeys['disapprove'],
1410  'featured' => $aLanguageKeys['featured'],
1411  'unfeatured' => $aLanguageKeys['unfeatured'],
1412 
1413  'delete' => array(
1414  'type' => 'submit',
1415  'name' => 'delete',
1416  'value' => $aLanguageKeys['delete'],
1417  'onclick' => 'onclick="return confirm(\'' . $aLanguageKeys['sure'] . '\')"',
1418  ),
1419  );
1420 
1421  $sButtons = $oNewSearchresult -> showAdminActionsPanel('poll_form', $aButtons, 'poll_id');
1422 
1423  if (isset($GLOBALS['oAdmTemplate'])) {
1424  $GLOBALS['oAdmTemplate']->addDynamicLocation($this->_oConfig->getHomePath(), $this->_oConfig->getHomeUrl());
1425  $GLOBALS['oAdmTemplate'] -> addCss('main.css');
1426  }
1427 
1428  // generate template ;
1429  $aTemplateKeys = array (
1430  'action' => $this -> sPathToModule . 'administration&amp;page=' . $iPage . '&amp;per_page=' . $iPerPage,
1431 
1432  'init_js' => $sInitPart,
1433  'js_file' => $this -> _oTemplate -> addJs( 'profile_poll.js', true ),
1434 
1435  'ch_repeat:polls' => $aPollsList,
1436  'pagination' => $sPagination,
1437  'admin_panel' => $sButtons,
1438  );
1439 
1440  $sOutputHtml .= $this -> _oTemplate -> parseHtmlByName( $this -> aUsedTemplates['poll_premoderation'], $aTemplateKeys );
1441 
1442  $sOutputHtml = '<div id="pol_container">' . $sOutputHtml . '</div>';
1443  return $sOutputHtml;
1444  }
1445 
1451  function actionAdministration()
1452  {
1453  $GLOBALS['iAdminPage'] = 1;
1454 
1455  if( !isAdmin() ) {
1456  header('location: ' . CH_WSB_URL_ROOT);
1457  }
1458 
1459  $aLanguageKeys = array(
1460  'premoderation' => _t('_ch_poll_tags_premoderation'),
1461  );
1462 
1463  $aMenu = array(
1464  'ch_poll_main' => array('title' => _t('_ch_poll_main'), 'href' => $this -> sPathToModule . 'administration&action=main'),
1465  'ch_poll_settings' => array('title' => _t('_ch_poll_settings'), 'href' => $this -> sPathToModule . 'administration&action=settings'),
1466  );
1467 
1468  $sAction = ( isset($_GET['action']) ) ? $_GET['action'] : null;
1469 
1470  switch ($sAction) {
1471  case 'main':
1472  $aMenu['ch_poll_main']['active'] = 1;
1473  $sContent = $this -> getAdminForm();
1474  break;
1475  case 'settings':
1476  $aMenu['ch_poll_settings']['active'] = 1;
1477  $sContent = $this -> getSettingsForm();
1478  break;
1479  default:
1480  $aMenu['ch_poll_main']['active'] = 1;
1481  $sContent = $this -> getAdminForm();
1482  }
1483 
1484  $this -> _oTemplate-> pageCodeAdminStart();
1485  echo $this -> _oTemplate -> adminBlock ($sContent, $aLanguageKeys['premoderation'], $aMenu);
1486  $this -> _oTemplate->pageCodeAdmin( _t('_ch_poll_module') );
1487  }
1488 
1494  function actionSetOption($iPollId, $sAction = 'approval')
1495  {
1496  $iPollId = (int)$iPollId;
1497  if ($iPollId)
1498  {
1499  $iActionerId = getLoggedId();
1500  $sJQueryJS = genAjaxyPopupJS($iPollId);
1501  if (isAdmin($iActionerId) || isModerator($iActionerId))
1502  {
1503  if (!$this->_oDb ->setOption($iPollId, $sAction))
1504  $sMsg = '_Error';
1505  else
1506  $sMsg = '_Saved';
1507  }
1508  else
1509  $sMsg = '_Access denied';
1510  header('Content-Type: text/html; charset=UTF-8');
1511  echo MsgBox(_t($sMsg)) . $sJQueryJS;
1512  exit;
1513  }
1514  }
1520  function getSettingsForm()
1521  {
1522  $iId = $this-> _oDb -> getSettingsCategory('enable_poll');
1523  if(!$iId) {
1524  return MsgBox( _t('_Empty') );
1525  }
1526 
1527  ch_import('ChWsbAdminSettings');
1528 
1529  $mixedResult = '';
1530  if(isset($_POST['save']) && isset($_POST['cat'])) {
1531  $oSettings = new ChWsbAdminSettings($iId);
1532  $mixedResult = $oSettings -> saveChanges($_POST);
1533  }
1534 
1535  $oSettings = new ChWsbAdminSettings($iId);
1536  $sResult = $oSettings->getForm();
1537 
1538  if($mixedResult !== true && !empty($mixedResult))
1539  $sResult = $mixedResult . $sResult;
1540 
1541  return $GLOBALS['oAdmTemplate']
1542  -> parseHtmlByName( 'design_box_content.html', array('content' => $sResult) );
1543  }
1544 
1553  function searchTags($sTag, $sExtraParam = '', $bUseInitPart = true)
1554  {
1555  $sOutputCode = '';
1556 
1557  //concat init part;
1558  if($bUseInitPart) {
1559  $sOutputCode = $this -> getInitPollPage();
1560  }
1561 
1562  $this -> oSearch -> aCurrent['restriction']['tag']['value'] = $sTag;
1563 
1564  !$sExtraParam ? $sExtraParam = '&tag=' . urlencode( title2uri($sTag) ) : '';
1565  $sOutputCode .= $this
1566  -> showSearchResult( _t('_ch_poll_browse_tag') . ': ' . htmlspecialchars_adv($sTag), $sExtraParam );
1567 
1568  return $sOutputCode;
1569  }
1570 
1579  function searchCategories($sCategory, $sExtraParam = null, $bUseInitPart = true)
1580  {
1581  $sOutputCode = null;
1582 
1583  //concat init part;
1584  if($bUseInitPart) {
1585  $sOutputCode = $this -> getInitPollPage();
1586  }
1587 
1588  $this -> oSearch -> aCurrent['restriction']['category']['value'] = $sCategory;
1589  $sExtraParam .= '&category=' . urlencode( title2uri($sCategory) );
1590  $sOutputCode .= $this -> showSearchResult( _t('_ch_poll_browse_category')
1591  . ': ' . htmlspecialchars_adv($sCategory), $sExtraParam );
1592 
1593  return $sOutputCode;
1594  }
1595 
1602  function searchFeatured($bUseInitPart = true, $iLimit = 0)
1603  {
1604  $sOutputCode = null;
1605 
1606  //concat init part;
1607  if($bUseInitPart) {
1608  $sOutputCode = $this -> getInitPollPage();
1609  }
1610 
1611  $this -> oSearch -> aCurrent['restriction']['featured']['value'] = '1';
1612  $sOutputCode .= $this -> showSearchResult( _t('_ch_poll_featured') );
1613 
1614  return $sOutputCode;
1615  }
1616 
1623  function searchFeaturedHome($bUseInitPart = true)
1624  {
1625  $sOutputCode = null;
1626 
1627  //concat init part;
1628  if($bUseInitPart) {
1629  $sOutputCode = $this -> getInitPollPage();
1630  }
1631 
1632  $this -> oSearch -> aCurrent['restriction']['featured']['value'] = '1';
1633  $this -> oSearch -> aCurrent['paginate']['perPage'] = 1;
1634 
1635  $sOutputCode .= $this -> showSearchResult( _t('_ch_poll_featured'), null, 0, false, 1);
1636 
1637  return $sOutputCode;
1638  }
1639 
1646  function searchPopular($bUseInitPart = true)
1647  {
1648  $sOutputCode = null;
1649 
1650  //concat init part;
1651  if($bUseInitPart) {
1652  $sOutputCode = $this -> getInitPollPage();
1653  }
1654 
1655  $this -> oSearch -> aCurrent['sorting'] = 'popular';
1656  $sOutputCode .= $this -> showSearchResult( _t('_ch_poll_popular') );
1657 
1658  return $sOutputCode;
1659  }
1660 
1667  function searchMy($bUseInitPart = true)
1668  {
1669  $sOutputCode = null;
1670  $sMemberPanel = $this -> genMemberAdministration();
1671 
1672  //concat init part;
1673  if($bUseInitPart) {
1674  $sOutputCode = $this -> getInitPollPage();
1675  }
1676 
1677  $this -> oSearch -> aCurrent['restriction']['my']['value'] = $this -> aPollSettings['member_id'];
1678  $this -> oSearch -> aCurrent['restriction']['activeStatus']['value'] = '';
1679 
1680  if($this->aPollSettings['mode'] != 'manage' && $this->aPollSettings['mode'] != 'pending')
1681  $sOutputCode .= $this -> showSearchResult( _t('_ch_poll_my') );
1682 
1683  return $sMemberPanel . $sOutputCode;
1684  }
1685 
1694  function searchAll($iLimit = 0, $iPerLine = 0, $bUseInitPart = true, $sCaption = null, $bShowEmptyMsg = true)
1695  {
1696  $sOutputCode = null;
1697 
1698  $this -> oSearch -> aCurrent['restriction']['unfeatured']['value'] = 0;
1699 
1700  //concat init part;
1701  if($bUseInitPart) {
1702  $sOutputCode = $this -> getInitPollPage();
1703  }
1704 
1705  $sPageCaption = $sCaption ? _t($sCaption) : _t('_ch_poll_latest');
1706 
1707  $sOutputCode .= $this -> showSearchResult( $sPageCaption
1708  , null, ($iLimit) ? $iLimit : 0, ($iLimit) ? false : true, $iPerLine, true, $bShowEmptyMsg);
1709 
1710  return $sOutputCode;
1711  }
1712 
1720  function searchProfilePolls($iProfileId, $iLimit = 6, $bUseInitPart = true, $bShowEmptyMsg = true)
1721  {
1722  $sOutputCode = null;
1723 
1724  //concat init part;
1725  if($bUseInitPart)
1726  $sOutputCode = $this -> getInitPollPage();
1727 
1728  $this -> oSearch -> aCurrent['restriction']['my']['value'] = $iProfileId;
1729  $sOutputCode .= $this -> showSearchResult( _t('_ch_polls_profile'), null, $iLimit, false, 1, true, $bShowEmptyMsg );
1730 
1731  return $sOutputCode;
1732  }
1733 
1743  function searchAllProfilePolls($iProfileId, $iLimit = 0, $iPerLine = 0, $bUseInitPart = true)
1744  {
1745  $sOutputCode = null;
1746 
1747  $this -> oSearch -> aCurrent['restriction']['my']['value'] = $iProfileId;
1748 
1749  //concat init part;
1750  if($bUseInitPart) {
1751  $sOutputCode = $this -> getInitPollPage();
1752  }
1753 
1754  $sNickName = isset($_GET['nickname']) ? $_GET['nickname'] : null;
1755  $sExtraParam = '&nickname=' . $sNickName;
1756 
1757  $this -> oSearch -> aCurrent['sorting'] = 'popular';
1758  $sOutputCode .= $this -> showSearchResult( _t('_ch_poll_popular'), $sExtraParam );
1759 
1760  return $sOutputCode;
1761  }
1762 
1773  function searchByDate($sCaption, $iYear, $iMonth, $iDay, $bUseInitPart = true)
1774  {
1775  $sOutputCode = null;
1776 
1777  //concat init part;
1778  if($bUseInitPart) {
1779  $sOutputCode = $this -> getInitPollPage();
1780  }
1781 
1782  $oCalendar = new ChPollCalendar($iYear, $iMonth, $this->_oDb, $this->_oTemplate, $this->_oConfig);
1783 
1784  $iYear = (int) $iYear;
1785  $iMonth = (int) $iMonth;
1786  $iDay = (int) $iDay;
1787  $iNextDay = $iDay + 1;
1788 
1789  $this -> oSearch -> aCurrent['restriction']['calendar-min']['value'] = "UNIX_TIMESTAMP('{$iYear}-{$iMonth}-{$iDay}')";
1790  $this -> oSearch -> aCurrent['restriction']['calendar-max']['value'] = "UNIX_TIMESTAMP('{$iYear}-{$iMonth}-{$iNextDay}')-1";
1791 
1792  $sExtraParam = $oCalendar -> sActionViewResult . "{$iYear}/{$iMonth}/{$iDay}";
1793  $sOutputCode .= $this -> showSearchResult( $sCaption, $sExtraParam );
1794 
1795  return $sOutputCode;
1796  }
1797 
1808  function showSearchResult($sBlockCaption, $sExtraParam = null, $iPerPage = 5, $bShowPagination = true, $iPerLine = 0, $bUseDesignBox = true, $bShowEmptyMsg = true)
1809  {
1810  $sOutputCode = $sPaginate = '';
1811 
1812  $this -> oSearch -> aCurrent['paginate']['perPage'] = $iPerPage ? $iPerPage : 5;
1813  if(!$bShowPagination)
1814  $this -> oSearch -> aCurrent['paginate']['page'] = 1;
1815 
1816  $aPolls = $this -> oSearch -> getSearchData();
1817 
1818  //process recived data;
1819  if( $aPolls && is_array($aPolls) ) {
1820  $sOutputCode = $this -> genPollsList($aPolls);
1821 
1822  if(!empty($sOutputCode))
1823  $sOutputCode = $this->_oTemplate->parseHtmlByName('default_margin.html', array(
1824  'content' => $sOutputCode
1825  ));
1826 
1827  if($bShowPagination)
1828  $sPaginate = $this -> oSearch -> showPagination(array('module_path' => $this -> sPathToModule . $sExtraParam));
1829  } else
1830  $sOutputCode = $bShowEmptyMsg ? MsgBox( _t('_Empty') ) : '';
1831 
1832  return ($bUseDesignBox && $sOutputCode) ? DesignBoxContent($sBlockCaption, $sOutputCode, 1, '', $sPaginate) : $sOutputCode . $sPaginate;
1833  }
1834 
1847  function createPoll($sPollQuestion, $sPollAnswers, $sPollResults, $sTags, $iCommentGroupValue, $iVoteGroupValue, $sCategory, $iViewGroupValue)
1848  {
1849  // check membership;
1850  if(!$this -> isPollCreateAlowed($this -> aPollSettings['member_id'], true) ) {
1851  return;
1852  }
1853 
1854  // ** init some needed variables ;
1855  $aPoolInfo = array();
1856 
1857  if ( !$sPollQuestion or !$sPollAnswers ) {
1858  $this -> sActionAnswer = MsgBox(POLL_EMPTY_FIELDS);
1859  } else {
1860  $aPoolInfo = array
1861  (
1862  'owner_id' => $this -> aPollSettings['member_id'],
1863  'question' => $sPollQuestion,
1864  'answers' => $sPollAnswers,
1865  'results' => $sPollResults,
1866  'tags' => $sTags,
1867  'allow_comment' => $iCommentGroupValue,
1868  'allow_vote' => $iVoteGroupValue,
1869  'category' => $sCategory,
1870  'allow_view' => $iViewGroupValue
1871  );
1872 
1873  $iResponse = $this -> _oDb -> createPoll($aPoolInfo, $this -> aPollSettings['admin_mode']);
1874  $iLastPoll = $this -> _oDb -> lastId();
1875 
1876  // define the action number ;
1877  switch($iResponse) {
1878  case '0':
1879  $this -> sActionAnswer = MsgBox(POLL_NOT_ALLOW);
1880  break;
1881 
1882  case '1' :
1883  $this -> sActionAnswer = MsgBox(POLL_CREATED);
1884  // create system event
1885  $oZ = new ChWsbAlerts('ch_poll', 'add', $iLastPoll);
1886  $oZ->alert();
1887 
1888  $oTag = new ChWsbTags();
1889  $oTag -> reparseObjTags('ch_poll', $iLastPoll);
1890 
1891  $oCateg = new ChWsbCategories();
1892  $oCateg->reparseObjTags('ch_poll', $iLastPoll);
1893  break;
1894 
1895  case '2' :
1896  $this -> sActionAnswer = MsgBox(POLL_MAX_REACHED);
1897  break;
1898  }
1899  }
1900  }
1901 
1912  function editPoll($iPollId, $sPollQuestion, $sPollAnswers, $sCategory, $bActive = true, $bApprove = false, $sTags = null, $iCommentGroupValue = 3, $iVoteGroupValue = 3, $iViewGroupValue = 3)
1913  {
1914  if ( !$sPollQuestion or !$sPollAnswers ) {
1915  $this -> sActionAnswer = MsgBox(POLL_EMPTY_FIELDS);
1916  } else {
1917  // check poll's owner Id;
1918  $aPoolInfo = $this -> _oDb -> getPollInfo( $iPollId );
1919 
1920  if ( $this -> aPollSettings['admin_mode']
1921  or ( $this -> aPollSettings['member_id']
1922  and $aPoolInfo[0]['id_profile'] == $this -> aPollSettings['member_id']) ) {
1923 
1924  $aPoolInfo = array
1925  (
1926  'question' => $sPollQuestion,
1927  'answers' => $sPollAnswers,
1928  'status' => ( $bActive ) ? 'active' : null,
1929  'Id' => $iPollId,
1930  'tags' => $sTags,
1931  'allow_comment' => $iCommentGroupValue,
1932  'allow_vote' => $iVoteGroupValue,
1933  'category' => $sCategory,
1934  'allow_view' => $iViewGroupValue,
1935  );
1936 
1937  if ( $this -> aPollSettings['admin_mode'] ) {
1938  $aPoolInfo['approve'] = ( $bApprove ) ? true : false;
1939  }
1940 
1941  $this -> _oDb -> editPoll($aPoolInfo);
1942  $this -> sActionAnswer = MsgBox(POLL_EDITED);
1943 
1944  // create system event
1945  $oZ = new ChWsbAlerts('ch_poll', 'edit', $iPollId);
1946  $oZ->alert();
1947 
1948  // reparse poll's tags;
1949  $oTag = new ChWsbTags();
1950  $oTag -> reparseObjTags('ch_poll', $iPollId);
1951 
1952  $oCateg = new ChWsbCategories();
1953  $oCateg->reparseObjTags('ch_poll', $iPollId);
1954  } else {
1955  $this -> sActionAnswer = MsgBox(POLL_NOT_ALLOW);
1956  }
1957  }
1958  }
1959 
1960  function deletePoll($iId)
1961  {
1962  $aPoll = $this->_oDb->getPollInfo($iId);
1963  if(empty($aPoll) || !is_array($aPoll))
1964  return false;
1965 
1966  $aPoll = array_shift($aPoll);
1967  if(!isLogged() || (!isAdmin() && $aPoll['id_profile'] != getLoggedId()))
1968  return false;
1969 
1970  $this->_oDb->deletePoll($iId);
1971 
1972  $oTag = new ChWsbTags();
1973  $oTag -> reparseObjTags('ch_poll', $iId);
1974 
1975  $oCateg = new ChWsbCategories();
1976  $oCateg->reparseObjTags('ch_poll', $iId);
1977 
1978  //delete all subscriptions
1979  $oSubscription = ChWsbSubscription::getInstance();
1980  $oSubscription->unsubscribe(array('type' => 'object_id', 'unit' => 'ch_poll', 'object_id' => $iId));
1981 
1982  // create system event
1983  $oZ = new ChWsbAlerts('ch_poll', 'delete_poll', $iId);
1984  $oZ->alert();
1985 
1986  return true;
1987  }
1988 
1996  function serviceGetPolls($sAction, $iProfileId = 0)
1997  {
1998  // concat css file;
1999  $this -> _oTemplate -> addCss('main.css');
2000 
2001  switch($sAction) {
2002 
2003  // for profile's page;
2004  case 'get_profile_polls' :
2005  if($iProfileId) {
2006  $iRowsLimit = $this -> _oConfig -> iProfilePagePollsCount;
2007  $sOutputCode = $this -> searchProfilePolls($iProfileId, $iRowsLimit, true, false);
2008  }
2009  break;
2010 
2011  // for index page;
2012  case 'get_polls' :
2013  $aVis = array(CH_WSB_PG_ALL);
2014  if ($this->getUserId())
2015  $aVis[] = CH_WSB_PG_MEMBERS;
2016  $this -> oSearch -> aCurrent['restriction']['allow_view']['value'] = $aVis;
2017  $iRowsLimit = $this ->_oConfig -> iIndexPagePollsCount;
2018  $sOutputCode = $this -> searchAll($iRowsLimit, 1, true, '_ch_polls_public', false);
2019  break;
2020  }
2021 
2022  echo $sOutputCode;
2023  }
2024 
2025  function serviceGetMemberMenuLink($iMemberId = false)
2026  {
2027  if (false === $iMemberId)
2028  $iMemberId = getLoggedId();
2029 
2030  $oMemberMenu = ch_instance('ChWsbMemberMenu');
2031 
2032  $aLinkInfo = array(
2033  'item_img_src' => 'tasks',
2034  'item_img_alt' => _t( '_ch_polls' ),
2035  'item_link' => $this -> sPathToModule . '&action=my',
2036  'item_title' => _t( '_ch_polls' ),
2037  'extra_info' => count($this -> _oDb -> getAllPolls(null, $iMemberId)), // number of member's polls
2038  );
2039 
2040  return $oMemberMenu -> getGetExtraMenuLink($aLinkInfo);
2041  }
2042 
2043  function serviceGetMemberMenuLinkAddContent($iMemberId = false)
2044  {
2045  if (false === $iMemberId)
2046  $iMemberId = getLoggedId();
2047 
2048  if (!$this -> isPollCreateAlowed($iMemberId))
2049  return '';
2050 
2051  $oMemberMenu = ch_instance('ChWsbMemberMenu');
2052 
2053  $aLinkInfo = array(
2054  'item_img_src' => 'tasks',
2055  'item_img_alt' => _t( '_ch_poll' ),
2056  'item_link' => $this -> sPathToModule . '&action=my&mode=add',
2057  'item_title' => _t( '_ch_poll' ),
2058  );
2059 
2060  return $oMemberMenu -> getGetExtraMenuLink($aLinkInfo);
2061  }
2062 
2066  function serviceEditActionButton($iMemberId, $iPollId)
2067  {
2068  $sEditLink = null;
2069 
2070  $aPollInfo = $this -> _oDb -> getPollInfo( (int) $iPollId);
2071  $aPollInfo = array_shift($aPollInfo);
2072 
2073  if($aPollInfo['id_profile'] == $iMemberId || isAdmin() ){
2074  $sEditLink = $this -> sPathToModule . '&action=my&mode=edit_poll&edit_poll_id=' . $iPollId;
2075  }
2076 
2077  return $sEditLink;
2078  }
2079 
2083  function serviceDeleteActionButton($iMemberId, $iPollId)
2084  {
2085  $sDeleteLink = null;
2086 
2087  $aPollInfo = $this -> _oDb -> getPollInfo( (int) $iPollId);
2088  $aPollInfo = array_shift($aPollInfo);
2089 
2090  if($aPollInfo['id_profile'] == $iMemberId || isAdmin() ){
2091  $sDeleteLink = $this -> sPathToModule . '&action=delete_poll&id=' . $iPollId;
2092  }
2093 
2094  return $sDeleteLink;
2095  }
2096 
2097  function serviceGetSubscriptionParams ($sAction, $iEntryId)
2098  {
2099  $aDataEntry = $this->_oDb->getPollInfo($iEntryId);
2100  $aDataEntry = array_shift($aDataEntry);
2101  if(empty($aDataEntry) || (int)$aDataEntry['poll_approval'] == 0) {
2102  return array('skip' => true);
2103  }
2104 
2105  $aActionList = array(
2106  'commentPost' => '_ch_poll_sbs_comment'
2107  );
2108 
2109  $sActionName = isset($aActionList[$sAction]) ? ' (' . _t($aActionList[$sAction]) . ')' : '';
2110  return array (
2111  'skip' => false,
2112  'template' => array (
2113  'Subscription' => $aDataEntry['poll_question'] . $sActionName,
2114  'ViewLink' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . '&action=show_poll_info&id=' . $aDataEntry['id_poll'],
2115  ),
2116  );
2117  }
2118 
2119  function serviceGetWallPost($aEvent)
2120  {
2121  $aItem = $this->_oDb->getPollInfo((int)$aEvent['object_id']);
2122  if(empty($aItem))
2123  return array('perform_delete' => true);
2124 
2125  $aItem = array_shift($aItem);
2126 
2127  $iOwner = 0;
2128  if(!empty($aEvent['owner_id']))
2129  $iOwner = (int)$aEvent['owner_id'];
2130 
2131  $iDate = 0;
2132  if(!empty($aEvent['date']))
2133  $iDate = (int)$aEvent['date'];
2134 
2135  $bItem = !empty($aItem) && is_array($aItem);
2136  if($iOwner == 0 && $bItem && !empty($aItem['id_profile']))
2137  $iOwner = (int)$aItem['id_profile'];
2138 
2139  if($iDate == 0 && $bItem && !empty($aItem['poll_date']))
2140  $iDate = (int)$aItem['poll_date'];
2141 
2142  if($iOwner == 0 || !$bItem)
2143  return '';
2144 
2145  $aProfile = getProfileInfo($iOwner);
2146  if(empty($aProfile) || (int)$aItem['poll_approval'] != 1 || !$this->oPrivacy->check('view', (int)$aEvent['object_id'], getLoggedId()))
2147  return '';
2148 
2149  $sJs = $sCss = $sInit = '';
2150  $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/';
2151  if($aEvent['js_mode']) {
2152  $sJs = $this->_oTemplate->addJs(array('profile_poll.js'), true);
2153  $sCss = $this->_oTemplate->addCss(array('main.css', 'wall_post.css'), true);
2154  } else {
2155  $this->_oTemplate->addJs(array('profile_poll.js'));
2156  $this->_oTemplate->addCss(array('main.css', 'wall_post.css'));
2157  }
2158 
2159  $sInit = $this->getInitPollPage();
2160  $sOwner = getNickName($iOwner);
2161 
2162  //--- Single public event
2163  $aItem['url'] = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . '&action=show_poll_info&id=' . $aItem['id_poll'];
2164 
2165  $sTextWallObject = _t('_ch_poll_wall_object');
2166  return array(
2167  'owner_id' => $iOwner,
2168  'title' => _t('_ch_poll_wall_added_new_title', $sOwner, $sTextWallObject),
2169  'description' => $aItem['poll_question'],
2170  'content' => $sJs . $sCss . $sInit . $this->_oTemplate->parseHtmlByName('wall_post.html', array(
2171  'cpt_user_name' => $sOwner,
2172  'cpt_added_new' => _t('_ch_poll_wall_added_new'),
2173  'cpt_object' => $sTextWallObject,
2174  'cpt_item_url' => $aItem['url'],
2175  'cnt_item_page' => $aItem['url'],
2176  'cnt_item_title' => $aItem['poll_question'],
2177  'cnt_item_id' => $aItem['id_poll'],
2178  'post_id' => $aEvent['id'],
2179  )),
2180  'date' => $iDate
2181  );
2182  }
2183 
2184  function serviceGetWallPostOutline($aEvent)
2185  {
2186  $aItem = $this->_oDb->getPollInfo((int)$aEvent['object_id']);
2187  if(empty($aItem))
2188  return array('perform_delete' => true);
2189 
2190  $aItem = array_shift($aItem);
2191  $aProfile = getProfileInfo((int)$aEvent['owner_id']);
2192  if(empty($aProfile) || (int)$aItem['poll_approval'] != 1 || !$this->oPrivacy->check('view', (int)$aEvent['object_id'], getLoggedId()))
2193  return '';
2194 
2195  $sCss = '';
2196  $sPrefix = 'ch_' . $this->_oConfig->getUri();
2197  if($aEvent['js_mode'])
2198  $sCss = $this->_oTemplate->addCss('wall_outline.css', true);
2199  else
2200  $this->_oTemplate->addCss('wall_outline.css');
2201 
2202  $iOwner = (int)$aEvent['owner_id'];
2203  $sOwner = getNickName($iOwner);
2204  $sOwnerLink = getProfileLink($iOwner);
2205 
2206  //--- Single public event
2207  $aItem['poll_url'] = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . '&action=show_poll_info&id=' . $aItem['id_poll'];
2208 
2209  return array(
2210  'content' => $sCss . $this->_oTemplate->parseHtmlByName('modules/cheetah/wall/|outline_item_text.html', array(
2211  'mod_prefix' => $sPrefix,
2212  'mod_icon' => 'tasks',
2213  'user_name' => $sOwner,
2214  'user_link' => $sOwnerLink,
2215  'item_page' => $aItem['poll_url'],
2216  'item_title' => $aItem['poll_question'],
2217  'item_description' => $this->_getWallContent($aItem),
2218  'item_comments' => (int)$aItem['poll_comments_count'] > 0 ? _t('_wall_n_comments', $aItem['poll_comments_count']) : _t('_wall_no_comments'),
2219  'item_comments_link' => $aItem['poll_url'] . '#cmta-' . $sPrefix . '-' . $aItem['id'],
2220  'post_id' => $aEvent['id'],
2221  'post_ago' => $aEvent['ago']
2222  ))
2223  );
2224  }
2225 
2226  function serviceGetWallAddComment($aEvent)
2227  {
2228  $iId = (int)$aEvent['object_id'];
2229  $iOwner = (int)$aEvent['owner_id'];
2230  $sOwner = $iOwner != 0 ? getNickName($iOwner) : _t('_Anonymous');
2231 
2232  $aContent = unserialize($aEvent['content']);
2233  if(empty($aContent) || empty($aContent['object_id']))
2234  return '';
2235 
2236  $iItem = (int)$aContent['object_id'];
2237  $aItem = $this->_oDb->getPollInfo($iItem);
2238  if(empty($aItem) || !is_array($aItem))
2239  return array('perform_delete' => true);
2240 
2241  if(!$this->oPrivacy->check('view', $iItem, getLoggedId()))
2242  return '';
2243 
2244  ch_import('ChTemplCmtsView');
2245  $oCmts = new ChTemplCmtsView('ch_poll', $iItem);
2246  if(!$oCmts->isEnabled())
2247  return '';
2248 
2249  $aComment = $oCmts->getCommentRow($iId);
2250  if(empty($aComment) || !is_array($aComment))
2251  return array('perform_delete' => true);
2252 
2253  $sCss = '';
2254  if($aEvent['js_mode'])
2255  $sCss = $this->_oTemplate->addCss('wall_post.css', true);
2256  else
2257  $this->_oTemplate->addCss('wall_post.css');
2258 
2259  $aItem = array_shift($aItem);
2260  $aItem['url'] = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . '&action=show_poll_info&id=' . $aItem['id_poll'];
2261 
2262  $sTextWallObject = _t('_ch_poll_wall_object');
2263  return array(
2264  'title' => _t('_ch_poll_wall_added_new_title_comment', $sOwner, $sTextWallObject),
2265  'description' => $aComment['cmt_text'],
2266  'content' => $sCss . $this->_oTemplate->parseHtmlByName('wall_post_comment.html', array(
2267  'cpt_user_name' => $sOwner,
2268  'cpt_added_new' => _t('_ch_poll_wall_added_new_comment'),
2269  'cpt_object' => $sTextWallObject,
2270  'cpt_item_url' => $aItem['url'],
2271  'cnt_comment_text' => $aComment['cmt_text'],
2272  'cnt_item_page' => $aItem['url'],
2273  'cnt_item_title' => $aItem['poll_question'],
2274  'cnt_item_description' => $this->_getWallContent($aItem),
2275  'post_id' => $aEvent['id'],
2276  ))
2277  );
2278  }
2279 
2283  function serviceGetWallPostComment($aEvent)
2284  {
2285  $iId = (int)$aEvent['object_id'];
2286  $iOwner = (int)$aEvent['owner_id'];
2287  $sOwner = getNickName($iOwner);
2288 
2289  $aItem = $this->_oDb->getPollInfo($iId);
2290  if(empty($aItem))
2291  return array('perform_delete' => true);
2292 
2293  if(!$this->oPrivacy->check('view', $iId, getLoggedId()))
2294  return '';
2295 
2296  $aContent = unserialize($aEvent['content']);
2297  if(empty($aContent) || !isset($aContent['comment_id']))
2298  return '';
2299 
2300  ch_import('ChTemplCmtsView');
2301  $oCmts = new ChTemplCmtsView('ch_poll', $iId);
2302  if(!$oCmts->isEnabled())
2303  return '';
2304 
2305  $aItem = array_shift($aItem);
2306  $aItem['url'] = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . '&action=show_poll_info&id=' . $aItem['id_poll'];
2307  $aComment = $oCmts->getCommentRow((int)$aContent['comment_id']);
2308  if(empty($aComment) || !is_array($aComment))
2309  return array('perform_delete' => true);
2310 
2311  $sCss = '';
2312  if($aEvent['js_mode'])
2313  $sCss = $this->_oTemplate->addCss('wall_post.css', true);
2314  else
2315  $this->_oTemplate->addCss('wall_post.css');
2316 
2317  $sTextWallObject = _t('_ch_poll_wall_object');
2318  return array(
2319  'title' => _t('_ch_poll_wall_added_new_title_comment', $sOwner, $sTextWallObject),
2320  'description' => $aComment['cmt_text'],
2321  'content' => $sCss . $this->_oTemplate->parseHtmlByName('wall_post_comment.html', array(
2322  'cpt_user_name' => $sOwner,
2323  'cpt_added_new' => _t('_ch_poll_wall_added_new_comment'),
2324  'cpt_object' => $sTextWallObject,
2325  'cpt_item_url' => $aItem['url'],
2326  'cnt_comment_text' => $aComment['cmt_text'],
2327  'cnt_item_page' => $aItem['url'],
2328  'cnt_item_title' => $aItem['poll_question'],
2329  'cnt_item_description' => $this->_getWallContent($aItem),
2330  'post_id' => $aEvent['id'],
2331  ))
2332  );
2333  }
2334 
2335  function serviceGetWallData ()
2336  {
2337  $sUri = $this->_oConfig->getUri();
2338  $aName = 'ch_' . $sUri;
2339 
2340  return array(
2341  'handlers' => array(
2342  array('alert_unit' => $aName, 'alert_action' => 'add', 'module_uri' => $sUri, 'module_class' => 'Module', 'module_method' => 'get_wall_post', 'groupable' => 0, 'group_by' => '', 'timeline' => 1, 'outline' => 1),
2343  array('alert_unit' => $aName, 'alert_action' => 'comment_add', 'module_uri' => $sUri, 'module_class' => 'Module', 'module_method' => 'get_wall_add_comment', 'groupable' => 0, 'group_by' => '', 'timeline' => 1, 'outline' => 0),
2344 
2345  //DEPRICATED, saved for backward compatibility
2346  array('alert_unit' => $aName, 'alert_action' => 'commentPost', 'module_uri' => $sUri, 'module_class' => 'Module', 'module_method' => 'get_wall_post_comment', 'groupable' => 0, 'group_by' => '', 'timeline' => 1, 'outline' => 0)
2347  ),
2348  'alerts' => array(
2349  array('unit' => $aName, 'action' => 'add')
2350  )
2351  );
2352  }
2353 
2354  function _getWallContent($aItem, $bAsArray = false)
2355  {
2356  $aItemAns = explode(CH_POLL_ANS_DIVIDER, trim($aItem['poll_answers'], CH_POLL_ANS_DIVIDER));
2357  $iItemAns = count($aItemAns);
2358  $aItemRes = explode(CH_POLL_RES_DIVIDER, trim($aItem['poll_results'], CH_POLL_RES_DIVIDER));
2359  $iItemTotal = (int)$aItem['poll_total_votes'];
2360 
2361  $aResult = array();
2362  for($i = 0; $i < $iItemAns; $i++)
2363  if(!empty($aItemAns[$i]))
2364  $aResult[] = array(
2365  'answer' => $aItemAns[$i],
2366  'result' => round(($iItemTotal != 0 ? 100 * ($aItemRes[$i] / $iItemTotal) : 0), 1)
2367  );
2368 
2369  return $bAsArray ? $aResult : $this->_oTemplate->parseHtmlByName('poll_answers.html', array('ch_repeat:items' => $aResult));
2370  }
2371 
2372  function serviceGetSpyData ()
2373  {
2374  return array(
2375  'handlers' => array(
2376  array('alert_unit' => 'ch_poll', 'alert_action' => 'add', 'module_uri' => 'poll', 'module_class' => 'Module', 'module_method' => 'get_spy_post'),
2377  array('alert_unit' => 'ch_poll', 'alert_action' => 'answered', 'module_uri' => 'poll', 'module_class' => 'Module', 'module_method' => 'get_spy_post'),
2378  array('alert_unit' => 'ch_poll', 'alert_action' => 'rate', 'module_uri' => 'poll', 'module_class' => 'Module', 'module_method' => 'get_spy_post'),
2379  array('alert_unit' => 'ch_poll', 'alert_action' => 'commentPost', 'module_uri' => 'poll', 'module_class' => 'Module', 'module_method' => 'get_spy_post'),
2380  ),
2381  'alerts' => array(
2382  array('unit' => 'ch_poll', 'action' => 'add'),
2383  array('unit' => 'ch_poll', 'action' => 'answered'),
2384  array('unit' => 'ch_poll', 'action' => 'rate'),
2385  array('unit' => 'ch_poll', 'action' => 'delete_poll'),
2386  array('unit' => 'ch_poll', 'action' => 'commentPost'),
2387  array('unit' => 'ch_poll', 'action' => 'commentRemoved')
2388  )
2389  );
2390  }
2391 
2397  function serviceGetSpyPost($sAction, $iObjectId = 0, $iSenderId = 0, $aExtraParams = array())
2398  {
2399  $aRet = array();
2400 
2401  switch($sAction) {
2402  case 'add' :
2403  // define some poll's data for rendering;
2404  $sNickName = getNickName($iSenderId);
2405  $sProfileLink = getProfileLink($iSenderId);
2406 
2407  $aPollInfo = $this -> _oDb -> getPollInfo($iObjectId);
2408  $sPollCaption = $aPollInfo[0]['poll_question'];
2409  $sPollLink = $this -> sPathToModule . '&action=show_poll_info&id=' . $iObjectId;
2410 
2411  $aRet = array(
2412  'lang_key' => '_ch_poll_added',
2413  'params' => array(
2414  'profile_link' => $sProfileLink,
2415  'profile_nick' => $sNickName,
2416  'poll_url' => $sPollLink,
2417  'poll_caption' => $sPollCaption,
2418  ),
2419  'recipient_id' => 0,
2420  );
2421  break;
2422 
2423  case 'answered' :
2424  $aRet = $this -> _getSpyArray($aExtraParams['poll_id'], $iSenderId, '_ch_poll_answered', 'content_activity', $iObjectId);
2425  break;
2426 
2427  case 'rate' :
2428  $aRet = $this -> _getSpyArray($iObjectId, $iSenderId, '_ch_poll_rated');
2429  break;
2430 
2431  case 'commentPost' :
2432  $aRet = $this -> _getSpyArray($iObjectId, $iSenderId, '_ch_poll_commented');
2433  break;
2434  }
2435  return $aRet;
2436  }
2437 
2447  function _getSpyArray($iObjectId, $iSenderId, $sLangKey, $sActivityType = 'content_activity', $iRecipientId = 0)
2448  {
2449  $aRet = array();
2450 
2451  // try define the poll's owner;
2452  $aPollInfo = array_shift( $this -> _oDb -> getPollInfo($iObjectId) );
2453  if( isset($aPollInfo['id_profile']) ) {
2454  $sRecipientNickName = getNickName($aPollInfo['id_profile']);
2455  $sRecipientProfileLink = getProfileLink($aPollInfo['id_profile']);
2456  $sSenderNickName = $iSenderId ? getNickName($iSenderId) : _t('_Guest');
2457  $sSenderProfileLink = $iSenderId ? getProfileLink($iSenderId) : 'javascript:void(0)';
2458  $sPollLink = $this -> sPathToModule . '&action=show_poll_info&id=' . $aPollInfo['id_poll'];
2459 
2460  $aRet = array(
2461  'lang_key' => $sLangKey,
2462  'params' => array(
2463  'recipient_p_link' => $sRecipientProfileLink,
2464  'recipient_p_nick' => $sRecipientNickName,
2465  'profile_nick' => $sSenderNickName,
2466  'profile_link' => $sSenderProfileLink,
2467  'poll_link' => $sPollLink,
2468  ),
2469  'recipient_id' => ($iRecipientId) ? $iRecipientId : $aPollInfo['id_profile'],
2470  'spy_type' => $sActivityType,
2471  );
2472  }
2473 
2474  return $aRet;
2475  }
2476 
2484  function genPollsList(&$aActivePolls)
2485  {
2486  $iNow = time();
2487 
2488  $sOutputCode = '';
2489  foreach($aActivePolls as $iKey => $aItems) {
2490  $aItems['poll_ago'] = $iNow - (int)$aItems['poll_date'];
2491  $sOutputCode .= $this->getPollBlock($aItems);
2492  }
2493 
2494  return '<div id="pol_container">' . $sOutputCode . '</div>';
2495  }
2496 
2503  function isPollCreateAlowed($iMemberId = false, $isPerformAction = false)
2504  {
2505  if (false === $iMemberId)
2506  $iMemberId = getLoggedId();
2507  $this -> _defineActions();
2508  $aCheck = checkAction($iMemberId, CH_CREATE_POLLS, $isPerformAction);
2509  return $aCheck[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED;
2510  }
2511 
2512  function isAllowedShare(&$aDataEntry)
2513  {
2514  if($aDataEntry['allow_view_to'] != CH_WSB_PG_ALL)
2515  return false;
2516 
2517  return true;
2518  }
2519 
2520  function _defineActions()
2521  {
2522  defineMembershipActions( array('create polls') );
2523  }
2524  }
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
ChPollModule\getModulePath
getModulePath()
Definition: ChPollModule.php:225
ChPollModule\getPrivatePollBlock
getPrivatePollBlock(&$aPollInfo)
Definition: ChPollModule.php:429
ChWsbPageView\getBlockCaptionItemCode
static getBlockCaptionItemCode( $iBlockID, $aLinks)
Definition: ChWsbPageView.php:502
ChWsbFormCheckerHelper\passXss
static passXss($s)
Definition: ChWsbForm.php:647
ChPollModule\getOwnerBlock
getOwnerBlock($iPollOwner, $aPollInfo)
Definition: ChPollModule.php:237
ChPollModule\getInitPollPage
getInitPollPage($bDynamic=true)
Definition: ChPollModule.php:545
ChTemplFormView
Definition: ChTemplFormView.php:11
$sOutputHtml
$sOutputHtml
Definition: browse.php:86
ChTemplTagsModule
Definition: ChTemplTagsModule.php:11
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
$sLimitFrom
$sLimitFrom
Definition: post_mod_crss.php:49
ChPollModule\actionSharePopup
actionSharePopup($iEntryId=0)
Definition: ChPollModule.php:1143
ChPollModule\$sHomeUrl
$sHomeUrl
Definition: ChPollModule.php:118
defineTimeInterval
defineTimeInterval($iTime, $bAutoDateConvert=true, $bShort=false)
Definition: utils.inc.php:831
$aUnit
$aUnit
Definition: short_profile_info.php:31
ChCheckerPoll
Definition: ChPollModule.php:28
ChPollModule\proccesData
proccesData()
Definition: ChPollModule.php:588
$sCode
$sCode
Definition: explanation.php:19
CH_POLL_RES_DIVIDER
const CH_POLL_RES_DIVIDER
Definition: ChPollModule.php:18
CH_WSB_TAGS_DIVIDER
const CH_WSB_TAGS_DIVIDER
Definition: ChWsbTags.php:12
$aModule
$aModule
Definition: classifieds.php:21
$_page
$_page['name_index']
Definition: about_us.php:13
ChPollModule\$aPollSettings
$aPollSettings
Definition: ChPollModule.php:124
ChPollModule\getManagePollsPage
getManagePollsPage($bApproval=true)
Definition: ChPollModule.php:350
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ChPollModule\$sPathToModule
$sPathToModule
Definition: ChPollModule.php:133
$iPollId
$iPollId
Definition: index.php:20
$_page_cont
$_page_cont[$_ni]['page_main_code']
Definition: about_us.php:24
ChPollModule\genToggleElements
genToggleElements()
Definition: ChPollModule.php:318
ChPollModule\genMemberAdministration
genMemberAdministration()
Definition: ChPollModule.php:263
ChPollModule\showAdminActionsPanel
showAdminActionsPanel($sWrapperId, $aButtons, $sCheckboxName='entry', $bSelectAll=true, $bSelectAllChecked=false)
Definition: ChPollModule.php:381
ChPollModule\getCustomActionButton
getCustomActionButton()
Definition: ChPollModule.php:817
uri2title
uri2title($sValue)
Definition: utils.inc.php:51
ChPollModule\getAdminForm
getAdminForm()
Definition: ChPollModule.php:1307
ChPollModule\actionCategories
actionCategories()
Definition: ChPollModule.php:1255
php
$oZ
$oZ
Definition: db.php:20
ChWsbTags
Definition: ChWsbTags.php:15
getLinkSet
getLinkSet($sLinkString, $sUrlPrefix, $sDivider=';,', $bUriConvert=false)
Definition: utils.inc.php:1438
CH_POLL_ANS_DIVIDER
const CH_POLL_ANS_DIVIDER
Definition: ChPollModule.php:17
ChPollModule\$sActionAnswer
$sActionAnswer
Definition: ChPollModule.php:130
ChTemplCategoriesModule
Definition: ChTemplCategoriesModule.php:11
$iPerPage
else $iPerPage
Definition: browse.php:61
ChWsbCategories
Definition: ChWsbCategories.php:13
ChPollPrivacy
Definition: ChPollPrivacy.php:11
CATEGORIES_DIVIDER
const CATEGORIES_DIVIDER
Definition: ChWsbCategories.php:10
$aMemberInfo
$aMemberInfo
Definition: profile_info.php:34
isAdmin
isAdmin()
Definition: index.php:649
getSitesArray
getSitesArray($sLink)
Definition: shared_sites.inc.php:25
ChPollModule\$sPollHomeTitleLenght
$sPollHomeTitleLenght
Definition: ChPollModule.php:139
ChPollModule\$iPollsForPerLine
$iPollsForPerLine
Definition: ChPollModule.php:142
ChPollModule\showSearchResult
showSearchResult($sBlockCaption, $sExtraParam=null, $iPerPage=5, $bShowPagination=true, $iPerLine=0, $bUseDesignBox=true, $bShowEmptyMsg=true)
Definition: ChPollModule.php:1808
$oForm
$oForm
Definition: host_tools.php:42
ChPollModule\getCreationForm
getCreationForm()
Definition: ChPollModule.php:686
ChWsbAlerts
Definition: ChWsbAlerts.php:39
exit
exit
Definition: cart.php:21
$_GET
$_GET['debug']
Definition: index.php:67
$iIndex
$iIndex
Definition: bottom_menu_compose.php:142
and
and
Definition: license.txt:18
ChPollModule\actionDeletePoll
actionDeletePoll($iPollId)
Definition: ChPollModule.php:1187
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
ChPollModule\deletePoll
deletePoll($iId)
Definition: ChPollModule.php:1960
$sPageCaption
$sPageCaption
Definition: index.php:75
get_member_thumbnail
get_member_thumbnail($ID, $float, $bGenProfLink=false, $sForceSex='visitor', $aOnline=array())
Definition: design.inc.php:165
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
CH_POLL_VOTE_UNIQ
const CH_POLL_VOTE_UNIQ
Definition: ChPollModule.php:16
ChCheckerPoll\passAnswers
passAnswers($a)
Definition: ChPollModule.php:38
getTemplateIcon
getTemplateIcon($sFileName)
Definition: design.inc.php:193
ChPollModule\actionGetQuestions
actionGetQuestions($iPollID)
Definition: ChPollModule.php:1056
ChTemplSearchResult
Definition: ChTemplSearchResult.php:11
ChPollModule\actionTag
actionTag($sTag='')
Definition: ChPollModule.php:1275
getNickName
getNickName( $ID='')
Definition: profiles.inc.php:461
ChPollModule\getPollBlock
getPollBlock(&$aPollInfo, $bAjaxQuery=false, $bViewMode=false, $bAdminMode=false)
Definition: ChPollModule.php:445
$site
$site['ver']
Definition: version.inc.php:8
$sTags
$sTags
Definition: actions.inc.php:12
ChPollModule\isPollCreateAlowed
isPollCreateAlowed($iMemberId=false, $isPerformAction=false)
Definition: ChPollModule.php:2503
ChPollModule\actionViewCalendar
actionViewCalendar($iYear=0, $iMonth=0, $iDay=0)
Definition: ChPollModule.php:1220
ChPollModule\actionGetPollBlock
actionGetPollBlock($iPollId, $bViewMode=false)
Definition: ChPollModule.php:1208
ChPollModule\$oPrivacy
$oPrivacy
Definition: ChPollModule.php:136
ChPollModule
Definition: ChPollModule.php:117
ChWsbPaginate
Definition: ChWsbPaginate.php:69
ChPollModule\actionSetAnswer
actionSetAnswer($iPollID, $iVoteNumber)
Definition: ChPollModule.php:1105
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
ChWsbModule
Definition: ChWsbModule.php:41
$bResult
$bResult
Definition: get_file.php:11
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
time
that in the case of a Adaptation or at a minimum such credit will if a credit for all contributing authors of the Adaptation or Collection then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors For the avoidance of You may only use the credit required by this Section for the purpose of attribution in the manner set out above by exercising Your rights under this You may not implicitly or explicitly assert or imply any connection sponsorship or endorsement by the Original Licensor and or Attribution as of You or Your use of the without the express prior written permission of the Original Licensor and or Attribution Parties Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable if You Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or You must not modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author s honor or reputation Licensor agrees that in those in which any exercise of the right granted in modification or other derogatory action prejudicial to the Original Author s honor and the Licensor will waive or not as this to the fullest extent permitted by the applicable national to enable You to reasonably exercise Your right under Warranties and Disclaimer UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN LICENSOR OFFERS THE WORK AS IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE STATUTORY OR WITHOUT WARRANTIES OF FITNESS FOR A PARTICULAR OR THE ABSENCE OF LATENT OR OTHER OR THE PRESENCE OF ABSENCE OF WHETHER OR NOT DISCOVERABLE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED SO SUCH EXCLUSION MAY NOT APPLY TO YOU Limitation on Liability EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES Termination This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License Individuals or entities who have received Adaptations or Collections from You under this will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses and will survive any termination of this License Subject to the above terms and the license granted here is Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time
Definition: license.txt:56
PageCode
PageCode($oTemplate=null)
Definition: design.inc.php:91
getProfileLink
getProfileLink( $iID, $sLinkAdd='')
Definition: profiles.inc.php:484
CH_WSB_LOCALE_DATE_SHORT
const CH_WSB_LOCALE_DATE_SHORT
Definition: utils.inc.php:15
ChPollModule\createPoll
createPoll($sPollQuestion, $sPollAnswers, $sPollResults, $sTags, $iCommentGroupValue, $iVoteGroupValue, $sCategory, $iViewGroupValue)
Definition: ChPollModule.php:1847
ChPollSearch
Definition: ChPollSearch.php:13
ChPollModule\searchByDate
searchByDate($sCaption, $iYear, $iMonth, $iDay, $bUseInitPart=true)
Definition: ChPollModule.php:1773
CH_TAGS_STRIP
const CH_TAGS_STRIP
Definition: utils.inc.php:22
ChPollModule\__construct
__construct($aModule, $aPollSettings=array())
Definition: ChPollModule.php:166
$iPage
$iPage
Definition: browse.php:50
ChPollModule\actionCalendar
actionCalendar($iYear=null, $iMonth=null)
Definition: ChPollModule.php:1240
ChPollModule\actionResultsList
actionResultsList($iPollID)
Definition: ChPollModule.php:998
default
Attr AllowedFrameTargets _parent and _top Values should be as validation will be done in a case sensitive manner despite W3C s recommendation XHTML Strict does not permit the target attribute so this directive will have no effect in that doctype XHTML does not enable the Target module by default
Definition: Attr.AllowedFrameTargets.txt:10
$logged
$logged['member']
Definition: activation_email.php:16
ChPollModule\searchTags
searchTags($sTag, $sExtraParam='', $bUseInitPart=true)
Definition: ChPollModule.php:1553
getProfileInfo
getProfileInfo($iProfileID=0, $checkActiveStatus=false, $forceCache=false)
Definition: profiles.inc.php:249
ChPollModule\$aUsedTemplates
$aUsedTemplates
Definition: ChPollModule.php:121
ChPollModule\actionTags
actionTags()
Definition: ChPollModule.php:1290
$aForm
$aForm
Definition: forgot.php:43
$sCaption
$sCaption
Definition: tellfriend.php:39
ChPollModule\$oSearch
$oSearch
Definition: ChPollModule.php:144
ChPollModule\editPoll
editPoll($iPollId, $sPollQuestion, $sPollAnswers, $sCategory, $bActive=true, $bApprove=false, $sTags=null, $iCommentGroupValue=3, $iVoteGroupValue=3, $iViewGroupValue=3)
Definition: ChPollModule.php:1912
$iTotalNum
if(isset($_POST['crsss']) &&is_array($_POST['crsss'])) $iTotalNum
Definition: post_mod_crss.php:40
ChWsbFormCheckerHelper
Definition: ChWsbForm.php:461
DesignBoxContent
DesignBoxContent($title, $content, $db_num=0, $caption_item='', $bottom_item='')
Definition: design.inc.php:78
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
ChPollCalendar
Definition: ChPollCalendar.php:11
getLocaleDate
getLocaleDate($sTimestamp='', $iCode=CH_WSB_LOCALE_DATE_SHORT)
Definition: utils.inc.php:70
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChCheckerPoll\checkAnswers
checkAnswers($aItems, $iLenMin, $iLenMax)
Definition: ChPollModule.php:29
ChPollModule\getEditForm
getEditForm()
Definition: ChPollModule.php:832
$iProfileId
if( $sMembersList) $iProfileId
Definition: communicator.php:29
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10
or
Voluntary License Schemes The Licensor waives the right to collect whether individually or
Definition: license.txt:37
isMember
isMember($iId=0)
Definition: profiles.inc.php:44
reparseObjTags
reparseObjTags( $sType, $iID)
Definition: tags.inc.php:47
ChPollModule\$aModuleInfo
$aModuleInfo
Definition: ChPollModule.php:127