Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F800323
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Feb 22, 12:05 AM
Size
4 KB
Mime Type
text/x-diff
Expires
Mon, Feb 24, 12:05 AM (7 h, 39 m)
Engine
blob
Format
Raw Data
Handle
573580
Attached To
rINP In-Portal
in-portal
View Options
Index: branches/5.2.x/core/units/user_profile/user_profile_tp.php
===================================================================
--- branches/5.2.x/core/units/user_profile/user_profile_tp.php (revision 16349)
+++ branches/5.2.x/core/units/user_profile/user_profile_tp.php (revision 16350)
@@ -1,159 +1,161 @@
<?php
/**
* @version $Id$
* @package In-Portal
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
defined('FULL_PATH') or die('restricted access!');
class UserProfileTagProcessor extends kDBTagProcessor {
/**
* Get's requested field value.
*
* @param array $params Tag params.
*
* @return string
*/
public function Field($params)
{
$field = $this->SelectParam($params, 'name,field');
$profile_mapping = $this->Application->getUnitOption('u', 'UserProfileMapping');
$user_field = array_key_exists($field, $profile_mapping) ? $profile_mapping[$field] : false;
// Get field value to show on "Public Profile" page.
if ( array_key_exists('profile_field', $params) && $params['profile_field'] ) {
if ( $user_field ) {
$params['name'] = $user_field;
}
return $this->Application->ProcessParsedTag('u.profile', 'Field', $params);
}
if ( $user_field ) {
- // Determine if field should be shown on "Public Profile" page.
+ // Determine if field should be shown on "Public Profile" page (always checkbox).
$block_params = array('name' => 'DisplayToPublic', 'value' => $user_field);
$selected = $this->Application->ProcessParsedTag(
$this->getUserPrefixSpecial(),
'Selected',
$block_params
);
+ $value = $selected ? 1 : 0;
}
else {
- // New user-defined public profile field - fallback to persistent session storage.
- $selected = $this->recallUserProfileVar($field) == 1;
+ // Custom user preference (can by field of any type) - fallback to persistent session storage.
+ $value = $this->recallUserProfileVar($field);
+ $selected = $value == 1;
}
if ( isset($params['checked']) && $params['checked'] ) {
return $selected ? 'checked' : '';
}
- return $selected ? 1 : 0;
+ return $value;
}
/**
* Returns prefix and special of user to operate with
*
* @return string
*/
function getUserPrefixSpecial()
{
return $this->Application->GetVar('user_id') ? 'u.profile' : 'u.current';
}
/**
* Allows to get persistent var from other user
*
* @param string $var_name
* @return mixed
*/
function recallUserProfileVar($var_name)
{
static $cache = null;
if (!isset($cache)) {
$user = $this->Application->recallObject( $this->getUserPrefixSpecial() );
/* @var $user kDBItem */
$sql = 'SELECT VariableValue, VariableName
FROM ' . TABLE_PREFIX . 'UserPersistentSessionData
WHERE (PortalUserId = ' . $user->GetID() . ')';
$cache = $this->Conn->GetCol($sql, 'VariableName');
}
if (array_key_exists($var_name, $cache)) {
// get variable value from persistent session
return $cache[$var_name];
}
else {
// not found in persistent session -> get default value from config variable with same name
$config_value = $this->Application->ConfigValue($var_name);
if ($config_value !== false) {
return $config_value;
}
}
return false;
}
/**
* Returns visible field count in user profile
*
* @param Array $params
* @return int
*/
function ProfileFieldCount($params)
{
static $field_count = null;
if (!isset($field_count)) {
$user = $this->Application->recallObject( $this->getUserPrefixSpecial() );
/* @var $user kDBItem */
$display_to_public = $user->GetDBField('DisplayToPublic');
$field_count = $display_to_public ? substr_count($display_to_public, '|') - 1 : 0;
}
return $field_count;
}
/**
* Allows to detect that not all fields were shown
*
* @param Array $params
* @return bool
* @access protected
*/
protected function NotLastField($params)
{
$counter = (int)$this->Application->GetVar( $params['counter'] );
return $counter < $this->ProfileFieldCount($params);
}
/**
* Because of persistent session table doesn't have ids, we use user id as id for each record
*
* @param Array $params
* @return Array (id,field)
* @access private
*/
function prepareInputName($params)
{
$params['force_id'] = $this->Application->RecallVar('user_id');
return parent::prepareInputName($params);
}
}
Event Timeline
Log In to Comment