Cheetah
All Classes Namespaces Files Functions Variables Pages
ChBaseAccountView.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbPageView');
9 ch_import('ChWsbMemberMenu');
10 
12 {
13  var $iMember;
16  var $aConfDir;
17 
18  function __construct($iMember, &$aSite, &$aDir)
19  {
20  $this->iMember = (int)$iMember;
21  $this->aMemberInfo = getProfileInfo($this->iMember);
22 
23  $this->aConfSite = $aSite;
24  $this->aConfDir = $aDir;
25 
26  parent::__construct('member');
27  }
28 
30  {
32 
33  ch_import('ChTemplCommunicator');
34  $oCommunicator = new ChTemplCommunicator(array('member_id' => $this->iMember));
35 
36  $oSysTemplate->addCss($oCommunicator->getCss());
37  $oSysTemplate->addJs($oCommunicator->getJs());
38  return $oCommunicator->getBlockCode_FriendRequests(false);
39  }
40 
42  {
44 
45  ch_import('ChTemplMailBox');
46  $aSettings = array(
47  'member_id' => $this->iMember,
48  'recipient_id' => $this->iMember,
49  'mailbox_mode' => 'inbox_new'
50  );
51  $oMailBox = new ChTemplMailBox('mail_page', $aSettings);
52 
53  $oSysTemplate->addCss($oMailBox->getCss());
54  $oSysTemplate->addJs($oMailBox->getJs());
55  return $oMailBox->getBlockCode_NewMessages(false);
56  }
57 
59  {
60  global $oTemplConfig, $aPreValues;
61 
62  //Labels
63  $sProfileStatusC = _t('_Profile status');
64  $sPresenceC = _t('_Presence');
65  $sMembershipC = _t('_Membership2');
66  $sLastLoginC = _t('_Last login');
67  $sRegistrationC = _t('_Registration');
68  $sEmailC = _t('_Email');
69  $sMembersC = ' ' . _t('_Members');
70  $sProfileC = _t('_Profile');
71  $sContentC = _t('_Content');
72 
73  //--- General Info block ---//
74  $sProfileStatus = _t( "__{$this->aMemberInfo['Status']}" );
75  $sProfileStatusMess = '';
76  switch ( $this->aMemberInfo['Status'] ) {
77  case 'Unconfirmed':
78  $sProfileStatusMess = _t( "_ATT_UNCONFIRMED", $oTemplConfig -> popUpWindowWidth, $oTemplConfig -> popUpWindowHeight );
79  break;
80  case 'Approval':
81  $sProfileStatusMess = _t( "_ATT_APPROVAL", $oTemplConfig -> popUpWindowWidth, $oTemplConfig -> popUpWindowHeight );
82  break;
83  case 'Active':
84  $sProfileStatusMess = _t( "_ATT_ACTIVE", $this->aMemberInfo['ID'], $oTemplConfig -> popUpWindowWidth, $oTemplConfig -> popUpWindowHeight );
85  break;
86  case 'Rejected':
87  $sProfileStatusMess = _t( "_ATT_REJECTED", $oTemplConfig -> popUpWindowWidth, $oTemplConfig -> popUpWindowHeight );
88  break;
89  case 'Suspended':
90  $sProfileStatusMess = _t( "_ATT_SUSPENDED", $oTemplConfig -> popUpWindowWidth, $oTemplConfig -> popUpWindowHeight );
91  break;
92  }
93 
94  $oForm = ch_instance('ChWsbFormCheckerHelper');
95  $sMembStatus = GetMembershipStatus($this->aMemberInfo['ID']);
96 
97  $sLastLogin = 'never';
98  if (!empty($this->aMemberInfo['DateLastLogin']) && $this->aMemberInfo['DateLastLogin'] != "0000-00-00 00:00:00") {
99  $sLastLoginTS = $oForm->_passDateTime($this->aMemberInfo['DateLastLogin']);
100  $sLastLogin = getLocaleDate($sLastLoginTS, CH_WSB_LOCALE_DATE);
101  }
102 
103  $sRegistration = 'never';
104  if(!empty($this->aMemberInfo['DateReg']) && $this->aMemberInfo['DateReg'] != "0000-00-00 00:00:00" ) {
105  $sRegistrationTS = $oForm->_passDateTime($this->aMemberInfo['DateReg']);
106  $sRegistration = getLocaleDate($sRegistrationTS, CH_WSB_LOCALE_DATE);
107  }
108 
109  //--- Presence block ---//
110  require_once( CH_DIRECTORY_PATH_CLASSES . 'ChWsbUserStatusView.php' );
111  $oStatusView = new ChWsbUserStatusView();
112  $sUserStatus = $oStatusView->getMemberMenuStatuses();
113 
114  //--- Content block ---//
115  $aAccountCustomStatElements = $GLOBALS['MySQL']->fromCache('sys_account_custom_stat_elements', 'getAllWithKey', 'SELECT * FROM `sys_account_custom_stat_elements`', 'ID');
116  $aPQStatisticsElements = $GLOBALS['MySQL']->fromCache('sys_stat_member', 'getAllWithKey', 'SELECT * FROM `sys_stat_member`', 'Type');
117 
118  $aCustomElements = array();
119  foreach($aAccountCustomStatElements as $iID => $aMemberStats) {
120  $sUnparsedLabel = $aMemberStats['Label'];
121  $sUnparsedValue = $aMemberStats['Value'];
122 
123  $sLabel = _t($sUnparsedLabel);
124  $sUnparsedValue = str_replace('__site_url__', CH_WSB_URL_ROOT, $sUnparsedValue);
125 
126  //step 1 - replacements of keys
127  $sLblTmpl = '__l_';
128  $sTmpl = '__';
129  while(($iStartPos = strpos($sUnparsedValue, $sLblTmpl)) !== false) {
130  $iEndPos = strpos($sUnparsedValue, $sTmpl, $iStartPos + 1);
131  if($iEndPos <= $iStartPos)
132  break;
133 
134  $sSubstr = substr($sUnparsedValue, $iStartPos + strlen($sLblTmpl), $iEndPos-$iStartPos - strlen($sLblTmpl));
135  $sKeyValue = mb_strtolower(_t('_' . $sSubstr));
136  $sUnparsedValue = str_replace($sLblTmpl.$sSubstr.$sTmpl, $sKeyValue, $sUnparsedValue);
137  }
138 
139  //step 2 - replacements of Stat keys
140  while(($iStartPos = strpos($sUnparsedValue, $sTmpl, 0)) !== false) {
141  $iEndPos = strpos($sUnparsedValue, $sTmpl, $iStartPos + 1);
142  if($iEndPos <= $iStartPos)
143  break;
144 
145  $iCustomCnt = 0;
146  $sSubstr = process_db_input( substr($sUnparsedValue, $iStartPos + strlen($sTmpl), $iEndPos-$iStartPos - strlen($sTmpl)), CH_TAGS_STRIP);
147  if ($sSubstr) {
148  $sCustomSQL = $aPQStatisticsElements[$sSubstr]['SQL'];
149  $sCustomSQL = str_replace('__member_id__', $this->aMemberInfo['ID'], $sCustomSQL);
150  $sCustomSQL = str_replace('__profile_media_define_photo__', _t('_ProfilePhotos'), $sCustomSQL);
151  $sCustomSQL = str_replace('__profile_media_define_music__', _t('_ProfileMusic'), $sCustomSQL);
152  $sCustomSQL = str_replace('__profile_media_define_video__', _t('_ProfileVideos'), $sCustomSQL);
153  $sCustomSQL = str_replace('__member_nick__', process_db_input($this->aMemberInfo['NickName'], CH_TAGS_NO_ACTION, CH_SLASHES_NO_ACTION), $sCustomSQL);
154  $iCustomCnt = ($sCustomSQL!='') ? (int)db_value($sCustomSQL) : '';
155  }
156  $sUnparsedValue = str_replace($sTmpl . $sSubstr . $sTmpl, $iCustomCnt, $sUnparsedValue);
157  }
158 
159  $sTrimmedLabel = trim($sUnparsedLabel, '_');
160  $aCustomElements[$sTrimmedLabel] = array(
161  'type' => 'custom',
162  'name' => $sTrimmedLabel,
163  'content' => '<b>' . $sLabel . ':</b> ' . $sUnparsedValue,
164  'colspan' => true
165  );
166  }
167  $aForm = array(
168  'form_attrs' => array(
169  'action' => '',
170  'method' => 'post',
171  ),
172  'params' => array(
173  'remove_form' => true,
174  ),
175  'inputs' => array(
176  'header1' => array(
177  'type' => 'block_header',
178  'caption' => $sProfileC,
179  'collapsable' => true
180  ),
181  'Info' => array(
182  'type' => 'custom',
183  'name' => 'Info',
184  'content' => get_member_thumbnail($this->aMemberInfo['ID'], 'none', true),
185  'colspan' => true
186  ),
187  'Status' => array(
188  'type' => 'custom',
189  'name' => 'Status',
190  'content' => '<b>' . $sProfileStatusC . ':</b> ' . $sProfileStatus . '<br />' . $sProfileStatusMess,
191  'colspan' => true
192  ),
193  'Email' => array(
194  'type' => 'custom',
195  'name' => 'Email',
196  'content' => '<b>' . $sEmailC . ':</b> ' . $this->aMemberInfo['Email'] . '<br />' . _t('_sys_txt_ac_manage_subscriptions'),
197  'colspan' => true
198  ),
199  'Membership' => array(
200  'type' => 'custom',
201  'name' => 'Membership',
202  'content' => '<b>' . $sMembershipC . ':</b> ' . $sMembStatus,
203  'colspan' => true
204  ),
205  'LastLogin' => array(
206  'type' => 'custom',
207  'name' => 'LastLogin',
208  'content' => '<b>' . $sLastLoginC . ':</b> ' . $sLastLogin,
209  'colspan' => true
210  ),
211  'Registration' => array(
212  'type' => 'custom',
213  'name' => 'Registration',
214  'content' => '<b>' . $sRegistrationC . ':</b> ' . $sRegistration,
215  'colspan' => true
216  ),
217  'header1_end' => array(
218  'type' => 'block_end'
219  ),
220  'header2' => array(
221  'type' => 'block_header',
222  'caption' => $sPresenceC,
223  'collapsable' => true,
224  'collapsed' => true,
225  'attrs' => array (
226  'id' => 'user_status_ac',
227  ),
228  ),
229  'UserStatus' => array(
230  'type' => 'custom',
231  'name' => 'Info',
232  'content' => $sUserStatus,
233  'colspan' => true
234  ),
235  'header2_end' => array(
236  'type' => 'block_end'
237  )
238  ),
239  );
240 
241  //custom
242  if(!empty($aCustomElements)) {
243  $aForm['inputs'] = array_merge(
244  $aForm['inputs'],
245  array('header5' => array(
246  'type' => 'block_header',
247  'caption' => $sContentC,
248  'collapsable' => true,
249  'collapsed' => true
250  )),
251  $aCustomElements,
252  array('header5_end' => array(
253  'type' => 'block_end'
254  ))
255  );
256  }
257 
259  $sContent = $GLOBALS['oSysTemplate']->parseHtmlByName('member_account_control.html', array(
260  'content' => $oForm->getCode()
261  ));
262 
263  return array($sContent, array(), array(), false);
264  }
265 
267  {
268  $iLimit = 10;
269  $sContent = $sPaginate = '';
270 
271  $sAllFriends = 'viewFriends.php?iUser=' . $this->iMember;
272 
273  // count all friends ;
274  $iCount = getFriendNumber($this->iMember);
275  if($iCount == 0)
276  return;
277 
278  $iPages = ceil($iCount/$iLimit);
279  $iPage = isset($_GET['page']) ? (int) $_GET['page'] : 1;
280 
281  if($iPage < 1)
282  $iPage = 1;
283 
284  if($iPage > $iPages)
285  $iPage = $iPages;
286 
287  $sSqlFrom = ($iPage - 1) * $iLimit;
288  $sSqlLimit = "LIMIT {$sSqlFrom}, {$iLimit}";
289  $aFriends = getMyFriendsEx($this->iMember, '', 'image', $sSqlLimit);
290 
291  $aTmplParams['ch_repeat:friends'] = array();
292  foreach ($aFriends as $iId => $aFriend)
293  $aTmplParams['ch_repeat:friends'][] = array(
294  'content' => get_member_thumbnail( $iId, 'none', true, 'visitor', array('is_online' => $aFriend[5]))
295  );
296  $sContent = $GLOBALS['oSysTemplate']->parseHtmlByName('member_friends.html', $aTmplParams);
297 
298  $oPaginate = new ChWsbPaginate(array(
299  'page_url' => CH_WSB_URL_ROOT . 'member.php',
300  'count' => $iCount,
301  'per_page' => $iLimit,
302  'page' => $iPage,
303  'on_change_page' => 'return !loadDynamicBlock({id}, \'member.php?page={page}&per_page={per_page}\');',
304  ));
305  $sPaginate = $oPaginate->getSimplePaginate($sAllFriends);
306 
307  return array($sContent, array(), $sPaginate);
308  }
309 
311  {
312  ch_import('ChTemplMenuQlinks2');
313  $oMenu = new ChTemplMenuQlinks2();
314  $sCodeBlock = $oMenu->getCode();
315  return $sCodeBlock;
316  }
317 }
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
CH_WSB_LOCALE_DATE
const CH_WSB_LOCALE_DATE
Definition: utils.inc.php:16
getMyFriendsEx
getMyFriendsEx($iID, $sWhereParam='', $sSortParam='', $sqlLimit='')
Definition: profiles.inc.php:384
ChTemplFormView
Definition: ChTemplFormView.php:11
ChBaseAccountView\$iMember
$iMember
Definition: ChBaseAccountView.php:13
$oMenu
$oMenu
Definition: bottom_menu_compose.php:29
ChBaseAccountView\$aConfDir
$aConfDir
Definition: ChBaseAccountView.php:16
ChWsbPageView
Definition: ChWsbPageView.php:99
ChBaseAccountView\getBlockCode_QuickLinks
getBlockCode_QuickLinks()
Definition: ChBaseAccountView.php:310
GetMembershipStatus
GetMembershipStatus($memberID, $bOfferUpgrade=true, $bViewActions=true)
Definition: profiles.inc.php:148
ChBaseAccountView\getBlockCode_Friends
getBlockCode_Friends()
Definition: ChBaseAccountView.php:266
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$oCommunicator
$oCommunicator
Definition: communicator.php:68
php
$iId
$iId
Definition: license.php:15
CH_SLASHES_NO_ACTION
const CH_SLASHES_NO_ACTION
Definition: utils.inc.php:30
$sUserStatus
$sUserStatus
Definition: short_profile_info.php:29
$oForm
$oForm
Definition: host_tools.php:42
ChBaseAccountView\__construct
__construct($iMember, &$aSite, &$aDir)
Definition: ChBaseAccountView.php:18
$_GET
$_GET['debug']
Definition: index.php:67
get_member_thumbnail
get_member_thumbnail($ID, $float, $bGenProfLink=false, $sForceSex='visitor', $aOnline=array())
Definition: design.inc.php:165
ChTemplMenuQlinks2
Definition: ChTemplMenuQlinks2.php:12
CH_TAGS_NO_ACTION
const CH_TAGS_NO_ACTION
Definition: utils.inc.php:21
ch_instance
ch_instance($sClassName, $aParams=array(), $aModule=array())
Definition: utils.inc.php:1264
ChWsbPaginate
Definition: ChWsbPaginate.php:69
ChWsbUserStatusView
Definition: ChWsbUserStatusView.php:9
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChTemplCommunicator
Definition: ChTemplCommunicator.php:11
CH_TAGS_STRIP
const CH_TAGS_STRIP
Definition: utils.inc.php:22
ChBaseAccountView\getBlockCode_NewMessages
getBlockCode_NewMessages()
Definition: ChBaseAccountView.php:41
ChBaseAccountView
Definition: ChBaseAccountView.php:12
ChBaseAccountView\getBlockCode_AccountControl
getBlockCode_AccountControl()
Definition: ChBaseAccountView.php:58
$iPage
$iPage
Definition: browse.php:50
db_value
db_value($query, $bindings=[], $error_checking=true, $index=0)
Definition: db.inc.php:98
getProfileInfo
getProfileInfo($iProfileID=0, $checkActiveStatus=false, $forceCache=false)
Definition: profiles.inc.php:249
ChTemplMailBox
Definition: ChTemplMailBox.php:11
$aForm
$aForm
Definition: forgot.php:43
$oMailBox
if(isset($_GET['messages_types'])) switch($aMailBoxSettings['mailbox_mode']) $oMailBox
Definition: mail.php:163
ChBaseAccountView\getBlockCode_FriendRequests
getBlockCode_FriendRequests()
Definition: ChBaseAccountView.php:29
$oSysTemplate
$oSysTemplate
Definition: params.inc.php:22
ChBaseAccountView\$aMemberInfo
$aMemberInfo
Definition: ChBaseAccountView.php:14
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
$oTemplConfig
$oTemplConfig
Definition: params.inc.php:90
getLocaleDate
getLocaleDate($sTimestamp='', $iCode=CH_WSB_LOCALE_DATE_SHORT)
Definition: utils.inc.php:70
getFriendNumber
getFriendNumber($iID, $iFrStatus=1, $iOnline=0, $sqlWhere='')
Definition: profiles.inc.php:301
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChBaseAccountView\$aConfSite
$aConfSite
Definition: ChBaseAccountView.php:15
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10