Skip to content

Commit

Permalink
Add i18n support
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinoconnor7 committed Jun 4, 2015
1 parent 53953ff commit 074483b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 21 deletions.
16 changes: 14 additions & 2 deletions auth-cas/cas.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function getProfile() {

class CasStaffAuthBackend extends ExternalStaffAuthenticationBackend {
static $id = "cas";
static $name = "CAS";
static $name = /* trans */ "CAS";

static $service_name = "CAS";

Expand All @@ -93,6 +93,12 @@ function __construct($config) {
$this->cas = new CasAuth($config);
}

function getName() {
$config = $this->config;
list($__, $_N) = $config::translate();
return $__(static::$name);
}

function signOn() {
if (isset($_SESSION[':cas']['user'])) {
$staff = new StaffSession($this->cas->getEmail());
Expand All @@ -119,7 +125,7 @@ function triggerAuth() {

class CasClientAuthBackend extends ExternalUserAuthenticationBackend {
static $id = "cas.client";
static $name = "CAS";
static $name = /* trans */ "CAS";

static $service_name = "CAS";

Expand All @@ -128,6 +134,12 @@ function __construct($config) {
$this->cas = new CasAuth($config);
}

function getName() {
$config = $this->config;
list($__, $_N) = $config::translate();
return $__(static::$name);
}

function supportsInteractiveAuthentication() {
return false;
}
Expand Down
46 changes: 31 additions & 15 deletions auth-cas/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,64 @@
require_once INCLUDE_DIR . 'class.plugin.php';

class CasPluginConfig extends PluginConfig {

// Provide compatibility function for versions of osTicket prior to
// translation support (v1.9.4)
function translate() {
if (!method_exists('Plugin', 'translate')) {
return array(
function($x) { return $x; },
function($x, $y, $n) { return $n != 1 ? $y : $x; },
);
}
return Plugin::translate('auth-cas');
}

function getOptions() {
list($__, $_N) = self::translate();
$modes = new ChoiceField(array(
'label' => 'Authenticate',
'label' => $__('Authentication'),
'default' => "disabled",
'choices' => array(
'0' => 'Disabled',
'staff' => 'Agents Only',
'client' => 'Clients Only',
'all' => 'Agents and Clients',
'disabled' => $__('Disabled'),
'staff' => $__('Agents Only'),
'client' => $__('Clients Only'),
'all' => $__('Agents and Clients'),
),
));
return array(
'cas' => new SectionBreakField(array(
'label' => 'CAS Authentication',
'label' => $__('CAS Authentication'),
)),
'cas-hostname' => new TextboxField(array(
'label' => 'CAS Server Hostname',
'label' => $__('CAS Server Hostname'),
'configuration' => array('size'=>60, 'length'=>100),
)),
'cas-port' => new TextboxField(array(
'label' => 'CAS Server Port',
'label' => $__('CAS Server Port'),
'configuration' => array('size'=>10, 'length'=>8),
)),
'cas-context' => new TextboxField(array(
'label' => 'CAS Server Context',
'label' => $__('CAS Server Context'),
'configuration' => array('size'=>60, 'length'=>100),
'hint' => 'This value is "/cas" for most installs.',
'hint' => $__('This value is "/cas" for most installs.'),
)),
'cas-ca-cert-path' => new TextboxField(array(
'label' => 'CAS CA Cert Path',
'label' => $__('CAS CA Cert Path'),
'configuration' => array('size'=>60, 'length'=>100),
)),
'cas-at-domain' => new TextboxField(array(
'label' => 'CAS e-mail suffix',
'label' => $__('CAS e-mail suffix'),
'configuration' => array('size'=>60, 'length'=>100),
'hint' => 'Use this field if your CAS server does not report an e-mail attribute. ex: "@domain.tld"',
'hint' => $__('Use this field if your CAS server does not
report an e-mail attribute. ex: "@domain.tld"'),
)),
'cas-name-attribute-key' => new TextboxField(array(
'label' => 'CAS name attribute key',
'label' => $__('CAS name attribute key'),
'configuration' => array('size'=>60, 'length'=>100),
)),
'cas-email-attribute-key' => new TextboxField(array(
'label' => 'CAS email attribute key',
'label' => $__('CAS email attribute key'),
'configuration' => array('size'=>60, 'length'=>100),
)),
'cas-enabled' => clone $modes,
Expand Down
8 changes: 4 additions & 4 deletions auth-cas/plugin.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
return array(
'id' => 'auth:cas', # notrans
'version' => '0.1',
'name' => 'JASIG CAS Authentication',
'version' => '0.2',
'name' => /* trans */ 'JASIG CAS Authentication',
'author' => 'Kevin O\'Connor',
'description' => 'Provides a configurable authentication backend
for authenticating staff and clients using anJASIG CAS interface.',
'description' => /* trans */ 'Provides a configurable authentication
backend for authenticating staff and clients using CAS.',
'url' => 'http://www.osticket.com/plugins/auth/cas',
'plugin' => 'authentication.php:CasAuthPlugin',
'requires' => array(
Expand Down

0 comments on commit 074483b

Please sign in to comment.