]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/CasAuthentication/CasAuthenticationPlugin.php
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x
[quix0rs-gnu-social.git] / plugins / CasAuthentication / CasAuthenticationPlugin.php
index 8b6ef54621f28e51430d0299ff0eae5f88125544..3196bd94a7a622f6d0e186b698e0a8ea0d297040 100644 (file)
@@ -22,7 +22,7 @@
  * @category  Plugin
  * @package   StatusNet
  * @author    Craig Andrews <candrews@integralblue.com>
- * @copyright 2009 Craig Andrews http://candrews.integralblue.com
+ * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link      http://status.net/
  */
@@ -34,12 +34,12 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
 // We bundle the phpCAS library...
 set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/extlib/CAS');
 
-require_once INSTALLDIR.'/plugins/Authentication/AuthenticationPlugin.php';
 class CasAuthenticationPlugin extends AuthenticationPlugin
 {
     public $server;
     public $port = 443;
     public $path = '';
+    public $takeOverLogin = false;
 
     function checkPassword($username, $password)
     {
@@ -57,8 +57,14 @@ class CasAuthenticationPlugin extends AuthenticationPlugin
          case 'CasloginAction':
             require_once(INSTALLDIR.'/plugins/CasAuthentication/' . strtolower(mb_substr($cls, 0, -6)) . '.php');
             return false;
-         default:
-            return parent::onAutoload($cls);
+        }
+    }
+
+    function onArgsInitialize(&$args)
+    {
+        if($this->takeOverLogin && $args['action'] == 'login')
+        {
+            $args['action'] = 'caslogin';
         }
     }
 
@@ -68,13 +74,15 @@ class CasAuthenticationPlugin extends AuthenticationPlugin
         return true;
     }
 
-    function onEndLoginGroupNav(&$action)
+    function onEndLoginGroupNav($action)
     {
         $action_name = $action->trimmed('action');
 
         $action->menuItem(common_local_url('caslogin'),
+                          // TRANS: Menu item. CAS is Central Authentication Service.
                           _m('CAS'),
-                          _m('Login or register with CAS'),
+                          // TRANS: Tooltip for menu item. CAS is Central Authentication Service.
+                          _m('Login or register with CAS.'),
                           $action_name === 'caslogin');
 
         return true;
@@ -87,9 +95,11 @@ class CasAuthenticationPlugin extends AuthenticationPlugin
         switch ($name)
         {
          case 'login':
-            $instr = '(Have an account with CAS? ' .
-              'Try our [CAS login]'.
-              '(%%action.caslogin%%)!)';
+            // TRANS: Invitation to users with a CAS account to log in using the service.
+            // TRANS: "[CAS login]" is a link description. (%%action.caslogin%%) is the URL.
+            // TRANS: These two elements may not be separated.
+            $instr = _m('(Have an account with CAS? ' .
+              'Try our [CAS login](%%action.caslogin%%)!)');
             break;
          default:
             return true;
@@ -115,13 +125,13 @@ class CasAuthenticationPlugin extends AuthenticationPlugin
     function onInitializePlugin(){
         parent::onInitializePlugin();
         if(!isset($this->server)){
-            throw new Exception("must specify a server");
+            throw new Exception(_m("Specifying a server is required."));
         }
         if(!isset($this->port)){
-            throw new Exception("must specify a port");
+            throw new Exception(_m("Specifying a port is required."));
         }
         if(!isset($this->path)){
-            throw new Exception("must specify a path");
+            throw new Exception(_m("Specifying a path is required."));
         }
         //These values need to be accessible to a action object
         //I can't think of any other way than global variables
@@ -131,5 +141,17 @@ class CasAuthenticationPlugin extends AuthenticationPlugin
         $casSettings['server']=$this->server;
         $casSettings['port']=$this->port;
         $casSettings['path']=$this->path;
+        $casSettings['takeOverLogin']=$this->takeOverLogin;
+    }
+
+    function onPluginVersion(&$versions)
+    {
+        $versions[] = array('name' => 'CAS Authentication',
+                            'version' => STATUSNET_VERSION,
+                            'author' => 'Craig Andrews',
+                            'homepage' => 'http://status.net/wiki/Plugin:CasAuthentication',
+                            // TRANS: Plugin description. CAS is Central Authentication Service.
+                            'rawdescription' => _m('The CAS Authentication plugin allows for StatusNet to handle authentication through CAS (Central Authentication Service).'));
+        return true;
     }
 }