/** * Get a role's ID based on its path. * @param $rolePath string * @return int */ function getRoleIdFromPath($rolePath) { switch ($rolePath) { case 'editor': return ROLE_ID_EDITOR; case 'sectionEditor': return ROLE_ID_SECTION_EDITOR; case 'subscriptionManager': return ROLE_ID_SUBSCRIPTION_MANAGER; default: return parent::getRoleIdFromPath($rolePath); } }
/** * Get a mapping of role keys and i18n key names. * @param boolean $contextOnly If false, also returns site-level roles (Site admin) * @param array $roleIds Only return role names of these IDs * @return array */ static function getRoleNames($contextOnly = false, $roleIds = null) { $parentRoleNames = parent::getRoleNames($contextOnly); $journalRoleNames = array(ROLE_ID_MANAGER => 'user.role.manager', ROLE_ID_GUEST_EDITOR => 'user.role.guestEditor', ROLE_ID_ASSISTANT => 'user.role.journalAssistant', ROLE_ID_SECTION_EDITOR => 'user.role.sectionEditor', ROLE_ID_SUBSCRIPTION_MANAGER => 'user.role.subscriptionManager'); $roleNames = $parentRoleNames + $journalRoleNames; if (!empty($roleIds)) { $returner = array(); foreach ($roleIds as $roleId) { if (isset($roleNames[$roleId])) { $returner[$roleId] = $roleNames[$roleId]; } } return $returner; } else { return $roleNames; } }
/** * Get a mapping of role keys and i18n key names. * @param boolean $contextOnly If false, also returns site-level roles (Site admin) * @param array $roleIds Only return role names of these IDs * @return array */ static function getRoleNames($contextOnly = false, $roleIds = null) { $parentRoleNames = parent::getRoleNames($contextOnly); $pressRoleNames = array(ROLE_ID_MANAGER => 'user.role.manager', ROLE_ID_SERIES_EDITOR => 'user.role.subEditor', ROLE_ID_ASSISTANT => 'user.role.assistant'); $roleNames = $parentRoleNames + $pressRoleNames; if (!empty($roleIds)) { $returner = array(); foreach ($roleIds as $roleId) { if (isset($roleNames[$roleId])) { $returner[$roleId] = $roleNames[$roleId]; } } return $returner; } else { return $roleNames; } }
/** * Get a role's ID based on its path. * @param $rolePath string * @return int */ function getRoleIdFromPath($rolePath) { switch ($rolePath) { case ROLE_PATH_DIRECTOR: return ROLE_ID_DIRECTOR; case ROLE_PATH_TRACK_DIRECTOR: return ROLE_ID_TRACK_DIRECTOR; default: return parent::getRoleIdFromPath($rolePath); } }