Moved isAuthenticated() from horde/Auth to horde/Core
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 1 Jun 2010 09:04:04 +0000 (03:04 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 2 Jun 2010 03:32:19 +0000 (21:32 -0600)
30 files changed:
agora/owner.php
ansel/lib/Ansel.php
ansel/lib/Gallery.php
ansel/lib/View/GalleryRenderer/Base.php
ansel/lib/Widget/Actions.php
ansel/templates/view/image.inc
ansel/xppublish.php
folks/account/resetpassword.php
folks/edit/friends/approve.php
folks/edit/friends/reject.php
folks/edit/tabs.php
folks/friends.php
folks/lib/Block/my_comments.php
folks/lib/Driver.php
folks/lib/Folks.php
folks/lib/Notification.php
folks/login.php
folks/search.php
folks/templates/common-header.inc
folks/templates/user/user.php
folks/user.php
framework/Auth/lib/Horde/Auth.php
framework/Core/lib/Horde/Registry.php
framework/Rpc/lib/Horde/Rpc/Phpgw.php
horde/login.php
news/add.php
news/lib/Block/my_comments.php
news/mail.php
news/reads.php
whups/mybugs.php

index b18ceb1..a9bbac7 100644 (file)
 require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('agora');
 
-/* Only authenticated users should be using this. */
-if (!Horde_Auth::isAuthenticated()) {
-    $notification->push(_("You are not authorised for this action."), 'horde.warning');
-    Horde_Auth::authenticateFailure('agora');
-}
-
 /* Default to agora and current user if is not an admin. */
 $scope = Horde_Util::getGet('scope', 'agora');
 $owner = $registry->isAdmin() ? Horde_Util::getGet('owner', Horde_Auth::getAuth()) : Horde_Auth::getAuth();
index 3c25fc1..933a90c 100644 (file)
@@ -602,7 +602,7 @@ class Ansel
                        : '__noselection');
         }
 
-        if ($conf['faces']['driver'] && Horde_Auth::isAuthenticated()) {
+        if ($conf['faces']['driver'] && $registry->isAuthenticated()) {
             $menu->add(Horde::applicationUrl('faces/search/all.php'), _("_Faces"), 'user.png', Horde_Themes::img(null, 'horde'));
         }
 
index eb692ac..33501e4 100644 (file)
@@ -98,7 +98,7 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
             return true;
 
         case 'authenticated':
-            return Horde_Auth::isAuthenticated();
+            return $GLOBALS['registry']->isAuthenticated();
 
         case 'edit':
             return $this->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT);
@@ -822,7 +822,8 @@ class Ansel_Gallery extends Horde_Share_Object_Sql_Hierarchical
         }
 
         // Can we hook user's age?
-        if ($GLOBALS['conf']['ages']['hook'] && Horde_Auth::isAuthenticated()) {
+        if ($GLOBALS['conf']['ages']['hook'] &&
+            $GLOBALS['registry']->isAuthenticated()) {
             $result = Horde::callHook('_ansel_hook_user_age');
             if (is_int($result)) {
                 $_SESSION['ansel']['user_age'] = $result;
index a95a08f..4cc0fee 100644 (file)
@@ -35,7 +35,7 @@ abstract class Ansel_View_GalleryRenderer_Base
 
     /**
      * The current page we are viewing
-     * 
+     *
      * @var integer
      */
     public $page = 0;
@@ -150,7 +150,8 @@ abstract class Ansel_View_GalleryRenderer_Base
                 /* Don't show action widget if no actions */
                 if (Horde_Auth::getAuth() ||
                     !empty($conf['report_content']['driver']) &&
-                    (($conf['report_content']['allow'] == 'authenticated' && Horde_Auth::isAuthenticated()) ||
+                    (($conf['report_content']['allow'] == 'authenticated' &&
+                      $GLOBALS['registry']->isAuthenticated()) ||
                      $conf['report_content']['allow'] == 'all')) {
 
                     $this->view->addWidget(Ansel_Widget::factory('Actions'));
index e8c7782..7b98c4d 100644 (file)
@@ -22,7 +22,7 @@ class Ansel_Widget_Actions extends Ansel_Widget_Base
     }
 
     /**
-     * 
+     *
      * @see ansel/lib/Widget/Ansel_Widget_Base#html()
      */
     public function html()
@@ -183,7 +183,8 @@ class Ansel_Widget_Actions extends Ansel_Widget_Base
             $this->_view->gallery->get('owner') == Horde_Auth::getAuth()) {
             $html .= '<li>' . Horde::link('#', '', 'popup widget', '', Horde::popupJs(Horde::applicationUrl('perms.php'), array('params' => array('cid' => $this->_view->gallery->id), 'urlencode' => true)) . 'return false;') . Horde::img('perms.png') . ' ' . _("Set permissions") . '</a></li>';
         } elseif (!empty($conf['report_content']['driver']) &&
-                  (($conf['report_content']['allow'] == 'authenticated' && Horde_Auth::isAuthenticated()) ||
+            (($conf['report_content']['allow'] == 'authenticated' &&
+            $registry->isAuthenticated()) ||
                    $conf['report_content']['allow'] == 'all')) {
 
             $reporturl = Horde_Util::addParameter(Horde::applicationUrl('report.php'),
index 6b040f4..1e29d1c 100644 (file)
@@ -73,7 +73,7 @@ function arrowHandler(e)
              $this->gallery->get('owner') != Horde_Auth::getAuth()) &&
             !empty($GLOBALS['conf']['report_content']['driver']) &&
             (($conf['report_content']['allow'] == 'authenticated' &&
-              Horde_Auth::isAuthenticated()) ||
+              $GLOBALS['registry']->isAuthenticated()) ||
              $conf['report_content']['allow'] == 'all')) {
 
             $actionHTML .=  ($needSeperator ? ' | ' : '' ) . Horde::link($this->_urls['report']) . _("Report") . '</a>';
index 7370651..bbb8657 100644 (file)
@@ -53,7 +53,7 @@ if ($cmd == 'login') {
 }
 
 // If we don't have a valid login, print the login form.
-if (!Horde_Auth::isAuthenticated()) {
+if (!$registry->isAuthenticated()) {
     $PUBLISH_ONNEXT = 'login.submit();';
     $PUBLISH_CMD = 'login.username.focus();';
     require ANSEL_TEMPLATES . '/xppublish/login.inc';
index a0a74e7..17f5e1d 100644 (file)
@@ -29,7 +29,7 @@ function _getCAPTCHA($new = false)
 }
 
 // We are already logged
-if (Horde_Auth::isAuthenticated()) {
+if ($registry->isAuthenticated()) {
     header('Location: ' . Folks::getUrlFor('user', Horde_Auth::getAuth()));
     exit;
 }
index 0b15d6e..d43b6f5 100644 (file)
@@ -14,7 +14,7 @@
 require_once dirname(__FILE__) . '/../../lib/base.php';
 require_once FOLKS_BASE . '/lib/Friends.php';
 
-if (!Horde_Auth::isAuthenticated()) {
+if (!$registry->isAuthenticated()) {
     Horde_Auth::authenticateFailure('folks');
 }
 
index 9877584..628dcf6 100644 (file)
@@ -14,7 +14,7 @@
 require_once dirname(__FILE__) . '/../../lib/base.php';
 require_once FOLKS_BASE . '/lib/Friends.php';
 
-if (!Horde_Auth::isAuthenticated()) {
+if (!$registry->isAuthenticated()) {
     Horde_Auth::authenticateFailure('folks');
 }
 
index 19da846..12ef405 100644 (file)
@@ -11,7 +11,7 @@
  * @package Folks
  */
 
-if (!Horde_Auth::isAuthenticated()) {
+if (!$registry->isAuthenticated()) {
     Horde_Auth::authenticateFailure('folks');
 }
 
index 18c8d9f..0859029 100644 (file)
@@ -14,7 +14,7 @@
 require_once dirname(__FILE__) . '/lib/base.php';
 require_once FOLKS_BASE . '/lib/Forms/Activity.php';
 
-if (!Horde_Auth::isAuthenticated()) {
+if (!$registry->isAuthenticated()) {
     Horde_Auth::authenticateFailure('folks');
 }
 
index b00ff9b..ade8f92 100644 (file)
@@ -36,7 +36,7 @@ class Horde_Block_folks_my_comments extends Horde_Block {
      */
     function _content()
     {
-        if (!Horde_Auth::isAuthenticated()) {
+        if (!$GLOBALS['registry']->isAuthenticated()) {
             return '';
         }
 
index 24f7415..4d0e024 100644 (file)
@@ -272,7 +272,7 @@ class Folks_Driver {
             $this->_updateOnlineStatus();
 
             // Update profile
-            if (Horde_Auth::isAuthenticated()) {
+            if ($GLOBALS['registry']->isAuthenticated()) {
                 $this->_saveProfile(array('last_online_on' => $_SERVER['REQUEST_TIME']), Horde_Auth::getAuth());
             }
         }
@@ -420,7 +420,7 @@ class Folks_Driver {
      */
     function logView($id)
     {
-        if (!Horde_Auth::isAuthenticated() || Horde_Auth::getAUth() == $id) {
+        if (!$GLOBALS['registry']->isAuthenticated() || Horde_Auth::getAUth() == $id) {
             return false;
         }
 
index 35b0795..c2adba3 100644 (file)
@@ -266,7 +266,7 @@ class Folks {
 
         // If there is no email set use the registration one
         if (empty($email)) {
-            if (Horde_Auth::isAuthenticated()) {
+            if ($GLOBALS['registry']->isAuthenticated()) {
                 $profile = $GLOBALS['folks_driver']->getProfile($user);
             } else {
                 $profile = $GLOBALS['folks_driver']->getRawProfile($user);
index acc7df5..e02f736 100644 (file)
@@ -50,7 +50,7 @@ class Folks_Notification {
         $result = false;
 
         if (empty($user)) {
-            if (Horde_Auth::isAuthenticated()) {
+            if ($GLOBALS['registry']->isAuthenticated()) {
                 $user = Horde_Auth::getAuth();
             } else {
                 return true;
@@ -92,7 +92,7 @@ class Folks_Notification {
         $result = false;
 
         if (empty($user)) {
-            if (Horde_Auth::isAuthenticated()) {
+            if ($GLOBALS['registry']->isAuthenticated()) {
                 $user = Horde_Auth::getAuth();
             } else {
                 return true;
index b6da13d..410b865 100644 (file)
@@ -94,7 +94,7 @@ $login_url = Horde_Util::addParameter(Horde::getServiceLink('login', 'folks'), '
 /*
  * We are already logged in?
  */
-if (Horde_Auth::isAuthenticated()) {
+if ($registry->isAuthenticated()) {
     if (empty($url_param)) {
         $url_param = Folks::getUrlFor('user', Horde_Auth::getAuth());
     }
index 046df1e..6bd39f5 100644 (file)
@@ -73,7 +73,7 @@ if (!empty($criteria)) {
     $users = array();
 }
 
-if (Horde_Auth::isAuthenticated()) {
+if ($registry->isAuthenticated()) {
     $queries = $folks_driver->getSavedSearch();
     if ($queries instanceof PEAR_Error) {
         $notification->push($queries);
@@ -92,7 +92,7 @@ require FOLKS_TEMPLATES . '/list/list.php';
 
 echo '<br />';
 $form->renderActive(null, null, null, 'post');
-if (Horde_Auth::isAuthenticated()) {
+if ($registry->isAuthenticated()) {
     require FOLKS_TEMPLATES . '/list/search.php';
 }
 
index 8827ce1..1e2e32a 100644 (file)
@@ -22,7 +22,7 @@ Horde::includeScriptFiles();
 <title><?php echo htmlspecialchars($page_title) ?></title>
 <link href="<?php echo Horde_Themes::img('favicon.ico', array('nohorde' => true)) ?>" rel="SHORTCUT ICON" />
 <link rel="alternate" type="application/rss+xml" href="<?php echo Folks::getUrlFor('feed', 'online') ?>" title="<?php echo _("Online users") ?>" />
-<?php if (Horde_Auth::isAuthenticated()): ?>
+<?php if ($GLOBALS['registry']->isAuthenticated()): ?>
 <link rel="alternate" type="application/rss+xml" href="<?php echo Folks::getUrlFor('feed', 'friends') ?>" title="<?php echo _("Online friends") ?>" />
 <link rel="alternate" type="application/rss+xml" href="<?php echo Folks::getUrlFor('feed', 'activity') ?>" title="<?php echo _("Friends activity") ?>" />
 <link rel="alternate" type="application/rss+xml" href="<?php echo Folks::getUrlFor('feed', 'know') ?>" title="<?php echo _("People you might know") ?>" />
index c5391cc..70e6a07 100644 (file)
@@ -50,7 +50,7 @@ include FOLKS_TEMPLATES . '/user/actions.php';
             echo '<span class="offline">' . _("Offline") . '</span>';
             if ($profile['last_online_on'] &&
                 ($profile['last_online'] == 'all' ||
-                Horde_Auth::isAuthenticated() && (
+                $GLOBALS['registry']->isAuthenticated() && (
                     $profile['last_online'] == 'authenticated' ||
                     $profile['last_online'] == 'friends' && $friends_driver->isFriend(Horde_Auth::getAuth())))
                 ) {
@@ -373,7 +373,7 @@ case 'never':
     break;
 
 case 'authenticated':
-    $allow_comments = Horde_Auth::isAuthenticated();
+    $allow_comments = $GLOBALS['registry']->isAuthenticated();
     if ($allow_comments) {
         if ($friends_driver->isBlacklisted(Horde_Auth::getAuth())) {
             $allow_comments = false;
@@ -394,7 +394,7 @@ case 'friends':
 
 default:
     $allow_comments = true;
-    if (Horde_Auth::isAuthenticated() && $friends_driver->isBlacklisted(Horde_Auth::getAuth())) {
+    if ($GLOBALS['registry']->isAuthenticated() && $friends_driver->isBlacklisted(Horde_Auth::getAuth())) {
         $allow_comments = false;
         $comments_reason = sprintf(_("You are on %s blacklist."), $user);
     }
index 90f520f..fb5b0f1 100644 (file)
@@ -31,7 +31,7 @@ $folks_driver->logView($user);
 
 // Get user activity
 if ($profile['activity_log'] == 'all' ||
-    Horde_Auth::isAuthenticated() && (
+    $registry->isAuthenticated() && (
         $profile['activity_log'] == 'authenticated' ||
         $profile['activity_log'] == 'friends' && $friends_driver->isFriend($user))
     ) {
@@ -83,7 +83,7 @@ case 'private':
 break;
 
 case 'public_authenticated':
-    if (Horde_Auth::isAuthenticated()) {
+    if ($registry->isAuthenticated()) {
         require FOLKS_TEMPLATES . '/user/user.php';
     } else {
         require FOLKS_TEMPLATES . '/user/authenticated.php';
index f1634ed..0269b06 100644 (file)
@@ -330,42 +330,6 @@ class Horde_Auth
     }
 
     /**
-     * Checks if there is a session with valid auth information. If there
-     * isn't, but the configured Auth driver supports transparent
-     * authentication, then we try that.
-     *
-     * @params array $options  Additional options:
-     * <pre>
-     * 'app' - (string) Check authentication for this app.
-     *         DEFAULT: Checks horde-wide authentication.
-     * </pre>
-     *
-     * @return boolean  Whether or not the user is authenticated.
-     * @throws Horde_Auth_Exception
-     */
-    static public function isAuthenticated($options = array())
-    {
-        /* Check for cached authentication results. */
-        if (self::getAuth()) {
-            $driver = (empty($options['app']) || ($options['app'] == 'horde'))
-                ? $GLOBALS['conf']['auth']['driver']
-                : $options['app'];
-
-            if (($_SESSION['horde_auth']['driver'] == $driver) ||
-                isset($_SESSION['horde_auth']['app'][$driver])) {
-                return self::checkExistingAuth();
-            }
-        }
-
-        /* Try transparent authentication. */
-        $auth = (empty($options['app']) || ($options['app'] == 'horde'))
-            ? $GLOBALS['injector']->getInstance('Horde_Auth')->getOb()
-            : $GLOBALS['injector']->getInstance('Horde_Auth')->getOb('application', array('app' => $options['app']));
-
-        return $auth->transparent();
-    }
-
-    /**
      * Check existing auth for triggers that might invalidate it.
      *
      * @return boolean  Is existing auth valid?
index 40cb792..e28fe7b 100644 (file)
@@ -1088,7 +1088,7 @@ class Horde_Registry
                 throw new Horde_Exception('User is not authorized', self::AUTH_FAILURE);
             }
             if (!$this->hasPermission($app, Horde_Perms::READ)) {
-                if (!Horde_Auth::isAuthenticated(array('app' => $app))) {
+                if (!$this->isAuthenticated(array('app' => $app))) {
                     throw new Horde_Exception('User is not authorized', self::AUTH_FAILURE);
                 }
 
@@ -1216,7 +1216,7 @@ class Horde_Registry
         /* Always do isAuthenticated() check first. You can be an admin, but
          * application auth != Horde admin auth. And there can *never* be
          * non-SHOW access to an application that requires authentication. */
-        if (!Horde_Auth::isAuthenticated(array('app' => $app)) &&
+        if (!$this->isAuthenticated(array('app' => $app)) &&
             $this->requireAuth($app) &&
             ($perms != Horde_Perms::SHOW)) {
             return false;
@@ -1637,4 +1637,39 @@ class Horde_Registry
             : $GLOBALS['injector']->getInstance('Horde_Auth')->getOb('application', array('app' => $app))->requireAuth();
     }
 
+    /**
+     * Checks if there is a session with valid auth information. If there
+     * isn't, but the configured Auth driver supports transparent
+     * authentication, then we try that.
+     *
+     * @params array $options  Additional options:
+     * <pre>
+     * 'app' - (string) Check authentication for this app.
+     *         DEFAULT: Checks horde-wide authentication.
+     * </pre>
+     *
+     * @return boolean  Whether or not the user is authenticated.
+     */
+    public function isAuthenticated($options = array())
+    {
+        /* Check for cached authentication results. */
+        if (Horde_Auth::getAuth()) {
+            $driver = (empty($options['app']) || ($options['app'] == 'horde'))
+                ? $GLOBALS['conf']['auth']['driver']
+                : $options['app'];
+
+            if (($_SESSION['horde_auth']['driver'] == $driver) ||
+                isset($_SESSION['horde_auth']['app'][$driver])) {
+                return Horde_Auth::checkExistingAuth();
+            }
+        }
+
+        /* Try transparent authentication. */
+        $auth = (empty($options['app']) || ($options['app'] == 'horde'))
+            ? $GLOBALS['injector']->getInstance('Horde_Auth')->getOb()
+            : $GLOBALS['injector']->getInstance('Horde_Auth')->getOb('application', array('app' => $options['app']));
+
+        return $auth->transparent();
+    }
+
 }
index dc95b52..6194647 100644 (file)
@@ -90,7 +90,7 @@ class Horde_Rpc_Phpgw extends Horde_Rpc
         }
 
         // Be authenticated or call system.login.
-        $authenticated = Horde_Auth::isAuthenticated() || $method== "phpgw/system/login";
+        $authenticated = $registry->isAuthenticated() || $method== "phpgw/system/login";
 
         if ($authenticated) {
             Horde::logMessage("rpc call $method allowed", 'NOTICE');
index d7a7030..e643541 100644 (file)
@@ -85,7 +85,7 @@ try {
 } catch (Horde_Exception $e) {}
 
 $app = Horde_Util::getFormData('app');
-$is_auth = Horde_Auth::isAuthenticated();
+$is_auth = $registry->isAuthenticated();
 
 /* This ensures index.php doesn't pick up the 'url' parameter. */
 $horde_login_url = '';
index 7863721..ca5ec7b 100644 (file)
@@ -88,7 +88,7 @@ function _max_upload_size()
 }
 
 // Is logged it?
-if (!Horde_Auth::isAuthenticated()) {
+if (!$registry->isAuthenticated()) {
     $notification->push(_("Only authenticated users can post news."), 'horde.warning');
     Horde_Auth::authenticateFailure('news');
 }
index 2feba13..1ae4439 100644 (file)
@@ -36,7 +36,7 @@ class Horde_Block_news_my_comments extends Horde_Block {
      */
     function _content()
     {
-        if (!Horde_Auth::isAuthenticated()) {
+        if (!$GLOBALS['registry']->isAuthenticated()) {
             return '';
         }
 
index 19a9eae..68e5818 100644 (file)
@@ -31,7 +31,7 @@ function _error($msg)
     exit;
 }
 
-if (!Horde_Auth::isAuthenticated()) {
+if (!$registry->isAuthenticated()) {
     _error(_("Only authenticated users can send mails."));
 }
 
index 077632c..fbabfda 100644 (file)
@@ -13,7 +13,7 @@
 
 require_once dirname(__FILE__) . '/lib/base.php';
 
-if (!Horde_Auth::isAuthenticated()) {
+if (!$registry->isAuthenticated()) {
     Horde_Auth::authenticateFailure('news');
 }
 
index a188ef9..f51fbf4 100644 (file)
@@ -34,7 +34,7 @@ if ($r_time = $prefs->getValue('summary_refresh_time')) {
 // block set for guests.
 $mybugs_layout = @unserialize($prefs->getValue('mybugs_layout'));
 if (!$mybugs_layout) {
-    if (Horde_Auth::isAuthenticated()) {
+    if ($registry->isAuthenticated()) {
         $mybugs_layout = array(
             array(array('app' => 'whups', 'params' => array('type' => 'mytickets', 'params' => false), 'height' => 1, 'width' => 1)),
             array(array('app' => 'whups', 'params' => array('type' => 'myrequests', 'params' => false), 'height' => 1, 'width' => 1)),