Cheetah
ChEventsPageMy.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbPageView');
9 
11 {
12  var $_oMain;
14  var $_oConfig;
15  var $_oDb;
17 
18  function __construct(&$oMain, &$aProfile)
19  {
20  $this->_oMain = &$oMain;
21  $this->_oTemplate = $oMain->_oTemplate;
22  $this->_oConfig = $oMain->_oConfig;
23  $this->_oDb = $oMain->_oDb;
24  $this->_aProfile = &$aProfile;
25  parent::__construct('ch_events_my');
26  }
27 
28  function getBlockCode_Owner()
29  {
30  if (!$this->_oMain->_iProfileId || !$this->_aProfile)
31  return '';
32 
33  $sContent = '';
34  switch (ch_get('ch_events_filter')) {
35  case 'add_event':
36  $sContent = $this->getBlockCode_Add ();
37  break;
38  case 'manage_events':
39  $sContent = $this->getBlockCode_Manage ();
40  break;
41  case 'pending_events':
42  $sContent = $this->getBlockCode_Pending ();
43  break;
44  default:
45  $sContent = $this->getBlockCode_Main ();
46  }
47 
48  $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . "browse/my";
49  $aMenu = array(
50  _t('_ch_events_block_submenu_main') => array('href' => $sBaseUrl, 'active' => !ch_get('ch_events_filter')),
51  _t('_ch_events_block_submenu_add') => array('href' => $sBaseUrl . '&ch_events_filter=add_event', 'active' => 'add_event' == ch_get('ch_events_filter')),
52  _t('_ch_events_block_submenu_manage') => array('href' => $sBaseUrl . '&ch_events_filter=manage_events', 'active' => 'manage_events' == ch_get('ch_events_filter')),
53  _t('_ch_events_block_submenu_pending') => array('href' => $sBaseUrl . '&ch_events_filter=pending_events', 'active' => 'pending_events' == ch_get('ch_events_filter')),
54  );
55  return array($sContent, $aMenu, '', '');
56  }
57 
59  {
60  ch_events_import ('SearchResult');
61  $o = new ChEventsSearchResult('user', process_db_input ($this->_aProfile['NickName'], CH_TAGS_NO_ACTION, CH_SLASHES_NO_ACTION));
62  $o->aCurrent['rss'] = 0;
63 
64  $o->sBrowseUrl = "browse/my";
65  $o->aCurrent['title'] = _t('_ch_events_block_my_events');
66 
67  if ($o->isError) {
68  return MsgBox(_t('_Empty'));
69  }
70 
71  if ($s = $o->processing()) {
72  $this->_oTemplate->addCss (array('unit.css', 'main.css', 'twig.css'));
73  return $s;
74  } else {
75  return DesignBoxContent(_t('_ch_events_block_user_events'), MsgBox(_t('_Empty')), 1);
76  }
77  }
78 
79  function getBlockCode_Main()
80  {
81  $iActive = $this->_oDb->getCountByAuthorAndStatus($this->_aProfile['ID'], 'approved');
82  $iPending = $this->_oDb->getCountByAuthorAndStatus($this->_aProfile['ID'], 'pending');
83  $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . "browse/my";
84  $aVars = array ('msg' => '');
85  if ($iPending)
86  $aVars['msg'] = sprintf(_t('_ch_events_msg_you_have_pending_approval_events'), $sBaseUrl . '&ch_events_filter=pending_events', $iPending);
87  elseif (!$iActive)
88  $aVars['msg'] = sprintf(_t('_ch_events_msg_you_have_no_events'), $sBaseUrl . '&ch_events_filter=add_event');
89  else
90  $aVars['msg'] = sprintf(_t('_ch_events_msg_you_have_some_events'), $sBaseUrl . '&ch_events_filter=manage_events', $iActive, $sBaseUrl . '&ch_events_filter=add_event');
91  return $this->_oTemplate->parseHtmlByName('my_events_main', $aVars);
92  }
93 
94  function getBlockCode_Add()
95  {
96  if (!$this->_oMain->isAllowedAdd()) {
97  return MsgBox(_t('_Access denied'));
98  }
99  ob_start();
100  $this->_oMain->_addForm(CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'browse/my');
101  $aVars = array ('form' => ob_get_clean());
102  $this->_oTemplate->addCss ('forms_extra.css');
103  return $this->_oTemplate->parseHtmlByName('my_events_create_event', $aVars);
104  }
105 
106  function getBlockCode_My()
107  {
108  return $this->getBlockCode_Manage();
109  }
110 
112  {
113  $sForm = $this->_oMain->_manageEntries ('user', process_db_input ($this->_aProfile['NickName'], CH_TAGS_NO_ACTION, CH_SLASHES_NO_ACTION), false, 'ch_events_my_active', array(
114  'action_delete' => '_ch_events_admin_delete',
115  ), 'ch_events_my_active', 7);
116  $aVars = array ('form' => $sForm, 'id' => 'ch_events_my_active');
117  return $this->_oTemplate->parseHtmlByName('my_events_manage', $aVars);
118  }
119 
121  {
122  $sForm = $this->_oMain->_manageEntries ('my_pending', '', false, 'ch_events_my_pending', array(
123  'action_delete' => '_ch_events_admin_delete',
124  ), 'ch_events_my_pending', 7);
125  $aVars = array ('form' => $sForm, 'id' => 'ch_events_my_pending');
126  return $this->_oTemplate->parseHtmlByName('my_events_manage', $aVars);
127  }
128 }
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
ChEventsPageMy\__construct
__construct(&$oMain, &$aProfile)
Definition: ChEventsPageMy.php:18
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
ChWsbPageView
Definition: ChWsbPageView.php:99
ChEventsPageMy\$_oConfig
$_oConfig
Definition: ChEventsPageMy.php:14
ChEventsPageMy\getBlockCode_Owner
getBlockCode_Owner()
Definition: ChEventsPageMy.php:28
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ch_get
ch_get($sName)
Definition: utils.inc.php:1664
ChEventsPageMy\$_aProfile
$_aProfile
Definition: ChEventsPageMy.php:16
ChEventsPageMy\getBlockCode_Manage
getBlockCode_Manage()
Definition: ChEventsPageMy.php:111
php
CH_SLASHES_NO_ACTION
const CH_SLASHES_NO_ACTION
Definition: utils.inc.php:30
ChEventsPageMy\getBlockCode_Add
getBlockCode_Add()
Definition: ChEventsPageMy.php:94
ChEventsPageMy\$_oDb
$_oDb
Definition: ChEventsPageMy.php:15
ChEventsPageMy
Definition: ChEventsPageMy.php:11
$aProfile
$aProfile
Definition: flash.php:14
CH_TAGS_NO_ACTION
const CH_TAGS_NO_ACTION
Definition: utils.inc.php:21
ChEventsPageMy\$_oTemplate
$_oTemplate
Definition: ChEventsPageMy.php:13
ch_events_import
ch_events_import($sClassPostfix, $aModuleOverwright=array())
Definition: ChEventsModule.php:8
$sContent
$sContent
Definition: bottom_menu_compose.php:169
ChEventsSearchResult
Definition: ChEventsSearchResult.php:11
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChEventsPageMy\getBlockCode_Browse
getBlockCode_Browse()
Definition: ChEventsPageMy.php:58
$aMenu
$aMenu
Definition: categories.php:257
ChEventsPageMy\$_oMain
$_oMain
Definition: ChEventsPageMy.php:12
$aVars
$aVars
Definition: license.php:101
$s
$s
Definition: embed.php:13
ChEventsPageMy\getBlockCode_Main
getBlockCode_Main()
Definition: ChEventsPageMy.php:79
ChEventsPageMy\getBlockCode_Pending
getBlockCode_Pending()
Definition: ChEventsPageMy.php:120
$sForm
$sForm
Definition: forgot.php:118
DesignBoxContent
DesignBoxContent($title, $content, $db_num=0, $caption_item='', $bottom_item='')
Definition: design.inc.php:78
$o
$o
Definition: cmd.php:193
ChEventsPageMy\getBlockCode_My
getBlockCode_My()
Definition: ChEventsPageMy.php:106