Cheetah
ChSitesPageProfile.php
Go to the documentation of this file.
1 <?php
2 
8 require_once(CH_DIRECTORY_PATH_CLASSES . 'ChWsbPageView.php');
9 
11 {
12  var $_oSites;
13  var $_oDb;
15  var $_oConfig;
18 
19  function __construct(&$oSites, $aProfile, $sSubMenu)
20  {
21  parent::__construct('ch_sites_profile');
22 
23  $GLOBALS['oTopMenu']->setCurrentProfileNickName($aProfile['NickName']);
24  $this->_oSites = &$oSites;
25  $this->_oDb = $oSites->_oDb;
26  $this->_oTemplate = $oSites->_oTemplate;
27  $this->_oConfig = $oSites->_oConfig;
28  $this->_aProfile = $aProfile;
29  $this->_sSubMenu = $sSubMenu;
30  }
31 
33  {
34  $sContent = '';
35  $bPadding = true;
36  switch ($this->_sSubMenu) {
37  case 'add':
38  $sContent = $this->getBlockCode_Add();
39  break;
40 
41  case 'manage':
42  $sContent = $this->getBlockCode_Manage();
43  $bPadding = false;
44  break;
45 
46  case 'pending':
48  $bPadding = false;
49  break;
50 
51  default:
52  $sContent = $this->getBlockCode_Main();
53  }
54 
55  $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . 'browse/my';
56 
57  $aMenu = array(
58  _t('_ch_sites_block_submenu_main') => array('href' => $sBaseUrl, 'active' => !$this->_sSubMenu),
59  _t('_ch_sites_block_submenu_add_site') => array('href' => $sBaseUrl . '/add', 'active' => $this->_sSubMenu == 'add'),
60  _t('_ch_sites_block_submenu_manage_sites') => array('href' => $sBaseUrl . '/manage', 'active' => $this->_sSubMenu == 'manage'),
61  _t('_ch_sites_block_submenu_pending_sites') => array('href' => $sBaseUrl . '/pending', 'active' => $this->_sSubMenu == 'pending'),
62  );
63 
64  return array($sContent, $aMenu, '', $bPadding ? false : '');
65  }
66 
67  function getBlockCode_Owner()
68  {
69  ch_sites_import('SearchResult');
70  $oSearchResult = new ChSitesSearchResult('user', process_db_input($this->_aProfile['NickName'], CH_TAGS_NO_ACTION, CH_SLASHES_NO_ACTION));
71 
72  if ($s = $oSearchResult->displayResultBlock(true))
73  return $s;
74  else
75  return MsgBox(_t('_Empty'));
76  }
77 
78  function getBlockCode_Main()
79  {
80  $iActive = $this->_oDb->getCountByOwnerAndStatus($this->_aProfile['ID'], 'approved');
81  $iPending = $this->_oDb->getCountByOwnerAndStatus($this->_aProfile['ID'], 'pending');
82  $sBaseUrl = CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() . "browse/my";
83  $aVars = array ('msg' => '');
84 
85  if ($iActive)
86  $sActive = sprintf(_t('_ch_sites_msg_you_have_active_sites'), $sBaseUrl . '/manage', $iActive);
87  if ($iPending)
88  $sPending = ($iActive ? ', ' : '') . sprintf(_t('_ch_sites_msg_you_have_pending_sites'), $sBaseUrl . '/pending', $iPending);
89 
90  if (isset($sActive) || isset($sPending))
91  $aVars['msg'] = sprintf(_t('_ch_sites_msg_you_have_sites'),
92  isset($sActive) ? $sActive : '', isset($sPending) ? $sPending : '');
93  else
94  $aVars['msg'] = _t('_ch_sites_msg_no_sites');
95 
96  if ($this->_oSites->isAllowedAdd())
97  $aVars['msg'] .= (strlen($aVars['msg']) ? ' ' : '') . sprintf(_t('_ch_sites_msg_add_more_sites'), $sBaseUrl . '/add');
98 
99  return $this->_oTemplate->parseHtmlByName('my_sites_main.html', $aVars);
100 
101  }
102 
103  function getBlockCode_Add()
104  {
105  if ($this->_oSites->isAllowedAdd())
106  return $this->_oSites->_addSiteForm();
107  else
108  return MsgBox(_t('_ch_sites_msg_access_denied'));
109  }
110 
112  {
113  // check delete sites
114  if ($_POST['action_delete'] && is_array($_POST['entry']))
115  foreach ($_POST['entry'] as $iSiteId)
116  $this->_oSites->deleteSite($iSiteId);
117  // refresh sites thumbnail
118  if ($_POST['action_refresh_thumb'] && is_array($_POST['entry']))
119  foreach ($_POST['entry'] as $iSiteId)
120  $this->_oSites->refreshSiteThumb($iSiteId);
121 
122  $aButtons = array(
123  'action_delete' => '_ch_sites_admin_delete',
124  );
125 
126  if (getParam('ch_sites_redo') == 'on' && getParam('ch_sites_account_type') == 'Enabled') {
127  $aButtons['action_refresh_thumb'] = '_ch_sites_admin_refresh_thumb';
128  }
129 
130  $sForm = $this->_oSites->_manageSites('user', $this->_aProfile['NickName'], $aButtons);
131  $aVars = array ('form' => $sForm);
132 
133  return $this->_oTemplate->parseHtmlByName('my_sites_manage.html', $aVars);
134  }
135 
137  {
138  // check delete sites
139  if ($_POST['action_delete'] && is_array($_POST['entry']))
140  foreach ($_POST['entry'] as $iSiteId)
141  $this->_oSites->deleteSite($iSiteId);
142 
143  $aButtons = array(
144  'action_delete' => '_ch_sites_admin_delete'
145  );
146  $sForm = $this->_oSites->_manageSites('my_pending', '', $aButtons);
147  $aVars = array ('form' => $sForm);
148 
149  return $this->_oTemplate->parseHtmlByName('my_sites_manage.html', $aVars);
150  }
151 }
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
ChSitesPageProfile\$_oConfig
$_oConfig
Definition: ChSitesPageProfile.php:15
ChSitesPageProfile\getBlockCode_Owner
getBlockCode_Owner()
Definition: ChSitesPageProfile.php:67
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
ChSitesPageProfile\$_oSites
$_oSites
Definition: ChSitesPageProfile.php:12
ChWsbPageView
Definition: ChWsbPageView.php:99
ChSitesPageProfile\getBlockCode_Pending
getBlockCode_Pending()
Definition: ChSitesPageProfile.php:136
ChSitesPageProfile\$_sSubMenu
$_sSubMenu
Definition: ChSitesPageProfile.php:16
ChSitesPageProfile\getBlockCode_Add
getBlockCode_Add()
Definition: ChSitesPageProfile.php:103
php
ChSitesSearchResult
Definition: ChSitesSearchResult.php:11
ChSitesPageProfile\$_oTemplate
$_oTemplate
Definition: ChSitesPageProfile.php:14
ChSitesPageProfile\__construct
__construct(&$oSites, $aProfile, $sSubMenu)
Definition: ChSitesPageProfile.php:19
CH_SLASHES_NO_ACTION
const CH_SLASHES_NO_ACTION
Definition: utils.inc.php:30
ChSitesPageProfile\$_aProfile
$_aProfile
Definition: ChSitesPageProfile.php:17
ChSitesPageProfile
Definition: ChSitesPageProfile.php:11
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
ChSitesPageProfile\getBlockCode_Manage
getBlockCode_Manage()
Definition: ChSitesPageProfile.php:111
$aProfile
$aProfile
Definition: flash.php:14
CH_TAGS_NO_ACTION
const CH_TAGS_NO_ACTION
Definition: utils.inc.php:21
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
$aMenu
$aMenu
Definition: categories.php:257
ChSitesPageProfile\getBlockCode_Main
getBlockCode_Main()
Definition: ChSitesPageProfile.php:78
$aVars
$aVars
Definition: license.php:101
ch_sites_import
ch_sites_import($sClassPostfix, $aModuleOverwright=array())
Definition: ChSitesModule.php:8
$s
$s
Definition: embed.php:13
ChSitesPageProfile\$_oDb
$_oDb
Definition: ChSitesPageProfile.php:13
ChSitesPageProfile\getBlockCode_Administration
getBlockCode_Administration()
Definition: ChSitesPageProfile.php:32
$sForm
$sForm
Definition: forgot.php:118
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10