Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions View/Helper/UserSearchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,20 @@ public function __construct(View $View, $settings = array()) {
$this->UsersLanguage = ClassRegistry::init('Users.UsersLanguage');

$this->userAttributes = Hash::combine(
$this->_View->viewVars['userAttributes'], '{n}.{n}.{n}.UserAttribute.key', '{n}.{n}.{n}'
Hash::get($this->_View->viewVars, 'userAttributes', array()),
'{n}.{n}.{n}.UserAttribute.key', '{n}.{n}.{n}'
);
}

/**
* テーブルヘッダーの出力
*
* @param bool $isEdit 編集の有無
* @param bool $isSort ソートの有無
* @return string User value
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
public function tableHeaders($isEdit = false) {
public function tableHeaders($isEdit = false, $isSort = true) {
$output = '';

foreach ($this->_View->viewVars['displayFields'] as $fieldName) {
Expand All @@ -81,15 +83,22 @@ public function tableHeaders($isEdit = false) {

$output .= '<th' . $class . '>';
if ($fieldName === 'room_role_key') {
$output .= $this->_View->Paginator->sort('RoomRole.level', __d('rooms', 'Room role'));
$label = __d('rooms', 'Room role');
$key = 'RoomRole.level';
} else {
$userAttribute = Hash::extract(
$this->userAttributes, '{s}.UserAttribute[key=' . $fieldName . ']'
);
$output .= $this->_View->Paginator->sort(
$this->User->getOriginalUserField($fieldName), $userAttribute[0]['name']
);
$label = $userAttribute[0]['name'];
$key = $this->User->getOriginalUserField($fieldName);
}

if ($isSort) {
$output .= $this->_View->Paginator->sort($key, $label);
} else {
$output .= h($label);
}

$output .= '</th>';

if ($isEdit) {
Expand Down