Cheetah
ChWsbXMLRPCProfileView.php
Go to the documentation of this file.
1 <?php
2 
8 require_once( CH_DIRECTORY_PATH_BASE . 'scripts/ChBaseProfileGenerator.php' );
9 
10 define('CH_BLOCK_GENERALINFO', 17);
11 define('CH_BLOCK_ADDITIONALINFO', 20);
12 
14 {
16 
17  function __construct($iProfileId, $iViewerId = 0)
18  {
20  $this->_iViewerId = $iViewerId;
21  }
22 
24  {
25  $oPrivacy = new ChWsbPrivacy('sys_page_compose_privacy', 'id', 'user_id');
26  $aRet = array();
27  $r = db_res ("SELECT `pc`.`Caption`, `pc`.`Content`, `pc`.`Func`, `pc`.`ID` AS `BlockID`
28  FROM `sys_profile_fields` AS `pf`
29  INNER JOIN `sys_page_compose` AS `pc`
30  ON ((`pc`.`Func` = 'PFBlock' AND `pc`.`Content` = `pf`.`ID`) OR (`pc`.`Func` = 'GeneralInfo' AND " . CH_BLOCK_GENERALINFO . " = `pf`.`ID`) OR (`pc`.`Func` = 'AdditionalInfo' AND " . CH_BLOCK_ADDITIONALINFO . " = `pf`.`ID`))
31  WHERE `pc`.`Page` = 'profile_info' AND `pf`.`Type` = 'block' AND `pc`.`Column` != 0
32  ORDER BY `pc`.`Column`, `pc`.`Order`");
33  while ($a = $r->fetch()) {
34  $iPrivacyId = (int)$GLOBALS['MySQL']->getOne("SELECT `id` FROM `sys_page_compose_privacy` WHERE `user_id`='" . $this->_iProfileID . "' AND `block_id`='" . $a['BlockID'] . "' LIMIT 1");
35  if ($iPrivacyId != 0 && !$oPrivacy->check('view_block', $iPrivacyId, $this->_iViewerId))
36  continue;
37 
38  switch ($a['Func']) {
39  case 'GeneralInfo': $i = CH_BLOCK_GENERALINFO; break;
40  case 'AdditionalInfo': $i = CH_BLOCK_ADDITIONALINFO; break;
41  default: $i = $a['Content'];
42  }
43  $aBlock = $this->getProfileInfoBlock ($a['Caption'], $i);
44  if (false === $aBlock) continue;
45  $aRet[] = $aBlock;
46  }
47 
48  if ($this->_iViewerId == $this->_iProfileID) {
49 
50  $aOwnInfo[] = new xmlrpcval (array (
51  'Caption' => new xmlrpcval (_t('_E-mail')),
52  'Type' => new xmlrpcval ('text'),
53  'Value1' => new xmlrpcval ($this->_aProfile['Email']),
54  ), "struct");
55 
56  $aOwnInfo[] = new xmlrpcval (array (
57  'Caption' => new xmlrpcval (_t('_Membership2')),
58  'Type' => new xmlrpcval ('text'),
59  'Value1' => new xmlrpcval (strip_tags(GetMembershipStatus($this->_iProfileID, false, false))),
60  ), "struct");
61 
62  $aOwnInfo[] = new xmlrpcval (array (
63  'Caption' => new xmlrpcval (_t('_Status')),
64  'Type' => new xmlrpcval ('text'),
65  'Value1' => new xmlrpcval (_t('__' . $this->_aProfile['Status'])),
66  ), "struct");
67 
68  $aRet[] = new xmlrpcval (array (
69  'Info' => new xmlrpcval ($aOwnInfo, "array"),
70  'Title' => new xmlrpcval (_t('_Account Info')),
71  ), "struct");
72  }
73 
74  return new xmlrpcval ($aRet, "array");
75  }
76 
78  {
79  global $site;
80 
81  $iBlockID = (int)$sContent;
82 
83  if( !isset( $this->aPFBlocks[$iBlockID] ) or empty( $this->aPFBlocks[$iBlockID]['Items'] ) )
84  return false;
85 
86  $aItems = $this->aPFBlocks[$iBlockID]['Items'];
87 
88  $aRet = array ();
89  foreach( $aItems as $aItem ) {
90 
91  $sValue1 = htmlspecialchars_decode($this->oPF->getViewableValue($aItem, $this->_aProfile[$aItem['Name']]), ENT_COMPAT);
92 
93  if ($aItem['Name'] == 'Age')
94  $sValue1 = (isset($this->_aProfile['DateOfBirth'])) ? age($this->_aProfile['DateOfBirth']) : _t("_uknown");
95 
96  if( !$sValue1 ) //if empty, do not draw
97  continue;
98 
99  $aStruct = array ();
100 
101  $aStruct['Caption'] = new xmlrpcval (strip_tags(_t($aItem['Caption'])));
102  $aStruct['Type'] = new xmlrpcval ($aItem['Type']);
103  $aStruct['Value1'] = new xmlrpcval (strip_tags($sValue1));
104 
105  if ($this->bCouple) {
106  if (!in_array( $aItem['Name'], $this->aCoupleMutualItems)) {
107  $sValue2 = htmlspecialchars_decode($this->oPF->getViewableValue($aItem, $this->_aCouple[$aItem['Name']]), ENT_COMPAT);
108  if ($aItem['Name'] == 'Age')
109  $sValue2 = (isset($this->_aCouple['DateOfBirth'])) ? age($this->_aCouple['DateOfBirth']) : _t("_uknown");
110  $aStruct['Value2'] = new xmlrpcval (strip_tags($sValue2));
111  }
112  }
113 
114  $aRet[] = new xmlrpcval ($aStruct, "struct");
115  }
116 
117  return new xmlrpcval (array (
118  'Info' => new xmlrpcval ($aRet, "array"),
119  'Title' => new xmlrpcval (_t($sCaption)),
120  ), "struct");
121  }
122 }
ChWsbXMLRPCProfileView
Definition: ChWsbXMLRPCProfileView.php:14
GetMembershipStatus
GetMembershipStatus($memberID, $bOfferUpgrade=true, $bViewActions=true)
Definition: profiles.inc.php:148
xmlrpcval
Definition: xmlrpc.inc:2696
php
ChBaseProfileGenerator\__construct
__construct($ID)
Definition: ChBaseProfileGenerator.php:26
ChWsbXMLRPCProfileView\getProfileInfoBlock
getProfileInfoBlock($sCaption, $sContent)
Definition: ChWsbXMLRPCProfileView.php:77
ChBaseProfileGenerator
Definition: ChBaseProfileGenerator.php:15
ChWsbXMLRPCProfileView\getProfileInfoExtra
getProfileInfoExtra()
Definition: ChWsbXMLRPCProfileView.php:23
CH_BLOCK_GENERALINFO
const CH_BLOCK_GENERALINFO
Definition: ChWsbXMLRPCProfileView.php:10
ChWsbXMLRPCProfileView\$_iViewerId
$_iViewerId
Definition: ChWsbXMLRPCProfileView.php:15
$site
$site['ver']
Definition: version.inc.php:8
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
age
age( $birth_date)
Definition: profiles.inc.php:119
CH_BLOCK_ADDITIONALINFO
const CH_BLOCK_ADDITIONALINFO
Definition: ChWsbXMLRPCProfileView.php:11
ChWsbXMLRPCProfileView\__construct
__construct($iProfileId, $iViewerId=0)
Definition: ChWsbXMLRPCProfileView.php:17
db_res
db_res($query, $bindings=[])
Definition: db.inc.php:39
$sCaption
$sCaption
Definition: tellfriend.php:39
ChWsbPrivacy
Definition: ChWsbPrivacy.php:60
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
$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