Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/user_profile/user_profile_tp.php
Show All 10 Lines | |||||
* or other free or open source software licenses. | * or other free or open source software licenses. | ||||
* See http://www.in-portal.org/license for copyright notices and details. | * See http://www.in-portal.org/license for copyright notices and details. | ||||
*/ | */ | ||||
defined('FULL_PATH') or die('restricted access!'); | defined('FULL_PATH') or die('restricted access!'); | ||||
class UserProfileTagProcessor extends kDBTagProcessor { | class UserProfileTagProcessor extends kDBTagProcessor { | ||||
function Field($params) | /** | ||||
* Get's requested field value. | |||||
* | |||||
* @param array $params Tag params. | |||||
* | |||||
* @return string | |||||
*/ | |||||
public function Field($params) | |||||
{ | { | ||||
$field = $this->SelectParam($params, 'name,field'); | $field = $this->SelectParam($params, 'name,field'); | ||||
$profile_mapping = $this->Application->getUnitOption('u', 'UserProfileMapping'); | $profile_mapping = $this->Application->getUnitOption('u', 'UserProfileMapping'); | ||||
$user_field = array_key_exists($field, $profile_mapping) ? $profile_mapping[$field] : false; | $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 ( array_key_exists('profile_field', $params) && $params['profile_field'] ) { | ||||
// get variable from mapping | if ( $user_field ) { | ||||
$params['name'] = $user_field; | $params['name'] = $user_field; | ||||
$value = $this->Application->ProcessParsedTag('u.profile', 'Field', $params); | |||||
} | } | ||||
elseif ($user_field) { | |||||
// old style variable for displaying fields in public profile (named "pp_*") | return $this->Application->ProcessParsedTag('u.profile', 'Field', $params); | ||||
$block_params = Array ('name' => 'DisplayToPublic', 'value' => $user_field); | } | ||||
$value = $this->Application->ProcessParsedTag($this->getUserPrefixSpecial(), 'Selected', $block_params); | |||||
if ( $user_field ) { | |||||
// Determine if field should be shown on "Public Profile" page. | |||||
$block_params = array('name' => 'DisplayToPublic', 'value' => $user_field); | |||||
$selected = $this->Application->ProcessParsedTag( | |||||
$this->getUserPrefixSpecial(), | |||||
'Selected', | |||||
$block_params | |||||
); | |||||
} | } | ||||
else { | else { | ||||
// get variable by name | // New user-defined public profile field - fallback to persistent session storage. | ||||
$value = $this->recallUserProfileVar($field); | $selected = $this->recallUserProfileVar($field) == 1; | ||||
} | } | ||||
if (isset($params['checked']) && $params['checked']) { | if ( isset($params['checked']) && $params['checked'] ) { | ||||
$checked_value = isset($params['value']) ? $params['value'] : 1; | return $selected ? 'checked' : ''; | ||||
$value = ($value == $checked_value) ? 'checked' : ''; | |||||
} | } | ||||
return $value; | return $selected ? 1 : 0; | ||||
} | } | ||||
/** | /** | ||||
* Returns prefix and special of user to operate with | * Returns prefix and special of user to operate with | ||||
* | * | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
function getUserPrefixSpecial() | function getUserPrefixSpecial() | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | |||||
*/ | */ | ||||
function prepareInputName($params) | function prepareInputName($params) | ||||
{ | { | ||||
$params['force_id'] = $this->Application->RecallVar('user_id'); | $params['force_id'] = $this->Application->RecallVar('user_id'); | ||||
return parent::prepareInputName($params); | return parent::prepareInputName($params); | ||||
} | } | ||||
} | } | ||||
No newline at end of file |