復制代碼 代碼如下:
function fetchRoles($user)
{
if ($this->existsLink($this->rolesField)) {
$link =& $this->getLink($this->rolesField);
$rolenameField = $link->assocTDG->rolesNameField;
} else {
$rolenameField = 'rolename';
}
if (!isset($user[$this->rolesField]) ||
!is_array($user[$this->rolesField])) {
return array();
}
$roles = array();
foreach ($user[$this->rolesField] as $role) {
if (!is_array($role)) {
return array($user[$this->rolesField][$rolenameField]);
}
$roles[] = $role[$rolenameField];
}
return $roles;
}
在頁面中定義了rolesNameField 也無效,因此在下面這段後面加多一行
復制代碼 代碼如下:
$rolenameField = $link->assocTDG->rolesNameField;
復制代碼 代碼如下:
$rolenameField = $rolenameField ? $rolenameField : 'rolename';